@keyblade/tinymce-editor-vue2 0.0.12-alpha.45 → 0.0.12-alpha.46

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