|
@@ -101,16 +101,17 @@ const listItem: NodeSpec = {
|
|
|
group: 'block',
|
|
group: 'block',
|
|
|
}
|
|
}
|
|
|
*/
|
|
*/
|
|
|
|
|
+
|
|
|
const listItem: NodeSpec = {
|
|
const listItem: NodeSpec = {
|
|
|
attrs: {
|
|
attrs: {
|
|
|
- align: { default: '' },
|
|
|
|
|
|
|
+ textAlign: { default: '' }, // 对应 CSS text-align
|
|
|
|
|
+ textAlignLast: { default: '' }, // 对应 CSS text-align-last
|
|
|
textIndent: { default: '' },
|
|
textIndent: { default: '' },
|
|
|
marginTop: { default: '' },
|
|
marginTop: { default: '' },
|
|
|
marginBottom: { default: '' },
|
|
marginBottom: { default: '' },
|
|
|
marginLeft: { default: '' },
|
|
marginLeft: { default: '' },
|
|
|
marginRight: { default: '' },
|
|
marginRight: { default: '' },
|
|
|
lineHeight: { default: '' },
|
|
lineHeight: { default: '' },
|
|
|
- // ✅ 新增 padding 属性
|
|
|
|
|
paddingTop: { default: '' },
|
|
paddingTop: { default: '' },
|
|
|
paddingRight: { default: '' },
|
|
paddingRight: { default: '' },
|
|
|
paddingBottom: { default: '' },
|
|
paddingBottom: { default: '' },
|
|
@@ -133,17 +134,14 @@ const listItem: NodeSpec = {
|
|
|
const marginLeft = style.marginLeft || '';
|
|
const marginLeft = style.marginLeft || '';
|
|
|
const marginRight = style.marginRight || '';
|
|
const marginRight = style.marginRight || '';
|
|
|
const lineHeight = style.lineHeight || '';
|
|
const lineHeight = style.lineHeight || '';
|
|
|
- // ✅ 读取 padding 值
|
|
|
|
|
const paddingTop = style.paddingTop || '';
|
|
const paddingTop = style.paddingTop || '';
|
|
|
const paddingRight = style.paddingRight || '';
|
|
const paddingRight = style.paddingRight || '';
|
|
|
const paddingBottom = style.paddingBottom || '';
|
|
const paddingBottom = style.paddingBottom || '';
|
|
|
const paddingLeft = style.paddingLeft || '';
|
|
const paddingLeft = style.paddingLeft || '';
|
|
|
|
|
|
|
|
- let align = textAlign || textAlignLast || '';
|
|
|
|
|
- align = /^(left|right|center|justify)$/.test(align) ? align : '';
|
|
|
|
|
-
|
|
|
|
|
return {
|
|
return {
|
|
|
- align,
|
|
|
|
|
|
|
+ textAlign,
|
|
|
|
|
+ textAlignLast,
|
|
|
textIndent,
|
|
textIndent,
|
|
|
marginTop,
|
|
marginTop,
|
|
|
marginBottom,
|
|
marginBottom,
|
|
@@ -160,7 +158,8 @@ const listItem: NodeSpec = {
|
|
|
],
|
|
],
|
|
|
toDOM(node) {
|
|
toDOM(node) {
|
|
|
const {
|
|
const {
|
|
|
- align,
|
|
|
|
|
|
|
+ textAlign,
|
|
|
|
|
+ textAlignLast,
|
|
|
textIndent,
|
|
textIndent,
|
|
|
marginTop,
|
|
marginTop,
|
|
|
marginBottom,
|
|
marginBottom,
|
|
@@ -175,18 +174,20 @@ const listItem: NodeSpec = {
|
|
|
|
|
|
|
|
let style = '';
|
|
let style = '';
|
|
|
|
|
|
|
|
- if (align) {
|
|
|
|
|
- style += `text-align: ${align}; text-align-last: ${align};`;
|
|
|
|
|
|
|
+ if (textAlign && textAlign !== 'left') {
|
|
|
|
|
+ style += `text-align: ${textAlign};`;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (textAlignLast) {
|
|
|
|
|
+ style += `text-align-last: ${textAlignLast};`;
|
|
|
}
|
|
}
|
|
|
if (textIndent) {
|
|
if (textIndent) {
|
|
|
- style += `text-indent: ${textIndent};`;
|
|
|
|
|
|
|
+ style += `text-indent: (100% - ${textIndent});`;
|
|
|
}
|
|
}
|
|
|
if (marginTop) style += `margin-top: ${marginTop};`;
|
|
if (marginTop) style += `margin-top: ${marginTop};`;
|
|
|
if (marginBottom) style += `margin-bottom: ${marginBottom};`;
|
|
if (marginBottom) style += `margin-bottom: ${marginBottom};`;
|
|
|
if (marginLeft) style += `margin-left: ${marginLeft};`;
|
|
if (marginLeft) style += `margin-left: ${marginLeft};`;
|
|
|
if (marginRight) style += `margin-right: ${marginRight};`;
|
|
if (marginRight) style += `margin-right: ${marginRight};`;
|
|
|
- if (lineHeight) style += `line-height: ${lineHeight};`;
|
|
|
|
|
- // ✅ 输出 padding
|
|
|
|
|
|
|
+ if (lineHeight) style += `line-height: ${lineHeight * 1.2};`;
|
|
|
if (paddingTop) style += `padding-top: ${paddingTop};`;
|
|
if (paddingTop) style += `padding-top: ${paddingTop};`;
|
|
|
if (paddingRight) style += `padding-right: ${paddingRight};`;
|
|
if (paddingRight) style += `padding-right: ${paddingRight};`;
|
|
|
if (paddingBottom) style += `padding-bottom: ${paddingBottom};`;
|
|
if (paddingBottom) style += `padding-bottom: ${paddingBottom};`;
|
|
@@ -199,9 +200,12 @@ const listItem: NodeSpec = {
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+
|
|
|
const paragraph: NodeSpec = {
|
|
const paragraph: NodeSpec = {
|
|
|
|
|
+ whitespace: "pre",
|
|
|
attrs: {
|
|
attrs: {
|
|
|
- align: { default: '' },
|
|
|
|
|
|
|
+ textAlign: { default: '' }, // 对应 CSS text-align
|
|
|
|
|
+ textAlignLast: { default: '' }, // 对应 CSS text-align-last
|
|
|
indent: { default: 0 },
|
|
indent: { default: 0 },
|
|
|
textIndent: { default: 0 },
|
|
textIndent: { default: 0 },
|
|
|
marginTop: { default: '' },
|
|
marginTop: { default: '' },
|
|
@@ -209,7 +213,6 @@ const paragraph: NodeSpec = {
|
|
|
marginLeft: { default: '' },
|
|
marginLeft: { default: '' },
|
|
|
marginRight: { default: '' },
|
|
marginRight: { default: '' },
|
|
|
lineHeight: { default: '' },
|
|
lineHeight: { default: '' },
|
|
|
- // ✅ 新增 padding 属性
|
|
|
|
|
paddingTop: { default: '' },
|
|
paddingTop: { default: '' },
|
|
|
paddingRight: { default: '' },
|
|
paddingRight: { default: '' },
|
|
|
paddingBottom: { default: '' },
|
|
paddingBottom: { default: '' },
|
|
@@ -225,23 +228,21 @@ const paragraph: NodeSpec = {
|
|
|
const style = el.style;
|
|
const style = el.style;
|
|
|
|
|
|
|
|
const textAlign = style.textAlign || '';
|
|
const textAlign = style.textAlign || '';
|
|
|
- let align = el.getAttribute('align') || textAlign || '';
|
|
|
|
|
- align = /^(left|right|center|justify)$/.test(align) ? align : '';
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const textAlignLast = style.textAlignLast || '';
|
|
|
const marginTop = style.marginTop || '';
|
|
const marginTop = style.marginTop || '';
|
|
|
const marginBottom = style.marginBottom || '';
|
|
const marginBottom = style.marginBottom || '';
|
|
|
const marginLeft = style.marginLeft || '';
|
|
const marginLeft = style.marginLeft || '';
|
|
|
const marginRight = style.marginRight || '';
|
|
const marginRight = style.marginRight || '';
|
|
|
const textIndent = style.textIndent || '';
|
|
const textIndent = style.textIndent || '';
|
|
|
const lineHeight = style.lineHeight || '';
|
|
const lineHeight = style.lineHeight || '';
|
|
|
- // ✅ 读取 padding
|
|
|
|
|
const paddingTop = style.paddingTop || '';
|
|
const paddingTop = style.paddingTop || '';
|
|
|
const paddingRight = style.paddingRight || '';
|
|
const paddingRight = style.paddingRight || '';
|
|
|
const paddingBottom = style.paddingBottom || '';
|
|
const paddingBottom = style.paddingBottom || '';
|
|
|
const paddingLeft = style.paddingLeft || '';
|
|
const paddingLeft = style.paddingLeft || '';
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
- align,
|
|
|
|
|
|
|
+ textAlign,
|
|
|
|
|
+ textAlignLast,
|
|
|
textIndent,
|
|
textIndent,
|
|
|
marginTop,
|
|
marginTop,
|
|
|
marginBottom,
|
|
marginBottom,
|
|
@@ -266,7 +267,8 @@ const paragraph: NodeSpec = {
|
|
|
],
|
|
],
|
|
|
toDOM: (node: Node) => {
|
|
toDOM: (node: Node) => {
|
|
|
const {
|
|
const {
|
|
|
- align,
|
|
|
|
|
|
|
+ textAlign,
|
|
|
|
|
+ textAlignLast,
|
|
|
textIndent,
|
|
textIndent,
|
|
|
marginTop,
|
|
marginTop,
|
|
|
marginBottom,
|
|
marginBottom,
|
|
@@ -281,18 +283,20 @@ const paragraph: NodeSpec = {
|
|
|
|
|
|
|
|
let style = '';
|
|
let style = '';
|
|
|
|
|
|
|
|
- if (align && align !== 'left') {
|
|
|
|
|
- style += `text-align: ${align};text-align-last: ${align};`;
|
|
|
|
|
|
|
+ if (textAlign && textAlign !== 'left') {
|
|
|
|
|
+ style += `text-align: ${textAlign};`;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (textAlignLast) {
|
|
|
|
|
+ style += `text-align-last: ${textAlignLast};`;
|
|
|
}
|
|
}
|
|
|
if (textIndent) {
|
|
if (textIndent) {
|
|
|
- style += `text-indent: ${textIndent};`;
|
|
|
|
|
|
|
+ style += `text-indent: (100% - ${textIndent});`;
|
|
|
}
|
|
}
|
|
|
if (marginTop) style += `margin-top: ${marginTop};`;
|
|
if (marginTop) style += `margin-top: ${marginTop};`;
|
|
|
if (marginBottom) style += `margin-bottom: ${marginBottom};`;
|
|
if (marginBottom) style += `margin-bottom: ${marginBottom};`;
|
|
|
if (marginLeft) style += `margin-left: ${marginLeft};`;
|
|
if (marginLeft) style += `margin-left: ${marginLeft};`;
|
|
|
if (marginRight) style += `margin-right: ${marginRight};`;
|
|
if (marginRight) style += `margin-right: ${marginRight};`;
|
|
|
- if (lineHeight) style += `line-height: ${lineHeight};`;
|
|
|
|
|
- // ✅ 输出 padding
|
|
|
|
|
|
|
+ if (lineHeight) style += `line-height: ${lineHeight * 1.2};`;
|
|
|
if (paddingTop) style += `padding-top: ${paddingTop};`;
|
|
if (paddingTop) style += `padding-top: ${paddingTop};`;
|
|
|
if (paddingRight) style += `padding-right: ${paddingRight};`;
|
|
if (paddingRight) style += `padding-right: ${paddingRight};`;
|
|
|
if (paddingBottom) style += `padding-bottom: ${paddingBottom};`;
|
|
if (paddingBottom) style += `padding-bottom: ${paddingBottom};`;
|