@keyblade/tinymce-editor-vue2 0.0.12-alpha.3 → 0.0.12-alpha.31

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 ge, ref as g, computed as C, watch as U, onMounted as he, onUnmounted as xe } from "vue";
2
+ import { oneTravelImgPondBeforeAddFile as G, oneTravelImageCheckAndTransform as be, oneTravelImageCompressor as J } from "@keyblade/one-travel";
3
+ import { blobToFile as K, getFileExtension as Q, getImagePixel as we } from "./util.js";
4
+ import "./style.less.js";
5
+ import ye from "imgpond";
6
+ import { conclude as T } from "vue-global-config";
7
+ import X from "tinymce";
8
+ import _e 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 w, Loading as Ce } from "element-ui";
39
+ const ua = /* @__PURE__ */ ge({
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: I }) {
54
+ const c = Y;
55
+ X.addI18n("zh_CN", _e);
56
+ const z = {
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
+ }, H = g(), x = g(), P = g(!1), D = g(!1), b = g({
75
+ show: !1,
76
+ text: "图片上传中,请稍等"
77
+ }), d = C(() => T([c.imageUploadOptions, A.imageUploadOptions, z]) || {}), m = C(() => T([c.videoUploadOptions, A.videoUploadOptions, V]) || {}), f = C(() => T([c.audioUploadOptions, A.audioUploadOptions, B]) || {}), k = C(() => T([c.imgPondOptions, A.imgPondOptions]) || {}), Z = C(() => {
78
+ var e, i;
79
+ return ((i = (e = d == null ? void 0 : d.value) == null ? void 0 : e.allowedType) == null ? void 0 : i.map((o) => `.${o}`).join(",")) || "";
80
+ }), M = g();
81
+ U(() => M.value, () => {
82
+ M.value && G(M.value, {
83
+ onStart: () => {
84
+ b.value = {
85
+ show: !0,
86
+ text: "图片加载中,请稍等"
87
+ };
88
+ },
89
+ onSuccess: () => {
90
+ b.value.show = !1;
91
+ },
92
+ onError: (e) => {
93
+ b.value.show = !1, w.error(e);
94
+ }
95
+ });
96
+ }, { immediate: !0 });
97
+ const S = g();
98
+ U(() => S.value, () => {
99
+ if (S.value) {
100
+ let e;
101
+ G(S.value, {
102
+ onStart: () => {
103
+ e = Ce.service({ text: "图片加载中,请稍等", fullscreen: !0, customClass: "tinymce-loading", background: "rgba(0, 0, 0, 0.8)" });
104
+ },
105
+ onSuccess: () => {
106
+ e == null || e.close();
107
+ },
108
+ onError: (i) => {
109
+ e == null || e.close(), w.error(i);
110
+ }
111
+ });
112
+ }
113
+ }, { immediate: !0 });
114
+ const _ = g({
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
+ }), R = g(), W = () => {
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 = R.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 = x.value) == null || t.insertContent(`<img src=${a} alt="" />`);
130
+ }), W());
86
131
  });
