vue-editify 0.1.47 → 0.1.49
Sign up to get free protection for your applications and to get access to all the features.
- package/examples/App.vue +30 -51
- package/lib/core/function.d.ts +50 -63
- package/lib/editify.es.js +18722 -18114
- package/lib/editify.umd.js +1 -1
- package/lib/index.d.ts +6 -2
- package/lib/plugins/infoBlock/index.d.ts +55 -0
- package/lib/plugins/panel/index.d.ts +48 -0
- package/lib/style.css +1 -1
- package/package.json +2 -2
- package/src/components/menu/menu.vue +14 -13
- package/src/components/toolbar/toolbar.vue +146 -111
- package/src/core/function.ts +249 -183
- package/src/core/rule.ts +78 -48
- package/src/editify/editify.less +52 -1
- package/src/editify/editify.vue +29 -29
- package/src/icon/iconfont.css +8 -0
- package/src/icon/iconfont.ttf +0 -0
- package/src/icon/iconfont.woff +0 -0
- package/src/index.ts +8 -2
- package/src/locale/en_US.ts +9 -1
- package/src/locale/zh_CN.ts +9 -1
- package/src/plugins/attachment/index.ts +10 -6
- package/src/plugins/infoBlock/index.ts +238 -0
- package/src/plugins/mathformula/index.ts +1 -3
- package/src/plugins/panel/index.ts +228 -0
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 =
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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 =
|
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
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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 =
|
88
|
-
|
89
|
-
|
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
|
112
|
+
const children: AlexElementCreateConfigType[] = []
|
100
113
|
for (let j = 0; j < columnNumber; j++) {
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
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 =
|
402
|
-
'closed',
|
403
|
-
'col',
|
404
|
-
{
|
425
|
+
const col = AlexElement.create({
|
426
|
+
type: 'closed',
|
427
|
+
parsedom: 'col',
|
428
|
+
marks: {
|
405
429
|
width: 'auto'
|
406
|
-
}
|
407
|
-
|
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
|
-
|
438
|
+
const children: AlexElementCreateConfigType[] = []
|
417
439
|
for (let i = columnNumber - 1; i >= 0; i--) {
|
418
|
-
|
419
|
-
'closed',
|
420
|
-
'col',
|
421
|
-
{
|
440
|
+
children.push({
|
441
|
+
type: 'closed',
|
442
|
+
parsedom: 'col',
|
443
|
+
marks: {
|
422
444
|
width: 'auto'
|
423
|
-
}
|
424
|
-
|
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 =
|
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 =
|
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()
|
package/src/editify/editify.less
CHANGED
@@ -404,7 +404,58 @@
|
|
404
404
|
|
405
405
|
&:hover {
|
406
406
|
cursor: pointer;
|
407
|
-
background: @background-
|
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 60px;
|
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 20px;
|
408
459
|
}
|
409
460
|
}
|
410
461
|
|
package/src/editify/editify.vue
CHANGED
@@ -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,
|
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
|
184
|
-
const
|
185
|
-
const
|
186
|
-
const
|
187
|
-
const
|
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 (
|
189
|
+
if (link) {
|
190
190
|
toolbarOptions.value.type = 'link'
|
191
|
-
toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${
|
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 (
|
199
|
+
else if (image) {
|
200
200
|
toolbarOptions.value.type = 'image'
|
201
|
-
toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${
|
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 (
|
209
|
+
else if (video) {
|
210
210
|
toolbarOptions.value.type = 'video'
|
211
|
-
toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${
|
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 (
|
219
|
+
else if (table) {
|
220
220
|
toolbarOptions.value.type = 'table'
|
221
|
-
toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${
|
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 (
|
229
|
+
else if (pre) {
|
230
230
|
toolbarOptions.value.type = 'codeBlock'
|
231
|
-
toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${
|
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
|
414
|
-
if (
|
413
|
+
const table = getMatchElementByRange(editor.value!, dataRangeCaches.value, { parsedom: 'table' })
|
414
|
+
if (!table) {
|
415
415
|
return
|
416
416
|
}
|
417
|
-
const colgroup =
|
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
|
457
|
-
if (
|
456
|
+
const table = getMatchElementByRange(editor.value!, dataRangeCaches.value, { parsedom: 'table' })
|
457
|
+
if (!table) {
|
458
458
|
return
|
459
459
|
}
|
460
|
-
const colgroup =
|
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
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
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
|
}
|
package/src/icon/iconfont.css
CHANGED
package/src/icon/iconfont.ttf
CHANGED
Binary file
|
package/src/icon/iconfont.woff
CHANGED
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,
|
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.
|
22
|
+
const version = '0.1.49'
|
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 }
|
package/src/locale/en_US.ts
CHANGED
@@ -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
|
}
|
package/src/locale/zh_CN.ts
CHANGED
@@ -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 {
|
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)
|
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 == '
|
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 =
|
135
|
+
const attachmentElement = AlexElement.create({
|
136
|
+
type: 'closed',
|
137
|
+
parsedom: 'span',
|
138
|
+
marks
|
139
|
+
})
|
136
140
|
//插入编辑器
|
137
141
|
editor.insertElement(attachmentElement)
|
138
142
|
//移动光标到新插入的元素
|