adtec-core-package 2.9.1 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adtec-core-package",
3
- "version": "2.9.1",
3
+ "version": "2.9.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -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">
@@ -156,13 +156,6 @@ const props = defineProps({
156
156
  type: String,
157
157
  default: 'default'
158
158
  },
159
- /**
160
- * 文件列表
161
- */
162
- uploadFilesList: {
163
- type: Array<ISysUploadFiles>,
164
- default: () => []
165
- },
166
159
  /**
167
160
  * @description 是否编辑状态
168
161
  * @default 'true'
@@ -203,14 +196,18 @@ const props = defineProps({
203
196
  default: true
204
197
  },
205
198
  showOptMessage: {
206
- type:Boolean,
207
- default:true
199
+ type: Boolean,
200
+ default: true
208
201
  },
209
202
  watermarkCode: {
210
203
  type: String,
211
204
  default: () => undefined
212
- },
205
+ }
213
206
  })
207
+ /**
208
+ * 文件列表
209
+ */
210
+ const uploadFilesList = defineModel<ISysUploadFiles[]>('uploadFilesList', { default: [] })
214
211
  const mousemove = (fileName: string) => {
215
212
  hoverfileName.value = fileName
216
213
  }
@@ -256,7 +253,7 @@ const getIcon = (fileName: string) => {
256
253
  }
257
254
  const success = (response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) => {
258
255
  if (response.code === '0') {
259
- props.uploadFilesList.push(response.data as ISysUploadFiles)
256
+ uploadFilesList.value.push(response.data as ISysUploadFiles)
260
257
  } else {
261
258
  ElMessage.error(response.msg)
262
259
  ref_upload.value?.handleRemove(uploadFile)
@@ -268,7 +265,7 @@ const success = (response: any, uploadFile: UploadFile, uploadFiles: UploadFiles
268
265
  }
269
266
  if (response.code === '0') {
270
267
  props.showOptMessage && ElMessage.success('上传成功')
271
- emit('success', { files: props.uploadFilesList, deleteFiles: deleteFiles.value })
268
+ emit('success', { files: uploadFilesList.value, deleteFiles: deleteFiles.value })
272
269
  }
273
270
  loading.value = false
274
271
  }
@@ -293,7 +290,7 @@ const hasPendingFiles = computed(() => {
293
290
  // { deep: true }
294
291
  // )
295
292
  const beforeUpload = async (file: File) => {
296
- const f = props.uploadFilesList.find((c) => c.name === file.name)
293
+ const f = uploadFilesList.value.find((c) => c.name === file.name)
297
294
  if (f) {
298
295
  ElMessage.warning(file.name + ',文件已存在')
299
296
  return false
@@ -341,8 +338,8 @@ const handleFileChange = (file, newFileList) => {
341
338
  }
342
339
  // 处理覆盖逻辑
343
340
  const exceed = async (files: File[], uploadFiles: UploadUserFile[]) => {
344
- if (props.limit === 1 && props.overwrite && props.uploadFilesList.length >= 1) {
345
- const existingFile = props.uploadFilesList[0]
341
+ if (props.limit === 1 && props.overwrite && uploadFilesList.value.length >= 1) {
342
+ const existingFile = uploadFilesList.value[0]
346
343
  if (!props.isConfirmDelete) {
347
344
  const flag = await ElMessageBox.confirm('只允许上传一个附件,是否点击确定覆盖原有附件?', '提示', {
348
345
  confirmButtonText: '确定',
@@ -364,7 +361,7 @@ const exceed = async (files: File[], uploadFiles: UploadUserFile[]) => {
364
361
  loading.value = false
365
362
  }
366
363
  }
367
- props.uploadFilesList.splice(0, 1)
364
+ uploadFilesList.value = []
368
365
  ref_upload.value?.clearFiles()
369
366
  if (files.length > 0) {
370
367
  const canUpload = await beforeUpload(files[0])
@@ -373,7 +370,7 @@ const exceed = async (files: File[], uploadFiles: UploadUserFile[]) => {
373
370
  ref_upload.value?.handleStart(files[0])
374
371
  props.autoUpload && ref_upload.value?.submit()
375
372
  } else {
376
- props.uploadFilesList.push(existingFile)
373
+ uploadFilesList.value.push(existingFile)
377
374
  }
378
375
  }
379
376
  } else {
@@ -390,7 +387,7 @@ const error = (error: Error, uploadFile: UploadFile, uploadFiles: UploadFiles) =
390
387
  loading.value = false
391
388
  }
392
389
  const preview = async (uploadFile: UploadFile) => {
393
- const file = props.uploadFilesList.find((c) => c.name === uploadFile.name)
390
+ const file = uploadFilesList.value.find((c) => c.name === uploadFile.name)
394
391
  if (file) {
395
392
  //if ((uploadFile.response as any).code === '0') {
396
393
  // const data = (uploadFile.response as any).data as ISysUploadFiles
@@ -400,13 +397,13 @@ const preview = async (uploadFile: UploadFile) => {
400
397
  const remove = async (file: UploadFile, isConfirm: boolean = true) => {
401
398
  // if ((file.response as any).code === '0') {
402
399
  // const data = (file.response as any).data as ISysUploadFiles
403
- const find = props.uploadFilesList.find((c) => c.name === file.name)
400
+ const find = uploadFilesList.value.find((c) => c.name === file.name)
404
401
  if (find) {
405
402
  try {
406
403
  if (!isConfirm && !props.isConfirmDelete) {
407
404
  await documentApi.delSysUploadFile(find.id)
408
405
  }
409
- props.uploadFilesList.splice(props.uploadFilesList.indexOf(find), 1)
406
+ uploadFilesList.value.splice(uploadFilesList.value.indexOf(find), 1)
410
407
  deleteFiles.value.push(find)
411
408
  } catch (err: any) {
412
409
  frameworkUtils.messageError(err)
@@ -417,7 +414,7 @@ const remove = async (file: UploadFile, isConfirm: boolean = true) => {
417
414
  const progress = (event: { percent: number }, file: UploadFile) => {
418
415
  loading.value = true
419
416
  }
420
- const confirm = async (autoDelete: boolean=true) => {
417
+ const confirm = async (autoDelete: boolean = true) => {
421
418
  try {
422
419
  loading.value = true
423
420
  if (props.isConfirmDelete && deleteFiles.value.length > 0 && autoDelete) {
@@ -429,7 +426,7 @@ const confirm = async (autoDelete: boolean=true) => {
429
426
  ref_upload.value?.submit()
430
427
  } else {
431
428
  props.showOptMessage && ElMessage.success('操作成功')
432
- emit('success', { files: props.uploadFilesList, deleteFiles: deleteFiles.value })
429
+ emit('success', { files: uploadFilesList.value, deleteFiles: deleteFiles.value })
433
430
  }
434
431
  }
435
432
  } catch (err: any) {
@@ -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
  }