@keyblade/tinymce-editor-vue2 0.1.0 → 0.1.1

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
@@ -208,6 +208,8 @@ export interface VideoUploadOptions {
208
208
  headers?: (parameters: { file: File | Blob, extParameters?: Record<string, any> }) => Record<string, any>;
209
209
  /** 额外请求体 */
210
210
  data?: (parameters: { file: File | Blob, extParameters?: Record<string, any> }) => Record<string, any>;
211
+ /** 上传之前回调结束(开始调用上传接口) */
212
+ beforeUploadEnd?: (file: File | Blob) => void
211
213
  /** 响应处理(启用必传) */
212
214
  handlerResponse?: (response: any) => { url?: string; errorMessage?: string }
213
215
  }
@@ -230,6 +232,8 @@ export interface AudioUploadOptions {
230
232
  headers?: (parameters: { file: File | Blob, extParameters?: Record<string, any> }) => Record<string, any>;
231
233
  /** 额外请求体 */
232
234
  data?: (parameters: { file: File | Blob, extParameters?: Record<string, any> }) => Record<string, any>;
235
+ /** 上传之前回调结束(开始调用上传接口) */
236
+ beforeUploadEnd?: (file: File | Blob) => void
233
237
  /** 响应处理(启用必传) */
234
238
  handlerResponse?: (response: any) => { url?: string; errorMessage?: string }
235
239
  }
