zydx-plus 1.10.36 → 1.10.38
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
|
@@ -41,6 +41,10 @@ export default defineComponent({
|
|
|
41
41
|
type: Array,
|
|
42
42
|
default: []
|
|
43
43
|
},
|
|
44
|
+
menusText: {
|
|
45
|
+
type: Array,
|
|
46
|
+
default: []
|
|
47
|
+
},
|
|
44
48
|
uploadImage: {
|
|
45
49
|
type: Object,
|
|
46
50
|
default: {}
|
|
@@ -55,7 +59,7 @@ export default defineComponent({
|
|
|
55
59
|
confirm() {
|
|
56
60
|
this.syncContent() //强制同步数据
|
|
57
61
|
this.$emit('confirm', this.formData.html)
|
|
58
|
-
}
|
|
62
|
+
}
|
|
59
63
|
},
|
|
60
64
|
mounted() {
|
|
61
65
|
setTimeout(() => {
|
|
@@ -94,7 +98,22 @@ export default defineComponent({
|
|
|
94
98
|
})
|
|
95
99
|
// 不要使用 reactive/ref,应该使用 shallowReactive/shallowRef 来接收 json array 数据
|
|
96
100
|
const formData = shallowReactive({html: ''})
|
|
97
|
-
|
|
101
|
+
console.log(opts)
|
|
102
|
+
setTimeout(() => {
|
|
103
|
+
for (let i = 0; i < props.menusText.length; i++) {
|
|
104
|
+
let indexs = findIndexByKey(menuModule.menus,props.menusText[i]['key'])
|
|
105
|
+
menuModule.menus[indexs].factory(props.menusText[i])
|
|
106
|
+
}
|
|
107
|
+
},0)
|
|
108
|
+
//根据key值查询数组索引
|
|
109
|
+
function findIndexByKey(arr, value) {
|
|
110
|
+
for (let i = 0; i < arr.length; i++) {
|
|
111
|
+
if (arr[i]['key'] === value) {
|
|
112
|
+
return i
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return -1
|
|
116
|
+
}
|
|
98
117
|
return { handle, formData, syncContent }
|
|
99
118
|
}
|
|
100
119
|
})
|
|
@@ -119,6 +138,7 @@ export default defineComponent({
|
|
|
119
138
|
background-color: #fff;
|
|
120
139
|
border: 1px solid #e8e8e8;
|
|
121
140
|
margin-bottom: 20px;
|
|
141
|
+
position: relative;
|
|
122
142
|
}
|
|
123
143
|
.def-but{
|
|
124
144
|
margin-left: 5px;
|
|
@@ -1,6 +1,23 @@
|
|
|
1
|
+
let signData = null
|
|
2
|
+
let titleData = null
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function typeCode(node,value) {
|
|
6
|
+
let hasAttachment = false
|
|
7
|
+
for(let i = 0; i < node.length; i++){
|
|
8
|
+
for(let j = 0; j < node[i].children.length; j++){
|
|
9
|
+
if(node[i].children[j].type === value) {
|
|
10
|
+
hasAttachment = true
|
|
11
|
+
break
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return hasAttachment
|
|
16
|
+
}
|
|
1
17
|
|
|
2
18
|
class signButtonMenu {
|
|
3
|
-
constructor() {
|
|
19
|
+
constructor(v) {
|
|
20
|
+
signData = v
|
|
4
21
|
this.title = '添加标志' // 自定义菜单标题
|
|
5
22
|
// this.iconSvg = '<svg>...</svg>' // 可选
|
|
6
23
|
this.tag = 'button'
|
|
@@ -20,23 +37,16 @@ class signButtonMenu {
|
|
|
20
37
|
// 点击菜单时触发的函数
|
|
21
38
|
exec(editor, value) {
|
|
22
39
|
if (this.isDisabled(editor)) return
|
|
40
|
+
// console.log(editor.getEditableContainer())
|
|
23
41
|
let node = editor.children
|
|
24
42
|
let nodes = JSON.parse(JSON.stringify(node)) //拷贝一份
|
|
25
|
-
|
|
26
|
-
let hasAttachment = false
|
|
27
|
-
for(let i = 0; i < node.length; i++){
|
|
28
|
-
for(let j = 0; j < node[i].children.length; j++){
|
|
29
|
-
if(node[i].children[j].type === 'attachment') {
|
|
30
|
-
hasAttachment = true
|
|
31
|
-
break
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if(hasAttachment) return
|
|
43
|
+
if(typeCode(node,'attachment')) return
|
|
36
44
|
const resume = {
|
|
37
45
|
type: 'paragraph',
|
|
38
46
|
children: [{
|
|
39
47
|
type: 'attachment',
|
|
48
|
+
fileName: signData.text,
|
|
49
|
+
link: signData.ico,
|
|
40
50
|
children: [{text:''}]
|
|
41
51
|
}]
|
|
42
52
|
}
|
|
@@ -68,8 +78,20 @@ class redButtonMenu {
|
|
|
68
78
|
// 点击菜单时触发的函数
|
|
69
79
|
exec(editor, value) {
|
|
70
80
|
if (this.isDisabled(editor)) return
|
|
81
|
+
let node = editor.children
|
|
82
|
+
let nodes = JSON.parse(JSON.stringify(node)) //拷贝一份
|
|
83
|
+
if(nodes[0].children.length === 1) nodes.splice(0,1)
|
|
84
|
+
let hasAttachment = false
|
|
85
|
+
for(let i = 0; i < node.length; i++){
|
|
86
|
+
if(node[i].state === 1) {
|
|
87
|
+
hasAttachment = true
|
|
88
|
+
break
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if(hasAttachment) return
|
|
71
92
|
const resume = {
|
|
72
93
|
type: 'paragraph',
|
|
94
|
+
state: 1,
|
|
73
95
|
children: [
|
|
74
96
|
{
|
|
75
97
|
text:'XXXXXXX(单位)文件',
|
|
@@ -94,17 +116,60 @@ class redButtonMenu {
|
|
|
94
116
|
type: 'divider',
|
|
95
117
|
children: [{text:''}]
|
|
96
118
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
119
|
+
if(typeCode(node,'attachment')) {
|
|
120
|
+
nodes.splice(1,0,resume)
|
|
121
|
+
nodes.splice(2,0,resume1)
|
|
122
|
+
nodes.splice(3,0,resume2)
|
|
123
|
+
}else {
|
|
124
|
+
nodes.splice(0,0,resume)
|
|
125
|
+
nodes.splice(1,0,resume1)
|
|
126
|
+
nodes.splice(2,0,resume2)
|
|
127
|
+
}
|
|
128
|
+
editor.clear()
|
|
129
|
+
for(let i = 0; i < nodes.length; i++){
|
|
130
|
+
editor.insertNode(nodes[i])
|
|
131
|
+
}
|
|
100
132
|
}
|
|
101
133
|
}
|
|
102
134
|
|
|
135
|
+
class titleButtonMenu {
|
|
136
|
+
constructor(v) {
|
|
137
|
+
titleData = v
|
|
138
|
+
this.title = '添加标题' // 自定义菜单标题
|
|
139
|
+
this.tag = 'button'
|
|
140
|
+
}
|
|
141
|
+
// 获取菜单执行时的 value ,用不到则返回空 字符串或 false
|
|
142
|
+
getValue(editor) {
|
|
143
|
+
return false
|
|
144
|
+
}
|
|
145
|
+
// 菜单是否需要激活(如选中加粗文本,“加粗”菜单会激活),用不到则返回 false
|
|
146
|
+
isActive(editor) {
|
|
147
|
+
return false
|
|
148
|
+
}
|
|
149
|
+
// 菜单是否需要禁用(如选中 H1 ,“引用”菜单被禁用),用不到则返回 false
|
|
150
|
+
isDisabled(editor) {
|
|
151
|
+
return false
|
|
152
|
+
}
|
|
153
|
+
// 点击菜单时触发的函数
|
|
154
|
+
exec(editor, value) {
|
|
155
|
+
if (this.isDisabled(editor)) return
|
|
156
|
+
const resume = {
|
|
157
|
+
type: 'paragraph',
|
|
158
|
+
children: [{
|
|
159
|
+
text: titleData.text,
|
|
160
|
+
color: '#000000',
|
|
161
|
+
fontSize: '48px',
|
|
162
|
+
}],
|
|
163
|
+
textAlign: 'center'
|
|
164
|
+
}
|
|
165
|
+
editor.insertNode(resume)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
103
168
|
|
|
104
169
|
const signMenuConf = {
|
|
105
170
|
key: 'signMenu',
|
|
106
|
-
factory() {
|
|
107
|
-
return new signButtonMenu()
|
|
171
|
+
factory(v) {
|
|
172
|
+
return new signButtonMenu(v)
|
|
108
173
|
},
|
|
109
174
|
}
|
|
110
175
|
|
|
@@ -115,6 +180,13 @@ const redMenuConf = {
|
|
|
115
180
|
},
|
|
116
181
|
}
|
|
117
182
|
|
|
183
|
+
const titleMenuConf = {
|
|
184
|
+
key: 'titleMenu',
|
|
185
|
+
factory(v) {
|
|
186
|
+
return new titleButtonMenu(v)
|
|
187
|
+
},
|
|
188
|
+
}
|
|
189
|
+
|
|
118
190
|
export const menuModule = {
|
|
119
|
-
menus: [signMenuConf,redMenuConf]
|
|
191
|
+
menus: [signMenuConf,redMenuConf,titleMenuConf]
|
|
120
192
|
}
|
|
@@ -4,7 +4,7 @@ function renderAttachment(elem, children, editor) {
|
|
|
4
4
|
const iconVnode = h(
|
|
5
5
|
'img',
|
|
6
6
|
{
|
|
7
|
-
props: { src:
|
|
7
|
+
props: { src: elem.link }, // HTML 属性,驼峰式写法
|
|
8
8
|
style: { width: '20px',height: '20px',position: 'absolute',top: '0',left: '0'},
|
|
9
9
|
}
|
|
10
10
|
)
|
|
@@ -14,7 +14,7 @@ function renderAttachment(elem, children, editor) {
|
|
|
14
14
|
props: { contentEditable: false },
|
|
15
15
|
style: {display: 'inline-block',paddingLeft: '25px'}
|
|
16
16
|
},
|
|
17
|
-
[
|
|
17
|
+
[ elem.fileName ]
|
|
18
18
|
)
|
|
19
19
|
const attachVnode = h(
|
|
20
20
|
'span',
|
|
@@ -254,14 +254,20 @@ const Editable = defineComponent({
|
|
|
254
254
|
});
|
|
255
255
|
// placeholder
|
|
256
256
|
watch(() => opts.editable.config.placeholder, (nv) => {
|
|
257
|
-
|
|
258
|
-
|
|
257
|
+
let target = null;
|
|
258
|
+
if(rootRef.value){
|
|
259
|
+
target = rootRef.value.querySelector('.w-e-text-placeholder')
|
|
260
|
+
}
|
|
259
261
|
if (target instanceof HTMLElement)
|
|
260
262
|
target.innerHTML = nv || '';
|
|
261
263
|
});
|
|
262
264
|
// scroll
|
|
263
265
|
watch(() => opts.editable.config.scroll, (nv) => {
|
|
264
|
-
const target = rootRef.value?.querySelector('.w-e-scroll');
|
|
266
|
+
// const target = rootRef.value?.querySelector('.w-e-scroll');
|
|
267
|
+
let target = null
|
|
268
|
+
if(rootRef.value){
|
|
269
|
+
target = rootRef.value.querySelector('.w-e-scroll')
|
|
270
|
+
}
|
|
265
271
|
if (target instanceof HTMLElement)
|
|
266
272
|
target.style.overflowY = nv ? 'auto' : '';
|
|
267
273
|
});
|