@keyblade/tinymce-editor-vue2 0.0.12-alpha.3 → 0.0.12-alpha.30
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/README.md +151 -68
- package/es/editor.vue.d.ts +25 -181
- package/es/editor.vue.js +20 -19
- package/es/editor.vue2.js +312 -244
- package/es/index.d.ts +85 -669
- package/es/index.js +11 -11
- package/es/style.css +1 -1
- package/es/types.d.ts +79 -0
- package/es/util.d.ts +12 -32
- package/es/util.js +14 -67
- package/package.json +3 -4
- package/src/index.ts +16 -31
- /package/es/{editor.vue3.js → style.less.js} +0 -0
package/es/editor.vue2.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
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
|
|
36
|
-
import {
|
|
37
|
-
const
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
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"
|
|
67
|
-
setup(
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const z =
|
|
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
|
-
}),
|
|
76
|
-
|
|
119
|
+
}), R = g(), W = () => {
|
|
120
|
+
_.value.dialogVisible = !1, _.value.formData = {
|
|
77
121
|
images: []
|
|
78
122
|
};
|
|
79
|
-
},
|
|
80
|
-
var
|
|
81
|
-
(
|
|
82
|
-
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
},
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
},
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
},
|
|
132
|
-
var
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
|
156
|
-
if (!
|
|
157
|
-
|
|
158
|
-
|
|
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(
|
|
190
|
+
o(n.url);
|
|
163
191
|
});
|
|
164
|
-
async function
|
|
165
|
-
var o,
|
|
166
|
-
const
|
|
167
|
-
for (let
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
|
176
|
-
if (!
|
|
177
|
-
(
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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:
|
|
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(
|
|
277
|
-
|
|
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(
|
|
282
|
-
|
|
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(
|
|
287
|
-
return new Promise(async (
|
|
288
|
-
var
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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 (!
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
|
308
|
-
if (!
|
|
309
|
-
return
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
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(
|
|
319
|
-
|
|
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
|
|
325
|
-
const
|
|
326
|
-
|
|
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
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
-
},
|
|
390
|
+
}, i = T(
|
|
348
391
|
[
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
392
|
+
c.options,
|
|
393
|
+
A.options,
|
|
394
|
+
e
|
|
352
395
|
],
|
|
353
396
|
{
|
|
354
|
-
mergeFunction: (
|
|
355
|
-
|
|
397
|
+
mergeFunction: (a, t) => (...n) => {
|
|
398
|
+
a(...n), t(...n);
|
|
356
399
|
},
|
|
357
400
|
type: Object
|
|
358
401
|
}
|
|
359
402
|
);
|
|
360
|
-
|
|
361
|
-
var
|
|
362
|
-
|
|
363
|
-
if (
|
|
364
|
-
|
|
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
|
-
|
|
368
|
-
}),
|
|
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
|
|
372
|
-
var i,
|
|
373
|
-
const e =
|
|
374
|
-
|
|
375
|
-
},
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
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 (
|
|
382
|
-
|
|
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
|
-
}),
|
|
387
|
-
|
|
388
|
-
},
|
|
389
|
-
|
|
390
|
-
},
|
|
391
|
-
var i,
|
|
392
|
-
const e =
|
|
393
|
-
|
|
394
|
-
},
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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 (
|
|
401
|
-
|
|
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
|
-
}),
|
|
406
|
-
|
|
407
|
-
},
|
|
408
|
-
|
|
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
|
|
411
|
-
var
|
|
412
|
-
(
|
|
413
|
-
}
|
|
414
|
-
|
|
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
|
|
420
|
-
if (
|
|
421
|
-
|
|
487
|
+
var e;
|
|
488
|
+
if (P.value) {
|
|
489
|
+
P.value = !1;
|
|
422
490
|
return;
|
|
423
491
|
}
|
|
424
|
-
|
|
492
|
+
D.value = !0, (e = x.value) == null || e.setContent(c.value ? c.value : "");
|
|
425
493
|
},
|
|
426
494
|
{ immediate: !0 }
|
|
427
|
-
), { __sfc: !0,
|
|
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
|
-
|
|
499
|
+
ua as default
|
|
432
500
|
};
|