@keyblade/tinymce-editor-vue2 0.0.12-alpha.48 → 0.0.12-alpha.50

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 +221 -325
  2. package/package.json +2 -2
package/es/editor.vue2.js CHANGED
@@ -1,11 +1,11 @@
1
- import { defineComponent as De, ref as y, computed as T, watch as k, onMounted as Ae, onUnmounted as Te } from "vue";
2
- import { oneTravelImgPondBeforeAddFile as K, oneTravelImageCompressor as Q, oneTravelImageCheckAndTransform as Ce } from "@keyblade/one-travel";
3
- import { blobToFile as Y, generateUUID as Pe, getImagePixel as Z, getFileExtension as ee } from "./util.js";
1
+ import { defineComponent as be, ref as b, computed as C, watch as z, onMounted as ye, onUnmounted as _e } from "vue";
2
+ import { oneTravelImgPondBeforeAddFile as J, oneTravelImageCompressor as K, oneTravelImageCheckAndTransform as De } from "@keyblade/one-travel";
3
+ import { blobToFile as Q, getImagePixel as Ae, getFileExtension as Ce } from "./util.js";
4
4
  import "./style.less.js";
5
- import Me from "imgpond";
6
- import { conclude as C } from "vue-global-config";
7
- import ae from "tinymce";
8
- import Se from "./langs/zh_CN.js";
5
+ import Te from "imgpond";
6
+ import { conclude as T } from "vue-global-config";
7
+ import Y from "tinymce";
8
+ import Pe from "./langs/zh_CN.js";
9
9
  import "tinymce/skins/ui/oxide/skin";
10
10
  import "tinymce/models/dom";
11
11
  import "tinymce/themes/silver";
@@ -35,8 +35,8 @@ import "tinymce/plugins/visualblocks";
35
35
  import "tinymce/plugins/visualchars";
36
36
  import "tinymce/plugins/wordcount";
37
37
  import { globalProps as P } from "./index.js";
