vue-editify 0.1.46 → 0.1.48

Sign up to get free protection for your applications and to get access to all the features.
package/src/core/rule.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { AlexEditor, AlexElement } from 'alex-editor'
1
+ import { AlexEditor, AlexElement, AlexElementCreateConfigType } from 'alex-editor'
2
2
  import { LanguagesItemType, getHljsHtml } from '../hljs'
3
3
  import { isList, isTask, getTableSize, getCellSpanNumber } from './function'
4
4
  import { common as DapCommon } from 'dap-util'
5
+ import { isPanel } from '../plugins/panel'
6
+ import { isInfoBlock } from '../plugins/infoBlock'
5
7
 
6
8
  /**
7
9
  * 自动补全表格行和列
@@ -27,17 +29,19 @@ const autocompleteTableCells = (editor: AlexEditor, rowElements: AlexElement[],
27
29
  let i = 1
28
30
  //补全的数量小于需要补全的数量并且列总数量小于理论数量
29
31
  while (i < colspan && item.parent!.children!.length < columnNumber) {
30
- const column = new AlexElement(
31
- 'inblock',
32
- 'td',
33
- {
32
+ const column = AlexElement.create({
33
+ type: 'inblock',
34
+ parsedom: 'td',
35
+ marks: {
34
36
  'data-editify-merged': 'true'
35
37
  },
36
- null,
37
- null
38
- )
39
- const breakElement = new AlexElement('closed', 'br', null, null, null)
40
- editor.addElementTo(breakElement, column)
38
+ children: [
39
+ {
40
+ type: 'closed',
41
+ parsedom: 'br'
42
+ }
43
+ ]
44
+ })
41
45
  editor.addElementAfter(column, item)
42
46
  i++
43
47
  }
@@ -55,17 +59,19 @@ const autocompleteTableCells = (editor: AlexEditor, rowElements: AlexElement[],
55
59
  const nextCell = nextRow.children![index]
56
60
  //根据当前单元格的跨列数补充符合跨列数的隐藏单元格
57
61
  for (let j = 0; j < colspan; j++) {
58
- const column = new AlexElement(
59
- 'inblock',
60
- 'td',
61
- {
62
+ const column = AlexElement.create({
63
+ type: 'inblock',
64
+ parsedom: 'td',
65
+ marks: {
62
66
  'data-editify-merged': 'true'
63
67
  },
64
- null,
65
- null
66
- )
67
- const breakElement = new AlexElement('closed', 'br', null, null, null)
68
- editor.addElementTo(breakElement, column)
68
+ children: [
69
+ {
70
+ type: 'closed',
71
+ parsedom: 'br'
72
+ }
73
+ ]
74
+ })
69
75
  if (nextCell) {
70
76
  editor.addElementBefore(column, nextCell)
71
77
  } else {
@@ -84,9 +90,16 @@ const autocompleteTableCells = (editor: AlexEditor, rowElements: AlexElement[],
84
90
  const number = rowElement.children!.length
85
91
  if (number < columnNumber) {
86
92
  for (let i = 0; i < columnNumber - number; i++) {
87
- const column = new AlexElement('inblock', 'td', null, null, null)
88
- const breakElement = new AlexElement('closed', 'br', null, null, null)
89
- editor.addElementTo(breakElement, column)
93
+ const column = AlexElement.create({
94
+ type: 'inblock',
95
+ parsedom: 'td',
96
+ children: [
97
+ {
98
+ type: 'closed',
99
+ parsedom: 'br'
100
+ }
101
+ ]
102
+ })
90
103
  editor.addElementTo(column, rowElement, rowElement.children!.length)
91
104
  }
92
105
  }
@@ -96,13 +109,24 @@ const autocompleteTableCells = (editor: AlexEditor, rowElements: AlexElement[],
96
109
  //判断总行数是否小于实际行数则补全行
97
110
  if (length < rowNumber) {
98
111
  for (let i = 0; i < rowNumber - length; i++) {
99
- const row = new AlexElement('inblock', 'tr', null, null, null)
112
+ const children: AlexElementCreateConfigType[] = []
100
113
  for (let j = 0; j < columnNumber; j++) {
101
- const column = new AlexElement('inblock', 'td', null, null, null)
102
- const breakElement = new AlexElement('closed', 'br', null, null, null)
103
- editor.addElementTo(breakElement, column)
104
- editor.addElementTo(column, row)
114
+ children.push({
115
+ type: 'inblock',
116
+ parsedom: 'td',
117
+ children: [
118
+ {
119
+ type: 'closed',
120
+ parsedom: 'br'
121
+ }
122
+ ]
123
+ })
105
124
  }
125
+ const row = AlexElement.create({
126
+ type: 'inblock',
127
+ parsedom: 'tr',
128
+ children
129
+ })
106
130
  rowElements.push(row)
107
131
  }
108
132
  }
@@ -398,41 +422,44 @@ export const tableFormatHandle = (editor: AlexEditor, element: AlexElement) => {
398
422
  const length = colgroup.children!.length
399
423
  if (length < columnNumber) {
400
424
  for (let i = 0; i < columnNumber - length; i++) {
401
- const col = new AlexElement(
402
- 'closed',
403
- 'col',
404
- {
425
+ const col = AlexElement.create({
426
+ type: 'closed',
427
+ parsedom: 'col',
428
+ marks: {
405
429
  width: 'auto'
406
- },
407
- null,
408
- null
409
- )
430
+ }
431
+ })
410
432
  editor.addElementTo(col, colgroup, colgroup.children!.length)
411
433
  }
412
434
  }
413
435
  }
414
436
  //如果colgroup元素不存在则新建
415
437
  else {
416
- colgroup = new AlexElement('inblock', 'colgroup', null, null, null)
438
+ const children: AlexElementCreateConfigType[] = []
417
439
  for (let i = columnNumber - 1; i >= 0; i--) {
418
- const col = new AlexElement(
419
- 'closed',
420
- 'col',
421
- {
440
+ children.push({
441
+ type: 'closed',
442
+ parsedom: 'col',
443
+ marks: {
422
444
  width: 'auto'
423
- },
424
- null,
425
- null
426
- )
427
- editor.addElementTo(col, colgroup)
445
+ }
446
+ })
428
447
  }
448
+ colgroup = AlexElement.create({
449
+ type: 'inblock',
450
+ parsedom: 'colgroup',
451
+ children
452
+ })
429
453
  }
430
454
  //自动补全表格的单元格
431
455
  autocompleteTableCells(editor, rows, rowNumber, columnNumber)
432
456
  //清空表格
433
457
  element.children = []
434
458
  //创建tbody元素
435
- const tbody = new AlexElement('inblock', 'tbody', null, null, null)
459
+ const tbody = AlexElement.create({
460
+ type: 'inblock',
461
+ parsedom: 'tbody'
462
+ })
436
463
  //将rows全部加入表格中
437
464
  rows.forEach(row => {
438
465
  const index = tbody.hasChildren() ? tbody.children!.length : 0
@@ -587,7 +614,10 @@ export const preHandle = (editor: AlexEditor, element: AlexElement, highlight: b
587
614
  updateRangeInPre(editor, element, originalTextElements, newElements)
588
615
  } else {
589
616
  //将换行元素加入到pre子元素数组中
590
- const breakElement = new AlexElement('closed', 'br', null, null, null)
617
+ const breakElement = AlexElement.create({
618
+ type: 'closed',
619
+ parsedom: 'br'
620
+ })
591
621
  element.children = [breakElement]
592
622
  breakElement.parent = element
593
623
  if (editor.range) {
@@ -607,7 +637,7 @@ export const preHandle = (editor: AlexEditor, element: AlexElement, highlight: b
607
637
  export const specialInblockHandle = (editor: AlexEditor, element: AlexElement) => {
608
638
  if (element.hasChildren()) {
609
639
  element.children!.forEach(el => {
610
- if (isList(el, true) || isList(el, false) || isTask(el) || ['blockquote', 'pre', 'table', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'].includes(el.parsedom!)) {
640
+ if (isList(el, true) || isList(el, false) || isTask(el) || ['blockquote', 'pre', 'table', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'].includes(el.parsedom!) || isPanel(el) || isInfoBlock(el)) {
611
641
  const newEl = el.clone()
612
642
  newEl.type = 'block'
613
643
  const block = element.getBlock()
@@ -404,7 +404,58 @@
404
404
 
405
405
  &:hover {
406
406
  cursor: pointer;
407
- background: @background-dark;
407
+ background: @background-darker;
408
+ }
409
+ }
410
+
411
+ //面板样式
412
+ :deep(div[data-editify-panel]) {
413
+ display: block;
414
+ position: relative;
415
+ width: 100%;
416
+ background-color: @background-dark;
417
+ color: @font-color;
418
+ border-radius: 4px;
419
+ margin-bottom: 15px;
420
+ padding: 10px 10px 1px 10px;
421
+ border: 1px solid @border-color;
422
+
423
+ & > div {
424
+ margin: 0 0 10px 0;
425
+ font-size: @font-size;
426
+
427
+ &:first-child {
428
+ margin: 0 0 15px 0;
429
+ font-size: 18px;
430
+ border-bottom: 1px solid @border-color;
431
+ padding-bottom: 8px;
432
+ }
433
+ }
434
+ }
435
+
436
+ //信息块样式
437
+ :deep(div[data-editify-info]) {
438
+ display: block;
439
+ position: relative;
440
+ width: 100%;
441
+ border-radius: 4px;
442
+ margin-bottom: 15px;
443
+ padding: 10px 10px 10px 40px;
444
+ font-size: @font-size;
445
+
446
+ &::before {
447
+ position: absolute;
448
+ left: 0;
449
+ top: 50%;
450
+ height: 100%;
451
+ transform: translateY(-50%);
452
+ display: flex;
453
+ justify-content: center;
454
+ align-items: center;
455
+ content: '\e610';
456
+ font-family: 'editify-icon' !important;
457
+ font-size: 1.25em;
458
+ padding: 0 10px;
408
459
  }
409
460
  }
410
461
 
@@ -24,7 +24,7 @@ import { AlexEditor, AlexElement, AlexElementRangeType, AlexElementsRangeType }
24
24
  import { element as DapElement, event as DapEvent, data as DapData, number as DapNumber, color as DapColor } from 'dap-util'
25
25
  import { mergeObject, getToolbarConfig, getMenuConfig, MenuConfigType, ObjectType, ToolbarConfigType, PluginResultType } from '../core/tool'
26
26
  import { parseList, orderdListHandle, commonElementHandle, tableThTdHandle, tableFormatHandle, tableRangeMergedHandle, preHandle, specialInblockHandle } from '../core/rule'
27
- import { isTask, elementToParagraph, getMatchElementsByRange, hasTableInRange, hasLinkInRange, hasPreInRange, hasImageInRange, hasVideoInRange } from '../core/function'
27
+ import { isTask, elementToParagraph, getMatchElementByRange, hasTableInRange, hasLinkInRange, hasPreInRange, hasImageInRange, hasVideoInRange } from '../core/function'
28
28
  import Toolbar from '../components/toolbar/toolbar.vue'
29
29
  import Menu from '../components/menu/menu.vue'
30
30
  import Layer from '../components/layer/layer.vue'
@@ -180,15 +180,15 @@ const handleToolbar = () => {
180
180
  }
181
181
  hideToolbar()
182
182
  nextTick(() => {
183
- const tables = getMatchElementsByRange(editor.value!, dataRangeCaches.value, { parsedom: 'table' })
184
- const pres = getMatchElementsByRange(editor.value!, dataRangeCaches.value, { parsedom: 'pre' })
185
- const links = getMatchElementsByRange(editor.value!, dataRangeCaches.value, { parsedom: 'a' })
186
- const images = getMatchElementsByRange(editor.value!, dataRangeCaches.value, { parsedom: 'img' })
187
- const videos = getMatchElementsByRange(editor.value!, dataRangeCaches.value, { parsedom: 'video' })
183
+ const table = getMatchElementByRange(editor.value!, dataRangeCaches.value, { parsedom: 'table' })
184
+ const pre = getMatchElementByRange(editor.value!, dataRangeCaches.value, { parsedom: 'pre' })
185
+ const link = getMatchElementByRange(editor.value!, dataRangeCaches.value, { parsedom: 'a' })
186
+ const image = getMatchElementByRange(editor.value!, dataRangeCaches.value, { parsedom: 'img' })
187
+ const video = getMatchElementByRange(editor.value!, dataRangeCaches.value, { parsedom: 'video' })
188
188
  //显示链接工具条
189
- if (links.length == 1) {
189
+ if (link) {
190
190
  toolbarOptions.value.type = 'link'
191
- toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${links[0].key}"]`
191
+ toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${link.key}"]`
192
192
  if (toolbarOptions.value.show) {
193
193
  ;(<InstanceType<typeof Layer>>toolbarRef.value!.$refs.layerRef).setPosition()
194
194
  } else {
@@ -196,9 +196,9 @@ const handleToolbar = () => {
196
196
  }
197
197
  }
198
198
  //显示图片工具条
199
- else if (images.length == 1) {
199
+ else if (image) {
200
200
  toolbarOptions.value.type = 'image'
201
- toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${images[0].key}"]`
201
+ toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${image.key}"]`
202
202
  if (toolbarOptions.value.show) {
203
203
  ;(<InstanceType<typeof Layer>>toolbarRef.value!.$refs.layerRef).setPosition()
204
204
  } else {
@@ -206,9 +206,9 @@ const handleToolbar = () => {
206
206
  }
207
207
  }
208
208
  //显示视频工具条
209
- else if (videos.length == 1) {
209
+ else if (video) {
210
210
  toolbarOptions.value.type = 'video'
211
- toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${videos[0].key}"]`
211
+ toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${video.key}"]`
212
212
  if (toolbarOptions.value.show) {
213
213
  ;(<InstanceType<typeof Layer>>toolbarRef.value!.$refs.layerRef).setPosition()
214
214
  } else {
@@ -216,9 +216,9 @@ const handleToolbar = () => {
216
216
  }
217
217
  }
218
218
  //显示表格工具条
219
- else if (tables.length == 1) {
219
+ else if (table) {
220
220
  toolbarOptions.value.type = 'table'
221
- toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${tables[0].key}"]`
221
+ toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${table.key}"]`
222
222
  if (toolbarOptions.value.show) {
223
223
  ;(<InstanceType<typeof Layer>>toolbarRef.value!.$refs.layerRef).setPosition()
224
224
  } else {
@@ -226,9 +226,9 @@ const handleToolbar = () => {
226
226
  }
227
227
  }
228
228
  //显示代码块工具条
229
- else if (pres.length == 1) {
229
+ else if (pre) {
230
230
  toolbarOptions.value.type = 'codeBlock'
231
- toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${pres[0].key}"]`
231
+ toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${pre.key}"]`
232
232
  if (toolbarOptions.value.show) {
233
233
  ;(<InstanceType<typeof Layer>>toolbarRef.value!.$refs.layerRef).setPosition()
234
234
  } else {
@@ -410,11 +410,11 @@ const documentMouseMove = (e: Event) => {
410
410
  }
411
411
  //表格列宽拖拽
412
412
  if (resizeParams.value.element.parsedom == 'td') {
413
- const tables = getMatchElementsByRange(editor.value!, dataRangeCaches.value, { parsedom: 'table' })
414
- if (tables.length != 1) {
413
+ const table = getMatchElementByRange(editor.value!, dataRangeCaches.value, { parsedom: 'table' })
414
+ if (!table) {
415
415
  return
416
416
  }
417
- const colgroup = tables[0].children!.find(item => {
417
+ const colgroup = table.children!.find(item => {
418
418
  return item.parsedom == 'colgroup'
419
419
  })!
420
420
  const index = resizeParams.value.element.parent!.children!.findIndex(el => {
@@ -453,11 +453,11 @@ const documentMouseUp = () => {
453
453
  }
454
454
  //表格列宽拖拽
455
455
  if (resizeParams.value.element.parsedom == 'td') {
456
- const tables = getMatchElementsByRange(editor.value!, dataRangeCaches.value, { parsedom: 'table' })
457
- if (tables.length != 1) {
456
+ const table = getMatchElementByRange(editor.value!, dataRangeCaches.value, { parsedom: 'table' })
457
+ if (!table) {
458
458
  return
459
459
  }
460
- const colgroup = tables[0].children!.find(item => {
460
+ const colgroup = table.children!.find(item => {
461
461
  return item.parsedom == 'colgroup'
462
462
  })!
463
463
  const index = resizeParams.value.element.parent!.children!.findIndex(el => {
@@ -663,14 +663,13 @@ const handleCustomHtmlPaste = async (elements: AlexElement[]) => {
663
663
  }
664
664
  //默认粘贴html
665
665
  else {
666
- for (let i = 0; i < elements.length; i++) {
667
- //第一个元素会在当前光标所在根级块元素只有一个换行符时进行覆盖
668
- if (i == 0) {
669
- editor.value!.insertElement(elements[i])
670
- } else {
671
- editor.value!.insertElement(elements[i], false)
672
- }
666
+ //第一个元素会在当前光标所在根级块元素只有一个换行符时进行覆盖
667
+ editor.value!.insertElement(elements[0])
668
+ for (let i = elements.length - 1; i >= 1; i--) {
669
+ editor.value!.addElementAfter(elements[i], elements[0])
673
670
  }
671
+ editor.value!.range!.anchor.moveToEnd(elements[elements.length - 1])
672
+ editor.value!.range!.focus.moveToEnd(elements[elements.length - 1])
674
673
  }
675
674
  }
676
675
  //重新定义编辑器合并元素的逻辑
@@ -865,6 +864,7 @@ const handleRangeUpdate = () => {
865
864
  }
866
865
  //编辑器部分删除情景(在编辑器起始处)
867
866
  const handleDeleteInStart = (element: AlexElement) => {
867
+ //根级块转为段落
868
868
  if (element.isBlock()) {
869
869
  elementToParagraph(element)
870
870
  }
@@ -1,3 +1,11 @@
1
+ .editify-icon-info:before {
2
+ content: '\e610';
3
+ }
4
+
5
+ .editify-icon-panel:before {
6
+ content: '\e6c0';
7
+ }
8
+
1
9
  .editify-icon-merge-cells-up:before {
2
10
  content: '\e73e';
3
11
  }
Binary file
Binary file
package/src/index.ts CHANGED
@@ -12,14 +12,14 @@ export type { MenuButtonType, MenuSelectButtonType, MenuDisplayButtonType, MenuI
12
12
  export type { ElementMatchConfigType } from './core/function'
13
13
 
14
14
  //导出编辑器操作方法
15
- export { elementIsMatch, getMatchElementByElement, getMatchElementsByRange, elementIsInList, elementIsInTask, isList, isTask, hasPreInRange, isRangeInPre, hasQuoteInRange, isRangeInQuote, hasListInRange, isRangeInList, hasTaskInRange, isRangeInTask, hasLinkInRange, hasTableInRange, hasImageInRange, hasVideoInRange, queryTextStyle, queryTextMark, getRangeText, setIndentIncrease, setIndentDecrease, setQuote, setAlign, setList, setTask, setTextStyle, setTextMark, removeTextStyle, removeTextMark, setLineHeight, insertLink, insertImage, insertVideo, insertTable, insertCodeBlock, insertSeparator } from './core/function'
15
+ export { elementIsMatch, getMatchElementByElement, getMatchElementByRange, isList, isTask, elementIsInList, elementIsInTask, hasPreInRange, hasQuoteInRange, hasListInRange, hasTaskInRange, hasLinkInRange, hasTableInRange, hasImageInRange, hasVideoInRange, isRangeInQuote, isRangeInList, isRangeInTask, queryTextStyle, queryTextMark, getRangeText, setIndentIncrease, setIndentDecrease, setQuote, setAlign, setList, setTask, setTextStyle, setTextMark, removeTextStyle, removeTextMark, setLineHeight, insertLink, insertImage, insertVideo, insertTable, insertCodeBlock, insertSeparator } from './core/function'
16
16
 
17
17
  //安装函数
18
18
  const install: FunctionPlugin = (app: App) => {
19
19
  app.component(Editify.name!, Editify)
20
20
  }
21
21
  //版本号
22
- const version = '0.1.46'
22
+ const version = '0.1.48'
23
23
 
24
24
  //导出AlexElement元素
25
25
  export { AlexElement } from 'alex-editor'
@@ -31,6 +31,12 @@ export { attachment, isAttachment, hasAttachmentInRange } from './plugins/attach
31
31
  //导出mathformula插件相关的方法和类型
32
32
  export type { MathformulaOptionsType } from './plugins/mathformula'
33
33
  export { mathformula, isMathformula, isUnderMathformula, getMathformulaElement, hasMathformulaInRange, getMathformulaElementByRange } from './plugins/mathformula'
34
+ //导出panel插件相关的方法和类型
35
+ export type { PanelOptionsType } from './plugins/panel'
36
+ export { panel, isPanel, isUnderPanel, getPanelElement, hasPanelInRange, getPanelElementByRange } from './plugins/panel'
37
+ //导出infoBlock插件相关的方法和类型
38
+ export type { InfoBlockOptionsType } from './plugins/infoBlock'
39
+ export { infoBlock, isInfoBlock, isUnderInfoBlock, getInfoBlockElement, hasInfoBlockInRange, getInfoBlockElementByRange } from './plugins/infoBlock'
34
40
 
35
41
  //导出组件和安装函数
36
42
  export { install as default, install, Editify, version }
@@ -104,5 +104,13 @@ export const en_US: ObjectType = {
104
104
  //数学公式插件语言配置
105
105
  insertMathformula: 'Insert mathematical formula',
106
106
  editMathformula: 'Edit mathematical formula',
107
- mathformulaPlaceholder: 'Please enter LaTex syntax'
107
+ mathformulaPlaceholder: 'Please enter LaTex syntax',
108
+
109
+ //面板插件语言配置
110
+ insertPanel: 'Insert Panel',
111
+ panelTitle: 'Here is the title',
112
+ panelContent: 'Here is the content',
113
+
114
+ //信息插件语言配置
115
+ insertInfoBlock: 'Insert Information Block'
108
116
  }
@@ -104,5 +104,13 @@ export const zh_CN: ObjectType = {
104
104
  //数学公式插件语言配置
105
105
  insertMathformula: '插入数学公式',
106
106
  editMathformula: '编辑数学公式',
107
- mathformulaPlaceholder: '请输入LaTex语法'
107
+ mathformulaPlaceholder: '请输入LaTex语法',
108
+
109
+ //面板插件语言配置
110
+ insertPanel: '插入面板',
111
+ panelTitle: '这里是标题',
112
+ panelContent: '这里是内容',
113
+
114
+ //信息插件语言配置
115
+ insertInfoBlock: '插入信息块'
108
116
  }
@@ -7,7 +7,7 @@ import Icon from '../../components/icon/icon.vue'
7
7
  import InsertAttachment from './insertAttachment/insertAttachment.vue'
8
8
  import { InsertAttachmentUploadErrorType } from './insertAttachment/props'
9
9
  import { event as DapEvent, common as DapCommon } from 'dap-util'
10
- import { hasLinkInRange, hasPreInRange, hasQuoteInRange } from '../../core/function'
10
+ import { hasPreInRange } from '../../core/function'
11
11
  import { hasMathformulaInRange } from '../mathformula'
12
12
 
13
13
  export type AttachmentOptionsType = {
@@ -78,9 +78,9 @@ export const attachment = (options?: AttachmentOptionsType) => {
78
78
  }
79
79
  const plugin: PluginType = (editifyInstance: ComponentInternalInstance, editTrans: (key: string) => any) => {
80
80
  let isDisabled = false
81
- //如果光标范围内有数学公式、链接、代码块和引用则禁用
81
+ //如果光标选区内有数学公式、代码块则禁用
82
82
  if (editifyInstance.exposed!.editor.value) {
83
- isDisabled = hasMathformulaInRange(editifyInstance.exposed!.editor.value, editifyInstance.exposed!.dataRangeCaches.value) || hasPreInRange(editifyInstance.exposed!.editor.value, editifyInstance.exposed!.dataRangeCaches.value) || hasLinkInRange(editifyInstance.exposed!.editor.value, editifyInstance.exposed!.dataRangeCaches.value) || hasQuoteInRange(editifyInstance.exposed!.editor.value, editifyInstance.exposed!.dataRangeCaches.value)
83
+ isDisabled = hasMathformulaInRange(editifyInstance.exposed!.editor.value, editifyInstance.exposed!.dataRangeCaches.value) || hasPreInRange(editifyInstance.exposed!.editor.value, editifyInstance.exposed!.dataRangeCaches.value)
84
84
  }
85
85
  return {
86
86
  name: 'attachment',
@@ -88,8 +88,8 @@ export const attachment = (options?: AttachmentOptionsType) => {
88
88
  menu: {
89
89
  sequence: options!.sequence || 100,
90
90
  extraDisabled: (name: string) => {
91
- //如果光标选区内有附件则禁用链接菜单、引用菜单、代码块菜单
92
- if (name == 'link' || name == 'quote' || name == 'codeBlock') {
91
+ //如果光标选区内有附件则禁用链接菜单、代码块菜单
92
+ if (name == 'link' || name == 'codeBlock') {
93
93
  return hasAttachmentInRange(editifyInstance.exposed!.editor.value, editifyInstance.exposed!.dataRangeCaches.value)
94
94
  }
95
95
  return false
@@ -132,7 +132,11 @@ export const attachment = (options?: AttachmentOptionsType) => {
132
132
  'data-editify-attachment-name': name || editTrans('attachmentDefaultName')
133
133
  }
134
134
  //创建元素
135
- const attachmentElement = new AlexElement('closed', 'span', marks, null, null)
135
+ const attachmentElement = AlexElement.create({
136
+ type: 'closed',
137
+ parsedom: 'span',
138
+ marks
139
+ })
136
140
  //插入编辑器
137
141
  editor.insertElement(attachmentElement)
138
142
  //移动光标到新插入的元素