@keyblade/tinymce-editor-vue2 0.0.12-alpha.8 → 0.1.0

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/es/editor.vue2.js CHANGED
@@ -1,9 +1,41 @@
1
- import { defineComponent as ue, ref as m, computed as w, onMounted as me, onUnmounted as pe, watch as R } from "vue";
2
- import { oneTravelImageCheck as E, oneTravelImageCompressor as O, getImagePixel as ce } from "./util.js";
3
- import ge from "imgpond";
4
- import { conclude as M } from "vue-global-config";
5
- import I from "tinymce";
6
- import fe from "./langs/zh_CN.js";
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) => {
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) => {
16
+ try {
17
+ m(i.next(h));
18
+ } catch (T) {
19
+ M(T);
20
+ }
21
+ }, k = (h) => {
22
+ try {
23
+ m(i.throw(h));
24
+ } catch (T) {
25
+ M(T);
26
+ }
27
+ }, m = (h) => h.done ? I(h.value) : Promise.resolve(h.value).then(P, k);
28
+ m((i = i.apply(u, n)).next());
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";
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";
7
39
  import "tinymce/skins/ui/oxide/skin";
8
40
  import "tinymce/models/dom";
9
41
  import "tinymce/themes/silver";
@@ -18,6 +50,8 @@ import "tinymce/plugins/directionality";
18
50
  import "tinymce/plugins/emoticons";
19
51
  import "tinymce/plugins/emoticons/js/emojis.min";
20
52
  import "tinymce/plugins/fullscreen";
53
+ import "tinymce/plugins/help";
54
+ import "tinymce/plugins/help/js/i18n/keynav/zh_CN";
21
55
  import "tinymce/plugins/image";
22
56
  import "tinymce/plugins/insertdatetime";
23
57
  import "tinymce/plugins/link";
@@ -32,61 +66,103 @@ import "tinymce/plugins/table";
32
66
  import "tinymce/plugins/visualblocks";
33
67
  import "tinymce/plugins/visualchars";
34
68
  import "tinymce/plugins/wordcount";
