zydx-plus 1.20.115 → 1.20.117

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.20.115",
3
+ "version": "1.20.117",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -148,8 +148,9 @@ export default defineComponent({
148
148
 
149
149
  /*工具栏样式*/
150
150
  .toolbar {
151
- border: 1px solid #d9d9d9;
152
- margin-bottom: 20px;
151
+ border-top: 1px solid #d9d9d9;
152
+ border-left: 1px solid #d9d9d9;
153
+ border-right: 1px solid #d9d9d9;
153
154
  }
154
155
 
155
156
  /*工具栏剧中显示*/
@@ -188,4 +189,19 @@ export default defineComponent({
188
189
  :deep(.w-e-text-placeholder) {
189
190
  top: 6px;
190
191
  }
192
+ :deep(.w-e-bar-item) {
193
+ border-right: 1px solid rgba(204, 204, 204, 1);
194
+ flex: 1;
195
+ padding: 0;
196
+ height: auto;
197
+ }
198
+ :deep(.w-e-bar-item):last-child {
199
+ border-right: 0;
200
+ }
201
+ :deep(.w-e-bar):last-child {
202
+ padding: 0;
203
+ }
204
+ :deep(.w-e-bar-item-menus-container) {
205
+ margin-top: 32px;
206
+ }
191
207
  </style>
@@ -1,17 +1,39 @@
1
1
  let signData = null
2
2
  let titleData = null
3
+ let authorData = null
4
+ let numberData = null
3
5
 
4
6
  const num = {1: '①', 2: '②', 3: '③', 4: '④', 5: '⑤', 6: '⑥', 7: '⑦', 8: '⑧', 9: '⑨', 10: '⑩', 11: '⑪', 12: '⑫', 13: '⑬', 14: '⑭', 15: '⑮', 16: '⑯', 17: '⑰', 18: '⑱', 19: '⑲', 20: '⑳',}
5
7
 
6
- function typeCode(node,value) {
8
+
9
+ function resumeSing() {
10
+ return {
11
+ type: 'attachment',
12
+ fileName: signData.text,
13
+ link: signData.ico,
14
+ sign: true,
15
+ children: [{text:''}]
16
+ }
17
+ }
18
+
19
+ function typeCode(node,value,num = false) {
7
20
  let hasAttachment = false
8
- for(let i = 0; i < node.length; i++){
9
- for(let j = 0; j < node[i].children.length; j++){
10
- if(node[i].children[j].type === value) {
21
+ if(num) {
22
+ for(let i = 0; i < node.length; i++){
23
+ if(node[i][value]) {
11
24
  hasAttachment = true
12
25
  break
13
26
  }
14
27
  }
28
+ }else {
29
+ for(let i = 0; i < node.length; i++){
30
+ for(let j = 0; j < node[i].children.length; j++){
31
+ if(node[i].children[j][value]) {
32
+ hasAttachment = true
33
+ break
34
+ }
35
+ }
36
+ }
15
37
  }
16
38
  return hasAttachment
17
39
  }
@@ -28,12 +50,31 @@ function hasValue(arr, value) {
28
50
  let num = 0
29
51
  arr.some(item => {
30
52
  item.children.some(items => {
31
- if(items.sup) num++
53
+ if(items[value]) num++
32
54
  })
33
55
  })
34
56
  return num
35
57
  }
36
58
 
59
+ //分割数组
60
+ function group(array, subNum) {
61
+ let index = 0;
62
+ let newArray = [];
63
+ let num = 0
64
+ while(index < array.length) {
65
+ newArray.push(array.slice(index, index += subNum));
66
+ }
67
+ for(let i=0; i<newArray[1].length; i++) {
68
+ if(newArray[1][i].children[0].state === undefined) {
69
+ num = (i === 0)? 1 : i
70
+ break;
71
+ }else {
72
+ num = (i === 0)? 1 : i
73
+ }
74
+ }
75
+ return num;
76
+ }
77
+
37
78
  //添加标志
38
79
  class signButtonMenu {
39
80
  constructor(v) {
@@ -59,14 +100,8 @@ class signButtonMenu {
59
100
  if (this.isDisabled(editor)) return
60
101
  let node = editor.children
61
102
  let nodes = JSON.parse(JSON.stringify(node)) //拷贝一份
62
- if(typeCode(node,'attachment')) return
63
- const resume = {
64
- type: 'attachment',
65
- fileName: signData.text,
66
- link: signData.ico,
67
- children: [{text:''}]
68
- }
69
- nodes.unshift(resume)
103
+ if(typeCode(nodes,'sign')) return
104
+ nodes.unshift(resumeSing())
70
105
  addNode(editor,nodes)
71
106
  }
72
107
  }
@@ -93,18 +128,10 @@ class redButtonMenu {
93
128
  if (this.isDisabled(editor)) return
94
129
  let node = editor.children
95
130
  let nodes = JSON.parse(JSON.stringify(node)) //拷贝一份
96
- if(nodes[0].children.length === 1) nodes.splice(0,1)
97
- let hasAttachment = false
98
- for(let i = 0; i < node.length; i++){
99
- if(node[i].state === 1) {
100
- hasAttachment = true
101
- break
102
- }
103
- }
104
- if(hasAttachment) return
131
+ if(typeCode(nodes,'tou', true)) return
105
132
  const resume = {
106
133
  type: 'paragraph',
107
- state: 1,
134
+ tou: true,
108
135
  children: [
109
136
  {
110
137
  text:'XXXXXXX(单位)文件',
@@ -129,7 +156,9 @@ class redButtonMenu {
129
156
  type: 'divider',
130
157
  children: [{text:''}]
131
158
  }
132
- if(typeCode(node,'attachment')) {
159
+ if(typeCode(node,'sign')) {
160
+ nodes.splice(0,1)
161
+ nodes.splice(0,0,resumeSing())
133
162
  nodes.splice(1,0,resume)
134
163
  nodes.splice(2,0,resume1)
135
164
  nodes.splice(3,0,resume2)
@@ -181,10 +210,49 @@ class titleButtonMenu {
181
210
  editor.insertNode(resume2)
182
211
  }
183
212
  }
213
+ //作者
214
+ class authorButtonMenu {
215
+ constructor(v) {
216
+ authorData = v
217
+ this.title = '添加作者' // 自定义菜单标题
218
+ this.tag = 'button'
219
+ }
220
+ // 获取菜单执行时的 value ,用不到则返回空 字符串或 false
221
+ getValue(editor) {
222
+ return false
223
+ }
224
+ // 菜单是否需要激活(如选中加粗文本,“加粗”菜单会激活),用不到则返回 false
225
+ isActive(editor) {
226
+ return false
227
+ }
228
+ // 菜单是否需要禁用(如选中 H1 ,“引用”菜单被禁用),用不到则返回 false
229
+ isDisabled(editor) {
230
+ return false
231
+ }
232
+ // 点击菜单时触发的函数
233
+ exec(editor, value) {
234
+ if (this.isDisabled(editor)) return
235
+ const resume = {
236
+ type: 'paragraph',
237
+ children: [{
238
+ type: 'authorAttachment',
239
+ fileName: authorData.text,
240
+ children: [{text:''}]
241
+ }],
242
+ textAlign: 'center'
243
+ }
244
+ const resume2 = {
245
+ type: 'paragraph',
246
+ children: [{text:''}],
247
+ textAlign: 'left'
248
+ }
249
+ editor.insertNode(resume)
250
+ editor.insertNode(resume2)
251
+ }
252
+ }
184
253
  // 添加参考文献
185
254
  class literatureButtonMenu {
186
255
  constructor(v) {
187
- titleData = v
188
256
  this.title = '参考文献' // 自定义菜单标题
189
257
  this.tag = 'button'
190
258
  }
@@ -245,7 +313,6 @@ class literatureButtonMenu {
245
313
  // 添加标注
246
314
  class taggingButtonMenu {
247
315
  constructor(v) {
248
- titleData = v
249
316
  this.title = '添加标注' // 自定义菜单标题
250
317
  this.tag = 'button'
251
318
  }
@@ -260,32 +327,142 @@ class taggingButtonMenu {
260
327
  }
261
328
  exec(editor, value) {
262
329
  if (this.isDisabled(editor)) return
263
- const anchor = editor.selection.anchor
330
+ const anchor = editor.selection.anchor // 获取光标位置
264
331
  if(anchor.offset === 0) return
265
332
  let node = editor.children
266
333
  let nodes = JSON.parse(JSON.stringify(node)) //拷贝一份
267
- const numSub = hasValue(nodes,'sup')
268
- let one = nodes[0]
269
- nodes.splice(0,1)
270
- nodes.unshift({
271
- type: 'attachment',
272
- text: one.children[0].text
273
- })
334
+ const numSub = hasValue(nodes,'subs')
335
+ let textNode = nodes[anchor.path[0]].children[anchor.path[1]].text
336
+ const left = textNode.substring(0, anchor.offset)
337
+ const right = textNode.substring(anchor.offset)
338
+ nodes[anchor.path[0]].children[anchor.path[1]].text = left
274
339
  nodes[anchor.path[0]].children.push({
275
340
  text: num[numSub+1],
276
- sup: true
277
- },{text: ' '})
278
- nodes.push({
341
+ sup: true,
342
+ subs: true
343
+ },{text: right})
344
+ const devider = {
279
345
  type: 'divider',
280
346
  children: [{text:''}]
281
- })
282
- nodes.push({
347
+ }
348
+ const devider2 = {
283
349
  type: 'paragraph',
284
350
  children: [{
351
+ state: numSub+1,
285
352
  text: `${num[numSub+1]}填写标注内容`,
353
+ fontSize: '12px'
286
354
  }],
287
355
  textAlign: 'left'
288
- })
356
+ }
357
+ let nodeType = (nodes[anchor.path[0] + 1])? nodes[anchor.path[0] + 1].type : ''
358
+ let deviderData = [devider,devider2]
359
+ let numNode = -1
360
+ if(nodeType === 'divider') {
361
+ numNode = group(nodes,anchor.path[0] + 2)
362
+ deviderData = [devider2]
363
+ }
364
+ nodes.splice(anchor.path[0] + 2 + numNode, 0, deviderData)
365
+ addNode(editor,nodes)
366
+ }
367
+ }
368
+ // 摘要
369
+ class abstractButtonMenu {
370
+ constructor(v) {
371
+ this.title = '添加摘要' // 自定义菜单标题
372
+ this.tag = 'button'
373
+ }
374
+ getValue(editor) {
375
+ return false
376
+ }
377
+ isActive(editor) {
378
+ return false
379
+ }
380
+ isDisabled(editor) {
381
+ return false
382
+ }
383
+ exec(editor, value) {
384
+ if (this.isDisabled(editor)) return
385
+ const resume = {
386
+ type: 'paragraph',
387
+ children: [{
388
+ text: ' 摘要:',
389
+ color: '#000000',
390
+ fontSize: '12px',
391
+ bold: true
392
+ },{
393
+ text: '请填写摘要内容',
394
+ color: '#000000',
395
+ fontSize: '12px',
396
+ }],
397
+ textAlign: 'left'
398
+ }
399
+ editor.insertNode(resume)
400
+ }
401
+ }
402
+ //关键词
403
+ class keywordButtonMenu {
404
+ constructor(v) {
405
+ this.title = '关键词' // 自定义菜单标题
406
+ this.tag = 'button'
407
+ }
408
+ getValue(editor) {
409
+ return false
410
+ }
411
+ isActive(editor) {
412
+ return false
413
+ }
414
+ isDisabled(editor) {
415
+ return false
416
+ }
417
+ exec(editor, value) {
418
+ if (this.isDisabled(editor)) return
419
+ const resume = {
420
+ type: 'paragraph',
421
+ children: [{
422
+ text: ' 关键词:',
423
+ color: '#000000',
424
+ fontSize: '12px',
425
+ bold: true
426
+ },{
427
+ text: '请填写关键词内容',
428
+ color: '#000000',
429
+ fontSize: '12px',
430
+ }],
431
+ textAlign: 'left'
432
+ }
433
+ editor.insertNode(resume)
434
+ }
435
+ }
436
+ // 编号
437
+ class numberButtonMenu {
438
+ constructor(v) {
439
+ numberData = v
440
+ this.title = '标注编号' // 自定义菜单标题
441
+ this.tag = 'button'
442
+ }
443
+ getValue(editor) {
444
+ return false
445
+ }
446
+ isActive(editor) {
447
+ return false
448
+ }
449
+ isDisabled(editor) {
450
+ return false
451
+ }
452
+ exec(editor, value) {
453
+ if (this.isDisabled(editor)) return
454
+ const anchor = editor.selection.anchor // 获取光标位置
455
+ if(anchor.offset === 0) return
456
+ let node = editor.children
457
+ let nodes = JSON.parse(JSON.stringify(node)) //拷贝一份
458
+ let textNode = nodes[anchor.path[0]].children[anchor.path[1]].text
459
+ const left = textNode.substring(0, anchor.offset)
460
+ const right = textNode.substring(anchor.offset)
461
+ nodes[anchor.path[0]].children[anchor.path[1]].text = left
462
+ nodes[anchor.path[0]].children.push({
463
+ text: `【${numberData.text}】`,
464
+ sup: true
465
+ },{text: right})
289
466
  addNode(editor,nodes)
290
467
  }
291
468
  }
@@ -322,7 +499,31 @@ const taggingMenuConf = {
322
499
  return new taggingButtonMenu(v)
323
500
  },
324
501
  }
502
+ const authorMenuConf = {
503
+ key: 'authorMenu',
504
+ factory(v) {
505
+ return new authorButtonMenu(v)
506
+ },
507
+ }
508
+ const abstractMenuConf = {
509
+ key: 'abstractMenu',
510
+ factory() {
511
+ return new abstractButtonMenu()
512
+ },
513
+ }
514
+ const keywordMenuConf = {
515
+ key: 'keywordMenu',
516
+ factory() {
517
+ return new keywordButtonMenu()
518
+ },
519
+ }
520
+ const numberMenuConf = {
521
+ key: 'numberMenu',
522
+ factory(v) {
523
+ return new numberButtonMenu(v)
524
+ },
525
+ }
325
526
 
326
527
  export const menuModule = {
327
- menus: [signMenuConf,redMenuConf,titleMenuConf,literatureMenuConf,taggingMenuConf]
528
+ menus: [signMenuConf,redMenuConf,titleMenuConf,literatureMenuConf,taggingMenuConf,authorMenuConf,numberMenuConf,abstractMenuConf,keywordMenuConf]
328
529
  }
@@ -48,7 +48,27 @@ function titleAttachment(elem, children, editor) {
48
48
  )
49
49
  return attachVnode
50
50
  }
51
-
51
+ // 作者
52
+ function authorAttachment(elem, children, editor) {
53
+ const iconText = h(
54
+ 'span',
55
+ {
56
+ props: { contentEditable: false },
57
+ style: {display: 'inline-block',fontSize: '16px'}
58
+ },
59
+ [ elem.fileName ]
60
+ )
61
+ const attachVnode = h(
62
+ 'span',
63
+ {
64
+ props: { contentEditable: false },
65
+ style: { display: 'inline-block'},
66
+ // on: { click() { console.log('clicked', link) } }
67
+ },
68
+ [ iconText]
69
+ )
70
+ return attachVnode
71
+ }
52
72
 
53
73
  const renderElemConf = {
54
74
  type: 'attachment',
@@ -58,7 +78,11 @@ const titleElemConf = {
58
78
  type: 'titleAttachment',
59
79
  renderElem: titleAttachment,
60
80
  }
81
+ const authorElemConf = {
82
+ type: 'authorAttachment',
83
+ renderElem: authorAttachment,
84
+ }
61
85
 
62
86
  export const nodeModule = {
63
- renderElems: [renderElemConf,titleElemConf]
87
+ renderElems: [renderElemConf,titleElemConf,authorElemConf]
64
88
  }
@@ -24,7 +24,9 @@
24
24
  <p :style="enclosureStyle">{{ enclosureText }}</p>
25
25
  <div class="enclosure-list" v-for="(item,index) in uploadAttData">
26
26
  <div class="enclosure-item">
27
- <span>{{ index + 1 }}. {{ (item.name)? item.name : item.annexName }}</span>
27
+ <span v-if="item.name">{{ index + 1 }}. {{ item.name }}</span>
28
+ <span v-if="item.annexName">{{ index + 1 }}. {{ item.annexName }}</span>
29
+ <span v-if="item.fileName">{{ index + 1 }}. {{ item.fileName }}</span>
28
30
  </div>
29
31
  <div class="enclosure-item en-but">
30
32
  <div style="display: inline-block; height: 21px;">
package/src/index.js CHANGED
@@ -63,7 +63,7 @@ function install(app) {
63
63
  }
64
64
 
65
65
  export default {
66
- version: '1.20.115',
66
+ version: '1.20.117',
67
67
  install,
68
68
  Calendar,
69
69
  Message,