@keyblade/tinymce-editor-vue2 0.0.4 → 0.0.5-alpha.2

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 +35 -35
  2. package/package.json +2 -2
package/es/editor.vue2.js CHANGED
@@ -52,23 +52,23 @@ const ke = /* @__PURE__ */ F({
52
52
  },
53
53
  emits: ["input", "update:modelValue"],
54
54
  setup(O, { expose: R, emit: b }) {
55
- const a = O;
55
+ const i = O;
56
56
  G();
57
57
  const M = y(), m = y(), g = y(!1), f = y(!1);
58
58
  async function A(n) {
59
59
  var o, e;
60
60
  const s = n.getElementsByTagName("img");
61
- for (let i of s) {
62
- const t = i.src;
61
+ for (let a of s) {
62
+ const t = a.src;
63
63
  if (t.startsWith("http://") || t.startsWith("https://")) {
64
64
  const r = await C(t);
65
- if (r.width < a.imageMinWidth && r.height < a.imageMinHeight || r.width > a.imageMaxWidth && r.height > a.imageMaxHeight) {
66
- (o = i == null ? void 0 : i.remove) == null || o.call(i);
65
+ if (r.width < i.imageMinWidth && r.height < i.imageMinHeight || r.width > i.imageMaxWidth && r.height > i.imageMaxHeight) {
66
+ (o = a == null ? void 0 : a.remove) == null || o.call(a);
67
67
  return;
68
68
  }
69
69
  const w = t.split("."), S = w[w.length - 1].toLowerCase();
70
- if (!a.imageAllowedType.includes(S)) {
71
- (e = i == null ? void 0 : i.remove) == null || e.call(i);
70
+ if (!i.imageAllowedType.includes(S)) {
71
+ (e = a == null ? void 0 : a.remove) == null || e.call(a);
72
72
  return;
73
73
  }
74
74
  }
@@ -76,10 +76,10 @@ const ke = /* @__PURE__ */ F({
76
76
  }
77
77
  const H = (n) => {
78
78
  const s = n.split(","), o = s[0].match(/:(.*?);/)[1], e = atob(s[1]);
79
- let i = e.length;
80
- const t = new Uint8Array(i);
81
- for (; i--; )
82
- t[i] = e.charCodeAt(i);
79
+ let a = e.length;
80
+ const t = new Uint8Array(a);
81
+ for (; a--; )
82
+ t[a] = e.charCodeAt(a);
83
83
  return new Blob([t], { type: o });
84
84
  };
85
85
  function C(n) {
@@ -104,15 +104,15 @@ const ke = /* @__PURE__ */ F({
104
104
  });
105
105
  }
106
106
  const h = W(
107
- () => _([a.paste_preprocess, d.paste_preprocess], {
107
+ () => _([i.paste_preprocess, d.paste_preprocess], {
108
108
  type: Function
109
109
  })
110
110
  ), v = W(
111
- () => _([a.paste_postprocess, d.paste_postprocess], {
111
+ () => _([i.paste_postprocess, d.paste_postprocess], {
112
112
  type: Function
113
113
  })
114
114
  ), c = W(
115
- () => _([a.imageUploadHandle, d.imageUploadHandle], {
115
+ () => _([i.imageUploadHandle, d.imageUploadHandle], {
116
116
  type: Function
117
117
  })
118
118
  );
@@ -188,28 +188,28 @@ const ke = /* @__PURE__ */ F({
188
188
  paste_data_images: !0,
189
189
  // 粘贴前处理
190
190
  paste_preprocess(o, e) {
191
- var i;
192
- e.content = e.content.replace(/<video[^>]*(?:\/>|>[\s\S]*?<\/video>)/g, ""), e.content = e.content.replace(/<audio[^>]*(?:\/>|>[\s\S]*?<\/audio>)/g, ""), e.content = e.content.replace(/<nav/g, "<div").replace(/<\/nav>/g, "</div>"), e.content = e.content.replace(/<header/g, "<div").replace(/<\/header>/g, "</div>"), e.content = e.content.replace(/<footer/g, "<div").replace(/<\/footer>/g, "</div>"), e.content = e.content.replace(/<aside/g, "<div").replace(/<\/aside>/g, "</div>"), e.content = e.content.replace(/<section/g, "<div").replace(/<\/section>/g, "</div>"), e.content = e.content.replace(/<main/g, "<div").replace(/<\/main>/g, "</div>"), e.content = e.content.replace(/<article/g, "<div").replace(/<\/article>/g, "</div>"), e.content = e.content.replace(/<details/g, "<div").replace(/<\/details>/g, "</div>"), (i = h.value) == null || i.call(h, o, e);
191
+ var a;
192
+ e.content = e.content.replace(/<video[^>]*(?:\/>|>[\s\S]*?<\/video>)/g, ""), e.content = e.content.replace(/<audio[^>]*(?:\/>|>[\s\S]*?<\/audio>)/g, ""), e.content = e.content.replace(/<nav/g, "<div").replace(/<\/nav>/g, "</div>"), e.content = e.content.replace(/<header/g, "<div").replace(/<\/header>/g, "</div>"), e.content = e.content.replace(/<footer/g, "<div").replace(/<\/footer>/g, "</div>"), e.content = e.content.replace(/<aside/g, "<div").replace(/<\/aside>/g, "</div>"), e.content = e.content.replace(/<section/g, "<div").replace(/<\/section>/g, "</div>"), e.content = e.content.replace(/<main/g, "<div").replace(/<\/main>/g, "</div>"), e.content = e.content.replace(/<article/g, "<div").replace(/<\/article>/g, "</div>"), e.content = e.content.replace(/<details/g, "<div").replace(/<\/details>/g, "</div>"), (a = h.value) == null || a.call(h, o, e);
193
193
  },
194
194
  // 粘贴后处理(处理异步操作)
195
195
  paste_postprocess(o, e) {
196
196
  var t;
197
- const i = e.node;
198
- A(i), (t = v.value) == null || t.call(v, o, e);
197
+ const a = e.node;
198
+ A(a), (t = v.value) == null || t.call(v, o, e);
199
199
  },
200
200
  images_upload_handler(o) {
201
- return new Promise(async (e, i) => {
201
+ return new Promise(async (e, a) => {
202
202
  var x, V, B;
203
203
  const t = (V = (x = d.message) == null ? void 0 : x.loading) == null ? void 0 : V.call(x);
204
204
  let r = o.blob();
205
205
  const w = o.base64(), S = o.filename(), P = r.name.split("."), $ = P[P.length - 1].toLowerCase();
206
- if (r.size > a.imageMaxSize * 1024 * 1024)
207
- return t == null || t.close(), i({ message: `请上传大小不超过${a.imageMaxSize}M的图片`, remove: !0 });
208
- if (!a.imageAllowedMineType.includes(r.type))
209
- return t == null || t.close(), i({ message: `请上传格式为${a.imageAllowedType.map((u) => u.toUpperCase()).join("、")}的图片`, remove: !0 });
206
+ if (r.size > i.imageMaxSize * 1024 * 1024)
207
+ return t == null || t.close(), a({ message: `请上传大小不超过${i.imageMaxSize}M的图片`, remove: !0 });
208
+ if (!i.imageAllowedMineType.includes(r.type))
209
+ return t == null || t.close(), a({ message: `请上传格式为${i.imageAllowedType.map((u) => u.toUpperCase()).join("、")}的图片`, remove: !0 });
210
210
  const U = "data:" + r.type + ";base64," + w, p = await C(U);
211
- if (p.width < a.imageMinWidth && p.height < a.imageMinHeight || p.width > a.imageMaxWidth && p.height > a.imageMaxHeight)
212
- return t == null || t.close(), i({ message: `请上传像素不低于${a.imageMinWidth}*${a.imageMinHeight}且像素不高于${a.imageMaxWidth}*${a.imageMaxHeight}的图片`, remove: !0 });
211
+ if (p.width < i.imageMinWidth && p.height < i.imageMinHeight || p.width > i.imageMaxWidth && p.height > i.imageMaxHeight)
212
+ return t == null || t.close(), a({ message: `请上传像素不低于${i.imageMinWidth}*${i.imageMinHeight}且像素不高于${i.imageMaxWidth}*${i.imageMaxHeight}的图片`, remove: !0 });
213
213
  const l = {};
214
214
  ["image/heif", "image/heic", "image/webp"].includes($) && (l.convertTypes = [r.type], l.convertSize = 0);
215
215
  const k = 5 * 1024 * 1024;
@@ -218,25 +218,25 @@ const ke = /* @__PURE__ */ F({
218
218
  if (u.success)
219
219
  r = u.file;
220
220
  else
221
- return t == null || t.close(), i({ message: u.error, remove: !0 });
221
+ return t == null || t.close(), a({ message: u.error, remove: !0 });
222
222
  }
223
223
  if (!c.value)
224
- return t == null || t.close(), i({ message: "缺少图片上传配置", remove: !0 });
224
+ return t == null || t.close(), a({ message: "缺少图片上传配置", remove: !0 });
225
225
  const z = await ((B = c.value) == null ? void 0 : B.call(c, r, S));
226
226
  if (!z.success)
227
- return t == null || t.close(), i({ message: z.errorMessage, remove: !0 });
227
+ return t == null || t.close(), a({ message: z.errorMessage, remove: !0 });
228
228
  t == null || t.close(), e(z.url);
229
229
  });
230
230
  }
231
231
  }, s = _(
232
232
  [
233
- a.options,
233
+ i.options,
234
234
  d.tinymceOptions,
235
235
  n
236
236
  ],
237
237
  {
238
- mergeFunction: (o, e) => (...i) => {
239
- o(...i), e(...i);
238
+ mergeFunction: (o, e) => (...a) => {
239
+ o(...a), e(...a);
240
240
  },
241
241
  type: Object
242
242
  }
@@ -249,26 +249,26 @@ const ke = /* @__PURE__ */ F({
249
249
  return;
250
250
  }
251
251
  g.value = !0, b("input", o.getContent()), b("update:modelValue", o.getContent());
252
- }), m.value = o, (e = a.initComplete) == null || e.call(a);
252
+ }), m.value = o, (e = i.initComplete) == null || e.call(i);
253
253
  });
254
254
  }), j(() => {
255
255
  var n;
256
256
  (n = m.value) == null || n.destroy();
257
257
  }), L(
258
- () => [a.value, a.modelValue, m.value],
258
+ () => [i.value, i.modelValue, m.value],
259
259
  () => {
260
260
  var n;
261
261
  if (g.value) {
262
262
  g.value = !1;
263
263
  return;
264
264
  }
265
- f.value = !0, (n = m.value) == null || n.setContent(a.value ?? a.modelValue ?? "");
265
+ f.value = !0, (n = m.value) == null || n.setContent(i.value ? i.value : i.modelValue ? i.modelValue : "");
266
266
  },
267
267
  { immediate: !0 }
268
268
  ), R({
269
269
  insRef: M,
270
270
  editorRef: m
271
- }), { __sfc: !0, insRef: M, editorRef: m, preventSettingContent: g, preventUpdatingModelValue: f, props: a, emits: b, processPastedImage: A, dataURLtoBlob: H, getImagePixel: C, compressorImage: T, paste_preprocess: h, paste_postprocess: v, imageUploadHandle: c };
271
+ }), { __sfc: !0, insRef: M, editorRef: m, preventSettingContent: g, preventUpdatingModelValue: f, props: i, emits: b, processPastedImage: A, dataURLtoBlob: H, getImagePixel: C, compressorImage: T, paste_preprocess: h, paste_postprocess: v, imageUploadHandle: c };
272
272
  }
273
273
  });
274
274
  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.4",
5
+ "version": "0.0.5-alpha.02",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "compressorjs": "^1.2.1",
24
- "vue-global-config": "^0.6.1",
24
+ "vue-global-config": "^0.2.6",
25
25
  "tinymce": "^7.1.0"
26
26
  },
27
27
  "devDependencies": {},