|
@@ -101,11 +101,10 @@ const listItem: NodeSpec = {
|
|
|
group: 'block',
|
|
group: 'block',
|
|
|
}
|
|
}
|
|
|
*/
|
|
*/
|
|
|
-
|
|
|
|
|
const listItem: NodeSpec = {
|
|
const listItem: NodeSpec = {
|
|
|
attrs: {
|
|
attrs: {
|
|
|
- textAlign: { default: '' }, // 对应 CSS text-align
|
|
|
|
|
- textAlignLast: { default: '' }, // 对应 CSS text-align-last
|
|
|
|
|
|
|
+ textAlign: { default: '' },
|
|
|
|
|
+ textAlignLast: { default: '' },
|
|
|
textIndent: { default: '' },
|
|
textIndent: { default: '' },
|
|
|
marginTop: { default: '' },
|
|
marginTop: { default: '' },
|
|
|
marginBottom: { default: '' },
|
|
marginBottom: { default: '' },
|
|
@@ -116,6 +115,7 @@ const listItem: NodeSpec = {
|
|
|
paddingRight: { default: '' },
|
|
paddingRight: { default: '' },
|
|
|
paddingBottom: { default: '' },
|
|
paddingBottom: { default: '' },
|
|
|
paddingLeft: { default: '' },
|
|
paddingLeft: { default: '' },
|
|
|
|
|
+ whiteSpace: { default: 'normal' }, // 新增 white-space 属性
|
|
|
},
|
|
},
|
|
|
content: 'paragraph block*',
|
|
content: 'paragraph block*',
|
|
|
group: 'block',
|
|
group: 'block',
|
|
@@ -138,6 +138,7 @@ const listItem: NodeSpec = {
|
|
|
const paddingRight = style.paddingRight || '';
|
|
const paddingRight = style.paddingRight || '';
|
|
|
const paddingBottom = style.paddingBottom || '';
|
|
const paddingBottom = style.paddingBottom || '';
|
|
|
const paddingLeft = style.paddingLeft || '';
|
|
const paddingLeft = style.paddingLeft || '';
|
|
|
|
|
+ const whiteSpace = style.whiteSpace || 'normal'; // 读取 white-space
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
textAlign,
|
|
textAlign,
|
|
@@ -152,6 +153,7 @@ const listItem: NodeSpec = {
|
|
|
paddingRight,
|
|
paddingRight,
|
|
|
paddingBottom,
|
|
paddingBottom,
|
|
|
paddingLeft,
|
|
paddingLeft,
|
|
|
|
|
+ whiteSpace, // 返回 whiteSpace
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -170,6 +172,7 @@ const listItem: NodeSpec = {
|
|
|
paddingRight,
|
|
paddingRight,
|
|
|
paddingBottom,
|
|
paddingBottom,
|
|
|
paddingLeft,
|
|
paddingLeft,
|
|
|
|
|
+ whiteSpace, // 获取 whiteSpace
|
|
|
} = node.attrs;
|
|
} = node.attrs;
|
|
|
|
|
|
|
|
let style = '';
|
|
let style = '';
|
|
@@ -192,6 +195,9 @@ const listItem: NodeSpec = {
|
|
|
if (paddingRight) style += `padding-right: ${paddingRight};`;
|
|
if (paddingRight) style += `padding-right: ${paddingRight};`;
|
|
|
if (paddingBottom) style += `padding-bottom: ${paddingBottom};`;
|
|
if (paddingBottom) style += `padding-bottom: ${paddingBottom};`;
|
|
|
if (paddingLeft) style += `padding-left: ${paddingLeft};`;
|
|
if (paddingLeft) style += `padding-left: ${paddingLeft};`;
|
|
|
|
|
+ if (whiteSpace && whiteSpace !== 'normal') {
|
|
|
|
|
+ style += `white-space: ${whiteSpace};`; // 添加 white-space
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
const attrs: { style?: string } = {};
|
|
const attrs: { style?: string } = {};
|
|
|
if (style) attrs.style = style;
|
|
if (style) attrs.style = style;
|
|
@@ -200,12 +206,11 @@ const listItem: NodeSpec = {
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-
|
|
|
|
|
const paragraph: NodeSpec = {
|
|
const paragraph: NodeSpec = {
|
|
|
- whitespace: "pre",
|
|
|
|
|
|
|
+ whitespace: "pre", // 此属性控制 ProseMirror 内部空格处理,与 CSS white-space 无关,保留不变
|
|
|
attrs: {
|
|
attrs: {
|
|
|
- textAlign: { default: '' }, // 对应 CSS text-align
|
|
|
|
|
- textAlignLast: { default: '' }, // 对应 CSS text-align-last
|
|
|
|
|
|
|
+ textAlign: { default: '' },
|
|
|
|
|
+ textAlignLast: { default: '' },
|
|
|
indent: { default: 0 },
|
|
indent: { default: 0 },
|
|
|
textIndent: { default: 0 },
|
|
textIndent: { default: 0 },
|
|
|
marginTop: { default: '' },
|
|
marginTop: { default: '' },
|
|
@@ -217,6 +222,7 @@ const paragraph: NodeSpec = {
|
|
|
paddingRight: { default: '' },
|
|
paddingRight: { default: '' },
|
|
|
paddingBottom: { default: '' },
|
|
paddingBottom: { default: '' },
|
|
|
paddingLeft: { default: '' },
|
|
paddingLeft: { default: '' },
|
|
|
|
|
+ whiteSpace: { default: 'normal' }, // 新增 white-space 属性
|
|
|
},
|
|
},
|
|
|
content: 'inline*',
|
|
content: 'inline*',
|
|
|
group: 'block',
|
|
group: 'block',
|
|
@@ -239,6 +245,7 @@ const paragraph: NodeSpec = {
|
|
|
const paddingRight = style.paddingRight || '';
|
|
const paddingRight = style.paddingRight || '';
|
|
|
const paddingBottom = style.paddingBottom || '';
|
|
const paddingBottom = style.paddingBottom || '';
|
|
|
const paddingLeft = style.paddingLeft || '';
|
|
const paddingLeft = style.paddingLeft || '';
|
|
|
|
|
+ const whiteSpace = style.whiteSpace || 'normal'; // 读取 white-space
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
textAlign,
|
|
textAlign,
|
|
@@ -253,6 +260,7 @@ const paragraph: NodeSpec = {
|
|
|
paddingRight,
|
|
paddingRight,
|
|
|
paddingBottom,
|
|
paddingBottom,
|
|
|
paddingLeft,
|
|
paddingLeft,
|
|
|
|
|
+ whiteSpace, // 返回 whiteSpace
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -279,6 +287,7 @@ const paragraph: NodeSpec = {
|
|
|
paddingRight,
|
|
paddingRight,
|
|
|
paddingBottom,
|
|
paddingBottom,
|
|
|
paddingLeft,
|
|
paddingLeft,
|
|
|
|
|
+ whiteSpace, // 获取 whiteSpace
|
|
|
} = node.attrs;
|
|
} = node.attrs;
|
|
|
|
|
|
|
|
let style = '';
|
|
let style = '';
|
|
@@ -301,6 +310,9 @@ const paragraph: NodeSpec = {
|
|
|
if (paddingRight) style += `padding-right: ${paddingRight};`;
|
|
if (paddingRight) style += `padding-right: ${paddingRight};`;
|
|
|
if (paddingBottom) style += `padding-bottom: ${paddingBottom};`;
|
|
if (paddingBottom) style += `padding-bottom: ${paddingBottom};`;
|
|
|
if (paddingLeft) style += `padding-left: ${paddingLeft};`;
|
|
if (paddingLeft) style += `padding-left: ${paddingLeft};`;
|
|
|
|
|
+ if (whiteSpace && whiteSpace !== 'normal') {
|
|
|
|
|
+ style += `white-space: ${whiteSpace};`; // 添加 white-space
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
const attr: Attr = { style };
|
|
const attr: Attr = { style };
|
|
|
return ['p', attr, 0];
|
|
return ['p', attr, 0];
|
|
@@ -317,7 +329,6 @@ const hardBreak: NodeSpec = {
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-
|
|
|
|
|
const {
|
|
const {
|
|
|
doc,
|
|
doc,
|
|
|
blockquote,
|
|
blockquote,
|