|
|
@@ -93,7 +93,7 @@ export default {
|
|
|
type: [String, Boolean],
|
|
|
/* eslint-disable max-len */
|
|
|
default:
|
|
|
- 'fontselect fontsizeselect forecolor backcolor lineheight paragraphSpacing letterSpacing fullwidthspace indent outdent customUnderline bold italic strikethrough alignleft aligncenter alignright bullist numlist dotEmphasis image media link blockquote hr mathjax',
|
|
|
+ 'fontselect fontsizeselect forecolor backcolor lineheight paragraphSpacing letterSpacing fullwidthspace indent outdent rightindent rightoutdent customUnderline bold italic strikethrough alignleft aligncenter alignright bullist numlist dotEmphasis image media link blockquote hr mathjax',
|
|
|
},
|
|
|
wordlimitNum: {
|
|
|
type: [Number, Boolean],
|
|
|
@@ -211,8 +211,8 @@ export default {
|
|
|
plugins: 'link lists image hr media autoresize ax_wordlimit paste', // 移除 lineheight
|
|
|
toolbar: this.toolbar, // 工具栏
|
|
|
lineheight_formats: '0.5 1.0 1.2 1.5 2.0 2.5 3.0', // 行高选项(倍数)
|
|
|
- paragraphheight_formats: [1.0, 1.2, 1.5, 2.0, 2.5, 3.0], // 段落间距
|
|
|
- letterSpacing_formats: [1.0, 1.2, 1.5, 2.0, 2.5, 3.0], // 字间距选项
|
|
|
+ paragraphheight_formats: [0.5, 1.0, 1.2, 1.5, 2.0, 2.5, 3.0], // 段落间距
|
|
|
+ letterSpacing_formats: [0.5, 1.0, 1.2, 1.5, 2.0, 2.5, 3.0], // 字间距选项
|
|
|
contextmenu: false, // 右键菜单
|
|
|
menubar: false, // 菜单栏
|
|
|
branding: false, // 品牌
|
|
|
@@ -269,6 +269,12 @@ export default {
|
|
|
remove_similar: true,
|
|
|
});
|
|
|
}
|
|
|
+ if (!editor.formatter.has('rightIndent')) {
|
|
|
+ editor.formatter.register('rightIndent', {
|
|
|
+ block: 'p',
|
|
|
+ styles: { 'padding-right': '40px' },
|
|
|
+ });
|
|
|
+ }
|
|
|
if (!editor.formatter.has('coloredunderline')) {
|
|
|
editor.formatter.register('coloredunderline', {
|
|
|
inline: 'span',
|
|
|
@@ -416,7 +422,7 @@ export default {
|
|
|
});
|
|
|
items.push({
|
|
|
type: 'menuitem',
|
|
|
- text: '清除间距',
|
|
|
+ text: '清除段落间距',
|
|
|
onAction: () => {
|
|
|
// 清除所有间距格式
|
|
|
this.init.paragraphheight_formats.forEach((config) => {
|
|
|
@@ -509,6 +515,70 @@ export default {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
+ // 注册右缩进自定义图标
|
|
|
+ editor.ui.registry.addIcon(
|
|
|
+ 'rightindent',
|
|
|
+ '<svg viewBox="0 0 18 18" width="18" height="18"><rect x="1.5" y="2" width="15" height="1.8" rx="0.9" fill="currentColor"/><rect x="1.5" y="6.6" width="9" height="1.8" rx="0.9" fill="currentColor"/><rect x="1.5" y="11.2" width="9" height="1.8" rx="0.9" fill="currentColor"/><rect x="1.5" y="15.8" width="15" height="1.8" rx="0.9" fill="currentColor"/><polyline points="16.5,8 14.625,10 16.5,12" stroke="currentColor" stroke-width="1.8" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
|
+ );
|
|
|
+ editor.ui.registry.addIcon(
|
|
|
+ 'rightoutdent',
|
|
|
+ '<svg viewBox="0 0 18 18" width="18" height="18"><rect x="1.5" y="2" width="15" height="1.8" rx="0.9" fill="currentColor"/><rect x="1.5" y="6.6" width="9" height="1.8" rx="0.9" fill="currentColor"/><rect x="1.5" y="11.2" width="9" height="1.8" rx="0.9" fill="currentColor"/><rect x="1.5" y="15.8" width="15" height="1.8" rx="0.9" fill="currentColor"/><polyline points="15,8 16.875,10 15,12" stroke="currentColor" stroke-width="1.8" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
|
+ );
|
|
|
+
|
|
|
+ // 获取当前段落的右缩进像素值
|
|
|
+ const getRightIndentPx = (editor) => {
|
|
|
+ const node = editor.selection.getNode();
|
|
|
+ const p = editor.dom.getParent(node, 'p');
|
|
|
+ if (!p) return 0;
|
|
|
+ const pr = editor.dom.getStyle(p, 'padding-right', true);
|
|
|
+ const num = parseFloat(pr);
|
|
|
+ return isNaN(num) ? 0 : num;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 增加右缩进按钮
|
|
|
+ editor.ui.registry.addButton('rightindent', {
|
|
|
+ icon: 'rightindent',
|
|
|
+ tooltip: '增加右缩进',
|
|
|
+ onAction: () => {
|
|
|
+ const cur = getRightIndentPx(editor);
|
|
|
+ const newVal = cur + 40;
|
|
|
+ editor.formatter.remove('rightIndent');
|
|
|
+ editor.formatter.register('rightIndent', {
|
|
|
+ block: 'p',
|
|
|
+ styles: { 'padding-right': `${newVal}px` },
|
|
|
+ });
|
|
|
+ editor.formatter.apply('rightIndent');
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ // 减少右缩进按钮
|
|
|
+ editor.ui.registry.addButton('rightoutdent', {
|
|
|
+ icon: 'rightoutdent',
|
|
|
+ tooltip: '减少右缩进',
|
|
|
+ onAction: () => {
|
|
|
+ const cur = getRightIndentPx(editor);
|
|
|
+ if (cur <= 40) {
|
|
|
+ editor.formatter.remove('rightIndent');
|
|
|
+ } else {
|
|
|
+ const newVal = cur - 40;
|
|
|
+ editor.formatter.remove('rightIndent');
|
|
|
+ editor.formatter.register('rightIndent', {
|
|
|
+ block: 'p',
|
|
|
+ styles: { 'padding-right': `${newVal}px` },
|
|
|
+ });
|
|
|
+ editor.formatter.apply('rightIndent');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onSetup: (api) => {
|
|
|
+ const handler = () => {
|
|
|
+ const cur = getRightIndentPx(editor);
|
|
|
+ api.setDisabled(cur <= 0);
|
|
|
+ };
|
|
|
+ editor.on('NodeChange', handler);
|
|
|
+ return () => editor.off('NodeChange', handler);
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
// 注册自定义全角空格图标
|
|
|
editor.ui.registry.addIcon(
|
|
|
'fullwidthspace',
|