package/es/editor.vue2.js CHANGED
@@ -1,41 +1,41 @@
1
- var ze = Object.defineProperty, Ve = Object.defineProperties;
2
- var Be = Object.getOwnPropertyDescriptors;
3
- var re = Object.getOwnPropertySymbols;
4
- var He = Object.prototype.hasOwnProperty, qe = Object.prototype.propertyIsEnumerable;
5
- var le = (u, n) => (n = Symbol[u]) ? n : Symbol.for("Symbol." + u);
6
- var ne = (u, n, i) => n in u ? ze(u, n, { enumerable: !0, configurable: !0, writable: !0, value: i }) : u[n] = i, C = (u, n) => {
1
+ var Ee = Object.defineProperty, He = Object.defineProperties;
2
+ var qe = Object.getOwnPropertyDescriptors;
3
+ var ne = Object.getOwnPropertySymbols;
4
+ var Ve = Object.prototype.hasOwnProperty, je = Object.prototype.propertyIsEnumerable;
5
+ var se = (m, n) => (n = Symbol[m]) ? n : Symbol.for("Symbol." + m);
6
+ var ue = (m, n, i) => n in m ? Ee(m, n, { enumerable: !0, configurable: !0, writable: !0, value: i }) : m[n] = i, P = (m, n) => {
7
7
  for (var i in n || (n = {}))
8
- He.call(n, i) && ne(u, i, n[i]);
9
- if (re)
10
- for (var i of re(n))
11
- qe.call(n, i) && ne(u, i, n[i]);
12
- return u;
13
- }, j = (u, n) => Ve(u, Be(n));
14
- var N = (u, n, i) => new Promise((I, M) => {
15
- var P = (h) => {
8
+ Ve.call(n, i) && ue(m, i, n[i]);
9
+ if (ne)
10
+ for (var i of ne(n))
11
+ je.call(n, i) && ue(m, i, n[i]);
12
+ return m;
13
+ }, j = (m, n) => He(m, qe(n));
14
+ var L = (m, n, i) => new Promise((k, I) => {
15
+ var S = (x) => {
16
16
  try {
17
- m(i.next(h));
18
- } catch (T) {
19
- M(T);
17
+ d(i.next(x));
18
+ } catch (C) {
19
+ I(C);
20
20
  }
21
- }, k = (h) => {
21
+ }, z = (x) => {
22
22
  try {
23
- m(i.throw(h));
24
- } catch (T) {
25
- M(T);
23
+ d(i.throw(x));
24
+ } catch (C) {
25
+ I(C);
26
26
  }
27
- }, m = (h) => h.done ? I(h.value) : Promise.resolve(h.value).then(P, k);
28
- m((i = i.apply(u, n)).next());
27
+ }, d = (x) => x.done ? k(x.value) : Promise.resolve(x.value).then(S, z);
28
+ d((i = i.apply(m, n)).next());
29
29
  });
30
- var X = (u, n, i) => (n = u[le("asyncIterator")]) ? n.call(u) : (u = u[le("iterator")](), n = {}, i = (I, M) => (M = u[I]) && (n[I] = (P) => new Promise((k, m, h) => (P = M.call(u, P), h = P.done, Promise.resolve(P.value).then((T) => k({ value: T, done: h }), m)))), i("next"), i("return"), n);
31
- import { defineComponent as je, ref as y, computed as E, watch as O, onMounted as Ee, onUnmounted as $e } from "vue";
32
- import { oneTravelImgPondBeforeAddFile as se, oneTravelImageCompressor as ue, oneTravelImageCheckAndTransform as Fe } from "@keyblade/one-travel";
33
- import { blobToFile as me, getImagePixel as Re, getFileExtension as We } from "./util.js";
30
+ var K = (m, n, i) => (n = m[se("asyncIterator")]) ? n.call(m) : (m = m[se("iterator")](), n = {}, i = (k, I) => (I = m[k]) && (n[k] = (S) => new Promise((z, d, x) => (S = I.call(m, S), x = S.done, Promise.resolve(S.value).then((C) => z({ value: C, done: x }), d)))), i("next"), i("return"), n);
31
+ import { defineComponent as $e, ref as y, computed as $, watch as O, onMounted as Fe, onUnmounted as Re } from "vue";
32
+ import { oneTravelImgPondBeforeAddFile as me, oneTravelImageCompressor as de, oneTravelImageCheckAndTransform as We } from "@keyblade/one-travel";
33
+ import { blobToFile as ce, getImagePixel as Ne, getFileExtension as Le } from "./util.js";
34
34
  import "./style.less.js";
35
- import Ne from "imgpond";
36
- import { conclude as $ } from "vue-global-config";
37
- import de from "tinymce";
38
- import Oe from "./langs/zh_CN.js";
35
+ import Oe from "imgpond";
36
+ import { conclude as F } from "vue-global-config";
37
+ import pe from "tinymce";
38
+ import Ge from "./langs/zh_CN.js";
39
39
  import "tinymce/skins/ui/oxide/skin";
40
40
  import "tinymce/models/dom";
41
41
  import "tinymce/themes/silver";
@@ -66,9 +66,9 @@ import "tinymce/plugins/table";
66
66
  import "tinymce/plugins/visualblocks";
67
67
  import "tinymce/plugins/visualchars";
68
68
  import "tinymce/plugins/wordcount";
69
- import { globalProps as F } from "./index.js";
69
+ import { globalProps as R } from "./index.js";
70
70
  import { Message as g } from "element-ui";
71
- const Va = /* @__PURE__ */ je({
71
+ const Ha = /* @__PURE__ */ $e({
72
72
  __name: "editor",
73
73
  props: {
74
74
  value: { default: "" },
@@ -82,10 +82,10 @@ const Va = /* @__PURE__ */ je({
82
82
  initComplete: null
83
83
  },
84
84
  emits: ["input"],
85
- setup(u, { emit: n }) {
86
- const i = u;
87
- de.addI18n("zh_CN", Oe);
88
- const I = {
85
+ setup(m, { emit: n }) {
86
+ const i = m;
87
+ pe.addI18n("zh_CN", Ge);
88
+ const k = {
89
89
  maxCount: 10,
90
90
  tipText: "上传",
91
91
  maxSize: 30,
@@ -94,75 +94,75 @@ const Va = /* @__PURE__ */ je({
94
94
  minHeight: 50,
95
95
  maxWidth: 6e3,
96
96
  maxHeight: 6e3
97
- }, M = {
97
+ }, I = {
98
98
  enable: !0,
99
99
  maxSize: 300,
100
100
  allowedType: ["avi", "wmv", "mp4", "mov", "3gp"],
101
101
  accept: ".avi,.wmv,.mp4,.mov,.3gp"
102
- }, P = {
102
+ }, S = {
103
103
  enable: !0,
104
104
  maxSize: 200,
105
105
  allowedType: ["wav", "mp3", "mp4", "m4a", "wma", "aac"],
106
106
  accept: ".wav,.mp3,.mp4,.m4a,.wma,.aac"
107
- }, k = y(), m = y(), h = y(!1), T = y(!1), A = y({
107
+ }, z = y(), d = y(), x = y(!1), C = y(!1), T = y({
108
108
  show: !1,
109
109
  text: "图片上传中,请稍等"
110
- }), s = E(() => $([i.imageUploadOptions, F.imageUploadOptions, I]) || {}), p = E(() => $([i.videoUploadOptions, F.videoUploadOptions, M]) || {}), b = E(() => $([i.audioUploadOptions, F.audioUploadOptions, P]) || {}), L = E(() => $([i.imgPondOptions, F.imgPondOptions]) || {}), ce = E(() => {
110
+ }), s = $(() => F([i.imageUploadOptions, R.imageUploadOptions, k]) || {}), u = $(() => F([i.videoUploadOptions, R.videoUploadOptions, I]) || {}), h = $(() => F([i.audioUploadOptions, R.audioUploadOptions, S]) || {}), G = $(() => F([i.imgPondOptions, R.imgPondOptions]) || {}), fe = $(() => {
111
111
  var e, a;
112
- return ((a = (e = s == null ? void 0 : s.value) == null ? void 0 : e.allowedType) == null ? void 0 : a.map((o) => `.${o}`).join(",")) || "";
113
- }), R = y();
114
- O(() => R.value, () => {
115
- R.value && se(R.value, {
112
+ return ((a = (e = s == null ? void 0 : s.value) == null ? void 0 : e.allowedType) == null ? void 0 : a.map((t) => `.${t}`).join(",")) || "";
113
+ }), W = y();
114
+ O(() => W.value, () => {
115
+ W.value && me(W.value, {
116
116
  onStart: () => {
117
- A.value = {
117
+ T.value = {
118
118
  show: !0,
119
119
  text: "图片加载中,请稍等"
120
120
  };
121
121
  },
122
122
  onSuccess: () => {
123
- A.value.show = !1;
123
+ T.value.show = !1;
124
124
  },
125
125
  onError: (e) => {
126
- A.value.show = !1, g.error({ message: e, customClass: "tinymce-editor-message", duration: 3e3 });
126
+ T.value.show = !1, g.error({ message: e, customClass: "tinymce-editor-message", duration: 3e3 });
127
127
  }
128
128
  });
129
129
  }, { immediate: !0 });
130
- const W = y();
131
- O(() => W.value, () => {
132
- W.value && se(W.value, {
130
+ const N = y();
131
+ O(() => N.value, () => {
132
+ N.value && me(N.value, {
133
133
  onStart: () => {
134
- A.value = {
134
+ T.value = {
135
135
  show: !0,
136
136
  text: "图片加载中,请稍等"
137
137
  };
138
138
  },
139
139
  onSuccess: () => {
140
- A.value.show = !1;
140
+ T.value.show = !1;
141
141
  },
142
142
  onError: (e) => {
143
- A.value.show = !1, g.error(e);
143
+ T.value.show = !1, g.error(e);
144
144
  }
145
145
  });
146
146
  }, { immediate: !0 });
147
- const B = y({
147
+ const E = y({
148
148
  dialogVisible: !1,
149
149
  formData: {
150
150
  images: []
151
151
  }
152
- }), J = y(), K = () => {
153
- H = [], B.value.dialogVisible = !1, B.value.formData = {
152
+ }), Q = y(), Y = () => {
153
+ H = [], E.value.dialogVisible = !1, E.value.formData = {
154
154
  images: []
155
155
  };
156
- }, pe = () => {
156
+ }, ve = () => {
157
157
  var e;
158
- H = [], (e = J.value) == null || e.validate((a) => {
159
- a && (B.value.formData.images.forEach((o) => {
158
+ H = [], (e = Q.value) == null || e.validate((a) => {
159
+ a && (E.value.formData.images.forEach((t) => {
160
160
  var r;
161
- let t = o;
162
- L.value.srcAt && (t = (o == null ? void 0 : o[L.value.srcAt]) || ""), (r = m.value) == null || r.insertContent(`<img src=${t} alt="" />`);
163
- }), K());
161
+ let o = t;
162
+ G.value.srcAt && (o = (t == null ? void 0 : t[G.value.srcAt]) || ""), (r = d.value) == null || r.insertContent(`<img src=${o} alt="" />`);
163
+ }), Y());
164
164
  });
165
- }, w = y({
165
+ }, b = y({
166
166
  dialogVisible: !1,
167
167
  formData: {
168
168
  // 名称
@@ -174,17 +174,17 @@ const Va = /* @__PURE__ */ je({
174
174
  },
175
175
  // 用于临时保存上传前的参数 { file: File }
176
176
  additionalData: {}
177
- }), Q = y(), Y = () => {
178
- w.value.dialogVisible = !1, w.value.formData = {
177
+ }), Z = y(), ee = () => {
178
+ b.value.dialogVisible = !1, b.value.formData = {
179
179
  name: "",
180
180
  cover: [],
181
181
  file: []
182
- }, w.value.additionalData = {};
183
- }, fe = () => {
182
+ }, b.value.additionalData = {};
183
+ }, ge = () => {
184
184
  var e;
185
- (e = Q.value) == null || e.validate((a) => {
186
- var o, t;
187
- a && ((t = m.value) == null || t.insertContent(`<audio controls controlslist="nodownload noplaybackrate" data-name="${w.value.formData.name}" data-poster="${w.value.formData.cover[0]}" src="${(o = w.value.formData.file[0]) == null ? void 0 : o.url}"></audio>`), Y());
185
+ (e = Z.value) == null || e.validate((a) => {
186
+ var t, o;
187
+ a && ((o = d.value) == null || o.insertContent(`<audio controls controlslist="nodownload noplaybackrate" data-name="${b.value.formData.name}" data-poster="${b.value.formData.cover[0]}" src="${(t = b.value.formData.file[0]) == null ? void 0 : t.url}"></audio>`), ee());
188
188
  });
189
189
  }, _ = y({
190
190
  dialogVisible: !1,
@@ -194,61 +194,61 @@ const Va = /* @__PURE__ */ je({
194
194
  },
195
195
  // 用于临时保存上传前的参数 { file: File }
196
196
  additionalData: {}
197
- }), Z = y(), ee = () => {
197
+ }), ae = y(), te = () => {
198
198
  _.value.dialogVisible = !1, _.value.formData = {
199
199
  file: []
200
200
  }, _.value.additionalData = {};
201
- }, ve = () => {
201
+ }, he = () => {
202
202
  var e;
203
- (e = Z.value) == null || e.validate((a) => {
204
- var o, t;
205
- a && ((t = m.value) == null || t.insertContent(`<video width="auto" height="auto" controls src="${(o = _.value.formData.file[0]) == null ? void 0 : o.url}"></video>`), ee());
203
+ (e = ae.value) == null || e.validate((a) => {
204
+ var t, o;
205
+ a && ((o = d.value) == null || o.insertContent(`<video width="auto" height="auto" controls src="${(t = _.value.formData.file[0]) == null ? void 0 : t.url}"></video>`), te());
206
206
  });
207
- }, ge = () => {
207
+ }, xe = () => {
208
208
  document.querySelectorAll(".swal2-container .swal2-title").forEach((e) => {
209
209
  e && (e.innerHTML = `单次最多可选择${s.value.maxCount}张图片`);
210
210
  });
211
211
  };
212
212
  let H = [];
213
- const he = (e, a) => new Promise((o, t) => N(this, null, function* () {
213
+ const we = (e, a) => new Promise((t, o) => L(this, null, function* () {
214
214
  var f, v;
215
- if (H.find((c) => (c == null ? void 0 : c.uid) === (e == null ? void 0 : e.uid)))
215
+ if (H.find((p) => (p == null ? void 0 : p.uid) === (e == null ? void 0 : e.uid)))
216
216
  return setTimeout(() => {
217
- document.querySelectorAll(".swal2-container").forEach((c) => {
218
- c == null || c.remove();
217
+ document.querySelectorAll(".swal2-container").forEach((p) => {
218
+ p == null || p.remove();
219
219
  });
220
- }), t("");
220
+ }), o("");
221
221
  H.push(e);
222
- const l = yield ue(e);
222
+ const l = yield de(e);
223
223
  if (!l.success) {
224
- t(), setTimeout(() => {
224
+ o(), setTimeout(() => {
225
225
  a.onError(l.errorMessage);
226
226
  });
227
227
  return;
228
228
  }
229
- const d = yield (v = (f = s.value).handleRequest) == null ? void 0 : v.call(f, me(l.file, e.name), e.name, { extParameters: i.extParameters });
230
- if (!d || !(d != null && d.success)) {
231
- t(), setTimeout(() => {
232
- a.onError(d == null ? void 0 : d.errorMessage);
229
+ const c = yield (v = (f = s.value).handleRequest) == null ? void 0 : v.call(f, ce(l.file, e.name), e.name, { extParameters: i.extParameters });
230
+ if (!c || !(c != null && c.success)) {
231
+ o(), setTimeout(() => {
232
+ a.onError(c == null ? void 0 : c.errorMessage);
233
233
  });
234
234
  return;
235
235
  }
236
- o(d.url);
236
+ t(c.url);
237
237
  }));
238
- function ae(e) {
239
- return N(this, null, function* () {
240
- var d, f, v;
238
+ function oe(e) {
239
+ return L(this, null, function* () {
240
+ var c, f, v;
241
241
  let a = e;
242
- if (!((d = s.value) != null && d.handleRequest)) {
242
+ if (!((c = s.value) != null && c.handleRequest)) {
243
243
  g.error("缺少图片上传配置");
244
244
  return;
245
245
  }
246
- let o = a.name ? a.name : "";
246
+ let t = a.name ? a.name : "";
247
247
  if (!(a != null && a.name) && !(a != null && a.lastModified) && a.type === "image/png") {
248
248
  g.error("不允许粘贴");
249
249
  return;
250
250
  }
251
- const t = yield Fe(a, o, {
251
+ const o = yield We(a, t, {
252
252
  imageMaxSize: s.value.maxSize,
253
253
  imageAllowedType: s.value.allowedType,
254
254
  // imageAllowedMineType: mergeImageUploadOptions.value.allowedMineType,
@@ -257,21 +257,21 @@ const Va = /* @__PURE__ */ je({
257
257
  imageMaxWidth: s.value.maxWidth,
258
258
  imageMaxHeight: s.value.maxHeight
259
259
  });
260
- if (!t.success) {
261
- g.error((t == null ? void 0 : t.errorMessage) || "");
260
+ if (!o.success) {
261
+ g.error((o == null ? void 0 : o.errorMessage) || "");
262
262
  return;
263
263
  }
264
- if (t.hasTransform) {
265
- a = t.file;
266
- const c = o == null ? void 0 : o.split(".");
267
- c.pop(), o = `${c.join(",")}.jpg`;
264
+ if (o.hasTransform) {
265
+ a = o.file;
266
+ const p = t == null ? void 0 : t.split(".");
267
+ p.pop(), t = `${p.join(",")}.jpg`;
268
268
  }
269
- const r = yield ue(a);
269
+ const r = yield de(a);
270
270
  if (!r.success) {
271
271
  g.error((r == null ? void 0 : r.errorMessage) || "压缩失败");
272
272
  return;
273
273
  }
274
- const l = yield (v = (f = s.value).handleRequest) == null ? void 0 : v.call(f, me(r.file, o), o, { extParameters: i.extParameters });
274
+ const l = yield (v = (f = s.value).handleRequest) == null ? void 0 : v.call(f, ce(r.file, t), t, { extParameters: i.extParameters });
275
275
  if (!l || !l.success) {
276
276
  g.error((l == null ? void 0 : l.errorMessage) || "");
277
277
  return;
@@ -279,98 +279,98 @@ const Va = /* @__PURE__ */ je({
279
279
  return l.url;
280
280
  });
281
281
  }
282
- const G = (e) => N(this, null, function* () {
283
- var l, d, z;
284
- const a = m.value, o = e.types;
285
- if (o.includes("text/html")) {
286
- const U = e.getData("text/html"), V = new DOMParser().parseFromString(U, "text/html"), ie = Array.from(V.body.querySelectorAll("img")), Ue = Array.from(V.body.querySelectorAll("audio")), Ie = Array.from(V.body.querySelectorAll("video"));
287
- ie.length > 0 && (A.value = {
282
+ const X = (e) => L(this, null, function* () {
283
+ var l, c, D;
284
+ const a = d.value, t = e.types;
285
+ if (t.includes("text/html")) {
286
+ const U = e.getData("text/html"), B = new DOMParser().parseFromString(U, "text/html"), le = Array.from(B.body.querySelectorAll("img")), ke = Array.from(B.body.querySelectorAll("audio")), ze = Array.from(B.body.querySelectorAll("video"));
287
+ le.length > 0 && (T.value = {
288
288
  show: !0,
289
289
  text: "图片加载中,请稍等"
290
290
  });
291
- for (const D of [...Ue, ...Ie])
292
- D == null || D.remove();
291
+ for (const A of [...ke, ...ze])
292
+ A == null || A.remove();
293
293
  try {
294
- for (var f = X([...ie]), v, c, S; v = !(c = yield f.next()).done; v = !1) {
295
- const D = c.value;
296
- if (D.removeAttribute("crossorigin"), D.src.startsWith("http"))
294
+ for (var f = K([...le]), v, p, M; v = !(p = yield f.next()).done; v = !1) {
295
+ const A = p.value;
296
+ if (A.removeAttribute("crossorigin"), A.src.startsWith("http"))
297
297
  if ((l = s.value) != null && l.handleRequestByUrl) {
298
- const x = yield (d = s.value) == null ? void 0 : d.handleRequestByUrl(D.src, { extParameters: i.extParameters });
299
- x != null && x.success && (x != null && x.url) ? D.src = x == null ? void 0 : x.url : D.remove();
298
+ const w = yield (c = s.value) == null ? void 0 : c.handleRequestByUrl(A.src, { extParameters: i.extParameters });
299
+ w != null && w.success && (w != null && w.url) ? A.src = w == null ? void 0 : w.url : A.remove();
300
300
  } else {
301
- const x = yield Re(D.src);
302
- x && (x.width < (s.value.minWidth || 0) && x.height < (s.value.minHeight || 0) || x.width > (s.value.maxWidth || 0) && x.height > (s.value.maxHeight || 0)) && D.remove();
301
+ const w = yield Ne(A.src);
302
+ w && (w.width < (s.value.minWidth || 0) && w.height < (s.value.minHeight || 0) || w.width > (s.value.maxWidth || 0) && w.height > (s.value.maxHeight || 0)) && A.remove();
303
303
  }
304
304
  else
305
- D.remove(), g.error("不支持Word中批量复制图片或视频,请改为单个复制,或者从工具栏中手动插入上传");
305
+ A.remove(), g.error("不支持Word中批量复制图片或视频,请改为单个复制,或者从工具栏中手动插入上传");
306
306
  }
307
- } catch (c) {
308
- S = [c];
307
+ } catch (p) {
308
+ M = [p];
309
309
  } finally {
310
310
  try {
311
- v && (c = f.return) && (yield c.call(f));
311
+ v && (p = f.return) && (yield p.call(f));
312
312
  } finally {
313
- if (S)
314
- throw S[0];
313
+ if (M)
314
+ throw M[0];
315
315
  }
316
316
  }
317
- A.value.show = !1;
318
- const ke = new XMLSerializer().serializeToString(V.body);
319
- a.insertContent(ke);
317
+ T.value.show = !1;
318
+ const Be = new XMLSerializer().serializeToString(B.body);
319
+ a.insertContent(Be);
320
320
  } else
321
- o.includes("text/plain") && a.insertContent(e.getData("text/plain"));
322
- const t = Array.from((e == null ? void 0 : e.files) || []), r = [];
323
- for (const U of t) {
321
+ t.includes("text/plain") && a.insertContent(e.getData("text/plain"));
322
+ const o = Array.from((e == null ? void 0 : e.files) || []), r = [];
323
+ for (const U of o) {
324
324
  if (!U)
325
325
  continue;
326
- const q = We(U.name);
327
- U.type.indexOf("image") > -1 || (z = s.value.allowedType) != null && z.includes(q.toLowerCase()) ? r.push(U) : g.error("暂不支持的文件类型");
326
+ const V = Le(U.name);
327
+ U.type.indexOf("image") > -1 || (D = s.value.allowedType) != null && D.includes(V.toLowerCase()) ? r.push(U) : g.error("暂不支持的文件类型");
328
328
  }
329
329
  if (r.length > 0) {
330
- A.value = {
330
+ T.value = {
331
331
  show: !0,
332
332
  text: "图片上传中,请稍等"
333
333
  };
334
334
  try {
335
- for (var qa = X(r), ja, Ea, $a; ja = !(Ea = yield qa.next()).done; ja = !1) {
336
- const U = Ea.value;
337
- const q = yield ae(U);
338
- if (q) {
339
- const V = `<img src="${q}" alt="" />`;
340
- a.insertContent(V);
335
+ for (var q = K(r), J, ja, $a; J = !(ja = yield q.next()).done; J = !1) {
336
+ const U = ja.value;
337
+ const V = yield oe(U);
338
+ if (V) {
339
+ const B = `<img src="${V}" alt="" />`;
340
+ a.insertContent(B);
341
341
  }
342
342
  }
343
- } catch (Ea) {
344
- $a = [Ea];
343
+ } catch (ja) {
344
+ $a = [ja];
345
345
  } finally {
346
346
  try {
347
- ja && (Ea = qa.return) && (yield Ea.call(qa));
347
+ J && (ja = q.return) && (yield ja.call(q));
348
348
  } finally {
349
349
  if ($a)
350
350
  throw $a[0];
351
351
  }
352
352
  }
353
- A.value.show = !1;
353
+ T.value.show = !1;
354
354
  }
355
355
  n("input", a.getContent());
356
- }), oe = (e) => {
357
- var o;
356
+ }), ie = (e) => {
357
+ var t;
358
358
  e.preventDefault();
359
- const a = e.clipboardData || ((o = e == null ? void 0 : e.originalEvent) == null ? void 0 : o.clipboardData);
360
- G(a);
361
- }, te = (e) => {
362
- var o;
359
+ const a = e.clipboardData || ((t = e == null ? void 0 : e.originalEvent) == null ? void 0 : t.clipboardData);
360
+ X(a);
361
+ }, re = (e) => {
362
+ var t;
363
363
  e.preventDefault();
364
- const a = e.dataTransfer || ((o = e == null ? void 0 : e.originalEvent) == null ? void 0 : o.dataTransfer);
365
- G(a);
364
+ const a = e.dataTransfer || ((t = e == null ? void 0 : e.originalEvent) == null ? void 0 : t.dataTransfer);
365
+ X(a);
366
366
  };
367
- Ee(() => {
368
- var o;
367
+ Fe(() => {
368
+ var t;
369
369
  const e = {
370
370
  // 设置语言
371
371
  language: "zh_CN",
372
372
  // 实例
373
- target: k.value,
373
+ target: z.value,
374
374
  // 隐藏品牌
375
375
  branding: !1,
376
376
  // 隐藏右上角升级按钮
@@ -448,168 +448,168 @@ const Va = /* @__PURE__ */ je({
448
448
  convert_urls: !1,
449
449
  paste_webkit_styles: "all",
450
450
  paste_data_images: !1,
451
- images_file_types: ((o = s.value.allowedType) == null ? void 0 : o.join(",")) || "jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp",
451
+ images_file_types: ((t = s.value.allowedType) == null ? void 0 : t.join(",")) || "jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp",
452
452
  // 粘贴前处理
453
- paste_preprocess(t, r) {
453
+ paste_preprocess(o, r) {
454
454
  r == null || r.preventDefault();
455
455
  },
456
- setup(t) {
457
- var l, d;
456
+ setup(o) {
457
+ var l, c;
458
458
  const r = () => {
459
- B.value.dialogVisible = !0, setTimeout(() => {
460
- var v, c;
459
+ E.value.dialogVisible = !0, setTimeout(() => {
460
+ var v, p;
461
461
  const f = (v = document == null ? void 0 : document.querySelector) == null ? void 0 : v.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
462
- f && (f.innerHTML = ((c = s.value) == null ? void 0 : c.tipText) || "上传");
462
+ f && (f.innerHTML = ((p = s.value) == null ? void 0 : p.tipText) || "上传");
463
463
  });
464
464
  };
465
- if (t.ui.registry.addMenuItem("localImage", {
465
+ if (o.ui.registry.addMenuItem("localImage", {
466
466
  text: "图片",
467
467
  icon: "image",
468
468
  onAction: () => r()
469
- }), t.ui.registry.addButton("localImage", {
469
+ }), o.ui.registry.addButton("localImage", {
470
470
  icon: "image",
471
471
  tooltip: "图片",
472
472
  onAction: () => r()
473
- }), (l = b == null ? void 0 : b.value) != null && l.enable) {
473
+ }), (l = h == null ? void 0 : h.value) != null && l.enable) {
474
474
  const f = () => {
475
- w.value.dialogVisible = !0, setTimeout(() => {
476
- var c, S;
477
- const v = (c = document == null ? void 0 : document.querySelector) == null ? void 0 : c.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
478
- v && (v.innerHTML = ((S = s.value) == null ? void 0 : S.tipText) || "上传");
475
+ b.value.dialogVisible = !0, setTimeout(() => {
476
+ var p, M;
477
+ const v = (p = document == null ? void 0 : document.querySelector) == null ? void 0 : p.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
478
+ v && (v.innerHTML = ((M = s.value) == null ? void 0 : M.tipText) || "上传");
479
479
  });
480
480
  };
481
- t.ui.registry.addMenuItem("localAudio", {
481
+ o.ui.registry.addMenuItem("localAudio", {
482
482
  text: "音频",
483
483
  icon: "arrow-right",
484
484
  onAction: () => f()
485
- }), t.ui.registry.addButton("localAudio", {
485
+ }), o.ui.registry.addButton("localAudio", {
486
486
  icon: "arrow-right",
487
487
  tooltip: "音频",
488
488
  onAction: () => f()
489
489
  });
490
490
  }
491
- if ((d = p == null ? void 0 : p.value) != null && d.enable) {
491
+ if ((c = u == null ? void 0 : u.value) != null && c.enable) {
492
492
  const f = () => {
493
493
  _.value.dialogVisible = !0;
494
494
  };
495
- t.ui.registry.addMenuItem("localVideo", {
495
+ o.ui.registry.addMenuItem("localVideo", {
496
496
  text: "视频",
497
497
  icon: "embed",
498
498
  onAction: () => f()
499
- }), t.ui.registry.addButton("localVideo", {
499
+ }), o.ui.registry.addButton("localVideo", {
500
500
  icon: "embed",
501
501
  tooltip: "视频",
502
502
  onAction: () => f()
503
503
  });
504
504
  }
505
505
  }
506
- }, a = $(
506
+ }, a = F(
507
507
  [
508
508
  i.options,
509
- F.options,
509
+ R.options,
510
510
  e
511
511
  ],
512
512
  {
513
- mergeFunction: (t, r) => (...l) => {
514
- t(...l), r(...l);
513
+ mergeFunction: (o, r) => (...l) => {
514
+ o(...l), r(...l);
515
515
  },
516
516
  type: Object
517
517
  }
518
518
  );
519
- de.init(a).then(([t]) => {
519
+ pe.init(a).then(([o]) => {
520
520
  var r;
521
- t && (t.customProps = C({}, i), t.on("input", () => {
522
- if (T.value) {
523
- T.value = !1;
521
+ o && (o.customProps = P({}, i), o.on("input", () => {
522
+ if (C.value) {
523
+ C.value = !1;
524
524
  return;
525
525
  }
526
- h.value = !0, n("input", t.getContent());
527
- }), t.on("change", () => {
528
- n("input", t.getContent());
529
- }), t.on("paste", (l) => {
530
- oe(l);
531
- }), t.on("drop", (l) => {
532
- te(l);
533
- }), (r = i.initComplete) == null || r.call(i, { editorIns: t }), m.value = t);
526
+ x.value = !0, n("input", o.getContent());
527
+ }), o.on("change", () => {
528
+ n("input", o.getContent());
529
+ }), o.on("paste", (l) => {
530
+ ie(l);
531
+ }), o.on("drop", (l) => {
532
+ re(l);
533
+ }), (r = i.initComplete) == null || r.call(i, { editorIns: o }), d.value = o);
534
534
  });
535
- }), $e(() => {
536
- var e, a, o, t;
537
- (e = m.value) == null || e.off("input"), (a = m.value) == null || a.off("paste"), (o = m.value) == null || o.off("drop"), (t = m.value) == null || t.destroy();
535
+ }), Re(() => {
536
+ var e, a, t, o;
537
+ (e = d.value) == null || e.off("input"), (a = d.value) == null || a.off("paste"), (t = d.value) == null || t.off("drop"), (o = d.value) == null || o.destroy();
538
538
  });
539
- const xe = () => {
540
- var a, o;
541
- const e = C({}, w.value.additionalData || {});
542
- return ((o = (a = b.value) == null ? void 0 : a.data) == null ? void 0 : o.call(a, j(C({}, e), { extParameters: i.extParameters }))) || {};
543
- }, we = () => {
544
- var a, o;
545
- const e = C({}, w.value.additionalData || {});
546
- return ((o = (a = b.value) == null ? void 0 : a.headers) == null ? void 0 : o.call(a, j(C({}, e), { extParameters: i.extParameters }))) || {};
547
- }, be = (e, a, o) => {
539
+ const be = () => {
540
+ var a, t;
541
+ const e = P({}, b.value.additionalData || {});
542
+ return ((t = (a = h.value) == null ? void 0 : a.data) == null ? void 0 : t.call(a, j(P({}, e), { extParameters: i.extParameters }))) || {};
543
+ }, ye = () => {
544
+ var a, t;
545
+ const e = P({}, b.value.additionalData || {});
546
+ return ((t = (a = h.value) == null ? void 0 : a.headers) == null ? void 0 : t.call(a, j(P({}, e), { extParameters: i.extParameters }))) || {};
547
+ }, _e = (e, a, t) => {
548
548
  var r, l;
549
- const t = (l = (r = b == null ? void 0 : b.value) == null ? void 0 : r.handlerResponse) == null ? void 0 : l.call(r, e);
550
- t != null && t.url ? o[o.length - 1].url = t.url : t != null && t.errorMessage && (g.error(t.errorMessage), o.splice(o.length - 1, 1)), w.value.formData.file = o;
551
- }, ye = (e, a) => new Promise((o, t) => {
552
- var l, d, f, v, c, S;
549
+ const o = (l = (r = h == null ? void 0 : h.value) == null ? void 0 : r.handlerResponse) == null ? void 0 : l.call(r, e);
550
+ o != null && o.url ? t[t.length - 1].url = o.url : o != null && o.errorMessage && (g.error(o.errorMessage), t.splice(t.length - 1, 1)), b.value.formData.file = t;
551
+ }, De = (e, a) => new Promise((t, o) => {
552
+ var l, c, f, v, p, M, D, q;
553
553
  const r = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
554
- if (!((d = (l = b.value) == null ? void 0 : l.allowedType) != null && d.includes(r.toLowerCase()))) {
555
- g.error(`请上传格式为${(v = (f = b.value) == null ? void 0 : f.allowedType) == null ? void 0 : v.map((z) => z.toUpperCase()).join("、")}的音频`), t();
554
+ if (!((c = (l = h.value) == null ? void 0 : l.allowedType) != null && c.includes(r.toLowerCase()))) {
555
+ g.error(`请上传格式为${(v = (f = h.value) == null ? void 0 : f.allowedType) == null ? void 0 : v.map((J) => J.toUpperCase()).join("、")}的音频`), o();
556
556
  return;
557
557
  }
558
- if (e.size > (((c = b.value) == null ? void 0 : c.maxSize) || 0) * 1024 * 1024) {
559
- g.error(`请上传${((S = b.value) == null ? void 0 : S.maxSize) || 0}M内的音频`), t();
558
+ if (e.size > (((p = h.value) == null ? void 0 : p.maxSize) || 0) * 1024 * 1024) {
559
+ g.error(`请上传${((M = h.value) == null ? void 0 : M.maxSize) || 0}M内的音频`), o();
560
560
  return;
561
561
  }
562
- w.value.additionalData = { file: e }, o(!0);
563
- }), _e = (e, a) => {
564
- w.value.formData.file = a;
565
- }, De = (e, a, o) => {
566
- g.error("上传发生错误,请重试!"), w.value.formData.file = o;
567
- }, Ae = () => {
568
- var a, o;
569
- const e = C({}, _.value.additionalData || {});
570
- return ((o = (a = p.value) == null ? void 0 : a.data) == null ? void 0 : o.call(a, j(C({}, e), { extParameters: i.extParameters }))) || {};
571
- }, Te = () => {
572
- var a, o;
573
- const e = C({}, _.value.additionalData || {});
574
- return ((o = (a = p.value) == null ? void 0 : a.headers) == null ? void 0 : o.call(a, j(C({}, e), { extParameters: i.extParameters }))) || {};
575
- }, Ce = (e, a, o) => {
562
+ b.value.additionalData = { file: e }, (q = (D = h == null ? void 0 : h.value) == null ? void 0 : D.beforeUploadEnd) == null || q.call(D, e), t(!0);
563
+ }), Ae = (e, a) => {
564
+ b.value.formData.file = a;
565
+ }, Te = (e, a, t) => {
566
+ g.error("上传发生错误,请重试!"), b.value.formData.file = t;
567
+ }, Ce = () => {
568
+ var a, t;
569
+ const e = P({}, _.value.additionalData || {});
570
+ return ((t = (a = u.value) == null ? void 0 : a.data) == null ? void 0 : t.call(a, j(P({}, e), { extParameters: i.extParameters }))) || {};
571
+ }, Pe = () => {
572
+ var a, t;
573
+ const e = P({}, _.value.additionalData || {});
574
+ return ((t = (a = u.value) == null ? void 0 : a.headers) == null ? void 0 : t.call(a, j(P({}, e), { extParameters: i.extParameters }))) || {};
575
+ }, Se = (e, a, t) => {
576
576
  var r, l;
577
- const t = (l = (r = p == null ? void 0 : p.value) == null ? void 0 : r.handlerResponse) == null ? void 0 : l.call(r, e);
578
- t != null && t.url ? o[o.length - 1].url = t.url : t != null && t.errorMessage && (g.error(t.errorMessage), o.splice(o.length - 1, 1)), _.value.formData.file = o;
579
- }, Pe = (e, a) => new Promise((o, t) => {
580
- var l, d, f, v, c, S;
577
+ const o = (l = (r = u == null ? void 0 : u.value) == null ? void 0 : r.handlerResponse) == null ? void 0 : l.call(r, e);
578
+ o != null && o.url ? t[t.length - 1].url = o.url : o != null && o.errorMessage && (g.error(o.errorMessage), t.splice(t.length - 1, 1)), _.value.formData.file = t;
579
+ }, Me = (e, a) => new Promise((t, o) => {
580
+ var l, c, f, v, p, M, D, q;
581
581
  const r = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
582
- if (!((d = (l = p == null ? void 0 : p.value) == null ? void 0 : l.allowedType) != null && d.includes(r.toLowerCase()))) {
583
- g.error(`请上传格式为${(v = (f = p == null ? void 0 : p.value) == null ? void 0 : f.allowedType) == null ? void 0 : v.map((z) => z.toUpperCase()).join("、")}的视频`), t();
582
+ if (!((c = (l = u == null ? void 0 : u.value) == null ? void 0 : l.allowedType) != null && c.includes(r.toLowerCase()))) {
583
+ g.error(`请上传格式为${(v = (f = u == null ? void 0 : u.value) == null ? void 0 : f.allowedType) == null ? void 0 : v.map((J) => J.toUpperCase()).join("、")}的视频`), o();
584
584
  return;
585
585
  }
586
- if (e.size > (((c = p == null ? void 0 : p.value) == null ? void 0 : c.maxSize) || 0) * 1024 * 1024) {
587
- g.error(`请上传${((S = p == null ? void 0 : p.value) == null ? void 0 : S.maxSize) || 0}M内的视频`), t();
586
+ if (e.size > (((p = u == null ? void 0 : u.value) == null ? void 0 : p.maxSize) || 0) * 1024 * 1024) {
587
+ g.error(`请上传${((M = u == null ? void 0 : u.value) == null ? void 0 : M.maxSize) || 0}M内的视频`), o();
588
588
  return;
589
589
  }
590
- _.value.additionalData = { file: e }, o(!0);
591
- }), Se = (e, a) => {
590
+ _.value.additionalData = { file: e }, (q = (D = u == null ? void 0 : u.value) == null ? void 0 : D.beforeUploadEnd) == null || q.call(D, e), t(!0);
591
+ }), Ie = (e, a) => {
592
592
  _.value.formData.file = a;
593
- }, Me = (e, a, o) => {
594
- g.error("上传发生错误,请重试!"), _.value.formData.file = o;
593
+ }, Ue = (e, a, t) => {
594
+ g.error("上传发生错误,请重试!"), _.value.formData.file = t;
595
595
  };
596
- return O(() => [i.disabled, m.value], () => {
596
+ return O(() => [i.disabled, d.value], () => {
597
597
  var e, a;
598
- (a = (e = m.value) == null ? void 0 : e.mode) == null || a.set(i.disabled ? "readonly" : "design");
598
+ (a = (e = d.value) == null ? void 0 : e.mode) == null || a.set(i.disabled ? "readonly" : "design");
599
599
  }, { immediate: !0 }), O(
600
- () => [i.value, m.value],
600
+ () => [i.value, d.value],
601
601
  () => {
602
- var e, a, o, t;
603
- if (h.value) {
604
- h.value = !1;
602
+ var e, a, t, o;
603
+ if (x.value) {
604
+ x.value = !1;
605
605
  return;
606
606
  }
607
- T.value = !0, (e = m.value) == null || e.setContent(i.value ? i.value : ""), (o = m.value) == null || o.selection.select((a = m.value) == null ? void 0 : a.getBody(), !0), (t = m.value) == null || t.selection.collapse(!1);
607
+ C.value = !0, (e = d.value) == null || e.setContent(i.value ? i.value : ""), (t = d.value) == null || t.selection.select((a = d.value) == null ? void 0 : a.getBody(), !0), (o = d.value) == null || o.selection.collapse(!1);
608
608
  },
609
609
  { immediate: !0 }
610
- ), { __sfc: !0, defaultImageUploadOptions: I, defaultVideoUploadOptions: M, defaultAudioUploadOptions: P, props: i, emits: n, insRef: k, editorRef: m, preventSettingContent: h, preventUpdatingModelValue: T, uploadLoadingConfig: A, mergeImageUploadOptions: s, mergeVideoUploadOptions: p, mergeAudioUploadOptions: b, mergeImgPondOptions: L, imgPondAccept: ce, uploadImageImgPondRef: R, audioImageImgPondRef: W, uploadImage: B, uploadImageFormRef: J, onUploadImageClose: K, onUploadImageConfirm: pe, uploadAudio: w, uploadAudioFormRef: Q, onUploadAudioClose: Y, onUploadAudioConfirm: fe, uploadVideo: _, uploadVideoFormRef: Z, onUploadVideoClose: ee, onUploadVideoConfirm: ve, onImageUploadUploadExceed: ge, imageUploadTempFiles: H, onImageUploadUpload: he, uploadPasteOrDropFile: ae, handleDataTransfer: G, onValuePaste: oe, onValueDrop: te, getUploadAudioData: xe, getUploadAudioHeaders: we, onUploadAudioSuccess: be, onUploadAudioBeforeUpload: ye, onUploadAudioRemove: _e, onUploadAudioError: De, getUploadVideoData: Ae, getUploadVideoHeaders: Te, onUploadVideoSuccess: Ce, onUploadVideoBeforeUpload: Pe, onUploadVideoRemove: Se, onUploadVideoError: Me, ImgPond: Ne };
610
+ ), { __sfc: !0, defaultImageUploadOptions: k, defaultVideoUploadOptions: I, defaultAudioUploadOptions: S, props: i, emits: n, insRef: z, editorRef: d, preventSettingContent: x, preventUpdatingModelValue: C, uploadLoadingConfig: T, mergeImageUploadOptions: s, mergeVideoUploadOptions: u, mergeAudioUploadOptions: h, mergeImgPondOptions: G, imgPondAccept: fe, uploadImageImgPondRef: W, audioImageImgPondRef: N, uploadImage: E, uploadImageFormRef: Q, onUploadImageClose: Y, onUploadImageConfirm: ve, uploadAudio: b, uploadAudioFormRef: Z, onUploadAudioClose: ee, onUploadAudioConfirm: ge, uploadVideo: _, uploadVideoFormRef: ae, onUploadVideoClose: te, onUploadVideoConfirm: he, onImageUploadUploadExceed: xe, imageUploadTempFiles: H, onImageUploadUpload: we, uploadPasteOrDropFile: oe, handleDataTransfer: X, onValuePaste: ie, onValueDrop: re, getUploadAudioData: be, getUploadAudioHeaders: ye, onUploadAudioSuccess: _e, onUploadAudioBeforeUpload: De, onUploadAudioRemove: Ae, onUploadAudioError: Te, getUploadVideoData: Ce, getUploadVideoHeaders: Pe, onUploadVideoSuccess: Se, onUploadVideoBeforeUpload: Me, onUploadVideoRemove: Ie, onUploadVideoError: Ue, ImgPond: Oe };
611
611
  }
612
612
  });
613
613
  export {
614
- Va as default
614
+ Ha as default
615
615
  };
package/es/types.d.ts CHANGED
@@ -55,6 +55,8 @@ export interface VideoUploadOptions {
55
55
  file: File | Blob;
56
56
  extParameters?: Record<string, any>;
57
57
  }) => Record<string, any>;
58
+ /** 上传之前回调结束(开始调用上传接口) */
59
+ beforeUploadEnd?: (file: File | Blob) => void;
58
60
  /** 响应处理(启用必传) */
59
61
  handlerResponse?: (response: any) => {
60
62
  url?: string;
@@ -83,6 +85,8 @@ export interface AudioUploadOptions {
83
85
  file: File | Blob;
84
86
  extParameters?: Record<string, any>;
85
87
  }) => Record<string, any>;
88
+ /** 上传之前回调结束(开始调用上传接口) */
89
+ beforeUploadEnd?: (file: File | Blob) => void;
86
90
  /** 响应处理(启用必传) */
87
91
  handlerResponse?: (response: any) => {
88
92
  url?: string;
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.1.0",
5
+ "version": "0.1.1",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",