adtec-core-package 2.9.2 → 2.9.3
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
|
@@ -26,7 +26,7 @@ enum WatchType {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const watchHandlers = ref<Partial<Record<WatchType, WatchStopHandle>>>({})
|
|
29
|
-
|
|
29
|
+
const emit = defineEmits(['onBlur', 'onChange'])
|
|
30
30
|
const divRef = ref()
|
|
31
31
|
let aiEditor: AiEditor | null
|
|
32
32
|
const props = withDefaults(
|
|
@@ -57,17 +57,17 @@ const props = withDefaults(
|
|
|
57
57
|
showToolbar: true,
|
|
58
58
|
borderWidth: '1px',
|
|
59
59
|
editorConfig: {},
|
|
60
|
-
isEdit: true
|
|
61
|
-
}
|
|
60
|
+
isEdit: true,
|
|
61
|
+
},
|
|
62
62
|
)
|
|
63
63
|
const model = defineModel({
|
|
64
64
|
type: [String, null, undefined],
|
|
65
65
|
required: false,
|
|
66
|
-
default: null
|
|
66
|
+
default: null,
|
|
67
67
|
})
|
|
68
68
|
const text = defineModel('text', {
|
|
69
69
|
type: String,
|
|
70
|
-
required: false
|
|
70
|
+
required: false,
|
|
71
71
|
})
|
|
72
72
|
//字体对照表
|
|
73
73
|
const fontSizes = [
|
|
@@ -86,7 +86,7 @@ const fontSizes = [
|
|
|
86
86
|
{ name: '小一', pt: 24, px: 28 },
|
|
87
87
|
{ name: '一号', pt: 26, px: 30 },
|
|
88
88
|
{ name: '小初', pt: 36, px: 42 },
|
|
89
|
-
{ name: '初号', pt: 42, px: 49 }
|
|
89
|
+
{ name: '初号', pt: 42, px: 49 },
|
|
90
90
|
]
|
|
91
91
|
|
|
92
92
|
function setDefaultPx(html: string) {
|
|
@@ -145,11 +145,11 @@ const defaultConfig = {
|
|
|
145
145
|
'video',
|
|
146
146
|
'ai',
|
|
147
147
|
'quote',
|
|
148
|
-
'emoji'
|
|
148
|
+
'emoji',
|
|
149
149
|
],
|
|
150
150
|
textSelectionBubbleMenu: {
|
|
151
151
|
enable: true,
|
|
152
|
-
items: ['Bold', 'Italic', 'Underline', 'Strike', 'code', 'comment']
|
|
152
|
+
items: ['Bold', 'Italic', 'Underline', 'Strike', 'code', 'comment'],
|
|
153
153
|
},
|
|
154
154
|
image: {
|
|
155
155
|
uploaderEvent: {
|
|
@@ -158,18 +158,18 @@ const defaultConfig = {
|
|
|
158
158
|
ElMessage.warning('图片大小不能超过2M')
|
|
159
159
|
return false
|
|
160
160
|
}
|
|
161
|
-
}
|
|
161
|
+
},
|
|
162
162
|
// onSuccess: (file, response) => {
|
|
163
163
|
// console.log('onSuccess', file, response)
|
|
164
164
|
// }
|
|
165
|
-
}
|
|
165
|
+
},
|
|
166
166
|
},
|
|
167
167
|
htmlPasteConfig: {
|
|
168
168
|
pasteProcessor: (html) => {
|
|
169
169
|
// return html;
|
|
170
170
|
// console.log('html:', html, 'xxxxxx', removeAllFontFamilyStyles(html))
|
|
171
171
|
return removeAllFontFamilyStyles(html)
|
|
172
|
-
}
|
|
172
|
+
},
|
|
173
173
|
},
|
|
174
174
|
fontSize: {
|
|
175
175
|
defaultValue: ' ',
|
|
@@ -190,17 +190,21 @@ const defaultConfig = {
|
|
|
190
190
|
{ name: '六号', value: 9 },
|
|
191
191
|
{ name: '小六', value: 8 },
|
|
192
192
|
{ name: '七号', value: 6 },
|
|
193
|
-
{ name: '八号', value: 5 }
|
|
194
|
-
]
|
|
193
|
+
{ name: '八号', value: 5 },
|
|
194
|
+
],
|
|
195
195
|
},
|
|
196
196
|
onChange: (editor: AiEditor) => {
|
|
197
|
+
emit('onChange', { html: editor.getHtml(), text: editor.getText() })
|
|
197
198
|
setFooter()
|
|
198
199
|
model.value = editor.getHtml()
|
|
199
200
|
text.value = editor.getText()
|
|
200
201
|
setTimeout(() => {
|
|
201
202
|
setContent()
|
|
202
203
|
}, 200)
|
|
203
|
-
}
|
|
204
|
+
},
|
|
205
|
+
onBlur: (editor: AiEditor) => {
|
|
206
|
+
emit('onBlur', { html: editor.getHtml(), text: editor.getText() })
|
|
207
|
+
},
|
|
204
208
|
}
|
|
205
209
|
|
|
206
210
|
/**
|
|
@@ -229,7 +233,7 @@ function removeAllFontFamilyStyles(html: string): string {
|
|
|
229
233
|
// 使用简化的正则表达式移除字体相关属性(现在可以安全地假设每个属性后都有分号)
|
|
230
234
|
style = style.replace(
|
|
231
235
|
/(?:font-family|mso-(?:ascii|hansi|bidi|fareast|east-asian|font)-font-family)\s*:\s*[^;]+;/gi,
|
|
232
|
-
''
|
|
236
|
+
'',
|
|
233
237
|
)
|
|
234
238
|
// 清理空样式
|
|
235
239
|
style = style.trim()
|
|
@@ -249,7 +253,7 @@ function removeAllFontFamilyStyles(html: string): string {
|
|
|
249
253
|
'mso-ascii-font-family',
|
|
250
254
|
'mso-fareast-font-family',
|
|
251
255
|
'mso-east-asian-font-family',
|
|
252
|
-
'mso-font-font-family'
|
|
256
|
+
'mso-font-font-family',
|
|
253
257
|
]
|
|
254
258
|
fontFamilyAttrs.forEach((attr) => element.removeAttribute(attr))
|
|
255
259
|
|
|
@@ -290,7 +294,7 @@ function calcImagesHeight(html: string) {
|
|
|
290
294
|
if (width > 1 && height > 1) {
|
|
291
295
|
map.set(
|
|
292
296
|
imageElement.src.length > 100 ? imageElement.src.substring(0, 100) : imageElement.src,
|
|
293
|
-
height
|
|
297
|
+
height,
|
|
294
298
|
)
|
|
295
299
|
}
|
|
296
300
|
})
|
|
@@ -306,7 +310,7 @@ function customStringReplacement(
|
|
|
306
310
|
startMarker: string,
|
|
307
311
|
endMarker: string,
|
|
308
312
|
target: string,
|
|
309
|
-
replacement: string
|
|
313
|
+
replacement: string,
|
|
310
314
|
): string {
|
|
311
315
|
let result = ''
|
|
312
316
|
let currentIndex = 0
|
|
@@ -362,8 +366,8 @@ onMounted(() => {
|
|
|
362
366
|
{ name: '微软雅黑', value: 'Microsoft YaHei' },
|
|
363
367
|
{ name: '方正仿宋简体_GBK', value: 'FangSong_GB2312' },
|
|
364
368
|
{ name: 'Arial', value: 'Arial' },
|
|
365
|
-
{ name: 'Times New Roman', value: 'Times New Roman' }
|
|
366
|
-
]
|
|
369
|
+
{ name: 'Times New Roman', value: 'Times New Roman' },
|
|
370
|
+
],
|
|
367
371
|
},
|
|
368
372
|
onCreated: (editor: AiEditor) => {
|
|
369
373
|
setFooter()
|
|
@@ -391,9 +395,9 @@ onMounted(() => {
|
|
|
391
395
|
}
|
|
392
396
|
}
|
|
393
397
|
},
|
|
394
|
-
{ immediate: true }
|
|
398
|
+
{ immediate: true },
|
|
395
399
|
)
|
|
396
|
-
}
|
|
400
|
+
},
|
|
397
401
|
}
|
|
398
402
|
// 隐藏工具栏
|
|
399
403
|
if (!props.showToolbar) {
|
|
@@ -403,7 +407,7 @@ onMounted(() => {
|
|
|
403
407
|
aiEditor = new AiEditor(config)
|
|
404
408
|
}, 100)
|
|
405
409
|
})
|
|
406
|
-
onActivated(()=>{
|
|
410
|
+
onActivated(() => {
|
|
407
411
|
const header = divRef.value?.querySelector('aie-header') as HTMLElement
|
|
408
412
|
if (header) {
|
|
409
413
|
const div = header.querySelector('div') as HTMLElement
|
|
@@ -423,7 +427,7 @@ const setFooter = () => {
|
|
|
423
427
|
if (footerSpan && footerSpan.textContent) {
|
|
424
428
|
footerSpan.textContent = footerSpan.textContent.replace(
|
|
425
429
|
'Powered by AiEditor, Characters',
|
|
426
|
-
'字数'
|
|
430
|
+
'字数',
|
|
427
431
|
)
|
|
428
432
|
}
|
|
429
433
|
}
|
|
@@ -452,7 +456,7 @@ defineExpose({
|
|
|
452
456
|
if (aiEditor) {
|
|
453
457
|
aiEditor.setContent(initHtml(html), focus)
|
|
454
458
|
}
|
|
455
|
-
}
|
|
459
|
+
},
|
|
456
460
|
})
|
|
457
461
|
</script>
|
|
458
462
|
<style scoped lang="scss">
|
package/src/utils/commonUtils.ts
CHANGED
|
@@ -316,7 +316,17 @@ export default {
|
|
|
316
316
|
return x >= a && x < b;
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
|
-
|
|
319
|
+
if (rule.includes('≤x≤')) {
|
|
320
|
+
const match = rule.match(/^([+-]?\d+(\.\d+)?)≤x≤([+-]?\d+(\.\d+)?)$/);
|
|
321
|
+
if (match) {
|
|
322
|
+
const a = parseFloat(match[1]);
|
|
323
|
+
const b = parseFloat(match[3]);
|
|
324
|
+
if (isNaN(a) || isNaN(b)) {
|
|
325
|
+
throw new Error(`Invalid rule values: ${match[1]} or ${match[3]}`);
|
|
326
|
+
}
|
|
327
|
+
return x >= a && x <= b;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
320
330
|
} catch (error) {
|
|
321
331
|
throw new Error(`Rule parsing error: ${(error as Error).message}`);
|
|
322
332
|
}
|