@keyblade/tinymce-editor-vue2 0.0.12-alpha.36 → 0.0.12-alpha.38
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 +136 -126
- package/es/index.js +5 -4
- package/es/util.d.ts +1 -0
- package/es/util.js +17 -12
- package/package.json +2 -2
package/es/editor.vue2.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import { blobToFile as
|
|
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
4
|
import "./style.less.js";
|
|
5
5
|
import Te from "imgpond";
|
|
6
6
|
import { conclude as C } from "vue-global-config";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import X from "tinymce";
|
|
8
|
+
import Ce from "./langs/zh_CN.js";
|
|
9
9
|
import "tinymce/skins/ui/oxide/skin";
|
|
10
10
|
import "tinymce/models/dom";
|
|
11
11
|
import "tinymce/themes/silver";
|
|
@@ -34,9 +34,9 @@ import "tinymce/plugins/table";
|
|
|
34
34
|
import "tinymce/plugins/visualblocks";
|
|
35
35
|
import "tinymce/plugins/visualchars";
|
|
36
36
|
import "tinymce/plugins/wordcount";
|
|
37
|
-
import { globalProps as
|
|
38
|
-
import { Message as
|
|
39
|
-
const
|
|
37
|
+
import { globalProps as A } from "./index.js";
|
|
38
|
+
import { Message as y } from "element-ui";
|
|
39
|
+
const ma = /* @__PURE__ */ he({
|
|
40
40
|
__name: "editor",
|
|
41
41
|
props: {
|
|
42
42
|
value: { default: "" },
|
|
@@ -50,10 +50,10 @@ const da = /* @__PURE__ */ xe({
|
|
|
50
50
|
initComplete: null
|
|
51
51
|
},
|
|
52
52
|
emits: ["input"],
|
|
53
|
-
setup(
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
const
|
|
53
|
+
setup(Y, { emit: z }) {
|
|
54
|
+
const d = Y;
|
|
55
|
+
X.addI18n("zh_CN", Ce);
|
|
56
|
+
const H = {
|
|
57
57
|
maxCount: 10,
|
|
58
58
|
tipText: "上传",
|
|
59
59
|
maxSize: 30,
|
|
@@ -63,23 +63,23 @@ const da = /* @__PURE__ */ xe({
|
|
|
63
63
|
minHeight: 50,
|
|
64
64
|
maxWidth: 6e3,
|
|
65
65
|
maxHeight: 6e3
|
|
66
|
-
},
|
|
66
|
+
}, V = {
|
|
67
67
|
enable: !0,
|
|
68
68
|
maxSize: 300,
|
|
69
69
|
allowedType: ["mp4", "3gp"]
|
|
70
|
-
},
|
|
70
|
+
}, B = {
|
|
71
71
|
enable: !0,
|
|
72
72
|
maxSize: 200,
|
|
73
73
|
allowedType: ["mp3", "m4a", "wav", "aac"]
|
|
74
|
-
},
|
|
74
|
+
}, R = h(), b = h(), D = h(!1), P = h(!1), f = h({
|
|
75
75
|
show: !1,
|
|
76
76
|
text: "图片上传中,请稍等"
|
|
77
|
-
}),
|
|
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
78
|
var e, i;
|
|
79
|
-
return ((i = (e =
|
|
80
|
-
}),
|
|
81
|
-
S(() =>
|
|
82
|
-
|
|
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
83
|
onStart: () => {
|
|
84
84
|
f.value = {
|
|
85
85
|
show: !0,
|
|
@@ -90,13 +90,13 @@ const da = /* @__PURE__ */ xe({
|
|
|
90
90
|
f.value.show = !1;
|
|
91
91
|
},
|
|
92
92
|
onError: (e) => {
|
|
93
|
-
f.value.show = !1,
|
|
93
|
+
f.value.show = !1, y.error(e);
|
|
94
94
|
}
|
|
95
|
-
})
|
|
95
|
+
});
|
|
96
96
|
}, { immediate: !0 });
|
|
97
|
-
const
|
|
98
|
-
S(() =>
|
|
99
|
-
|
|
97
|
+
const U = h();
|
|
98
|
+
S(() => U.value, () => {
|
|
99
|
+
U.value && G(U.value, {
|
|
100
100
|
onStart: () => {
|
|
101
101
|
f.value = {
|
|
102
102
|
show: !0,
|
|
@@ -107,27 +107,27 @@ const da = /* @__PURE__ */ xe({
|
|
|
107
107
|
f.value.show = !1;
|
|
108
108
|
},
|
|
109
109
|
onError: (e) => {
|
|
110
|
-
f.value.show = !1,
|
|
110
|
+
f.value.show = !1, y.error(e);
|
|
111
111
|
}
|
|
112
|
-
})
|
|
112
|
+
});
|
|
113
113
|
}, { immediate: !0 });
|
|
114
|
-
const
|
|
114
|
+
const _ = h({
|
|
115
115
|
dialogVisible: !1,
|
|
116
116
|
formData: {
|
|
117
117
|
images: []
|
|
118
118
|
}
|
|
119
|
-
}),
|
|
120
|
-
|
|
119
|
+
}), W = h(), $ = () => {
|
|
120
|
+
_.value.dialogVisible = !1, _.value.formData = {
|
|
121
121
|
images: []
|
|
122
122
|
};
|
|
123
|
-
},
|
|
123
|
+
}, ee = () => {
|
|
124
124
|
var e;
|
|
125
|
-
(e =
|
|
126
|
-
i && (
|
|
125
|
+
(e = W.value) == null || e.validate((i) => {
|
|
126
|
+
i && (_.value.formData.images.forEach((o) => {
|
|
127
127
|
var t;
|
|
128
128
|
let a = o;
|
|
129
|
-
|
|
130
|
-
}),
|
|
129
|
+
k.value.srcAt && (a = (o == null ? void 0 : o[k.value.srcAt]) || ""), (t = b.value) == null || t.insertContent(`<img src=${a} alt="" />`);
|
|
130
|
+
}), $());
|
|
131
131
|
});
|
|
132
132
|
}, v = h({
|
|
133
133
|
dialogVisible: !1,
|
|
@@ -141,17 +141,17 @@ const da = /* @__PURE__ */ xe({
|
|
|
141
141
|
},
|
|
142
142
|
// 用于临时保存上传前的参数 { file: File }
|
|
143
143
|
additionalData: {}
|
|
144
|
-
}),
|
|
144
|
+
}), E = h(), j = () => {
|
|
145
145
|
v.value.dialogVisible = !1, v.value.formData = {
|
|
146
146
|
name: "",
|
|
147
147
|
cover: [],
|
|
148
148
|
file: []
|
|
149
149
|
}, v.value.additionalData = {};
|
|
150
|
-
},
|
|
150
|
+
}, ae = () => {
|
|
151
151
|
var e;
|
|
152
|
-
(e =
|
|
152
|
+
(e = E.value) == null || e.validate((i) => {
|
|
153
153
|
var o, a;
|
|
154
|
-
i && ((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
155
|
});
|
|
156
156
|
}, x = h({
|
|
157
157
|
dialogVisible: !1,
|
|
@@ -161,30 +161,30 @@ const da = /* @__PURE__ */ xe({
|
|
|
161
161
|
},
|
|
162
162
|
// 用于临时保存上传前的参数 { file: File }
|
|
163
163
|
additionalData: {}
|
|
164
|
-
}),
|
|
164
|
+
}), q = h(), F = () => {
|
|
165
165
|
x.value.dialogVisible = !1, x.value.formData = {
|
|
166
166
|
file: []
|
|
167
167
|
}, x.value.additionalData = {};
|
|
168
|
-
},
|
|
168
|
+
}, te = () => {
|
|
169
169
|
var e;
|
|
170
|
-
(e =
|
|
170
|
+
(e = q.value) == null || e.validate((i) => {
|
|
171
171
|
var o, a;
|
|
172
|
-
i && ((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());
|
|
173
173
|
});
|
|
174
|
-
},
|
|
174
|
+
}, oe = () => {
|
|
175
175
|
document.querySelectorAll(".swal2-container .swal2-title").forEach((e) => {
|
|
176
|
-
e && (e.innerHTML = `单次最多可选择${
|
|
176
|
+
e && (e.innerHTML = `单次最多可选择${m.value.maxCount}张图片`);
|
|
177
177
|
});
|
|
178
|
-
},
|
|
178
|
+
}, ie = (e, i) => new Promise(async (o, a) => {
|
|
179
179
|
var r, l;
|
|
180
|
-
const t = await
|
|
180
|
+
const t = await J(e);
|
|
181
181
|
if (!t.success) {
|
|
182
182
|
a(), setTimeout(() => {
|
|
183
183
|
i.onError(t.errorMessage);
|
|
184
184
|
});
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
187
|
-
const n = await ((l = (r =
|
|
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
188
|
if (!n || !(n != null && n.success)) {
|
|
189
189
|
a(), setTimeout(() => {
|
|
190
190
|
i.onError(n == null ? void 0 : n.errorMessage);
|
|
@@ -193,34 +193,44 @@ const da = /* @__PURE__ */ xe({
|
|
|
193
193
|
}
|
|
194
194
|
o(n.url);
|
|
195
195
|
});
|
|
196
|
-
async function
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
+
}
|
|
213
223
|
}
|
|
214
224
|
}
|
|
215
|
-
}
|
|
225
|
+
});
|
|
216
226
|
}
|
|
217
|
-
|
|
227
|
+
xe(() => {
|
|
218
228
|
var o;
|
|
219
229
|
const e = {
|
|
220
230
|
// 设置语言
|
|
221
231
|
language: "zh_CN",
|
|
222
232
|
// 实例
|
|
223
|
-
target:
|
|
233
|
+
target: R.value,
|
|
224
234
|
// 隐藏品牌
|
|
225
235
|
branding: !1,
|
|
226
236
|
// 隐藏右上角升级按钮
|
|
@@ -295,19 +305,19 @@ const da = /* @__PURE__ */ xe({
|
|
|
295
305
|
convert_urls: !1,
|
|
296
306
|
paste_webkit_styles: "all",
|
|
297
307
|
paste_data_images: !0,
|
|
298
|
-
images_file_types: ((o =
|
|
308
|
+
images_file_types: ((o = m.value.allowedType) == null ? void 0 : o.join(",")) || "jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp",
|
|
299
309
|
// 粘贴前处理
|
|
300
310
|
paste_preprocess(a, t) {
|
|
301
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>");
|
|
302
312
|
},
|
|
303
313
|
// 粘贴后处理(处理异步操作)
|
|
304
314
|
paste_postprocess(a, t) {
|
|
305
|
-
|
|
315
|
+
N(a, t);
|
|
306
316
|
},
|
|
307
317
|
images_upload_handler(a) {
|
|
308
318
|
return new Promise(async (t, n) => {
|
|
309
|
-
var
|
|
310
|
-
if (!((
|
|
319
|
+
var w, I, L;
|
|
320
|
+
if (!((w = m.value) != null && w.handleRequest))
|
|
311
321
|
return n({ message: "缺少图片上传配置", remove: !0 });
|
|
312
322
|
f.value = {
|
|
313
323
|
show: !0,
|
|
@@ -316,26 +326,26 @@ const da = /* @__PURE__ */ xe({
|
|
|
316
326
|
let r = a.blob(), l = r.name ? r.name : a.filename();
|
|
317
327
|
if (!(r != null && r.name) && !(r != null && r.lastModified) && r.type === "image/png")
|
|
318
328
|
return f.value.show = !1, n({ message: "不允许粘贴", remove: !0 });
|
|
319
|
-
const s = await
|
|
320
|
-
imageMaxSize:
|
|
321
|
-
imageAllowedType:
|
|
329
|
+
const s = await be(r, l, {
|
|
330
|
+
imageMaxSize: m.value.maxSize,
|
|
331
|
+
imageAllowedType: m.value.allowedType,
|
|
322
332
|
// imageAllowedMineType: mergeImageUploadOptions.value.allowedMineType,
|
|
323
|
-
imageMinWidth:
|
|
324
|
-
imageMinHeight:
|
|
325
|
-
imageMaxWidth:
|
|
326
|
-
imageMaxHeight:
|
|
333
|
+
imageMinWidth: m.value.minWidth,
|
|
334
|
+
imageMinHeight: m.value.minHeight,
|
|
335
|
+
imageMaxWidth: m.value.maxWidth,
|
|
336
|
+
imageMaxHeight: m.value.maxHeight
|
|
327
337
|
});
|
|
328
338
|
if (!s.success)
|
|
329
339
|
return f.value.show = !1, n({ message: (s == null ? void 0 : s.errorMessage) || "", remove: !0 });
|
|
330
340
|
if (s.hasTransform) {
|
|
331
341
|
r = s.file;
|
|
332
|
-
const
|
|
333
|
-
|
|
342
|
+
const O = l == null ? void 0 : l.split(".");
|
|
343
|
+
O.pop(), l = `${O.join(",")}.jpg`;
|
|
334
344
|
}
|
|
335
|
-
const u = await
|
|
345
|
+
const u = await J(r);
|
|
336
346
|
if (!u.success)
|
|
337
347
|
return f.value.show = !1, n({ message: u == null ? void 0 : u.errorMessage, remove: !0 });
|
|
338
|
-
const p = await ((
|
|
348
|
+
const p = await ((L = (I = m.value).handleRequest) == null ? void 0 : L.call(I, K(u.file, l), l, { extParameters: d.extParameters }));
|
|
339
349
|
if (!p || !p.success)
|
|
340
350
|
return f.value.show = !1, n({ message: p.errorMessage, remove: !0 });
|
|
341
351
|
f.value.show = !1, t(p.url);
|
|
@@ -344,10 +354,10 @@ const da = /* @__PURE__ */ xe({
|
|
|
344
354
|
setup(a) {
|
|
345
355
|
var n, r;
|
|
346
356
|
const t = () => {
|
|
347
|
-
|
|
357
|
+
_.value.dialogVisible = !0, setTimeout(() => {
|
|
348
358
|
var s, u;
|
|
349
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");
|
|
350
|
-
l && (l.innerHTML = ((u =
|
|
360
|
+
l && (l.innerHTML = ((u = m.value) == null ? void 0 : u.tipText) || "上传");
|
|
351
361
|
});
|
|
352
362
|
};
|
|
353
363
|
if (a.ui.registry.addMenuItem("localImage", {
|
|
@@ -363,7 +373,7 @@ const da = /* @__PURE__ */ xe({
|
|
|
363
373
|
v.value.dialogVisible = !0, setTimeout(() => {
|
|
364
374
|
var u, p;
|
|
365
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");
|
|
366
|
-
s && (s.innerHTML = ((p =
|
|
376
|
+
s && (s.innerHTML = ((p = m.value) == null ? void 0 : p.tipText) || "上传");
|
|
367
377
|
});
|
|
368
378
|
};
|
|
369
379
|
a.ui.registry.addMenuItem("localAudio", {
|
|
@@ -393,8 +403,8 @@ const da = /* @__PURE__ */ xe({
|
|
|
393
403
|
}
|
|
394
404
|
}, i = C(
|
|
395
405
|
[
|
|
396
|
-
|
|
397
|
-
|
|
406
|
+
d.options,
|
|
407
|
+
A.options,
|
|
398
408
|
e
|
|
399
409
|
],
|
|
400
410
|
{
|
|
@@ -404,101 +414,101 @@ const da = /* @__PURE__ */ xe({
|
|
|
404
414
|
type: Object
|
|
405
415
|
}
|
|
406
416
|
);
|
|
407
|
-
|
|
417
|
+
X.init(i).then(([a]) => {
|
|
408
418
|
var t;
|
|
409
|
-
a && (a.customProps = { ...
|
|
410
|
-
if (
|
|
411
|
-
|
|
419
|
+
a && (a.customProps = { ...d }, a.on("change input Redo Undo SetContent", () => {
|
|
420
|
+
if (P.value) {
|
|
421
|
+
P.value = !1;
|
|
412
422
|
return;
|
|
413
423
|
}
|
|
414
|
-
D.value = !0,
|
|
424
|
+
D.value = !0, z("input", a.getContent());
|
|
415
425
|
}), a.on("paste", (n) => {
|
|
416
426
|
var l, s;
|
|
417
427
|
const r = ((l = n.clipboardData) == null ? void 0 : l.files) || [];
|
|
418
428
|
for (let u of r) {
|
|
419
|
-
const p =
|
|
420
|
-
(s =
|
|
429
|
+
const p = Q(u.name) || "";
|
|
430
|
+
(s = m.value.allowedType) != null && s.includes(p.toLowerCase()) || n.preventDefault();
|
|
421
431
|
}
|
|
422
|
-
}), (t =
|
|
432
|
+
}), (t = d.initComplete) == null || t.call(d, { editorIns: a }), b.value = a);
|
|
423
433
|
});
|
|
424
|
-
}),
|
|
434
|
+
}), we(() => {
|
|
425
435
|
var e;
|
|
426
|
-
(e =
|
|
436
|
+
(e = b.value) == null || e.destroy();
|
|
427
437
|
});
|
|
428
438
|
const ne = () => {
|
|
429
439
|
var i, o;
|
|
430
440
|
const e = { ...v.value.additionalData || {} };
|
|
431
|
-
return ((o = (i = g.value) == null ? void 0 : i.data) == null ? void 0 : o.call(i, { file: e, extParameters:
|
|
432
|
-
},
|
|
441
|
+
return ((o = (i = g.value) == null ? void 0 : i.data) == null ? void 0 : o.call(i, { file: e, extParameters: d.extParameters })) || {};
|
|
442
|
+
}, le = () => {
|
|
433
443
|
var i, o;
|
|
434
444
|
const e = { ...v.value.additionalData || {} };
|
|
435
|
-
return ((o = (i = g.value) == null ? void 0 : i.headers) == null ? void 0 : o.call(i, { file: e, extParameters:
|
|
436
|
-
},
|
|
445
|
+
return ((o = (i = g.value) == null ? void 0 : i.headers) == null ? void 0 : o.call(i, { file: e, extParameters: d.extParameters })) || {};
|
|
446
|
+
}, re = (e, i, o) => {
|
|
437
447
|
var t, n;
|
|
438
448
|
const a = (n = (t = g == null ? void 0 : g.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t, e);
|
|
439
|
-
a != null && a.url ? o[o.length - 1].url = a.url : a != null && a.errorMessage && (
|
|
440
|
-
},
|
|
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) => {
|
|
441
451
|
var n, r, l, s, u, p;
|
|
442
452
|
const t = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
|
|
443
453
|
if (!((r = (n = g.value) == null ? void 0 : n.allowedType) != null && r.includes(t.toLowerCase()))) {
|
|
444
|
-
|
|
454
|
+
y.error(`请上传格式为${(s = (l = g.value) == null ? void 0 : l.allowedType) == null ? void 0 : s.map((w) => w.toUpperCase()).join("、")}的音频`), a();
|
|
445
455
|
return;
|
|
446
456
|
}
|
|
447
457
|
if (e.size > (((u = g.value) == null ? void 0 : u.maxSize) || 0) * 1024 * 1024) {
|
|
448
|
-
|
|
458
|
+
y.error(`请上传${((p = g.value) == null ? void 0 : p.maxSize) || 0}M内的音频`), a();
|
|
449
459
|
return;
|
|
450
460
|
}
|
|
451
461
|
v.value.additionalData = { file: e }, o(!0);
|
|
452
|
-
}),
|
|
462
|
+
}), ue = (e, i) => {
|
|
453
463
|
v.value.formData.file = i;
|
|
454
464
|
}, me = (e, i, o) => {
|
|
455
|
-
|
|
456
|
-
},
|
|
465
|
+
y.error("上传发生错误,请重试!"), v.value.formData.file = o;
|
|
466
|
+
}, de = () => {
|
|
457
467
|
var i, o;
|
|
458
468
|
const e = { ...x.value.additionalData || {} };
|
|
459
|
-
return ((o = (i = c.value) == null ? void 0 : i.data) == null ? void 0 : o.call(i, { file: e, extParameters:
|
|
460
|
-
},
|
|
469
|
+
return ((o = (i = c.value) == null ? void 0 : i.data) == null ? void 0 : o.call(i, { file: e, extParameters: d.extParameters })) || {};
|
|
470
|
+
}, ce = () => {
|
|
461
471
|
var i, o;
|
|
462
472
|
const e = { ...x.value.additionalData || {} };
|
|
463
|
-
return ((o = (i = c.value) == null ? void 0 : i.headers) == null ? void 0 : o.call(i, { file: e, extParameters:
|
|
464
|
-
},
|
|
473
|
+
return ((o = (i = c.value) == null ? void 0 : i.headers) == null ? void 0 : o.call(i, { file: e, extParameters: d.extParameters })) || {};
|
|
474
|
+
}, pe = (e, i, o) => {
|
|
465
475
|
var t, n;
|
|
466
476
|
const a = (n = (t = c == null ? void 0 : c.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t, e);
|
|
467
|
-
a != null && a.url ? o[o.length - 1].url = a.url : a != null && a.errorMessage && (
|
|
468
|
-
},
|
|
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) => {
|
|
469
479
|
var n, r, l, s, u, p;
|
|
470
480
|
const t = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
|
|
471
481
|
if (!((r = (n = c == null ? void 0 : c.value) == null ? void 0 : n.allowedType) != null && r.includes(t.toLowerCase()))) {
|
|
472
|
-
|
|
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();
|
|
473
483
|
return;
|
|
474
484
|
}
|
|
475
485
|
if (e.size > (((u = c == null ? void 0 : c.value) == null ? void 0 : u.maxSize) || 0) * 1024 * 1024) {
|
|
476
|
-
|
|
486
|
+
y.error(`请上传${((p = c == null ? void 0 : c.value) == null ? void 0 : p.maxSize) || 0}M内的视频`), a();
|
|
477
487
|
return;
|
|
478
488
|
}
|
|
479
489
|
x.value.additionalData = { file: e }, o(!0);
|
|
480
|
-
}),
|
|
490
|
+
}), fe = (e, i) => {
|
|
481
491
|
x.value.formData.file = i;
|
|
482
|
-
},
|
|
483
|
-
|
|
492
|
+
}, ge = (e, i, o) => {
|
|
493
|
+
y.error("上传发生错误,请重试!"), x.value.formData.file = o;
|
|
484
494
|
};
|
|
485
|
-
return S(() => [
|
|
495
|
+
return S(() => [d.disabled, b.value], () => {
|
|
486
496
|
var e, i;
|
|
487
|
-
(i = (e =
|
|
497
|
+
(i = (e = b.value) == null ? void 0 : e.mode) == null || i.set(d.disabled ? "readonly" : "design");
|
|
488
498
|
}, { immediate: !0 }), S(
|
|
489
|
-
() => [
|
|
499
|
+
() => [d.value, b.value],
|
|
490
500
|
() => {
|
|
491
501
|
var e;
|
|
492
502
|
if (D.value) {
|
|
493
503
|
D.value = !1;
|
|
494
504
|
return;
|
|
495
505
|
}
|
|
496
|
-
|
|
506
|
+
P.value = !0, (e = b.value) == null || e.setContent(d.value ? d.value : "");
|
|
497
507
|
},
|
|
498
508
|
{ immediate: !0 }
|
|
499
|
-
), { __sfc: !0, defaultImageUploadOptions:
|
|
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 };
|
|
500
510
|
}
|
|
501
511
|
});
|
|
502
512
|
export {
|
|
503
|
-
|
|
513
|
+
ma as default
|
|
504
514
|
};
|
package/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './style.css';
|
|
2
2
|
import o from "./editor.vue.js";
|
|
3
3
|
import { Button as s, Slider as i, Dialog as n, Upload as r, Tag as u, Form as m, FormItem as l, ButtonGroup as g, InputNumber as c, Loading as b } from "element-ui";
|
|
4
|
-
import { blobToFile as y, getFileExtension as
|
|
4
|
+
import { blobToFile as I, generateUUID as y, getFileExtension as U, getImagePixel as a } from "./util.js";
|
|
5
5
|
const d = {}, x = Object.assign(o, {
|
|
6
6
|
install: (e, t) => {
|
|
7
7
|
Object.assign(d, t || {}), e.use(s), e.use(i), e.use(n), e.use(r), e.use(u), e.use(m), e.use(l), e.use(g), e.use(c), e.use(b), e.component("KbTinymceEditor", o);
|
|
@@ -9,9 +9,10 @@ const d = {}, x = Object.assign(o, {
|
|
|
9
9
|
});
|
|
10
10
|
export {
|
|
11
11
|
x as TinymceEditor,
|
|
12
|
-
|
|
12
|
+
I as blobToFile,
|
|
13
13
|
x as default,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
y as generateUUID,
|
|
15
|
+
U as getFileExtension,
|
|
16
|
+
a as getImagePixel,
|
|
16
17
|
d as globalProps
|
|
17
18
|
};
|
package/es/util.d.ts
CHANGED
package/es/util.js
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
function
|
|
1
|
+
function o(e) {
|
|
2
2
|
return new Promise((n) => {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
n({ width:
|
|
6
|
-
},
|
|
7
|
-
n(void 0);
|
|
8
|
-
},
|
|
3
|
+
const t = new Image();
|
|
4
|
+
t.onload = function() {
|
|
5
|
+
n({ width: t.width, height: t.height, image: t }), t.remove();
|
|
6
|
+
}, t.onerror = function(i) {
|
|
7
|
+
n(void 0), t.remove();
|
|
8
|
+
}, t.src = e;
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function r(e) {
|
|
12
12
|
const n = e.split(".");
|
|
13
13
|
return n ? n[n.length - 1] : "";
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function c(e, n) {
|
|
16
16
|
return e.name ? e : new File([e], n, { type: e.type });
|
|
17
17
|
}
|
|
18
|
+
function g() {
|
|
19
|
+
const e = Date.now().toString(16), n = Math.random().toString(16).slice(2);
|
|
20
|
+
return `${e}-${n}`;
|
|
21
|
+
}
|
|
18
22
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
r as
|
|
23
|
+
c as blobToFile,
|
|
24
|
+
g as generateUUID,
|
|
25
|
+
r as getFileExtension,
|
|
26
|
+
o as getImagePixel
|
|
22
27
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@keyblade/tinymce-editor-vue2",
|
|
3
3
|
"description": "KeyBlade Tinymce Editor Vue2",
|
|
4
4
|
"author": "yangshuai <704807396@qq.com>",
|
|
5
|
-
"version": "0.0.12-alpha.
|
|
5
|
+
"version": "0.0.12-alpha.38",
|
|
6
6
|
"private": false,
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "es/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"vue-global-config": "^0.2.6",
|
|
24
24
|
"tinymce": "^7.1.0",
|
|
25
25
|
"element-ui": "^2.15.14",
|
|
26
|
-
"@keyblade/one-travel": "^2.0.
|
|
26
|
+
"@keyblade/one-travel": "^2.0.8"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"vue": "^2.7.0",
|