zydx-plus 1.32.246 → 1.32.248

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.32.246",
3
+ "version": "1.32.248",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="z-editor">
2
+ <div class="z-editor" ref="only">
3
3
  <div class="editor-header" v-show="!readOnly">
4
4
  <div class="editor-but" v-for="(item,index) in butData">
5
5
  <div class="editor-but-name" v-if="item.key === 'group-upload'">
@@ -36,17 +36,27 @@
36
36
  <span>{{ menusData('signMenu')?.text }}</span>
37
37
  </div>
38
38
  <editor-content class="editing-cont" :editor="editor"></editor-content>
39
+ <div class="menu">
40
+ <button class="but" @click="enlSee" v-if="readOnly">查看</button>
41
+ <button class="but" @click="enlDownload" v-if="readOnly">下载</button>
42
+ <button class="but" @click="enlDel" v-if="!readOnly">删除</button>
43
+ </div>
39
44
  </div>
40
45
  </div>
41
46
  <div class="complete" v-if="!readOnly && toolbar.length > 0">
42
47
  <button class="but" v-if="butShow" @click="confirm">完成</button>
43
48
  </div>
44
49
  <div class="read-only" v-if="page&&readOnly" :style="{width: (wit + 20) + 'px'}">
50
+ <div class="menus" v-if="menus&&readOnly" :style="menusStyle">
51
+ <button class="but" @click="enlSee" v-if="readOnly">查看</button>
52
+ <button class="but" @click="enlDownload" v-if="readOnly">下载</button>
53
+ <button class="but" @click="enlDel" v-if="!readOnly">删除</button>
54
+ </div>
45
55
  <div class="editing-header" v-if="signMenuShow">
46
56
  <img :src="menusData('signMenu')?.ico" alt=""/>
47
57
  <span>{{ menusData('signMenu')?.text }}</span>
48
58
  </div>
49
- <div class="read-only-page" :style="{height: wit * 1.4 + 'px',width: wit + 'px'}" v-for="(item,index) in htmlArr">
59
+ <div class="read-only-page" @click="menusTap" :style="{height: wit * 1.4 + 'px',width: wit + 'px'}" v-for="(item,index) in htmlArr">
50
60
  <div class="read-only-p" v-html="item"></div>
51
61
  <div class="read-only-a">{{ index + 1 }}/{{ htmlArr.length }}</div>
52
62
  </div>
@@ -82,11 +92,13 @@ import Color from '@tiptap/extension-color'
82
92
  import FontFamily from "@tiptap/extension-font-family";
83
93
  import Superscript from "@tiptap/extension-superscript";
84
94
  import HorizontalRule from "@tiptap/extension-horizontal-rule";
95
+ import BubbleMenu from '@tiptap/extension-bubble-menu'
85
96
  import Link from "@tiptap/extension-link";
86
97
  import {FontSize} from "./extend/font-size";
87
98
  import {signId} from "./extend/sign-id";
88
99
  import {Contenteditable} from "./extend/contenteditable";
89
100
  import {titleId} from "./extend/title-id";
101
+ import {dataUrl} from "./extend/data-url";
90
102
 
91
103
  export default {
92
104
  name: 'zydx-editor',
@@ -106,7 +118,14 @@ export default {
106
118
  editableShow: true,
107
119
  wit: 0,
108
120
  htmlArr2: [],
109
- loading: false
121
+ loading: false,
122
+ encIndex: {},
123
+ init: false,
124
+ menus: false,
125
+ menusStyle: {
126
+ top: '0px',
127
+ left: '0px'
128
+ }
110
129
  }
111
130
  },
