@keyblade/tinymce-editor-vue2 0.0.12-alpha.36 → 0.0.12-alpha.37

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 +75 -75
  2. package/package.json +1 -1
package/es/editor.vue2.js CHANGED
@@ -1,11 +1,11 @@
1
- import { defineComponent as xe, ref as h, computed as A, watch as S, onMounted as we, onUnmounted as be } from "vue";
2
- import { oneTravelImgPondOnExceed as G, oneTravelImgPondBeforeAddFile as J, oneTravelImageCheckAndTransform as ye, oneTravelImageCompressor as K } from "@keyblade/one-travel";
3
- import { blobToFile as Q, getFileExtension as X, getImagePixel as _e } from "./util.js";
1
+ import { defineComponent as he, ref as h, computed as T, watch as I, onMounted as xe, onUnmounted as we } from "vue";
2
+ import { oneTravelImgPondBeforeAddFile as G, oneTravelImageCheckAndTransform as be, oneTravelImageCompressor as J } from "@keyblade/one-travel";
3
+ import { blobToFile as K, getFileExtension as Q, getImagePixel as ye } from "./util.js";
4
4
  import "./style.less.js";
5
- import Te from "imgpond";
6
- import { conclude as C } from "vue-global-config";
7
- import Y from "tinymce";
8
- import Ae from "./langs/zh_CN.js";
5
+ import _e from "imgpond";
6
+ import { conclude as A } from "vue-global-config";
7
+ import X from "tinymce";
8
+ import Te 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 P } from "./index.js";
37
+ import { globalProps as C } from "./index.js";
38
38
  import { Message as b } from "element-ui";
