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

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.
package/README.md CHANGED
@@ -42,6 +42,17 @@ Vue.use(TinymceEditor, {
42
42
  })
43
43
  }, 1000)
44
44
  })
45
+ },
46
+ // 网络图片,将URL传给后端,让后端下载后校验、转换、压缩等操作
47
+ handleRequestByUrl: (url: string, parameters: { extParameters: Record<string, any> }) => {
48
+ return new Promise((resolve) => {
49
+ setTimeout(() => {
50
+ resolve({
51
+ success: true,
52
+ url: 'https://object.gcongo.com.cn/onecode-travel/nonClassic/8cefe379c03b5f39cd8ef725293a3c02/2024/5/1715995588295/d0b5bb458b694130be0c63e2f1d0090b.png'
53
+ })
54
+ }, 1000)
55
+ })
45
56
  }
46
57
  },
47
58
  // 音频
@@ -173,6 +184,10 @@ export interface ImageUploadOptions {
173
184
  handleRequest?: (file: File, filename: string, options?: {
174
185
  extParameters?: Record<string, any>
175
186
  }) => Promise<{success: boolean; url?: string; errorMessage?: string}>;
187
+ /** 图片URL上传请求处理(前端跨域,交给后端处理) */
188
+ handleRequestByUrl?: (url: string, options?: {
189
+ extParameters?: Record<string, any>
190
+ }) => Promise<{success: boolean; url?: string; errorMessage?: string}>;
176
191
  }