112
131
  props: {
@@ -154,6 +173,7 @@ export default {
154
173
  watch: {
155
174
  html: {
156
175
  handler: function (e, oldVal) {
176
+ this.init = false
157
177
  if (e[0]?.tag === 'sign') {
158
178
  this.signMenuShow = true
159
179
  e.shift()
@@ -168,6 +188,9 @@ export default {
168
188
  }
169
189
  }, 300)
170
190
  }
191
+ setTimeout(() => {
192
+ this.init = true
193
+ }, 500)
171
194
  },
172
195
  deep: true,
173
196
  },
@@ -207,6 +230,18 @@ export default {
207
230
  TextStyle, // 文本样式
208
231
  Superscript, // 上标
209
232
  titleId, // 标题id
233
+ dataUrl,
234
+ BubbleMenu.configure({
235
+ element: document.querySelector('.menu'),
236
+ shouldShow: ({ editor, view, state, oldState, from, to }) => {
237
+ _this.encIndex = state.selection.$from.parent.attrs
238
+ if(_this.init) {
239
+ return state.selection.$from.parent.attrs.titleId === 'mu'
240
+ }else {
241
+ return false
242
+ }
243
+ },
244
+ }),
210
245
  Link.configure({
211
246
  HTMLAttributes: {
212
247
  class: 'custom-link',
@@ -260,8 +295,28 @@ export default {
260
295
  })
261
296
  _this.organizeButton()
262
297
  },
263
- emits: ['confirm', 'enclosure'],
298
+ emits: ['confirm', 'enclosure','enlDownload','enlSee'],
264
299
  methods: {
300
+ // 下载附件
301
+ enlDownload() {
302
+ this.$emit('enlDownload', this.encIndex)
303
+ },
304
+ // 查看附件
305
+ enlSee() {
306
+ this.$emit('enlSee', this.encIndex)
307
+ },
308
+ // 删除附件
309
+ enlDel() {
310
+ const json = this.editor.getJSON()
311
+ for (let i = 0; i < json.content.length; i++) {
312
+ const val = json.content[i].attrs?.signId
313
+ if (val === this.encIndex.signId) {
314
+ json.content.splice(i, 1)
315
+ this.editor?.commands.setContent(json)
316
+ break
317
+ }
318
+ }
319
+ },
265
320
  signMenu(next) { // 签名菜单
266
321
  this.signMenuShow = !this.signMenuShow
267
322
  next(this.signMenuShow)
@@ -405,6 +460,27 @@ export default {
405
460
  break
406
461
  }
407
462
  }
463
+ // 绑定点击事件
464
+ setTimeout(() => {
465
+ this.documentClick()
466
+ }, 1000)
467
+ },
468
+ documentClick() {
469
+ const p = document.getElementsByClassName('mu')
470
+ for (let i = 0; i < p.length; i++) {
471
+ p[i].onclick = (e) => {
472
+ e.stopPropagation()
473
+ this.menus = true
474
+ const only = this.$refs.only.getBoundingClientRect() // 获取div的位置
475
+ this.menusStyle = {
476
+ top: `${e.clientY - only.top - 40}px`,
477
+ left: `${e.clientX - only.left - 60}px`
478
+ }
479
+ }
480
+ }
481
+ },
482
+ menusTap() {
483
+ this.menus = false
408
484
  },
409
485
  rows(data,num) {
410
486
  let size = parseInt(window.getComputedStyle(data, null).fontSize)
@@ -530,12 +606,12 @@ export default {
530
606
  const last = this.editor.state.selection.$anchor.path[0].content.size
531
607
  if (t === -1) this.editor.chain().focus().insertContentAt(last, html).run()
532
608
  const num = this.upSort(this.editor, 'enclosure')
533
- const html2 = `<p contenteditable="false" data-signId="u-${num.num}"><a href="${url}" ><span>${num.num}. ${name}</span></a></p>`
609
+ const html2 = `<p contenteditable="false" data-signId="u-${num.num}" data-url="${url}"><span class="mu">${num.num}. ${name}</span></p>`
534
610
  this.editor.chain().focus().insertContentAt(num.len, html2).run()
535
611
  } else {
536
612
  if (t === -1) this.editor.chain().focus().insertContentAt(this.selectionPath('paragraph', b - 1), html).run()
537
613
  const num = this.upSort(this.editor, 'enclosure')
538
- const html2 = `<p contenteditable="false" data-signId="u-${num.num}"><a href="${url}" ><span>${num.num}. ${name}</span></a></p>`
614
+ const html2 = `<p contenteditable="false" data-signId="u-${num.num}" data-url="${url}"><span class="mu">${num.num}. ${name}</span></p>`
539
615
  this.editor.chain().focus().insertContentAt(num.len, html2).run()
540
616
  }
541
617
  })
@@ -947,8 +1023,8 @@ label {
947
1023
 
948
1024
  .editing-header {
949
1025
  position: absolute;
950
- top: 0;
951
- left: 0;
1026
+ top: 5px;
1027
+ left: 5px;
952
1028
  display: flex;
953
1029
  z-index: 1;
954
1030
  }
@@ -979,6 +1055,9 @@ label {
979
1055
  :deep(.custom-link) {
980
1056
  margin: 10px 0;
981
1057
  }
1058
+ :deep(.mu) {
1059
+ cursor: pointer;
1060
+ }
982
1061
 
983
1062
  .editing-cont :deep(p) {
984
1063
  line-height: 24px;
@@ -1141,4 +1220,18 @@ li {
1141
1220
  width: 100%;
1142
1221
  }
1143
1222
  }
1223
+ .menu{
1224
+ background-color: #fff;
1225
+ padding: 5px;
1226
+ border-radius: 5px;
1227
+ box-shadow: 0 0 10px rgba(0, 0, 0, .2);
1228
+ }
1229
+ .menus{
1230
+ background-color: #fff;
1231
+ padding: 5px;
1232
+ border-radius: 5px;
1233
+ box-shadow: 0 0 10px rgba(0, 0, 0, .2);
1234
+ position: absolute;
1235
+ z-index: 10;
1236
+ }
1144
1237
  </style>
@@ -0,0 +1,33 @@
1
+ import { Extension } from '@tiptap/core'
2
+
3
+ export const dataUrl = Extension.create({
4
+ name: 'dataUrl',
5
+
6
+ addOptions() {
7
+ return {
8
+ types: ['heading', 'paragraph'],
9
+ }
10
+ },
11
+
12
+ addGlobalAttributes() {
13
+ return [
14
+ {
15
+ types: this.options.types,
16
+ attributes: {
17
+ dataUrl: {
18
+ default: null,
19
+ parseHTML: element => element.getAttribute('data-url'),
20
+ renderHTML: attributes => {
21
+ if (!attributes.dataUrl) {
22
+ return {}
23
+ }
24
+ return {
25
+ 'data-url': attributes.dataUrl,
26
+ }
27
+ },
28
+ },
29
+ },
30
+ },
31
+ ]
32
+ }
33
+ })
@@ -554,6 +554,7 @@ export default {
554
554
  }
555
555
  .ed-cont{
556
556
  padding-top: 4px;
557
+ margin-bottom: 14px;
557
558
  }
558
559
  .editor{
559
560
  border-radius: 3px;
package/src/index.js CHANGED
@@ -79,7 +79,7 @@ function install(app) {
79
79
  }
80
80
 
81
81
  export default {
82
- version: '1.32.246',
82
+ version: '1.32.248',
83
83
  install,
84
84
  Calendar,
85
85
  Message,