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