free-fe-core-modules 0.0.33 → 0.0.35

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.
@@ -25,7 +25,7 @@
25
25
  <span
26
26
  v-if="Field.ReadOnly"
27
27
  class="col readonly"
28
- :ref="readonlyContent"
28
+ ref="readonlyContent"
29
29
  ></span>
30
30
  <tiny
31
31
  v-if="!Field.ReadOnly"
@@ -48,7 +48,12 @@
48
48
  extended_valid_elements:'efield',
49
49
  setup: tinySetup,
50
50
  default_link_target: (Field && Field.Options && Field.Options.LinkTarget) || '_blank',
51
- }"
51
+
52
+ automatic_uploads: true,
53
+ images_upload_url: '/api/upload',
54
+ images_reuse_filename: true,
55
+ images_upload_handler,
56
+ }"
52
57
  initial-value
53
58
  model-events
54
59
  plugins
@@ -63,7 +68,7 @@
63
68
  </template>
64
69
 
65
70
  <script>
66
- import { defineComponent, watchEffect, ref } from 'vue';
71
+ import { defineComponent, watchEffect, ref, getCurrentInstance } from 'vue';
67
72
  import tiny from '@tinymce/tinymce-vue';
68
73
  import { fileSizeStrToNumber } from '../composible/useFileSizeUtils';
69
74
  import { useFreeField, freeFieldProps } from '../composible/useFreeField';
@@ -115,6 +120,8 @@ export default defineComponent({
115
120
  enableField: { type: Boolean, default: false },
116
121
  },
117
122
  setup(props, { expose, emit }) {
123
+ const { proxy:vm } = getCurrentInstance();
124
+
118
125
  if (!props.Field) return {};
119
126
 
120
127
  const { fieldData, setFieldData } = useFreeField(props);
@@ -347,6 +354,34 @@ export default defineComponent({
347
354
  toolbar,
348
355
  quickbars_selection_toolbar,
349
356
  contextmenu,
357
+
358
+ images_upload_handler: (
359
+ blobInfo,
360
+ success,
361
+ failure,
362
+ ) => {
363
+ const formData = new FormData();
364
+ formData.append('file', blobInfo.blob(), blobInfo.filename());
365
+
366
+ vm.postRequest('/upload', formData, {
367
+ __ignoreDecycle: true,
368
+ headers: {
369
+ 'Content-Type': 'multipart/form-data',
370
+ },
371
+ }).then((res) => {
372
+ if (res && res.data && res.data.id) {
373
+ success(`${vm.ctx.config.imageUrlBase}${res.data.id}`);
374
+ } else {
375
+ failure('上传失败', {
376
+ remove: true,
377
+ });
378
+ }
379
+ }).catch((err) => {
380
+ failure(err, {
381
+ remove: true,
382
+ });
383
+ });
384
+ },
350
385
  };
351
386
  },
352
387
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-fe-core-modules",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/freeeis/free-fe-core-modules.git",
6
6
  "author": "zhiquan",