@keyblade/tinymce-editor-vue2 0.0.12-alpha.9 → 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 me, ref as m, computed as M, onMounted as pe, onUnmounted as ce, watch as E } from "vue";
2
- import { oneTravelImageCheck as O, oneTravelImageCompressor as I, getImagePixel as ge } from "./util.js";
3
- import fe from "imgpond";
4
- import { conclude as x } from "vue-global-config";
5
- import F from "tinymce";
6
- import ve 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,63 +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 b } from "./index.js";
36
- import { Loading as he, Message as v } from "element-ui";
37
- const ea = /* @__PURE__ */ me({
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(q, { emit: C }) {
70
- const a = q;
71
- F.addI18n("zh_CN", ve);
72
- const S = m(), d = m(), A = m(!1), T = 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
- }), k = m(), N = () => {
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
- }, j = () => {
82
- var o;
83
- (o = k.value) == null || o.validate((l) => {
84
- l && (c.value.formData.images.forEach((t) => {
85
- var e, i;
86
- if (P.value.srcAt)
87
- return (e = d.value) == null ? void 0 : e.insertContent(`<img src=${t == null ? void 0 : t[P.value.srcAt]} alt="" />`);
88
- (i = d.value) == null || i.insertContent(`<img src=${t} alt="" />`);
89
- }), 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());
90
164
  });
91
- }, r = m({
165
+ }, w = y({
92
166
  dialogVisible: !1,
93
167
  formData: {
94
168
  // 名称
@@ -100,23 +174,19 @@ const ea = /* @__PURE__ */ me({
100
174
  },
101
175
  // 用于临时保存上传前的参数 { file: File }
102
176
  additionalData: {}
103
- }), z = m(), G = () => {
104
- var o;
105
- (o = z.value) == null || o.validate((l) => {
106
- var t, e;
107
- l && ((e = d.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 = {
108
- name: "",
109
- cover: [],
110
- file: []
111
- }, r.value.additionalData = {});
112
- });
113
- }, L = () => {
114
- r.value.dialogVisible = !1, r.value.formData = {
177
+ }), Q = y(), Y = () => {
178
+ w.value.dialogVisible = !1, w.value.formData = {
115
179
  name: "",
116
180
  cover: [],
117
181
  file: []
118
- }, r.value.additionalData = {};
119
- }, 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({
120
190
  dialogVisible: !1,
121
191
  formData: {
122
192
  // 文件
@@ -124,89 +194,183 @@ const ea = /* @__PURE__ */ me({
124
194
  },
125
195
  // 用于临时保存上传前的参数 { file: File }
126
196
  additionalData: {}
127
- }), H = m(), J = () => {
128
- var o;
129
- (o = H.value) == null || o.validate((l) => {
130
- var t, e;
131
- l && ((e = d.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 = {
132
- file: []
133
- }, s.value.additionalData = {});
134
- });
135
- }, K = () => {
136
- s.value.dialogVisible = !1, s.value.formData = {
197
+ }), Z = y(), ee = () => {
198
+ _.value.dialogVisible = !1, _.value.formData = {
137
199
  file: []
138
- }, s.value.additionalData = {};
139
- }, Q = (o, l) => new Promise(async (t, e) => {
140
- var h;
141
- const i = await O(o, {
142
- imageMaxSize: a.imageMaxSize,
143
- imageAllowedMineType: a.imageAllowedMineType,
144
- imageMinWidth: a.imageMinWidth,
145
- imageMinHeight: a.imageMinHeight,
146
- imageMaxWidth: a.imageMaxWidth,
147
- 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}张图片`);
148
210
  });
149
- if (!i.success) {
150
- e(), setTimeout(() => {
151
- var p, f, w;
152
- (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("、")}的图片`) : (w = i.error) != null && w.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);
153
226
  });
154
227
  return;
155
228
  }
156
- const n = await I(o);
157
- if (!n.success) {
158
- e(), setTimeout(() => {
159
- 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);
160
233
  });
161
234
  return;
162
235
  }
163
- const u = await ((h = g.value) == null ? void 0 : h.call(g, n.file, o.name, { extParameters: a.extParameters }));
164
- if (!u.success) {
165
- e(), setTimeout(() => {
166
- l.onError(u.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
167
259
  });
168
- 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("暂不支持的文件类型");
169
328
  }
170
- t(u.url);
171
- }), X = M(() => a.imageAllowedMineType.map((o) => `.${o.split("/")[1]}`).join(",") || "");
172
- async function $(o) {
173
- var t, e;
174
- const l = o.getElementsByTagName("img");
175
- for (let i of l) {
176
- const n = i.src;
177
- if (n.startsWith("http://") || n.startsWith("https://")) {
178
- const u = await ge(n);
179
- if (u.width < a.imageMinWidth && u.height < a.imageMinHeight || u.width > a.imageMaxWidth && u.height > a.imageMaxHeight) {
180
- (t = i == null ? void 0 : i.remove) == null || t.call(i);
181
- 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
+ }
182
342
  }
183
- const h = n.split("."), p = h[h.length - 1].toLowerCase();
184
- if (!a.imageAllowedType.includes(p)) {
185
- (e = i == null ? void 0 : i.remove) == null || e.call(i);
186
- 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];
187
351
  }
188
352
  }
353
+ A.value.show = !1;
189
354
  }
190
- }
191
- const y = M(() => x([a.videoUploadOptions, b.videoUploadOptions]) || {}), _ = M(() => x([a.audioUploadOptions, b.audioUploadOptions]) || {}), P = M(() => x([a.imgPondOptions, b.imgPondOptions]) || {}), U = M(
192
- () => x([a.paste_preprocess, b.paste_preprocess], {
193
- type: Function
194
- })
195
- ), V = M(
196
- () => x([a.paste_postprocess, b.paste_postprocess], {
197
- type: Function
198
- })
199
- ), g = M(
200
- () => x([a.imageUploadHandle, b.imageUploadHandle], {
201
- type: Function
202
- })
203
- );
204
- pe(() => {
205
- 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 = {
206
370
  // 设置语言
207
371
  language: "zh_CN",
208
372
  // 实例
209
- target: S.value,
373
+ target: k.value,
210
374
  // 隐藏品牌
211
375
  branding: !1,
212
376
  // 隐藏右上角升级按钮
@@ -241,7 +405,7 @@ const ea = /* @__PURE__ */ me({
241
405
  "directionality",
242
406
  "emoticons",
243
407
  "fullscreen",
244
- // 'help',
408
+ "help",
245
409
  "image",
246
410
  // 'importcss'
247
411
  "insertdatetime",
@@ -262,16 +426,19 @@ const ea = /* @__PURE__ */ me({
262
426
  menu: {
263
427
  insert: {
264
428
  title: "插入",
265
- 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"
266
430
  }
267
431
  },
268
432
  toolbar_mode: "sliding",
269
433
  // 工具栏
270
- 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",
271
435
  // 改动后刷新,不再弹 alert
272
436
  autosave_ask_before_unload: !1,
273
- // 内容样式 data-mce-bogus="all" 音频点击会出现另外一个
274
- 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,
275
442
  // 字体大小
276
443
  font_size_formats: "8px 10px 12px 14px 16px 18px 20px 22px 24px 26px 28px 30px 32px 34px 36px 38px",
277
444
  font_size_input_default_unit: "px",
@@ -280,200 +447,169 @@ const ea = /* @__PURE__ */ me({
280
447
  relative_urls: !1,
281
448
  convert_urls: !1,
282
449
  paste_webkit_styles: "all",
283
- 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",
284
452
  // 粘贴前处理
285
- paste_preprocess(t, e) {
286
- var i;
287
- 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 = U.value) == null || i.call(U, t, e);
288
- },
289
- // 粘贴后处理(处理异步操作)
290
- paste_postprocess(t, e) {
291
- var n;
292
- const i = e.node;
293
- $(i), (n = V.value) == null || n.call(V, t, e);
294
- },
295
- images_upload_handler(t) {
296
- return new Promise(async (e, i) => {
297
- var D, W, B, R;
298
- const n = he.service({ text: "上传中" });
299
- let u = t.blob();
300
- const h = t.filename(), p = await O(u, {
301
- imageMaxSize: a.imageMaxSize,
302
- imageAllowedMineType: a.imageAllowedMineType,
303
- imageMinWidth: a.imageMinWidth,
304
- imageMinHeight: a.imageMinHeight,
305
- imageMaxWidth: a.imageMaxWidth,
306
- imageMaxHeight: a.imageMaxHeight
307
- });
308
- if (!p.success) {
309
- if (n == null || n.close(), (D = p.error) != null && D.size)
310
- return i({ message: `请上传大小不超过${a.imageMaxSize}M的图片`, remove: !0 });
311
- if ((W = p.error) != null && W.format)
312
- return i({ message: `请上传格式为${a.imageAllowedType.map((ue) => ue.toUpperCase()).join("、")}的图片`, remove: !0 });
313
- if ((B = p.error) != null && B.pixel)
314
- return i({ message: `请上传像素不低于${a.imageMinWidth}*${a.imageMinHeight}且像素不高于${a.imageMaxWidth}*${a.imageMaxHeight}的图片`, remove: !0 });
315
- }
316
- const f = await I(u);
317
- if (!f.success)
318
- return n == null || n.close(), i({ message: f == null ? void 0 : f.errorMessage, remove: !0 });
319
- if (!g.value)
320
- return n == null || n.close(), i({ message: "缺少图片上传配置", remove: !0 });
321
- const w = await ((R = g.value) == null ? void 0 : R.call(g, f.file, h, { extParameters: a.extParameters }));
322
- if (!w.success)
323
- return n == null || n.close(), i({ message: w.errorMessage, remove: !0 });
324
- n == null || n.close(), e(w.url);
325
- });
453
+ paste_preprocess(t, r) {
454
+ r == null || r.preventDefault();
326
455
  },
327
456
  setup(t) {
328
- 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", {
329
466
  text: "图片",
330
467
  icon: "image",
331
- onAction: () => {
332
- c.value.dialogVisible = !0, setTimeout(() => {
333
- var i;
334
- const e = (i = document == null ? void 0 : document.querySelector) == null ? void 0 : i.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
335
- e && (e.innerHTML = a.imageUploadTip || "上传");
336
- });
337
- }
468
+ onAction: () => r()
338
469
  }), t.ui.registry.addButton("localImage", {
339
470
  icon: "image",
340
471
  tooltip: "图片",
341
- onAction: () => {
342
- c.value.dialogVisible = !0, setTimeout(() => {
343
- var i;
344
- const e = (i = document == null ? void 0 : document.querySelector) == null ? void 0 : i.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
345
- e && (e.innerHTML = a.imageUploadTip || "上传");
346
- });
347
- }
348
- }), a.audioEnable && (t.ui.registry.addMenuItem("localAudio", {
349
- text: "音频",
350
- icon: "arrow-right",
351
- onAction: () => {
352
- r.value.dialogVisible = !0, setTimeout(() => {
353
- var i;
354
- const e = (i = document == null ? void 0 : document.querySelector) == null ? void 0 : i.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
355
- e && (e.innerHTML = a.imageUploadTip || "上传");
356
- });
357
- }
358
- }), t.ui.registry.addButton("localAudio", {
359
- icon: "arrow-right",
360
- tooltip: "音频",
361
- onAction: () => {
362
- r.value.dialogVisible = !0, setTimeout(() => {
363
- var i;
364
- const e = (i = document == null ? void 0 : document.querySelector) == null ? void 0 : i.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
365
- 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) || "上传");
366
479
  });
367
- }
368
- })), a.videoEnable && (t.ui.registry.addMenuItem("localVideo", {
369
- text: "视频",
370
- icon: "embed",
371
- onAction: () => {
372
- s.value.dialogVisible = !0;
373
- }
374
- }), t.ui.registry.addButton("localVideo", {
375
- icon: "embed",
376
- tooltip: "视频",
377
- onAction: () => {
378
- s.value.dialogVisible = !0;
379
- }
380
- }));
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
+ }
381
505
  }
382
- }, l = x(
506
+ }, a = $(
383
507
  [
384
- a.options,
385
- b.tinymceOptions,
386
- o
508
+ i.options,
509
+ F.options,
510
+ e
387
511
  ],
388
512
  {
389
- mergeFunction: (t, e) => (...i) => {
390
- t(...i), e(...i);
513
+ mergeFunction: (t, r) => (...l) => {
514
+ t(...l), r(...l);
391
515
  },
392
516
  type: Object
393
517
  }
394
518
  );
395
- F.init(l).then(([t]) => {
396
- var e;
397
- t && (t.customProps = { ...a }, t.on("change input Redo Undo SetContent", () => {
519
+ de.init(a).then(([t]) => {
520
+ var r;
521
+ t && (t.customProps = C({}, i), t.on("input", () => {
398
522
  if (T.value) {
399
523
  T.value = !1;
400
524
  return;
401
525
  }
402
- A.value = !0, C("input", t.getContent()), C("update:modelValue", t.getContent());
403
- }), (e = a.initComplete) == null || e.call(a, { editorIns: t }), d.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);
404
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();
405
538
  });
406
- const Y = () => {
407
- var o, l;
408
- return ((l = (o = _.value) == null ? void 0 : o.data) == null ? void 0 : l.call(o, { ...r.value.additionalData || {}, extParameters: a.extParameters })) || {};
409
- }, Z = () => {
410
- var o, l;
411
- return ((l = (o = _.value) == null ? void 0 : o.headers) == null ? void 0 : l.call(o, { ...r.value.additionalData || {}, extParameters: a.extParameters })) || {};
412
- }, ee = (o, l, t) => {
413
- var i, n;
414
- const e = (n = (i = _ == null ? void 0 : _.value) == null ? void 0 : i.handlerResponse) == null ? void 0 : n.call(i, o);
415
- 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;
416
- }, ae = (o, l) => new Promise((t, e) => {
417
- const i = o.name.split(".").filter(Boolean).pop() ? o.name.split(".").filter(Boolean).pop() : "";
418
- if (!a.audioAllowedType.includes(i.toUpperCase())) {
419
- 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();
420
556
  return;
421
557
  }
422
- if (o.size > a.audioMaxSize * 1024 * 1024) {
423
- 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();
424
560
  return;
425
561
  }
426
- r.value.additionalData = { file: o }, t(!0);
427
- }), oe = (o, l) => {
428
- r.value.formData.file = l;
429
- }, ie = (o, l, t) => {
430
- v.error("上传发生错误,请重试!"), r.value.formData.file = t;
431
- }, te = () => {
432
- var o, l;
433
- return ((l = (o = y.value) == null ? void 0 : o.data) == null ? void 0 : l.call(o, { ...s.value.additionalData || {}, extParameters: a.extParameters })) || {};
434
- }, le = () => {
435
- var o, l;
436
- return ((l = (o = y.value) == null ? void 0 : o.headers) == null ? void 0 : l.call(o, { ...s.value.additionalData || {}, extParameters: a.extParameters })) || {};
437
- }, ne = (o, l, t) => {
438
- var i, n;
439
- const e = (n = (i = y == null ? void 0 : y.value) == null ? void 0 : i.handlerResponse) == null ? void 0 : n.call(i, o);
440
- 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;
441
- }, re = (o, l) => new Promise((t, e) => {
442
- const i = o.name.split(".").filter(Boolean).pop() ? o.name.split(".").filter(Boolean).pop() : "";
443
- if (!a.videoAllowedType.includes(i.toUpperCase())) {
444
- 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();
445
584
  return;
446
585
  }
447
- if (o.size > a.videoMaxSize * 1024 * 1024) {
448
- 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();
449
588
  return;
450
589
  }
451
- s.value.additionalData = { file: o }, t(!0);
452
- }), se = (o, l) => {
453
- s.value.formData.file = l;
454
- }, de = (o, l, t) => {
455
- 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;
456
595
  };
457
- return ce(() => {
458
- var o;
459
- (o = d.value) == null || o.destroy();
460
- }), E(() => [a.disabled, d.value], () => {
461
- var o, l;
462
- (l = (o = d.value) == null ? void 0 : o.mode) == null || l.set(a.disabled ? "readonly" : "design");
463
- }, { immediate: !0 }), E(
464
- () => [a.value, a.modelValue, d.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],
465
601
  () => {
466
- var o;
467
- if (A.value) {
468
- A.value = !1;
602
+ var e, a, o, t;
603
+ if (h.value) {
604
+ h.value = !1;
469
605
  return;
470
606
  }
471
- T.value = !0, (o = d.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);
472
608
  },
473
609
  { immediate: !0 }
474
- ), { __sfc: !0, insRef: S, editorRef: d, preventSettingContent: A, preventUpdatingModelValue: T, uploadImage: c, uploadImageFormRef: k, onUploadImageClose: N, onUploadImageConfirm: j, uploadAudio: r, uploadAudioFormRef: z, onUploadAudioConfirm: G, onUploadAudioClose: L, uploadVideo: s, uploadVideoFormRef: H, onUploadVideoConfirm: J, onUploadVideoClose: K, onImageUploadUpload: Q, props: a, emits: C, imgPondAccept: X, processPastedImage: $, mergeVideoUploadOptions: y, mergeAudioUploadOptions: _, mergeImgPondOptions: P, paste_preprocess: U, paste_postprocess: V, imageUploadHandle: g, getUploadAudioData: Y, getUploadAudioHeaders: Z, onUploadAudioSuccess: ee, onUploadAudioBeforeUpload: ae, onUploadAudioRemove: oe, onUploadAudioError: ie, getUploadVideoData: te, getUploadVideoHeaders: le, onUploadVideoSuccess: ne, onUploadVideoBeforeUpload: re, onUploadVideoRemove: se, onUploadVideoError: de, ImgPond: fe };
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 };
475
611
  }
476
612
  });
477
613
  export {
478
- ea as default
614
+ Va as default
479
615
  };