38
- import { Message as f } from "element-ui";
39
- const va = /* @__PURE__ */ De({
38
+ import { Message as p } from "element-ui";
39
+ const pa = /* @__PURE__ */ be({
40
40
  __name: "editor",
41
41
  props: {
42
42
  value: { default: "" },
@@ -50,10 +50,10 @@ const va = /* @__PURE__ */ De({
50
50
  initComplete: null
51
51
  },
52
52
  emits: ["input"],
53
- setup(te, { emit: z }) {
54
- const m = te;
55
- ae.addI18n("zh_CN", Se);
56
- const B = {
53
+ setup(Z, { emit: M }) {
54
+ const s = Z;
55
+ Y.addI18n("zh_CN", Pe);
56
+ const j = {
57
57
  maxCount: 10,
58
58
  tipText: "上传",
59
59
  maxSize: 30,
@@ -62,7 +62,7 @@ const va = /* @__PURE__ */ De({
62
62
  minHeight: 50,
63
63
  maxWidth: 6e3,
64
64
  maxHeight: 6e3
65
- }, j = {
65
+ }, B = {
66
66
  enable: !0,
67
67
  maxSize: 300,
68
68
  allowedType: ["mp4", "3gp"],
@@ -72,65 +72,65 @@ const va = /* @__PURE__ */ De({
72
72
  maxSize: 200,
73
73
  allowedType: ["mp3", "m4a", "wav", "aac"],
74
74
  accept: "audio/mp3,audio/wav,audio/aac,audio/x-m4a"
75
- }, E = y(), h = y(), M = y(!1), S = y(!1), v = y({
75
+ }, E = b(), h = b(), S = b(!1), k = b(!1), f = b({
76
76
  show: !1,
77
77
  text: "图片上传中,请稍等"
78
- }), r = T(() => C([m.imageUploadOptions, P.imageUploadOptions, B]) || {}), c = T(() => C([m.videoUploadOptions, P.videoUploadOptions, j]) || {}), w = T(() => C([m.audioUploadOptions, P.audioUploadOptions, q]) || {}), H = T(() => C([m.imgPondOptions, P.imgPondOptions]) || {}), oe = T(() => {
78
+ }), r = C(() => T([s.imageUploadOptions, P.imageUploadOptions, j]) || {}), u = C(() => T([s.videoUploadOptions, P.videoUploadOptions, B]) || {}), w = C(() => T([s.audioUploadOptions, P.audioUploadOptions, q]) || {}), V = C(() => T([s.imgPondOptions, P.imgPondOptions]) || {}), ee = C(() => {
79
79
  var e, a;
80
- return ((a = (e = r == null ? void 0 : r.value) == null ? void 0 : e.allowedType) == null ? void 0 : a.map((t) => `.${t}`).join(",")) || "";
81
- }), U = y();
82
- k(() => U.value, () => {
83
- U.value && K(U.value, {
80
+ return ((a = (e = r == null ? void 0 : r.value) == null ? void 0 : e.allowedType) == null ? void 0 : a.map((o) => `.${o}`).join(",")) || "";
81
+ }), U = b();
82
+ z(() => U.value, () => {
83
+ U.value && J(U.value, {
84
84
  onStart: () => {
85
- v.value = {
85
+ f.value = {
86
86
  show: !0,
87
87
  text: "图片加载中,请稍等"
88
88
  };
89
89
  },
90
90
  onSuccess: () => {
91
- v.value.show = !1;
91
+ f.value.show = !1;
92
92
  },
93
93
  onError: (e) => {
94
- v.value.show = !1, f.error({ message: e, customClass: "tinymce-editor-message", duration: 2e4 });
94
+ f.value.show = !1, p.error({ message: e, customClass: "tinymce-editor-message", duration: 2e4 });
95
95
  }
96
96
  });
97
97
  }, { immediate: !0 });
98
- const I = y();
99
- k(() => I.value, () => {
100
- I.value && K(I.value, {
98
+ const I = b();
99
+ z(() => I.value, () => {
100
+ I.value && J(I.value, {
101
101
  onStart: () => {
102
- v.value = {
102
+ f.value = {
103
103
  show: !0,
104
104
  text: "图片加载中,请稍等"
105
105
  };
106
106
  },
107
107
  onSuccess: () => {
108
- v.value.show = !1;
108
+ f.value.show = !1;
109
109
  },
110
110
  onError: (e) => {
111
- v.value.show = !1, f.error(e);
111
+ f.value.show = !1, p.error(e);
112
112
  }
113
113
  });
114
114
  }, { immediate: !0 });
115
- const A = y({
115
+ const A = b({
116
116
  dialogVisible: !1,
117
117
  formData: {
118
118
  images: []
119
119
  }
120
- }), $ = y(), R = () => {
120
+ }), $ = b(), R = () => {
121
121
  A.value.dialogVisible = !1, A.value.formData = {
122
122
  images: []
123
123
  };
124
- }, ie = () => {
124
+ }, ae = () => {
125
125
  var e;
126
126
  (e = $.value) == null || e.validate((a) => {
127
- a && (A.value.formData.images.forEach((t) => {
128
- var l;
129
- let o = t;
130
- H.value.srcAt && (o = (t == null ? void 0 : t[H.value.srcAt]) || ""), (l = h.value) == null || l.insertContent(`<img src=${o} alt="" />`);
127
+ a && (A.value.formData.images.forEach((o) => {
128
+ var i;
129
+ let t = o;
130
+ V.value.srcAt && (t = (o == null ? void 0 : o[V.value.srcAt]) || ""), (i = h.value) == null || i.insertContent(`<img src=${t} alt="" />`);
131
131
  }), R());
132
132
  });
133
- }, x = y({
133
+ }, x = b({
134
134
  dialogVisible: !1,
135
135
  formData: {
136
136
  // 名称
@@ -142,19 +142,19 @@ const va = /* @__PURE__ */ De({
142
142
  },
143
143
  // 用于临时保存上传前的参数 { file: File }
144
144
  additionalData: {}
145
- }), F = y(), N = () => {
145
+ }), W = b(), F = () => {
146
146
  x.value.dialogVisible = !1, x.value.formData = {
147
147
  name: "",
148
148
  cover: [],
149
149
  file: []
150
150
  }, x.value.additionalData = {};
151
- }, le = () => {
151
+ }, oe = () => {
152
152
  var e;
153
- (e = F.value) == null || e.validate((a) => {
154
- var t, o;
155
- a && ((o = h.value) == null || o.insertContent(`<audio controls controlslist="nodownload noplaybackrate" data-name="${x.value.formData.name}" data-poster="${x.value.formData.cover[0]}" src="${(t = x.value.formData.file[0]) == null ? void 0 : t.url}"></audio>`), N());
153
+ (e = W.value) == null || e.validate((a) => {
154
+ var o, t;
155
+ a && ((t = h.value) == null || t.insertContent(`<audio controls controlslist="nodownload noplaybackrate" data-name="${x.value.formData.name}" data-poster="${x.value.formData.cover[0]}" src="${(o = x.value.formData.file[0]) == null ? void 0 : o.url}"></audio>`), F());
156
156
  });
157
- }, _ = y({
157
+ }, y = b({
158
158
  dialogVisible: !1,
159
159
  formData: {
160
160
  // 文件
@@ -162,86 +162,55 @@ const va = /* @__PURE__ */ De({
162
162
  },
163
163
  // 用于临时保存上传前的参数 { file: File }
164
164
  additionalData: {}
165
- }), O = y(), L = () => {
166
- _.value.dialogVisible = !1, _.value.formData = {
165
+ }), N = b(), O = () => {
166
+ y.value.dialogVisible = !1, y.value.formData = {
167
167
  file: []
168
- }, _.value.additionalData = {};
169
- }, ne = () => {
168
+ }, y.value.additionalData = {};
169
+ }, te = () => {
170
170
  var e;
171
- (e = O.value) == null || e.validate((a) => {
172
- var t, o;
173
- a && ((o = h.value) == null || o.insertContent(`<video width="auto" height="auto" controls src="${(t = _.value.formData.file[0]) == null ? void 0 : t.url}"></video>`), L());
171
+ (e = N.value) == null || e.validate((a) => {
172
+ var o, t;
173
+ a && ((t = h.value) == null || t.insertContent(`<video width="auto" height="auto" controls src="${(o = y.value.formData.file[0]) == null ? void 0 : o.url}"></video>`), O());
174
174
  });
175
- }, re = () => {
175
+ }, ie = () => {
176
176
  document.querySelectorAll(".swal2-container .swal2-title").forEach((e) => {
177
177
  e && (e.innerHTML = `单次最多可选择${r.value.maxCount}张图片`);
178
178
  });
179
- }, se = (e, a) => new Promise(async (t, o) => {
180
- var d, n;
181
- const l = await Q(e);
182
- if (!l.success) {
183
- o(), setTimeout(() => {
184
- a.onError(l.errorMessage);
179
+ }, le = (e, a) => new Promise(async (o, t) => {
180
+ var c, n;
181
+ const i = await K(e);
182
+ if (!i.success) {
183
+ t(), setTimeout(() => {
184
+ a.onError(i.errorMessage);
185
185
  });
186
186
  return;
187
187
  }
188
- const i = await ((n = (d = r.value).handleRequest) == null ? void 0 : n.call(d, Y(l.file, e.name), e.name, { extParameters: m.extParameters }));
189
- if (!i || !(i != null && i.success)) {
190
- o(), setTimeout(() => {
191
- a.onError(i == null ? void 0 : i.errorMessage);
188
+ const l = await ((n = (c = r.value).handleRequest) == null ? void 0 : n.call(c, Q(i.file, e.name), e.name, { extParameters: s.extParameters }));
189
+ if (!l || !(l != null && l.success)) {
190
+ t(), setTimeout(() => {
191
+ a.onError(l == null ? void 0 : l.errorMessage);
192
192
  });
193
193
  return;
194
194
  }
195
- t(i.url);
195
+ o(l.url);
196
196
  });
197
- async function ue(e, a) {
198
- const o = a.node.getElementsByTagName("img"), l = [];
199
- for (let i = o.length - 1; i >= 0; i--) {
200
- const d = o[i], n = "img-" + Pe();
201
- d.classList.add(n), l.push(n);
202
- }
203
- setTimeout(async () => {
204
- var i, d;
205
- for (let n = l.length - 1; n >= 0; n--) {
206
- const u = e.dom.select(`.${l[n]}`);
207
- if (u.length === 0)
208
- continue;
209
- const s = u[0], p = s.src;
210
- if (p.startsWith("data:image")) {
211
- e.dom.remove(s);
212
- continue;
213
- } else if (p.startsWith("http://") || p.startsWith("https://")) {
214
- const b = await Z(p);
215
- if (b && (b.width < (r.value.minWidth || 0) && b.height < (r.value.minHeight || 0) || b.width > (r.value.maxWidth || 0) && b.height > (r.value.maxHeight || 0))) {
216
- e.dom.remove(s);
217
- continue;
218
- }
219
- const W = ee(p);
220
- if (!((d = (i = r.value) == null ? void 0 : i.allowedType) != null && d.includes(W.toLowerCase()))) {
221
- e.dom.remove(s);
222
- continue;
223
- }
224
- }
225
- }
226
- });
227
- }
228
- async function G(e) {
229
- var d, n, u;
197
+ async function L(e) {
198
+ var c, n, d;
230
199
  let a = e;
231
- if (!((d = r.value) != null && d.handleRequest)) {
232
- f.error("缺少图片上传配置");
200
+ if (!((c = r.value) != null && c.handleRequest)) {
201
+ p.error("缺少图片上传配置");
233
202
  return;
234
203
  }
235
- v.value = {
204
+ f.value = {
236
205
  show: !0,
237
206
  text: "图片上传中,请稍等"
238
207
  };
239
- let t = a.name ? a.name : "";
208
+ let o = a.name ? a.name : "";
240
209
  if (!(a != null && a.name) && !(a != null && a.lastModified) && a.type === "image/png") {
241
- v.value.show = !1, f.error("不允许粘贴");
210
+ f.value.show = !1, p.error("不允许粘贴");
242
211
  return;
243
212
  }
244
- const o = await Ce(a, t, {
213
+ const t = await De(a, o, {
245
214
  imageMaxSize: r.value.maxSize,
246
215
  imageAllowedType: r.value.allowedType,
247
216
  // imageAllowedMineType: mergeImageUploadOptions.value.allowedMineType,
@@ -250,82 +219,82 @@ const va = /* @__PURE__ */ De({
250
219
  imageMaxWidth: r.value.maxWidth,
251
220
  imageMaxHeight: r.value.maxHeight
252
221
  });
253
- if (!o.success) {
254
- v.value.show = !1, f.error((o == null ? void 0 : o.errorMessage) || "");
222
+ if (!t.success) {
223
+ f.value.show = !1, p.error((t == null ? void 0 : t.errorMessage) || "");
255
224
  return;
256
225
  }
257
- if (o.hasTransform) {
258
- a = o.file;
259
- const s = t == null ? void 0 : t.split(".");
260
- s.pop(), t = `${s.join(",")}.jpg`;
226
+ if (t.hasTransform) {
227
+ a = t.file;
228
+ const m = o == null ? void 0 : o.split(".");
229
+ m.pop(), o = `${m.join(",")}.jpg`;
261
230
  }
262
- const l = await Q(a);
263
- if (!l.success) {
264
- v.value.show = !1, f.error((l == null ? void 0 : l.errorMessage) || "压缩失败");
231
+ const i = await K(a);
232
+ if (!i.success) {
233
+ f.value.show = !1, p.error((i == null ? void 0 : i.errorMessage) || "压缩失败");
265
234
  return;
266
235
  }
267
- const i = await ((u = (n = r.value).handleRequest) == null ? void 0 : u.call(n, Y(l.file, t), t, { extParameters: m.extParameters }));
268
- if (!i || !i.success) {
269
- v.value.show = !1, f.error((i == null ? void 0 : i.errorMessage) || "");
236
+ const l = await ((d = (n = r.value).handleRequest) == null ? void 0 : d.call(n, Q(i.file, o), o, { extParameters: s.extParameters }));
237
+ if (!l || !l.success) {
238
+ f.value.show = !1, p.error((l == null ? void 0 : l.errorMessage) || "");
270
239
  return;
271
240
  }
272
- return v.value.show = !1, i.url;
241
+ return f.value.show = !1, l.url;
273
242
  }
274
- const V = async (e) => {
275
- var l, i, d;
276
- const a = h.value, t = e.types;
277
- if (t.includes("text/html")) {
278
- const n = e.getData("text/html"), s = new DOMParser().parseFromString(n, "text/html"), p = Array.from(s.body.querySelectorAll("img")), b = Array.from(s.body.querySelectorAll("audio")), W = Array.from(s.body.querySelectorAll("video"));
279
- p.length > 0 && (v.value = {
243
+ const H = async (e) => {
244
+ var i, l, c;
245
+ const a = h.value, o = e.types;
246
+ if (o.includes("text/html")) {
247
+ const n = e.getData("text/html"), m = new DOMParser().parseFromString(n, "text/html"), v = Array.from(m.body.querySelectorAll("img")), D = Array.from(m.body.querySelectorAll("audio")), xe = Array.from(m.body.querySelectorAll("video"));
248
+ v.length > 0 && (f.value = {
280
249
  show: !0,
281
250
  text: "图片加载中,请稍等"
282
251
  });
283
- for (const D of [...b, ...W])
284
- D == null || D.remove();
285
- for await (const D of [...p])
286
- if (D.removeAttribute("crossorigin"), D.src.startsWith("http"))
287
- if ((l = r.value) != null && l.handleRequestByUrl) {
288
- const g = await ((i = r.value) == null ? void 0 : i.handleRequestByUrl(D.src, { extParameters: m.extParameters }));
289
- g != null && g.success && (g != null && g.url) ? D.src = g == null ? void 0 : g.url : D.remove();
252
+ for (const _ of [...D, ...xe])
253
+ _ == null || _.remove();
254
+ for await (const _ of [...v])
255
+ if (_.removeAttribute("crossorigin"), _.src.startsWith("http"))
256
+ if ((i = r.value) != null && i.handleRequestByUrl) {
257
+ const g = await ((l = r.value) == null ? void 0 : l.handleRequestByUrl(_.src, { extParameters: s.extParameters }));
258
+ g != null && g.success && (g != null && g.url) ? _.src = g == null ? void 0 : g.url : _.remove();
290
259
  } else {
291
- const g = await Z(D.src);
292
- g && (g.width < (r.value.minWidth || 0) && g.height < (r.value.minHeight || 0) || g.width > (r.value.maxWidth || 0) && g.height > (r.value.maxHeight || 0)) && D.remove();
260
+ const g = await Ae(_.src);
261
+ g && (g.width < (r.value.minWidth || 0) && g.height < (r.value.minHeight || 0) || g.width > (r.value.maxWidth || 0) && g.height > (r.value.maxHeight || 0)) && _.remove();
293
262
  }
294
263
  else
295
- D.remove(), f.error("不支持Word中批量复制图片或视频,请改为单个复制,或者从工具栏中手动插入上传");
296
- v.value.show = !1;
297
- const _e = new XMLSerializer().serializeToString(s.body);
298
- a.insertContent(_e);
264
+ _.remove(), p.error("不支持Word中批量复制图片或视频,请改为单个复制,或者从工具栏中手动插入上传");
265
+ f.value.show = !1;
266
+ const we = new XMLSerializer().serializeToString(m.body);
267
+ a.insertContent(we);
299
268
  } else
300
- t.includes("text/plain") && a.insertContent(e.getData("text/plain"));
301
- const o = Array.from(e.items);
302
- for await (const n of o) {
303
- const u = n.getAsFile();
304
- if (!u)
269
+ o.includes("text/plain") && a.insertContent(e.getData("text/plain"));
270
+ const t = Array.from(e.items);
271
+ for await (const n of t) {
272
+ const d = n.getAsFile();
273
+ if (!d)
305
274
  continue;
306
- const s = ee(u.name);
307
- if (u.type.indexOf("image") > -1 || (d = r.value.allowedType) != null && d.includes(s.toLowerCase())) {
308
- const p = await G(u);
309
- if (p) {
310
- const b = `<img src="${p}" alt="" />`;
311
- a.insertContent(b);
275
+ const m = Ce(d.name);
276
+ if (d.type.indexOf("image") > -1 || (c = r.value.allowedType) != null && c.includes(m.toLowerCase())) {
277
+ const v = await L(d);
278
+ if (v) {
279
+ const D = `<img src="${v}" alt="" />`;
280
+ a.insertContent(D);
312
281
  }
313
282
  }
314
283
  }
315
- z("input", a.getContent());
316
- }, X = (e) => {
317
- var t;
284
+ M("input", a.getContent());
285
+ }, G = (e) => {
286
+ var o;
318
287
  e.preventDefault();
319
- const a = e.clipboardData || ((t = e == null ? void 0 : e.originalEvent) == null ? void 0 : t.clipboardData);
320
- V(a);
321
- }, J = (e) => {
322
- var t;
288
+ const a = e.clipboardData || ((o = e == null ? void 0 : e.originalEvent) == null ? void 0 : o.clipboardData);
289
+ H(a);
290
+ }, X = (e) => {
291
+ var o;
323
292
  e.preventDefault();
324
- const a = e.dataTransfer || ((t = e == null ? void 0 : e.originalEvent) == null ? void 0 : t.dataTransfer);
325
- V(a);
293
+ const a = e.dataTransfer || ((o = e == null ? void 0 : e.originalEvent) == null ? void 0 : o.dataTransfer);
294
+ H(a);
326
295
  };
327
- Ae(() => {
328
- var t;
296
+ ye(() => {
297
+ var o;
329
298
  const e = {
330
299
  // 设置语言
331
300
  language: "zh_CN",
@@ -408,241 +377,168 @@ const va = /* @__PURE__ */ De({
408
377
  convert_urls: !1,
409
378
  paste_webkit_styles: "all",
410
379
  paste_data_images: !1,
411
- images_file_types: ((t = r.value.allowedType) == null ? void 0 : t.join(",")) || "jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp",
380
+ images_file_types: ((o = r.value.allowedType) == null ? void 0 : o.join(",")) || "jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp",
412
381
  // 粘贴前处理
413
- paste_preprocess(o, l) {
414
- l == null || l.preventDefault();
382
+ paste_preprocess(t, i) {
383
+ i == null || i.preventDefault();
415
384
  },
416
- // // 粘贴后处理(处理异步操作)
417
- // paste_postprocess(editor, args) {
418
- // // 处理图片
419
- // processPastedImage(editor, args)
420
- // },
421
- // images_upload_handler(blobInfo) {
422
- // // eslint-disable-next-line no-async-promise-executor
423
- // return new Promise(async (resolve, reject) => {
424
- // // 校验图片配置
425
- // if (!mergeImageUploadOptions.value?.handleRequest) {
426
- // removeNotification()
427
- // return reject({ message: '缺少图片上传配置', remove: true })
428
- // }
429
- //
430
- // uploadLoadingConfig.value = {
431
- // show: true,
432
- // text: '图片上传中,请稍等'
433
- // }
434
- //
435
- // // 获取文件 blob 数据
436
- // // 1.从本地复制图片都是 File 对象,chrome 复制非图片文件,都是 blob,且为 png
437
- // let file = blobInfo.blob()
438
- // // 有名称,则取真实名称
439
- // let filename = (file as File).name ? (file as File).name : blobInfo.filename()
440
- // if (!(file as File)?.name && !(file as File)?.lastModified && file.type === 'image/png') {// chrome 复制非图片格式
441
- // uploadLoadingConfig.value.show = false
442
- // removeNotification()
443
- // return reject({ message: '不允许粘贴', remove: true })
444
- // }
445
- //
446
- // // 图片校验
447
- // const checkRes = await oneTravelImageCheckAndTransform(file, filename, {
448
- // imageMaxSize: mergeImageUploadOptions.value.maxSize,
449
- // imageAllowedType: mergeImageUploadOptions.value.allowedType,
450
- // imageMinWidth: mergeImageUploadOptions.value.minWidth,
451
- // imageMinHeight: mergeImageUploadOptions.value.minHeight,
452
- // imageMaxWidth: mergeImageUploadOptions.value.maxWidth,
453
- // imageMaxHeight: mergeImageUploadOptions.value.maxHeight
454
- // })
455
- // if (!checkRes.success) {
456
- // uploadLoadingConfig.value.show = false
457
- // removeNotification()
458
- // return reject({ message: checkRes?.errorMessage || '', remove: true })
459
- // }
460
- // if (checkRes.hasTransform) {// 被转换
461
- // // 修改文件
462
- // file = checkRes.file!
463
- //
464
- // // 修改名称
465
- // const arr = filename?.split('.')
466
- // arr.pop()
467
- // const prefix = arr.join(',')
468
- // filename = `${prefix}.jpg`
469
- // }
470
- //
471
- // // 图片压缩
472
- // const compressorRes = await oneTravelImageCompressor(file)
473
- // if (!compressorRes.success) {
474
- // uploadLoadingConfig.value.show = false
475
- // removeNotification()
476
- // return reject({ message: compressorRes?.errorMessage, remove: true })
477
- // }
478
- //
479
- // // 上传图片
480
- // const uploadRes = await mergeImageUploadOptions.value.handleRequest?.(blobToFile(compressorRes.file, filename), filename, { extParameters: props.extParameters })
481
- // if (!uploadRes || !uploadRes.success) {
482
- // uploadLoadingConfig.value.show = false
483
- // removeNotification()
484
- // return reject({ message: uploadRes.errorMessage, remove: true })
485
- // }
486
- //
487
- // uploadLoadingConfig.value.show = false
488
- // resolve(uploadRes.url!)
489
- // })
490
- // },
491
- setup(o) {
492
- var i, d;
493
- const l = () => {
385
+ setup(t) {
386
+ var l, c;
387
+ const i = () => {
494
388
  A.value.dialogVisible = !0, setTimeout(() => {
495
- var u, s;
496
- const n = (u = document == null ? void 0 : document.querySelector) == null ? void 0 : u.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
497
- n && (n.innerHTML = ((s = r.value) == null ? void 0 : s.tipText) || "上传");
389
+ var d, m;
390
+ const n = (d = document == null ? void 0 : document.querySelector) == null ? void 0 : d.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
391
+ n && (n.innerHTML = ((m = r.value) == null ? void 0 : m.tipText) || "上传");
498
392
  });
499
393
  };
500
- if (o.ui.registry.addMenuItem("localImage", {
394
+ if (t.ui.registry.addMenuItem("localImage", {
501
395
  text: "图片",
502
396
  icon: "image",
503
- onAction: () => l()
504
- }), o.ui.registry.addButton("localImage", {
397
+ onAction: () => i()
398
+ }), t.ui.registry.addButton("localImage", {
505
399
  icon: "image",
506
400
  tooltip: "图片",
507
- onAction: () => l()
508
- }), (i = w == null ? void 0 : w.value) != null && i.enable) {
401
+ onAction: () => i()
402
+ }), (l = w == null ? void 0 : w.value) != null && l.enable) {
509
403
  const n = () => {
510
404
  x.value.dialogVisible = !0, setTimeout(() => {
511
- var s, p;
512
- const u = (s = document == null ? void 0 : document.querySelector) == null ? void 0 : s.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
513
- u && (u.innerHTML = ((p = r.value) == null ? void 0 : p.tipText) || "上传");
405
+ var m, v;
406
+ const d = (m = document == null ? void 0 : document.querySelector) == null ? void 0 : m.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
407
+ d && (d.innerHTML = ((v = r.value) == null ? void 0 : v.tipText) || "上传");
514
408
  });
515
409
  };
516
- o.ui.registry.addMenuItem("localAudio", {
410
+ t.ui.registry.addMenuItem("localAudio", {
517
411
  text: "音频",
518
412
  icon: "arrow-right",
519
413
  onAction: () => n()
520
- }), o.ui.registry.addButton("localAudio", {
414
+ }), t.ui.registry.addButton("localAudio", {
521
415
  icon: "arrow-right",
522
416
  tooltip: "音频",
523
417
  onAction: () => n()
524
418
  });
525
419
  }
526
- if ((d = c == null ? void 0 : c.value) != null && d.enable) {
420
+ if ((c = u == null ? void 0 : u.value) != null && c.enable) {
527
421
  const n = () => {
528
- _.value.dialogVisible = !0;
422
+ y.value.dialogVisible = !0;
529
423
  };
530
- o.ui.registry.addMenuItem("localVideo", {
424
+ t.ui.registry.addMenuItem("localVideo", {
531
425
  text: "视频",
532
426
  icon: "embed",
533
427
  onAction: () => n()
534
- }), o.ui.registry.addButton("localVideo", {
428
+ }), t.ui.registry.addButton("localVideo", {
535
429
  icon: "embed",
536
430
  tooltip: "视频",
537
431
  onAction: () => n()
538
432
  });
539
433
  }
540
434
  }
541
- }, a = C(
435
+ }, a = T(
542
436
  [
543
- m.options,
437
+ s.options,
544
438
  P.options,
545
439
  e
546
440
  ],
547
441
  {
548
- mergeFunction: (o, l) => (...i) => {
549
- o(...i), l(...i);
442
+ mergeFunction: (t, i) => (...l) => {
443
+ t(...l), i(...l);
550
444
  },
551
445
  type: Object
552
446
  }
553
447
  );
554
- ae.init(a).then(([o]) => {
555
- var l;
556
- o && (o.customProps = { ...m }, o.on("input", () => {
557
- if (S.value) {
558
- S.value = !1;
448
+ Y.init(a).then(([t]) => {
449
+ var i;
450
+ t && (t.customProps = { ...s }, t.on("input", () => {
451
+ if (k.value) {
452
+ k.value = !1;
559
453
  return;
560
454
  }
561
- M.value = !0, z("input", o.getContent());
562
- }), o.on("paste", (i) => {
563
- X(i);
564
- }), o.on("drop", (i) => {
565
- J(i);
566
- }), (l = m.initComplete) == null || l.call(m, { editorIns: o }), h.value = o);
455
+ S.value = !0, M("input", t.getContent());
456
+ }), t.on("change", () => {
457
+ M("input", t.getContent());
458
+ }), t.on("paste", (l) => {
459
+ G(l);
460
+ }), t.on("drop", (l) => {
461
+ X(l);
462
+ }), (i = s.initComplete) == null || i.call(s, { editorIns: t }), h.value = t);
567
463
  });
568
- }), Te(() => {
569
- var e, a, t, o;
570
- (e = h.value) == null || e.off("input"), (a = h.value) == null || a.off("paste"), (t = h.value) == null || t.off("drop"), (o = h.value) == null || o.destroy();
464
+ }), _e(() => {
465
+ var e, a, o, t;
466
+ (e = h.value) == null || e.off("input"), (a = h.value) == null || a.off("paste"), (o = h.value) == null || o.off("drop"), (t = h.value) == null || t.destroy();
571
467
  });
572
- const me = () => {
573
- var a, t;
468
+ const re = () => {
469
+ var a, o;
574
470
  const e = { ...x.value.additionalData || {} };
575
- return ((t = (a = w.value) == null ? void 0 : a.data) == null ? void 0 : t.call(a, { ...e, extParameters: m.extParameters })) || {};
576
- }, de = () => {
577
- var a, t;
471
+ return ((o = (a = w.value) == null ? void 0 : a.data) == null ? void 0 : o.call(a, { ...e, extParameters: s.extParameters })) || {};
472
+ }, ne = () => {
473
+ var a, o;
578
474
  const e = { ...x.value.additionalData || {} };
579
- return ((t = (a = w.value) == null ? void 0 : a.headers) == null ? void 0 : t.call(a, { ...e, extParameters: m.extParameters })) || {};
580
- }, ce = (e, a, t) => {
581
- var l, i;
582
- const o = (i = (l = w == null ? void 0 : w.value) == null ? void 0 : l.handlerResponse) == null ? void 0 : i.call(l, e);
583
- o != null && o.url ? t[t.length - 1].url = o.url : o != null && o.errorMessage && (f.error(o.errorMessage), t.splice(t.length - 1, 1)), x.value.formData.file = t;
584
- }, pe = (e, a) => new Promise((t, o) => {
585
- var i, d, n, u, s, p;
586
- const l = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
587
- if (!((d = (i = w.value) == null ? void 0 : i.allowedType) != null && d.includes(l.toLowerCase()))) {
588
- f.error(`请上传格式为${(u = (n = w.value) == null ? void 0 : n.allowedType) == null ? void 0 : u.map((b) => b.toUpperCase()).join("、")}的音频`), o();
475
+ return ((o = (a = w.value) == null ? void 0 : a.headers) == null ? void 0 : o.call(a, { ...e, extParameters: s.extParameters })) || {};
476
+ }, se = (e, a, o) => {
477
+ var i, l;
478
+ const t = (l = (i = w == null ? void 0 : w.value) == null ? void 0 : i.handlerResponse) == null ? void 0 : l.call(i, e);
479
+ t != null && t.url ? o[o.length - 1].url = t.url : t != null && t.errorMessage && (p.error(t.errorMessage), o.splice(o.length - 1, 1)), x.value.formData.file = o;
480
+ }, ue = (e, a) => new Promise((o, t) => {
481
+ var l, c, n, d, m, v;
482
+ const i = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
483
+ if (!((c = (l = w.value) == null ? void 0 : l.allowedType) != null && c.includes(i.toLowerCase()))) {
484
+ p.error(`请上传格式为${(d = (n = w.value) == null ? void 0 : n.allowedType) == null ? void 0 : d.map((D) => D.toUpperCase()).join("、")}的音频`), t();
589
485
  return;
590
486
  }
591
- if (e.size > (((s = w.value) == null ? void 0 : s.maxSize) || 0) * 1024 * 1024) {
592
- f.error(`请上传${((p = w.value) == null ? void 0 : p.maxSize) || 0}M内的音频`), o();
487
+ if (e.size > (((m = w.value) == null ? void 0 : m.maxSize) || 0) * 1024 * 1024) {
488
+ p.error(`请上传${((v = w.value) == null ? void 0 : v.maxSize) || 0}M内的音频`), t();
593
489
  return;
594
490
  }
595
- x.value.additionalData = { file: e }, t(!0);
596
- }), fe = (e, a) => {
491
+ x.value.additionalData = { file: e }, o(!0);
492
+ }), me = (e, a) => {
597
493
  x.value.formData.file = a;
598
- }, ve = (e, a, t) => {
599
- f.error("上传发生错误,请重试!"), x.value.formData.file = t;
600
- }, ge = () => {
601
- var a, t;
602
- const e = { ..._.value.additionalData || {} };
603
- return ((t = (a = c.value) == null ? void 0 : a.data) == null ? void 0 : t.call(a, { ...e, extParameters: m.extParameters })) || {};
604
- }, he = () => {
605
- var a, t;
606
- const e = { ..._.value.additionalData || {} };
607
- return ((t = (a = c.value) == null ? void 0 : a.headers) == null ? void 0 : t.call(a, { ...e, extParameters: m.extParameters })) || {};
608
- }, xe = (e, a, t) => {
609
- var l, i;
610
- const o = (i = (l = c == null ? void 0 : c.value) == null ? void 0 : l.handlerResponse) == null ? void 0 : i.call(l, e);
611
- o != null && o.url ? t[t.length - 1].url = o.url : o != null && o.errorMessage && (f.error(o.errorMessage), t.splice(t.length - 1, 1)), _.value.formData.file = t;
612
- }, we = (e, a) => new Promise((t, o) => {
613
- var i, d, n, u, s, p;
614
- const l = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
615
- if (!((d = (i = c == null ? void 0 : c.value) == null ? void 0 : i.allowedType) != null && d.includes(l.toLowerCase()))) {
616
- f.error(`请上传格式为${(u = (n = c == null ? void 0 : c.value) == null ? void 0 : n.allowedType) == null ? void 0 : u.map((b) => b.toUpperCase()).join("、")}的视频`), o();
494
+ }, de = (e, a, o) => {
495
+ p.error("上传发生错误,请重试!"), x.value.formData.file = o;
496
+ }, ce = () => {
497
+ var a, o;
498
+ const e = { ...y.value.additionalData || {} };
499
+ return ((o = (a = u.value) == null ? void 0 : a.data) == null ? void 0 : o.call(a, { ...e, extParameters: s.extParameters })) || {};
500
+ }, pe = () => {
501
+ var a, o;
502
+ const e = { ...y.value.additionalData || {} };
503
+ return ((o = (a = u.value) == null ? void 0 : a.headers) == null ? void 0 : o.call(a, { ...e, extParameters: s.extParameters })) || {};
504
+ }, fe = (e, a, o) => {
505
+ var i, l;
506
+ const t = (l = (i = u == null ? void 0 : u.value) == null ? void 0 : i.handlerResponse) == null ? void 0 : l.call(i, e);
507
+ t != null && t.url ? o[o.length - 1].url = t.url : t != null && t.errorMessage && (p.error(t.errorMessage), o.splice(o.length - 1, 1)), y.value.formData.file = o;
508
+ }, ve = (e, a) => new Promise((o, t) => {
509
+ var l, c, n, d, m, v;
510
+ const i = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
511
+ if (!((c = (l = u == null ? void 0 : u.value) == null ? void 0 : l.allowedType) != null && c.includes(i.toLowerCase()))) {
512
+ p.error(`请上传格式为${(d = (n = u == null ? void 0 : u.value) == null ? void 0 : n.allowedType) == null ? void 0 : d.map((D) => D.toUpperCase()).join("、")}的视频`), t();
617
513
  return;
618
514
  }
619
- if (e.size > (((s = c == null ? void 0 : c.value) == null ? void 0 : s.maxSize) || 0) * 1024 * 1024) {
620
- f.error(`请上传${((p = c == null ? void 0 : c.value) == null ? void 0 : p.maxSize) || 0}M内的视频`), o();
515
+ if (e.size > (((m = u == null ? void 0 : u.value) == null ? void 0 : m.maxSize) || 0) * 1024 * 1024) {
516
+ p.error(`请上传${((v = u == null ? void 0 : u.value) == null ? void 0 : v.maxSize) || 0}M内的视频`), t();
621
517
  return;
622
518
  }
623
- _.value.additionalData = { file: e }, t(!0);
624
- }), be = (e, a) => {
625
- _.value.formData.file = a;
626
- }, ye = (e, a, t) => {
627
- f.error("上传发生错误,请重试!"), _.value.formData.file = t;
519
+ y.value.additionalData = { file: e }, o(!0);
520
+ }), ge = (e, a) => {
521
+ y.value.formData.file = a;
522
+ }, he = (e, a, o) => {
523
+ p.error("上传发生错误,请重试!"), y.value.formData.file = o;
628
524
  };
629
- return k(() => [m.disabled, h.value], () => {
525
+ return z(() => [s.disabled, h.value], () => {
630
526
  var e, a;
631
- (a = (e = h.value) == null ? void 0 : e.mode) == null || a.set(m.disabled ? "readonly" : "design");
632
- }, { immediate: !0 }), k(
633
- () => [m.value, h.value],
527
+ (a = (e = h.value) == null ? void 0 : e.mode) == null || a.set(s.disabled ? "readonly" : "design");
528
+ }, { immediate: !0 }), z(
529
+ () => [s.value, h.value],
634
530
  () => {
635
531
  var e;
636
- if (M.value) {
637
- M.value = !1;
532
+ if (S.value) {
533
+ S.value = !1;
638
534
  return;
639
535
  }
640
- S.value = !0, (e = h.value) == null || e.setContent(m.value ? m.value : "");
536
+ k.value = !0, (e = h.value) == null || e.setContent(s.value ? s.value : "");
641
537
  },
642
538
  { immediate: !0 }
643
- ), { __sfc: !0, defaultImageUploadOptions: B, defaultVideoUploadOptions: j, defaultAudioUploadOptions: q, props: m, emits: z, insRef: E, editorRef: h, preventSettingContent: M, preventUpdatingModelValue: S, uploadLoadingConfig: v, mergeImageUploadOptions: r, mergeVideoUploadOptions: c, mergeAudioUploadOptions: w, mergeImgPondOptions: H, imgPondAccept: oe, uploadImageImgPondRef: U, audioImageImgPondRef: I, uploadImage: A, uploadImageFormRef: $, onUploadImageClose: R, onUploadImageConfirm: ie, uploadAudio: x, uploadAudioFormRef: F, onUploadAudioClose: N, onUploadAudioConfirm: le, uploadVideo: _, uploadVideoFormRef: O, onUploadVideoClose: L, onUploadVideoConfirm: ne, onImageUploadUploadExceed: re, onImageUploadUpload: se, processPastedImage: ue, uploadPasteOrDropFile: G, handleDataTransfer: V, onValuePaste: X, onValueDrop: J, getUploadAudioData: me, getUploadAudioHeaders: de, onUploadAudioSuccess: ce, onUploadAudioBeforeUpload: pe, onUploadAudioRemove: fe, onUploadAudioError: ve, getUploadVideoData: ge, getUploadVideoHeaders: he, onUploadVideoSuccess: xe, onUploadVideoBeforeUpload: we, onUploadVideoRemove: be, onUploadVideoError: ye, ImgPond: Me };
539
+ ), { __sfc: !0, defaultImageUploadOptions: j, defaultVideoUploadOptions: B, defaultAudioUploadOptions: q, props: s, emits: M, insRef: E, editorRef: h, preventSettingContent: S, preventUpdatingModelValue: k, uploadLoadingConfig: f, mergeImageUploadOptions: r, mergeVideoUploadOptions: u, mergeAudioUploadOptions: w, mergeImgPondOptions: V, imgPondAccept: ee, uploadImageImgPondRef: U, audioImageImgPondRef: I, uploadImage: A, uploadImageFormRef: $, onUploadImageClose: R, onUploadImageConfirm: ae, uploadAudio: x, uploadAudioFormRef: W, onUploadAudioClose: F, onUploadAudioConfirm: oe, uploadVideo: y, uploadVideoFormRef: N, onUploadVideoClose: O, onUploadVideoConfirm: te, onImageUploadUploadExceed: ie, onImageUploadUpload: le, uploadPasteOrDropFile: L, handleDataTransfer: H, onValuePaste: G, onValueDrop: X, getUploadAudioData: re, getUploadAudioHeaders: ne, onUploadAudioSuccess: se, onUploadAudioBeforeUpload: ue, onUploadAudioRemove: me, onUploadAudioError: de, getUploadVideoData: ce, getUploadVideoHeaders: pe, onUploadVideoSuccess: fe, onUploadVideoBeforeUpload: ve, onUploadVideoRemove: ge, onUploadVideoError: he, ImgPond: Te };
644
540
  }
645
541
  });
646
542
  export {
647
- va as default
543
+ pa as default
648
544
  };
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.48",
5
+ "version": "0.0.12-alpha.50",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",
@@ -23,7 +23,7 @@
23
23
  "vue-global-config": "^0.2.6",
24
24
  "tinymce": "^7.1.0",
25
25
  "element-ui": "^2.15.14",
26
- "@keyblade/one-travel": "^2.0.14"
26
+ "@keyblade/one-travel": "^2.0.15"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "vue": "^2.7.0",