@keyblade/tinymce-editor-vue2 0.0.12-alpha.2 → 0.0.12-alpha.3

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 +73 -73
  2. package/package.json +1 -1
package/es/editor.vue2.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { defineComponent as ne, ref as u, computed as y, onMounted as re, onUnmounted as se, watch as O } from "vue";
2
- import { oneTravelImageCheck as E, oneTravelImageCompressor as I, getImagePixel as me } from "./util.js";
2
+ import { oneTravelImageCheck as B, oneTravelImageCompressor as E, getImagePixel as me } from "./util.js";
3
3
  import de from "imgpond";
4
4
  import { conclude as M } from "vue-global-config";
5
- import B from "tinymce";
5
+ import I from "tinymce";
6
6
  import ue from "./langs/zh_CN.js";
7
7
  import "tinymce/skins/ui/oxide/skin";
8
8
  import "tinymce/models/dom";
@@ -66,7 +66,7 @@ const Qe = /* @__PURE__ */ ne({
66
66
  emits: ["input", "update:modelValue"],
67
67
  setup(F, { emit: S }) {
68
68
  const a = F;
69
- B.addI18n("zh_CN", ue);
69
+ I.addI18n("zh_CN", ue);
70
70
  const z = u(), m = u(), _ = u(!1), w = u(!1), v = u({
71
71
  dialogVisible: !1,
72
72
  formData: {
@@ -79,9 +79,9 @@ const Qe = /* @__PURE__ */ ne({
79
79
  }, q = () => {
80
80
  var t;
81
81
  (t = P.value) == null || t.validate((n) => {
82
- n && (v.value.formData.images.forEach((i) => {
82
+ n && (v.value.formData.images.forEach((o) => {
83
83
  var e;
84
- (e = m.value) == null || e.insertContent(`<img src=${i} alt="" />`);
84
+ (e = m.value) == null || e.insertContent(`<img src=${o} alt="" />`);
85
85
  }), v.value.dialogVisible = !1, v.value.formData.images = []);
86
86
  });
87
87
  }, r = u({
@@ -97,8 +97,8 @@ const Qe = /* @__PURE__ */ ne({
97
97
  }), k = u(), j = () => {
98
98
  var t;
99
99
  (t = k.value) == null || t.validate((n) => {
100
- var i, e;
101
- n && ((e = m.value) == null || e.insertContent(`<audio controls data-name="${r.value.formData.name}" data-poster="${r.value.formData.cover[0]}" src="${(i = r.value.formData.file[0]) == null ? void 0 : i.url}"></audio>`), r.value.dialogVisible = !1, r.value.formData = {
100
+ var o, e;
101
+ n && ((e = m.value) == null || e.insertContent(`<audio controls data-name="${r.value.formData.name}" data-poster="${r.value.formData.cover[0]}" src="${(o = r.value.formData.file[0]) == null ? void 0 : o.url}"></audio>`), r.value.dialogVisible = !1, r.value.formData = {
102
102
  name: "",
103
103
  cover: [],
104
104
  file: []
@@ -119,8 +119,8 @@ const Qe = /* @__PURE__ */ ne({
119
119
  }), W = u(), J = () => {
120
120
  var t;
121
121
  (t = W.value) == null || t.validate((n) => {
122
- var i, e;
123
- n && ((e = m.value) == null || e.insertContent(`<video controls controlslist="nodownload" src="${(i = d.value.formData.file[0]) == null ? void 0 : i.url}"></video>`), d.value.dialogVisible = !1, d.value.formData = {
122
+ var o, e;
123
+ n && ((e = m.value) == null || e.insertContent(`<video controls controlslist="nodownload" src="${(o = d.value.formData.file[0]) == null ? void 0 : o.url}"></video>`), d.value.dialogVisible = !1, d.value.formData = {
124
124
  file: []
125
125
  });
126
126
  });
@@ -128,9 +128,9 @@ const Qe = /* @__PURE__ */ ne({
128
128
  d.value.dialogVisible = !1, d.value.formData = {
129
129
  file: []
130
130
  };
131
- }, Q = (t, n) => new Promise(async (i, e) => {
131
+ }, Q = (t, n) => new Promise(async (o, e) => {
132
132
  var h;
133
- const o = await E(t, {
133
+ const i = await B(t, {
134
134
  imageMaxSize: a.imageMaxSize,
135
135
  imageAllowedMineType: a.imageAllowedMineType,
136
136
  imageMinWidth: a.imageMinWidth,
@@ -138,14 +138,14 @@ const Qe = /* @__PURE__ */ ne({
138
138
  imageMaxWidth: a.imageMaxWidth,
139
139
  imageMaxHeight: a.imageMaxHeight
140
140
  });
141
- if (!o.success) {
141
+ if (!i.success) {
142
142
  e(), setTimeout(() => {
143
143
  var p, g, b;
144
- (p = o.error) != null && p.size ? n.onError(`请上传大小不超过${a.imageMaxSize}M的图片`) : (g = o.error) != null && g.format ? n.onError(`请上传格式为${a.imageAllowedType.map((V) => V.toUpperCase()).join("、")}的图片`) : (b = o.error) != null && b.pixel && n.onError(`请上传像素不低于${a.imageMinWidth}*${a.imageMinHeight}且像素不高于${a.imageMaxWidth}*${a.imageMaxHeight}的图片`);
144
+ (p = i.error) != null && p.size ? n.onError(`请上传大小不超过${a.imageMaxSize}M的图片`) : (g = i.error) != null && g.format ? n.onError(`请上传格式为${a.imageAllowedType.map((V) => V.toUpperCase()).join("、")}的图片`) : (b = i.error) != null && b.pixel && n.onError(`请上传像素不低于${a.imageMinWidth}*${a.imageMinHeight}且像素不高于${a.imageMaxWidth}*${a.imageMaxHeight}的图片`);
145
145
  });
146
146
  return;
147
147
  }
148
- const l = await I(t);
148
+ const l = await E(t);
149
149
  if (!l.success) {
150
150
  e(), setTimeout(() => {
151
151
  n.onError(l.errorMessage);
@@ -159,22 +159,22 @@ const Qe = /* @__PURE__ */ ne({
159
159
  });
160
160
  return;
161
161
  }
162
- i(s.url);
162
+ o(s.url);
163
163
  });
164
164
  async function $(t) {
165
- var i, e;
165
+ var o, e;
166
166
  const n = t.getElementsByTagName("img");
167
- for (let o of n) {
168
- const l = o.src;
167
+ for (let i of n) {
168
+ const l = i.src;
169
169
  if (l.startsWith("http://") || l.startsWith("https://")) {
170
170
  const s = await me(l);
171
171
  if (s.width < a.imageMinWidth && s.height < a.imageMinHeight || s.width > a.imageMaxWidth && s.height > a.imageMaxHeight) {
172
- (i = o == null ? void 0 : o.remove) == null || i.call(o);
172
+ (o = i == null ? void 0 : i.remove) == null || o.call(i);
173
173
  return;
174
174
  }
175
175
  const h = l.split("."), p = h[h.length - 1].toLowerCase();
176
176
  if (!a.imageAllowedType.includes(p)) {
177
- (e = o == null ? void 0 : o.remove) == null || e.call(o);
177
+ (e = i == null ? void 0 : i.remove) == null || e.call(i);
178
178
  return;
179
179
  }
180
180
  }
@@ -273,22 +273,22 @@ const Qe = /* @__PURE__ */ ne({
273
273
  paste_webkit_styles: "all",
274
274
  paste_data_images: !0,
275
275
  // 粘贴前处理
276
- paste_preprocess(i, e) {
277
- var o;
278
- 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>"), (o = C.value) == null || o.call(C, i, e);
276
+ paste_preprocess(o, e) {
277
+ var i;
278
+ 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 = C.value) == null || i.call(C, o, e);
279
279
  },
280
280
  // 粘贴后处理(处理异步操作)
281
- paste_postprocess(i, e) {
281
+ paste_postprocess(o, e) {
282
282
  var l;
283
- const o = e.node;
284
- $(o), (l = T.value) == null || l.call(T, i, e);
283
+ const i = e.node;
284
+ $(i), (l = T.value) == null || l.call(T, o, e);
285
285
  },
286
- images_upload_handler(i) {
287
- return new Promise(async (e, o) => {
286
+ images_upload_handler(o) {
287
+ return new Promise(async (e, i) => {
288
288
  var V, D, H, R;
289
289
  const l = pe.service({ text: "上传中" });
290
- let s = i.blob();
291
- const h = i.filename(), p = await E(s, {
290
+ let s = o.blob();
291
+ const h = o.filename(), p = await B(s, {
292
292
  imageMaxSize: a.imageMaxSize,
293
293
  imageAllowedMineType: a.imageAllowedMineType,
294
294
  imageMinWidth: a.imageMinWidth,
@@ -298,45 +298,45 @@ const Qe = /* @__PURE__ */ ne({
298
298
  });
299
299
  if (!p.success) {
300
300
  if (l == null || l.close(), (V = p.error) != null && V.size)
301
- return o({ message: `请上传大小不超过${a.imageMaxSize}M的图片`, remove: !0 });
301
+ return i({ message: `请上传大小不超过${a.imageMaxSize}M的图片`, remove: !0 });
302
302
  if ((D = p.error) != null && D.format)
303
- return o({ message: `请上传格式为${a.imageAllowedType.map((le) => le.toUpperCase()).join("、")}的图片`, remove: !0 });
303
+ return i({ message: `请上传格式为${a.imageAllowedType.map((le) => le.toUpperCase()).join("、")}的图片`, remove: !0 });
304
304
  if ((H = p.error) != null && H.pixel)
305
- return o({ message: `请上传像素不低于${a.imageMinWidth}*${a.imageMinHeight}且像素不高于${a.imageMaxWidth}*${a.imageMaxHeight}的图片`, remove: !0 });
305
+ return i({ message: `请上传像素不低于${a.imageMinWidth}*${a.imageMinHeight}且像素不高于${a.imageMaxWidth}*${a.imageMaxHeight}的图片`, remove: !0 });
306
306
  }
307
- const g = await I(s);
307
+ const g = await E(s);
308
308
  if (!g.success)
309
- return l == null || l.close(), o({ message: g == null ? void 0 : g.errorMessage, remove: !0 });
309
+ return l == null || l.close(), i({ message: g == null ? void 0 : g.errorMessage, remove: !0 });
310
310
  if (!c.value)
311
- return l == null || l.close(), o({ message: "缺少图片上传配置", remove: !0 });
311
+ return l == null || l.close(), i({ message: "缺少图片上传配置", remove: !0 });
312
312
  const b = await ((R = c.value) == null ? void 0 : R.call(c, g.file, h, { extParameters: a.extParameters }));
313
313
  if (!b.success)
314
- return l == null || l.close(), o({ message: b.errorMessage, remove: !0 });
314
+ return l == null || l.close(), i({ message: b.errorMessage, remove: !0 });
315
315
  l == null || l.close(), e(b.url);
316
316
  });
317
317
  },
318
- setup(i) {
319
- i.ui.registry.addMenuItem("localImage", {
318
+ setup(o) {
319
+ o.ui.registry.addMenuItem("localImage", {
320
320
  text: "图片",
321
321
  icon: "image",
322
322
  onAction: () => {
323
323
  v.value.dialogVisible = !0, setTimeout(() => {
324
- var o;
325
- const e = (o = document == null ? void 0 : document.querySelector) == null ? void 0 : o.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
324
+ var i;
325
+ const e = (i = document == null ? void 0 : document.querySelector) == null ? void 0 : i.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
326
326
  e && (e.innerHTML = a.imageUploadTip || "上传");
327
327
  });
328
328
  }
329
- }), i.ui.registry.addMenuItem("localAudio", {
329
+ }), o.ui.registry.addMenuItem("localAudio", {
330
330
  text: "音频",
331
331
  icon: "arrow-right",
332
332
  onAction: () => {
333
333
  r.value.dialogVisible = !0, setTimeout(() => {
334
- var o;
335
- const e = (o = document == null ? void 0 : document.querySelector) == null ? void 0 : o.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
334
+ var i;
335
+ const e = (i = document == null ? void 0 : document.querySelector) == null ? void 0 : i.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
336
336
  e && (e.innerHTML = a.imageUploadTip || "上传");
337
337
  });
338
338
  }
339
- }), i.ui.registry.addMenuItem("localVideo", {
339
+ }), o.ui.registry.addMenuItem("localVideo", {
340
340
  text: "视频",
341
341
  icon: "embed",
342
342
  onAction: () => {
@@ -351,30 +351,30 @@ const Qe = /* @__PURE__ */ ne({
351
351
  t
352
352
  ],
353
353
  {
354
- mergeFunction: (i, e) => (...o) => {
355
- i(...o), e(...o);
354
+ mergeFunction: (o, e) => (...i) => {
355
+ o(...i), e(...i);
356
356
  },
357
357
  type: Object
358
358
  }
359
359
  );
360
- B.init(n).then(([i]) => {
360
+ I.init(n).then(([o]) => {
361
361
  var e;
362
- i && (i.customProps = { ...a }, i.on("change input Redo Undo SetContent", () => {
362
+ o && (o.customProps = { ...a }, o.on("change input Redo Undo SetContent", () => {
363
363
  if (w.value) {
364
364
  w.value = !1;
365
365
  return;
366
366
  }
367
- _.value = !0, S("input", i.getContent()), S("update:modelValue", i.getContent());
368
- }), (e = a.initComplete) == null || e.call(a, { editorIns: i }), m.value = i);
367
+ _.value = !0, S("input", o.getContent()), S("update:modelValue", o.getContent());
368
+ }), (e = a.initComplete) == null || e.call(a, { editorIns: o }), m.value = o);
369
369
  });
370
370
  });
371
- const Y = (t, n, i) => {
372
- var o, l;
373
- const e = (l = (o = U == null ? void 0 : U.value) == null ? void 0 : o.handlerResponse) == null ? void 0 : l.call(o, t);
374
- e != null && e.url ? i[i.length - 1].url = e.url : e != null && e.errorMessage && (f.error(e.errorMessage), i.splice(i.length - 1, 1)), r.value.formData.file = i;
375
- }, Z = (t, n) => new Promise((i, e) => {
376
- const o = t.name.split(".").filter(Boolean).pop() ?? "";
377
- if (!a.audioAllowedType.includes(o.toUpperCase())) {
371
+ const Y = (t, n, o) => {
372
+ var i, l;
373
+ const e = (l = (i = U == null ? void 0 : U.value) == null ? void 0 : i.handlerResponse) == null ? void 0 : l.call(i, t);
374
+ e != null && e.url ? o[o.length - 1].url = e.url : e != null && e.errorMessage && (f.error(e.errorMessage), o.splice(o.length - 1, 1)), r.value.formData.file = o;
375
+ }, Z = (t, n) => new Promise((o, e) => {
376
+ const i = t.name.split(".").filter(Boolean).pop() ? t.name.split(".").filter(Boolean).pop() : "";
377
+ if (!a.audioAllowedType.includes(i.toUpperCase())) {
378
378
  f.info(`请上传格式为${a.audioAllowedType.join("、")}的音频`), e();
379
379
  return;
380
380
  }
@@ -382,18 +382,18 @@ const Qe = /* @__PURE__ */ ne({
382
382
  f.info(`请上传${a.audioMaxSize}M内的音频`), e();
383
383
  return;
384
384
  }
385
- i(!0);
385
+ o(!0);
386
386
  }), L = (t, n) => {
387
387
  r.value.formData.file = n;
388
- }, ee = (t, n, i) => {
389
- f.error("上传发生错误,请重试!"), r.value.formData.file = i;
390
- }, ae = (t, n, i) => {
391
- var o, l;
392
- const e = (l = (o = A == null ? void 0 : A.value) == null ? void 0 : o.handlerResponse) == null ? void 0 : l.call(o, t);
393
- e != null && e.url ? i[i.length - 1].url = e.url : e != null && e.errorMessage && (f.error(e.errorMessage), i.splice(i.length - 1, 1)), d.value.formData.file = i;
394
- }, ie = (t, n) => new Promise((i, e) => {
395
- const o = t.name.split(".").filter(Boolean).pop() ?? "";
396
- if (!a.videoAllowedType.includes(o.toUpperCase())) {
388
+ }, ee = (t, n, o) => {
389
+ f.error("上传发生错误,请重试!"), r.value.formData.file = o;
390
+ }, ae = (t, n, o) => {
391
+ var i, l;
392
+ const e = (l = (i = A == null ? void 0 : A.value) == null ? void 0 : i.handlerResponse) == null ? void 0 : l.call(i, t);
393
+ e != null && e.url ? o[o.length - 1].url = e.url : e != null && e.errorMessage && (f.error(e.errorMessage), o.splice(o.length - 1, 1)), d.value.formData.file = o;
394
+ }, oe = (t, n) => new Promise((o, e) => {
395
+ const i = t.name.split(".").filter(Boolean).pop() ? t.name.split(".").filter(Boolean).pop() : "";
396
+ if (!a.videoAllowedType.includes(i.toUpperCase())) {
397
397
  f.info(`请上传格式为${a.videoAllowedType.join("、")}的视频`), e();
398
398
  return;
399
399
  }
@@ -401,11 +401,11 @@ const Qe = /* @__PURE__ */ ne({
401
401
  f.info(`请上传${a.videoMaxSize}M内的视频`), e();
402
402
  return;
403
403
  }
404
- i(!0);
405
- }), oe = (t, n) => {
404
+ o(!0);
405
+ }), ie = (t, n) => {
406
406
  d.value.formData.file = n;
407
- }, te = (t, n, i) => {
408
- f.error("上传发生错误,请重试!"), d.value.formData.file = i;
407
+ }, te = (t, n, o) => {
408
+ f.error("上传发生错误,请重试!"), d.value.formData.file = o;
409
409
  };
410
410
  return se(() => {
411
411
  var t;
@@ -424,7 +424,7 @@ const Qe = /* @__PURE__ */ ne({
424
424
  w.value = !0, (t = m.value) == null || t.setContent(a.value ? a.value : a.modelValue ? a.modelValue : "");
425
425
  },
426
426
  { immediate: !0 }
427
- ), { __sfc: !0, insRef: z, editorRef: m, preventSettingContent: _, preventUpdatingModelValue: w, uploadImage: v, uploadImageFormRef: P, onUploadImageClose: N, onUploadImageConfirm: q, uploadAudio: r, uploadAudioFormRef: k, onUploadAudioConfirm: j, onUploadAudioClose: G, uploadVideo: d, uploadVideoFormRef: W, onUploadVideoConfirm: J, onUploadVideoClose: K, onImageUploadUpload: Q, props: a, emits: S, processPastedImage: $, mergeVideoUploadOptions: A, mergeAudioUploadOptions: U, mergeImgPondOptions: X, paste_preprocess: C, paste_postprocess: T, imageUploadHandle: c, onUploadAudioSuccess: Y, onUploadAudioBeforeUpload: Z, onUploadAudioRemove: L, onUploadAudioError: ee, onUploadVideoSuccess: ae, onUploadVideoBeforeUpload: ie, onUploadVideoRemove: oe, onUploadVideoError: te, ImgPond: de };
427
+ ), { __sfc: !0, insRef: z, editorRef: m, preventSettingContent: _, preventUpdatingModelValue: w, uploadImage: v, uploadImageFormRef: P, onUploadImageClose: N, onUploadImageConfirm: q, uploadAudio: r, uploadAudioFormRef: k, onUploadAudioConfirm: j, onUploadAudioClose: G, uploadVideo: d, uploadVideoFormRef: W, onUploadVideoConfirm: J, onUploadVideoClose: K, onImageUploadUpload: Q, props: a, emits: S, processPastedImage: $, mergeVideoUploadOptions: A, mergeAudioUploadOptions: U, mergeImgPondOptions: X, paste_preprocess: C, paste_postprocess: T, imageUploadHandle: c, onUploadAudioSuccess: Y, onUploadAudioBeforeUpload: Z, onUploadAudioRemove: L, onUploadAudioError: ee, onUploadVideoSuccess: ae, onUploadVideoBeforeUpload: oe, onUploadVideoRemove: ie, onUploadVideoError: te, ImgPond: de };
428
428
  }
429
429
  });
430
430
  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.12-alpha.02",
5
+ "version": "0.0.12-alpha.03",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",