177
192
  ```
178
193
 
package/es/editor.vue2.js CHANGED
@@ -1,11 +1,11 @@
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";
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";
4
4
  import "./style.less.js";
5
- import Te from "imgpond";
6
- import { conclude as T } from "vue-global-config";
7
- import Q from "tinymce";
8
- import Ce from "./langs/zh_CN.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";
9
9
  import "tinymce/skins/ui/oxide/skin";
10
10
  import "tinymce/models/dom";
11
11
  import "tinymce/themes/silver";
@@ -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 C } from "./index.js";
37
+ import { globalProps as P } from "./index.js";
38
38
  import { Message as f } from "element-ui";
39
- const da = /* @__PURE__ */ xe({
39
+ const va = /* @__PURE__ */ De({
40
40
  __name: "editor",
41
41
  props: {
42
42
  value: { default: "" },
@@ -50,10 +50,10 @@ const da = /* @__PURE__ */ xe({
50
50
  initComplete: null
51
51
  },
52
52
  emits: ["input"],
53
- setup(Y, { emit: U }) {
54
- const u = Y;
55
- Q.addI18n("zh_CN", Ce);
56
- const H = {
53
+ setup(te, { emit: z }) {
54
+ const m = te;
55
+ ae.addI18n("zh_CN", Se);
56
+ const B = {
57
57
  maxCount: 10,
58
58
  tipText: "上传",
59
59
  maxSize: 30,
@@ -67,20 +67,20 @@ const da = /* @__PURE__ */ xe({
67
67
  maxSize: 300,
68
68
  allowedType: ["mp4", "3gp"],
69
69
  accept: "video/mp4,video/3gpp"
70
- }, W = {
70
+ }, q = {
71
71
  enable: !0,
72
72
  maxSize: 200,
73
73
  allowedType: ["mp3", "m4a", "wav", "aac"],
74
74
  accept: "audio/mp3,audio/wav,audio/aac,audio/x-m4a"
75
- }, B = w(), g = w(), P = w(!1), M = w(!1), v = w({
75
+ }, E = y(), h = y(), M = y(!1), S = y(!1), v = y({
76
76
  show: !1,
77
77
  text: "图片上传中,请稍等"
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(() => {
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(() => {
79
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, {
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, {
84
84
  onStart: () => {
85
85
  v.value = {
86
86
  show: !0,
@@ -95,9 +95,9 @@ const da = /* @__PURE__ */ xe({
95
95
  }
96
96
  });
97
97
  }, { immediate: !0 });
98
- const I = w();
98
+ const I = y();
99
99
  k(() => I.value, () => {
100
- I.value && X(I.value, {
100
+ I.value && K(I.value, {
101
101
  onStart: () => {
102
102
  v.value = {
103
103
  show: !0,
@@ -112,25 +112,25 @@ const da = /* @__PURE__ */ xe({
112
112
  }
113
113
  });
114
114
  }, { immediate: !0 });
115
- const D = w({
115
+ const A = y({
116
116
  dialogVisible: !1,
117
117
  formData: {
118
118
  images: []
119
119
  }
120
- }), $ = w(), E = () => {
121
- D.value.dialogVisible = !1, D.value.formData = {
120
+ }), $ = y(), R = () => {
121
+ A.value.dialogVisible = !1, A.value.formData = {
122
122
  images: []
123
123
  };
124
- }, ee = () => {
124
+ }, ie = () => {
125
125
  var e;
126
126
  (e = $.value) == null || e.validate((a) => {
127
- a && (D.value.formData.images.forEach((t) => {
127
+ a && (A.value.formData.images.forEach((t) => {
128
128
  var l;
129
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());
130
+ H.value.srcAt && (o = (t == null ? void 0 : t[H.value.srcAt]) || ""), (l = h.value) == null || l.insertContent(`<img src=${o} alt="" />`);
131
+ }), R());
132
132
  });
133
- }, h = w({
133
+ }, x = y({
134
134
  dialogVisible: !1,
135
135
  formData: {
136
136
  // 名称
@@ -142,19 +142,19 @@ const da = /* @__PURE__ */ xe({
142
142
  },
143
143
  // 用于临时保存上传前的参数 { file: File }
144
144
  additionalData: {}
145
- }), q = w(), F = () => {
146
- h.value.dialogVisible = !1, h.value.formData = {
145
+ }), F = y(), N = () => {
146
+ x.value.dialogVisible = !1, x.value.formData = {
147
147
  name: "",
148
148
  cover: [],
149
149
  file: []
150
- }, h.value.additionalData = {};
151
- }, ae = () => {
150
+ }, x.value.additionalData = {};
151
+ }, le = () => {
152
152
  var e;
153
- (e = q.value) == null || e.validate((a) => {
153
+ (e = F.value) == null || e.validate((a) => {
154
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());
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());
156
156
  });
157
- }, b = w({
157
+ }, _ = y({
158
158
  dialogVisible: !1,
159
159
  formData: {
160
160
  // 文件
@@ -162,30 +162,30 @@ const da = /* @__PURE__ */ xe({
162
162
  },
163
163
  // 用于临时保存上传前的参数 { file: File }
164
164
  additionalData: {}
165
- }), R = w(), N = () => {
166
- b.value.dialogVisible = !1, b.value.formData = {
165
+ }), O = y(), L = () => {
166
+ _.value.dialogVisible = !1, _.value.formData = {
167
167
  file: []
168
- }, b.value.additionalData = {};
169
- }, te = () => {
168
+ }, _.value.additionalData = {};
169
+ }, ne = () => {
170
170
  var e;
171
- (e = R.value) == null || e.validate((a) => {
171
+ (e = O.value) == null || e.validate((a) => {
172
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());
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());
174
174
  });
175
- }, oe = () => {
175
+ }, re = () => {
176
176
  document.querySelectorAll(".swal2-container .swal2-title").forEach((e) => {
177
- e && (e.innerHTML = `单次最多可选择${s.value.maxCount}张图片`);
177
+ e && (e.innerHTML = `单次最多可选择${r.value.maxCount}张图片`);
178
178
  });
179
- }, ie = (e, a) => new Promise(async (t, o) => {
180
- var r, n;
181
- const l = await J(e);
179
+ }, se = (e, a) => new Promise(async (t, o) => {
180
+ var d, n;
181
+ const l = await Q(e);
182
182
  if (!l.success) {
183
183
  o(), setTimeout(() => {
184
184
  a.onError(l.errorMessage);
185
185
  });
186
186
  return;
187
187
  }
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 }));
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
189
  if (!i || !(i != null && i.success)) {
190
190
  o(), setTimeout(() => {
191
191
  a.onError(i == null ? void 0 : i.errorMessage);
@@ -194,41 +194,41 @@ const da = /* @__PURE__ */ xe({
194
194
  }
195
195
  t(i.url);
196
196
  });
197
- async function le(e, a) {
197
+ async function ue(e, a) {
198
198
  const o = a.node.getElementsByTagName("img"), l = [];
199
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);
200
+ const d = o[i], n = "img-" + Pe();
201
+ d.classList.add(n), l.push(n);
202
202
  }
203
203
  setTimeout(async () => {
204
- var i, r;
204
+ var i, d;
205
205
  for (let n = l.length - 1; n >= 0; n--) {
206
- const c = e.dom.select(`.${l[n]}`);
207
- if (c.length === 0)
206
+ const u = e.dom.select(`.${l[n]}`);
207
+ if (u.length === 0)
208
208
  continue;
209
- const d = c[0], p = d.src;
209
+ const s = u[0], p = s.src;
210
210
  if (p.startsWith("data:image")) {
211
- e.dom.remove(d);
211
+ e.dom.remove(s);
212
212
  continue;
213
213
  } else if (p.startsWith("http://") || p.startsWith("https://")) {
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);
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
217
  continue;
218
218
  }
219
- const _ = Ae(p);
220
- if (!((r = (i = s.value) == null ? void 0 : i.allowedType) != null && r.includes(_.toLowerCase()))) {
221
- e.dom.remove(d);
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
222
  continue;
223
223
  }
224
224
  }
225
225
  }
226
226
  });
227
227
  }
228
- async function O(e) {
229
- var r, n, c;
228
+ async function G(e) {
229
+ var d, n, u;
230
230
  let a = e;
231
- if (!((r = s.value) != null && r.handleRequest)) {
231
+ if (!((d = r.value) != null && d.handleRequest)) {
232
232
  f.error("缺少图片上传配置");
233
233
  return;
234
234
  }
@@ -241,14 +241,14 @@ const da = /* @__PURE__ */ xe({
241
241
  v.value.show = !1, f.error("不允许粘贴");
242
242
  return;
243
243
  }
244
- const o = await ye(a, t, {
245
- imageMaxSize: s.value.maxSize,
246
- imageAllowedType: s.value.allowedType,
244
+ const o = await Ce(a, t, {
245
+ imageMaxSize: r.value.maxSize,
246
+ imageAllowedType: r.value.allowedType,
247
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
248
+ imageMinWidth: r.value.minWidth,
249
+ imageMinHeight: r.value.minHeight,
250
+ imageMaxWidth: r.value.maxWidth,
251
+ imageMaxHeight: r.value.maxHeight
252
252
  });
253
253
  if (!o.success) {
254
254
  v.value.show = !1, f.error((o == null ? void 0 : o.errorMessage) || "");
@@ -256,15 +256,15 @@ const da = /* @__PURE__ */ xe({
256
256
  }
257
257
  if (o.hasTransform) {
258
258
  a = o.file;
259
- const d = t == null ? void 0 : t.split(".");
260
- d.pop(), t = `${d.join(",")}.jpg`;
259
+ const s = t == null ? void 0 : t.split(".");
260
+ s.pop(), t = `${s.join(",")}.jpg`;
261
261
  }
262
- const l = await J(a);
262
+ const l = await Q(a);
263
263
  if (!l.success) {
264
264
  v.value.show = !1, f.error((l == null ? void 0 : l.errorMessage) || "压缩失败");
265
265
  return;
266
266
  }
267
- const i = await ((c = (n = s.value).handleRequest) == null ? void 0 : c.call(n, K(l.file, t), t, { extParameters: u.extParameters }));
267
+ const i = await ((u = (n = r.value).handleRequest) == null ? void 0 : u.call(n, Y(l.file, t), t, { extParameters: m.extParameters }));
268
268
  if (!i || !i.success) {
269
269
  v.value.show = !1, f.error((i == null ? void 0 : i.errorMessage) || "");
270
270
  return;
@@ -272,52 +272,65 @@ const da = /* @__PURE__ */ xe({
272
272
  return v.value.show = !1, i.url;
273
273
  }
274
274
  const V = async (e) => {
275
- const a = g.value, t = e.types;
275
+ var l, i, d;
276
+ const a = h.value, t = e.types;
276
277
  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 = {
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 = {
279
280
  show: !0,
280
281
  text: "图片加载中,请稍等"
281
282
  });
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中批量复制图片或视频,请改为单个复制,或者从工具栏中手动插入上传"));
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();
290
+ } 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();
293
+ }
294
+ else
295
+ D.remove(), f.error("不支持Word中批量复制图片或视频,请改为单个复制,或者从工具栏中手动插入上传");
286
296
  v.value.show = !1;
287
- const y = new XMLSerializer().serializeToString(r.body);
288
- a.insertContent(y);
297
+ const _e = new XMLSerializer().serializeToString(s.body);
298
+ a.insertContent(_e);
289
299
  } else
290
300
  t.includes("text/plain") && a.insertContent(e.getData("text/plain"));
291
301
  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);
302
+ for await (const n of o) {
303
+ const u = n.getAsFile();
304
+ if (!u)
305
+ 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);
299
312
  }
300
313
  }
301
314
  }
302
- U("input", a.getContent());
303
- }, L = (e) => {
315
+ z("input", a.getContent());
316
+ }, X = (e) => {
304
317
  var t;
305
318
  e.preventDefault();
306
319
  const a = e.clipboardData || ((t = e == null ? void 0 : e.originalEvent) == null ? void 0 : t.clipboardData);
307
320
  V(a);
308
- }, G = (e) => {
321
+ }, J = (e) => {
309
322
  var t;
310
323
  e.preventDefault();
311
324
  const a = e.dataTransfer || ((t = e == null ? void 0 : e.originalEvent) == null ? void 0 : t.dataTransfer);
312
325
  V(a);
313
326
  };
314
- we(() => {
327
+ Ae(() => {
315
328
  var t;
316
329
  const e = {
317
330
  // 设置语言
318
331
  language: "zh_CN",
319
332
  // 实例
320
- target: B.value,
333
+ target: E.value,
321
334
  // 隐藏品牌
322
335
  branding: !1,
323
336
  // 隐藏右上角升级按钮
@@ -395,7 +408,7 @@ const da = /* @__PURE__ */ xe({
395
408
  convert_urls: !1,
396
409
  paste_webkit_styles: "all",
397
410
  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",
411
+ images_file_types: ((t = r.value.allowedType) == null ? void 0 : t.join(",")) || "jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp",
399
412
  // 粘贴前处理
400
413
  paste_preprocess(o, l) {
401
414
  l == null || l.preventDefault();
@@ -476,12 +489,12 @@ const da = /* @__PURE__ */ xe({
476
489
  // })
477
490
  // },
478
491
  setup(o) {
479
- var i, r;
492
+ var i, d;
480
493
  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) || "上传");
494
+ 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) || "上传");
485
498
  });
486
499
  };
487
500
  if (o.ui.registry.addMenuItem("localImage", {
@@ -492,12 +505,12 @@ const da = /* @__PURE__ */ xe({
492
505
  icon: "image",
493
506
  tooltip: "图片",
494
507
  onAction: () => l()
495
- }), (i = x == null ? void 0 : x.value) != null && i.enable) {
508
+ }), (i = w == null ? void 0 : w.value) != null && i.enable) {
496
509
  const n = () => {
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) || "上传");
510
+ 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) || "上传");
501
514
  });
502
515
  };
503
516
  o.ui.registry.addMenuItem("localAudio", {
@@ -510,9 +523,9 @@ const da = /* @__PURE__ */ xe({
510
523
  onAction: () => n()
511
524
  });
512
525
  }
513
- if ((r = m == null ? void 0 : m.value) != null && r.enable) {
526
+ if ((d = c == null ? void 0 : c.value) != null && d.enable) {
514
527
  const n = () => {
515
- b.value.dialogVisible = !0;
528
+ _.value.dialogVisible = !0;
516
529
  };
517
530
  o.ui.registry.addMenuItem("localVideo", {
518
531
  text: "视频",
@@ -525,10 +538,10 @@ const da = /* @__PURE__ */ xe({
525
538
  });
526
539
  }
527
540
  }
528
- }, a = T(
541
+ }, a = C(
529
542
  [
530
- u.options,
531
- C.options,
543
+ m.options,
544
+ P.options,
532
545
  e
533
546
  ],
534
547
  {
@@ -538,98 +551,98 @@ const da = /* @__PURE__ */ xe({
538
551
  type: Object
539
552
  }
540
553
  );
541
- Q.init(a).then(([o]) => {
554
+ ae.init(a).then(([o]) => {
542
555
  var l;
543
- o && (o.customProps = { ...u }, o.on("input", () => {
544
- if (M.value) {
545
- M.value = !1;
556
+ o && (o.customProps = { ...m }, o.on("input", () => {
557
+ if (S.value) {
558
+ S.value = !1;
546
559
  return;
547
560
  }
548
- P.value = !0, U("input", o.getContent());
561
+ M.value = !0, z("input", o.getContent());
549
562
  }), o.on("paste", (i) => {
550
- L(i);
563
+ X(i);
551
564
  }), o.on("drop", (i) => {
552
- G(i);
553
- }), (l = u.initComplete) == null || l.call(u, { editorIns: o }), g.value = o);
565
+ J(i);
566
+ }), (l = m.initComplete) == null || l.call(m, { editorIns: o }), h.value = o);
554
567
  });
555
- }), be(() => {
568
+ }), Te(() => {
556
569
  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();
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();
558
571
  });
559
- const ne = () => {
572
+ const me = () => {
560
573
  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 })) || {};
563
- }, re = () => {
574
+ 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 = () => {
564
577
  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) => {
578
+ 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) => {
568
581
  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;
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;
573
586
  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();
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();
576
589
  return;
577
590
  }
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();
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();
580
593
  return;
581
594
  }
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;
587
- }, ce = () => {
595
+ x.value.additionalData = { file: e }, t(!0);
596
+ }), fe = (e, a) => {
597
+ x.value.formData.file = a;
598
+ }, ve = (e, a, t) => {
599
+ f.error("上传发生错误,请重试!"), x.value.formData.file = t;
600
+ }, ge = () => {
588
601
  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 })) || {};
591
- }, pe = () => {
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 = () => {
592
605
  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) => {
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) => {
596
609
  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;
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;
601
614
  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();
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();
604
617
  return;
605
618
  }
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();
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();
608
621
  return;
609
622
  }
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;
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;
615
628
  };
616
- return k(() => [u.disabled, g.value], () => {
629
+ return k(() => [m.disabled, h.value], () => {
617
630
  var e, a;
618
- (a = (e = g.value) == null ? void 0 : e.mode) == null || a.set(u.disabled ? "readonly" : "design");
631
+ (a = (e = h.value) == null ? void 0 : e.mode) == null || a.set(m.disabled ? "readonly" : "design");
619
632
  }, { immediate: !0 }), k(
620
- () => [u.value, g.value],
633
+ () => [m.value, h.value],
621
634
  () => {
622
635
  var e;
623
- if (P.value) {
624
- P.value = !1;
636
+ if (M.value) {
637
+ M.value = !1;
625
638
  return;
626
639
  }
627
- M.value = !0, (e = g.value) == null || e.setContent(u.value ? u.value : "");
640
+ S.value = !0, (e = h.value) == null || e.setContent(m.value ? m.value : "");
628
641
  },
629
642
  { immediate: !0 }
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 };
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 };
631
644
  }
632
645
  });
633
646
  export {
634
- da as default
647
+ va as default
635
648
  };
package/es/types.d.ts CHANGED
@@ -24,6 +24,14 @@ export interface ImageUploadOptions {
24
24
  url?: string;
25
25
  errorMessage?: string;
26
26
  }>;
27
+ /** 图片URL上传请求处理(前端跨域,交给后端处理) */
28
+ handleRequestByUrl?: (url: string, options?: {
29
+ extParameters?: Record<string, any>;
30
+ }) => Promise<{
31
+ success: boolean;
32
+ url?: string;
33
+ errorMessage?: string;
34
+ }>;
27
35
  }
28
36
  /** 视频选项 */
29
37
  export interface VideoUploadOptions {
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.46",
5
+ "version": "0.0.12-alpha.47",
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.12"
26
+ "@keyblade/one-travel": "^2.0.13"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "vue": "^2.7.0",