vue-editify 0.2.17 → 0.2.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. package/examples/App.vue +4 -12
  2. package/lib/components/colors/colors.vue.d.ts +9 -0
  3. package/lib/components/colors/props.d.ts +4 -0
  4. package/lib/components/tooltip/tooltip.vue.d.ts +1 -1
  5. package/lib/core/function.d.ts +112 -64
  6. package/lib/core/rule.d.ts +23 -17
  7. package/lib/core/shortcut.d.ts +36 -0
  8. package/lib/core/tool.d.ts +12 -16
  9. package/lib/editify/editify.vue.d.ts +162 -15
  10. package/lib/editify/props.d.ts +1 -5
  11. package/lib/editify/toolbar/props.d.ts +1 -1
  12. package/lib/editify/toolbar/toolbar.vue.d.ts +3 -3
  13. package/lib/editify.es.js +13660 -12954
  14. package/lib/editify.umd.js +2 -2
  15. package/lib/feature/align.d.ts +0 -14
  16. package/lib/feature/heading.d.ts +0 -14
  17. package/lib/feature/lineHeight.d.ts +0 -14
  18. package/lib/feature/orderList.d.ts +1 -3
  19. package/lib/feature/task.d.ts +0 -14
  20. package/lib/feature/unorderList.d.ts +1 -3
  21. package/lib/index.d.ts +164 -17
  22. package/package.json +2 -2
  23. package/src/components/button/button.vue +3 -3
  24. package/src/components/checkbox/checkbox.vue +1 -1
  25. package/src/components/colors/colors.vue +4 -4
  26. package/src/components/colors/props.ts +6 -1
  27. package/src/components/insertAttachment/insertAttachment.vue +1 -1
  28. package/src/components/insertImage/insertImage.vue +1 -1
  29. package/src/components/insertLink/insertLink.vue +1 -1
  30. package/src/components/insertVideo/insertVideo.vue +1 -1
  31. package/src/components/layer/layer.vue +9 -3
  32. package/src/components/tooltip/tooltip.vue +1 -1
  33. package/src/components/updateLink/updateLink.vue +1 -1
  34. package/src/core/function.ts +873 -491
  35. package/src/core/rule.ts +86 -368
  36. package/src/core/shortcut.ts +386 -0
  37. package/src/core/tool.ts +111 -159
  38. package/src/css/var.less +0 -10
  39. package/src/editify/editify.less +85 -39
  40. package/src/editify/editify.vue +204 -88
  41. package/src/editify/menu/menu.vue +2 -3
  42. package/src/editify/props.ts +1 -6
  43. package/src/editify/toolbar/props.ts +2 -2
  44. package/src/editify/toolbar/toolbar.vue +12 -12
  45. package/src/feature/align.ts +2 -62
  46. package/src/feature/attachment.ts +14 -27
  47. package/src/feature/backColor.ts +2 -1
  48. package/src/feature/bold.ts +1 -1
  49. package/src/feature/code.ts +1 -1
  50. package/src/feature/codeBlock.ts +3 -3
  51. package/src/feature/fontFamily.ts +1 -1
  52. package/src/feature/fontSize.ts +1 -1
  53. package/src/feature/foreColor.ts +2 -1
  54. package/src/feature/formatClear.ts +1 -1
  55. package/src/feature/fullScreen.ts +1 -1
  56. package/src/feature/heading.ts +5 -76
  57. package/src/feature/image.ts +1 -1
  58. package/src/feature/indent.ts +1 -1
  59. package/src/feature/infoBlock.ts +6 -37
  60. package/src/feature/italic.ts +1 -1
  61. package/src/feature/lineHeight.ts +2 -78
  62. package/src/feature/link.ts +1 -1
  63. package/src/feature/mathformula.ts +4 -51
  64. package/src/feature/orderList.ts +168 -37
  65. package/src/feature/quote.ts +3 -3
  66. package/src/feature/redo.ts +1 -1
  67. package/src/feature/separator.ts +1 -1
  68. package/src/feature/sourceView.ts +1 -1
  69. package/src/feature/strikethrough.ts +1 -1
  70. package/src/feature/sub.ts +1 -1
  71. package/src/feature/super.ts +1 -1
  72. package/src/feature/table.ts +3 -3
  73. package/src/feature/task.ts +4 -58
  74. package/src/feature/underline.ts +1 -1
  75. package/src/feature/undo.ts +1 -1
  76. package/src/feature/unorderList.ts +108 -37
  77. package/src/feature/video.ts +1 -1
  78. package/src/icon/iconfont.css +39 -3
  79. package/src/icon/iconfont.ttf +0 -0
  80. package/src/icon/iconfont.woff +0 -0
  81. package/src/index.ts +13 -11
  82. package/src/locale/en_US.ts +109 -110
  83. package/src/locale/zh_CN.ts +11 -12
  84. package/lib/feature/panel.d.ts +0 -18
  85. package/src/feature/panel.ts +0 -107