39
- const da = /* @__PURE__ */ xe({
39
+ const ua = /* @__PURE__ */ he({
40
40
  __name: "editor",
41
41
  props: {
42
42
  value: { default: "" },
@@ -50,9 +50,9 @@ const da = /* @__PURE__ */ xe({
50
50
  initComplete: null
51
51
  },
52
52
  emits: ["input"],
53
- setup(Z, { emit: k }) {
54
- const m = Z;
55
- Y.addI18n("zh_CN", Ae);
53
+ setup(Y, { emit: k }) {
54
+ const m = Y;
55
+ X.addI18n("zh_CN", Te);
56
56
  const z = {
57
57
  maxCount: 10,
58
58
  tipText: "上传",
@@ -71,15 +71,15 @@ const da = /* @__PURE__ */ xe({
71
71
  enable: !0,
72
72
  maxSize: 200,
73
73
  allowedType: ["mp3", "m4a", "wav", "aac"]
74
- }, B = h(), w = h(), D = h(!1), M = h(!1), f = h({
74
+ }, B = h(), w = h(), P = h(!1), D = h(!1), f = h({
75
75
  show: !1,
76
76
  text: "图片上传中,请稍等"
77
- }), d = A(() => C([m.imageUploadOptions, P.imageUploadOptions, z]) || {}), c = A(() => C([m.videoUploadOptions, P.videoUploadOptions, H]) || {}), g = A(() => C([m.audioUploadOptions, P.audioUploadOptions, V]) || {}), U = A(() => C([m.imgPondOptions, P.imgPondOptions]) || {}), ee = A(() => {
77
+ }), d = T(() => A([m.imageUploadOptions, C.imageUploadOptions, z]) || {}), c = T(() => A([m.videoUploadOptions, C.videoUploadOptions, H]) || {}), g = T(() => A([m.audioUploadOptions, C.audioUploadOptions, V]) || {}), U = T(() => A([m.imgPondOptions, C.imgPondOptions]) || {}), Z = T(() => {
78
78
  var e, i;
79
79
  return ((i = (e = d == null ? void 0 : d.value) == null ? void 0 : e.allowedType) == null ? void 0 : i.map((o) => `.${o}`).join(",")) || "";
80
- }), y = h();
81
- S(() => y.value, () => {
82
- y.value && (G(y.value), J(y.value, {
80
+ }), M = h();
81
+ I(() => M.value, () => {
82
+ M.value && G(M.value, {
83
83
  onStart: () => {
84
84
  f.value = {
85
85
  show: !0,
@@ -92,11 +92,11 @@ const da = /* @__PURE__ */ xe({
92
92
  onError: (e) => {
93
93
  f.value.show = !1, b.error(e);
94
94
  }
95
- }));
95
+ });
96
96
  }, { immediate: !0 });
97
- const I = h();
98
- S(() => I.value, () => {
99
- I.value && (G(y.value), J(I.value, {
97
+ const S = h();
98
+ I(() => S.value, () => {
99
+ S.value && G(S.value, {
100
100
  onStart: () => {
101
101
  f.value = {
102
102
  show: !0,
@@ -109,25 +109,25 @@ const da = /* @__PURE__ */ xe({
109
109
  onError: (e) => {
110
110
  f.value.show = !1, b.error(e);
111
111
  }
112
- }));
112
+ });
113
113
  }, { immediate: !0 });
114
- const T = h({
114
+ const _ = h({
115
115
  dialogVisible: !1,
116
116
  formData: {
117
117
  images: []
118
118
  }
119
- }), E = h(), R = () => {
120
- T.value.dialogVisible = !1, T.value.formData = {
119
+ }), R = h(), W = () => {
120
+ _.value.dialogVisible = !1, _.value.formData = {
121
121
  images: []
122
122
  };
123
- }, ae = () => {
123
+ }, ee = () => {
124
124
  var e;
125
- (e = E.value) == null || e.validate((i) => {
126
- i && (T.value.formData.images.forEach((o) => {
125
+ (e = R.value) == null || e.validate((i) => {
126
+ i && (_.value.formData.images.forEach((o) => {
127
127
  var t;
128
128
  let a = o;
129
129
  U.value.srcAt && (a = (o == null ? void 0 : o[U.value.srcAt]) || ""), (t = w.value) == null || t.insertContent(`<img src=${a} alt="" />`);
130
- }), R());
130
+ }), W());
131
131
  });
132
132
  }, v = h({
133
133
  dialogVisible: !1,
@@ -141,15 +141,15 @@ const da = /* @__PURE__ */ xe({
141
141
  },
142
142
  // 用于临时保存上传前的参数 { file: File }
143
143
  additionalData: {}
144
- }), W = h(), $ = () => {
144
+ }), E = h(), $ = () => {
145
145
  v.value.dialogVisible = !1, v.value.formData = {
146
146
  name: "",
147
147
  cover: [],
148
148
  file: []
149
149
  }, v.value.additionalData = {};
150
- }, te = () => {
150
+ }, ae = () => {
151
151
  var e;
152
- (e = W.value) == null || e.validate((i) => {
152
+ (e = E.value) == null || e.validate((i) => {
153
153
  var o, a;
154
154
  i && ((a = w.value) == null || a.insertContent(`<audio controls data-name="${v.value.formData.name}" data-poster="${v.value.formData.cover[0]}" src="${(o = v.value.formData.file[0]) == null ? void 0 : o.url}"></audio>`), $());
155
155
  });
@@ -165,26 +165,26 @@ const da = /* @__PURE__ */ xe({
165
165
  x.value.dialogVisible = !1, x.value.formData = {
166
166
  file: []
167
167
  }, x.value.additionalData = {};
168
- }, oe = () => {
168
+ }, te = () => {
169
169
  var e;
170
170
  (e = j.value) == null || e.validate((i) => {
171
171
  var o, a;
172
172
  i && ((a = w.value) == null || a.insertContent(`<video controls controlslist="nodownload" src="${(o = x.value.formData.file[0]) == null ? void 0 : o.url}"></video>`), q());
173
173
  });
174
- }, ie = () => {
174
+ }, oe = () => {
175
175
  document.querySelectorAll(".swal2-container .swal2-title").forEach((e) => {
176
176
  e && (e.innerHTML = `单次最多可选择${d.value.maxCount}张图片`);
177
177
  });
178
- }, le = (e, i) => new Promise(async (o, a) => {
178
+ }, ie = (e, i) => new Promise(async (o, a) => {
179
179
  var r, l;
180
- const t = await K(e);
180
+ const t = await J(e);
181
181
  if (!t.success) {
182
182
  a(), setTimeout(() => {
183
183
  i.onError(t.errorMessage);
184
184
  });
185
185
  return;
186
186
  }
187
- const n = await ((l = (r = d.value).handleRequest) == null ? void 0 : l.call(r, Q(t.file, e.name), e.name, { extParameters: m.extParameters }));
187
+ const n = await ((l = (r = d.value).handleRequest) == null ? void 0 : l.call(r, K(t.file, e.name), e.name, { extParameters: m.extParameters }));
188
188
  if (!n || !(n != null && n.success)) {
189
189
  a(), setTimeout(() => {
190
190
  i.onError(n == null ? void 0 : n.errorMessage);
@@ -201,12 +201,12 @@ const da = /* @__PURE__ */ xe({
201
201
  if (s.startsWith("data:image"))
202
202
  (o = l == null ? void 0 : l.remove) == null || o.call(l);
203
203
  else if (s.startsWith("http://") || s.startsWith("https://")) {
204
- const u = await _e(s);
204
+ const u = await ye(s);
205
205
  if (u && (u.width < (d.value.minWidth || 0) && u.height < (d.value.minHeight || 0) || u.width > (d.value.maxWidth || 0) && u.height > (d.value.maxHeight || 0))) {
206
206
  (a = l == null ? void 0 : l.remove) == null || a.call(l);
207
207
  return;
208
208
  }
209
- const p = X(s);
209
+ const p = Q(s);
210
210
  if (!((n = (t = d.value) == null ? void 0 : t.allowedType) != null && n.includes(p.toLowerCase()))) {
211
211
  (r = l == null ? void 0 : l.remove) == null || r.call(l);
212
212
  return;
@@ -214,7 +214,7 @@ const da = /* @__PURE__ */ xe({
214
214
  }
215
215
  }
216
216
  }
217
- we(() => {
217
+ xe(() => {
218
218
  var o;
219
219
  const e = {
220
220
  // 设置语言
@@ -306,8 +306,8 @@ const da = /* @__PURE__ */ xe({
306
306
  },
307
307
  images_upload_handler(a) {
308
308
  return new Promise(async (t, n) => {
309
- var _, N, O;
310
- if (!((_ = d.value) != null && _.handleRequest))
309
+ var y, N, O;
310
+ if (!((y = d.value) != null && y.handleRequest))
311
311
  return n({ message: "缺少图片上传配置", remove: !0 });
312
312
  f.value = {
313
313
  show: !0,
@@ -316,7 +316,7 @@ const da = /* @__PURE__ */ xe({
316
316
  let r = a.blob(), l = r.name ? r.name : a.filename();
317
317
  if (!(r != null && r.name) && !(r != null && r.lastModified) && r.type === "image/png")
318
318
  return f.value.show = !1, n({ message: "不允许粘贴", remove: !0 });
319
- const s = await ye(r, l, {
319
+ const s = await be(r, l, {
320
320
  imageMaxSize: d.value.maxSize,
321
321
  imageAllowedType: d.value.allowedType,
322
322
  // imageAllowedMineType: mergeImageUploadOptions.value.allowedMineType,
@@ -332,10 +332,10 @@ const da = /* @__PURE__ */ xe({
332
332
  const L = l == null ? void 0 : l.split(".");
333
333
  L.pop(), l = `${L.join(",")}.jpg`;
334
334
  }
335
- const u = await K(r);
335
+ const u = await J(r);
336
336
  if (!u.success)
337
337
  return f.value.show = !1, n({ message: u == null ? void 0 : u.errorMessage, remove: !0 });
338
- const p = await ((O = (N = d.value).handleRequest) == null ? void 0 : O.call(N, Q(u.file, l), l, { extParameters: m.extParameters }));
338
+ const p = await ((O = (N = d.value).handleRequest) == null ? void 0 : O.call(N, K(u.file, l), l, { extParameters: m.extParameters }));
339
339
  if (!p || !p.success)
340
340
  return f.value.show = !1, n({ message: p.errorMessage, remove: !0 });
341
341
  f.value.show = !1, t(p.url);
@@ -344,7 +344,7 @@ const da = /* @__PURE__ */ xe({
344
344
  setup(a) {
345
345
  var n, r;
346
346
  const t = () => {
347
- T.value.dialogVisible = !0, setTimeout(() => {
347
+ _.value.dialogVisible = !0, setTimeout(() => {
348
348
  var s, u;
349
349
  const l = (s = document == null ? void 0 : document.querySelector) == null ? void 0 : s.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
350
350
  l && (l.innerHTML = ((u = d.value) == null ? void 0 : u.tipText) || "上传");
@@ -391,10 +391,10 @@ const da = /* @__PURE__ */ xe({
391
391
  });
392
392
  }
393
393
  }
394
- }, i = C(
394
+ }, i = A(
395
395
  [
396
396
  m.options,
397
- P.options,
397
+ C.options,
398
398
  e
399
399
  ],
400
400
  {
@@ -404,44 +404,44 @@ const da = /* @__PURE__ */ xe({
404
404
  type: Object
405
405
  }
406
406
  );
407
- Y.init(i).then(([a]) => {
407
+ X.init(i).then(([a]) => {
408
408
  var t;
409
409
  a && (a.customProps = { ...m }, a.on("change input Redo Undo SetContent", () => {
410
- if (M.value) {
411
- M.value = !1;
410
+ if (D.value) {
411
+ D.value = !1;
412
412
  return;
413
413
  }
414
- D.value = !0, k("input", a.getContent());
414
+ P.value = !0, k("input", a.getContent());
415
415
  }), a.on("paste", (n) => {
416
416
  var l, s;
417
417
  const r = ((l = n.clipboardData) == null ? void 0 : l.files) || [];
418
418
  for (let u of r) {
419
- const p = X(u.name) || "";
419
+ const p = Q(u.name) || "";
420
420
  (s = d.value.allowedType) != null && s.includes(p.toLowerCase()) || n.preventDefault();
421
421
  }
422
422
  }), (t = m.initComplete) == null || t.call(m, { editorIns: a }), w.value = a);
423
423
  });
424
- }), be(() => {
424
+ }), we(() => {
425
425
  var e;
426
426
  (e = w.value) == null || e.destroy();
427
427
  });
428
- const ne = () => {
428
+ const le = () => {
429
429
  var i, o;
430
430
  const e = { ...v.value.additionalData || {} };
431
431
  return ((o = (i = g.value) == null ? void 0 : i.data) == null ? void 0 : o.call(i, { file: e, extParameters: m.extParameters })) || {};
432
- }, re = () => {
432
+ }, ne = () => {
433
433
  var i, o;
434
434
  const e = { ...v.value.additionalData || {} };
435
435
  return ((o = (i = g.value) == null ? void 0 : i.headers) == null ? void 0 : o.call(i, { file: e, extParameters: m.extParameters })) || {};
436
- }, se = (e, i, o) => {
436
+ }, re = (e, i, o) => {
437
437
  var t, n;
438
438
  const a = (n = (t = g == null ? void 0 : g.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t, e);
439
439
  a != null && a.url ? o[o.length - 1].url = a.url : a != null && a.errorMessage && (b.error(a.errorMessage), o.splice(o.length - 1, 1)), v.value.formData.file = o;
440
- }, ue = (e, i) => new Promise((o, a) => {
440
+ }, se = (e, i) => new Promise((o, a) => {
441
441
  var n, r, l, s, u, p;
442
442
  const t = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
443
443
  if (!((r = (n = g.value) == null ? void 0 : n.allowedType) != null && r.includes(t.toLowerCase()))) {
444
- b.error(`请上传格式为${(s = (l = g.value) == null ? void 0 : l.allowedType) == null ? void 0 : s.map((_) => _.toUpperCase()).join("、")}的音频`), a();
444
+ b.error(`请上传格式为${(s = (l = g.value) == null ? void 0 : l.allowedType) == null ? void 0 : s.map((y) => y.toUpperCase()).join("、")}的音频`), a();
445
445
  return;
446
446
  }
447
447
  if (e.size > (((u = g.value) == null ? void 0 : u.maxSize) || 0) * 1024 * 1024) {
@@ -449,27 +449,27 @@ const da = /* @__PURE__ */ xe({
449
449
  return;
450
450
  }
451
451
  v.value.additionalData = { file: e }, o(!0);
452
- }), de = (e, i) => {
452
+ }), ue = (e, i) => {
453
453
  v.value.formData.file = i;
454
- }, me = (e, i, o) => {
454
+ }, de = (e, i, o) => {
455
455
  b.error("上传发生错误,请重试!"), v.value.formData.file = o;
456
- }, ce = () => {
456
+ }, me = () => {
457
457
  var i, o;
458
458
  const e = { ...x.value.additionalData || {} };
459
459
  return ((o = (i = c.value) == null ? void 0 : i.data) == null ? void 0 : o.call(i, { file: e, extParameters: m.extParameters })) || {};
460
- }, pe = () => {
460
+ }, ce = () => {
461
461
  var i, o;
462
462
  const e = { ...x.value.additionalData || {} };
463
463
  return ((o = (i = c.value) == null ? void 0 : i.headers) == null ? void 0 : o.call(i, { file: e, extParameters: m.extParameters })) || {};
464
- }, ve = (e, i, o) => {
464
+ }, pe = (e, i, o) => {
465
465
  var t, n;
466
466
  const a = (n = (t = c == null ? void 0 : c.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t, e);
467
467
  a != null && a.url ? o[o.length - 1].url = a.url : a != null && a.errorMessage && (b.error(a.errorMessage), o.splice(o.length - 1, 1)), x.value.formData.file = o;
468
- }, fe = (e, i) => new Promise((o, a) => {
468
+ }, ve = (e, i) => new Promise((o, a) => {
469
469
  var n, r, l, s, u, p;
470
470
  const t = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
471
471
  if (!((r = (n = c == null ? void 0 : c.value) == null ? void 0 : n.allowedType) != null && r.includes(t.toLowerCase()))) {
472
- b.error(`请上传格式为${(s = (l = c == null ? void 0 : c.value) == null ? void 0 : l.allowedType) == null ? void 0 : s.map((_) => _.toUpperCase()).join("、")}的视频`), a();
472
+ b.error(`请上传格式为${(s = (l = c == null ? void 0 : c.value) == null ? void 0 : l.allowedType) == null ? void 0 : s.map((y) => y.toUpperCase()).join("、")}的视频`), a();
473
473
  return;
474
474
  }
475
475
  if (e.size > (((u = c == null ? void 0 : c.value) == null ? void 0 : u.maxSize) || 0) * 1024 * 1024) {
@@ -477,28 +477,28 @@ const da = /* @__PURE__ */ xe({
477
477
  return;
478
478
  }
479
479
  x.value.additionalData = { file: e }, o(!0);
480
- }), ge = (e, i) => {
480
+ }), fe = (e, i) => {
481
481
  x.value.formData.file = i;
482
- }, he = (e, i, o) => {
482
+ }, ge = (e, i, o) => {
483
483
  b.error("上传发生错误,请重试!"), x.value.formData.file = o;
484
484
  };
485
- return S(() => [m.disabled, w.value], () => {
485
+ return I(() => [m.disabled, w.value], () => {
486
486
  var e, i;
487
487
  (i = (e = w.value) == null ? void 0 : e.mode) == null || i.set(m.disabled ? "readonly" : "design");
488
- }, { immediate: !0 }), S(
488
+ }, { immediate: !0 }), I(
489
489
  () => [m.value, w.value],
490
490
  () => {
491
491
  var e;
492
- if (D.value) {
493
- D.value = !1;
492
+ if (P.value) {
493
+ P.value = !1;
494
494
  return;
495
495
  }
496
- M.value = !0, (e = w.value) == null || e.setContent(m.value ? m.value : "");
496
+ D.value = !0, (e = w.value) == null || e.setContent(m.value ? m.value : "");
497
497
  },
498
498
  { immediate: !0 }
499
- ), { __sfc: !0, defaultImageUploadOptions: z, defaultVideoUploadOptions: H, defaultAudioUploadOptions: V, props: m, emits: k, insRef: B, editorRef: w, preventSettingContent: D, preventUpdatingModelValue: M, uploadLoadingConfig: f, mergeImageUploadOptions: d, mergeVideoUploadOptions: c, mergeAudioUploadOptions: g, mergeImgPondOptions: U, imgPondAccept: ee, uploadImageImgPondRef: y, audioImageImgPondRef: I, uploadImage: T, uploadImageFormRef: E, onUploadImageClose: R, onUploadImageConfirm: ae, uploadAudio: v, uploadAudioFormRef: W, onUploadAudioClose: $, onUploadAudioConfirm: te, uploadVideo: x, uploadVideoFormRef: j, onUploadVideoClose: q, onUploadVideoConfirm: oe, onImageUploadUploadExceed: ie, onImageUploadUpload: le, processPastedImage: F, 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: Te };
499
+ ), { __sfc: !0, defaultImageUploadOptions: z, defaultVideoUploadOptions: H, defaultAudioUploadOptions: V, props: m, emits: k, insRef: B, editorRef: w, preventSettingContent: P, preventUpdatingModelValue: D, uploadLoadingConfig: f, mergeImageUploadOptions: d, mergeVideoUploadOptions: c, mergeAudioUploadOptions: g, mergeImgPondOptions: U, imgPondAccept: Z, uploadImageImgPondRef: M, audioImageImgPondRef: S, uploadImage: _, uploadImageFormRef: R, onUploadImageClose: W, onUploadImageConfirm: ee, uploadAudio: v, uploadAudioFormRef: E, onUploadAudioClose: $, onUploadAudioConfirm: ae, uploadVideo: x, uploadVideoFormRef: j, onUploadVideoClose: q, onUploadVideoConfirm: te, onImageUploadUploadExceed: oe, onImageUploadUpload: ie, processPastedImage: F, getUploadAudioData: le, getUploadAudioHeaders: ne, onUploadAudioSuccess: re, onUploadAudioBeforeUpload: se, onUploadAudioRemove: ue, onUploadAudioError: de, getUploadVideoData: me, getUploadVideoHeaders: ce, onUploadVideoSuccess: pe, onUploadVideoBeforeUpload: ve, onUploadVideoRemove: fe, onUploadVideoError: ge, ImgPond: _e };
500
500
  }
501
501
  });
502
502
  export {
503
- da as default
503
+ ua as default
504
504
  };
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.36",
5
+ "version": "0.0.12-alpha.37",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",