vue-editify 0.2.14 → 0.2.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. package/examples/App.vue +41 -88
  2. package/lib/components/button/button.vue.d.ts +62 -60
  3. package/lib/components/button/index.d.ts +4 -0
  4. package/lib/components/button/props.d.ts +12 -1
  5. package/lib/components/checkbox/checkbox.vue.d.ts +9 -9
  6. package/lib/components/checkbox/index.d.ts +4 -0
  7. package/lib/components/checkbox/props.d.ts +2 -2
  8. package/lib/components/colors/colors.vue.d.ts +4 -4
  9. package/lib/components/colors/index.d.ts +4 -0
  10. package/lib/components/colors/props.d.ts +2 -2
  11. package/lib/components/icon/index.d.ts +4 -0
  12. package/lib/components/insertAttachment/index.d.ts +4 -0
  13. package/lib/{plugins/attachment → components}/insertAttachment/insertAttachment.vue.d.ts +3 -3
  14. package/lib/{plugins/attachment → components}/insertAttachment/props.d.ts +1 -1
  15. package/lib/components/insertImage/index.d.ts +4 -0
  16. package/lib/components/insertImage/insertImage.vue.d.ts +3 -3
  17. package/lib/components/insertImage/props.d.ts +1 -1
  18. package/lib/components/insertLink/index.d.ts +4 -0
  19. package/lib/components/insertLink/insertLink.vue.d.ts +6 -6
  20. package/lib/components/insertLink/props.d.ts +3 -3
  21. package/lib/components/insertMathformula/index.d.ts +4 -0
  22. package/lib/{plugins/mathformula → components}/insertMathformula/insertMathformula.vue.d.ts +3 -3
  23. package/lib/{plugins/mathformula → components}/insertMathformula/props.d.ts +2 -2
  24. package/lib/components/insertTable/index.d.ts +4 -0
  25. package/lib/components/insertTable/insertTable.vue.d.ts +3 -3
  26. package/lib/components/insertTable/props.d.ts +2 -2
  27. package/lib/components/insertVideo/index.d.ts +4 -0
  28. package/lib/components/insertVideo/insertVideo.vue.d.ts +3 -3
  29. package/lib/components/insertVideo/props.d.ts +1 -1
  30. package/lib/components/layer/index.d.ts +4 -0
  31. package/lib/components/layer/layer.vue.d.ts +10 -8
  32. package/lib/components/tooltip/index.d.ts +4 -0
  33. package/lib/components/tooltip/tooltip.vue.d.ts +6 -4
  34. package/lib/components/triangle/index.d.ts +4 -0
  35. package/lib/components/triangle/triangle.vue.d.ts +1 -1
  36. package/lib/components/updateLink/index.d.ts +4 -0
  37. package/lib/components/updateLink/props.d.ts +17 -0
  38. package/lib/components/updateLink/updateLink.vue.d.ts +38 -0
  39. package/lib/core/function.d.ts +113 -36
  40. package/lib/core/rule.d.ts +20 -0
  41. package/lib/core/tool.d.ts +36 -34
  42. package/lib/editify/editify.vue.d.ts +18 -28
  43. package/lib/editify/menu/index.d.ts +4 -0
  44. package/lib/{components → editify}/menu/menu.vue.d.ts +3 -4
  45. package/lib/{components → editify}/menu/props.d.ts +1 -1
  46. package/lib/editify/props.d.ts +3 -7
  47. package/lib/editify/toolbar/index.d.ts +4 -0
  48. package/lib/{components → editify}/toolbar/props.d.ts +2 -2
  49. package/lib/{components → editify}/toolbar/toolbar.vue.d.ts +53 -53
  50. package/lib/editify.es.js +38964 -37727
  51. package/lib/editify.umd.js +2 -2
  52. package/lib/feature/align.d.ts +32 -0
  53. package/lib/feature/attachment.d.ts +18 -0
  54. package/lib/feature/backColor.d.ts +32 -0
  55. package/lib/feature/bold.d.ts +32 -0
  56. package/lib/feature/code.d.ts +32 -0
  57. package/lib/feature/codeBlock.d.ts +32 -0
  58. package/lib/feature/fontFamily.d.ts +32 -0
  59. package/lib/feature/fontSize.d.ts +32 -0
  60. package/lib/feature/foreColor.d.ts +32 -0
  61. package/lib/feature/formatClear.d.ts +32 -0
  62. package/lib/feature/fullScreen.d.ts +18 -0
  63. package/lib/feature/heading.d.ts +32 -0
  64. package/lib/feature/image.d.ts +32 -0
  65. package/lib/feature/indent.d.ts +18 -0
  66. package/lib/feature/infoBlock.d.ts +18 -0
  67. package/lib/feature/italic.d.ts +32 -0
  68. package/lib/feature/lineHeight.d.ts +32 -0
  69. package/lib/feature/link.d.ts +26 -0
  70. package/lib/feature/mathformula.d.ts +22 -0
  71. package/lib/feature/orderList.d.ts +32 -0
  72. package/lib/feature/panel.d.ts +18 -0
  73. package/lib/feature/quote.d.ts +18 -0
  74. package/lib/feature/redo.d.ts +18 -0
  75. package/lib/feature/separator.d.ts +18 -0
  76. package/lib/feature/sourceView.d.ts +18 -0
  77. package/lib/feature/strikethrough.d.ts +32 -0
  78. package/lib/feature/sub.d.ts +32 -0
  79. package/lib/feature/super.d.ts +32 -0
  80. package/lib/feature/table.d.ts +32 -0
  81. package/lib/feature/task.d.ts +32 -0
  82. package/lib/feature/underline.d.ts +32 -0
  83. package/lib/feature/undo.d.ts +18 -0
  84. package/lib/feature/unorderList.d.ts +32 -0
  85. package/lib/feature/video.d.ts +38 -0
  86. package/lib/index.d.ts +194 -202
  87. package/package.json +5 -5
  88. package/src/components/button/button.vue +21 -24
  89. package/src/components/button/index.ts +5 -0
  90. package/src/components/button/props.ts +14 -1
  91. package/src/components/checkbox/checkbox.vue +1 -1
  92. package/src/components/checkbox/index.ts +5 -0
  93. package/src/components/checkbox/props.ts +1 -1
  94. package/src/components/colors/colors.vue +3 -3
  95. package/src/components/colors/index.ts +5 -0
  96. package/src/components/colors/props.ts +2 -2
  97. package/src/components/icon/index.ts +5 -0
  98. package/src/components/insertAttachment/index.ts +5 -0
  99. package/src/{plugins/attachment → components}/insertAttachment/insertAttachment.vue +4 -2
  100. package/src/{plugins/attachment → components}/insertAttachment/props.ts +1 -1
  101. package/src/components/insertImage/index.ts +5 -0
  102. package/src/components/insertImage/insertImage.vue +5 -5
  103. package/src/components/insertImage/props.ts +1 -1
  104. package/src/components/insertLink/index.ts +5 -0
  105. package/src/components/insertLink/insertLink.vue +10 -10
  106. package/src/components/insertLink/props.ts +3 -3
  107. package/src/components/insertMathformula/index.ts +5 -0
  108. package/src/{plugins/mathformula → components}/insertMathformula/props.ts +2 -2
  109. package/src/components/insertTable/index.ts +5 -0
  110. package/src/components/insertTable/props.ts +2 -2
  111. package/src/components/insertVideo/index.ts +5 -0
  112. package/src/components/insertVideo/insertVideo.vue +2 -2
  113. package/src/components/insertVideo/props.ts +1 -1
  114. package/src/components/layer/index.ts +5 -0
  115. package/src/components/layer/layer.vue +42 -4
  116. package/src/components/tooltip/index.ts +5 -0
  117. package/src/components/tooltip/tooltip.vue +1 -1
  118. package/src/components/triangle/index.ts +5 -0
  119. package/src/components/triangle/triangle.vue +1 -1
  120. package/src/components/updateLink/index.ts +5 -0
  121. package/src/components/updateLink/props.ts +21 -0
  122. package/src/components/{toolbar/toolbar.less → updateLink/updateLink.less} +4 -20
  123. package/src/components/updateLink/updateLink.vue +74 -0
  124. package/src/core/function.ts +289 -97
  125. package/src/core/rule.ts +108 -29
  126. package/src/core/tool.ts +237 -81
  127. package/src/editify/editify.less +4 -0
  128. package/src/editify/editify.vue +183 -194
  129. package/src/editify/menu/index.ts +5 -0
  130. package/src/editify/menu/menu.vue +215 -0
  131. package/src/{components → editify}/menu/props.ts +1 -1
  132. package/src/editify/props.ts +7 -11
  133. package/src/editify/toolbar/index.ts +5 -0
  134. package/src/{components → editify}/toolbar/props.ts +1 -1
  135. package/src/editify/toolbar/toolbar.less +10 -0
  136. package/src/editify/toolbar/toolbar.vue +103 -0
  137. package/src/feature/align.ts +126 -0
  138. package/src/feature/attachment.ts +108 -0
  139. package/src/feature/backColor.ts +169 -0
  140. package/src/feature/bold.ts +134 -0
  141. package/src/feature/code.ts +134 -0
  142. package/src/feature/codeBlock.ts +201 -0
  143. package/src/feature/fontFamily.ts +138 -0
  144. package/src/feature/fontSize.ts +140 -0
  145. package/src/feature/foreColor.ts +171 -0
  146. package/src/feature/formatClear.ts +116 -0
  147. package/src/feature/fullScreen.ts +57 -0
  148. package/src/feature/heading.ts +152 -0
  149. package/src/feature/image.ts +222 -0
  150. package/src/feature/indent.ts +72 -0
  151. package/src/feature/infoBlock.ts +93 -0
  152. package/src/feature/italic.ts +134 -0
  153. package/src/feature/lineHeight.ts +163 -0
  154. package/src/feature/link.ts +146 -0
  155. package/src/feature/mathformula.ts +146 -0
  156. package/src/feature/orderList.ts +114 -0
  157. package/src/feature/panel.ts +107 -0
  158. package/src/feature/quote.ts +60 -0
  159. package/src/feature/redo.ts +56 -0
  160. package/src/feature/separator.ts +61 -0
  161. package/src/feature/sourceView.ts +59 -0
  162. package/src/feature/strikethrough.ts +134 -0
  163. package/src/feature/sub.ts +134 -0
  164. package/src/feature/super.ts +134 -0
  165. package/src/feature/table.ts +981 -0
  166. package/src/feature/task.ts +114 -0
  167. package/src/feature/underline.ts +134 -0
  168. package/src/feature/undo.ts +56 -0
  169. package/src/feature/unorderList.ts +114 -0
  170. package/src/feature/video.ts +335 -0
  171. package/src/hljs/index.ts +1 -1
  172. package/src/index.ts +82 -25
  173. package/src/locale/en_US.ts +3 -3
  174. package/src/locale/zh_CN.ts +3 -3
  175. package/lib/plugins/attachment/index.d.ts +0 -37
  176. package/lib/plugins/infoBlock/index.d.ts +0 -55
  177. package/lib/plugins/mathformula/index.d.ts +0 -49
  178. package/lib/plugins/panel/index.d.ts +0 -48
  179. package/src/components/menu/menu.vue +0 -1655
  180. package/src/components/toolbar/toolbar.vue +0 -1677
  181. package/src/plugins/attachment/index.ts +0 -237
  182. package/src/plugins/infoBlock/index.ts +0 -238
  183. package/src/plugins/mathformula/index.ts +0 -295
  184. package/src/plugins/panel/index.ts +0 -228
  185. package/tsconfig.json +0 -31
  186. package/tsconfig.node.json +0 -11
  187. /package/src/{plugins/attachment → components}/insertAttachment/insertAttachment.less +0 -0
  188. /package/src/{plugins/mathformula → components}/insertMathformula/insertMathformula.less +0 -0
  189. /package/src/{plugins/mathformula → components}/insertMathformula/insertMathformula.vue +0 -0
  190. /package/src/{components → editify}/menu/menu.less +0 -0