@@ -1,10 +1,8 @@
1
1
  import { computed, defineComponent, h, inject, PropType, ref, Ref } from 'vue'
2
2
  import { AlexEditor, AlexElementsRangeType } from 'alex-editor'
3
- import 'katex/dist/katex.css'
4
- import KaTex from 'katex'
5
3
  import { MenuMathformulaButtonType } from '@/core/tool'
6
4
  import { Button } from '@/components/button'
7
- import { getMatchElementByRange, hasLinkInRange, hasPreInRange } from '@/core/function'
5
+ import { getMatchElementByRange, hasLinkInRange, hasPreInRange, insertMathformula } from '@/core/function'
8
6
  import { Icon } from '@/components/icon'
9
7
  import { InsertMathformula } from '@/components/insertMathformula'
10
8
 
@@ -56,7 +54,7 @@ export const MathformulaMenuButton = defineComponent(
56
54
  zIndex: props.zIndex,
57
55
  type: 'select',
58
56
  hideScroll: true,
59
- title: $editTrans('insertMathformula'),
57
+ title: `${$editTrans('insertMathformula')}${props.config.shortcut?.title ? `【${props.config.shortcut?.title}】` : ''}`,
60
58
  leftBorder: props.config.leftBorder,
61
59
  rightBorder: props.config.rightBorder,
62
60
  active: !!getMatchElementByRange(editor.value, dataRangeCaches.value, {
@@ -77,53 +75,8 @@ export const MathformulaMenuButton = defineComponent(
77
75
  color: props.color,
78
76
  defaultLaTexContent: defaultLaTexContent.value,
79
77
  onInsert: (content: string) => {
80
- //如果公式文本框有内容则进行下一步处理
81
- if (content) {
82
- //获取选区所在的数学公式元素
83
- const mathformulaElement = getMatchElementByRange(editor.value, dataRangeCaches.value, {
84
- parsedom: 'span',
85
- marks: {
86
- 'data-editify-mathformula': true
87
- }
88
- })
89
- //如果在数学公式下
90
- if (mathformulaElement) {
91
- //清除该数学公式
92
- mathformulaElement.toEmpty()
93
- //移动光标到后一个元素上
94
- editor.value.range!.anchor.moveToStart(editor.value.getNextElement(mathformulaElement)!)
95
- editor.value.range!.focus.moveToStart(editor.value.getNextElement(mathformulaElement)!)
96
- }
97
- //定义转换后的mathml内容
98
- let mathml: string = ''
99
- try {
100
- //获取转换后的mathml
101
- mathml = KaTex.renderToString(content, {
102
- output: 'mathml',
103
- throwOnError: true
104
- })
105
- } catch (error) {
106
- mathml = ''
107
- if (typeof props.config!.handleError == 'function') {
108
- props.config!.handleError(error as Error)
109
- }
110
- }
111
- //如果mathml存在则表示数学公式渲染成功则插入到编辑器
112
- if (mathml) {
113
- //设置最终的html内容
114
- const html = `<span data-editify-mathformula="${content}" contenteditable="false">${mathml}</span>`
115
- //html内容转为元素数组
116
- const elements = editor.value.parseHtml(html)
117
- //插入编辑器
118
- editor.value.insertElement(elements[0])
119
- //移动光标到新插入的元素
120
- editor.value.range!.anchor.moveToEnd(elements[0])
121
- editor.value.range!.focus.moveToEnd(elements[0])
122
- //渲染
123
- editor.value.domRender()
124
- editor.value.rangeRender()
125
- }
126
- }
78
+ //插入数学公式
79
+ insertMathformula(editor.value, dataRangeCaches.value, content, props.config.handleError)
127
80
  //关闭浮层
128
81
  btnRef.value!.show = false
129
82
  }
@@ -1,7 +1,7 @@
1
- import { defineComponent, h, inject, PropType, Ref, ref } from 'vue'
2
- import { AlexElementsRangeType, AlexEditor } from 'alex-editor'
1
+ import { computed, defineComponent, h, inject, PropType, Ref } from 'vue'
2
+ import { AlexElementsRangeType, AlexEditor, AlexElement } from 'alex-editor'
3
3
  import { MenuButtonType } from '@/core/tool'
4
- import { hasPanelInRange, hasPreInRange, hasTableInRange, rangeIsInList, setList } from '@/core/function'
4
+ import { elementIsList, getMatchElementByRange, hasPreInRange, hasTableInRange, rangeIsInList, setList } from '@/core/function'
5
5
  import { Button } from '@/components/button'
6
6
  import { Icon } from '@/components/icon'
7
7
 
@@ -10,47 +10,179 @@ import { Icon } from '@/components/icon'
10
10
  */
11
11
  const FEATURE_NAME = 'orderList'
12
12
 
13
+ type orderType = 'decimal' | 'lower-roman' | 'upper-roman' | 'lower-alpha' | 'upper-alpha' | 'lower-greek' | 'cjk-ideographic'
14
+
13
15
  /**
14
16
  * 工具栏 - 有序列表
15
17
  */
16
- export const OrderListToolbarButton = defineComponent(
17
- (props, { expose }) => {
18
+ export const OrderListToolbar = defineComponent(
19
+ props => {
18
20
  const editor = inject<Ref<AlexEditor>>('editor')!
19
21
  const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
20
22
  const $editTrans = inject<(key: string) => any>('$editTrans')!
21
23
 
22
- const btnRef = ref<InstanceType<typeof Button> | null>(null)
23
-
24
- expose({
25
- btnRef
24
+ const active = computed<(val: orderType) => boolean>(() => {
25
+ return val => {
26
+ const el = getMatchElementByRange(editor.value, dataRangeCaches.value, {
27
+ parsedom: 'div',
28
+ marks: {
29
+ 'data-editify-list': 'ol'
30
+ }
31
+ })
32
+ if (el && el.marks!['data-editify-list-style']) {
33
+ return el.marks!['data-editify-list-style'] == val
34
+ }
35
+ return val == 'decimal'
36
+ }
26
37
  })
27
38
 
39
+ //设置前面列表的序标样式
40
+ const setPreviouseListStyle = (element: AlexElement, val: orderType) => {
41
+ element.marks!['data-editify-list-style'] = val
42
+ const previousElement = editor.value.getPreviousElement(element)
43
+ if (previousElement && elementIsList(previousElement, true)) {
44
+ setPreviouseListStyle(previousElement, val)
45
+ }
46
+ }
47
+
48
+ //设置后面列表的序标样式
49
+ const setNextListStyle = (element: AlexElement, val: orderType) => {
50
+ element.marks!['data-editify-list-style'] = val
51
+ const nextElement = editor.value.getNextElement(element)
52
+ if (nextElement && elementIsList(nextElement, true)) {
53
+ setNextListStyle(nextElement, val)
54
+ }
55
+ }
56
+
57
+ //设置列表序标样式
58
+ const setListStyle = (val: orderType) => {
59
+ const el = getMatchElementByRange(editor.value, dataRangeCaches.value, {
60
+ parsedom: 'div',
61
+ marks: {
62
+ 'data-editify-list': 'ol'
63
+ }
64
+ })!
65
+ el.marks!['data-editify-list-style'] = val
66
+ const previousElement = editor.value.getPreviousElement(el)
67
+ const nextElement = editor.value.getNextElement(el)
68
+ if (previousElement && elementIsList(previousElement, true)) {
69
+ setPreviouseListStyle(previousElement, val)
70
+ }
71
+ if (nextElement && elementIsList(nextElement, true)) {
72
+ setNextListStyle(nextElement, val)
73
+ }
74
+ editor.value.domRender()
75
+ editor.value.rangeRender()
76
+ }
77
+
28
78
  return () => {
29
- return props.config.show
30
- ? h(
31
- Button,
32
- {
33
- ref: btnRef,
34
- name: FEATURE_NAME,
35
- title: $editTrans('orderList'),
36
- tooltip: props.tooltip,
37
- color: props.color,
38
- zIndex: props.zIndex,
39
- leftBorder: props.config.leftBorder,
40
- rightBorder: props.config.rightBorder,
41
- active: rangeIsInList(editor.value, dataRangeCaches.value, true),
42
- disabled: props.config.disabled,
43
- onOperate: () => {
44
- setList(editor.value, dataRangeCaches.value, true)
45
- editor.value.domRender()
46
- editor.value.rangeRender()
47
- }
48
- },
49
- {
50
- default: () => h(Icon, { value: 'list-ordered' })
51
- }
52
- )
53
- : null
79
+ return [
80
+ h(
81
+ Button,
82
+ {
83
+ name: 'decimal',
84
+ title: $editTrans('decimal'),
85
+ tooltip: props.tooltip,
86
+ color: props.color,
87
+ zIndex: props.zIndex,
88
+ active: active.value('decimal'),
89
+ onOperate: () => setListStyle('decimal')
90
+ },
91
+ {
92
+ default: () => h(Icon, { value: 'list-decimal', style: { fontSize: '18px' } })
93
+ }
94
+ ),
95
+ h(
96
+ Button,
97
+ {
98
+ name: 'cjk-ideographic',
99
+ title: $editTrans('cjkIdeographic'),
100
+ tooltip: props.tooltip,
101
+ color: props.color,
102
+ zIndex: props.zIndex,
103
+ active: active.value('cjk-ideographic'),
104
+ onOperate: () => setListStyle('cjk-ideographic')
105
+ },
106
+ {
107
+ default: () => h(Icon, { value: 'list-cjk-ideographic', style: { fontSize: '18px' } })
108
+ }
109
+ ),
110
+ h(
111
+ Button,
112
+ {
113
+ name: 'lower-roman',
114
+ title: $editTrans('lowerRoman'),
115
+ tooltip: props.tooltip,
116
+ color: props.color,
117
+ zIndex: props.zIndex,
118
+ active: active.value('lower-roman'),
119
+ onOperate: () => setListStyle('lower-roman')
120
+ },
121
+ {
122
+ default: () => h(Icon, { value: 'list-lower-roman', style: { fontSize: '18px' } })
123
+ }
124
+ ),
125
+ h(
126
+ Button,
127
+ {
128
+ name: 'upper-roman',
129
+ title: $editTrans('upperRoman'),
130
+ tooltip: props.tooltip,
131
+ color: props.color,
132
+ zIndex: props.zIndex,
133
+ active: active.value('upper-roman'),
134
+ onOperate: () => setListStyle('upper-roman')
135
+ },
136
+ {
137
+ default: () => h(Icon, { value: 'list-upper-roman', style: { fontSize: '18px' } })
138
+ }
139
+ ),
140
+ h(
141
+ Button,
142
+ {
143
+ name: 'lower-alpha',
144
+ title: $editTrans('lowerAlpha'),
145
+ tooltip: props.tooltip,
146
+ color: props.color,
147
+ zIndex: props.zIndex,
148
+ active: active.value('lower-alpha'),
149
+ onOperate: () => setListStyle('lower-alpha')
150
+ },
151
+ {
152
+ default: () => h(Icon, { value: 'list-lower-alpha', style: { fontSize: '18px' } })
153
+ }
154
+ ),
155
+ h(
156
+ Button,
157
+ {
158
+ name: 'upper-alpha',
159
+ title: $editTrans('upperAlpha'),
160
+ tooltip: props.tooltip,
161
+ color: props.color,
162
+ zIndex: props.zIndex,
163
+ active: active.value('upper-alpha'),
164
+ onOperate: () => setListStyle('upper-alpha')
165
+ },
166
+ {
167
+ default: () => h(Icon, { value: 'list-upper-alpha', style: { fontSize: '18px' } })
168
+ }
169
+ ),
170
+ h(
171
+ Button,
172
+ {
173
+ name: 'lower-greek',
174
+ title: $editTrans('lowerGreek'),
175
+ tooltip: props.tooltip,
176
+ color: props.color,
177
+ zIndex: props.zIndex,
178
+ active: active.value('lower-greek'),
179
+ onOperate: () => setListStyle('lower-greek')
180
+ },
181
+ {
182
+ default: () => h(Icon, { value: 'list-lower-greek', style: { fontSize: '18px' } })
183
+ }
184
+ )
185
+ ]
54
186
  }
55
187
  },
56
188
  {
@@ -58,7 +190,6 @@ export const OrderListToolbarButton = defineComponent(
58
190
  props: {
59
191
  color: String,
60
192
  zIndex: Number,
61
- config: Object as PropType<MenuButtonType>,
62
193
  tooltip: Boolean
63
194
  }
64
195
  }
@@ -83,11 +214,11 @@ export const OrderListMenuButton = defineComponent(
83
214
  tooltip: props.tooltip,
84
215
  color: props.color,
85
216
  zIndex: props.zIndex,
86
- title: $editTrans('orderList'),
217
+ title: `${$editTrans('orderList')}${props.config.shortcut?.title ? `【${props.config.shortcut?.title}】` : ''}`,
87
218
  leftBorder: props.config.leftBorder,
88
219
  rightBorder: props.config.rightBorder,
89
220
  active: rangeIsInList(editor.value, dataRangeCaches.value, true),
90
- disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || hasTableInRange(editor.value, dataRangeCaches.value) || hasPanelInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
221
+ disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || hasTableInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
91
222
  onOperate: () => {
92
223
  setList(editor.value, dataRangeCaches.value, true)
93
224
  editor.value.domRender()
@@ -3,7 +3,7 @@ import { AlexEditor, AlexElementsRangeType } from 'alex-editor'
3
3
  import { Button } from '@/components/button'
4
4
  import { MenuSelectButtonType } from '@/core/tool'
5
5
  import { Icon } from '@/components/icon'
6
- import { hasPanelInRange, hasPreInRange, hasTableInRange, rangeIsInQuote, setQuote } from '@/core/function'
6
+ import { hasPreInRange, hasTableInRange, rangeIsInQuote, setQuote } from '@/core/function'
7
7
 
8
8
  /**
9
9
  * feature名称
@@ -29,11 +29,11 @@ export const QuoteMenuButton = defineComponent(
29
29
  tooltip: props.tooltip,
30
30
  color: props.color,
31
31
  zIndex: props.zIndex,
32
- title: $editTrans('quote'),
32
+ title: `${$editTrans('quote')}${props.config.shortcut?.title ? `【${props.config.shortcut?.title}】` : ''}`,
33
33
  leftBorder: props.config.leftBorder,
34
34
  rightBorder: props.config.rightBorder,
35
35
  active: rangeIsInQuote(editor.value, dataRangeCaches.value),
36
- disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || hasTableInRange(editor.value, dataRangeCaches.value) || hasPanelInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
36
+ disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || hasTableInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
37
37
  onOperate: () => {
38
38
  setQuote(editor.value, dataRangeCaches.value)
39
39
  editor.value.domRender()
@@ -33,7 +33,7 @@ export const RedoMenuButton = defineComponent(
33
33
  leftBorder: props.config.leftBorder,
34
34
  rightBorder: props.config.rightBorder,
35
35
  active: false,
36
- disabled: props.disabled || isSourceView.value || (rangeKey.value && editor.value.history && !editor.value.history.get(1)) || props.config.disabled,
36
+ disabled: props.disabled || isSourceView.value || (rangeKey.value && editor.value.history && editor.value.history.redoRecords.length == 0) || props.config.disabled,
37
37
  onOperate: () => redo()
38
38
  },
39
39
  {
@@ -29,7 +29,7 @@ export const SeparatorMenuButton = defineComponent(
29
29
  tooltip: props.tooltip,
30
30
  color: props.color,
31
31
  zIndex: props.zIndex,
32
- title: $editTrans('separator'),
32
+ title: `${$editTrans('separator')}${props.config.shortcut?.title ? `【${props.config.shortcut?.title}】` : ''}`,
33
33
  leftBorder: props.config.leftBorder,
34
34
  rightBorder: props.config.rightBorder,
35
35
  active: false,
@@ -27,7 +27,7 @@ export const SourceViewMenuButton = defineComponent(
27
27
  tooltip: props.tooltip,
28
28
  color: props.color,
29
29
  zIndex: props.zIndex,
30
- title: $editTrans('sourceView'),
30
+ title: `${$editTrans('sourceView')}${props.config.shortcut?.title ? `【${props.config.shortcut?.title}】` : ''}`,
31
31
  leftBorder: props.config.leftBorder,
32
32
  rightBorder: props.config.rightBorder,
33
33
  active: isSourceView.value,
@@ -97,7 +97,7 @@ export const StrikethroughMenuButton = defineComponent(
97
97
  tooltip: props.tooltip,
98
98
  color: props.color,
99
99
  zIndex: props.zIndex,
100
- title: $editTrans('strikethrough'),
100
+ title: `${$editTrans('strikethrough')}${props.config.shortcut?.title ? `【${props.config.shortcut?.title}】` : ''}`,
101
101
  leftBorder: props.config.leftBorder,
102
102
  rightBorder: props.config.rightBorder,
103
103
  active: active.value,
@@ -97,7 +97,7 @@ export const SubMenuButton = defineComponent(
97
97
  tooltip: props.tooltip,
98
98
  color: props.color,
99
99
  zIndex: props.zIndex,
100
- title: $editTrans('subscript'),
100
+ title: `${$editTrans('sub')}${props.config.shortcut?.title ? `【${props.config.shortcut?.title}】` : ''}`,
101
101
  leftBorder: props.config.leftBorder,
102
102
  rightBorder: props.config.rightBorder,
103
103
  disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
@@ -97,7 +97,7 @@ export const SuperMenuButton = defineComponent(
97
97
  tooltip: props.tooltip,
98
98
  color: props.color,
99
99
  zIndex: props.zIndex,
100
- title: $editTrans('superscript'),
100
+ title: `${$editTrans('super')}${props.config.shortcut?.title ? `【${props.config.shortcut?.title}】` : ''}`,
101
101
  leftBorder: props.config.leftBorder,
102
102
  rightBorder: props.config.rightBorder,
103
103
  active: active.value,
@@ -2,7 +2,7 @@ import { computed, defineComponent, h, inject, PropType, ref, Ref } from 'vue'
2
2
  import { AlexEditor, AlexElement, AlexElementsRangeType, AlexElementCreateConfigType } from 'alex-editor'
3
3
  import { Button } from '@/components/button'
4
4
  import { Icon } from '@/components/icon'
5
- import { getCellMergeElement, getCellSpanNumber, getMatchElementByElement, getMatchElementByRange, getTableSize, hasMathformulaInRange, hasPanelInRange, hasPreInRange, hasTableInRange, insertTable, setTableCellMerged } from '@/core/function'
5
+ import { getCellMergeElement, getCellSpanNumber, getMatchElementByElement, getMatchElementByRange, getTableSize, hasMathformulaInRange, hasPreInRange, hasTableInRange, insertTable, setTableCellMerged } from '@/core/function'
6
6
  import { MenuTableButtonType } from '@/core/tool'
7
7
  import { InsertTable } from '@/components/insertTable'
8
8
 
@@ -940,11 +940,11 @@ export const TableMenuButton = defineComponent(
940
940
  zIndex: props.zIndex,
941
941
  type: 'select',
942
942
  hideScroll: true,
943
- title: $editTrans('insertTable'),
943
+ title: `${$editTrans('insertTable')}${props.config.shortcut?.title ? `【${props.config.shortcut?.title}】` : ''}`,
944
944
  leftBorder: props.config.leftBorder,
945
945
  rightBorder: props.config.rightBorder,
946
946
  active: false,
947
- disabled: props.disabled || isSourceView.value || hasTableInRange(editor.value, dataRangeCaches.value) || hasPreInRange(editor.value, dataRangeCaches.value) || hasMathformulaInRange(editor.value, dataRangeCaches.value) || hasPanelInRange(editor.value, dataRangeCaches.value) || props.config.disabled
947
+ disabled: props.disabled || isSourceView.value || hasTableInRange(editor.value, dataRangeCaches.value) || hasPreInRange(editor.value, dataRangeCaches.value) || hasMathformulaInRange(editor.value, dataRangeCaches.value) || props.config.disabled
948
948
  },
949
949
  {
950
950
  default: () =>
@@ -1,7 +1,7 @@
1
- import { defineComponent, h, inject, PropType, Ref, ref } from 'vue'
1
+ import { defineComponent, h, inject, PropType, Ref } from 'vue'
2
2
  import { AlexElementsRangeType, AlexEditor } from 'alex-editor'
3
3
  import { MenuButtonType } from '@/core/tool'
4
- import { hasPanelInRange, hasPreInRange, hasTableInRange, rangeIsInTask, setTask } from '@/core/function'
4
+ import { hasPreInRange, hasTableInRange, rangeIsInTask, setTask } from '@/core/function'
5
5
  import { Button } from '@/components/button'
6
6
  import { Icon } from '@/components/icon'
7
7
 
@@ -10,60 +10,6 @@ import { Icon } from '@/components/icon'
10
10
  */
11
11
  const FEATURE_NAME = 'task'
12
12
 
13
- /**
14
- * 工具栏 - 任务列表
15
- */
16
- export const TaskToolbarButton = defineComponent(
17
- (props, { expose }) => {
18
- const editor = inject<Ref<AlexEditor>>('editor')!
19
- const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
20
- const $editTrans = inject<(key: string) => any>('$editTrans')!
21
-
22
- const btnRef = ref<InstanceType<typeof Button> | null>(null)
23
-
24
- expose({
25
- btnRef
26
- })
27
-
28
- return () => {
29
- return props.config.show
30
- ? h(
31
- Button,
32
- {
33
- ref: btnRef,
34
- name: FEATURE_NAME,
35
- title: $editTrans('task'),
36
- tooltip: props.tooltip,
37
- color: props.color,
38
- zIndex: props.zIndex,
39
- leftBorder: props.config.leftBorder,
40
- rightBorder: props.config.rightBorder,
41
- active: rangeIsInTask(editor.value, dataRangeCaches.value),
42
- disabled: props.config.disabled,
43
- onOperate: () => {
44
- setTask(editor.value, dataRangeCaches.value)
45
- editor.value.domRender()
46
- editor.value.rangeRender()
47
- }
48
- },
49
- {
50
- default: () => h(Icon, { value: 'task' })
51
- }
52
- )
53
- : null
54
- }
55
- },
56
- {
57
- name: `_${FEATURE_NAME}`,
58
- props: {
59
- color: String,
60
- zIndex: Number,
61
- config: Object as PropType<MenuButtonType>,
62
- tooltip: Boolean
63
- }
64
- }
65
- )
66
-
67
13
  /**
68
14
  * 菜单栏 - 任务列表
69
15
  */
@@ -83,11 +29,11 @@ export const TaskMenuButton = defineComponent(
83
29
  tooltip: props.tooltip,
84
30
  color: props.color,
85
31
  zIndex: props.zIndex,
86
- title: $editTrans('task'),
32
+ title: `${$editTrans('task')}${props.config.shortcut?.title ? `【${props.config.shortcut?.title}】` : ''}`,
87
33
  leftBorder: props.config.leftBorder,
88
34
  rightBorder: props.config.rightBorder,
89
35
  active: rangeIsInTask(editor.value, dataRangeCaches.value),
90
- disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || hasTableInRange(editor.value, dataRangeCaches.value) || hasPanelInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
36
+ disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || hasTableInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
91
37
  onOperate: () => {
92
38
  setTask(editor.value, dataRangeCaches.value)
93
39
  editor.value.domRender()
@@ -97,7 +97,7 @@ export const UnderlineMenuButton = defineComponent(
97
97
  tooltip: props.tooltip,
98
98
  color: props.color,
99
99
  zIndex: props.zIndex,
100
- title: $editTrans('underline'),
100
+ title: `${$editTrans('underline')}${props.config.shortcut?.title ? `【${props.config.shortcut?.title}】` : ''}`,
101
101
  leftBorder: props.config.leftBorder,
102
102
  rightBorder: props.config.rightBorder,
103
103
  disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
@@ -33,7 +33,7 @@ export const UndoMenuButton = defineComponent(
33
33
  leftBorder: props.config.leftBorder,
34
34
  rightBorder: props.config.rightBorder,
35
35
  active: false,
36
- disabled: props.disabled || isSourceView.value || (rangeKey.value && editor.value.history && !editor.value.history.get(-1)) || props.config.disabled,
36
+ disabled: props.disabled || isSourceView.value || (rangeKey.value && editor.value.history && editor.value.history.records.length <= 1) || props.config.disabled,
37
37
  onOperate: () => undo()
38
38
  },
39
39
  {