@keyblade/tinymce-editor-vue2 0.0.12-alpha.12 → 0.0.12-alpha.14

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/README.md CHANGED
@@ -110,6 +110,7 @@ import { oneTravelImageCheck, oneTravelImageCompressor } from '@keyblade/tinymce
110
110
  ```typescript
111
111
  export async function oneTravelImageCheck(data: File | Blob, options?: {
112
112
  imageMaxSize?: number;
113
+ imageAllowedType?: string[];
113
114
  imageAllowedMineType?: string[]
114
115
  imageMinWidth?: number;
115
116
  imageMinHeight?: number;
@@ -126,7 +127,9 @@ export async function oneTravelImageCheck(data: File | Blob, options?: {
126
127
  format?: boolean;
127
128
  pixel?: boolean;
128
129
  message?: string
129
- }
130
+ },
131
+ /** 错误消息 */
132
+ errorMessage?: string;
130
133
  }> {}
131
134
 
132
135
  export async function oneTravelImageCompressor(data: File | Blob): Promise<{
@@ -237,6 +237,7 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
237
237
  options: () => {};
238
238
  }>>>, {
239
239
  imageMaxSize: number;
240
+ imageAllowedType: string[];
240
241
  imageAllowedMineType: string[];
241
242
  imageMinWidth: number;
242
243
  imageMinHeight: number;
@@ -246,7 +247,6 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
246
247
  modelValue: string;
247
248
  imageUploadMaxCount: number;
248
249
  imageUploadTip: string;
249
- imageAllowedType: string[];
250
250
  audioEnable: boolean;
251
251
  audioMaxSize: number;
252
252
  audioAllowedType: string[];
package/es/editor.vue2.js CHANGED
@@ -32,7 +32,7 @@ import "tinymce/plugins/table";
32
32
  import "tinymce/plugins/visualblocks";
33
33
  import "tinymce/plugins/visualchars";
34
34
  import "tinymce/plugins/wordcount";
35
- import { globalProps as b } from "./index.js";
35
+ import { globalProps as y } from "./index.js";
36
36
  import { Loading as xe, Message as h } from "element-ui";
37
37
  const ia = /* @__PURE__ */ ce({
38
38
  __name: "editor",
@@ -140,6 +140,7 @@ const ia = /* @__PURE__ */ ce({
140
140
  var p, c;
141
141
  const t = await N(i, {
142
142
  imageMaxSize: a.imageMaxSize,
143
+ imageAllowedType: a.imageAllowedType,
143
144
  imageAllowedMineType: a.imageAllowedMineType,
144
145
  imageMinWidth: a.imageMinWidth,
145
146
  imageMinHeight: a.imageMinHeight,
@@ -190,16 +191,16 @@ const ia = /* @__PURE__ */ ce({
190
191
  }
191
192
  }
192
193
  }
193
- const y = M(() => x([a.videoUploadOptions, b.videoUploadOptions]) || {}), _ = M(() => x([a.audioUploadOptions, b.audioUploadOptions]) || {}), $ = M(() => x([a.imgPondOptions, b.imgPondOptions]) || {}), C = M(
194
- () => x([a.paste_preprocess, b.paste_preprocess], {
194
+ const b = M(() => x([a.videoUploadOptions, y.videoUploadOptions]) || {}), _ = M(() => x([a.audioUploadOptions, y.audioUploadOptions]) || {}), $ = M(() => x([a.imgPondOptions, y.imgPondOptions]) || {}), C = M(
195
+ () => x([a.paste_preprocess, y.paste_preprocess], {
195
196
  type: Function
196
197
  })
197
198
  ), D = M(
198
- () => x([a.paste_postprocess, b.paste_postprocess], {
199
+ () => x([a.paste_postprocess, y.paste_postprocess], {
199
200
  type: Function
200
201
  })
201
202
  ), f = M(
202
- () => x([a.imageUploadHandle, b.imageUploadHandle], {
203
+ () => x([a.imageUploadHandle, y.imageUploadHandle], {
203
204
  type: Function
204
205
  })
205
206
  );
@@ -301,6 +302,7 @@ const ia = /* @__PURE__ */ ce({
301
302
  let u = o.blob();
302
303
  const v = o.filename(), p = await N(u, {
303
304
  imageMaxSize: a.imageMaxSize,
305
+ imageAllowedType: a.imageAllowedType,
304
306
  imageAllowedMineType: a.imageAllowedMineType,
305
307
  imageMinWidth: a.imageMinWidth,
306
308
  imageMinHeight: a.imageMinHeight,
@@ -386,7 +388,7 @@ const ia = /* @__PURE__ */ ce({
386
388
  }, l = x(
387
389
  [
388
390
  a.options,
389
- b.tinymceOptions,
391
+ y.tinymceOptions,
390
392
  i
391
393
  ],
392
394
  {
@@ -434,13 +436,13 @@ const ia = /* @__PURE__ */ ce({
434
436
  h.error("上传发生错误,请重试!"), r.value.formData.file = o;
435
437
  }, re = () => {
436
438
  var i, l;
437
- return ((l = (i = y.value) == null ? void 0 : i.data) == null ? void 0 : l.call(i, { ...s.value.additionalData || {}, extParameters: a.extParameters })) || {};
439
+ return ((l = (i = b.value) == null ? void 0 : i.data) == null ? void 0 : l.call(i, { ...s.value.additionalData || {}, extParameters: a.extParameters })) || {};
438
440
  }, se = () => {
439
441
  var i, l;
440
- return ((l = (i = y.value) == null ? void 0 : i.headers) == null ? void 0 : l.call(i, { ...s.value.additionalData || {}, extParameters: a.extParameters })) || {};
442
+ return ((l = (i = b.value) == null ? void 0 : i.headers) == null ? void 0 : l.call(i, { ...s.value.additionalData || {}, extParameters: a.extParameters })) || {};
441
443
  }, de = (i, l, o) => {
442
444
  var t, n;
443
- const e = (n = (t = y == null ? void 0 : y.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t, i);
445
+ const e = (n = (t = b == null ? void 0 : b.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t, i);
444
446
  e != null && e.url ? o[o.length - 1].url = e.url : e != null && e.errorMessage && (h.error(e.errorMessage), o.splice(o.length - 1, 1)), s.value.formData.file = o;
445
447
  }, ue = (i, l) => new Promise((o, e) => {
446
448
  const t = i.name.split(".").filter(Boolean).pop() ? i.name.split(".").filter(Boolean).pop() : "";
@@ -475,7 +477,7 @@ const ia = /* @__PURE__ */ ce({
475
477
  V.value = !0, (i = d.value) == null || i.setContent(a.value ? a.value : a.modelValue ? a.modelValue : "");
476
478
  },
477
479
  { immediate: !0 }
478
- ), { __sfc: !0, insRef: k, editorRef: d, preventSettingContent: U, preventUpdatingModelValue: V, uploadImage: g, uploadImageFormRef: z, onUploadImageClose: L, onUploadImageConfirm: J, uploadAudio: r, uploadAudioFormRef: H, onUploadAudioConfirm: K, onUploadAudioClose: Q, uploadVideo: s, uploadVideoFormRef: W, onUploadVideoConfirm: X, onUploadVideoClose: Y, onImageUploadUpload: Z, props: a, emits: S, imgPondAccept: ee, processPastedImage: B, mergeVideoUploadOptions: y, mergeAudioUploadOptions: _, mergeImgPondOptions: $, paste_preprocess: C, paste_postprocess: D, imageUploadHandle: f, getUploadAudioData: ae, getUploadAudioHeaders: ie, onUploadAudioSuccess: oe, onUploadAudioBeforeUpload: te, onUploadAudioRemove: le, onUploadAudioError: ne, getUploadVideoData: re, getUploadVideoHeaders: se, onUploadVideoSuccess: de, onUploadVideoBeforeUpload: ue, onUploadVideoRemove: me, onUploadVideoError: pe, ImgPond: he };
480
+ ), { __sfc: !0, insRef: k, editorRef: d, preventSettingContent: U, preventUpdatingModelValue: V, uploadImage: g, uploadImageFormRef: z, onUploadImageClose: L, onUploadImageConfirm: J, uploadAudio: r, uploadAudioFormRef: H, onUploadAudioConfirm: K, onUploadAudioClose: Q, uploadVideo: s, uploadVideoFormRef: W, onUploadVideoConfirm: X, onUploadVideoClose: Y, onImageUploadUpload: Z, props: a, emits: S, imgPondAccept: ee, processPastedImage: B, mergeVideoUploadOptions: b, mergeAudioUploadOptions: _, mergeImgPondOptions: $, paste_preprocess: C, paste_postprocess: D, imageUploadHandle: f, getUploadAudioData: ae, getUploadAudioHeaders: ie, onUploadAudioSuccess: oe, onUploadAudioBeforeUpload: te, onUploadAudioRemove: le, onUploadAudioError: ne, getUploadVideoData: re, getUploadVideoHeaders: se, onUploadVideoSuccess: de, onUploadVideoBeforeUpload: ue, onUploadVideoRemove: me, onUploadVideoError: pe, ImgPond: he };
479
481
  }
480
482
  });
481
483
  export {
package/es/index.d.ts CHANGED
@@ -61,6 +61,10 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
61
61
  type: import('vue').PropType<number>;
62
62
  default: number;
63
63
  };
64
+ imageAllowedType: {
65
+ type: import('vue').PropType<string[]>;
66
+ default: () => string[];
67
+ };
64
68
  imageAllowedMineType: {
65
69
  type: import('vue').PropType<string[]>;
66
70
  default: () => string[];
@@ -103,10 +107,6 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
103
107
  type: import('vue').PropType<string>;
104
108
  default: string;
105
109
  };
106
- imageAllowedType: {
107
- type: import('vue').PropType<string[]>;
108
- default: () => string[];
109
- };
110
110
  audioEnable: {
111
111
  type: import('vue').PropType<boolean>;
112
112
  default: boolean;
@@ -203,6 +203,10 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
203
203
  type: import('vue').PropType<number>;
204
204
  default: number;
205
205
  };
206
+ imageAllowedType: {
207
+ type: import('vue').PropType<string[]>;
208
+ default: () => string[];
209
+ };
206
210
  imageAllowedMineType: {
207
211
  type: import('vue').PropType<string[]>;
208
212
  default: () => string[];
@@ -245,10 +249,6 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
245
249
  type: import('vue').PropType<string>;
246
250
  default: string;
247
251
  };
248
- imageAllowedType: {
249
- type: import('vue').PropType<string[]>;
250
- default: () => string[];
251
- };
252
252
  audioEnable: {
253
253
  type: import('vue').PropType<boolean>;
254
254
  default: boolean;
@@ -345,6 +345,7 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
345
345
  "update:modelValue": (value: string) => void;
346
346
  }, {
347
347
  imageMaxSize: number;
348
+ imageAllowedType: string[];
348
349
  imageAllowedMineType: string[];
349
350
  imageMinWidth: number;
350
351
  imageMinHeight: number;
@@ -354,7 +355,6 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
354
355
  modelValue: string;
355
356
  imageUploadMaxCount: number;
356
357
  imageUploadTip: string;
357
- imageAllowedType: string[];
358
358
  audioEnable: boolean;
359
359
  audioMaxSize: number;
360
360
  audioAllowedType: string[];
@@ -367,6 +367,10 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
367
367
  type: import('vue').PropType<number>;
368
368
  default: number;
369
369
  };
370
+ imageAllowedType: {
371
+ type: import('vue').PropType<string[]>;
372
+ default: () => string[];
373
+ };
370
374
  imageAllowedMineType: {
371
375
  type: import('vue').PropType<string[]>;
372
376
  default: () => string[];
@@ -409,10 +413,6 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
409
413
  type: import('vue').PropType<string>;
410
414
  default: string;
411
415
  };
412
- imageAllowedType: {
413
- type: import('vue').PropType<string[]>;
414
- default: () => string[];
415
- };
416
416
  audioEnable: {
417
417
  type: import('vue').PropType<boolean>;
418
418
  default: boolean;
@@ -509,6 +509,10 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
509
509
  type: import('vue').PropType<number>;
510
510
  default: number;
511
511
  };
512
+ imageAllowedType: {
513
+ type: import('vue').PropType<string[]>;
514
+ default: () => string[];
515
+ };
512
516
  imageAllowedMineType: {
513
517
  type: import('vue').PropType<string[]>;
514
518
  default: () => string[];
@@ -551,10 +555,6 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
551
555
  type: import('vue').PropType<string>;
552
556
  default: string;
553
557
  };
554
- imageAllowedType: {
555
- type: import('vue').PropType<string[]>;
556
- default: () => string[];
557
- };
558
558
  audioEnable: {
559
559
  type: import('vue').PropType<boolean>;
560
560
  default: boolean;
@@ -651,6 +651,10 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
651
651
  type: import('vue').PropType<number>;
652
652
  default: number;
653
653
  };
654
+ imageAllowedType: {
655
+ type: import('vue').PropType<string[]>;
656
+ default: () => string[];
657
+ };
654
658
  imageAllowedMineType: {
655
659
  type: import('vue').PropType<string[]>;
656
660
  default: () => string[];
@@ -693,10 +697,6 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
693
697
  type: import('vue').PropType<string>;
694
698
  default: string;
695
699
  };
696
- imageAllowedType: {
697
- type: import('vue').PropType<string[]>;
698
- default: () => string[];
699
- };
700
700
  audioEnable: {
701
701
  type: import('vue').PropType<boolean>;
702
702
  default: boolean;
@@ -793,6 +793,7 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
793
793
  "update:modelValue": (value: string) => void;
794
794
  }, string, {
795
795
  imageMaxSize: number;
796
+ imageAllowedType: string[];
796
797
  imageAllowedMineType: string[];
797
798
  imageMinWidth: number;
798
799
  imageMinHeight: number;
@@ -802,7 +803,6 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
802
803
  modelValue: string;
803
804
  imageUploadMaxCount: number;
804
805
  imageUploadTip: string;
805
- imageAllowedType: string[];
806
806
  audioEnable: boolean;
807
807
  audioMaxSize: number;
808
808
  audioAllowedType: string[];
@@ -816,6 +816,10 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
816
816
  type: import('vue').PropType<number>;
817
817
  default: number;
818
818
  };
819
+ imageAllowedType: {
820
+ type: import('vue').PropType<string[]>;
821
+ default: () => string[];
822
+ };
819
823
  imageAllowedMineType: {
820
824
  type: import('vue').PropType<string[]>;
821
825
  default: () => string[];
@@ -858,10 +862,6 @@ declare const TinymceEditor: import('vue/types/v3-component-public-instance').Co
858
862
  type: import('vue').PropType<string>;
859
863
  default: string;
860
864
  };
861
- imageAllowedType: {
862
- type: import('vue').PropType<string[]>;
863
- default: () => string[];
864
- };
865
865
  audioEnable: {
866
866
  type: import('vue').PropType<boolean>;
867
867
  default: boolean;
package/es/util.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  */
4
4
  export declare function oneTravelImageCheck(data: File | Blob, options?: {
5
5
  imageMaxSize?: number;
6
+ imageAllowedType?: string[];
6
7
  imageAllowedMineType?: string[];
7
8
  imageMinWidth?: number;
8
9
  imageMinHeight?: number;
package/es/util.js CHANGED
@@ -1,77 +1,90 @@
1
- import h from "compressorjs";
2
- async function y(a, e) {
1
+ import { compressAccurately as h } from "image-conversion";
2
+ import w from "compressorjs";
3
+ async function x(r, s) {
3
4
  const {
4
- imageMaxSize: s = 30,
5
- imageAllowedMineType: r = ["image/jpg", "image/jpeg", "image/png", "image/bmp", "image/heif", "image/heic", "image/gif", "image/webp"],
6
- imageMinWidth: i = 60,
7
- imageMinHeight: t = 60,
5
+ imageMaxSize: t = 30,
6
+ imageAllowedType: i = ["jpg", "jpeg", "png", "bmp", "heif", "gif", "webp"],
7
+ imageAllowedMineType: e = ["image/jpg", "image/jpeg", "image/png", "image/bmp", "image/heif", "image/heic", "image/gif", "image/webp"],
8
+ imageMinWidth: a = 60,
9
+ imageMinHeight: c = 60,
8
10
  imageMaxWidth: o = 6e3,
9
- imageMaxHeight: c = 6e3
10
- } = e || {}, n = a, l = await u(n);
11
- if (n.size > s * 1024 * 1024)
12
- return { success: !1, error: { size: !0 }, errorMessage: `请上传大小不超过${s}M的图片` };
13
- if (!r.includes(n.type))
14
- return { success: !1, error: { format: !0 }, errorMessage: `请上传格式为${r.map((f) => f.toUpperCase()).join("、")}的图片` };
15
- const g = await m(l);
16
- return g.width < i && g.height < t || g.width > o && g.height > c ? { success: !1, error: { pixel: !0 }, errorMessage: `请上传像素不低于${i}*${t}且像素不高于${o}*${c}的图片` } : { success: !0, file: n };
11
+ imageMaxHeight: g = 6e3
12
+ } = s || {}, n = r, p = await l(n);
13
+ if (n.size > t * 1024 * 1024)
14
+ return { success: !1, error: { size: !0 }, errorMessage: `请上传大小不超过${t}M的图片` };
15
+ if (!e.includes(n.type))
16
+ return { success: !1, error: { format: !0 }, errorMessage: `请上传格式为${i.map((f) => f.toUpperCase()).join("、")}的图片` };
17
+ const m = await u(p);
18
+ return m.width < a && m.height < c || m.width > o && m.height > g ? { success: !1, error: { pixel: !0 }, errorMessage: `请上传像素不低于${a}*${c}且像素不高于${o}*${g}的图片` } : { success: !0, file: n };
17
19
  }
18
- async function b(a) {
19
- var c;
20
- let e = a;
21
- const s = await u(e), r = await m(s);
20
+ async function z(r) {
21
+ var g;
22
+ let s = r;
23
+ const t = await l(s);
22
24
  let i = !1;
23
- const t = {};
24
- ["image/heif", "image/heic", "image/webp"].includes(e.type) && (t.convertTypes = [e.type], t.convertSize = 0, i = !0);
25
+ const e = {};
26
+ let a = "image-conversion", c = s.type;
27
+ ["image/heif", "image/heic", "image/webp"].includes(s.type) && (a = "compressor", e.convertTypes = [s.type], e.convertSize = 0, e.quality = 1, c = "image/jpeg", i = !0);
25
28
  const o = 5 * 1024 * 1024;
26
- if (e.size > o && (t.convertTypes = [e.type], t.convertSize = o, t.maxWidth = r.width * (o / e.size), i = !0), Object.keys(t).length > 0) {
27
- const n = await p(w(s), t);
29
+ if (s.size > o)
30
+ if (i) {
31
+ const n = await u(t);
32
+ a = "compressor", e.convertTypes = [s.type], e.convertSize = o, e.maxWidth = n.width * (o / s.size), e.quality = 0.92;
33
+ } else
34
+ a = "image-conversion", e.type = c, e.size = 5 * 1024;
35
+ if (Object.keys(e).length > 0) {
36
+ const n = await d(y(t), e, a);
28
37
  if (n.success)
29
- e = n.file;
38
+ s = n.file;
30
39
  else
31
- return { file: e, success: !1, hasConversion: i, errorMessage: (c = n.error) == null ? void 0 : c.message };
40
+ return { file: s, success: !1, hasConversion: i, errorMessage: (g = n.error) == null ? void 0 : g.message };
32
41
  }
33
- return { file: e, hasConversion: i, success: !0 };
42
+ return { file: s, hasConversion: i, success: !0 };
34
43
  }
35
- function p(a, e) {
36
- return new Promise((s) => {
37
- new h(a, {
38
- ...e,
39
- success: async (r) => {
40
- s({ success: !0, file: r });
44
+ function d(r, s = {}, t) {
45
+ return new Promise((i) => {
46
+ t === "compressor" ? new w(r, {
47
+ ...s,
48
+ success: async (e) => {
49
+ i({ success: !0, file: e });
41
50
  },
42
- error(r) {
43
- s({ success: !1, error: r });
51
+ error(e) {
52
+ i({ success: !1, error: e });
44
53
  }
54
+ }) : h(r, s).then((e) => {
55
+ i({ success: !0, file: e });
56
+ }).catch((e) => {
57
+ i({ success: !1, error: (e == null ? void 0 : e.message) || "" });
45
58
  });
46
59
  });
47
60
  }
48
- function m(a) {
49
- return new Promise((e) => {
50
- const s = new Image();
51
- s.onload = function() {
52
- e({ width: s.width, height: s.height, image: s });
53
- }, s.src = a;
61
+ function u(r) {
62
+ return new Promise((s) => {
63
+ const t = new Image();
64
+ t.onload = function() {
65
+ s({ width: t.width, height: t.height, image: t });
66
+ }, t.src = r;
54
67
  });
55
68
  }
56
- function w(a) {
57
- const e = a.split(","), s = e[0].match(/:(.*?);/)[1], r = atob(e[1]);
58
- let i = r.length;
59
- const t = new Uint8Array(i);
60
- for (; i--; )
61
- t[i] = r.charCodeAt(i);
62
- return new Blob([t], { type: s });
69
+ function y(r) {
70
+ const s = r.split(","), t = s[0].match(/:(.*?);/)[1], i = atob(s[1]);
71
+ let e = i.length;
72
+ const a = new Uint8Array(e);
73
+ for (; e--; )
74
+ a[e] = i.charCodeAt(e);
75
+ return new Blob([a], { type: t });
63
76
  }
64
- function u(a) {
65
- return new Promise((e, s) => {
66
- const r = new FileReader();
67
- r.onloadend = () => {
68
- const i = r.result;
69
- e(i);
70
- }, r.onerror = s, r.readAsDataURL(a);
77
+ function l(r) {
78
+ return new Promise((s, t) => {
79
+ const i = new FileReader();
80
+ i.onloadend = () => {
81
+ const e = i.result;
82
+ s(e);
83
+ }, i.onerror = t, i.readAsDataURL(r);
71
84
  });
72
85
  }
73
86
  export {
74
- m as getImagePixel,
75
- y as oneTravelImageCheck,
76
- b as oneTravelImageCompressor
87
+ u as getImagePixel,
88
+ x as oneTravelImageCheck,
89
+ z as oneTravelImageCompressor
77
90
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@keyblade/tinymce-editor-vue2",
3
3
  "description": "KeyBlade Tinymce Editor Vue2",
4
4
  "author": "yangshuai <704807396@qq.com>",
5
- "version": "0.0.12-alpha.12",
5
+ "version": "0.0.12-alpha.14",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",