@@ -1,1655 +0,0 @@
1
- <template>
2
- <div ref="menuRef" class="editify-menu" :class="{ 'editify-border': menuShowBorder, 'editify-source': isSourceView && menuMode == 'inner', 'editify-fullscreen': isFullScreen }" :data-editify-mode="menuMode" :style="{ zIndex: zIndex, ...(config.style || {}) }">
3
- <MenuItem v-for="item in menuNames" :name="item" :disabled="menuDisabled(item)"></MenuItem>
4
- </div>
5
- </template>
6
- <script setup lang="ts">
7
- import { common as DapCommon, event as DapEvent } from 'dap-util'
8
- import { h, ref, computed, inject, ComponentInternalInstance, Ref, ComputedRef, defineComponent, onMounted, getCurrentInstance, onBeforeUnmount } from 'vue'
9
- import { AlexEditor, AlexElementsRangeType } from 'alex-editor'
10
- import Icon from '@/components/icon/icon.vue'
11
- import Button from '@/components/button/button.vue'
12
- import Colors from '@/components/colors/colors.vue'
13
- import InsertLink from '@/components/insertLink/insertLink.vue'
14
- import InsertImage from '@/components/insertImage/insertImage.vue'
15
- import InsertVideo from '@/components/insertVideo/insertVideo.vue'
16
- import InsertTable from '@/components/insertTable/insertTable.vue'
17
- import { ButtonOptionsItemType } from '@/components/button/props'
18
- import { getRangeText, setHeading, setIndentIncrease, setIndentDecrease, setQuote, setAlign, setList, setTask, setTextStyle, setTextMark, removeTextStyle, removeTextMark, setLineHeight, insertLink, insertImage, insertVideo, insertTable, insertCodeBlock, hasPreInRange, hasTableInRange, hasLinkInRange, isRangeInQuote, isRangeInList, isRangeInTask, queryTextStyle, queryTextMark, getMatchElementByRange, hasImageInRange, hasVideoInRange, insertSeparator } from '@/core/function'
19
- import { MenuModeType, ObjectType, PluginResultType, MenuExtendType, MenuSequenceType, mergeObject } from '@/core/tool'
20
- import { MenuProps } from './props'
21
-
22
- defineOptions({
23
- name: 'Menu'
24
- })
25
- const instance = getCurrentInstance()!
26
- const props = defineProps(MenuProps)
27
-
28
- const $editTrans = inject<(key: string) => any>('$editTrans')!
29
- const editify = inject<ComponentInternalInstance>('editify')!
30
- const isSourceView = inject<Ref<boolean>>('isSourceView')!
31
- const isFullScreen = inject<Ref<boolean>>('isFullScreen')!
32
- const canUseMenu = inject<Ref<boolean>>('canUseMenu')!
33
- const editor = inject<Ref<AlexEditor>>('editor')!
34
- const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
35
- const showBorder = inject<ComputedRef<boolean>>('showBorder')!
36
- const pluginResultList = inject<ComputedRef<PluginResultType[]>>('pluginResultList')!
37
-
38
- //菜单dom
39
- const menuRef = ref<HTMLElement | null>(null)
40
- //菜单高度
41
- const height = ref<number>(0)
42
- //撤销按钮配置
43
- const undoConfig = ref<ObjectType>({
44
- show: props.config.undo!.show,
45
- leftBorder: props.config.undo!.leftBorder,
46
- rightBorder: props.config.undo!.rightBorder,
47
- active: false,
48
- disabled: false
49
- })
50
- //重做按钮配置
51
- const redoConfig = ref<ObjectType>({
52
- show: props.config.redo!.show,
53
- leftBorder: props.config.redo!.leftBorder,
54
- rightBorder: props.config.redo!.rightBorder,
55
- active: false,
56
- disabled: false
57
- })
58
- //标题按钮配置
59
- const headingConfig = ref<ObjectType>({
60
- show: props.config.heading!.show,
61
- displayConfig: {
62
- options: props.config.heading!.options,
63
- value: '',
64
- width: props.config.heading!.width,
65
- maxHeight: props.config.heading!.maxHeight
66
- },
67
- defaultValue: props.config.heading!.defaultValue,
68
- leftBorder: props.config.heading!.leftBorder,
69
- rightBorder: props.config.heading!.rightBorder,
70
- active: false,
71
- disabled: false
72
- })
73
- //缩进按钮配置
74
- const indentConfig = ref<ObjectType>({
75
- show: props.config.indent!.show,
76
- selectConfig: {
77
- options: props.config.indent!.options,
78
- value: '',
79
- width: props.config.indent!.width,
80
- maxHeight: props.config.indent!.maxHeight
81
- },
82
- leftBorder: props.config.indent!.leftBorder,
83
- rightBorder: props.config.indent!.rightBorder,
84
- active: false,
85
- disabled: false
86
- })
87
- //引用按钮配置
88
- const quoteConfig = ref<ObjectType>({
89
- show: props.config.quote!.show,
90
- leftBorder: props.config.quote!.leftBorder,
91
- rightBorder: props.config.quote!.rightBorder,
92
- active: false,
93
- disabled: false
94
- })
95
- //分隔线按钮配置
96
- const separatorConfig = ref<ObjectType>({
97
- show: props.config.separator!.show,
98
- leftBorder: props.config.separator!.leftBorder,
99
- rightBorder: props.config.separator!.rightBorder,
100
- active: false,
101
- disabled: false
102
- })
103
- //对齐方式按钮配置
104
- const alignConfig = ref<ObjectType>({
105
- show: props.config.align!.show,
106
- selectConfig: {
107
- options: props.config.align!.options,
108
- width: props.config.align!.width,
109
- maxHeight: props.config.align!.maxHeight
110
- },
111
- leftBorder: props.config.align!.leftBorder,
112
- rightBorder: props.config.align!.rightBorder,
113
- active: false,
114
- disabled: false
115
- })
116
- //有序列表按钮配置
117
- const orderListConfig = ref<ObjectType>({
118
- show: props.config.orderList!.show,
119
- leftBorder: props.config.orderList!.leftBorder,
120
- rightBorder: props.config.orderList!.rightBorder,
121
- active: false,
122
- disabled: false
123
- })
124
- //无序列表按钮配置
125
- const unorderListConfig = ref<ObjectType>({
126
- show: props.config.unorderList!.show,
127
- leftBorder: props.config.unorderList!.leftBorder,
128
- rightBorder: props.config.unorderList!.rightBorder,
129
- active: false,
130
- disabled: false
131
- })
132
- //任务列表按钮配置
133
- const taskConfig = ref<ObjectType>({
134
- show: props.config.task!.show,
135
- leftBorder: props.config.task!.leftBorder,
136
- rightBorder: props.config.task!.rightBorder,
137
- active: false,
138
- disabled: false
139
- })
140
- //粗体按钮配置
141
- const boldConfig = ref<ObjectType>({
142
- show: props.config.bold!.show,
143
- leftBorder: props.config.bold!.leftBorder,
144
- rightBorder: props.config.bold!.rightBorder,
145
- active: false,
146
- disabled: false
147
- })
148
- //下划线按钮配置
149
- const underlineConfig = ref<ObjectType>({
150
- show: props.config.underline!.show,
151
- leftBorder: props.config.underline!.leftBorder,
152
- rightBorder: props.config.underline!.rightBorder,
153
- active: false,
154
- disabled: false
155
- })
156
- //斜体按钮配置
157
- const italicConfig = ref<ObjectType>({
158
- show: props.config.italic!.show,
159
- leftBorder: props.config.italic!.leftBorder,
160
- rightBorder: props.config.italic!.rightBorder,
161
- active: false,
162
- disabled: false
163
- })
164
- //删除线按钮配置
165
- const strikethroughConfig = ref<ObjectType>({
166
- show: props.config.strikethrough!.show,
167
- leftBorder: props.config.strikethrough!.leftBorder,
168
- rightBorder: props.config.strikethrough!.rightBorder,
169
- active: false,
170
- disabled: false
171
- })
172
- //行内代码按钮配置
173
- const codeConfig = ref<ObjectType>({
174
- show: props.config.code!.show,
175
- leftBorder: props.config.code!.leftBorder,
176
- rightBorder: props.config.code!.rightBorder,
177
- active: false,
178
- disabled: false
179
- })
180
- //上标按钮配置
181
- const superConfig = ref<ObjectType>({
182
- show: props.config.super!.show,
183
- leftBorder: props.config.super!.leftBorder,
184
- rightBorder: props.config.super!.rightBorder,
185
- active: false,
186
- disabled: false
187
- })
188
- //下标按钮配置
189
- const subConfig = ref<ObjectType>({
190
- show: props.config.sub!.show,
191
- leftBorder: props.config.sub!.leftBorder,
192
- rightBorder: props.config.sub!.rightBorder,
193
- active: false,
194
- disabled: false
195
- })
196
- //清除格式按钮配置
197
- const formatClearConfig = ref<ObjectType>({
198
- show: props.config.formatClear!.show,
199
- leftBorder: props.config.formatClear!.leftBorder,
200
- rightBorder: props.config.formatClear!.rightBorder,
201
- active: false,
202
- disabled: false
203
- })
204
- //字号按钮配置
205
- const fontSizeConfig = ref<ObjectType>({
206
- show: props.config.fontSize!.show,
207
- displayConfig: {
208
- options: props.config.fontSize!.options,
209
- value: '',
210
- width: props.config.fontSize!.width,
211
- maxHeight: props.config.fontSize!.maxHeight
212
- },
213
- defaultValue: props.config.fontSize!.defaultValue,
214
- leftBorder: props.config.fontSize!.leftBorder,
215
- rightBorder: props.config.fontSize!.rightBorder,
216
- active: false,
217
- disabled: false
218
- })
219
- //字体按钮配置
220
- const fontFamilyConfig = ref<ObjectType>({
221
- show: props.config.fontFamily!.show,
222
- displayConfig: {
223
- options: props.config.fontFamily!.options,
224
- value: '',
225
- width: props.config.fontFamily!.width,
226
- maxHeight: props.config.fontFamily!.maxHeight
227
- },
228
- defaultValue: props.config.fontFamily!.defaultValue,
229
- leftBorder: props.config.fontFamily!.leftBorder,
230
- rightBorder: props.config.fontFamily!.rightBorder,
231
- active: false,
232
- disabled: false
233
- })
234
- //行高按钮配置
235
- const lineHeightConfig = ref<ObjectType>({
236
- show: props.config.lineHeight!.show,
237
- displayConfig: {
238
- options: props.config.lineHeight!.options,
239
- value: '',
240
- width: props.config.lineHeight!.width,
241
- maxHeight: props.config.lineHeight!.maxHeight
242
- },
243
- defaultValue: props.config.lineHeight!.defaultValue,
244
- leftBorder: props.config.lineHeight!.leftBorder,
245
- rightBorder: props.config.lineHeight!.rightBorder,
246
- active: false,
247
- disabled: false
248
- })
249
- //前景颜色按钮配置
250
- const foreColorConfig = ref<ObjectType>({
251
- show: props.config.foreColor!.show,
252
- selectConfig: {
253
- options: props.config.foreColor!.options
254
- },
255
- leftBorder: props.config.foreColor!.leftBorder,
256
- rightBorder: props.config.foreColor!.rightBorder,
257
- value: '', //选择的颜色值
258
- active: false,
259
- disabled: false
260
- })
261
- //背景颜色按钮配置
262
- const backColorConfig = ref<ObjectType>({
263
- show: props.config.backColor!.show,
264
- selectConfig: {
265
- options: props.config.backColor!.options
266
- },
267
- leftBorder: props.config.backColor!.leftBorder,
268
- rightBorder: props.config.backColor!.rightBorder,
269
- value: '', //选择的颜色值
270
- active: false,
271
- disabled: false
272
- })
273
- //链接按钮配置
274
- const linkConfig = ref<ObjectType>({
275
- show: props.config.link!.show,
276
- leftBorder: props.config.link!.leftBorder,
277
- rightBorder: props.config.link!.rightBorder,
278
- active: false,
279
- disabled: false,
280
- text: '' //链接的文本
281
- })
282
- //插入图片按钮配置
283
- const imageConfig = ref<ObjectType>({
284
- show: props.config.image!.show,
285
- leftBorder: props.config.image!.leftBorder,
286
- rightBorder: props.config.image!.rightBorder,
287
- active: false,
288
- disabled: false,
289
- allowedFileType: props.config.image!.allowedFileType,
290
- multiple: props.config.image!.multiple,
291
- maxSize: props.config.image!.maxSize,
292
- minSize: props.config.image!.minSize,
293
- handleError: props.config.image!.handleError,
294
- customUpload: props.config.image!.customUpload
295
- })
296
- //插入视频按钮配置
297
- const videoConfig = ref<ObjectType>({
298
- show: props.config.video!.show,
299
- leftBorder: props.config.video!.leftBorder,
300
- rightBorder: props.config.video!.rightBorder,
301
- active: false,
302
- disabled: false,
303
- allowedFileType: props.config.video!.allowedFileType,
304
- multiple: props.config.video!.multiple,
305
- maxSize: props.config.video!.maxSize,
306
- minSize: props.config.video!.minSize,
307
- handleError: props.config.video!.handleError,
308
- customUpload: props.config.video!.customUpload
309
- })
310
- //表格按钮配置
311
- const tableConfig = ref<ObjectType>({
312
- show: props.config.table!.show,
313
- leftBorder: props.config.table!.leftBorder,
314
- rightBorder: props.config.table!.rightBorder,
315
- active: false,
316
- disabled: false,
317
- maxRows: props.config.table!.maxRows,
318
- maxColumns: props.config.table!.maxColumns
319
- })
320
- //代码块按钮配置
321
- const codeBlockConfig = ref<ObjectType>({
322
- show: props.config.codeBlock!.show,
323
- leftBorder: props.config.codeBlock!.leftBorder,
324
- rightBorder: props.config.codeBlock!.rightBorder,
325
- active: false,
326
- disabled: false
327
- })
328
- //代码视图按钮配置
329
- const sourceViewConfig = ref<ObjectType>({
330
- show: props.config.sourceView!.show,
331
- leftBorder: props.config.sourceView!.leftBorder,
332
- rightBorder: props.config.sourceView!.rightBorder,
333
- active: false,
334
- disabled: false
335
- })
336
- //全屏按钮配置
337
- const fullScreenConfig = ref<ObjectType>({
338
- show: props.config.fullScreen!.show,
339
- leftBorder: props.config.fullScreen!.leftBorder,
340
- rightBorder: props.config.fullScreen!.rightBorder,
341
- active: false,
342
- disabled: false
343
- })
344
-
345
- //整个菜单栏是否禁用
346
- const disabled = computed<boolean>(() => {
347
- return <boolean>editify.props.disabled || !canUseMenu.value
348
- })
349
- //菜单名称数组
350
- const menuNames = computed<string[]>(() => {
351
- //获取插件列表的menu的sequence配置
352
- let pluginSequence: MenuSequenceType = {}
353
- pluginResultList.value.forEach(pluginResult => {
354
- if (pluginResult.menu) {
355
- pluginSequence[pluginResult.name] = pluginResult.menu.sequence
356
- }
357
- })
358
- //将插件列表的sequence配置和最终的配置合并
359
- pluginSequence = mergeObject(pluginSequence, props.config.sequence!) as MenuSequenceType
360
- return Object.keys(pluginSequence).sort((a, b) => {
361
- if (pluginSequence[a]! > pluginSequence[b]!) {
362
- return 1
363
- }
364
- return -1
365
- })
366
- })
367
- //菜单是否禁用
368
- const menuDisabled = computed<(name: string) => boolean>(() => {
369
- return (name: string) => {
370
- if (name == 'sourceView' || name == 'fullScreen') {
371
- return false
372
- }
373
- return isSourceView.value
374
- }
375
- })
376
- //菜单模式
377
- const menuMode = computed<MenuModeType>(() => {
378
- //如果是全屏状态下或者高度自适应状态下
379
- if (isFullScreen.value || editify.props.autoheight) {
380
- //fixed模式改为默认模式
381
- if (props.config.mode == 'fixed') {
382
- return 'default'
383
- }
384
- }
385
- return props.config.mode!
386
- })
387
- //菜单栏是否显示边框
388
- const menuShowBorder = computed<boolean>(() => {
389
- //fixed模式下不显示边框
390
- if (menuMode.value == 'fixed') {
391
- return false
392
- }
393
- //由编辑器的border属性来决定
394
- return showBorder.value
395
- })
396
- //拓展菜单配置
397
- const menuExtends = computed<MenuExtendType>(() => {
398
- //获取插件列表的menu的extend配置
399
- let pluginExtends: MenuExtendType = {}
400
- pluginResultList.value.forEach(pluginResult => {
401
- if (pluginResult.menu) {
402
- pluginExtends[pluginResult.name] = pluginResult.menu.extend
403
- }
404
- })
405
- //将插件列表的extend配置和最终的配置合并
406
- return mergeObject(pluginExtends, props.config.extends!) as MenuExtendType
407
- })
408
-
409
- //按钮操作触发函数
410
- const handleOperate = (name: string, val: any) => {
411
- //菜单栏禁用
412
- if (disabled.value) {
413
- return
414
- }
415
- //没有获取焦点
416
- if (!editor.value.range) {
417
- return
418
- }
419
- //撤销
420
- if (name == 'undo') {
421
- editify.exposed!.undo()
422
- }
423
- //重做
424
- else if (name == 'redo') {
425
- editify.exposed!.redo()
426
- }
427
- //设置标题
428
- else if (name == 'heading') {
429
- setHeading(editor.value, dataRangeCaches.value, $editTrans, <string>val)
430
- editor.value.formatElementStack()
431
- editor.value.domRender()
432
- editor.value.rangeRender()
433
- }
434
- //设置缩进
435
- else if (name == 'indent') {
436
- //增加缩进
437
- if (val == 'indent-increase') {
438
- setIndentIncrease(editor.value, dataRangeCaches.value)
439
- }
440
- //减少缩进
441
- else if (val == 'indent-decrease') {
442
- setIndentDecrease(editor.value, dataRangeCaches.value)
443
- }
444
- editor.value.formatElementStack()
445
- editor.value.domRender()
446
- editor.value.rangeRender()
447
- }
448
- //设置引用
449
- else if (name == 'quote') {
450
- setQuote(editor.value, dataRangeCaches.value)
451
- editor.value.formatElementStack()
452
- editor.value.domRender()
453
- editor.value.rangeRender()
454
- }
455
- //插入分隔线
456
- else if (name == 'separator') {
457
- insertSeparator(editor.value)
458
- editor.value.formatElementStack()
459
- editor.value.domRender()
460
- editor.value.rangeRender()
461
- }
462
- //设置对齐方式
463
- else if (name == 'align') {
464
- setAlign(editor.value, dataRangeCaches.value, val as 'left' | 'right' | 'center' | 'justify')
465
- editor.value.formatElementStack()
466
- editor.value.domRender()
467
- editor.value.rangeRender()
468
- }
469
- //设置有序列表
470
- else if (name == 'orderList') {
471
- setList(editor.value, dataRangeCaches.value, true)
472
- editor.value.formatElementStack()
473
- editor.value.domRender()
474
- editor.value.rangeRender()
475
- }
476
- //设置无序列表
477
- else if (name == 'unorderList') {
478
- setList(editor.value, dataRangeCaches.value, false)
479
- editor.value.formatElementStack()
480
- editor.value.domRender()
481
- editor.value.rangeRender()
482
- }
483
- //设置任务列表
484
- else if (name == 'task') {
485
- setTask(editor.value, dataRangeCaches.value)
486
- editor.value.formatElementStack()
487
- editor.value.domRender()
488
- editor.value.rangeRender()
489
- }
490
- //设置粗体
491
- else if (name == 'bold') {
492
- if (queryTextStyle(editor.value, dataRangeCaches.value, 'font-weight', 'bold') || queryTextStyle(editor.value, dataRangeCaches.value, 'font-weight', '700')) {
493
- removeTextStyle(editor.value, dataRangeCaches.value, ['font-weight'])
494
- } else {
495
- setTextStyle(editor.value, dataRangeCaches.value, {
496
- 'font-weight': 'bold'
497
- })
498
- }
499
- editor.value.formatElementStack()
500
- editor.value.domRender()
501
- editor.value.rangeRender()
502
- }
503
- //设置下划线
504
- else if (name == 'underline') {
505
- if (queryTextStyle(editor.value, dataRangeCaches.value, 'text-decoration', 'underline') || queryTextStyle(editor.value, dataRangeCaches.value, 'text-decoration-line', 'underline')) {
506
- removeTextStyle(editor.value, dataRangeCaches.value, ['text-decoration', 'text-decoration-line'])
507
- } else {
508
- setTextStyle(editor.value, dataRangeCaches.value, {
509
- 'text-decoration': 'underline'
510
- })
511
- }
512
- editor.value.formatElementStack()
513
- editor.value.domRender()
514
- editor.value.rangeRender()
515
- }
516
- //设置斜体
517
- else if (name == 'italic') {
518
- if (queryTextStyle(editor.value, dataRangeCaches.value, 'font-style', 'italic')) {
519
- removeTextStyle(editor.value, dataRangeCaches.value, ['font-style'])
520
- } else {
521
- setTextStyle(editor.value, dataRangeCaches.value, {
522
- 'font-style': 'italic'
523
- })
524
- }
525
- editor.value.formatElementStack()
526
- editor.value.domRender()
527
- editor.value.rangeRender()
528
- }
529
- //设置删除线
530
- else if (name == 'strikethrough') {
531
- if (queryTextStyle(editor.value, dataRangeCaches.value, 'text-decoration', 'line-through') || queryTextStyle(editor.value, dataRangeCaches.value, 'text-decoration-line', 'line-through')) {
532
- removeTextStyle(editor.value, dataRangeCaches.value, ['text-decoration', 'text-decoration-line'])
533
- } else {
534
- setTextStyle(editor.value, dataRangeCaches.value, {
535
- 'text-decoration': 'line-through'
536
- })
537
- }
538
- editor.value.formatElementStack()
539
- editor.value.domRender()
540
- editor.value.rangeRender()
541
- }
542
- //设置行内代码
543
- else if (name == 'code') {
544
- if (queryTextMark(editor.value, dataRangeCaches.value, 'data-editify-code')) {
545
- removeTextMark(editor.value, dataRangeCaches.value, ['data-editify-code'])
546
- } else {
547
- setTextMark(editor.value, dataRangeCaches.value, {
548
- 'data-editify-code': true
549
- })
550
- }
551
- editor.value.formatElementStack()
552
- editor.value.domRender()
553
- editor.value.rangeRender()
554
- }
555
- //设置上标
556
- else if (name == 'super') {
557
- if (queryTextStyle(editor.value, dataRangeCaches.value, 'vertical-align', 'super')) {
558
- removeTextStyle(editor.value, dataRangeCaches.value, ['vertical-align'])
559
- } else {
560
- setTextStyle(editor.value, dataRangeCaches.value, {
561
- 'vertical-align': 'super'
562
- })
563
- }
564
- editor.value.formatElementStack()
565
- editor.value.domRender()
566
- editor.value.rangeRender()
567
- }
568
- //设置下标
569
- else if (name == 'sub') {
570
- if (queryTextStyle(editor.value, dataRangeCaches.value, 'vertical-align', 'sub')) {
571
- removeTextStyle(editor.value, dataRangeCaches.value, ['vertical-align'])
572
- } else {
573
- setTextStyle(editor.value, dataRangeCaches.value, {
574
- 'vertical-align': 'sub'
575
- })
576
- }
577
- editor.value.formatElementStack()
578
- editor.value.domRender()
579
- editor.value.rangeRender()
580
- }
581
- //清除格式
582
- else if (name == 'formatClear') {
583
- removeTextStyle(editor.value, dataRangeCaches.value)
584
- removeTextMark(editor.value, dataRangeCaches.value)
585
- editor.value.formatElementStack()
586
- editor.value.domRender()
587
- editor.value.rangeRender()
588
- }
589
- //设置字号
590
- else if (name == 'fontSize') {
591
- setTextStyle(editor.value, dataRangeCaches.value, {
592
- 'font-size': val
593
- })
594
- editor.value.formatElementStack()
595
- editor.value.domRender()
596
- editor.value.rangeRender()
597
- }
598
- //设置字体
599
- else if (name == 'fontFamily') {
600
- setTextStyle(editor.value, dataRangeCaches.value, {
601
- 'font-family': val
602
- })
603
- editor.value.formatElementStack()
604
- editor.value.domRender()
605
- editor.value.rangeRender()
606
- }
607
- //设置行高
608
- else if (name == 'lineHeight') {
609
- setLineHeight(editor.value, dataRangeCaches.value, <string | number>val)
610
- editor.value.formatElementStack()
611
- editor.value.domRender()
612
- editor.value.rangeRender()
613
- }
614
- //设置前景色
615
- else if (name == 'foreColor') {
616
- setTextStyle(editor.value, dataRangeCaches.value, {
617
- color: val
618
- })
619
- editor.value.formatElementStack()
620
- editor.value.domRender()
621
- editor.value.rangeRender()
622
- }
623
- //设置背景色
624
- else if (name == 'backColor') {
625
- setTextStyle(editor.value, dataRangeCaches.value, {
626
- 'background-color': val
627
- })
628
- editor.value.formatElementStack()
629
- editor.value.domRender()
630
- editor.value.rangeRender()
631
- }
632
- //插入链接
633
- else if (name == 'link') {
634
- if (!(<ObjectType>val).url) {
635
- return
636
- }
637
- insertLink(editor.value, (<ObjectType>val).text, (<ObjectType>val).url, (<ObjectType>val).newOpen)
638
- editor.value.formatElementStack()
639
- editor.value.domRender()
640
- editor.value.rangeRender()
641
- }
642
- //插入图片
643
- else if (name == 'image') {
644
- if (!val) {
645
- return
646
- }
647
- //过滤掉空的地址
648
- const urls = (<string[]>val).filter(url => {
649
- return !!url
650
- })
651
- //如果数组为0
652
- if (urls.length == 0) {
653
- return
654
- }
655
- //遍历每个地址进行插入
656
- urls.forEach(url => {
657
- insertImage(editor.value, url)
658
- })
659
- editor.value.formatElementStack()
660
- editor.value.domRender()
661
- editor.value.rangeRender()
662
- }
663
- //插入视频
664
- else if (name == 'video') {
665
- if (!val) {
666
- return
667
- }
668
- //过滤掉空的地址
669
- const urls = (<string[]>val).filter(url => {
670
- return !!url
671
- })
672
- //如果数组为0
673
- if (urls.length == 0) {
674
- return
675
- }
676
- //遍历每个地址进行插入
677
- urls.forEach(url => {
678
- insertVideo(editor.value, url)
679
- })
680
- editor.value.formatElementStack()
681
- editor.value.domRender()
682
- editor.value.rangeRender()
683
- }
684
- //插入表格
685
- else if (name == 'table') {
686
- insertTable(editor.value, (<ObjectType>val).row, (<ObjectType>val).column)
687
- editor.value.formatElementStack()
688
- editor.value.domRender()
689
- editor.value.rangeRender()
690
- }
691
- //插入代码块
692
- else if (name == 'codeBlock') {
693
- insertCodeBlock(editor.value, dataRangeCaches.value)
694
- editor.value.formatElementStack()
695
- editor.value.domRender()
696
- editor.value.rangeRender()
697
- }
698
- //代码视图
699
- else if (name == 'sourceView') {
700
- isSourceView.value = !isSourceView.value
701
- sourceViewConfig.value.active = isSourceView.value
702
- if (!isSourceView.value) {
703
- editor.value.rangeRender()
704
- }
705
- }
706
- //全屏
707
- else if (name == 'fullScreen') {
708
- isFullScreen.value = !isFullScreen.value
709
- fullScreenConfig.value.active = isFullScreen.value
710
- editor.value.rangeRender()
711
- }
712
- }
713
- //处理光标更新
714
- const handleRangeUpdate = () => {
715
- //选区是否含有代码块
716
- const value_hasPreInRange = hasPreInRange(editor.value, dataRangeCaches.value)
717
- //选区是否含有表格元素
718
- const value_hasTableInRange = hasTableInRange(editor.value, dataRangeCaches.value)
719
- //选区是否含有链接元素
720
- const value_hasLinkInRange = hasLinkInRange(editor.value, dataRangeCaches.value)
721
- //选区是否含有图片
722
- const value_hasImageInRange = hasImageInRange(editor.value, dataRangeCaches.value)
723
- //选区是否含有视频
724
- const value_hasVideoInRange = hasVideoInRange(editor.value, dataRangeCaches.value)
725
- //选区是否都在引用元素内
726
- const value_isRangeInQuote = isRangeInQuote(editor.value, dataRangeCaches.value)
727
- //选区是否都在有序列表内
728
- const value_isRangeInOrderList = isRangeInList(editor.value, dataRangeCaches.value, true)
729
- //选区是否都在无序列表内
730
- const value_isRangeInUnorderList = isRangeInList(editor.value, dataRangeCaches.value, false)
731
- //选区是否都在任务列表内
732
- const value_isRangeInTask = isRangeInTask(editor.value, dataRangeCaches.value)
733
- //额外禁用判定
734
- const extraDisabled = (name: string) => {
735
- //对插件列表的menu的extraDisabled配置进行处理,获取最终是否禁用的结果
736
- let pluginDisabled = false
737
- let length = pluginResultList.value.length
738
- for (let i = 0; i < length; i++) {
739
- const pluginResult = pluginResultList.value[i]
740
- if (pluginResult.menu && typeof pluginResult.menu.extraDisabled == 'function') {
741
- pluginDisabled = pluginResult.menu.extraDisabled(name)
742
- //如果在某个插件时禁用了这个菜单则结束循环
743
- if (pluginDisabled) {
744
- break
745
- }
746
- }
747
- }
748
- //如果自定义了额外禁用方法则进行处理
749
- if (typeof props.config.extraDisabled == 'function') {
750
- return props.config.extraDisabled(name) || pluginDisabled || false
751
- }
752
- return pluginDisabled || false
753
- }
754
-
755
- //撤销按钮禁用
756
- undoConfig.value.disabled = !editor.value.history.get(-1) || extraDisabled('undo')
757
-
758
- //重做按钮禁用
759
- redoConfig.value.disabled = !editor.value.history.get(1) || extraDisabled('redo')
760
-
761
- //显示已设置标题
762
- const findHeadingItem = headingConfig.value.displayConfig.options.find((item: string | number | ButtonOptionsItemType) => {
763
- let val: string | number | ButtonOptionsItemType = item
764
- if (DapCommon.isObject(item)) {
765
- val = (<ButtonOptionsItemType>item).value!
766
- }
767
- if (editor.value.range!.anchor.isEqual(editor.value.range!.focus)) {
768
- return editor.value.range!.anchor.element.getBlock().parsedom == val
769
- }
770
- return dataRangeCaches.value.list.every(el => {
771
- if (el.element.isBlock()) {
772
- return el.element.parsedom == val
773
- }
774
- return el.element.getBlock().parsedom == val
775
- })
776
- })
777
- headingConfig.value.displayConfig.value = findHeadingItem ? (DapCommon.isObject(findHeadingItem) ? findHeadingItem.value : findHeadingItem) : headingConfig.value.defaultValue
778
- //标题禁用
779
- headingConfig.value.disabled = value_hasPreInRange || value_hasTableInRange || extraDisabled('heading')
780
-
781
- //缩进禁用
782
- indentConfig.value.disabled = value_hasPreInRange || value_hasTableInRange || extraDisabled('indent')
783
-
784
- //引用按钮激活
785
- quoteConfig.value.active = value_isRangeInQuote
786
- //引用按钮禁用
787
- quoteConfig.value.disabled = value_hasPreInRange || value_hasTableInRange || extraDisabled('quote')
788
-
789
- //分隔线按钮禁用
790
- separatorConfig.value.disabled = value_hasPreInRange || extraDisabled('separator')
791
-
792
- //对齐方式按钮禁用
793
- alignConfig.value.disabled = value_hasPreInRange || extraDisabled('align')
794
-
795
- //有序列表按钮激活
796
- orderListConfig.value.active = value_isRangeInOrderList
797
- //有序列表禁用
798
- orderListConfig.value.disabled = value_hasPreInRange || value_hasTableInRange || extraDisabled('orderList')
799
-
800
- //无序列表按钮激活
801
- unorderListConfig.value.active = value_isRangeInUnorderList
802
- //无序列表禁用
803
- unorderListConfig.value.disabled = value_hasPreInRange || value_hasTableInRange || extraDisabled('unorderList')
804
-
805
- //任务列表按钮激活
806
- taskConfig.value.active = value_isRangeInTask
807
- //任务列表禁用
808
- taskConfig.value.disabled = value_hasPreInRange || value_hasTableInRange || extraDisabled('task')
809
-
810
- //粗体按钮激活
811
- boldConfig.value.active = queryTextStyle(editor.value, dataRangeCaches.value, 'font-weight', 'bold') || queryTextStyle(editor.value, dataRangeCaches.value, 'font-weight', '700')
812
- //粗体按钮禁用
813
- boldConfig.value.disabled = value_hasPreInRange || extraDisabled('bold')
814
-
815
- //下划线按钮激活
816
- underlineConfig.value.active = queryTextStyle(editor.value, dataRangeCaches.value, 'text-decoration', 'underline') || queryTextStyle(editor.value, dataRangeCaches.value, 'text-decoration-line', 'underline')
817
- //下划线按钮禁用
818
- underlineConfig.value.disabled = value_hasPreInRange || extraDisabled('underline')
819
-
820
- //斜体按钮激活
821
- italicConfig.value.active = queryTextStyle(editor.value, dataRangeCaches.value, 'font-style', 'italic')
822
- //斜体按钮禁用
823
- italicConfig.value.disabled = value_hasPreInRange || extraDisabled('italic')
824
-
825
- //删除线按钮激活
826
- strikethroughConfig.value.active = queryTextStyle(editor.value, dataRangeCaches.value, 'text-decoration', 'line-through') || queryTextStyle(editor.value, dataRangeCaches.value, 'text-decoration-line', 'line-through')
827
- //删除线按钮禁用
828
- strikethroughConfig.value.disabled = value_hasPreInRange || extraDisabled('strikethrough')
829
-
830
- //行内代码按钮激活
831
- codeConfig.value.active = queryTextMark(editor.value, dataRangeCaches.value, 'data-editify-code')
832
- //行内代码按钮禁用
833
- codeConfig.value.disabled = value_hasPreInRange || extraDisabled('code')
834
-
835
- //上标按钮激活
836
- superConfig.value.active = queryTextStyle(editor.value, dataRangeCaches.value, 'vertical-align', 'super')
837
- //上标按钮禁用
838
- superConfig.value.disabled = value_hasPreInRange || extraDisabled('super')
839
-
840
- //下标按钮激活
841
- subConfig.value.active = queryTextStyle(editor.value, dataRangeCaches.value, 'vertical-align', 'sub')
842
- //下标按钮禁用
843
- subConfig.value.disabled = value_hasPreInRange || extraDisabled('sub')
844
-
845
- //清除格式按钮禁用
846
- formatClearConfig.value.disabled = value_hasPreInRange || extraDisabled('formatClear')
847
-
848
- //显示已选择字号
849
- const findFontItem = fontSizeConfig.value.displayConfig.options.find((item: string | ButtonOptionsItemType) => {
850
- if (DapCommon.isObject(item)) {
851
- return queryTextStyle(editor.value, dataRangeCaches.value, 'font-size', (<ButtonOptionsItemType>item).value)
852
- }
853
- return queryTextStyle(editor.value, dataRangeCaches.value, 'font-size', <string>item)
854
- })
855
- fontSizeConfig.value.displayConfig.value = findFontItem ? (DapCommon.isObject(findFontItem) ? findFontItem.value : findFontItem) : fontSizeConfig.value.defaultValue
856
- //字号按钮禁用
857
- fontSizeConfig.value.disabled = value_hasPreInRange || extraDisabled('fontSize')
858
-
859
- //显示已选择字体
860
- const findFamilyItem = fontFamilyConfig.value.displayConfig.options.find((item: string | ButtonOptionsItemType) => {
861
- if (DapCommon.isObject(item)) {
862
- return queryTextStyle(editor.value, dataRangeCaches.value, 'font-family', (<ButtonOptionsItemType>item).value)
863
- }
864
- return queryTextStyle(editor.value, dataRangeCaches.value, 'font-family', <string>item)
865
- })
866
- fontFamilyConfig.value.displayConfig.value = findFamilyItem ? (DapCommon.isObject(findFamilyItem) ? findFamilyItem.value : findFamilyItem) : fontFamilyConfig.value.defaultValue
867
- //字体按钮禁用
868
- fontFamilyConfig.value.disabled = value_hasPreInRange || extraDisabled('fontFamily')
869
-
870
- //显示已设置行高
871
- const findHeightItem = lineHeightConfig.value.displayConfig.options.find((item: string | number | ButtonOptionsItemType) => {
872
- let val: string | number | ButtonOptionsItemType = item
873
- if (DapCommon.isObject(item)) {
874
- val = (<ButtonOptionsItemType>item).value!
875
- }
876
- if (editor.value.range!.anchor.isEqual(editor.value.range!.focus)) {
877
- const block = editor.value.range!.anchor.element.getBlock()
878
- return block.hasStyles() && block.styles!['line-height'] == val
879
- }
880
- return dataRangeCaches.value.list.every(el => {
881
- if (el.element.isBlock() || el.element.isInblock()) {
882
- return el.element.hasStyles() && el.element.styles!['line-height'] == val
883
- }
884
- const block = el.element.getBlock()
885
- const inblock = el.element.getInblock()
886
- if (inblock) {
887
- return inblock.hasStyles() && inblock.styles!['line-height'] == val
888
- }
889
- return block.hasStyles() && block.styles!['line-height'] == val
890
- })
891
- })
892
- lineHeightConfig.value.displayConfig.value = findHeightItem ? (DapCommon.isObject(findHeightItem) ? findHeightItem.value : findHeightItem) : lineHeightConfig.value.defaultValue
893
- //行高按钮禁用
894
- lineHeightConfig.value.disabled = value_hasPreInRange || extraDisabled('lineHeight')
895
-
896
- //显示已选择的前景色
897
- const findForeColorItem = foreColorConfig.value.selectConfig.options.find((item: string | ButtonOptionsItemType) => {
898
- if (DapCommon.isObject(item)) {
899
- return queryTextStyle(editor.value, dataRangeCaches.value, 'color', (<ButtonOptionsItemType>item).value)
900
- }
901
- return queryTextStyle(editor.value, dataRangeCaches.value, 'color', <string>item)
902
- })
903
- foreColorConfig.value.value = findForeColorItem ? (DapCommon.isObject(findForeColorItem) ? findForeColorItem.value : findForeColorItem) : ''
904
- //前景色按钮禁用
905
- foreColorConfig.value.disabled = value_hasPreInRange || extraDisabled('foreColor')
906
-
907
- //显示已选择的背景色
908
- const findBackColorItem = backColorConfig.value.selectConfig.options.find((item: string | ButtonOptionsItemType) => {
909
- if (DapCommon.isObject(item)) {
910
- return queryTextStyle(editor.value, dataRangeCaches.value, 'background-color', (<ButtonOptionsItemType>item).value)
911
- }
912
- return queryTextStyle(editor.value, dataRangeCaches.value, 'background-color', <string>item)
913
- })
914
- backColorConfig.value.value = findBackColorItem ? (DapCommon.isObject(findBackColorItem) ? findBackColorItem.value : findBackColorItem) : ''
915
- //背景色按钮禁用
916
- backColorConfig.value.disabled = value_hasPreInRange || extraDisabled('backColor')
917
-
918
- //链接按钮禁用
919
- linkConfig.value.disabled = value_hasLinkInRange || value_hasPreInRange || extraDisabled('link')
920
-
921
- //插入图片按钮禁用
922
- imageConfig.value.disabled = value_hasPreInRange || extraDisabled('image')
923
-
924
- //插入视频按钮禁用
925
- videoConfig.value.disabled = value_hasPreInRange || extraDisabled('video')
926
-
927
- //表格按钮禁用
928
- tableConfig.value.disabled = value_hasPreInRange || value_hasTableInRange || extraDisabled('table')
929
-
930
- //代码块按钮激活
931
- codeBlockConfig.value.active = !!getMatchElementByRange(editor.value, dataRangeCaches.value, { parsedom: 'pre' })
932
- //代码块按钮禁用
933
- codeBlockConfig.value.disabled = value_hasTableInRange || value_hasImageInRange || value_hasVideoInRange || extraDisabled('codeBlock')
934
-
935
- //代码视图按钮激活
936
- sourceViewConfig.value.active = isSourceView.value
937
-
938
- //全屏按钮激活
939
- fullScreenConfig.value.active = isFullScreen.value
940
- }
941
-
942
- //菜单项子组件
943
- const MenuItem = defineComponent(
944
- selfProps => {
945
- //共同设置的属性
946
- const itemProps = {
947
- tooltip: props.config.tooltip,
948
- color: props.color,
949
- zIndex: props.zIndex + 1,
950
- name: selfProps.name
951
- }
952
- const btnRef = ref<InstanceType<typeof Button> | null>(null)
953
- return () => {
954
- //撤销按钮
955
- if (itemProps.name == 'undo' && undoConfig.value.show) {
956
- return h(
957
- Button,
958
- {
959
- ...itemProps,
960
- title: $editTrans('undo'),
961
- leftBorder: undoConfig.value.leftBorder,
962
- rightBorder: undoConfig.value.rightBorder,
963
- disabled: undoConfig.value.disabled || selfProps.disabled || disabled.value,
964
- active: undoConfig.value.active,
965
- onOperate: handleOperate
966
- },
967
- () => h(Icon, { value: 'undo' })
968
- )
969
- }
970
- //重做按钮
971
- if (itemProps.name == 'redo' && redoConfig.value.show) {
972
- return h(
973
- Button,
974
- {
975
- ...itemProps,
976
- title: $editTrans('redo'),
977
- leftBorder: redoConfig.value.leftBorder,
978
- rightBorder: redoConfig.value.rightBorder,
979
- disabled: redoConfig.value.disabled || selfProps.disabled || disabled.value,
980
- active: redoConfig.value.active,
981
- onOperate: handleOperate
982
- },
983
- () => h(Icon, { value: 'redo' })
984
- )
985
- }
986
- //标题按钮
987
- if (itemProps.name == 'heading' && headingConfig.value.show) {
988
- return h(Button, {
989
- ...itemProps,
990
- type: 'display',
991
- displayConfig: headingConfig.value.displayConfig,
992
- title: $editTrans('heading'),
993
- leftBorder: headingConfig.value.leftBorder,
994
- rightBorder: headingConfig.value.rightBorder,
995
- disabled: headingConfig.value.disabled || selfProps.disabled || disabled.value,
996
- active: headingConfig.value.active,
997
- onOperate: handleOperate
998
- })
999
- }
1000
- //缩进按钮
1001
- if (itemProps.name == 'indent' && indentConfig.value.show) {
1002
- return h(
1003
- Button,
1004
- {
1005
- ...itemProps,
1006
- type: 'select',
1007
- selectConfig: indentConfig.value.selectConfig,
1008
- title: $editTrans('indent'),
1009
- leftBorder: indentConfig.value.leftBorder,
1010
- rightBorder: indentConfig.value.rightBorder,
1011
- disabled: indentConfig.value.disabled || selfProps.disabled || disabled.value,
1012
- active: indentConfig.value.active,
1013
- onOperate: handleOperate
1014
- },
1015
- () => h(Icon, { value: 'indent-increase' })
1016
- )
1017
- }
1018
- //引用按钮
1019
- if (itemProps.name == 'quote' && quoteConfig.value.show) {
1020
- return h(
1021
- Button,
1022
- {
1023
- ...itemProps,
1024
- title: $editTrans('quote'),
1025
- leftBorder: quoteConfig.value.leftBorder,
1026
- rightBorder: quoteConfig.value.rightBorder,
1027
- disabled: quoteConfig.value.disabled || selfProps.disabled || disabled.value,
1028
- active: quoteConfig.value.active,
1029
- onOperate: handleOperate
1030
- },
1031
- () => h(Icon, { value: 'quote' })
1032
- )
1033
- }
1034
- //分隔线按钮
1035
- if (itemProps.name == 'separator' && separatorConfig.value.show) {
1036
- return h(
1037
- Button,
1038
- {
1039
- ...itemProps,
1040
- title: $editTrans('separator'),
1041
- leftBorder: separatorConfig.value.leftBorder,
1042
- rightBorder: separatorConfig.value.rightBorder,
1043
- disabled: separatorConfig.value.disabled || selfProps.disabled || disabled.value,
1044
- active: separatorConfig.value.active,
1045
- onOperate: handleOperate
1046
- },
1047
- () => h(Icon, { value: 'separator' })
1048
- )
1049
- }
1050
- //对齐方式按钮
1051
- if (itemProps.name == 'align' && alignConfig.value.show) {
1052
- return h(
1053
- Button,
1054
- {
1055
- ...itemProps,
1056
- type: 'select',
1057
- selectConfig: alignConfig.value.selectConfig,
1058
- title: $editTrans('align'),
1059
- leftBorder: alignConfig.value.leftBorder,
1060
- rightBorder: alignConfig.value.rightBorder,
1061
- disabled: alignConfig.value.disabled || selfProps.disabled || disabled.value,
1062
- active: alignConfig.value.active,
1063
- onOperate: handleOperate
1064
- },
1065
- () => h(Icon, { value: 'align-left' })
1066
- )
1067
- }
1068
- //有序列表按钮
1069
- if (itemProps.name == 'orderList' && orderListConfig.value.show) {
1070
- return h(
1071
- Button,
1072
- {
1073
- ...itemProps,
1074
- title: $editTrans('orderList'),
1075
- leftBorder: orderListConfig.value.leftBorder,
1076
- rightBorder: orderListConfig.value.rightBorder,
1077
- disabled: orderListConfig.value.disabled || selfProps.disabled || disabled.value,
1078
- active: orderListConfig.value.active,
1079
- onOperate: handleOperate
1080
- },
1081
- () => h(Icon, { value: 'list-ordered' })
1082
- )
1083
- }
1084
- //无序列表按钮
1085
- if (itemProps.name == 'unorderList' && unorderListConfig.value.show) {
1086
- return h(
1087
- Button,
1088
- {
1089
- ...itemProps,
1090
- title: $editTrans('unorderList'),
1091
- leftBorder: unorderListConfig.value.leftBorder,
1092
- rightBorder: unorderListConfig.value.rightBorder,
1093
- disabled: unorderListConfig.value.disabled || selfProps.disabled || disabled.value,
1094
- active: unorderListConfig.value.active,
1095
- onOperate: handleOperate
1096
- },
1097
- () => h(Icon, { value: 'list-unordered' })
1098
- )
1099
- }
1100
- //任务列表按钮
1101
- if (itemProps.name == 'task' && taskConfig.value.show) {
1102
- return h(
1103
- Button,
1104
- {
1105
- ...itemProps,
1106
- title: $editTrans('task'),
1107
- leftBorder: taskConfig.value.leftBorder,
1108
- rightBorder: taskConfig.value.rightBorder,
1109
- disabled: taskConfig.value.disabled || selfProps.disabled || disabled.value,
1110
- active: taskConfig.value.active,
1111
- onOperate: handleOperate
1112
- },
1113
- () => h(Icon, { value: 'task' })
1114
- )
1115
- }
1116
- //粗体按钮
1117
- if (itemProps.name == 'bold' && boldConfig.value.show) {
1118
- return h(
1119
- Button,
1120
- {
1121
- ...itemProps,
1122
- title: $editTrans('bold'),
1123
- leftBorder: boldConfig.value.leftBorder,
1124
- rightBorder: boldConfig.value.rightBorder,
1125
- disabled: boldConfig.value.disabled || selfProps.disabled || disabled.value,
1126
- active: boldConfig.value.active,
1127
- onOperate: handleOperate
1128
- },
1129
- () => h(Icon, { value: 'bold' })
1130
- )
1131
- }
1132
- //下划线按钮
1133
- if (itemProps.name == 'underline' && underlineConfig.value.show) {
1134
- return h(
1135
- Button,
1136
- {
1137
- ...itemProps,
1138
- title: $editTrans('underline'),
1139
- leftBorder: underlineConfig.value.leftBorder,
1140
- rightBorder: underlineConfig.value.rightBorder,
1141
- disabled: underlineConfig.value.disabled || selfProps.disabled || disabled.value,
1142
- active: underlineConfig.value.active,
1143
- onOperate: handleOperate
1144
- },
1145
- () => h(Icon, { value: 'underline' })
1146
- )
1147
- }
1148
- //斜体按钮
1149
- if (itemProps.name == 'italic' && italicConfig.value.show) {
1150
- return h(
1151
- Button,
1152
- {
1153
- ...itemProps,
1154
- title: $editTrans('italic'),
1155
- leftBorder: italicConfig.value.leftBorder,
1156
- rightBorder: italicConfig.value.rightBorder,
1157
- disabled: italicConfig.value.disabled || selfProps.disabled || disabled.value,
1158
- active: italicConfig.value.active,
1159
- onOperate: handleOperate
1160
- },
1161
- () => h(Icon, { value: 'italic' })
1162
- )
1163
- }
1164
- //删除线按钮
1165
- if (itemProps.name == 'strikethrough' && strikethroughConfig.value.show) {
1166
- return h(
1167
- Button,
1168
- {
1169
- ...itemProps,
1170
- title: $editTrans('strikethrough'),
1171
- leftBorder: strikethroughConfig.value.leftBorder,
1172
- rightBorder: strikethroughConfig.value.rightBorder,
1173
- disabled: strikethroughConfig.value.disabled || selfProps.disabled || disabled.value,
1174
- active: strikethroughConfig.value.active,
1175
- onOperate: handleOperate
1176
- },
1177
- () => h(Icon, { value: 'strikethrough' })
1178
- )
1179
- }
1180
- //行内代码按钮
1181
- if (itemProps.name == 'code' && codeConfig.value.show) {
1182
- return h(
1183
- Button,
1184
- {
1185
- ...itemProps,
1186
- title: $editTrans('code'),
1187
- leftBorder: codeConfig.value.leftBorder,
1188
- rightBorder: codeConfig.value.rightBorder,
1189
- disabled: codeConfig.value.disabled || selfProps.disabled || disabled.value,
1190
- active: codeConfig.value.active,
1191
- onOperate: handleOperate
1192
- },
1193
- () => h(Icon, { value: 'code' })
1194
- )
1195
- }
1196
- //上标按钮
1197
- if (itemProps.name == 'super' && superConfig.value.show) {
1198
- return h(
1199
- Button,
1200
- {
1201
- ...itemProps,
1202
- title: $editTrans('superscript'),
1203
- leftBorder: superConfig.value.leftBorder,
1204
- rightBorder: superConfig.value.rightBorder,
1205
- disabled: superConfig.value.disabled || selfProps.disabled || disabled.value,
1206
- active: superConfig.value.active,
1207
- onOperate: handleOperate
1208
- },
1209
- () => h(Icon, { value: 'superscript' })
1210
- )
1211
- }
1212
- //下标按钮
1213
- if (itemProps.name == 'sub' && subConfig.value.show) {
1214
- return h(
1215
- Button,
1216
- {
1217
- ...itemProps,
1218
- title: $editTrans('subscript'),
1219
- leftBorder: subConfig.value.leftBorder,
1220
- rightBorder: subConfig.value.rightBorder,
1221
- disabled: subConfig.value.disabled || selfProps.disabled || disabled.value,
1222
- active: subConfig.value.active,
1223
- onOperate: handleOperate
1224
- },
1225
- () => h(Icon, { value: 'subscript' })
1226
- )
1227
- }
1228
- //清除格式按钮
1229
- if (itemProps.name == 'formatClear' && formatClearConfig.value.show) {
1230
- return h(
1231
- Button,
1232
- {
1233
- ...itemProps,
1234
- title: $editTrans('formatClear'),
1235
- leftBorder: formatClearConfig.value.leftBorder,
1236
- rightBorder: formatClearConfig.value.rightBorder,
1237
- disabled: formatClearConfig.value.disabled || selfProps.disabled || disabled.value,
1238
- active: formatClearConfig.value.active,
1239
- onOperate: handleOperate
1240
- },
1241
- () => h(Icon, { value: 'format-clear' })
1242
- )
1243
- }
1244
- //字号按钮
1245
- if (itemProps.name == 'fontSize' && fontSizeConfig.value.show) {
1246
- return h(Button, {
1247
- ...itemProps,
1248
- type: 'display',
1249
- displayConfig: fontSizeConfig.value.displayConfig,
1250
- title: $editTrans('fontSize'),
1251
- leftBorder: fontSizeConfig.value.leftBorder,
1252
- rightBorder: fontSizeConfig.value.rightBorder,
1253
- disabled: fontSizeConfig.value.disabled || selfProps.disabled || disabled.value,
1254
- active: fontSizeConfig.value.active,
1255
- onOperate: handleOperate
1256
- })
1257
- }
1258
- //字体按钮
1259
- if (itemProps.name == 'fontFamily' && fontFamilyConfig.value.show) {
1260
- return h(Button, {
1261
- ...itemProps,
1262
- type: 'display',
1263
- displayConfig: fontFamilyConfig.value.displayConfig,
1264
- title: $editTrans('fontFamily'),
1265
- leftBorder: fontFamilyConfig.value.leftBorder,
1266
- rightBorder: fontFamilyConfig.value.rightBorder,
1267
- disabled: fontFamilyConfig.value.disabled || selfProps.disabled || disabled.value,
1268
- active: fontFamilyConfig.value.active,
1269
- onOperate: handleOperate
1270
- })
1271
- }
1272
- //行高按钮
1273
- if (itemProps.name == 'lineHeight' && lineHeightConfig.value.show) {
1274
- return h(Button, {
1275
- ...itemProps,
1276
- type: 'display',
1277
- displayConfig: lineHeightConfig.value.displayConfig,
1278
- title: $editTrans('lineHeight'),
1279
- leftBorder: lineHeightConfig.value.leftBorder,
1280
- rightBorder: lineHeightConfig.value.rightBorder,
1281
- disabled: lineHeightConfig.value.disabled || selfProps.disabled || disabled.value,
1282
- active: lineHeightConfig.value.active,
1283
- onOperate: handleOperate
1284
- })
1285
- }
1286
- //前景色按钮
1287
- if (itemProps.name == 'foreColor' && foreColorConfig.value.show) {
1288
- return h(
1289
- Button,
1290
- {
1291
- ...itemProps,
1292
- ref: btnRef,
1293
- type: 'select',
1294
- selectConfig: foreColorConfig.value.selectConfig,
1295
- title: $editTrans('foreColor'),
1296
- leftBorder: foreColorConfig.value.leftBorder,
1297
- rightBorder: foreColorConfig.value.rightBorder,
1298
- disabled: foreColorConfig.value.disabled || selfProps.disabled || disabled.value,
1299
- active: foreColorConfig.value.active,
1300
- hideScroll: true
1301
- },
1302
- {
1303
- default: () =>
1304
- h(Icon, {
1305
- value: 'font-color'
1306
- }),
1307
- layer: (data: ObjectType) => {
1308
- return h(Colors, {
1309
- tooltip: props.config.tooltip,
1310
- value: foreColorConfig.value.value,
1311
- data: data.options,
1312
- color: props.color,
1313
- onChange: (val: string) => {
1314
- handleOperate('foreColor', val)
1315
- btnRef.value!.show = false
1316
- }
1317
- })
1318
- }
1319
- }
1320
- )
1321
- }
1322
- //背景色按钮
1323
- if (itemProps.name == 'backColor' && backColorConfig.value.show) {
1324
- return h(
1325
- Button,
1326
- {
1327
- ...itemProps,
1328
- type: 'select',
1329
- ref: btnRef,
1330
- selectConfig: backColorConfig.value.selectConfig,
1331
- title: $editTrans('backColor'),
1332
- leftBorder: backColorConfig.value.leftBorder,
1333
- rightBorder: backColorConfig.value.rightBorder,
1334
- disabled: backColorConfig.value.disabled || selfProps.disabled || disabled.value,
1335
- active: backColorConfig.value.active,
1336
- onOperate: handleOperate,
1337
- hideScroll: true
1338
- },
1339
- {
1340
- default: () =>
1341
- h(Icon, {
1342
- value: 'brush'
1343
- }),
1344
- layer: (data: ObjectType) =>
1345
- h(Colors, {
1346
- tooltip: props.config.tooltip,
1347
- value: backColorConfig.value.value,
1348
- data: data.options,
1349
- color: props.color,
1350
- onChange: val => {
1351
- handleOperate('backColor', val)
1352
- btnRef.value!.show = false
1353
- }
1354
- })
1355
- }
1356
- )
1357
- }
1358
- //链接按钮
1359
- if (itemProps.name == 'link' && linkConfig.value.show) {
1360
- return h(
1361
- Button,
1362
- {
1363
- ...itemProps,
1364
- type: 'select',
1365
- ref: btnRef,
1366
- title: $editTrans('insertLink'),
1367
- leftBorder: linkConfig.value.leftBorder,
1368
- rightBorder: linkConfig.value.rightBorder,
1369
- disabled: linkConfig.value.disabled || selfProps.disabled || disabled.value,
1370
- active: linkConfig.value.active,
1371
- hideScroll: true,
1372
- onLayerShow: () => {
1373
- //存在选区的情况下预置链接文本值
1374
- linkConfig.value.text = getRangeText(dataRangeCaches.value)
1375
- }
1376
- },
1377
- {
1378
- default: () =>
1379
- h(Icon, {
1380
- value: 'link'
1381
- }),
1382
- layer: () =>
1383
- h(InsertLink, {
1384
- color: props.color,
1385
- text: linkConfig.value.text,
1386
- onInsert: (text, url, newOpen) => {
1387
- handleOperate('link', { text, url, newOpen })
1388
- btnRef.value!.show = false
1389
- }
1390
- })
1391
- }
1392
- )
1393
- }
1394
- //图片按钮
1395
- if (itemProps.name == 'image' && imageConfig.value.show) {
1396
- return h(
1397
- Button,
1398
- {
1399
- ...itemProps,
1400
- type: 'select',
1401
- ref: btnRef,
1402
- title: $editTrans('insertImage'),
1403
- leftBorder: imageConfig.value.leftBorder,
1404
- rightBorder: imageConfig.value.rightBorder,
1405
- disabled: imageConfig.value.disabled || selfProps.disabled || disabled.value,
1406
- active: imageConfig.value.active,
1407
- hideScroll: true
1408
- },
1409
- {
1410
- default: () =>
1411
- h(Icon, {
1412
- value: 'image'
1413
- }),
1414
- layer: () =>
1415
- h(InsertImage, {
1416
- color: props.color,
1417
- allowedFileType: imageConfig.value.allowedFileType,
1418
- multiple: imageConfig.value.multiple,
1419
- maxSize: imageConfig.value.maxSize,
1420
- minSize: imageConfig.value.minSize,
1421
- customUpload: imageConfig.value.customUpload,
1422
- handleError: imageConfig.value.handleError,
1423
- onChange: () => {
1424
- btnRef.value!.layerRef!.setPosition()
1425
- },
1426
- onInsert: (urls: string[]) => {
1427
- handleOperate('image', urls)
1428
- btnRef.value!.show = false
1429
- }
1430
- })
1431
- }
1432
- )
1433
- }
1434
- //视频按钮
1435
- if (itemProps.name == 'video' && videoConfig.value.show) {
1436
- return h(
1437
- Button,
1438
- {
1439
- ...itemProps,
1440
- type: 'select',
1441
- ref: btnRef,
1442
- title: $editTrans('insertVideo'),
1443
- leftBorder: videoConfig.value.leftBorder,
1444
- rightBorder: videoConfig.value.rightBorder,
1445
- disabled: videoConfig.value.disabled || selfProps.disabled || disabled.value,
1446
- active: videoConfig.value.active,
1447
- hideScroll: true
1448
- },
1449
- {
1450
- default: () =>
1451
- h(Icon, {
1452
- value: 'video'
1453
- }),
1454
- layer: () =>
1455
- h(InsertVideo, {
1456
- color: props.color,
1457
- allowedFileType: videoConfig.value.allowedFileType,
1458
- multiple: videoConfig.value.multiple,
1459
- maxSize: videoConfig.value.maxSize,
1460
- minSize: videoConfig.value.minSize,
1461
- customUpload: videoConfig.value.customUpload,
1462
- handleError: videoConfig.value.handleError,
1463
- onChange: () => {
1464
- btnRef.value!.layerRef!.setPosition()
1465
- },
1466
- onInsert: (urls: string[]) => {
1467
- handleOperate('video', urls)
1468
- btnRef.value!.show = false
1469
- }
1470
- })
1471
- }
1472
- )
1473
- }
1474
- //表格按钮
1475
- if (itemProps.name == 'table' && tableConfig.value.show) {
1476
- return h(
1477
- Button,
1478
- {
1479
- ...itemProps,
1480
- type: 'select',
1481
- ref: btnRef,
1482
- title: $editTrans('insertTable'),
1483
- leftBorder: tableConfig.value.leftBorder,
1484
- rightBorder: tableConfig.value.rightBorder,
1485
- disabled: tableConfig.value.disabled || selfProps.disabled || disabled.value,
1486
- active: tableConfig.value.active,
1487
- hideScroll: true
1488
- },
1489
- {
1490
- default: () =>
1491
- h(Icon, {
1492
- value: 'table'
1493
- }),
1494
- layer: () =>
1495
- h(InsertTable, {
1496
- color: props.color,
1497
- maxRows: tableConfig.value.maxRows,
1498
- maxColumns: tableConfig.value.maxColumns,
1499
- onInsert: (row, column) => {
1500
- handleOperate('table', { row, column })
1501
- btnRef.value!.show = false
1502
- }
1503
- })
1504
- }
1505
- )
1506
- }
1507
- //代码块按钮
1508
- if (itemProps.name == 'codeBlock' && codeBlockConfig.value.show) {
1509
- return h(
1510
- Button,
1511
- {
1512
- ...itemProps,
1513
- title: $editTrans('inserCodeBlock'),
1514
- leftBorder: codeBlockConfig.value.leftBorder,
1515
- rightBorder: codeBlockConfig.value.rightBorder,
1516
- disabled: codeBlockConfig.value.disabled || selfProps.disabled || disabled.value,
1517
- active: codeBlockConfig.value.active,
1518
- onOperate: handleOperate
1519
- },
1520
- () => h(Icon, { value: 'code-block' })
1521
- )
1522
- }
1523
- //代码视图按钮
1524
- if (itemProps.name == 'sourceView' && sourceViewConfig.value.show) {
1525
- return h(
1526
- Button,
1527
- {
1528
- ...itemProps,
1529
- title: $editTrans('sourceView'),
1530
- leftBorder: sourceViewConfig.value.leftBorder,
1531
- rightBorder: sourceViewConfig.value.rightBorder,
1532
- disabled: sourceViewConfig.value.disabled || selfProps.disabled || disabled.value,
1533
- active: sourceViewConfig.value.active,
1534
- onOperate: handleOperate
1535
- },
1536
- () => h(Icon, { value: 'source-view' })
1537
- )
1538
- }
1539
- //全屏按钮
1540
- if (itemProps.name == 'fullScreen' && fullScreenConfig.value.show) {
1541
- return h(
1542
- Button,
1543
- {
1544
- ...itemProps,
1545
- title: $editTrans('fullScreen'),
1546
- leftBorder: fullScreenConfig.value.leftBorder,
1547
- rightBorder: fullScreenConfig.value.rightBorder,
1548
- disabled: fullScreenConfig.value.disabled || selfProps.disabled || disabled.value,
1549
- active: fullScreenConfig.value.active,
1550
- onOperate: handleOperate
1551
- },
1552
- () => h(Icon, { value: 'full-screen' })
1553
- )
1554
- }
1555
- /** 下面是拓展菜单的配置 */
1556
- if (DapCommon.isObject(menuExtends.value)) {
1557
- //获取菜单按钮的配置
1558
- const configuration = menuExtends.value[itemProps.name]
1559
- if (configuration) {
1560
- //渲染函数
1561
- return h(
1562
- Button,
1563
- {
1564
- ...itemProps,
1565
- ref: btnRef,
1566
- type: configuration.type || 'default',
1567
- title: configuration.title || '',
1568
- leftBorder: configuration.leftBorder || false,
1569
- rightBorder: configuration.rightBorder || false,
1570
- disabled: configuration.disabled || selfProps.disabled || disabled.value,
1571
- hideScroll: configuration.hideScroll || false,
1572
- active: configuration.active || false,
1573
- selectConfig: {
1574
- width: configuration.width,
1575
- maxHeight: configuration.maxHeight,
1576
- options: configuration.options
1577
- },
1578
- displayConfig: {
1579
- width: configuration.width,
1580
- maxHeight: configuration.maxHeight,
1581
- value: configuration.value,
1582
- options: configuration.options
1583
- },
1584
- onLayerShow: () => {
1585
- if (typeof configuration.onLayerShow == 'function') {
1586
- configuration.onLayerShow(itemProps.name, btnRef.value!)
1587
- }
1588
- },
1589
- onLayerShown: () => {
1590
- if (typeof configuration.onLayerShown == 'function') {
1591
- configuration.onLayerShown(itemProps.name, btnRef.value!)
1592
- }
1593
- },
1594
- onLayerHidden: () => {
1595
- if (typeof configuration.onLayerHidden == 'function') {
1596
- configuration.onLayerHidden(itemProps.name, btnRef.value!)
1597
- }
1598
- },
1599
- onOperate: (name, val) => {
1600
- if (typeof configuration.onOperate == 'function') {
1601
- configuration.onOperate(name, val, btnRef.value!)
1602
- }
1603
- }
1604
- },
1605
- {
1606
- default: () => {
1607
- if (configuration.default) {
1608
- return configuration.default(itemProps.name, btnRef.value!)
1609
- }
1610
- return null
1611
- },
1612
- layer: () => {
1613
- if (configuration.layer) {
1614
- return configuration.layer(itemProps.name, btnRef.value!)
1615
- }
1616
- return null
1617
- },
1618
- option: () => {
1619
- if (configuration.option) {
1620
- return configuration.option(itemProps.name, btnRef.value!)
1621
- }
1622
- return null
1623
- }
1624
- }
1625
- )
1626
- }
1627
- }
1628
- return null
1629
- }
1630
- },
1631
- {
1632
- props: {
1633
- name: String,
1634
- disabled: Boolean
1635
- }
1636
- }
1637
- )
1638
-
1639
- onMounted(() => {
1640
- height.value = menuRef.value!.offsetHeight
1641
- DapEvent.on(window, `resize.editify_menu_${instance.uid}`, () => {
1642
- height.value = menuRef.value!.offsetHeight
1643
- })
1644
- })
1645
-
1646
- onBeforeUnmount(() => {
1647
- DapEvent.off(window, `resize.editify_menu_${instance.uid}`)
1648
- })
1649
-
1650
- defineExpose({
1651
- handleRangeUpdate,
1652
- height
1653
- })
1654
- </script>
1655
- <style scoped src="./menu.less"></style>