35
- import { globalProps as x } from "./index.js";
36
- import { Loading as ve, Message as v } from "element-ui";
37
- const Ze = /* @__PURE__ */ ue({
69
+ import { globalProps as F } from "./index.js";
70
+ import { Message as g } from "element-ui";
71
+ const Va = /* @__PURE__ */ je({
38
72
  __name: "editor",
39
73
  props: {
40
74
  value: { default: "" },
41
- modelValue: { default: "" },
42
- disabled: { type: Boolean },
43
- extParameters: null,
44
- imageUploadMaxCount: { default: 2 },
45
- imageUploadTip: { default: "上传" },
46
- imageMaxSize: { default: 30 },
47
- imageAllowedType: { default: () => ["jpg", "jpeg", "png", "bmp", "heif", "gif", "webp"] },
48
- imageAllowedMineType: { default: () => ["image/jpg", "image/jpeg", "image/png", "image/bmp", "image/heif", "image/heic", "image/gif", "image/webp"] },
49
- imageMinWidth: { default: 60 },
50
- imageMinHeight: { default: 60 },
51
- imageMaxWidth: { default: 6e3 },
52
- imageMaxHeight: { default: 6e3 },
53
- audioEnable: { type: Boolean, default: !0 },
54
- audioMaxSize: { default: 200 },
55
- audioAllowedType: { default: () => ["MP3", "M4A", "WAV", "AAC"] },
75
+ disabled: { type: Boolean, default: !1 },
76
+ extParameters: { default: () => ({}) },
77
+ options: { default: () => ({}) },
78
+ imageUploadOptions: null,
79
+ imgPondOptions: null,
56
80
  audioUploadOptions: null,
57
- videoEnable: { type: Boolean, default: !0 },
58
- videoMaxSize: { default: 300 },
59
- videoAllowedType: { default: () => ["MP4", "3GP"] },
60
81
  videoUploadOptions: null,
61
- imageUploadHandle: null,
62
- paste_preprocess: null,
63
- paste_postprocess: null,
64
- initComplete: null,
65
- options: { default: () => ({}) },
66
- imgPondOptions: null
82
+ initComplete: null
67
83
  },
68
- emits: ["input", "update:modelValue"],
69
- setup(F, { emit: C }) {
70
- const a = F;
71
- I.addI18n("zh_CN", fe);
72
- const P = m(), u = m(), A = m(!1), U = m(!1), c = m({
84
+ emits: ["input"],
85
+ setup(u, { emit: n }) {
86
+ const i = u;
87
+ de.addI18n("zh_CN", Oe);
88
+ const I = {
89
+ maxCount: 10,
90
+ tipText: "上传",
91
+ maxSize: 30,
92
+ allowedType: ["jpg", "jpeg", "png", "bmp", "heif", "heic", "gif", "webp"],
93
+ minWidth: 50,
94
+ minHeight: 50,
95
+ maxWidth: 6e3,
96
+ maxHeight: 6e3
97
+ }, M = {
98
+ enable: !0,
99
+ maxSize: 300,
100
+ allowedType: ["avi", "wmv", "mp4", "mov", "3gp"],
101
+ accept: ".avi,.wmv,.mp4,.mov,.3gp"
102
+ }, P = {
103
+ enable: !0,
104
+ maxSize: 200,
105
+ allowedType: ["wav", "mp3", "mp4", "m4a", "wma", "aac"],
106
+ accept: ".wav,.mp3,.mp4,.m4a,.wma,.aac"
107
+ }, k = y(), m = y(), h = y(!1), T = y(!1), A = y({
108
+ show: !1,
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(() => {
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, {
116
+ onStart: () => {
117
+ A.value = {
118
+ show: !0,
119
+ text: "图片加载中,请稍等"
120
+ };
121
+ },
122
+ onSuccess: () => {
123
+ A.value.show = !1;
124
+ },
125
+ onError: (e) => {
126
+ A.value.show = !1, g.error({ message: e, customClass: "tinymce-editor-message", duration: 3e3 });
127
+ }
128
+ });
129
+ }, { immediate: !0 });
130
+ const W = y();
131
+ O(() => W.value, () => {
132
+ W.value && se(W.value, {
133
+ onStart: () => {
134
+ A.value = {
135
+ show: !0,
136
+ text: "图片加载中,请稍等"
137
+ };
138
+ },
139
+ onSuccess: () => {
140
+ A.value.show = !1;
141
+ },
142
+ onError: (e) => {
143
+ A.value.show = !1, g.error(e);
144
+ }
145
+ });
146
+ }, { immediate: !0 });
147
+ const B = y({
73
148
  dialogVisible: !1,
74
149
  formData: {
75
150
  images: []
76
151
  }
77
- }), S = m(), q = () => {
78
- c.value.dialogVisible = !1, c.value.formData = {
152
+ }), J = y(), K = () => {
153
+ H = [], B.value.dialogVisible = !1, B.value.formData = {
79
154
  images: []
80
155
  };
81
- }, N = () => {
82
- var o;
83
- (o = S.value) == null || o.validate((l) => {
84
- l && (c.value.formData.images.forEach((t) => {
85
- var e;
86
- (e = u.value) == null || e.insertContent(`<img src=${t} alt="" />`);
87
- }), c.value.dialogVisible = !1, c.value.formData.images = []);
156
+ }, pe = () => {
157
+ var e;
158
+ H = [], (e = J.value) == null || e.validate((a) => {
159
+ a && (B.value.formData.images.forEach((o) => {
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());
88
164
  });
89
- }, r = m({
165
+ }, w = y({
90
166
  dialogVisible: !1,
91
167
  formData: {
92
168
  // 名称
@@ -98,23 +174,19 @@ const Ze = /* @__PURE__ */ ue({
98
174
  },
99
175
  // 用于临时保存上传前的参数 { file: File }
100
176
  additionalData: {}
101
- }), k = m(), j = () => {
102
- var o;
103
- (o = k.value) == null || o.validate((l) => {
104
- var t, e;
105
- l && ((e = u.value) == null || e.insertContent(`<audio controls data-name="${r.value.formData.name}" data-poster="${r.value.formData.cover[0]}" src="${(t = r.value.formData.file[0]) == null ? void 0 : t.url}"></audio>`), r.value.dialogVisible = !1, r.value.formData = {
106
- name: "",
107
- cover: [],
108
- file: []
109
- }, r.value.additionalData = {});
110
- });
111
- }, G = () => {
112
- r.value.dialogVisible = !1, r.value.formData = {
177
+ }), Q = y(), Y = () => {
178
+ w.value.dialogVisible = !1, w.value.formData = {
113
179
  name: "",
114
180
  cover: [],
115
181
  file: []
116
- }, r.value.additionalData = {};
117
- }, s = m({
182
+ }, w.value.additionalData = {};
183
+ }, fe = () => {
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());
188
+ });
189
+ }, _ = y({
118
190
  dialogVisible: !1,
119
191
  formData: {
120
192
  // 文件
@@ -122,89 +194,183 @@ const Ze = /* @__PURE__ */ ue({
122
194
  },
123
195
  // 用于临时保存上传前的参数 { file: File }
124
196
  additionalData: {}
125
- }), z = m(), L = () => {
126
- var o;
127
- (o = z.value) == null || o.validate((l) => {
128
- var t, e;
129
- l && ((e = u.value) == null || e.insertContent(`<video controls controlslist="nodownload" src="${(t = s.value.formData.file[0]) == null ? void 0 : t.url}"></video>`), s.value.dialogVisible = !1, s.value.formData = {
130
- file: []
131
- }, s.value.additionalData = {});
132
- });
133
- }, J = () => {
134
- s.value.dialogVisible = !1, s.value.formData = {
197
+ }), Z = y(), ee = () => {
198
+ _.value.dialogVisible = !1, _.value.formData = {
135
199
  file: []
136
- }, s.value.additionalData = {};
137
- }, K = (o, l) => new Promise(async (t, e) => {
138
- var h;
139
- const i = await E(o, {
140
- imageMaxSize: a.imageMaxSize,
141
- imageAllowedMineType: a.imageAllowedMineType,
142
- imageMinWidth: a.imageMinWidth,
143
- imageMinHeight: a.imageMinHeight,
144
- imageMaxWidth: a.imageMaxWidth,
145
- imageMaxHeight: a.imageMaxHeight
200
+ }, _.value.additionalData = {};
201
+ }, ve = () => {
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());
206
+ });
207
+ }, ge = () => {
208
+ document.querySelectorAll(".swal2-container .swal2-title").forEach((e) => {
209
+ e && (e.innerHTML = `单次最多可选择${s.value.maxCount}张图片`);
146
210
  });
147
- if (!i.success) {
148
- e(), setTimeout(() => {
149
- var p, f, _;
150
- (p = i.error) != null && p.size ? l.onError(`请上传大小不超过${a.imageMaxSize}M的图片`) : (f = i.error) != null && f.format ? l.onError(`请上传格式为${a.imageAllowedType.map((D) => D.toUpperCase()).join("、")}的图片`) : (_ = i.error) != null && _.pixel && l.onError(`请上传像素不低于${a.imageMinWidth}*${a.imageMinHeight}且像素不高于${a.imageMaxWidth}*${a.imageMaxHeight}的图片`);
211
+ };
212
+ let H = [];
213
+ const he = (e, a) => new Promise((o, t) => N(this, null, function* () {
214
+ var f, v;
215
+ if (H.find((c) => (c == null ? void 0 : c.uid) === (e == null ? void 0 : e.uid)))
216
+ return setTimeout(() => {
217
+ document.querySelectorAll(".swal2-container").forEach((c) => {
218
+ c == null || c.remove();
219
+ });
220
+ }), t("");
221
+ H.push(e);
222
+ const l = yield ue(e);
223
+ if (!l.success) {
224
+ t(), setTimeout(() => {
225
+ a.onError(l.errorMessage);
151
226
  });
152
227
  return;
153
228
  }
154
- const n = await O(o);
155
- if (!n.success) {
156
- e(), setTimeout(() => {
157
- l.onError(n.errorMessage);
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);
158
233
  });
159
234
  return;
160
235
  }
161
- const d = await ((h = g.value) == null ? void 0 : h.call(g, n.file, o.name, { extParameters: a.extParameters }));
162
- if (!d.success) {
163
- e(), setTimeout(() => {
164
- l.onError(d.errorMessage);
236
+ o(d.url);
237
+ }));
238
+ function ae(e) {
239
+ return N(this, null, function* () {
240
+ var d, f, v;
241
+ let a = e;
242
+ if (!((d = s.value) != null && d.handleRequest)) {
243
+ g.error("缺少图片上传配置");
244
+ return;
245
+ }
246
+ let o = a.name ? a.name : "";
247
+ if (!(a != null && a.name) && !(a != null && a.lastModified) && a.type === "image/png") {
248
+ g.error("不允许粘贴");
249
+ return;
250
+ }
251
+ const t = yield Fe(a, o, {
252
+ imageMaxSize: s.value.maxSize,
253
+ imageAllowedType: s.value.allowedType,
254
+ // imageAllowedMineType: mergeImageUploadOptions.value.allowedMineType,
255
+ imageMinWidth: s.value.minWidth,
256
+ imageMinHeight: s.value.minHeight,
257
+ imageMaxWidth: s.value.maxWidth,
258
+ imageMaxHeight: s.value.maxHeight
165
259
  });
166
- return;
260
+ if (!t.success) {
261
+ g.error((t == null ? void 0 : t.errorMessage) || "");
262
+ return;
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`;
268
+ }
269
+ const r = yield ue(a);
270
+ if (!r.success) {
271
+ g.error((r == null ? void 0 : r.errorMessage) || "压缩失败");
272
+ return;
273
+ }
274
+ const l = yield (v = (f = s.value).handleRequest) == null ? void 0 : v.call(f, me(r.file, o), o, { extParameters: i.extParameters });
275
+ if (!l || !l.success) {
276
+ g.error((l == null ? void 0 : l.errorMessage) || "");
277
+ return;
278
+ }
279
+ return l.url;
280
+ });
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 = {
288
+ show: !0,
289
+ text: "图片加载中,请稍等"
290
+ });
291
+ for (const D of [...Ue, ...Ie])
292
+ D == null || D.remove();
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"))
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();
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();
303
+ }
304
+ else
305
+ D.remove(), g.error("不支持Word中批量复制图片或视频,请改为单个复制,或者从工具栏中手动插入上传");
306
+ }
307
+ } catch (c) {
308
+ S = [c];
309
+ } finally {
310
+ try {
311
+ v && (c = f.return) && (yield c.call(f));
312
+ } finally {
313
+ if (S)
314
+ throw S[0];
315
+ }
316
+ }
317
+ A.value.show = !1;
318
+ const ke = new XMLSerializer().serializeToString(V.body);
319
+ a.insertContent(ke);
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) {
324
+ if (!U)
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("暂不支持的文件类型");
167
328
  }
168
- t(d.url);
169
- });
170
- async function H(o) {
171
- var t, e;
172
- const l = o.getElementsByTagName("img");
173
- for (let i of l) {
174
- const n = i.src;
175
- if (n.startsWith("http://") || n.startsWith("https://")) {
176
- const d = await ce(n);
177
- if (d.width < a.imageMinWidth && d.height < a.imageMinHeight || d.width > a.imageMaxWidth && d.height > a.imageMaxHeight) {
178
- (t = i == null ? void 0 : i.remove) == null || t.call(i);
179
- return;
329
+ if (r.length > 0) {
330
+ A.value = {
331
+ show: !0,
332
+ text: "图片上传中,请稍等"
333
+ };
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);
341
+ }
180
342
  }
181
- const h = n.split("."), p = h[h.length - 1].toLowerCase();
182
- if (!a.imageAllowedType.includes(p)) {
183
- (e = i == null ? void 0 : i.remove) == null || e.call(i);
184
- return;
343
+ } catch (Ea) {
344
+ $a = [Ea];
345
+ } finally {
346
+ try {
347
+ ja && (Ea = qa.return) && (yield Ea.call(qa));
348
+ } finally {
349
+ if ($a)
350
+ throw $a[0];
185
351
  }
186
352
  }
353
+ A.value.show = !1;
187
354
  }
188
- }
189
- const b = w(() => M([a.videoUploadOptions, x.videoUploadOptions]) || {}), y = w(() => M([a.audioUploadOptions, x.audioUploadOptions]) || {}), Q = w(() => M([a.imgPondOptions, x.imgPondOptions]) || {}), T = w(
190
- () => M([a.paste_preprocess, x.paste_preprocess], {
191
- type: Function
192
- })
193
- ), V = w(
194
- () => M([a.paste_postprocess, x.paste_postprocess], {
195
- type: Function
196
- })
197
- ), g = w(
198
- () => M([a.imageUploadHandle, x.imageUploadHandle], {
199
- type: Function
200
- })
201
- );
202
- me(() => {
203
- const o = {
355
+ n("input", a.getContent());
356
+ }), oe = (e) => {
357
+ var o;
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;
363
+ e.preventDefault();
364
+ const a = e.dataTransfer || ((o = e == null ? void 0 : e.originalEvent) == null ? void 0 : o.dataTransfer);
365
+ G(a);
366
+ };
367
+ Ee(() => {
368
+ var o;
369
+ const e = {
204
370
  // 设置语言
205
371
  language: "zh_CN",
206
372
  // 实例
207
- target: P.value,
373
+ target: k.value,
208
374
  // 隐藏品牌
209
375
  branding: !1,
210
376
  // 隐藏右上角升级按钮
@@ -239,7 +405,7 @@ const Ze = /* @__PURE__ */ ue({
239
405
  "directionality",
240
406
  "emoticons",
241
407
  "fullscreen",
242
- // 'help',
408
+ "help",
243
409
  "image",
244
410
  // 'importcss'
245
411
  "insertdatetime",
@@ -260,16 +426,19 @@ const Ze = /* @__PURE__ */ ue({
260
426
  menu: {
261
427
  insert: {
262
428
  title: "插入",
263
- items: "localImage localAudio localVideo | link mobilelink | template codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor toc | insertdatetime"
429
+ items: "localImage localAudio localVideo | template codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor toc | insertdatetime"
264
430
  }
265
431
  },
266
432
  toolbar_mode: "sliding",
267
433
  // 工具栏
268
- toolbar: "undo redo | bold italic underline strikethrough | fontfamily fontsize styles | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | fullscreen preview save print | localImage localAudio localVideo link anchor | ltr rtl",
434
+ toolbar: "undo redo | bold italic underline strikethrough | fontfamily fontsize styles | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | fullscreen preview save print | localImage localAudio localVideo anchor | ltr rtl",
269
435
  // 改动后刷新,不再弹 alert
270
436
  autosave_ask_before_unload: !1,
271
- // 内容样式 data-mce-bogus="all" 音频点击会出现另外一个
272
- content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }div[data-mce-bogus="all"] .mce-object-audio { display: none }div[data-mce-bogus="all"] .mce-object-video { display: none }',
437
+ content_style: 'img {max-width:100%;}video {max-width: 100%;}body { font-family:Helvetica,Arial,sans-serif; font-size:16px }div[data-mce-bogus="all"] .mce-object-audio { display: none }div[data-mce-bogus="all"] .mce-object-video { display: none }audio::-webkit-media-controls { overflow: hidden !important }audio::-webkit-media-controls-enclosure { width: calc(100% + 32px); margin-left: auto; }audio { border-radius: 50px; }video::-webkit-media-controls { overflow: hidden !important }video::-webkit-media-controls-enclosure { width: calc(100% + 42px); margin-left: auto; }video::-webkit-media-controls-timeline { width: calc(100% - 70px); }',
438
+ media_poster: !1,
439
+ media_alt_source: !1,
440
+ // 取消媒体宽高设置
441
+ media_dimensions: !1,
273
442
  // 字体大小
274
443
  font_size_formats: "8px 10px 12px 14px 16px 18px 20px 22px 24px 26px 28px 30px 32px 34px 36px 38px",
275
444
  font_size_input_default_unit: "px",
@@ -278,200 +447,169 @@ const Ze = /* @__PURE__ */ ue({
278
447
  relative_urls: !1,
279
448
  convert_urls: !1,
280
449
  paste_webkit_styles: "all",
281
- paste_data_images: !0,
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",
282
452
  // 粘贴前处理
283
- paste_preprocess(t, e) {
284
- var i;
285
- e.content = e.content.replace(/<video[^>]*(?:\/>|>[\s\S]*?<\/video>)/g, ""), e.content = e.content.replace(/<audio[^>]*(?:\/>|>[\s\S]*?<\/audio>)/g, ""), e.content = e.content.replace(/<nav/g, "<div").replace(/<\/nav>/g, "</div>"), e.content = e.content.replace(/<header/g, "<div").replace(/<\/header>/g, "</div>"), e.content = e.content.replace(/<footer/g, "<div").replace(/<\/footer>/g, "</div>"), e.content = e.content.replace(/<aside/g, "<div").replace(/<\/aside>/g, "</div>"), e.content = e.content.replace(/<section/g, "<div").replace(/<\/section>/g, "</div>"), e.content = e.content.replace(/<main/g, "<div").replace(/<\/main>/g, "</div>"), e.content = e.content.replace(/<article/g, "<div").replace(/<\/article>/g, "</div>"), e.content = e.content.replace(/<details/g, "<div").replace(/<\/details>/g, "</div>"), (i = T.value) == null || i.call(T, t, e);
286
- },
287
- // 粘贴后处理(处理异步操作)
288
- paste_postprocess(t, e) {
289
- var n;
290
- const i = e.node;
291
- H(i), (n = V.value) == null || n.call(V, t, e);
292
- },
293
- images_upload_handler(t) {
294
- return new Promise(async (e, i) => {
295
- var D, W, $, B;
296
- const n = ve.service({ text: "上传中" });
297
- let d = t.blob();
298
- const h = t.filename(), p = await E(d, {
299
- imageMaxSize: a.imageMaxSize,
300
- imageAllowedMineType: a.imageAllowedMineType,
301
- imageMinWidth: a.imageMinWidth,
302
- imageMinHeight: a.imageMinHeight,
303
- imageMaxWidth: a.imageMaxWidth,
304
- imageMaxHeight: a.imageMaxHeight
305
- });
306
- if (!p.success) {
307
- if (n == null || n.close(), (D = p.error) != null && D.size)
308
- return i({ message: `请上传大小不超过${a.imageMaxSize}M的图片`, remove: !0 });
309
- if ((W = p.error) != null && W.format)
310
- return i({ message: `请上传格式为${a.imageAllowedType.map((de) => de.toUpperCase()).join("、")}的图片`, remove: !0 });
311
- if (($ = p.error) != null && $.pixel)
312
- return i({ message: `请上传像素不低于${a.imageMinWidth}*${a.imageMinHeight}且像素不高于${a.imageMaxWidth}*${a.imageMaxHeight}的图片`, remove: !0 });
313
- }
314
- const f = await O(d);
315
- if (!f.success)
316
- return n == null || n.close(), i({ message: f == null ? void 0 : f.errorMessage, remove: !0 });
317
- if (!g.value)
318
- return n == null || n.close(), i({ message: "缺少图片上传配置", remove: !0 });
319
- const _ = await ((B = g.value) == null ? void 0 : B.call(g, f.file, h, { extParameters: a.extParameters }));
320
- if (!_.success)
321
- return n == null || n.close(), i({ message: _.errorMessage, remove: !0 });
322
- n == null || n.close(), e(_.url);
323
- });
453
+ paste_preprocess(t, r) {
454
+ r == null || r.preventDefault();
324
455
  },
325
456
  setup(t) {
326
- t.ui.registry.addMenuItem("localImage", {
457
+ var l, d;
458
+ const r = () => {
459
+ B.value.dialogVisible = !0, setTimeout(() => {
460
+ var v, c;
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) || "上传");
463
+ });
464
+ };
465
+ if (t.ui.registry.addMenuItem("localImage", {
327
466
  text: "图片",
328
467
  icon: "image",
329
- onAction: () => {
330
- c.value.dialogVisible = !0, setTimeout(() => {
331
- var i;
332
- const e = (i = document == null ? void 0 : document.querySelector) == null ? void 0 : i.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
333
- e && (e.innerHTML = a.imageUploadTip || "上传");
334
- });
335
- }
468
+ onAction: () => r()
336
469
  }), t.ui.registry.addButton("localImage", {
337
470
  icon: "image",
338
471
  tooltip: "图片",
339
- onAction: () => {
340
- c.value.dialogVisible = !0, setTimeout(() => {
341
- var i;
342
- const e = (i = document == null ? void 0 : document.querySelector) == null ? void 0 : i.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
343
- e && (e.innerHTML = a.imageUploadTip || "上传");
344
- });
345
- }
346
- }), a.audioEnable && (t.ui.registry.addMenuItem("localAudio", {
347
- text: "音频",
348
- icon: "arrow-right",
349
- onAction: () => {
350
- r.value.dialogVisible = !0, setTimeout(() => {
351
- var i;
352
- const e = (i = document == null ? void 0 : document.querySelector) == null ? void 0 : i.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
353
- e && (e.innerHTML = a.imageUploadTip || "上传");
354
- });
355
- }
356
- }), t.ui.registry.addButton("localAudio", {
357
- icon: "arrow-right",
358
- tooltip: "音频",
359
- onAction: () => {
360
- r.value.dialogVisible = !0, setTimeout(() => {
361
- var i;
362
- const e = (i = document == null ? void 0 : document.querySelector) == null ? void 0 : i.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
363
- e && (e.innerHTML = a.imageUploadTip || "上传");
472
+ onAction: () => r()
473
+ }), (l = b == null ? void 0 : b.value) != null && l.enable) {
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) || "上传");
364
479
  });
365
- }
366
- })), a.videoEnable && (t.ui.registry.addMenuItem("localVideo", {
367
- text: "视频",
368
- icon: "embed",
369
- onAction: () => {
370
- s.value.dialogVisible = !0;
371
- }
372
- }), t.ui.registry.addButton("localVideo", {
373
- icon: "embed",
374
- tooltip: "视频",
375
- onAction: () => {
376
- s.value.dialogVisible = !0;
377
- }
378
- }));
480
+ };
481
+ t.ui.registry.addMenuItem("localAudio", {
482
+ text: "音频",
483
+ icon: "arrow-right",
484
+ onAction: () => f()
485
+ }), t.ui.registry.addButton("localAudio", {
486
+ icon: "arrow-right",
487
+ tooltip: "音频",
488
+ onAction: () => f()
489
+ });
490
+ }
491
+ if ((d = p == null ? void 0 : p.value) != null && d.enable) {
492
+ const f = () => {
493
+ _.value.dialogVisible = !0;
494
+ };
495
+ t.ui.registry.addMenuItem("localVideo", {
496
+ text: "视频",
497
+ icon: "embed",
498
+ onAction: () => f()
499
+ }), t.ui.registry.addButton("localVideo", {
500
+ icon: "embed",
501
+ tooltip: "视频",
502
+ onAction: () => f()
503
+ });
504
+ }
379
505
  }
380
- }, l = M(
506
+ }, a = $(
381
507
  [
382
- a.options,
383
- x.tinymceOptions,
384
- o
508
+ i.options,
509
+ F.options,
510
+ e
385
511
  ],
386
512
  {
387
- mergeFunction: (t, e) => (...i) => {
388
- t(...i), e(...i);
513
+ mergeFunction: (t, r) => (...l) => {
514
+ t(...l), r(...l);
389
515
  },
390
516
  type: Object
391
517
  }
392
518
  );
393
- I.init(l).then(([t]) => {
394
- var e;
395
- t && (t.customProps = { ...a }, t.on("change input Redo Undo SetContent", () => {
396
- if (U.value) {
397
- U.value = !1;
519
+ de.init(a).then(([t]) => {
520
+ var r;
521
+ t && (t.customProps = C({}, i), t.on("input", () => {
522
+ if (T.value) {
523
+ T.value = !1;
398
524
  return;
399
525
  }
400
- A.value = !0, C("input", t.getContent()), C("update:modelValue", t.getContent());
401
- }), (e = a.initComplete) == null || e.call(a, { editorIns: t }), u.value = t);
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);
402
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();
403
538
  });
404
- const X = () => {
405
- var o, l;
406
- return ((l = (o = y.value) == null ? void 0 : o.data) == null ? void 0 : l.call(o, { ...r.value.additionalData || {}, extParameters: a.extParameters })) || {};
407
- }, Y = () => {
408
- var o, l;
409
- return ((l = (o = y.value) == null ? void 0 : o.headers) == null ? void 0 : l.call(o, { ...r.value.additionalData || {}, extParameters: a.extParameters })) || {};
410
- }, Z = (o, l, t) => {
411
- var i, n;
412
- const e = (n = (i = y == null ? void 0 : y.value) == null ? void 0 : i.handlerResponse) == null ? void 0 : n.call(i, o);
413
- e != null && e.url ? t[t.length - 1].url = e.url : e != null && e.errorMessage && (v.error(e.errorMessage), t.splice(t.length - 1, 1)), r.value.formData.file = t;
414
- }, ee = (o, l) => new Promise((t, e) => {
415
- const i = o.name.split(".").filter(Boolean).pop() ? o.name.split(".").filter(Boolean).pop() : "";
416
- if (!a.audioAllowedType.includes(i.toUpperCase())) {
417
- v.info(`请上传格式为${a.audioAllowedType.join("、")}的音频`), e();
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) => {
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;
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();
418
556
  return;
419
557
  }
420
- if (o.size > a.audioMaxSize * 1024 * 1024) {
421
- v.info(`请上传${a.audioMaxSize}M内的音频`), e();
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();
422
560
  return;
423
561
  }
424
- r.value.additionalData = { file: o }, t(!0);
425
- }), ae = (o, l) => {
426
- r.value.formData.file = l;
427
- }, oe = (o, l, t) => {
428
- v.error("上传发生错误,请重试!"), r.value.formData.file = t;
429
- }, ie = () => {
430
- var o, l;
431
- return ((l = (o = b.value) == null ? void 0 : o.data) == null ? void 0 : l.call(o, { ...s.value.additionalData || {}, extParameters: a.extParameters })) || {};
432
- }, te = () => {
433
- var o, l;
434
- return ((l = (o = b.value) == null ? void 0 : o.headers) == null ? void 0 : l.call(o, { ...s.value.additionalData || {}, extParameters: a.extParameters })) || {};
435
- }, le = (o, l, t) => {
436
- var i, n;
437
- const e = (n = (i = b == null ? void 0 : b.value) == null ? void 0 : i.handlerResponse) == null ? void 0 : n.call(i, o);
438
- e != null && e.url ? t[t.length - 1].url = e.url : e != null && e.errorMessage && (v.error(e.errorMessage), t.splice(t.length - 1, 1)), s.value.formData.file = t;
439
- }, ne = (o, l) => new Promise((t, e) => {
440
- const i = o.name.split(".").filter(Boolean).pop() ? o.name.split(".").filter(Boolean).pop() : "";
441
- if (!a.videoAllowedType.includes(i.toUpperCase())) {
442
- v.info(`请上传格式为${a.videoAllowedType.join("、")}的视频`), e();
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) => {
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;
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();
443
584
  return;
444
585
  }
445
- if (o.size > a.videoMaxSize * 1024 * 1024) {
446
- v.info(`请上传${a.videoMaxSize}M内的视频`), e();
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();
447
588
  return;
448
589
  }
449
- s.value.additionalData = { file: o }, t(!0);
450
- }), re = (o, l) => {
451
- s.value.formData.file = l;
452
- }, se = (o, l, t) => {
453
- v.error("上传发生错误,请重试!"), s.value.formData.file = t;
590
+ _.value.additionalData = { file: e }, o(!0);
591
+ }), Se = (e, a) => {
592
+ _.value.formData.file = a;
593
+ }, Me = (e, a, o) => {
594
+ g.error("上传发生错误,请重试!"), _.value.formData.file = o;
454
595
  };
455
- return pe(() => {
456
- var o;
457
- (o = u.value) == null || o.destroy();
458
- }), R(() => [a.disabled, u.value], () => {
459
- var o, l;
460
- (l = (o = u.value) == null ? void 0 : o.mode) == null || l.set(a.disabled ? "readonly" : "design");
461
- }, { immediate: !0 }), R(
462
- () => [a.value, a.modelValue, u.value],
596
+ return O(() => [i.disabled, m.value], () => {
597
+ var e, a;
598
+ (a = (e = m.value) == null ? void 0 : e.mode) == null || a.set(i.disabled ? "readonly" : "design");
599
+ }, { immediate: !0 }), O(
600
+ () => [i.value, m.value],
463
601
  () => {
464
- var o;
465
- if (A.value) {
466
- A.value = !1;
602
+ var e, a, o, t;
603
+ if (h.value) {
604
+ h.value = !1;
467
605
  return;
468
606
  }
469
- U.value = !0, (o = u.value) == null || o.setContent(a.value ? a.value : a.modelValue ? a.modelValue : "");
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);
470
608
  },
471
609
  { immediate: !0 }
472
- ), { __sfc: !0, insRef: P, editorRef: u, preventSettingContent: A, preventUpdatingModelValue: U, uploadImage: c, uploadImageFormRef: S, onUploadImageClose: q, onUploadImageConfirm: N, uploadAudio: r, uploadAudioFormRef: k, onUploadAudioConfirm: j, onUploadAudioClose: G, uploadVideo: s, uploadVideoFormRef: z, onUploadVideoConfirm: L, onUploadVideoClose: J, onImageUploadUpload: K, props: a, emits: C, processPastedImage: H, mergeVideoUploadOptions: b, mergeAudioUploadOptions: y, mergeImgPondOptions: Q, paste_preprocess: T, paste_postprocess: V, imageUploadHandle: g, getUploadAudioData: X, getUploadAudioHeaders: Y, onUploadAudioSuccess: Z, onUploadAudioBeforeUpload: ee, onUploadAudioRemove: ae, onUploadAudioError: oe, getUploadVideoData: ie, getUploadVideoHeaders: te, onUploadVideoSuccess: le, onUploadVideoBeforeUpload: ne, onUploadVideoRemove: re, onUploadVideoError: se, ImgPond: ge };
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 };
473
611
  }
474
612
  });
475
613
  export {
476
- Ze as default
614
+ Va as default
477
615
  };