zydx-plus 1.32.298 → 1.32.299
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/editor/src/butJson.js +29 -8
- package/src/components/editor/src/editor.vue +93 -22
- package/src/components/editor/src/extend/font-size.js +1 -1
- package/src/components/editor/src/extend/sign-id.js +12 -2
- package/src/components/editor/src/extend/title-id.js +13 -3
- package/src/index.js +1 -1
package/package.json
CHANGED
|
@@ -9,13 +9,13 @@ export function butJson (editor,data) {
|
|
|
9
9
|
menuKeys: []
|
|
10
10
|
},
|
|
11
11
|
titleMenu: {
|
|
12
|
-
name: '
|
|
12
|
+
name: '字体',
|
|
13
13
|
key: 'titleMenu',
|
|
14
14
|
menuKeys: [
|
|
15
|
-
{name: '
|
|
16
|
-
{name: '
|
|
17
|
-
{name: '
|
|
18
|
-
{name: '
|
|
15
|
+
{name: '微软雅黑', key: 'Microsoft Yahei'},
|
|
16
|
+
{name: '楷体', key: 'Kaiti'},
|
|
17
|
+
{name: '仿宋', key: 'FangSong'},
|
|
18
|
+
{name: '黑体', key: 'SimHei'},
|
|
19
19
|
],
|
|
20
20
|
html: {
|
|
21
21
|
blackCenter4: `<p data-signId="title-1" class="title ${randomId()}" style="text-align: center;"><span style="font-weight: 700;color: rgb(0, 0, 0);font-size: 16px;font-family: SimHei">${menusData(data,'titleMenu').text}</span></p>`,
|
|
@@ -25,17 +25,38 @@ export function butJson (editor,data) {
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
textMenu: {
|
|
28
|
-
name: '
|
|
28
|
+
name: '字号',
|
|
29
29
|
key: 'textMenu',
|
|
30
30
|
menuKeys: [
|
|
31
|
-
{name: '
|
|
32
|
-
{name: '
|
|
31
|
+
{name: '12', key: '12px'},
|
|
32
|
+
{name: '14', key: '14px'},
|
|
33
|
+
{name: '16', key: '16px'},
|
|
34
|
+
{name: '18', key: '18px'},
|
|
35
|
+
{name: '20', key: '20px'},
|
|
36
|
+
{name: '22', key: '22px'},
|
|
37
|
+
{name: '24', key: '24px'},
|
|
38
|
+
{name: '26', key: '26px'},
|
|
39
|
+
{name: '28', key: '28px'},
|
|
40
|
+
{name: '30', key: '30px'},
|
|
41
|
+
{name: '32', key: '32px'}
|
|
33
42
|
],
|
|
34
43
|
html: {
|
|
35
44
|
Song5: `<p class="text" style="text-align: left;"><span style="color: rgb(0, 0, 0);font-size: 14px;font-family: SimSun">请输入正文</span></p>`,
|
|
36
45
|
regular5: `<p class="text" style="text-align: left;"><span style="color: rgb(0, 0, 0);font-size: 14px;font-family: KaiTi">请输入正文</span></p>`,
|
|
37
46
|
}
|
|
38
47
|
},
|
|
48
|
+
outlineMenu: {
|
|
49
|
+
name: '大纲级别',
|
|
50
|
+
key: 'outlineMenu',
|
|
51
|
+
menuKeys: [
|
|
52
|
+
{name: '一级标题', key: 'title-1'},
|
|
53
|
+
{name: '二级标题', key: 'title-2'},
|
|
54
|
+
{name: '三级标题', key: 'title-3'},
|
|
55
|
+
{name: '四级标题', key: 'title-4'},
|
|
56
|
+
{name: '正文文本', key: 'text'},
|
|
57
|
+
],
|
|
58
|
+
html: {}
|
|
59
|
+
},
|
|
39
60
|
redMenu: {
|
|
40
61
|
name: '添加红头',
|
|
41
62
|
key: 'redMenu',
|
|
@@ -130,7 +130,8 @@ export default {
|
|
|
130
130
|
menusStyle: {
|
|
131
131
|
top: '0px',
|
|
132
132
|
left: '0px'
|
|
133
|
-
}
|
|
133
|
+
},
|
|
134
|
+
menuStast: null
|
|
134
135
|
}
|
|
135
136
|
},
|
|
136
137
|
props: {
|
|
@@ -236,7 +237,7 @@ export default {
|
|
|
236
237
|
Superscript, // 上标
|
|
237
238
|
titleId, // 标题id
|
|
238
239
|
dataUrl,
|
|
239
|
-
BubbleMenu.configure({
|
|
240
|
+
BubbleMenu.configure({ // 气泡菜单
|
|
240
241
|
element: document.querySelector('.menu'),
|
|
241
242
|
shouldShow: ({editor, view, state, oldState, from, to}) => {
|
|
242
243
|
_this.encIndex = state.selection.$from.parent.attrs
|
|
@@ -277,23 +278,66 @@ export default {
|
|
|
277
278
|
HTMLAttributes: {
|
|
278
279
|
class: 'editor-img'
|
|
279
280
|
}
|
|
280
|
-
})
|
|
281
|
+
})
|
|
281
282
|
],
|
|
282
|
-
injectCSS: true
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
283
|
+
injectCSS: true,
|
|
284
|
+
onBlur: () => {
|
|
285
|
+
_this.menuStast = null
|
|
286
|
+
_this.butDataName('outlineMenu','大纲级别')
|
|
287
|
+
_this.butDataName('textMenu','字号')
|
|
288
|
+
_this.butDataName('titleMenu','字体')
|
|
289
|
+
},
|
|
290
|
+
onTransaction: () => {
|
|
291
|
+
const index = _this.editor.state.selection.$anchor.path[1]
|
|
292
|
+
const json = _this.editor.getJSON()
|
|
293
|
+
for (let i = 0; i < json.content.length; i++) {
|
|
294
|
+
if(index === i) {
|
|
295
|
+
if(json.content[i].content === undefined) break
|
|
296
|
+
const attrs = json.content[i].attrs
|
|
297
|
+
if(attrs.titleId === 'text') {
|
|
298
|
+
_this.butDataName('正文文本')
|
|
296
299
|
}
|
|
300
|
+
if(attrs.signId !== null) {
|
|
301
|
+
_this.butData.map(x => {
|
|
302
|
+
if(x.key === 'outlineMenu') {
|
|
303
|
+
x.name = '大纲级别'
|
|
304
|
+
if(attrs.signId === 'title-1') x.name = '一级标题'
|
|
305
|
+
if(attrs.signId === 'title-2') x.name = '二级标题'
|
|
306
|
+
if(attrs.signId === 'title-3') x.name = '三级标题'
|
|
307
|
+
if(attrs.signId === 'title-4') x.name = '四级标题'
|
|
308
|
+
}
|
|
309
|
+
})
|
|
310
|
+
}
|
|
311
|
+
if(json.content[i].content[0].marks === undefined) break
|
|
312
|
+
const style = json.content[i].content[0].marks
|
|
313
|
+
style.forEach(x => {
|
|
314
|
+
if(x.type === 'textStyle') {
|
|
315
|
+
if(x.attrs.fontSize !== null) {
|
|
316
|
+
if(_this.menuStast !== 'textMenu') {
|
|
317
|
+
_this.butData.map(y => {
|
|
318
|
+
if(y.key === 'textMenu') {
|
|
319
|
+
y.name = '字号'
|
|
320
|
+
y.name = '字号 ' + x.attrs.fontSize.replace(/px/g, '')
|
|
321
|
+
}
|
|
322
|
+
})
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if(x.attrs.fontFamily !== null) {
|
|
326
|
+
if(_this.menuStast !== 'titleMenu') {
|
|
327
|
+
_this.butData.map(y => {
|
|
328
|
+
if(y.key === 'titleMenu') {
|
|
329
|
+
y.name = '字体'
|
|
330
|
+
if(x.attrs.fontFamily === 'Microsoft Yahei') y.name = '字体 雅黑'
|
|
331
|
+
if(x.attrs.fontFamily === 'Kaiti') y.name = '字体 楷体'
|
|
332
|
+
if(x.attrs.fontFamily === 'FangSong') y.name = '字体 仿宋'
|
|
333
|
+
if(x.attrs.fontFamily === 'SimHei') y.name = '字体 黑体'
|
|
334
|
+
}
|
|
335
|
+
})
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
})
|
|
340
|
+
break
|
|
297
341
|
}
|
|
298
342
|
}
|
|
299
343
|
}
|
|
@@ -302,6 +346,11 @@ export default {
|
|
|
302
346
|
},
|
|
303
347
|
emits: ['confirm', 'enclosure', 'enlDownload', 'enlSee'],
|
|
304
348
|
methods: {
|
|
349
|
+
butDataName(n,v) {
|
|
350
|
+
this.butData.map(x => {
|
|
351
|
+
if(x.key === n) x.name = v
|
|
352
|
+
})
|
|
353
|
+
},
|
|
305
354
|
// 粘贴文本处理
|
|
306
355
|
preventPaste(event) {
|
|
307
356
|
const text = event.clipboardData.getData('text/plain');
|
|
@@ -790,13 +839,32 @@ export default {
|
|
|
790
839
|
}
|
|
791
840
|
// 标题
|
|
792
841
|
if (data.key === 'titleMenu') {
|
|
793
|
-
|
|
794
|
-
|
|
842
|
+
this.menuStast = 'titleMenu'
|
|
843
|
+
if(key.key === 'Microsoft Yahei') {
|
|
844
|
+
this.butDataName('titleMenu','字体 雅黑')
|
|
845
|
+
}else {
|
|
846
|
+
this.butDataName('titleMenu',`字体 ${key.name}`)
|
|
847
|
+
}
|
|
848
|
+
this.editor.commands.setFontFamily(key.key)
|
|
795
849
|
}
|
|
796
850
|
// 正文
|
|
797
851
|
if (data.key === 'textMenu') {
|
|
798
|
-
|
|
799
|
-
this.
|
|
852
|
+
this.menuStast = 'textMenu'
|
|
853
|
+
this.butDataName('textMenu',`字号 ${key.name}`)
|
|
854
|
+
this.editor.commands.setFontSize(key.key)
|
|
855
|
+
}
|
|
856
|
+
// 大纲级别
|
|
857
|
+
if (data.key === 'outlineMenu') {
|
|
858
|
+
if (key.key === 'text') {
|
|
859
|
+
this.editor.commands.setTitleId(key.key)
|
|
860
|
+
this.editor.commands.unsetSignId()
|
|
861
|
+
this.editor.chain().focus().unsetBold().run()
|
|
862
|
+
}else {
|
|
863
|
+
const t = key.key.split('-')[0]
|
|
864
|
+
this.editor.commands.setSignId(key.key)
|
|
865
|
+
this.editor.commands.setTitleId(`${t} ${this.randomId()}`)
|
|
866
|
+
this.editor.chain().focus().setBold().run()
|
|
867
|
+
}
|
|
800
868
|
}
|
|
801
869
|
// 作者
|
|
802
870
|
if (data.key === 'authorMenu') {
|
|
@@ -902,6 +970,9 @@ export default {
|
|
|
902
970
|
this.imgPop = true
|
|
903
971
|
}
|
|
904
972
|
}
|
|
973
|
+
setTimeout(() => {
|
|
974
|
+
this.menuStast = null
|
|
975
|
+
},1000)
|
|
905
976
|
},
|
|
906
977
|
cursorPosition(data, index) {
|
|
907
978
|
let num = 0
|
|
@@ -1135,7 +1206,7 @@ label {
|
|
|
1135
1206
|
}
|
|
1136
1207
|
|
|
1137
1208
|
.editing-cont :deep(p) {
|
|
1138
|
-
line-height:
|
|
1209
|
+
line-height: 1.7;
|
|
1139
1210
|
}
|
|
1140
1211
|
|
|
1141
1212
|
.editing-cont :deep(img) {
|
|
@@ -29,5 +29,15 @@ export const signId = Extension.create({
|
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
]
|
|
32
|
-
}
|
|
33
|
-
|
|
32
|
+
},
|
|
33
|
+
addCommands() {
|
|
34
|
+
return {
|
|
35
|
+
setSignId: (alignment) => ({ commands }) => {
|
|
36
|
+
return commands.updateAttributes('paragraph', { signId: alignment })
|
|
37
|
+
},
|
|
38
|
+
unsetSignId: () => ({ commands }) => {
|
|
39
|
+
return commands.resetAttributes('paragraph', 'signId')
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core'
|
|
1
|
+
import { Extension, nodeInputRule } from '@tiptap/core'
|
|
2
2
|
|
|
3
3
|
export const titleId = Extension.create({
|
|
4
4
|
name: 'titleId',
|
|
@@ -29,5 +29,15 @@ export const titleId = Extension.create({
|
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
]
|
|
32
|
-
}
|
|
33
|
-
|
|
32
|
+
},
|
|
33
|
+
addCommands() {
|
|
34
|
+
return {
|
|
35
|
+
setTitleId: (alignment) => ({ commands }) => {
|
|
36
|
+
return commands.updateAttributes('paragraph', { titleId: alignment })
|
|
37
|
+
},
|
|
38
|
+
unsetTitleId: () => ({ commands }) => {
|
|
39
|
+
return commands.resetAttributes('paragraph', 'titleId')
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
})
|