@keyblade/tinymce-editor-vue2 0.0.12-alpha.4 → 0.0.12-alpha.40

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