@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/README.md +151 -68
- package/es/editor.vue.d.ts +25 -181
- package/es/editor.vue.js +20 -19
- package/es/editor.vue2.js +330 -248
- package/es/index.d.ts +85 -669
- package/es/index.js +12 -11
- package/es/style.css +1 -1
- package/es/types.d.ts +79 -0
- package/es/util.d.ts +13 -32
- package/es/util.js +20 -68
- package/package.json +3 -3
- 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 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
|
|
36
|
-
import {
|
|
37
|
-
const
|
|
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
|
-
|
|
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
|
|
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
|
-
}),
|
|
76
|
-
|
|
119
|
+
}), W = h(), $ = () => {
|
|
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 = 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
|
-
},
|
|
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
|
-
|
|
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
|
+
}), E = h(), j = () => {
|
|
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 = 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
|
-
|
|
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
|
+
}), q = h(), F = () => {
|
|
165
|
+
x.value.dialogVisible = !1, x.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
|
+
}, 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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
|
156
|
-
if (!
|
|
157
|
-
|
|
158
|
-
|
|
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(
|
|
194
|
+
o(n.url);
|
|
163
195
|
});
|
|
164
|
-
async function
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
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 = {
|
|
227
|
+
xe(() => {
|
|
228
|
+
var o;
|
|
229
|
+
const e = {
|
|
198
230
|
// 设置语言
|
|
199
231
|
language: "zh_CN",
|
|
200
232
|
// 实例
|
|
201
|
-
target:
|
|
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(
|
|
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);
|
|
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(
|
|
282
|
-
|
|
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(
|
|
287
|
-
return new Promise(async (
|
|
288
|
-
var
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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 (!
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
|
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);
|
|
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(
|
|
319
|
-
|
|
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
|
|
325
|
-
const
|
|
326
|
-
|
|
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
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
-
},
|
|
404
|
+
}, i = C(
|
|
348
405
|
[
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
406
|
+
d.options,
|
|
407
|
+
A.options,
|
|
408
|
+
e
|
|
352
409
|
],
|
|
353
410
|
{
|
|
354
|
-
mergeFunction: (
|
|
355
|
-
|
|
411
|
+
mergeFunction: (a, t) => (...n) => {
|
|
412
|
+
a(...n), t(...n);
|
|
356
413
|
},
|
|
357
414
|
type: Object
|
|
358
415
|
}
|
|
359
416
|
);
|
|
360
|
-
|
|
361
|
-
var
|
|
362
|
-
|
|
363
|
-
if (
|
|
364
|
-
|
|
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
|
-
|
|
368
|
-
}),
|
|
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
|
|
372
|
-
var i,
|
|
373
|
-
const e =
|
|
374
|
-
|
|
375
|
-
},
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
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 (
|
|
382
|
-
|
|
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
|
-
}),
|
|
387
|
-
|
|
388
|
-
},
|
|
389
|
-
|
|
390
|
-
},
|
|
391
|
-
var i,
|
|
392
|
-
const e =
|
|
393
|
-
|
|
394
|
-
},
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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 (
|
|
401
|
-
|
|
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
|
-
}),
|
|
406
|
-
|
|
407
|
-
},
|
|
408
|
-
|
|
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
|
|
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],
|
|
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
|
|
420
|
-
if (
|
|
421
|
-
|
|
501
|
+
var e;
|
|
502
|
+
if (D.value) {
|
|
503
|
+
D.value = !1;
|
|
422
504
|
return;
|
|
423
505
|
}
|
|
424
|
-
|
|
506
|
+
P.value = !0, (e = b.value) == null || e.setContent(d.value ? d.value : "");
|
|
425
507
|
},
|
|
426
508
|
{ immediate: !0 }
|
|
427
|
-
), { __sfc: !0,
|
|
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
|
-
|
|
513
|
+
ma as default
|
|
432
514
|
};
|