87
- }, r = u({
132
+ }, v = g({
88
133
  dialogVisible: !1,
89
134
  formData: {
90
135
  // 名称
@@ -93,112 +138,85 @@ 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
+ }), j = g(), $ = () => {
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 = j.value) == null || e.validate((i) => {
153
+ var o, a;
154
+ i && ((a = x.value) == null || a.insertContent(`<audio controls data-name="${v.value.formData.name}" data-poster="${v.value.formData.cover[0]}" src="${(o = v.value.formData.file[0]) == null ? void 0 : o.url}"></audio>`), $());
155
+ });
156
+ }, h = g({
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
+ }), E = g(), q = () => {
165
+ h.value.dialogVisible = !1, h.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
+ }, h.value.additionalData = {};
168
+ }, te = () => {
169
+ var e;
170
+ (e = E.value) == null || e.validate((i) => {
171
+ var o, a;
172
+ i && ((a = x.value) == null || a.insertContent(`<video controls controlslist="nodownload" src="${(o = h.value.formData.file[0]) == null ? void 0 : o.url}"></video>`), q());
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 = (e, i) => new Promise(async (o, a) => {
175
+ var r, l;
176
+ const t = await J(e);
177
+ if (!t.success) {
178
+ a(), setTimeout(() => {
179
+ i.onError(t.errorMessage);
152
180
  });
153
181
  return;
154
182
  }
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);
183
+ const n = await ((l = (r = d.value).handleRequest) == null ? void 0 : l.call(r, K(t.file, e.name), e.name, { extParameters: c.extParameters }));
184
+ if (!n || !(n != null && n.success)) {
185
+ a(), setTimeout(() => {
186
+ i.onError(n == null ? void 0 : n.errorMessage);
159
187
  });
160
188
  return;
161
189
  }
162
- o(s.url);
190
+ o(n.url);
163
191
  });
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);
192
+ async function F(e) {
193
+ var o, a, t, n, r;
194
+ const i = e.getElementsByTagName("img");
195
+ for (let l of i) {
196
+ const s = l.src;
197
+ if (s.startsWith("data:image"))
198
+ (o = l == null ? void 0 : l.remove) == null || o.call(l);
199
+ else if (s.startsWith("http://") || s.startsWith("https://")) {
200
+ const u = await we(s);
201
+ if (u && (u.width < (d.value.minWidth || 0) && u.height < (d.value.minHeight || 0) || u.width > (d.value.maxWidth || 0) && u.height > (d.value.maxHeight || 0))) {
202
+ (a = l == null ? void 0 : l.remove) == null || a.call(l);
173
203
  return;
174
204
  }
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);
205
+ const p = Q(s);
206
+ if (!((n = (t = d.value) == null ? void 0 : t.allowedType) != null && n.includes(p.toLowerCase()))) {
207
+ (r = l == null ? void 0 : l.remove) == null || r.call(l);
178
208
  return;
179
209
  }
180
210
  }
181
211
  }
182
212
  }
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 = {
213
+ he(() => {
214
+ var o;
215
+ const e = {
198
216
  // 设置语言
199
217
  language: "zh_CN",
200
218
  // 实例
201
- target: z.value,
219
+ target: H.value,
202
220
  // 隐藏品牌
203
221
  branding: !1,
204
222
  // 隐藏右上角升级按钮
@@ -253,12 +271,13 @@ const Qe = /* @__PURE__ */ ne({
253
271
  ],
254
272
  menu: {
255
273
  insert: {
256
- title: "菜单",
274
+ title: "插入",
257
275
  items: "localImage localAudio localVideo | link mobilelink | template codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor toc | insertdatetime"
258
276
  }
259
277
  },
278
+ toolbar_mode: "sliding",
260
279
  // 工具栏
261
- toolbar: "undo redo | bold italic underline strikethrough | fontfamily fontsize styles | alignleft aligncenter alignright alignjustify | outdent indent",
280
+ 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
281
  // 改动后刷新,不再弹 alert
263
282
  autosave_ask_before_unload: !1,
264
283
  // 内容样式 data-mce-bogus="all" 音频点击会出现另外一个
@@ -272,161 +291,210 @@ const Qe = /* @__PURE__ */ ne({
272
291
  convert_urls: !1,
273
292
  paste_webkit_styles: "all",
274
293
  paste_data_images: !0,
294
+ images_file_types: ((o = d.value.allowedType) == null ? void 0 : o.join(",")) || "jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp",
275
295
  // 粘贴前处理
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);
296
+ paste_preprocess(a, t) {
297
+ 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
298
  },
280
299
  // 粘贴后处理(处理异步操作)
281
- paste_postprocess(o, e) {
282
- var l;
283
- const i = e.node;
284
- $(i), (l = T.value) == null || l.call(T, o, e);
300
+ paste_postprocess(a, t) {
301
+ F(t.node);
285
302
  },
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
303
+ images_upload_handler(a) {
304
+ return new Promise(async (t, n) => {
305
+ var y, N, O;
306
+ if (!((y = d.value) != null && y.handleRequest))
307
+ return n({ message: "缺少图片上传配置", remove: !0 });
308
+ b.value = {
309
+ show: !0,
310
+ text: "图片上传中,请稍等"
311
+ };
312
+ let r = a.blob(), l = r.name ? r.name : a.filename();
313
+ if (!(r != null && r.name) && !(r != null && r.lastModified) && r.type === "image/png")
314
+ return b.value.show = !1, n({ message: "不允许粘贴", remove: !0 });
315
+ const s = await be(r, l, {
316
+ imageMaxSize: d.value.maxSize,
317
+ imageAllowedType: d.value.allowedType,
318
+ // imageAllowedMineType: mergeImageUploadOptions.value.allowedMineType,
319
+ imageMinWidth: d.value.minWidth,
320
+ imageMinHeight: d.value.minHeight,
321
+ imageMaxWidth: d.value.maxWidth,
322
+ imageMaxHeight: d.value.maxHeight
298
323
  });
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 });
324
+ if (!s.success)
325
+ return b.value.show = !1, n({ message: (s == null ? void 0 : s.errorMessage) || "", remove: !0 });
326
+ if (s.hasTransform) {
327
+ r = s.file;
328
+ const L = l == null ? void 0 : l.split(".");
329
+ L.pop(), l = `${L.join(",")}.jpg`;
306
330
  }
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);
331
+ const u = await J(r);
332
+ if (!u.success)
333
+ return b.value.show = !1, n({ message: u == null ? void 0 : u.errorMessage, remove: !0 });
334
+ const p = await ((O = (N = d.value).handleRequest) == null ? void 0 : O.call(N, K(u.file, l), l, { extParameters: c.extParameters }));
335
+ if (!p || !p.success)
336
+ return b.value.show = !1, n({ message: p.errorMessage, remove: !0 });
337
+ b.value.show = !1, t(p.url);
316
338
  });
317
339
  },
318
- setup(o) {
319
- o.ui.registry.addMenuItem("localImage", {
340
+ setup(a) {
341
+ var n, r;
342
+ const t = () => {
343
+ _.value.dialogVisible = !0, setTimeout(() => {
344
+ var s, u;
345
+ const l = (s = document == null ? void 0 : document.querySelector) == null ? void 0 : s.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
346
+ l && (l.innerHTML = ((u = d.value) == null ? void 0 : u.tipText) || "上传");
347
+ });
348
+ };
349
+ if (a.ui.registry.addMenuItem("localImage", {
320
350
  text: "图片",
321
351
  icon: "image",
322
- onAction: () => {
352
+ onAction: () => t()
353
+ }), a.ui.registry.addButton("localImage", {
354
+ icon: "image",
355
+ tooltip: "图片",
356
+ onAction: () => t()
357
+ }), (n = f == null ? void 0 : f.value) != null && n.enable) {
358
+ const l = () => {
323
359
  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 || "上传");
360
+ var u, p;
361
+ const s = (u = document == null ? void 0 : document.querySelector) == null ? void 0 : u.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
362
+ s && (s.innerHTML = ((p = d.value) == null ? void 0 : p.tipText) || "上传");
327
363
  });
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
- });
364
+ };
365
+ a.ui.registry.addMenuItem("localAudio", {
366
+ text: "音频",
367
+ icon: "arrow-right",
368
+ onAction: () => l()
369
+ }), a.ui.registry.addButton("localAudio", {
370
+ icon: "arrow-right",
371
+ tooltip: "音频",
372
+ onAction: () => l()
373
+ });
374
+ }
375
+ if ((r = m == null ? void 0 : m.value) != null && r.enable) {
376
+ const l = () => {
377
+ h.value.dialogVisible = !0;
378
+ };
379
+ a.ui.registry.addMenuItem("localVideo", {
380
+ text: "视频",
381
+ icon: "embed",
382
+ onAction: () => l()
383
+ }), a.ui.registry.addButton("localVideo", {
384
+ icon: "embed",
385
+ tooltip: "视频",
386
+ onAction: () => l()
387
+ });
388
+ }
346
389
  }
347
- }, n = M(
390
+ }, i = T(
348
391
  [
349
- a.options,
350
- x.tinymceOptions,
351
- t
392
+ c.options,
393
+ A.options,
394
+ e
352
395
  ],
353
396
  {
354
- mergeFunction: (o, e) => (...i) => {
355
- o(...i), e(...i);
397
+ mergeFunction: (a, t) => (...n) => {
398
+ a(...n), t(...n);
356
399
  },
357
400
  type: Object
358
401
  }
359
402
  );
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;
403
+ X.init(i).then(([a]) => {
404
+ var t;
405
+ a && (a.customProps = { ...c }, a.on("change input Redo Undo SetContent", () => {
406
+ if (D.value) {
407
+ D.value = !1;
365
408
  return;
366
409
  }
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);
410
+ P.value = !0, I("input", a.getContent());
411
+ }), a.on("paste", (n) => {
412
+ var l, s;
413
+ const r = ((l = n.clipboardData) == null ? void 0 : l.files) || [];
414
+ for (let u of r) {
415
+ const p = Q(u.name) || "";
416
+ (s = d.value.allowedType) != null && s.includes(p.toLowerCase()) || n.preventDefault();
417
+ }
418
+ }), (t = c.initComplete) == null || t.call(c, { editorIns: a }), x.value = a);
369
419
  });
420
+ }), xe(() => {
421
+ var e;
422
+ (e = x.value) == null || e.destroy();
370
423
  });
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();
424
+ const ie = () => {
425
+ var i, o;
426
+ const e = { ...v.value.additionalData || {} };
427
+ return ((o = (i = f.value) == null ? void 0 : i.data) == null ? void 0 : o.call(i, { file: e, extParameters: c.extParameters })) || {};
428
+ }, le = () => {
429
+ var i, o;
430
+ const e = { ...v.value.additionalData || {} };
431
+ return ((o = (i = f.value) == null ? void 0 : i.headers) == null ? void 0 : o.call(i, { file: e, extParameters: c.extParameters })) || {};
432
+ }, ne = (e, i, o) => {
433
+ var t, n;
434
+ const a = (n = (t = f == null ? void 0 : f.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t, e);
435
+ a != null && a.url ? o[o.length - 1].url = a.url : a != null && a.errorMessage && (w.error(a.errorMessage), o.splice(o.length - 1, 1)), v.value.formData.file = o;
436
+ }, re = (e, i) => new Promise((o, a) => {
437
+ var n, r, l, s, u, p;
438
+ const t = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
439
+ if (!((r = (n = f.value) == null ? void 0 : n.allowedType) != null && r.includes(t.toLowerCase()))) {
440
+ w.error(`请上传格式为${(s = (l = f.value) == null ? void 0 : l.allowedType) == null ? void 0 : s.map((y) => y.toUpperCase()).join("、")}的音频`), a();
379
441
  return;
380
442
  }
381
- if (t.size > a.audioMaxSize * 1024 * 1024) {
382
- f.info(`请上传${a.audioMaxSize}M内的音频`), e();
443
+ if (e.size > (((u = f.value) == null ? void 0 : u.maxSize) || 0) * 1024 * 1024) {
444
+ w.error(`请上传${((p = f.value) == null ? void 0 : p.maxSize) || 0}M内的音频`), a();
383
445
  return;
384
446
  }
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();
447
+ v.value.additionalData = { file: e }, o(!0);
448
+ }), se = (e, i) => {
449
+ v.value.formData.file = i;
450
+ }, ue = (e, i, o) => {
451
+ w.error("上传发生错误,请重试!"), v.value.formData.file = o;
452
+ }, de = () => {
453
+ var i, o;
454
+ const e = { ...h.value.additionalData || {} };
455
+ return ((o = (i = m.value) == null ? void 0 : i.data) == null ? void 0 : o.call(i, { file: e, extParameters: c.extParameters })) || {};
456
+ }, ce = () => {
457
+ var i, o;
458
+ const e = { ...h.value.additionalData || {} };
459
+ return ((o = (i = m.value) == null ? void 0 : i.headers) == null ? void 0 : o.call(i, { file: e, extParameters: c.extParameters })) || {};
460
+ }, me = (e, i, o) => {
461
+ var t, n;
462
+ const a = (n = (t = m == null ? void 0 : m.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t, e);
463
+ a != null && a.url ? o[o.length - 1].url = a.url : a != null && a.errorMessage && (w.error(a.errorMessage), o.splice(o.length - 1, 1)), h.value.formData.file = o;
464
+ }, pe = (e, i) => new Promise((o, a) => {
465
+ var n, r, l, s, u, p;
466
+ const t = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
467
+ if (!((r = (n = m == null ? void 0 : m.value) == null ? void 0 : n.allowedType) != null && r.includes(t.toLowerCase()))) {
468
+ w.error(`请上传格式为${(s = (l = m == null ? void 0 : m.value) == null ? void 0 : l.allowedType) == null ? void 0 : s.map((y) => y.toUpperCase()).join("、")}的视频`), a();
398
469
  return;
399
470
  }
400
- if (t.size > a.videoMaxSize * 1024 * 1024) {
401
- f.info(`请上传${a.videoMaxSize}M内的视频`), e();
471
+ if (e.size > (((u = m == null ? void 0 : m.value) == null ? void 0 : u.maxSize) || 0) * 1024 * 1024) {
472
+ w.error(`请上传${((p = m == null ? void 0 : m.value) == null ? void 0 : p.maxSize) || 0}M内的视频`), a();
402
473
  return;
403
474
  }
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;
475
+ h.value.additionalData = { file: e }, o(!0);
476
+ }), ve = (e, i) => {
477
+ h.value.formData.file = i;
478
+ }, fe = (e, i, o) => {
479
+ w.error("上传发生错误,请重试!"), h.value.formData.file = o;
409
480
  };
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],
481
+ return U(() => [c.disabled, x.value], () => {
482
+ var e, i;
483
+ (i = (e = x.value) == null ? void 0 : e.mode) == null || i.set(c.disabled ? "readonly" : "design");
484
+ }, { immediate: !0 }), U(
485
+ () => [c.value, x.value],
418
486
  () => {
419
- var t;
420
- if (_.value) {
421
- _.value = !1;
487
+ var e;
488
+ if (P.value) {
489
+ P.value = !1;
422
490
  return;
423
491
  }
424
- w.value = !0, (t = m.value) == null || t.setContent(a.value ? a.value : a.modelValue ? a.modelValue : "");
492
+ D.value = !0, (e = x.value) == null || e.setContent(c.value ? c.value : "");
425
493
  },
426
494
  { 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 };
495
+ ), { __sfc: !0, defaultImageUploadOptions: z, defaultVideoUploadOptions: V, defaultAudioUploadOptions: B, props: c, emits: I, insRef: H, editorRef: x, preventSettingContent: P, preventUpdatingModelValue: D, uploadLoadingConfig: b, mergeImageUploadOptions: d, mergeVideoUploadOptions: m, mergeAudioUploadOptions: f, mergeImgPondOptions: k, imgPondAccept: Z, uploadImageImgPondRef: M, audioImageImgPondRef: S, uploadImage: _, uploadImageFormRef: R, onUploadImageClose: W, onUploadImageConfirm: ee, uploadAudio: v, uploadAudioFormRef: j, onUploadAudioClose: $, onUploadAudioConfirm: ae, uploadVideo: h, uploadVideoFormRef: E, onUploadVideoClose: q, onUploadVideoConfirm: te, onImageUploadUpload: oe, processPastedImage: F, getUploadAudioData: ie, getUploadAudioHeaders: le, onUploadAudioSuccess: ne, onUploadAudioBeforeUpload: re, onUploadAudioRemove: se, onUploadAudioError: ue, getUploadVideoData: de, getUploadVideoHeaders: ce, onUploadVideoSuccess: me, onUploadVideoBeforeUpload: pe, onUploadVideoRemove: ve, onUploadVideoError: fe, ImgPond: ye };
428
496
  }
429
497
  });
430
498
  export {
431
- Qe as default
499
+ ua as default
432
500
  };