@keyblade/tinymce-editor-vue2 0.0.9-alpha.1 → 0.0.11

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.
Files changed (2) hide show
  1. package/es/editor.vue2.js +24 -24
  2. package/package.json +1 -1
package/es/editor.vue2.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineComponent as N, ref as y, computed as k, onMounted as L, onUnmounted as j, watch as O } from "vue";
1
+ import { defineComponent as N, ref as w, computed as k, onMounted as j, onUnmounted as L, watch as O } from "vue";
2
2
  import q from "compressorjs";
3
3
  import { conclude as _ } from "vue-global-config";
4
4
  import R from "tinymce";
@@ -56,8 +56,8 @@ const ze = /* @__PURE__ */ N({
56
56
  setup($, { emit: b }) {
57
57
  const t = $;
58
58
  R.addI18n("zh_CN", E);
59
- const P = y(), l = y(), g = y(!1), f = y(!1);
60
- async function W(n) {
59
+ const P = w(), l = w(), g = w(!1), f = w(!1);
60
+ async function T(n) {
61
61
  var a, e;
62
62
  const s = n.getElementsByTagName("img");
63
63
  for (let o of s) {
@@ -68,7 +68,7 @@ const ze = /* @__PURE__ */ N({
68
68
  (a = o == null ? void 0 : o.remove) == null || a.call(o);
69
69
  return;
70
70
  }
71
- const x = i.split("."), C = x[x.length - 1].toLowerCase();
71
+ const y = i.split("."), C = y[y.length - 1].toLowerCase();
72
72
  if (!t.imageAllowedType.includes(C)) {
73
73
  (e = o == null ? void 0 : o.remove) == null || e.call(o);
74
74
  return;
@@ -76,7 +76,7 @@ const ze = /* @__PURE__ */ N({
76
76
  }
77
77
  }
78
78
  }
79
- const A = (n) => {
79
+ const W = (n) => {
80
80
  const s = n.split(","), a = s[0].match(/:(.*?);/)[1], e = atob(s[1]);
81
81
  let o = e.length;
82
82
  const i = new Uint8Array(o);
@@ -92,7 +92,7 @@ const ze = /* @__PURE__ */ N({
92
92
  }, a.src = n;
93
93
  });
94
94
  }
95
- function H(n, s) {
95
+ function A(n, s) {
96
96
  return new Promise((a) => {
97
97
  new q(n, {
98
98
  ...s,
@@ -113,12 +113,12 @@ const ze = /* @__PURE__ */ N({
113
113
  () => _([t.paste_postprocess, d.paste_postprocess], {
114
114
  type: Function
115
115
  })
116
- ), c = k(
116
+ ), p = k(
117
117
  () => _([t.imageUploadHandle, d.imageUploadHandle], {
118
118
  type: Function
119
119
  })
120
120
  );
121
- return L(() => {
121
+ return j(() => {
122
122
  const n = {
123
123
  // 设置语言
124
124
  language: "zh_CN",
@@ -196,34 +196,34 @@ const ze = /* @__PURE__ */ N({
196
196
  paste_postprocess(a, e) {
197
197
  var i;
198
198
  const o = e.node;
199
- W(o), (i = v.value) == null || i.call(v, a, e);
199
+ T(o), (i = v.value) == null || i.call(v, a, e);
200
200
  },
201
201
  images_upload_handler(a) {
202
202
  return new Promise(async (e, o) => {
203
- var w, V, B;
204
- const i = (V = (w = d.message) == null ? void 0 : w.loading) == null ? void 0 : V.call(w);
203
+ var x, U, V, B;
204
+ const i = (U = (x = d.message) == null ? void 0 : x.loading) == null ? void 0 : U.call(x);
205
205
  let r = a.blob();
206
- const x = a.base64(), C = a.filename(), T = r.name.split("."), F = T[T.length - 1].toLowerCase();
206
+ const y = a.base64(), C = a.filename(), F = r.type;
207
207
  if (r.size > t.imageMaxSize * 1024 * 1024)
208
208
  return i == null || i.close(), o({ message: `请上传大小不超过${t.imageMaxSize}M的图片`, remove: !0 });
209
209
  if (!t.imageAllowedMineType.includes(r.type))
210
- return i == null || i.close(), o({ message: `请上传格式为${t.imageAllowedType.map((u) => u.toUpperCase()).join("、")}的图片`, remove: !0 });
211
- const U = "data:" + r.type + ";base64," + x, p = await M(U);
212
- if (p.width < t.imageMinWidth && p.height < t.imageMinHeight || p.width > t.imageMaxWidth && p.height > t.imageMaxHeight)
210
+ return i == null || i.close(), o({ message: `请上传格式为${t.imageAllowedType.map((c) => c.toUpperCase()).join("、")}的图片`, remove: !0 });
211
+ const H = "data:" + r.type + ";base64," + y, u = await M(H);
212
+ if (u.width < t.imageMinWidth && u.height < t.imageMinHeight || u.width > t.imageMaxWidth && u.height > t.imageMaxHeight)
213
213
  return i == null || i.close(), o({ message: `请上传像素不低于${t.imageMinWidth}*${t.imageMinHeight}且像素不高于${t.imageMaxWidth}*${t.imageMaxHeight}的图片`, remove: !0 });
214
214
  const m = {};
215
215
  ["image/heif", "image/heic", "image/webp"].includes(F) && (m.convertTypes = [r.type], m.convertSize = 0);
216
216
  const z = 5 * 1024 * 1024;
217
- if (r.size > z && (m.convertTypes = [r.type], m.convertSize = z, m.maxWidth = p.width * (z / r.size)), Object.keys(m).length > 0) {
218
- const u = await H(A(U), m);
219
- if (u.success)
220
- r = u.file;
217
+ if (r.size > z && (m.convertTypes = [r.type], m.convertSize = z, m.maxWidth = u.width * (z / r.size)), Object.keys(m).length > 0) {
218
+ const c = await A(W(H), m);
219
+ if (c.success)
220
+ r = c.file;
221
221
  else
222
- return i == null || i.close(), o({ message: u.error, remove: !0 });
222
+ return i == null || i.close(), o({ message: (V = c == null ? void 0 : c.error) == null ? void 0 : V.message, remove: !0 });
223
223
  }
224
- if (!c.value)
224
+ if (!p.value)
225
225
  return i == null || i.close(), o({ message: "缺少图片上传配置", remove: !0 });
226
- const S = await ((B = c.value) == null ? void 0 : B.call(c, r, C, { extParameters: t.extParameters }));
226
+ const S = await ((B = p.value) == null ? void 0 : B.call(p, r, C, { extParameters: t.extParameters }));
227
227
  if (!S.success)
228
228
  return i == null || i.close(), o({ message: S.errorMessage, remove: !0 });
229
229
  i == null || i.close(), e(S.url);
@@ -252,7 +252,7 @@ const ze = /* @__PURE__ */ N({
252
252
  g.value = !0, b("input", a.getContent()), b("update:modelValue", a.getContent());
253
253
  }), (e = t.initComplete) == null || e.call(t, { editorIns: a }), l.value = a);
254
254
  });
255
- }), j(() => {
255
+ }), L(() => {
256
256
  var n;
257
257
  (n = l.value) == null || n.destroy();
258
258
  }), O(() => [t.disabled, l.value], () => {
@@ -269,7 +269,7 @@ const ze = /* @__PURE__ */ N({
269
269
  f.value = !0, (n = l.value) == null || n.setContent(t.value ? t.value : t.modelValue ? t.modelValue : "");
270
270
  },
271
271
  { immediate: !0 }
272
- ), { __sfc: !0, insRef: P, editorRef: l, preventSettingContent: g, preventUpdatingModelValue: f, props: t, emits: b, processPastedImage: W, dataURLtoBlob: A, getImagePixel: M, compressorImage: H, paste_preprocess: h, paste_postprocess: v, imageUploadHandle: c };
272
+ ), { __sfc: !0, insRef: P, editorRef: l, preventSettingContent: g, preventUpdatingModelValue: f, props: t, emits: b, processPastedImage: T, dataURLtoBlob: W, getImagePixel: M, compressorImage: A, paste_preprocess: h, paste_postprocess: v, imageUploadHandle: p };
273
273
  }
274
274
  });
275
275
  export {
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.9-alpha.01",
5
+ "version": "0.0.11",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",