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