@keyblade/tinymce-editor-vue2 0.0.12-alpha.48 → 0.0.12-alpha.50
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 +221 -325
- package/package.json +2 -2
package/es/editor.vue2.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { oneTravelImgPondBeforeAddFile as
|
|
3
|
-
import { blobToFile as
|
|
1
|
+
import { defineComponent as be, ref as b, computed as C, watch as z, onMounted as ye, onUnmounted as _e } from "vue";
|
|
2
|
+
import { oneTravelImgPondBeforeAddFile as J, oneTravelImageCompressor as K, oneTravelImageCheckAndTransform as De } from "@keyblade/one-travel";
|
|
3
|
+
import { blobToFile as Q, getImagePixel as Ae, getFileExtension as Ce } from "./util.js";
|
|
4
4
|
import "./style.less.js";
|
|
5
|
-
import
|
|
6
|
-
import { conclude as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
5
|
+
import Te from "imgpond";
|
|
6
|
+
import { conclude as T } from "vue-global-config";
|
|
7
|
+
import Y from "tinymce";
|
|
8
|
+
import Pe 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";
|
|
@@ -35,8 +35,8 @@ import "tinymce/plugins/visualblocks";
|
|
|
35
35
|
import "tinymce/plugins/visualchars";
|
|
36
36
|
import "tinymce/plugins/wordcount";
|
|
37
37
|
import { globalProps as P } from "./index.js";
|
|
38
|
-
import { Message as
|
|
39
|
-
const
|
|
38
|
+
import { Message as p } from "element-ui";
|
|
39
|
+
const pa = /* @__PURE__ */ be({
|
|
40
40
|
__name: "editor",
|
|
41
41
|
props: {
|
|
42
42
|
value: { default: "" },
|
|
@@ -50,10 +50,10 @@ const va = /* @__PURE__ */ De({
|
|
|
50
50
|
initComplete: null
|
|
51
51
|
},
|
|
52
52
|
emits: ["input"],
|
|
53
|
-
setup(
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
const
|
|
53
|
+
setup(Z, { emit: M }) {
|
|
54
|
+
const s = Z;
|
|
55
|
+
Y.addI18n("zh_CN", Pe);
|
|
56
|
+
const j = {
|
|
57
57
|
maxCount: 10,
|
|
58
58
|
tipText: "上传",
|
|
59
59
|
maxSize: 30,
|
|
@@ -62,7 +62,7 @@ const va = /* @__PURE__ */ De({
|
|
|
62
62
|
minHeight: 50,
|
|
63
63
|
maxWidth: 6e3,
|
|
64
64
|
maxHeight: 6e3
|
|
65
|
-
},
|
|
65
|
+
}, B = {
|
|
66
66
|
enable: !0,
|
|
67
67
|
maxSize: 300,
|
|
68
68
|
allowedType: ["mp4", "3gp"],
|
|
@@ -72,65 +72,65 @@ const va = /* @__PURE__ */ De({
|
|
|
72
72
|
maxSize: 200,
|
|
73
73
|
allowedType: ["mp3", "m4a", "wav", "aac"],
|
|
74
74
|
accept: "audio/mp3,audio/wav,audio/aac,audio/x-m4a"
|
|
75
|
-
}, E =
|
|
75
|
+
}, E = b(), h = b(), S = b(!1), k = b(!1), f = b({
|
|
76
76
|
show: !1,
|
|
77
77
|
text: "图片上传中,请稍等"
|
|
78
|
-
}), r =
|
|
78
|
+
}), r = C(() => T([s.imageUploadOptions, P.imageUploadOptions, j]) || {}), u = C(() => T([s.videoUploadOptions, P.videoUploadOptions, B]) || {}), w = C(() => T([s.audioUploadOptions, P.audioUploadOptions, q]) || {}), V = C(() => T([s.imgPondOptions, P.imgPondOptions]) || {}), ee = C(() => {
|
|
79
79
|
var e, a;
|
|
80
|
-
return ((a = (e = r == null ? void 0 : r.value) == null ? void 0 : e.allowedType) == null ? void 0 : a.map((
|
|
81
|
-
}), U =
|
|
82
|
-
|
|
83
|
-
U.value &&
|
|
80
|
+
return ((a = (e = r == null ? void 0 : r.value) == null ? void 0 : e.allowedType) == null ? void 0 : a.map((o) => `.${o}`).join(",")) || "";
|
|
81
|
+
}), U = b();
|
|
82
|
+
z(() => U.value, () => {
|
|
83
|
+
U.value && J(U.value, {
|
|
84
84
|
onStart: () => {
|
|
85
|
-
|
|
85
|
+
f.value = {
|
|
86
86
|
show: !0,
|
|
87
87
|
text: "图片加载中,请稍等"
|
|
88
88
|
};
|
|
89
89
|
},
|
|
90
90
|
onSuccess: () => {
|
|
91
|
-
|
|
91
|
+
f.value.show = !1;
|
|
92
92
|
},
|
|
93
93
|
onError: (e) => {
|
|
94
|
-
|
|
94
|
+
f.value.show = !1, p.error({ message: e, customClass: "tinymce-editor-message", duration: 2e4 });
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
}, { immediate: !0 });
|
|
98
|
-
const I =
|
|
99
|
-
|
|
100
|
-
I.value &&
|
|
98
|
+
const I = b();
|
|
99
|
+
z(() => I.value, () => {
|
|
100
|
+
I.value && J(I.value, {
|
|
101
101
|
onStart: () => {
|
|
102
|
-
|
|
102
|
+
f.value = {
|
|
103
103
|
show: !0,
|
|
104
104
|
text: "图片加载中,请稍等"
|
|
105
105
|
};
|
|
106
106
|
},
|
|
107
107
|
onSuccess: () => {
|
|
108
|
-
|
|
108
|
+
f.value.show = !1;
|
|
109
109
|
},
|
|
110
110
|
onError: (e) => {
|
|
111
|
-
|
|
111
|
+
f.value.show = !1, p.error(e);
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
}, { immediate: !0 });
|
|
115
|
-
const A =
|
|
115
|
+
const A = b({
|
|
116
116
|
dialogVisible: !1,
|
|
117
117
|
formData: {
|
|
118
118
|
images: []
|
|
119
119
|
}
|
|
120
|
-
}), $ =
|
|
120
|
+
}), $ = b(), R = () => {
|
|
121
121
|
A.value.dialogVisible = !1, A.value.formData = {
|
|
122
122
|
images: []
|
|
123
123
|
};
|
|
124
|
-
},
|
|
124
|
+
}, ae = () => {
|
|
125
125
|
var e;
|
|
126
126
|
(e = $.value) == null || e.validate((a) => {
|
|
127
|
-
a && (A.value.formData.images.forEach((
|
|
128
|
-
var
|
|
129
|
-
let
|
|
130
|
-
|
|
127
|
+
a && (A.value.formData.images.forEach((o) => {
|
|
128
|
+
var i;
|
|
129
|
+
let t = o;
|
|
130
|
+
V.value.srcAt && (t = (o == null ? void 0 : o[V.value.srcAt]) || ""), (i = h.value) == null || i.insertContent(`<img src=${t} alt="" />`);
|
|
131
131
|
}), R());
|
|
132
132
|
});
|
|
133
|
-
}, x =
|
|
133
|
+
}, x = b({
|
|
134
134
|
dialogVisible: !1,
|
|
135
135
|
formData: {
|
|
136
136
|
// 名称
|
|
@@ -142,19 +142,19 @@ const va = /* @__PURE__ */ De({
|
|
|
142
142
|
},
|
|
143
143
|
// 用于临时保存上传前的参数 { file: File }
|
|
144
144
|
additionalData: {}
|
|
145
|
-
}),
|
|
145
|
+
}), W = b(), F = () => {
|
|
146
146
|
x.value.dialogVisible = !1, x.value.formData = {
|
|
147
147
|
name: "",
|
|
148
148
|
cover: [],
|
|
149
149
|
file: []
|
|
150
150
|
}, x.value.additionalData = {};
|
|
151
|
-
},
|
|
151
|
+
}, oe = () => {
|
|
152
152
|
var e;
|
|
153
|
-
(e =
|
|
154
|
-
var
|
|
155
|
-
a && ((
|
|
153
|
+
(e = W.value) == null || e.validate((a) => {
|
|
154
|
+
var o, t;
|
|
155
|
+
a && ((t = h.value) == null || t.insertContent(`<audio controls controlslist="nodownload noplaybackrate" data-name="${x.value.formData.name}" data-poster="${x.value.formData.cover[0]}" src="${(o = x.value.formData.file[0]) == null ? void 0 : o.url}"></audio>`), F());
|
|
156
156
|
});
|
|
157
|
-
},
|
|
157
|
+
}, y = b({
|
|
158
158
|
dialogVisible: !1,
|
|
159
159
|
formData: {
|
|
160
160
|
// 文件
|
|
@@ -162,86 +162,55 @@ const va = /* @__PURE__ */ De({
|
|
|
162
162
|
},
|
|
163
163
|
// 用于临时保存上传前的参数 { file: File }
|
|
164
164
|
additionalData: {}
|
|
165
|
-
}),
|
|
166
|
-
|
|
165
|
+
}), N = b(), O = () => {
|
|
166
|
+
y.value.dialogVisible = !1, y.value.formData = {
|
|
167
167
|
file: []
|
|
168
|
-
},
|
|
169
|
-
},
|
|
168
|
+
}, y.value.additionalData = {};
|
|
169
|
+
}, te = () => {
|
|
170
170
|
var e;
|
|
171
|
-
(e =
|
|
172
|
-
var
|
|
173
|
-
a && ((
|
|
171
|
+
(e = N.value) == null || e.validate((a) => {
|
|
172
|
+
var o, t;
|
|
173
|
+
a && ((t = h.value) == null || t.insertContent(`<video width="auto" height="auto" controls src="${(o = y.value.formData.file[0]) == null ? void 0 : o.url}"></video>`), O());
|
|
174
174
|
});
|
|
175
|
-
},
|
|
175
|
+
}, ie = () => {
|
|
176
176
|
document.querySelectorAll(".swal2-container .swal2-title").forEach((e) => {
|
|
177
177
|
e && (e.innerHTML = `单次最多可选择${r.value.maxCount}张图片`);
|
|
178
178
|
});
|
|
179
|
-
},
|
|
180
|
-
var
|
|
181
|
-
const
|
|
182
|
-
if (!
|
|
183
|
-
|
|
184
|
-
a.onError(
|
|
179
|
+
}, le = (e, a) => new Promise(async (o, t) => {
|
|
180
|
+
var c, n;
|
|
181
|
+
const i = await K(e);
|
|
182
|
+
if (!i.success) {
|
|
183
|
+
t(), setTimeout(() => {
|
|
184
|
+
a.onError(i.errorMessage);
|
|
185
185
|
});
|
|
186
186
|
return;
|
|
187
187
|
}
|
|
188
|
-
const
|
|
189
|
-
if (!
|
|
190
|
-
|
|
191
|
-
a.onError(
|
|
188
|
+
const l = await ((n = (c = r.value).handleRequest) == null ? void 0 : n.call(c, Q(i.file, e.name), e.name, { extParameters: s.extParameters }));
|
|
189
|
+
if (!l || !(l != null && l.success)) {
|
|
190
|
+
t(), setTimeout(() => {
|
|
191
|
+
a.onError(l == null ? void 0 : l.errorMessage);
|
|
192
192
|
});
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
195
|
-
|
|
195
|
+
o(l.url);
|
|
196
196
|
});
|
|
197
|
-
async function
|
|
198
|
-
|
|
199
|
-
for (let i = o.length - 1; i >= 0; i--) {
|
|
200
|
-
const d = o[i], n = "img-" + Pe();
|
|
201
|
-
d.classList.add(n), l.push(n);
|
|
202
|
-
}
|
|
203
|
-
setTimeout(async () => {
|
|
204
|
-
var i, d;
|
|
205
|
-
for (let n = l.length - 1; n >= 0; n--) {
|
|
206
|
-
const u = e.dom.select(`.${l[n]}`);
|
|
207
|
-
if (u.length === 0)
|
|
208
|
-
continue;
|
|
209
|
-
const s = u[0], p = s.src;
|
|
210
|
-
if (p.startsWith("data:image")) {
|
|
211
|
-
e.dom.remove(s);
|
|
212
|
-
continue;
|
|
213
|
-
} else if (p.startsWith("http://") || p.startsWith("https://")) {
|
|
214
|
-
const b = await Z(p);
|
|
215
|
-
if (b && (b.width < (r.value.minWidth || 0) && b.height < (r.value.minHeight || 0) || b.width > (r.value.maxWidth || 0) && b.height > (r.value.maxHeight || 0))) {
|
|
216
|
-
e.dom.remove(s);
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
const W = ee(p);
|
|
220
|
-
if (!((d = (i = r.value) == null ? void 0 : i.allowedType) != null && d.includes(W.toLowerCase()))) {
|
|
221
|
-
e.dom.remove(s);
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
async function G(e) {
|
|
229
|
-
var d, n, u;
|
|
197
|
+
async function L(e) {
|
|
198
|
+
var c, n, d;
|
|
230
199
|
let a = e;
|
|
231
|
-
if (!((
|
|
232
|
-
|
|
200
|
+
if (!((c = r.value) != null && c.handleRequest)) {
|
|
201
|
+
p.error("缺少图片上传配置");
|
|
233
202
|
return;
|
|
234
203
|
}
|
|
235
|
-
|
|
204
|
+
f.value = {
|
|
236
205
|
show: !0,
|
|
237
206
|
text: "图片上传中,请稍等"
|
|
238
207
|
};
|
|
239
|
-
let
|
|
208
|
+
let o = a.name ? a.name : "";
|
|
240
209
|
if (!(a != null && a.name) && !(a != null && a.lastModified) && a.type === "image/png") {
|
|
241
|
-
|
|
210
|
+
f.value.show = !1, p.error("不允许粘贴");
|
|
242
211
|
return;
|
|
243
212
|
}
|
|
244
|
-
const
|
|
213
|
+
const t = await De(a, o, {
|
|
245
214
|
imageMaxSize: r.value.maxSize,
|
|
246
215
|
imageAllowedType: r.value.allowedType,
|
|
247
216
|
// imageAllowedMineType: mergeImageUploadOptions.value.allowedMineType,
|
|
@@ -250,82 +219,82 @@ const va = /* @__PURE__ */ De({
|
|
|
250
219
|
imageMaxWidth: r.value.maxWidth,
|
|
251
220
|
imageMaxHeight: r.value.maxHeight
|
|
252
221
|
});
|
|
253
|
-
if (!
|
|
254
|
-
|
|
222
|
+
if (!t.success) {
|
|
223
|
+
f.value.show = !1, p.error((t == null ? void 0 : t.errorMessage) || "");
|
|
255
224
|
return;
|
|
256
225
|
}
|
|
257
|
-
if (
|
|
258
|
-
a =
|
|
259
|
-
const
|
|
260
|
-
|
|
226
|
+
if (t.hasTransform) {
|
|
227
|
+
a = t.file;
|
|
228
|
+
const m = o == null ? void 0 : o.split(".");
|
|
229
|
+
m.pop(), o = `${m.join(",")}.jpg`;
|
|
261
230
|
}
|
|
262
|
-
const
|
|
263
|
-
if (!
|
|
264
|
-
|
|
231
|
+
const i = await K(a);
|
|
232
|
+
if (!i.success) {
|
|
233
|
+
f.value.show = !1, p.error((i == null ? void 0 : i.errorMessage) || "压缩失败");
|
|
265
234
|
return;
|
|
266
235
|
}
|
|
267
|
-
const
|
|
268
|
-
if (!
|
|
269
|
-
|
|
236
|
+
const l = await ((d = (n = r.value).handleRequest) == null ? void 0 : d.call(n, Q(i.file, o), o, { extParameters: s.extParameters }));
|
|
237
|
+
if (!l || !l.success) {
|
|
238
|
+
f.value.show = !1, p.error((l == null ? void 0 : l.errorMessage) || "");
|
|
270
239
|
return;
|
|
271
240
|
}
|
|
272
|
-
return
|
|
241
|
+
return f.value.show = !1, l.url;
|
|
273
242
|
}
|
|
274
|
-
const
|
|
275
|
-
var
|
|
276
|
-
const a = h.value,
|
|
277
|
-
if (
|
|
278
|
-
const n = e.getData("text/html"),
|
|
279
|
-
|
|
243
|
+
const H = async (e) => {
|
|
244
|
+
var i, l, c;
|
|
245
|
+
const a = h.value, o = e.types;
|
|
246
|
+
if (o.includes("text/html")) {
|
|
247
|
+
const n = e.getData("text/html"), m = new DOMParser().parseFromString(n, "text/html"), v = Array.from(m.body.querySelectorAll("img")), D = Array.from(m.body.querySelectorAll("audio")), xe = Array.from(m.body.querySelectorAll("video"));
|
|
248
|
+
v.length > 0 && (f.value = {
|
|
280
249
|
show: !0,
|
|
281
250
|
text: "图片加载中,请稍等"
|
|
282
251
|
});
|
|
283
|
-
for (const
|
|
284
|
-
|
|
285
|
-
for await (const
|
|
286
|
-
if (
|
|
287
|
-
if ((
|
|
288
|
-
const g = await ((
|
|
289
|
-
g != null && g.success && (g != null && g.url) ?
|
|
252
|
+
for (const _ of [...D, ...xe])
|
|
253
|
+
_ == null || _.remove();
|
|
254
|
+
for await (const _ of [...v])
|
|
255
|
+
if (_.removeAttribute("crossorigin"), _.src.startsWith("http"))
|
|
256
|
+
if ((i = r.value) != null && i.handleRequestByUrl) {
|
|
257
|
+
const g = await ((l = r.value) == null ? void 0 : l.handleRequestByUrl(_.src, { extParameters: s.extParameters }));
|
|
258
|
+
g != null && g.success && (g != null && g.url) ? _.src = g == null ? void 0 : g.url : _.remove();
|
|
290
259
|
} else {
|
|
291
|
-
const g = await
|
|
292
|
-
g && (g.width < (r.value.minWidth || 0) && g.height < (r.value.minHeight || 0) || g.width > (r.value.maxWidth || 0) && g.height > (r.value.maxHeight || 0)) &&
|
|
260
|
+
const g = await Ae(_.src);
|
|
261
|
+
g && (g.width < (r.value.minWidth || 0) && g.height < (r.value.minHeight || 0) || g.width > (r.value.maxWidth || 0) && g.height > (r.value.maxHeight || 0)) && _.remove();
|
|
293
262
|
}
|
|
294
263
|
else
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
a.insertContent(
|
|
264
|
+
_.remove(), p.error("不支持Word中批量复制图片或视频,请改为单个复制,或者从工具栏中手动插入上传");
|
|
265
|
+
f.value.show = !1;
|
|
266
|
+
const we = new XMLSerializer().serializeToString(m.body);
|
|
267
|
+
a.insertContent(we);
|
|
299
268
|
} else
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
for await (const n of
|
|
303
|
-
const
|
|
304
|
-
if (!
|
|
269
|
+
o.includes("text/plain") && a.insertContent(e.getData("text/plain"));
|
|
270
|
+
const t = Array.from(e.items);
|
|
271
|
+
for await (const n of t) {
|
|
272
|
+
const d = n.getAsFile();
|
|
273
|
+
if (!d)
|
|
305
274
|
continue;
|
|
306
|
-
const
|
|
307
|
-
if (
|
|
308
|
-
const
|
|
309
|
-
if (
|
|
310
|
-
const
|
|
311
|
-
a.insertContent(
|
|
275
|
+
const m = Ce(d.name);
|
|
276
|
+
if (d.type.indexOf("image") > -1 || (c = r.value.allowedType) != null && c.includes(m.toLowerCase())) {
|
|
277
|
+
const v = await L(d);
|
|
278
|
+
if (v) {
|
|
279
|
+
const D = `<img src="${v}" alt="" />`;
|
|
280
|
+
a.insertContent(D);
|
|
312
281
|
}
|
|
313
282
|
}
|
|
314
283
|
}
|
|
315
|
-
|
|
316
|
-
},
|
|
317
|
-
var
|
|
284
|
+
M("input", a.getContent());
|
|
285
|
+
}, G = (e) => {
|
|
286
|
+
var o;
|
|
318
287
|
e.preventDefault();
|
|
319
|
-
const a = e.clipboardData || ((
|
|
320
|
-
|
|
321
|
-
},
|
|
322
|
-
var
|
|
288
|
+
const a = e.clipboardData || ((o = e == null ? void 0 : e.originalEvent) == null ? void 0 : o.clipboardData);
|
|
289
|
+
H(a);
|
|
290
|
+
}, X = (e) => {
|
|
291
|
+
var o;
|
|
323
292
|
e.preventDefault();
|
|
324
|
-
const a = e.dataTransfer || ((
|
|
325
|
-
|
|
293
|
+
const a = e.dataTransfer || ((o = e == null ? void 0 : e.originalEvent) == null ? void 0 : o.dataTransfer);
|
|
294
|
+
H(a);
|
|
326
295
|
};
|
|
327
|
-
|
|
328
|
-
var
|
|
296
|
+
ye(() => {
|
|
297
|
+
var o;
|
|
329
298
|
const e = {
|
|
330
299
|
// 设置语言
|
|
331
300
|
language: "zh_CN",
|
|
@@ -408,241 +377,168 @@ const va = /* @__PURE__ */ De({
|
|
|
408
377
|
convert_urls: !1,
|
|
409
378
|
paste_webkit_styles: "all",
|
|
410
379
|
paste_data_images: !1,
|
|
411
|
-
images_file_types: ((
|
|
380
|
+
images_file_types: ((o = r.value.allowedType) == null ? void 0 : o.join(",")) || "jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp",
|
|
412
381
|
// 粘贴前处理
|
|
413
|
-
paste_preprocess(
|
|
414
|
-
|
|
382
|
+
paste_preprocess(t, i) {
|
|
383
|
+
i == null || i.preventDefault();
|
|
415
384
|
},
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
// processPastedImage(editor, args)
|
|
420
|
-
// },
|
|
421
|
-
// images_upload_handler(blobInfo) {
|
|
422
|
-
// // eslint-disable-next-line no-async-promise-executor
|
|
423
|
-
// return new Promise(async (resolve, reject) => {
|
|
424
|
-
// // 校验图片配置
|
|
425
|
-
// if (!mergeImageUploadOptions.value?.handleRequest) {
|
|
426
|
-
// removeNotification()
|
|
427
|
-
// return reject({ message: '缺少图片上传配置', remove: true })
|
|
428
|
-
// }
|
|
429
|
-
//
|
|
430
|
-
// uploadLoadingConfig.value = {
|
|
431
|
-
// show: true,
|
|
432
|
-
// text: '图片上传中,请稍等'
|
|
433
|
-
// }
|
|
434
|
-
//
|
|
435
|
-
// // 获取文件 blob 数据
|
|
436
|
-
// // 1.从本地复制图片都是 File 对象,chrome 复制非图片文件,都是 blob,且为 png
|
|
437
|
-
// let file = blobInfo.blob()
|
|
438
|
-
// // 有名称,则取真实名称
|
|
439
|
-
// let filename = (file as File).name ? (file as File).name : blobInfo.filename()
|
|
440
|
-
// if (!(file as File)?.name && !(file as File)?.lastModified && file.type === 'image/png') {// chrome 复制非图片格式
|
|
441
|
-
// uploadLoadingConfig.value.show = false
|
|
442
|
-
// removeNotification()
|
|
443
|
-
// return reject({ message: '不允许粘贴', remove: true })
|
|
444
|
-
// }
|
|
445
|
-
//
|
|
446
|
-
// // 图片校验
|
|
447
|
-
// const checkRes = await oneTravelImageCheckAndTransform(file, filename, {
|
|
448
|
-
// imageMaxSize: mergeImageUploadOptions.value.maxSize,
|
|
449
|
-
// imageAllowedType: mergeImageUploadOptions.value.allowedType,
|
|
450
|
-
// imageMinWidth: mergeImageUploadOptions.value.minWidth,
|
|
451
|
-
// imageMinHeight: mergeImageUploadOptions.value.minHeight,
|
|
452
|
-
// imageMaxWidth: mergeImageUploadOptions.value.maxWidth,
|
|
453
|
-
// imageMaxHeight: mergeImageUploadOptions.value.maxHeight
|
|
454
|
-
// })
|
|
455
|
-
// if (!checkRes.success) {
|
|
456
|
-
// uploadLoadingConfig.value.show = false
|
|
457
|
-
// removeNotification()
|
|
458
|
-
// return reject({ message: checkRes?.errorMessage || '', remove: true })
|
|
459
|
-
// }
|
|
460
|
-
// if (checkRes.hasTransform) {// 被转换
|
|
461
|
-
// // 修改文件
|
|
462
|
-
// file = checkRes.file!
|
|
463
|
-
//
|
|
464
|
-
// // 修改名称
|
|
465
|
-
// const arr = filename?.split('.')
|
|
466
|
-
// arr.pop()
|
|
467
|
-
// const prefix = arr.join(',')
|
|
468
|
-
// filename = `${prefix}.jpg`
|
|
469
|
-
// }
|
|
470
|
-
//
|
|
471
|
-
// // 图片压缩
|
|
472
|
-
// const compressorRes = await oneTravelImageCompressor(file)
|
|
473
|
-
// if (!compressorRes.success) {
|
|
474
|
-
// uploadLoadingConfig.value.show = false
|
|
475
|
-
// removeNotification()
|
|
476
|
-
// return reject({ message: compressorRes?.errorMessage, remove: true })
|
|
477
|
-
// }
|
|
478
|
-
//
|
|
479
|
-
// // 上传图片
|
|
480
|
-
// const uploadRes = await mergeImageUploadOptions.value.handleRequest?.(blobToFile(compressorRes.file, filename), filename, { extParameters: props.extParameters })
|
|
481
|
-
// if (!uploadRes || !uploadRes.success) {
|
|
482
|
-
// uploadLoadingConfig.value.show = false
|
|
483
|
-
// removeNotification()
|
|
484
|
-
// return reject({ message: uploadRes.errorMessage, remove: true })
|
|
485
|
-
// }
|
|
486
|
-
//
|
|
487
|
-
// uploadLoadingConfig.value.show = false
|
|
488
|
-
// resolve(uploadRes.url!)
|
|
489
|
-
// })
|
|
490
|
-
// },
|
|
491
|
-
setup(o) {
|
|
492
|
-
var i, d;
|
|
493
|
-
const l = () => {
|
|
385
|
+
setup(t) {
|
|
386
|
+
var l, c;
|
|
387
|
+
const i = () => {
|
|
494
388
|
A.value.dialogVisible = !0, setTimeout(() => {
|
|
495
|
-
var
|
|
496
|
-
const n = (
|
|
497
|
-
n && (n.innerHTML = ((
|
|
389
|
+
var d, m;
|
|
390
|
+
const n = (d = document == null ? void 0 : document.querySelector) == null ? void 0 : d.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
|
|
391
|
+
n && (n.innerHTML = ((m = r.value) == null ? void 0 : m.tipText) || "上传");
|
|
498
392
|
});
|
|
499
393
|
};
|
|
500
|
-
if (
|
|
394
|
+
if (t.ui.registry.addMenuItem("localImage", {
|
|
501
395
|
text: "图片",
|
|
502
396
|
icon: "image",
|
|
503
|
-
onAction: () =>
|
|
504
|
-
}),
|
|
397
|
+
onAction: () => i()
|
|
398
|
+
}), t.ui.registry.addButton("localImage", {
|
|
505
399
|
icon: "image",
|
|
506
400
|
tooltip: "图片",
|
|
507
|
-
onAction: () =>
|
|
508
|
-
}), (
|
|
401
|
+
onAction: () => i()
|
|
402
|
+
}), (l = w == null ? void 0 : w.value) != null && l.enable) {
|
|
509
403
|
const n = () => {
|
|
510
404
|
x.value.dialogVisible = !0, setTimeout(() => {
|
|
511
|
-
var
|
|
512
|
-
const
|
|
513
|
-
|
|
405
|
+
var m, v;
|
|
406
|
+
const d = (m = document == null ? void 0 : document.querySelector) == null ? void 0 : m.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
|
|
407
|
+
d && (d.innerHTML = ((v = r.value) == null ? void 0 : v.tipText) || "上传");
|
|
514
408
|
});
|
|
515
409
|
};
|
|
516
|
-
|
|
410
|
+
t.ui.registry.addMenuItem("localAudio", {
|
|
517
411
|
text: "音频",
|
|
518
412
|
icon: "arrow-right",
|
|
519
413
|
onAction: () => n()
|
|
520
|
-
}),
|
|
414
|
+
}), t.ui.registry.addButton("localAudio", {
|
|
521
415
|
icon: "arrow-right",
|
|
522
416
|
tooltip: "音频",
|
|
523
417
|
onAction: () => n()
|
|
524
418
|
});
|
|
525
419
|
}
|
|
526
|
-
if ((
|
|
420
|
+
if ((c = u == null ? void 0 : u.value) != null && c.enable) {
|
|
527
421
|
const n = () => {
|
|
528
|
-
|
|
422
|
+
y.value.dialogVisible = !0;
|
|
529
423
|
};
|
|
530
|
-
|
|
424
|
+
t.ui.registry.addMenuItem("localVideo", {
|
|
531
425
|
text: "视频",
|
|
532
426
|
icon: "embed",
|
|
533
427
|
onAction: () => n()
|
|
534
|
-
}),
|
|
428
|
+
}), t.ui.registry.addButton("localVideo", {
|
|
535
429
|
icon: "embed",
|
|
536
430
|
tooltip: "视频",
|
|
537
431
|
onAction: () => n()
|
|
538
432
|
});
|
|
539
433
|
}
|
|
540
434
|
}
|
|
541
|
-
}, a =
|
|
435
|
+
}, a = T(
|
|
542
436
|
[
|
|
543
|
-
|
|
437
|
+
s.options,
|
|
544
438
|
P.options,
|
|
545
439
|
e
|
|
546
440
|
],
|
|
547
441
|
{
|
|
548
|
-
mergeFunction: (
|
|
549
|
-
|
|
442
|
+
mergeFunction: (t, i) => (...l) => {
|
|
443
|
+
t(...l), i(...l);
|
|
550
444
|
},
|
|
551
445
|
type: Object
|
|
552
446
|
}
|
|
553
447
|
);
|
|
554
|
-
|
|
555
|
-
var
|
|
556
|
-
|
|
557
|
-
if (
|
|
558
|
-
|
|
448
|
+
Y.init(a).then(([t]) => {
|
|
449
|
+
var i;
|
|
450
|
+
t && (t.customProps = { ...s }, t.on("input", () => {
|
|
451
|
+
if (k.value) {
|
|
452
|
+
k.value = !1;
|
|
559
453
|
return;
|
|
560
454
|
}
|
|
561
|
-
|
|
562
|
-
}),
|
|
563
|
-
|
|
564
|
-
}),
|
|
565
|
-
|
|
566
|
-
}),
|
|
455
|
+
S.value = !0, M("input", t.getContent());
|
|
456
|
+
}), t.on("change", () => {
|
|
457
|
+
M("input", t.getContent());
|
|
458
|
+
}), t.on("paste", (l) => {
|
|
459
|
+
G(l);
|
|
460
|
+
}), t.on("drop", (l) => {
|
|
461
|
+
X(l);
|
|
462
|
+
}), (i = s.initComplete) == null || i.call(s, { editorIns: t }), h.value = t);
|
|
567
463
|
});
|
|
568
|
-
}),
|
|
569
|
-
var e, a,
|
|
570
|
-
(e = h.value) == null || e.off("input"), (a = h.value) == null || a.off("paste"), (
|
|
464
|
+
}), _e(() => {
|
|
465
|
+
var e, a, o, t;
|
|
466
|
+
(e = h.value) == null || e.off("input"), (a = h.value) == null || a.off("paste"), (o = h.value) == null || o.off("drop"), (t = h.value) == null || t.destroy();
|
|
571
467
|
});
|
|
572
|
-
const
|
|
573
|
-
var a,
|
|
468
|
+
const re = () => {
|
|
469
|
+
var a, o;
|
|
574
470
|
const e = { ...x.value.additionalData || {} };
|
|
575
|
-
return ((
|
|
576
|
-
},
|
|
577
|
-
var a,
|
|
471
|
+
return ((o = (a = w.value) == null ? void 0 : a.data) == null ? void 0 : o.call(a, { ...e, extParameters: s.extParameters })) || {};
|
|
472
|
+
}, ne = () => {
|
|
473
|
+
var a, o;
|
|
578
474
|
const e = { ...x.value.additionalData || {} };
|
|
579
|
-
return ((
|
|
580
|
-
},
|
|
581
|
-
var
|
|
582
|
-
const
|
|
583
|
-
|
|
584
|
-
},
|
|
585
|
-
var
|
|
586
|
-
const
|
|
587
|
-
if (!((
|
|
588
|
-
|
|
475
|
+
return ((o = (a = w.value) == null ? void 0 : a.headers) == null ? void 0 : o.call(a, { ...e, extParameters: s.extParameters })) || {};
|
|
476
|
+
}, se = (e, a, o) => {
|
|
477
|
+
var i, l;
|
|
478
|
+
const t = (l = (i = w == null ? void 0 : w.value) == null ? void 0 : i.handlerResponse) == null ? void 0 : l.call(i, e);
|
|
479
|
+
t != null && t.url ? o[o.length - 1].url = t.url : t != null && t.errorMessage && (p.error(t.errorMessage), o.splice(o.length - 1, 1)), x.value.formData.file = o;
|
|
480
|
+
}, ue = (e, a) => new Promise((o, t) => {
|
|
481
|
+
var l, c, n, d, m, v;
|
|
482
|
+
const i = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
|
|
483
|
+
if (!((c = (l = w.value) == null ? void 0 : l.allowedType) != null && c.includes(i.toLowerCase()))) {
|
|
484
|
+
p.error(`请上传格式为${(d = (n = w.value) == null ? void 0 : n.allowedType) == null ? void 0 : d.map((D) => D.toUpperCase()).join("、")}的音频`), t();
|
|
589
485
|
return;
|
|
590
486
|
}
|
|
591
|
-
if (e.size > (((
|
|
592
|
-
|
|
487
|
+
if (e.size > (((m = w.value) == null ? void 0 : m.maxSize) || 0) * 1024 * 1024) {
|
|
488
|
+
p.error(`请上传${((v = w.value) == null ? void 0 : v.maxSize) || 0}M内的音频`), t();
|
|
593
489
|
return;
|
|
594
490
|
}
|
|
595
|
-
x.value.additionalData = { file: e },
|
|
596
|
-
}),
|
|
491
|
+
x.value.additionalData = { file: e }, o(!0);
|
|
492
|
+
}), me = (e, a) => {
|
|
597
493
|
x.value.formData.file = a;
|
|
598
|
-
},
|
|
599
|
-
|
|
600
|
-
},
|
|
601
|
-
var a,
|
|
602
|
-
const e = { ...
|
|
603
|
-
return ((
|
|
604
|
-
},
|
|
605
|
-
var a,
|
|
606
|
-
const e = { ...
|
|
607
|
-
return ((
|
|
608
|
-
},
|
|
609
|
-
var
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
},
|
|
613
|
-
var
|
|
614
|
-
const
|
|
615
|
-
if (!((
|
|
616
|
-
|
|
494
|
+
}, de = (e, a, o) => {
|
|
495
|
+
p.error("上传发生错误,请重试!"), x.value.formData.file = o;
|
|
496
|
+
}, ce = () => {
|
|
497
|
+
var a, o;
|
|
498
|
+
const e = { ...y.value.additionalData || {} };
|
|
499
|
+
return ((o = (a = u.value) == null ? void 0 : a.data) == null ? void 0 : o.call(a, { ...e, extParameters: s.extParameters })) || {};
|
|
500
|
+
}, pe = () => {
|
|
501
|
+
var a, o;
|
|
502
|
+
const e = { ...y.value.additionalData || {} };
|
|
503
|
+
return ((o = (a = u.value) == null ? void 0 : a.headers) == null ? void 0 : o.call(a, { ...e, extParameters: s.extParameters })) || {};
|
|
504
|
+
}, fe = (e, a, o) => {
|
|
505
|
+
var i, l;
|
|
506
|
+
const t = (l = (i = u == null ? void 0 : u.value) == null ? void 0 : i.handlerResponse) == null ? void 0 : l.call(i, e);
|
|
507
|
+
t != null && t.url ? o[o.length - 1].url = t.url : t != null && t.errorMessage && (p.error(t.errorMessage), o.splice(o.length - 1, 1)), y.value.formData.file = o;
|
|
508
|
+
}, ve = (e, a) => new Promise((o, t) => {
|
|
509
|
+
var l, c, n, d, m, v;
|
|
510
|
+
const i = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
|
|
511
|
+
if (!((c = (l = u == null ? void 0 : u.value) == null ? void 0 : l.allowedType) != null && c.includes(i.toLowerCase()))) {
|
|
512
|
+
p.error(`请上传格式为${(d = (n = u == null ? void 0 : u.value) == null ? void 0 : n.allowedType) == null ? void 0 : d.map((D) => D.toUpperCase()).join("、")}的视频`), t();
|
|
617
513
|
return;
|
|
618
514
|
}
|
|
619
|
-
if (e.size > (((
|
|
620
|
-
|
|
515
|
+
if (e.size > (((m = u == null ? void 0 : u.value) == null ? void 0 : m.maxSize) || 0) * 1024 * 1024) {
|
|
516
|
+
p.error(`请上传${((v = u == null ? void 0 : u.value) == null ? void 0 : v.maxSize) || 0}M内的视频`), t();
|
|
621
517
|
return;
|
|
622
518
|
}
|
|
623
|
-
|
|
624
|
-
}),
|
|
625
|
-
|
|
626
|
-
},
|
|
627
|
-
|
|
519
|
+
y.value.additionalData = { file: e }, o(!0);
|
|
520
|
+
}), ge = (e, a) => {
|
|
521
|
+
y.value.formData.file = a;
|
|
522
|
+
}, he = (e, a, o) => {
|
|
523
|
+
p.error("上传发生错误,请重试!"), y.value.formData.file = o;
|
|
628
524
|
};
|
|
629
|
-
return
|
|
525
|
+
return z(() => [s.disabled, h.value], () => {
|
|
630
526
|
var e, a;
|
|
631
|
-
(a = (e = h.value) == null ? void 0 : e.mode) == null || a.set(
|
|
632
|
-
}, { immediate: !0 }),
|
|
633
|
-
() => [
|
|
527
|
+
(a = (e = h.value) == null ? void 0 : e.mode) == null || a.set(s.disabled ? "readonly" : "design");
|
|
528
|
+
}, { immediate: !0 }), z(
|
|
529
|
+
() => [s.value, h.value],
|
|
634
530
|
() => {
|
|
635
531
|
var e;
|
|
636
|
-
if (
|
|
637
|
-
|
|
532
|
+
if (S.value) {
|
|
533
|
+
S.value = !1;
|
|
638
534
|
return;
|
|
639
535
|
}
|
|
640
|
-
|
|
536
|
+
k.value = !0, (e = h.value) == null || e.setContent(s.value ? s.value : "");
|
|
641
537
|
},
|
|
642
538
|
{ immediate: !0 }
|
|
643
|
-
), { __sfc: !0, defaultImageUploadOptions:
|
|
539
|
+
), { __sfc: !0, defaultImageUploadOptions: j, defaultVideoUploadOptions: B, defaultAudioUploadOptions: q, props: s, emits: M, insRef: E, editorRef: h, preventSettingContent: S, preventUpdatingModelValue: k, uploadLoadingConfig: f, mergeImageUploadOptions: r, mergeVideoUploadOptions: u, mergeAudioUploadOptions: w, mergeImgPondOptions: V, imgPondAccept: ee, uploadImageImgPondRef: U, audioImageImgPondRef: I, uploadImage: A, uploadImageFormRef: $, onUploadImageClose: R, onUploadImageConfirm: ae, uploadAudio: x, uploadAudioFormRef: W, onUploadAudioClose: F, onUploadAudioConfirm: oe, uploadVideo: y, uploadVideoFormRef: N, onUploadVideoClose: O, onUploadVideoConfirm: te, onImageUploadUploadExceed: ie, onImageUploadUpload: le, uploadPasteOrDropFile: L, handleDataTransfer: H, onValuePaste: G, onValueDrop: X, getUploadAudioData: re, getUploadAudioHeaders: ne, onUploadAudioSuccess: se, onUploadAudioBeforeUpload: ue, onUploadAudioRemove: me, onUploadAudioError: de, getUploadVideoData: ce, getUploadVideoHeaders: pe, onUploadVideoSuccess: fe, onUploadVideoBeforeUpload: ve, onUploadVideoRemove: ge, onUploadVideoError: he, ImgPond: Te };
|
|
644
540
|
}
|
|
645
541
|
});
|
|
646
542
|
export {
|
|
647
|
-
|
|
543
|
+
pa as default
|
|
648
544
|
};
|
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.50",
|
|
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.15"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"vue": "^2.7.0",
|