@keyblade/tinymce-editor-vue2 0.1.0 → 0.1.1
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 +4 -0
- package/es/editor.vue2.js +244 -244
- package/es/types.d.ts +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -208,6 +208,8 @@ export interface VideoUploadOptions {
|
|
|
208
208
|
headers?: (parameters: { file: File | Blob, extParameters?: Record<string, any> }) => Record<string, any>;
|
|
209
209
|
/** 额外请求体 */
|
|
210
210
|
data?: (parameters: { file: File | Blob, extParameters?: Record<string, any> }) => Record<string, any>;
|
|
211
|
+
/** 上传之前回调结束(开始调用上传接口) */
|
|
212
|
+
beforeUploadEnd?: (file: File | Blob) => void
|
|
211
213
|
/** 响应处理(启用必传) */
|
|
212
214
|
handlerResponse?: (response: any) => { url?: string; errorMessage?: string }
|
|
213
215
|
}
|
|
@@ -230,6 +232,8 @@ export interface AudioUploadOptions {
|
|
|
230
232
|
headers?: (parameters: { file: File | Blob, extParameters?: Record<string, any> }) => Record<string, any>;
|
|
231
233
|
/** 额外请求体 */
|
|
232
234
|
data?: (parameters: { file: File | Blob, extParameters?: Record<string, any> }) => Record<string, any>;
|
|
235
|
+
/** 上传之前回调结束(开始调用上传接口) */
|
|
236
|
+
beforeUploadEnd?: (file: File | Blob) => void
|
|
233
237
|
/** 响应处理(启用必传) */
|
|
234
238
|
handlerResponse?: (response: any) => { url?: string; errorMessage?: string }
|
|
235
239
|
}
|
package/es/editor.vue2.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
1
|
+
var Ee = Object.defineProperty, He = Object.defineProperties;
|
|
2
|
+
var qe = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var ne = Object.getOwnPropertySymbols;
|
|
4
|
+
var Ve = Object.prototype.hasOwnProperty, je = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var se = (m, n) => (n = Symbol[m]) ? n : Symbol.for("Symbol." + m);
|
|
6
|
+
var ue = (m, n, i) => n in m ? Ee(m, n, { enumerable: !0, configurable: !0, writable: !0, value: i }) : m[n] = i, P = (m, n) => {
|
|
7
7
|
for (var i in n || (n = {}))
|
|
8
|
-
|
|
9
|
-
if (
|
|
10
|
-
for (var i of
|
|
11
|
-
|
|
12
|
-
return
|
|
13
|
-
}, j = (
|
|
14
|
-
var
|
|
15
|
-
var
|
|
8
|
+
Ve.call(n, i) && ue(m, i, n[i]);
|
|
9
|
+
if (ne)
|
|
10
|
+
for (var i of ne(n))
|
|
11
|
+
je.call(n, i) && ue(m, i, n[i]);
|
|
12
|
+
return m;
|
|
13
|
+
}, j = (m, n) => He(m, qe(n));
|
|
14
|
+
var L = (m, n, i) => new Promise((k, I) => {
|
|
15
|
+
var S = (x) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
} catch (
|
|
19
|
-
|
|
17
|
+
d(i.next(x));
|
|
18
|
+
} catch (C) {
|
|
19
|
+
I(C);
|
|
20
20
|
}
|
|
21
|
-
},
|
|
21
|
+
}, z = (x) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch (
|
|
25
|
-
|
|
23
|
+
d(i.throw(x));
|
|
24
|
+
} catch (C) {
|
|
25
|
+
I(C);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, d = (x) => x.done ? k(x.value) : Promise.resolve(x.value).then(S, z);
|
|
28
|
+
d((i = i.apply(m, n)).next());
|
|
29
29
|
});
|
|
30
|
-
var
|
|
31
|
-
import { defineComponent as
|
|
32
|
-
import { oneTravelImgPondBeforeAddFile as
|
|
33
|
-
import { blobToFile as
|
|
30
|
+
var K = (m, n, i) => (n = m[se("asyncIterator")]) ? n.call(m) : (m = m[se("iterator")](), n = {}, i = (k, I) => (I = m[k]) && (n[k] = (S) => new Promise((z, d, x) => (S = I.call(m, S), x = S.done, Promise.resolve(S.value).then((C) => z({ value: C, done: x }), d)))), i("next"), i("return"), n);
|
|
31
|
+
import { defineComponent as $e, ref as y, computed as $, watch as O, onMounted as Fe, onUnmounted as Re } from "vue";
|
|
32
|
+
import { oneTravelImgPondBeforeAddFile as me, oneTravelImageCompressor as de, oneTravelImageCheckAndTransform as We } from "@keyblade/one-travel";
|
|
33
|
+
import { blobToFile as ce, getImagePixel as Ne, getFileExtension as Le } from "./util.js";
|
|
34
34
|
import "./style.less.js";
|
|
35
|
-
import
|
|
36
|
-
import { conclude as
|
|
37
|
-
import
|
|
38
|
-
import
|
|
35
|
+
import Oe from "imgpond";
|
|
36
|
+
import { conclude as F } from "vue-global-config";
|
|
37
|
+
import pe from "tinymce";
|
|
38
|
+
import Ge from "./langs/zh_CN.js";
|
|
39
39
|
import "tinymce/skins/ui/oxide/skin";
|
|
40
40
|
import "tinymce/models/dom";
|
|
41
41
|
import "tinymce/themes/silver";
|
|
@@ -66,9 +66,9 @@ import "tinymce/plugins/table";
|
|
|
66
66
|
import "tinymce/plugins/visualblocks";
|
|
67
67
|
import "tinymce/plugins/visualchars";
|
|
68
68
|
import "tinymce/plugins/wordcount";
|
|
69
|
-
import { globalProps as
|
|
69
|
+
import { globalProps as R } from "./index.js";
|
|
70
70
|
import { Message as g } from "element-ui";
|
|
71
|
-
const
|
|
71
|
+
const Ha = /* @__PURE__ */ $e({
|
|
72
72
|
__name: "editor",
|
|
73
73
|
props: {
|
|
74
74
|
value: { default: "" },
|
|
@@ -82,10 +82,10 @@ const Va = /* @__PURE__ */ je({
|
|
|
82
82
|
initComplete: null
|
|
83
83
|
},
|
|
84
84
|
emits: ["input"],
|
|
85
|
-
setup(
|
|
86
|
-
const i =
|
|
87
|
-
|
|
88
|
-
const
|
|
85
|
+
setup(m, { emit: n }) {
|
|
86
|
+
const i = m;
|
|
87
|
+
pe.addI18n("zh_CN", Ge);
|
|
88
|
+
const k = {
|
|
89
89
|
maxCount: 10,
|
|
90
90
|
tipText: "上传",
|
|
91
91
|
maxSize: 30,
|
|
@@ -94,75 +94,75 @@ const Va = /* @__PURE__ */ je({
|
|
|
94
94
|
minHeight: 50,
|
|
95
95
|
maxWidth: 6e3,
|
|
96
96
|
maxHeight: 6e3
|
|
97
|
-
},
|
|
97
|
+
}, I = {
|
|
98
98
|
enable: !0,
|
|
99
99
|
maxSize: 300,
|
|
100
100
|
allowedType: ["avi", "wmv", "mp4", "mov", "3gp"],
|
|
101
101
|
accept: ".avi,.wmv,.mp4,.mov,.3gp"
|
|
102
|
-
},
|
|
102
|
+
}, S = {
|
|
103
103
|
enable: !0,
|
|
104
104
|
maxSize: 200,
|
|
105
105
|
allowedType: ["wav", "mp3", "mp4", "m4a", "wma", "aac"],
|
|
106
106
|
accept: ".wav,.mp3,.mp4,.m4a,.wma,.aac"
|
|
107
|
-
},
|
|
107
|
+
}, z = y(), d = y(), x = y(!1), C = y(!1), T = y({
|
|
108
108
|
show: !1,
|
|
109
109
|
text: "图片上传中,请稍等"
|
|
110
|
-
}), s =
|
|
110
|
+
}), s = $(() => F([i.imageUploadOptions, R.imageUploadOptions, k]) || {}), u = $(() => F([i.videoUploadOptions, R.videoUploadOptions, I]) || {}), h = $(() => F([i.audioUploadOptions, R.audioUploadOptions, S]) || {}), G = $(() => F([i.imgPondOptions, R.imgPondOptions]) || {}), fe = $(() => {
|
|
111
111
|
var e, a;
|
|
112
|
-
return ((a = (e = s == null ? void 0 : s.value) == null ? void 0 : e.allowedType) == null ? void 0 : a.map((
|
|
113
|
-
}),
|
|
114
|
-
O(() =>
|
|
115
|
-
|
|
112
|
+
return ((a = (e = s == null ? void 0 : s.value) == null ? void 0 : e.allowedType) == null ? void 0 : a.map((t) => `.${t}`).join(",")) || "";
|
|
113
|
+
}), W = y();
|
|
114
|
+
O(() => W.value, () => {
|
|
115
|
+
W.value && me(W.value, {
|
|
116
116
|
onStart: () => {
|
|
117
|
-
|
|
117
|
+
T.value = {
|
|
118
118
|
show: !0,
|
|
119
119
|
text: "图片加载中,请稍等"
|
|
120
120
|
};
|
|
121
121
|
},
|
|
122
122
|
onSuccess: () => {
|
|
123
|
-
|
|
123
|
+
T.value.show = !1;
|
|
124
124
|
},
|
|
125
125
|
onError: (e) => {
|
|
126
|
-
|
|
126
|
+
T.value.show = !1, g.error({ message: e, customClass: "tinymce-editor-message", duration: 3e3 });
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
129
|
}, { immediate: !0 });
|
|
130
|
-
const
|
|
131
|
-
O(() =>
|
|
132
|
-
|
|
130
|
+
const N = y();
|
|
131
|
+
O(() => N.value, () => {
|
|
132
|
+
N.value && me(N.value, {
|
|
133
133
|
onStart: () => {
|
|
134
|
-
|
|
134
|
+
T.value = {
|
|
135
135
|
show: !0,
|
|
136
136
|
text: "图片加载中,请稍等"
|
|
137
137
|
};
|
|
138
138
|
},
|
|
139
139
|
onSuccess: () => {
|
|
140
|
-
|
|
140
|
+
T.value.show = !1;
|
|
141
141
|
},
|
|
142
142
|
onError: (e) => {
|
|
143
|
-
|
|
143
|
+
T.value.show = !1, g.error(e);
|
|
144
144
|
}
|
|
145
145
|
});
|
|
146
146
|
}, { immediate: !0 });
|
|
147
|
-
const
|
|
147
|
+
const E = y({
|
|
148
148
|
dialogVisible: !1,
|
|
149
149
|
formData: {
|
|
150
150
|
images: []
|
|
151
151
|
}
|
|
152
|
-
}),
|
|
153
|
-
H = [],
|
|
152
|
+
}), Q = y(), Y = () => {
|
|
153
|
+
H = [], E.value.dialogVisible = !1, E.value.formData = {
|
|
154
154
|
images: []
|
|
155
155
|
};
|
|
156
|
-
},
|
|
156
|
+
}, ve = () => {
|
|
157
157
|
var e;
|
|
158
|
-
H = [], (e =
|
|
159
|
-
a && (
|
|
158
|
+
H = [], (e = Q.value) == null || e.validate((a) => {
|
|
159
|
+
a && (E.value.formData.images.forEach((t) => {
|
|
160
160
|
var r;
|
|
161
|
-
let
|
|
162
|
-
|
|
163
|
-
}),
|
|
161
|
+
let o = t;
|
|
162
|
+
G.value.srcAt && (o = (t == null ? void 0 : t[G.value.srcAt]) || ""), (r = d.value) == null || r.insertContent(`<img src=${o} alt="" />`);
|
|
163
|
+
}), Y());
|
|
164
164
|
});
|
|
165
|
-
},
|
|
165
|
+
}, b = y({
|
|
166
166
|
dialogVisible: !1,
|
|
167
167
|
formData: {
|
|
168
168
|
// 名称
|
|
@@ -174,17 +174,17 @@ const Va = /* @__PURE__ */ je({
|
|
|
174
174
|
},
|
|
175
175
|
// 用于临时保存上传前的参数 { file: File }
|
|
176
176
|
additionalData: {}
|
|
177
|
-
}),
|
|
178
|
-
|
|
177
|
+
}), Z = y(), ee = () => {
|
|
178
|
+
b.value.dialogVisible = !1, b.value.formData = {
|
|
179
179
|
name: "",
|
|
180
180
|
cover: [],
|
|
181
181
|
file: []
|
|
182
|
-
},
|
|
183
|
-
},
|
|
182
|
+
}, b.value.additionalData = {};
|
|
183
|
+
}, ge = () => {
|
|
184
184
|
var e;
|
|
185
|
-
(e =
|
|
186
|
-
var
|
|
187
|
-
a && ((
|
|
185
|
+
(e = Z.value) == null || e.validate((a) => {
|
|
186
|
+
var t, o;
|
|
187
|
+
a && ((o = d.value) == null || o.insertContent(`<audio controls controlslist="nodownload noplaybackrate" data-name="${b.value.formData.name}" data-poster="${b.value.formData.cover[0]}" src="${(t = b.value.formData.file[0]) == null ? void 0 : t.url}"></audio>`), ee());
|
|
188
188
|
});
|
|
189
189
|
}, _ = y({
|
|
190
190
|
dialogVisible: !1,
|
|
@@ -194,61 +194,61 @@ const Va = /* @__PURE__ */ je({
|
|
|
194
194
|
},
|
|
195
195
|
// 用于临时保存上传前的参数 { file: File }
|
|
196
196
|
additionalData: {}
|
|
197
|
-
}),
|
|
197
|
+
}), ae = y(), te = () => {
|
|
198
198
|
_.value.dialogVisible = !1, _.value.formData = {
|
|
199
199
|
file: []
|
|
200
200
|
}, _.value.additionalData = {};
|
|
201
|
-
},
|
|
201
|
+
}, he = () => {
|
|
202
202
|
var e;
|
|
203
|
-
(e =
|
|
204
|
-
var
|
|
205
|
-
a && ((
|
|
203
|
+
(e = ae.value) == null || e.validate((a) => {
|
|
204
|
+
var t, o;
|
|
205
|
+
a && ((o = d.value) == null || o.insertContent(`<video width="auto" height="auto" controls src="${(t = _.value.formData.file[0]) == null ? void 0 : t.url}"></video>`), te());
|
|
206
206
|
});
|
|
207
|
-
},
|
|
207
|
+
}, xe = () => {
|
|
208
208
|
document.querySelectorAll(".swal2-container .swal2-title").forEach((e) => {
|
|
209
209
|
e && (e.innerHTML = `单次最多可选择${s.value.maxCount}张图片`);
|
|
210
210
|
});
|
|
211
211
|
};
|
|
212
212
|
let H = [];
|
|
213
|
-
const
|
|
213
|
+
const we = (e, a) => new Promise((t, o) => L(this, null, function* () {
|
|
214
214
|
var f, v;
|
|
215
|
-
if (H.find((
|
|
215
|
+
if (H.find((p) => (p == null ? void 0 : p.uid) === (e == null ? void 0 : e.uid)))
|
|
216
216
|
return setTimeout(() => {
|
|
217
|
-
document.querySelectorAll(".swal2-container").forEach((
|
|
218
|
-
|
|
217
|
+
document.querySelectorAll(".swal2-container").forEach((p) => {
|
|
218
|
+
p == null || p.remove();
|
|
219
219
|
});
|
|
220
|
-
}),
|
|
220
|
+
}), o("");
|
|
221
221
|
H.push(e);
|
|
222
|
-
const l = yield
|
|
222
|
+
const l = yield de(e);
|
|
223
223
|
if (!l.success) {
|
|
224
|
-
|
|
224
|
+
o(), setTimeout(() => {
|
|
225
225
|
a.onError(l.errorMessage);
|
|
226
226
|
});
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
229
|
-
const
|
|
230
|
-
if (!
|
|
231
|
-
|
|
232
|
-
a.onError(
|
|
229
|
+
const c = yield (v = (f = s.value).handleRequest) == null ? void 0 : v.call(f, ce(l.file, e.name), e.name, { extParameters: i.extParameters });
|
|
230
|
+
if (!c || !(c != null && c.success)) {
|
|
231
|
+
o(), setTimeout(() => {
|
|
232
|
+
a.onError(c == null ? void 0 : c.errorMessage);
|
|
233
233
|
});
|
|
234
234
|
return;
|
|
235
235
|
}
|
|
236
|
-
|
|
236
|
+
t(c.url);
|
|
237
237
|
}));
|
|
238
|
-
function
|
|
239
|
-
return
|
|
240
|
-
var
|
|
238
|
+
function oe(e) {
|
|
239
|
+
return L(this, null, function* () {
|
|
240
|
+
var c, f, v;
|
|
241
241
|
let a = e;
|
|
242
|
-
if (!((
|
|
242
|
+
if (!((c = s.value) != null && c.handleRequest)) {
|
|
243
243
|
g.error("缺少图片上传配置");
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
|
-
let
|
|
246
|
+
let t = a.name ? a.name : "";
|
|
247
247
|
if (!(a != null && a.name) && !(a != null && a.lastModified) && a.type === "image/png") {
|
|
248
248
|
g.error("不允许粘贴");
|
|
249
249
|
return;
|
|
250
250
|
}
|
|
251
|
-
const
|
|
251
|
+
const o = yield We(a, t, {
|
|
252
252
|
imageMaxSize: s.value.maxSize,
|
|
253
253
|
imageAllowedType: s.value.allowedType,
|
|
254
254
|
// imageAllowedMineType: mergeImageUploadOptions.value.allowedMineType,
|
|
@@ -257,21 +257,21 @@ const Va = /* @__PURE__ */ je({
|
|
|
257
257
|
imageMaxWidth: s.value.maxWidth,
|
|
258
258
|
imageMaxHeight: s.value.maxHeight
|
|
259
259
|
});
|
|
260
|
-
if (!
|
|
261
|
-
g.error((
|
|
260
|
+
if (!o.success) {
|
|
261
|
+
g.error((o == null ? void 0 : o.errorMessage) || "");
|
|
262
262
|
return;
|
|
263
263
|
}
|
|
264
|
-
if (
|
|
265
|
-
a =
|
|
266
|
-
const
|
|
267
|
-
|
|
264
|
+
if (o.hasTransform) {
|
|
265
|
+
a = o.file;
|
|
266
|
+
const p = t == null ? void 0 : t.split(".");
|
|
267
|
+
p.pop(), t = `${p.join(",")}.jpg`;
|
|
268
268
|
}
|
|
269
|
-
const r = yield
|
|
269
|
+
const r = yield de(a);
|
|
270
270
|
if (!r.success) {
|
|
271
271
|
g.error((r == null ? void 0 : r.errorMessage) || "压缩失败");
|
|
272
272
|
return;
|
|
273
273
|
}
|
|
274
|
-
const l = yield (v = (f = s.value).handleRequest) == null ? void 0 : v.call(f,
|
|
274
|
+
const l = yield (v = (f = s.value).handleRequest) == null ? void 0 : v.call(f, ce(r.file, t), t, { extParameters: i.extParameters });
|
|
275
275
|
if (!l || !l.success) {
|
|
276
276
|
g.error((l == null ? void 0 : l.errorMessage) || "");
|
|
277
277
|
return;
|
|
@@ -279,98 +279,98 @@ const Va = /* @__PURE__ */ je({
|
|
|
279
279
|
return l.url;
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
|
-
const
|
|
283
|
-
var l,
|
|
284
|
-
const a =
|
|
285
|
-
if (
|
|
286
|
-
const U = e.getData("text/html"),
|
|
287
|
-
|
|
282
|
+
const X = (e) => L(this, null, function* () {
|
|
283
|
+
var l, c, D;
|
|
284
|
+
const a = d.value, t = e.types;
|
|
285
|
+
if (t.includes("text/html")) {
|
|
286
|
+
const U = e.getData("text/html"), B = new DOMParser().parseFromString(U, "text/html"), le = Array.from(B.body.querySelectorAll("img")), ke = Array.from(B.body.querySelectorAll("audio")), ze = Array.from(B.body.querySelectorAll("video"));
|
|
287
|
+
le.length > 0 && (T.value = {
|
|
288
288
|
show: !0,
|
|
289
289
|
text: "图片加载中,请稍等"
|
|
290
290
|
});
|
|
291
|
-
for (const
|
|
292
|
-
|
|
291
|
+
for (const A of [...ke, ...ze])
|
|
292
|
+
A == null || A.remove();
|
|
293
293
|
try {
|
|
294
|
-
for (var f =
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
294
|
+
for (var f = K([...le]), v, p, M; v = !(p = yield f.next()).done; v = !1) {
|
|
295
|
+
const A = p.value;
|
|
296
|
+
if (A.removeAttribute("crossorigin"), A.src.startsWith("http"))
|
|
297
297
|
if ((l = s.value) != null && l.handleRequestByUrl) {
|
|
298
|
-
const
|
|
299
|
-
|
|
298
|
+
const w = yield (c = s.value) == null ? void 0 : c.handleRequestByUrl(A.src, { extParameters: i.extParameters });
|
|
299
|
+
w != null && w.success && (w != null && w.url) ? A.src = w == null ? void 0 : w.url : A.remove();
|
|
300
300
|
} else {
|
|
301
|
-
const
|
|
302
|
-
|
|
301
|
+
const w = yield Ne(A.src);
|
|
302
|
+
w && (w.width < (s.value.minWidth || 0) && w.height < (s.value.minHeight || 0) || w.width > (s.value.maxWidth || 0) && w.height > (s.value.maxHeight || 0)) && A.remove();
|
|
303
303
|
}
|
|
304
304
|
else
|
|
305
|
-
|
|
305
|
+
A.remove(), g.error("不支持Word中批量复制图片或视频,请改为单个复制,或者从工具栏中手动插入上传");
|
|
306
306
|
}
|
|
307
|
-
} catch (
|
|
308
|
-
|
|
307
|
+
} catch (p) {
|
|
308
|
+
M = [p];
|
|
309
309
|
} finally {
|
|
310
310
|
try {
|
|
311
|
-
v && (
|
|
311
|
+
v && (p = f.return) && (yield p.call(f));
|
|
312
312
|
} finally {
|
|
313
|
-
if (
|
|
314
|
-
throw
|
|
313
|
+
if (M)
|
|
314
|
+
throw M[0];
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
|
-
|
|
318
|
-
const
|
|
319
|
-
a.insertContent(
|
|
317
|
+
T.value.show = !1;
|
|
318
|
+
const Be = new XMLSerializer().serializeToString(B.body);
|
|
319
|
+
a.insertContent(Be);
|
|
320
320
|
} else
|
|
321
|
-
|
|
322
|
-
const
|
|
323
|
-
for (const U of
|
|
321
|
+
t.includes("text/plain") && a.insertContent(e.getData("text/plain"));
|
|
322
|
+
const o = Array.from((e == null ? void 0 : e.files) || []), r = [];
|
|
323
|
+
for (const U of o) {
|
|
324
324
|
if (!U)
|
|
325
325
|
continue;
|
|
326
|
-
const
|
|
327
|
-
U.type.indexOf("image") > -1 || (
|
|
326
|
+
const V = Le(U.name);
|
|
327
|
+
U.type.indexOf("image") > -1 || (D = s.value.allowedType) != null && D.includes(V.toLowerCase()) ? r.push(U) : g.error("暂不支持的文件类型");
|
|
328
328
|
}
|
|
329
329
|
if (r.length > 0) {
|
|
330
|
-
|
|
330
|
+
T.value = {
|
|
331
331
|
show: !0,
|
|
332
332
|
text: "图片上传中,请稍等"
|
|
333
333
|
};
|
|
334
334
|
try {
|
|
335
|
-
for (var
|
|
336
|
-
const U =
|
|
337
|
-
const
|
|
338
|
-
if (
|
|
339
|
-
const
|
|
340
|
-
a.insertContent(
|
|
335
|
+
for (var q = K(r), J, ja, $a; J = !(ja = yield q.next()).done; J = !1) {
|
|
336
|
+
const U = ja.value;
|
|
337
|
+
const V = yield oe(U);
|
|
338
|
+
if (V) {
|
|
339
|
+
const B = `<img src="${V}" alt="" />`;
|
|
340
|
+
a.insertContent(B);
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
} catch (
|
|
344
|
-
$a = [
|
|
343
|
+
} catch (ja) {
|
|
344
|
+
$a = [ja];
|
|
345
345
|
} finally {
|
|
346
346
|
try {
|
|
347
|
-
|
|
347
|
+
J && (ja = q.return) && (yield ja.call(q));
|
|
348
348
|
} finally {
|
|
349
349
|
if ($a)
|
|
350
350
|
throw $a[0];
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
|
-
|
|
353
|
+
T.value.show = !1;
|
|
354
354
|
}
|
|
355
355
|
n("input", a.getContent());
|
|
356
|
-
}),
|
|
357
|
-
var
|
|
356
|
+
}), ie = (e) => {
|
|
357
|
+
var t;
|
|
358
358
|
e.preventDefault();
|
|
359
|
-
const a = e.clipboardData || ((
|
|
360
|
-
|
|
361
|
-
},
|
|
362
|
-
var
|
|
359
|
+
const a = e.clipboardData || ((t = e == null ? void 0 : e.originalEvent) == null ? void 0 : t.clipboardData);
|
|
360
|
+
X(a);
|
|
361
|
+
}, re = (e) => {
|
|
362
|
+
var t;
|
|
363
363
|
e.preventDefault();
|
|
364
|
-
const a = e.dataTransfer || ((
|
|
365
|
-
|
|
364
|
+
const a = e.dataTransfer || ((t = e == null ? void 0 : e.originalEvent) == null ? void 0 : t.dataTransfer);
|
|
365
|
+
X(a);
|
|
366
366
|
};
|
|
367
|
-
|
|
368
|
-
var
|
|
367
|
+
Fe(() => {
|
|
368
|
+
var t;
|
|
369
369
|
const e = {
|
|
370
370
|
// 设置语言
|
|
371
371
|
language: "zh_CN",
|
|
372
372
|
// 实例
|
|
373
|
-
target:
|
|
373
|
+
target: z.value,
|
|
374
374
|
// 隐藏品牌
|
|
375
375
|
branding: !1,
|
|
376
376
|
// 隐藏右上角升级按钮
|
|
@@ -448,168 +448,168 @@ const Va = /* @__PURE__ */ je({
|
|
|
448
448
|
convert_urls: !1,
|
|
449
449
|
paste_webkit_styles: "all",
|
|
450
450
|
paste_data_images: !1,
|
|
451
|
-
images_file_types: ((
|
|
451
|
+
images_file_types: ((t = s.value.allowedType) == null ? void 0 : t.join(",")) || "jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp",
|
|
452
452
|
// 粘贴前处理
|
|
453
|
-
paste_preprocess(
|
|
453
|
+
paste_preprocess(o, r) {
|
|
454
454
|
r == null || r.preventDefault();
|
|
455
455
|
},
|
|
456
|
-
setup(
|
|
457
|
-
var l,
|
|
456
|
+
setup(o) {
|
|
457
|
+
var l, c;
|
|
458
458
|
const r = () => {
|
|
459
|
-
|
|
460
|
-
var v,
|
|
459
|
+
E.value.dialogVisible = !0, setTimeout(() => {
|
|
460
|
+
var v, p;
|
|
461
461
|
const f = (v = document == null ? void 0 : document.querySelector) == null ? void 0 : v.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
|
|
462
|
-
f && (f.innerHTML = ((
|
|
462
|
+
f && (f.innerHTML = ((p = s.value) == null ? void 0 : p.tipText) || "上传");
|
|
463
463
|
});
|
|
464
464
|
};
|
|
465
|
-
if (
|
|
465
|
+
if (o.ui.registry.addMenuItem("localImage", {
|
|
466
466
|
text: "图片",
|
|
467
467
|
icon: "image",
|
|
468
468
|
onAction: () => r()
|
|
469
|
-
}),
|
|
469
|
+
}), o.ui.registry.addButton("localImage", {
|
|
470
470
|
icon: "image",
|
|
471
471
|
tooltip: "图片",
|
|
472
472
|
onAction: () => r()
|
|
473
|
-
}), (l =
|
|
473
|
+
}), (l = h == null ? void 0 : h.value) != null && l.enable) {
|
|
474
474
|
const f = () => {
|
|
475
|
-
|
|
476
|
-
var
|
|
477
|
-
const v = (
|
|
478
|
-
v && (v.innerHTML = ((
|
|
475
|
+
b.value.dialogVisible = !0, setTimeout(() => {
|
|
476
|
+
var p, M;
|
|
477
|
+
const v = (p = document == null ? void 0 : document.querySelector) == null ? void 0 : p.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
|
|
478
|
+
v && (v.innerHTML = ((M = s.value) == null ? void 0 : M.tipText) || "上传");
|
|
479
479
|
});
|
|
480
480
|
};
|
|
481
|
-
|
|
481
|
+
o.ui.registry.addMenuItem("localAudio", {
|
|
482
482
|
text: "音频",
|
|
483
483
|
icon: "arrow-right",
|
|
484
484
|
onAction: () => f()
|
|
485
|
-
}),
|
|
485
|
+
}), o.ui.registry.addButton("localAudio", {
|
|
486
486
|
icon: "arrow-right",
|
|
487
487
|
tooltip: "音频",
|
|
488
488
|
onAction: () => f()
|
|
489
489
|
});
|
|
490
490
|
}
|
|
491
|
-
if ((
|
|
491
|
+
if ((c = u == null ? void 0 : u.value) != null && c.enable) {
|
|
492
492
|
const f = () => {
|
|
493
493
|
_.value.dialogVisible = !0;
|
|
494
494
|
};
|
|
495
|
-
|
|
495
|
+
o.ui.registry.addMenuItem("localVideo", {
|
|
496
496
|
text: "视频",
|
|
497
497
|
icon: "embed",
|
|
498
498
|
onAction: () => f()
|
|
499
|
-
}),
|
|
499
|
+
}), o.ui.registry.addButton("localVideo", {
|
|
500
500
|
icon: "embed",
|
|
501
501
|
tooltip: "视频",
|
|
502
502
|
onAction: () => f()
|
|
503
503
|
});
|
|
504
504
|
}
|
|
505
505
|
}
|
|
506
|
-
}, a =
|
|
506
|
+
}, a = F(
|
|
507
507
|
[
|
|
508
508
|
i.options,
|
|
509
|
-
|
|
509
|
+
R.options,
|
|
510
510
|
e
|
|
511
511
|
],
|
|
512
512
|
{
|
|
513
|
-
mergeFunction: (
|
|
514
|
-
|
|
513
|
+
mergeFunction: (o, r) => (...l) => {
|
|
514
|
+
o(...l), r(...l);
|
|
515
515
|
},
|
|
516
516
|
type: Object
|
|
517
517
|
}
|
|
518
518
|
);
|
|
519
|
-
|
|
519
|
+
pe.init(a).then(([o]) => {
|
|
520
520
|
var r;
|
|
521
|
-
|
|
522
|
-
if (
|
|
523
|
-
|
|
521
|
+
o && (o.customProps = P({}, i), o.on("input", () => {
|
|
522
|
+
if (C.value) {
|
|
523
|
+
C.value = !1;
|
|
524
524
|
return;
|
|
525
525
|
}
|
|
526
|
-
|
|
527
|
-
}),
|
|
528
|
-
n("input",
|
|
529
|
-
}),
|
|
530
|
-
|
|
531
|
-
}),
|
|
532
|
-
|
|
533
|
-
}), (r = i.initComplete) == null || r.call(i, { editorIns:
|
|
526
|
+
x.value = !0, n("input", o.getContent());
|
|
527
|
+
}), o.on("change", () => {
|
|
528
|
+
n("input", o.getContent());
|
|
529
|
+
}), o.on("paste", (l) => {
|
|
530
|
+
ie(l);
|
|
531
|
+
}), o.on("drop", (l) => {
|
|
532
|
+
re(l);
|
|
533
|
+
}), (r = i.initComplete) == null || r.call(i, { editorIns: o }), d.value = o);
|
|
534
534
|
});
|
|
535
|
-
}),
|
|
536
|
-
var e, a,
|
|
537
|
-
(e =
|
|
535
|
+
}), Re(() => {
|
|
536
|
+
var e, a, t, o;
|
|
537
|
+
(e = d.value) == null || e.off("input"), (a = d.value) == null || a.off("paste"), (t = d.value) == null || t.off("drop"), (o = d.value) == null || o.destroy();
|
|
538
538
|
});
|
|
539
|
-
const
|
|
540
|
-
var a,
|
|
541
|
-
const e =
|
|
542
|
-
return ((
|
|
543
|
-
},
|
|
544
|
-
var a,
|
|
545
|
-
const e =
|
|
546
|
-
return ((
|
|
547
|
-
},
|
|
539
|
+
const be = () => {
|
|
540
|
+
var a, t;
|
|
541
|
+
const e = P({}, b.value.additionalData || {});
|
|
542
|
+
return ((t = (a = h.value) == null ? void 0 : a.data) == null ? void 0 : t.call(a, j(P({}, e), { extParameters: i.extParameters }))) || {};
|
|
543
|
+
}, ye = () => {
|
|
544
|
+
var a, t;
|
|
545
|
+
const e = P({}, b.value.additionalData || {});
|
|
546
|
+
return ((t = (a = h.value) == null ? void 0 : a.headers) == null ? void 0 : t.call(a, j(P({}, e), { extParameters: i.extParameters }))) || {};
|
|
547
|
+
}, _e = (e, a, t) => {
|
|
548
548
|
var r, l;
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
},
|
|
552
|
-
var l,
|
|
549
|
+
const o = (l = (r = h == null ? void 0 : h.value) == null ? void 0 : r.handlerResponse) == null ? void 0 : l.call(r, e);
|
|
550
|
+
o != null && o.url ? t[t.length - 1].url = o.url : o != null && o.errorMessage && (g.error(o.errorMessage), t.splice(t.length - 1, 1)), b.value.formData.file = t;
|
|
551
|
+
}, De = (e, a) => new Promise((t, o) => {
|
|
552
|
+
var l, c, f, v, p, M, D, q;
|
|
553
553
|
const r = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
|
|
554
|
-
if (!((
|
|
555
|
-
g.error(`请上传格式为${(v = (f =
|
|
554
|
+
if (!((c = (l = h.value) == null ? void 0 : l.allowedType) != null && c.includes(r.toLowerCase()))) {
|
|
555
|
+
g.error(`请上传格式为${(v = (f = h.value) == null ? void 0 : f.allowedType) == null ? void 0 : v.map((J) => J.toUpperCase()).join("、")}的音频`), o();
|
|
556
556
|
return;
|
|
557
557
|
}
|
|
558
|
-
if (e.size > (((
|
|
559
|
-
g.error(`请上传${((
|
|
558
|
+
if (e.size > (((p = h.value) == null ? void 0 : p.maxSize) || 0) * 1024 * 1024) {
|
|
559
|
+
g.error(`请上传${((M = h.value) == null ? void 0 : M.maxSize) || 0}M内的音频`), o();
|
|
560
560
|
return;
|
|
561
561
|
}
|
|
562
|
-
|
|
563
|
-
}),
|
|
564
|
-
|
|
565
|
-
},
|
|
566
|
-
g.error("上传发生错误,请重试!"),
|
|
567
|
-
},
|
|
568
|
-
var a,
|
|
569
|
-
const e =
|
|
570
|
-
return ((
|
|
571
|
-
},
|
|
572
|
-
var a,
|
|
573
|
-
const e =
|
|
574
|
-
return ((
|
|
575
|
-
},
|
|
562
|
+
b.value.additionalData = { file: e }, (q = (D = h == null ? void 0 : h.value) == null ? void 0 : D.beforeUploadEnd) == null || q.call(D, e), t(!0);
|
|
563
|
+
}), Ae = (e, a) => {
|
|
564
|
+
b.value.formData.file = a;
|
|
565
|
+
}, Te = (e, a, t) => {
|
|
566
|
+
g.error("上传发生错误,请重试!"), b.value.formData.file = t;
|
|
567
|
+
}, Ce = () => {
|
|
568
|
+
var a, t;
|
|
569
|
+
const e = P({}, _.value.additionalData || {});
|
|
570
|
+
return ((t = (a = u.value) == null ? void 0 : a.data) == null ? void 0 : t.call(a, j(P({}, e), { extParameters: i.extParameters }))) || {};
|
|
571
|
+
}, Pe = () => {
|
|
572
|
+
var a, t;
|
|
573
|
+
const e = P({}, _.value.additionalData || {});
|
|
574
|
+
return ((t = (a = u.value) == null ? void 0 : a.headers) == null ? void 0 : t.call(a, j(P({}, e), { extParameters: i.extParameters }))) || {};
|
|
575
|
+
}, Se = (e, a, t) => {
|
|
576
576
|
var r, l;
|
|
577
|
-
const
|
|
578
|
-
|
|
579
|
-
},
|
|
580
|
-
var l,
|
|
577
|
+
const o = (l = (r = u == null ? void 0 : u.value) == null ? void 0 : r.handlerResponse) == null ? void 0 : l.call(r, e);
|
|
578
|
+
o != null && o.url ? t[t.length - 1].url = o.url : o != null && o.errorMessage && (g.error(o.errorMessage), t.splice(t.length - 1, 1)), _.value.formData.file = t;
|
|
579
|
+
}, Me = (e, a) => new Promise((t, o) => {
|
|
580
|
+
var l, c, f, v, p, M, D, q;
|
|
581
581
|
const r = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
|
|
582
|
-
if (!((
|
|
583
|
-
g.error(`请上传格式为${(v = (f =
|
|
582
|
+
if (!((c = (l = u == null ? void 0 : u.value) == null ? void 0 : l.allowedType) != null && c.includes(r.toLowerCase()))) {
|
|
583
|
+
g.error(`请上传格式为${(v = (f = u == null ? void 0 : u.value) == null ? void 0 : f.allowedType) == null ? void 0 : v.map((J) => J.toUpperCase()).join("、")}的视频`), o();
|
|
584
584
|
return;
|
|
585
585
|
}
|
|
586
|
-
if (e.size > (((
|
|
587
|
-
g.error(`请上传${((
|
|
586
|
+
if (e.size > (((p = u == null ? void 0 : u.value) == null ? void 0 : p.maxSize) || 0) * 1024 * 1024) {
|
|
587
|
+
g.error(`请上传${((M = u == null ? void 0 : u.value) == null ? void 0 : M.maxSize) || 0}M内的视频`), o();
|
|
588
588
|
return;
|
|
589
589
|
}
|
|
590
|
-
_.value.additionalData = { file: e },
|
|
591
|
-
}),
|
|
590
|
+
_.value.additionalData = { file: e }, (q = (D = u == null ? void 0 : u.value) == null ? void 0 : D.beforeUploadEnd) == null || q.call(D, e), t(!0);
|
|
591
|
+
}), Ie = (e, a) => {
|
|
592
592
|
_.value.formData.file = a;
|
|
593
|
-
},
|
|
594
|
-
g.error("上传发生错误,请重试!"), _.value.formData.file =
|
|
593
|
+
}, Ue = (e, a, t) => {
|
|
594
|
+
g.error("上传发生错误,请重试!"), _.value.formData.file = t;
|
|
595
595
|
};
|
|
596
|
-
return O(() => [i.disabled,
|
|
596
|
+
return O(() => [i.disabled, d.value], () => {
|
|
597
597
|
var e, a;
|
|
598
|
-
(a = (e =
|
|
598
|
+
(a = (e = d.value) == null ? void 0 : e.mode) == null || a.set(i.disabled ? "readonly" : "design");
|
|
599
599
|
}, { immediate: !0 }), O(
|
|
600
|
-
() => [i.value,
|
|
600
|
+
() => [i.value, d.value],
|
|
601
601
|
() => {
|
|
602
|
-
var e, a,
|
|
603
|
-
if (
|
|
604
|
-
|
|
602
|
+
var e, a, t, o;
|
|
603
|
+
if (x.value) {
|
|
604
|
+
x.value = !1;
|
|
605
605
|
return;
|
|
606
606
|
}
|
|
607
|
-
|
|
607
|
+
C.value = !0, (e = d.value) == null || e.setContent(i.value ? i.value : ""), (t = d.value) == null || t.selection.select((a = d.value) == null ? void 0 : a.getBody(), !0), (o = d.value) == null || o.selection.collapse(!1);
|
|
608
608
|
},
|
|
609
609
|
{ immediate: !0 }
|
|
610
|
-
), { __sfc: !0, defaultImageUploadOptions:
|
|
610
|
+
), { __sfc: !0, defaultImageUploadOptions: k, defaultVideoUploadOptions: I, defaultAudioUploadOptions: S, props: i, emits: n, insRef: z, editorRef: d, preventSettingContent: x, preventUpdatingModelValue: C, uploadLoadingConfig: T, mergeImageUploadOptions: s, mergeVideoUploadOptions: u, mergeAudioUploadOptions: h, mergeImgPondOptions: G, imgPondAccept: fe, uploadImageImgPondRef: W, audioImageImgPondRef: N, uploadImage: E, uploadImageFormRef: Q, onUploadImageClose: Y, onUploadImageConfirm: ve, uploadAudio: b, uploadAudioFormRef: Z, onUploadAudioClose: ee, onUploadAudioConfirm: ge, uploadVideo: _, uploadVideoFormRef: ae, onUploadVideoClose: te, onUploadVideoConfirm: he, onImageUploadUploadExceed: xe, imageUploadTempFiles: H, onImageUploadUpload: we, uploadPasteOrDropFile: oe, handleDataTransfer: X, onValuePaste: ie, onValueDrop: re, getUploadAudioData: be, getUploadAudioHeaders: ye, onUploadAudioSuccess: _e, onUploadAudioBeforeUpload: De, onUploadAudioRemove: Ae, onUploadAudioError: Te, getUploadVideoData: Ce, getUploadVideoHeaders: Pe, onUploadVideoSuccess: Se, onUploadVideoBeforeUpload: Me, onUploadVideoRemove: Ie, onUploadVideoError: Ue, ImgPond: Oe };
|
|
611
611
|
}
|
|
612
612
|
});
|
|
613
613
|
export {
|
|
614
|
-
|
|
614
|
+
Ha as default
|
|
615
615
|
};
|
package/es/types.d.ts
CHANGED
|
@@ -55,6 +55,8 @@ export interface VideoUploadOptions {
|
|
|
55
55
|
file: File | Blob;
|
|
56
56
|
extParameters?: Record<string, any>;
|
|
57
57
|
}) => Record<string, any>;
|
|
58
|
+
/** 上传之前回调结束(开始调用上传接口) */
|
|
59
|
+
beforeUploadEnd?: (file: File | Blob) => void;
|
|
58
60
|
/** 响应处理(启用必传) */
|
|
59
61
|
handlerResponse?: (response: any) => {
|
|
60
62
|
url?: string;
|
|
@@ -83,6 +85,8 @@ export interface AudioUploadOptions {
|
|
|
83
85
|
file: File | Blob;
|
|
84
86
|
extParameters?: Record<string, any>;
|
|
85
87
|
}) => Record<string, any>;
|
|
88
|
+
/** 上传之前回调结束(开始调用上传接口) */
|
|
89
|
+
beforeUploadEnd?: (file: File | Blob) => void;
|
|
86
90
|
/** 响应处理(启用必传) */
|
|
87
91
|
handlerResponse?: (response: any) => {
|
|
88
92
|
url?: string;
|
package/package.json
CHANGED