adtec-core-package 2.7.6 → 2.7.7
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
|
@@ -24,6 +24,7 @@ import { ElMessage } from 'element-plus'
|
|
|
24
24
|
enum WatchType {
|
|
25
25
|
initWatch = 'initWatch',
|
|
26
26
|
}
|
|
27
|
+
|
|
27
28
|
const watchHandlers = ref<Partial<Record<WatchType, WatchStopHandle>>>({})
|
|
28
29
|
|
|
29
30
|
const divRef = ref()
|
|
@@ -56,17 +57,17 @@ const props = withDefaults(
|
|
|
56
57
|
showToolbar: true,
|
|
57
58
|
borderWidth: '1px',
|
|
58
59
|
editorConfig: {},
|
|
59
|
-
isEdit: true
|
|
60
|
-
}
|
|
60
|
+
isEdit: true
|
|
61
|
+
}
|
|
61
62
|
)
|
|
62
63
|
const model = defineModel({
|
|
63
64
|
type: [String, null, undefined],
|
|
64
65
|
required: false,
|
|
65
|
-
default: null
|
|
66
|
+
default: null
|
|
66
67
|
})
|
|
67
68
|
const text = defineModel('text', {
|
|
68
69
|
type: String,
|
|
69
|
-
required: false
|
|
70
|
+
required: false
|
|
70
71
|
})
|
|
71
72
|
//字体对照表
|
|
72
73
|
const fontSizes = [
|
|
@@ -85,8 +86,9 @@ const fontSizes = [
|
|
|
85
86
|
{ name: '小一', pt: 24, px: 28 },
|
|
86
87
|
{ name: '一号', pt: 26, px: 30 },
|
|
87
88
|
{ name: '小初', pt: 36, px: 42 },
|
|
88
|
-
{ name: '初号', pt: 42, px: 49 }
|
|
89
|
+
{ name: '初号', pt: 42, px: 49 }
|
|
89
90
|
]
|
|
91
|
+
|
|
90
92
|
function setDefaultPx(html: string) {
|
|
91
93
|
// 创建临时div用于解析HTML
|
|
92
94
|
const tempDiv = document.createElement('div')
|
|
@@ -104,6 +106,7 @@ function setDefaultPx(html: string) {
|
|
|
104
106
|
})
|
|
105
107
|
return tempDiv.innerHTML
|
|
106
108
|
}
|
|
109
|
+
|
|
107
110
|
function convertPxToPt(html: string) {
|
|
108
111
|
html = setDefaultPx(html)
|
|
109
112
|
const regex = /font-size: (\d+)px/g
|
|
@@ -116,6 +119,7 @@ function convertPxToPt(html: string) {
|
|
|
116
119
|
return match
|
|
117
120
|
})
|
|
118
121
|
}
|
|
122
|
+
|
|
119
123
|
function convertPtToPx(html: string) {
|
|
120
124
|
const regex = /font-size: (\d+)pt/g
|
|
121
125
|
return html.replace(regex, (match, ptValue) => {
|
|
@@ -127,6 +131,7 @@ function convertPtToPx(html: string) {
|
|
|
127
131
|
return match
|
|
128
132
|
})
|
|
129
133
|
}
|
|
134
|
+
|
|
130
135
|
//默认的配置
|
|
131
136
|
const defaultConfig = {
|
|
132
137
|
placeholder: '请输入内容...',
|
|
@@ -140,11 +145,11 @@ const defaultConfig = {
|
|
|
140
145
|
'video',
|
|
141
146
|
'ai',
|
|
142
147
|
'quote',
|
|
143
|
-
'emoji'
|
|
148
|
+
'emoji'
|
|
144
149
|
],
|
|
145
150
|
textSelectionBubbleMenu: {
|
|
146
151
|
enable: true,
|
|
147
|
-
items: ['Bold', 'Italic', 'Underline', 'Strike', 'code', 'comment']
|
|
152
|
+
items: ['Bold', 'Italic', 'Underline', 'Strike', 'code', 'comment']
|
|
148
153
|
},
|
|
149
154
|
image: {
|
|
150
155
|
uploaderEvent: {
|
|
@@ -153,18 +158,18 @@ const defaultConfig = {
|
|
|
153
158
|
ElMessage.warning('图片大小不能超过2M')
|
|
154
159
|
return false
|
|
155
160
|
}
|
|
156
|
-
}
|
|
161
|
+
}
|
|
157
162
|
// onSuccess: (file, response) => {
|
|
158
163
|
// console.log('onSuccess', file, response)
|
|
159
164
|
// }
|
|
160
|
-
}
|
|
165
|
+
}
|
|
161
166
|
},
|
|
162
167
|
htmlPasteConfig: {
|
|
163
168
|
pasteProcessor: (html) => {
|
|
164
169
|
// return html;
|
|
165
170
|
// console.log('html:', html, 'xxxxxx', removeAllFontFamilyStyles(html))
|
|
166
171
|
return removeAllFontFamilyStyles(html)
|
|
167
|
-
}
|
|
172
|
+
}
|
|
168
173
|
},
|
|
169
174
|
fontSize: {
|
|
170
175
|
defaultValue: ' ',
|
|
@@ -185,8 +190,8 @@ const defaultConfig = {
|
|
|
185
190
|
{ name: '六号', value: 9 },
|
|
186
191
|
{ name: '小六', value: 8 },
|
|
187
192
|
{ name: '七号', value: 6 },
|
|
188
|
-
{ name: '八号', value: 5 }
|
|
189
|
-
]
|
|
193
|
+
{ name: '八号', value: 5 }
|
|
194
|
+
]
|
|
190
195
|
},
|
|
191
196
|
onChange: (editor: AiEditor) => {
|
|
192
197
|
setFooter()
|
|
@@ -195,7 +200,7 @@ const defaultConfig = {
|
|
|
195
200
|
setTimeout(() => {
|
|
196
201
|
setContent()
|
|
197
202
|
}, 200)
|
|
198
|
-
}
|
|
203
|
+
}
|
|
199
204
|
}
|
|
200
205
|
|
|
201
206
|
/**
|
|
@@ -224,7 +229,7 @@ function removeAllFontFamilyStyles(html: string): string {
|
|
|
224
229
|
// 使用简化的正则表达式移除字体相关属性(现在可以安全地假设每个属性后都有分号)
|
|
225
230
|
style = style.replace(
|
|
226
231
|
/(?:font-family|mso-(?:ascii|hansi|bidi|fareast|east-asian|font)-font-family)\s*:\s*[^;]+;/gi,
|
|
227
|
-
''
|
|
232
|
+
''
|
|
228
233
|
)
|
|
229
234
|
// 清理空样式
|
|
230
235
|
style = style.trim()
|
|
@@ -244,7 +249,7 @@ function removeAllFontFamilyStyles(html: string): string {
|
|
|
244
249
|
'mso-ascii-font-family',
|
|
245
250
|
'mso-fareast-font-family',
|
|
246
251
|
'mso-east-asian-font-family',
|
|
247
|
-
'mso-font-font-family'
|
|
252
|
+
'mso-font-font-family'
|
|
248
253
|
]
|
|
249
254
|
fontFamilyAttrs.forEach((attr) => element.removeAttribute(attr))
|
|
250
255
|
|
|
@@ -271,6 +276,7 @@ function removeAllFontFamilyStyles(html: string): string {
|
|
|
271
276
|
Array.from(tempDiv.children).forEach((child) => processElement(child))
|
|
272
277
|
return tempDiv.innerHTML
|
|
273
278
|
}
|
|
279
|
+
|
|
274
280
|
/**
|
|
275
281
|
* 计算富文本框中图片的高度并赋值
|
|
276
282
|
*/
|
|
@@ -284,7 +290,7 @@ function calcImagesHeight(html: string) {
|
|
|
284
290
|
if (width > 1 && height > 1) {
|
|
285
291
|
map.set(
|
|
286
292
|
imageElement.src.length > 100 ? imageElement.src.substring(0, 100) : imageElement.src,
|
|
287
|
-
height
|
|
293
|
+
height
|
|
288
294
|
)
|
|
289
295
|
}
|
|
290
296
|
})
|
|
@@ -300,7 +306,7 @@ function customStringReplacement(
|
|
|
300
306
|
startMarker: string,
|
|
301
307
|
endMarker: string,
|
|
302
308
|
target: string,
|
|
303
|
-
replacement: string
|
|
309
|
+
replacement: string
|
|
304
310
|
): string {
|
|
305
311
|
let result = ''
|
|
306
312
|
let currentIndex = 0
|
|
@@ -333,6 +339,7 @@ function initHtml(html: string) {
|
|
|
333
339
|
html = customStringReplacement(html, '<img', '>', 'height="[0-9]+"', 'height="auto"')
|
|
334
340
|
return convertPtToPx(html)
|
|
335
341
|
}
|
|
342
|
+
|
|
336
343
|
const stopWatchByType = (type: WatchType) => {
|
|
337
344
|
const stopHandle = watchHandlers.value[type]
|
|
338
345
|
if (stopHandle) {
|
|
@@ -355,8 +362,8 @@ onMounted(() => {
|
|
|
355
362
|
{ name: '微软雅黑', value: 'Microsoft YaHei' },
|
|
356
363
|
{ name: '方正仿宋简体_GBK', value: 'FangSong_GB2312' },
|
|
357
364
|
{ name: 'Arial', value: 'Arial' },
|
|
358
|
-
{ name: 'Times New Roman', value: 'Times New Roman' }
|
|
359
|
-
]
|
|
365
|
+
{ name: 'Times New Roman', value: 'Times New Roman' }
|
|
366
|
+
]
|
|
360
367
|
},
|
|
361
368
|
onCreated: (editor: AiEditor) => {
|
|
362
369
|
stopWatchByType(WatchType.initWatch)
|
|
@@ -366,19 +373,26 @@ onMounted(() => {
|
|
|
366
373
|
if (aiEditor) {
|
|
367
374
|
aiEditor.setEditable(val)
|
|
368
375
|
//头尾显隐
|
|
369
|
-
const footer = divRef.value?.querySelector('aie-footer') as HTMLElement
|
|
370
|
-
if (footer) {
|
|
371
|
-
|
|
372
|
-
}
|
|
376
|
+
// const footer = divRef.value?.querySelector('aie-footer') as HTMLElement
|
|
377
|
+
// if (footer) {
|
|
378
|
+
// footer.style.display = val ? '' : 'none'
|
|
379
|
+
// }
|
|
373
380
|
const header = divRef.value?.querySelector('aie-header') as HTMLElement
|
|
374
381
|
if (header) {
|
|
375
|
-
|
|
382
|
+
const div = header.querySelector('div') as HTMLElement
|
|
383
|
+
div.style.justifyContent = val ? '' : 'end'
|
|
384
|
+
const menuItems = header.querySelectorAll('.aie-menu-item:not(:last-child)')
|
|
385
|
+
if (menuItems.length) {
|
|
386
|
+
menuItems.forEach((item) => {
|
|
387
|
+
item.style.display = val ? '' : 'none'
|
|
388
|
+
})
|
|
389
|
+
}
|
|
376
390
|
}
|
|
377
391
|
}
|
|
378
392
|
},
|
|
379
|
-
{ immediate: true }
|
|
393
|
+
{ immediate: true }
|
|
380
394
|
)
|
|
381
|
-
}
|
|
395
|
+
}
|
|
382
396
|
}
|
|
383
397
|
// 隐藏工具栏
|
|
384
398
|
if (!props.showToolbar) {
|
|
@@ -386,20 +400,6 @@ onMounted(() => {
|
|
|
386
400
|
}
|
|
387
401
|
setTimeout(() => {
|
|
388
402
|
aiEditor = new AiEditor(config)
|
|
389
|
-
setTimeout(() => {
|
|
390
|
-
//当隐藏工具栏时,也隐藏 aie-footer/aie-header 元素
|
|
391
|
-
if (!props.showToolbar || props.editorConfig?.editable === false) {
|
|
392
|
-
const footer = divRef.value?.querySelector('aie-footer') as HTMLElement
|
|
393
|
-
if (footer) {
|
|
394
|
-
footer.style.display = 'none'
|
|
395
|
-
}
|
|
396
|
-
const header = divRef.value?.querySelector('aie-header') as HTMLElement
|
|
397
|
-
if (header) {
|
|
398
|
-
header.style.display = 'none'
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
setFooter()
|
|
402
|
-
}, 100)
|
|
403
403
|
}, 100)
|
|
404
404
|
})
|
|
405
405
|
|
|
@@ -410,7 +410,7 @@ const setFooter = () => {
|
|
|
410
410
|
if (footerSpan && footerSpan.textContent) {
|
|
411
411
|
footerSpan.textContent = footerSpan.textContent.replace(
|
|
412
412
|
'Powered by AiEditor, Characters',
|
|
413
|
-
'字数'
|
|
413
|
+
'字数'
|
|
414
414
|
)
|
|
415
415
|
}
|
|
416
416
|
}
|
|
@@ -439,7 +439,7 @@ defineExpose({
|
|
|
439
439
|
if (aiEditor) {
|
|
440
440
|
aiEditor.setContent(initHtml(html), focus)
|
|
441
441
|
}
|
|
442
|
-
}
|
|
442
|
+
}
|
|
443
443
|
})
|
|
444
444
|
</script>
|
|
445
445
|
<style scoped lang="scss">
|
|
@@ -448,6 +448,7 @@ defineExpose({
|
|
|
448
448
|
border-width: v-bind(borderWidth);
|
|
449
449
|
border-color: #dcdfe6;
|
|
450
450
|
}
|
|
451
|
+
|
|
451
452
|
.aie-content {
|
|
452
453
|
p {
|
|
453
454
|
margin: 6px 0;
|