free-fe-core-modules 0.1.19 → 0.1.21

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.
@@ -26,6 +26,10 @@ export default defineComponent({
26
26
 
27
27
  const { proxy:vm } = getCurrentInstance();
28
28
  const { fieldData, setFieldData } = useFreeField(props);
29
+ if (fieldData.value === void 0) {
30
+ setFieldData(false, emit);
31
+ }
32
+
29
33
  const hasError = ref(false);
30
34
 
31
35
  const fieldTip = (tip) => {
@@ -31,10 +31,10 @@
31
31
  v-if="!Field.ReadOnly"
32
32
  ref="tiny"
33
33
  api-key="wh7g3etkwrso25e0wcpqrx8uvoa51toag3j92mllkajtg1xb"
34
- tinymce-script-src="/tiny/tiny7.js"
34
+ :tinymce-script-src="`${baseUrl}tiny/tiny7.js`"
35
35
  :init="{
36
36
  placeholder: Field.Placeholder || '',
37
- language_url: '/tiny/langs/zh_cn.js',
37
+ language_url: `${baseUrl}tiny/langs/zh_cn.js`,
38
38
  language: 'zh_cn',
39
39
  plugins: Field.ReadOnly ? [] : this.plugins,
40
40
  menubar: Field.ReadOnly ? [] : this.menubar,
@@ -273,6 +273,48 @@ export default defineComponent({
273
273
  return isVal;
274
274
  };
275
275
 
276
+ const handleVideoUpload = (file, editor) => {
277
+ const formData = new FormData();
278
+ formData.append('file', file, file.name || 'pasted-video');
279
+
280
+ vm.postRequest('/upload', formData, {
281
+ __ignoreDecycle: true,
282
+ headers: {
283
+ 'Content-Type': 'multipart/form-data',
284
+ },
285
+ }).then((res) => {
286
+ if (res && res.data && res.data.id) {
287
+ const videoUrl = `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}${vm.ctx.config.videoUrlBase}${res.data.id}${props.Field.Options?.UploadedImageUrlArgs || ''}`;
288
+
289
+ // 插入视频元素到编辑器
290
+ editor.insertContent(`
291
+ <div class="video-container" style="margin: 10px 0;">
292
+ <video src="${videoUrl}" controls style="max-width: 100%; height: auto;">
293
+ 您的浏览器不支持视频播放
294
+ </video>
295
+ </div>
296
+ `);
297
+ }
298
+ }).catch(() => {
299
+ });
300
+ };
301
+
302
+ const paste_preprocess = (editor, args) => {
303
+ const items = args.clipboardData.items;
304
+
305
+ for (let i = 0; i < items.length; i++) {
306
+ const item = items[i];
307
+
308
+ // 检查是否为视频文件
309
+ if (item.kind === 'file' && item.type.startsWith('video/')) {
310
+ const file = item.getAsFile();
311
+
312
+ // 处理视频上传
313
+ handleVideoUpload(file, editor);
314
+ }
315
+ }
316
+ };
317
+
276
318
  const tinySetup = (editor) => {
277
319
  // add button for indent 2ems
278
320
  editor.on('init', () => {
@@ -331,6 +373,11 @@ export default defineComponent({
331
373
  }
332
374
  });
333
375
  }
376
+
377
+ // 处理粘贴视频文件
378
+ editor.on('paste', (e) => {
379
+ paste_preprocess(editor, e);
380
+ });
334
381
  };
335
382
 
336
383
  const tinyChanged = (v) => {
@@ -385,6 +432,8 @@ export default defineComponent({
385
432
  });
386
433
  });
387
434
  }),
435
+
436
+ baseUrl: import.meta.env.BASE_URL,
388
437
  };
389
438
  },
390
439
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-fe-core-modules",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/freeeis/free-fe-core-modules.git",
6
6
  "author": "zhiquan",