@keyblade/tinymce-editor-vue2 0.0.12-alpha.46 → 0.0.12-alpha.48
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 +15 -0
- package/es/editor.vue2.js +186 -173
- package/es/style.css +1 -1
- package/es/types.d.ts +8 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -42,6 +42,17 @@ Vue.use(TinymceEditor, {
|
|
|
42
42
|
})
|
|
43
43
|
}, 1000)
|
|
44
44
|
})
|
|
45
|
+
},
|
|
46
|
+
// 网络图片,将URL传给后端,让后端下载后校验、转换、压缩等操作
|
|
47
|
+
handleRequestByUrl: (url: string, parameters: { extParameters: Record<string, any> }) => {
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
resolve({
|
|
51
|
+
success: true,
|
|
52
|
+
url: 'https://object.gcongo.com.cn/onecode-travel/nonClassic/8cefe379c03b5f39cd8ef725293a3c02/2024/5/1715995588295/d0b5bb458b694130be0c63e2f1d0090b.png'
|
|
53
|
+
})
|
|
54
|
+
}, 1000)
|
|
55
|
+
})
|
|
45
56
|
}
|
|
46
57
|
},
|
|
47
58
|
// 音频
|
|
@@ -173,6 +184,10 @@ export interface ImageUploadOptions {
|
|
|
173
184
|
handleRequest?: (file: File, filename: string, options?: {
|
|
174
185
|
extParameters?: Record<string, any>
|
|
175
186
|
}) => Promise<{success: boolean; url?: string; errorMessage?: string}>;
|
|
187
|
+
/** 图片URL上传请求处理(前端跨域,交给后端处理) */
|
|
188
|
+
handleRequestByUrl?: (url: string, options?: {
|
|
189
|
+
extParameters?: Record<string, any>
|
|
190
|
+
}) => Promise<{success: boolean; url?: string; errorMessage?: string}>;
|
|
176
191
|
}
|
|
177
192
|
```
|
|
178
193
|
|
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 De, ref as y, computed as T, watch as k, onMounted as Ae, onUnmounted as Te } from "vue";
|
|
2
|
+
import { oneTravelImgPondBeforeAddFile as K, oneTravelImageCompressor as Q, oneTravelImageCheckAndTransform as Ce } from "@keyblade/one-travel";
|
|
3
|
+
import { blobToFile as Y, generateUUID as Pe, getImagePixel as Z, getFileExtension as ee } from "./util.js";
|
|
4
4
|
import "./style.less.js";
|
|
5
|
-
import
|
|
6
|
-
import { conclude as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
5
|
+
import Me from "imgpond";
|
|
6
|
+
import { conclude as C } from "vue-global-config";
|
|
7
|
+
import ae from "tinymce";
|
|
8
|
+
import Se 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
|
|
37
|
+
import { globalProps as P } from "./index.js";
|
|
38
38
|
import { Message as f } from "element-ui";
|
|
39
|
-
const
|
|
39
|
+
const va = /* @__PURE__ */ De({
|
|
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(te, { emit: z }) {
|
|
54
|
+
const m = te;
|
|
55
|
+
ae.addI18n("zh_CN", Se);
|
|
56
|
+
const B = {
|
|
57
57
|
maxCount: 10,
|
|
58
58
|
tipText: "上传",
|
|
59
59
|
maxSize: 30,
|
|
@@ -67,20 +67,20 @@ const da = /* @__PURE__ */ xe({
|
|
|
67
67
|
maxSize: 300,
|
|
68
68
|
allowedType: ["mp4", "3gp"],
|
|
69
69
|
accept: "video/mp4,video/3gpp"
|
|
70
|
-
},
|
|
70
|
+
}, q = {
|
|
71
71
|
enable: !0,
|
|
72
72
|
maxSize: 200,
|
|
73
73
|
allowedType: ["mp3", "m4a", "wav", "aac"],
|
|
74
74
|
accept: "audio/mp3,audio/wav,audio/aac,audio/x-m4a"
|
|
75
|
-
},
|
|
75
|
+
}, E = y(), h = y(), M = y(!1), S = y(!1), v = y({
|
|
76
76
|
show: !1,
|
|
77
77
|
text: "图片上传中,请稍等"
|
|
78
|
-
}),
|
|
78
|
+
}), r = T(() => C([m.imageUploadOptions, P.imageUploadOptions, B]) || {}), c = T(() => C([m.videoUploadOptions, P.videoUploadOptions, j]) || {}), w = T(() => C([m.audioUploadOptions, P.audioUploadOptions, q]) || {}), H = T(() => C([m.imgPondOptions, P.imgPondOptions]) || {}), oe = T(() => {
|
|
79
79
|
var e, a;
|
|
80
|
-
return ((a = (e =
|
|
81
|
-
}),
|
|
82
|
-
k(() =>
|
|
83
|
-
|
|
80
|
+
return ((a = (e = r == null ? void 0 : r.value) == null ? void 0 : e.allowedType) == null ? void 0 : a.map((t) => `.${t}`).join(",")) || "";
|
|
81
|
+
}), U = y();
|
|
82
|
+
k(() => U.value, () => {
|
|
83
|
+
U.value && K(U.value, {
|
|
84
84
|
onStart: () => {
|
|
85
85
|
v.value = {
|
|
86
86
|
show: !0,
|
|
@@ -91,13 +91,13 @@ const da = /* @__PURE__ */ xe({
|
|
|
91
91
|
v.value.show = !1;
|
|
92
92
|
},
|
|
93
93
|
onError: (e) => {
|
|
94
|
-
v.value.show = !1, f.error(e);
|
|
94
|
+
v.value.show = !1, f.error({ message: e, customClass: "tinymce-editor-message", duration: 2e4 });
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
}, { immediate: !0 });
|
|
98
|
-
const I =
|
|
98
|
+
const I = y();
|
|
99
99
|
k(() => I.value, () => {
|
|
100
|
-
I.value &&
|
|
100
|
+
I.value && K(I.value, {
|
|
101
101
|
onStart: () => {
|
|
102
102
|
v.value = {
|
|
103
103
|
show: !0,
|
|
@@ -112,25 +112,25 @@ const da = /* @__PURE__ */ xe({
|
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
}, { immediate: !0 });
|
|
115
|
-
const
|
|
115
|
+
const A = y({
|
|
116
116
|
dialogVisible: !1,
|
|
117
117
|
formData: {
|
|
118
118
|
images: []
|
|
119
119
|
}
|
|
120
|
-
}), $ =
|
|
121
|
-
|
|
120
|
+
}), $ = y(), R = () => {
|
|
121
|
+
A.value.dialogVisible = !1, A.value.formData = {
|
|
122
122
|
images: []
|
|
123
123
|
};
|
|
124
|
-
},
|
|
124
|
+
}, ie = () => {
|
|
125
125
|
var e;
|
|
126
126
|
(e = $.value) == null || e.validate((a) => {
|
|
127
|
-
a && (
|
|
127
|
+
a && (A.value.formData.images.forEach((t) => {
|
|
128
128
|
var l;
|
|
129
129
|
let o = t;
|
|
130
|
-
|
|
131
|
-
}),
|
|
130
|
+
H.value.srcAt && (o = (t == null ? void 0 : t[H.value.srcAt]) || ""), (l = h.value) == null || l.insertContent(`<img src=${o} alt="" />`);
|
|
131
|
+
}), R());
|
|
132
132
|
});
|
|
133
|
-
},
|
|
133
|
+
}, x = y({
|
|
134
134
|
dialogVisible: !1,
|
|
135
135
|
formData: {
|
|
136
136
|
// 名称
|
|
@@ -142,19 +142,19 @@ const da = /* @__PURE__ */ xe({
|
|
|
142
142
|
},
|
|
143
143
|
// 用于临时保存上传前的参数 { file: File }
|
|
144
144
|
additionalData: {}
|
|
145
|
-
}),
|
|
146
|
-
|
|
145
|
+
}), F = y(), N = () => {
|
|
146
|
+
x.value.dialogVisible = !1, x.value.formData = {
|
|
147
147
|
name: "",
|
|
148
148
|
cover: [],
|
|
149
149
|
file: []
|
|
150
|
-
},
|
|
151
|
-
},
|
|
150
|
+
}, x.value.additionalData = {};
|
|
151
|
+
}, le = () => {
|
|
152
152
|
var e;
|
|
153
|
-
(e =
|
|
153
|
+
(e = F.value) == null || e.validate((a) => {
|
|
154
154
|
var t, o;
|
|
155
|
-
a && ((o =
|
|
155
|
+
a && ((o = h.value) == null || o.insertContent(`<audio controls controlslist="nodownload noplaybackrate" data-name="${x.value.formData.name}" data-poster="${x.value.formData.cover[0]}" src="${(t = x.value.formData.file[0]) == null ? void 0 : t.url}"></audio>`), N());
|
|
156
156
|
});
|
|
157
|
-
},
|
|
157
|
+
}, _ = y({
|
|
158
158
|
dialogVisible: !1,
|
|
159
159
|
formData: {
|
|
160
160
|
// 文件
|
|
@@ -162,30 +162,30 @@ const da = /* @__PURE__ */ xe({
|
|
|
162
162
|
},
|
|
163
163
|
// 用于临时保存上传前的参数 { file: File }
|
|
164
164
|
additionalData: {}
|
|
165
|
-
}),
|
|
166
|
-
|
|
165
|
+
}), O = y(), L = () => {
|
|
166
|
+
_.value.dialogVisible = !1, _.value.formData = {
|
|
167
167
|
file: []
|
|
168
|
-
},
|
|
169
|
-
},
|
|
168
|
+
}, _.value.additionalData = {};
|
|
169
|
+
}, ne = () => {
|
|
170
170
|
var e;
|
|
171
|
-
(e =
|
|
171
|
+
(e = O.value) == null || e.validate((a) => {
|
|
172
172
|
var t, o;
|
|
173
|
-
a && ((o =
|
|
173
|
+
a && ((o = h.value) == null || o.insertContent(`<video width="auto" height="auto" controls src="${(t = _.value.formData.file[0]) == null ? void 0 : t.url}"></video>`), L());
|
|
174
174
|
});
|
|
175
|
-
},
|
|
175
|
+
}, re = () => {
|
|
176
176
|
document.querySelectorAll(".swal2-container .swal2-title").forEach((e) => {
|
|
177
|
-
e && (e.innerHTML = `单次最多可选择${
|
|
177
|
+
e && (e.innerHTML = `单次最多可选择${r.value.maxCount}张图片`);
|
|
178
178
|
});
|
|
179
|
-
},
|
|
180
|
-
var
|
|
181
|
-
const l = await
|
|
179
|
+
}, se = (e, a) => new Promise(async (t, o) => {
|
|
180
|
+
var d, n;
|
|
181
|
+
const l = await Q(e);
|
|
182
182
|
if (!l.success) {
|
|
183
183
|
o(), setTimeout(() => {
|
|
184
184
|
a.onError(l.errorMessage);
|
|
185
185
|
});
|
|
186
186
|
return;
|
|
187
187
|
}
|
|
188
|
-
const i = await ((n = (
|
|
188
|
+
const i = await ((n = (d = r.value).handleRequest) == null ? void 0 : n.call(d, Y(l.file, e.name), e.name, { extParameters: m.extParameters }));
|
|
189
189
|
if (!i || !(i != null && i.success)) {
|
|
190
190
|
o(), setTimeout(() => {
|
|
191
191
|
a.onError(i == null ? void 0 : i.errorMessage);
|
|
@@ -194,41 +194,41 @@ const da = /* @__PURE__ */ xe({
|
|
|
194
194
|
}
|
|
195
195
|
t(i.url);
|
|
196
196
|
});
|
|
197
|
-
async function
|
|
197
|
+
async function ue(e, a) {
|
|
198
198
|
const o = a.node.getElementsByTagName("img"), l = [];
|
|
199
199
|
for (let i = o.length - 1; i >= 0; i--) {
|
|
200
|
-
const
|
|
201
|
-
|
|
200
|
+
const d = o[i], n = "img-" + Pe();
|
|
201
|
+
d.classList.add(n), l.push(n);
|
|
202
202
|
}
|
|
203
203
|
setTimeout(async () => {
|
|
204
|
-
var i,
|
|
204
|
+
var i, d;
|
|
205
205
|
for (let n = l.length - 1; n >= 0; n--) {
|
|
206
|
-
const
|
|
207
|
-
if (
|
|
206
|
+
const u = e.dom.select(`.${l[n]}`);
|
|
207
|
+
if (u.length === 0)
|
|
208
208
|
continue;
|
|
209
|
-
const
|
|
209
|
+
const s = u[0], p = s.src;
|
|
210
210
|
if (p.startsWith("data:image")) {
|
|
211
|
-
e.dom.remove(
|
|
211
|
+
e.dom.remove(s);
|
|
212
212
|
continue;
|
|
213
213
|
} else if (p.startsWith("http://") || p.startsWith("https://")) {
|
|
214
|
-
const
|
|
215
|
-
if (
|
|
216
|
-
e.dom.remove(
|
|
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
217
|
continue;
|
|
218
218
|
}
|
|
219
|
-
const
|
|
220
|
-
if (!((
|
|
221
|
-
e.dom.remove(
|
|
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
222
|
continue;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
|
-
async function
|
|
229
|
-
var
|
|
228
|
+
async function G(e) {
|
|
229
|
+
var d, n, u;
|
|
230
230
|
let a = e;
|
|
231
|
-
if (!((
|
|
231
|
+
if (!((d = r.value) != null && d.handleRequest)) {
|
|
232
232
|
f.error("缺少图片上传配置");
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
@@ -241,14 +241,14 @@ const da = /* @__PURE__ */ xe({
|
|
|
241
241
|
v.value.show = !1, f.error("不允许粘贴");
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
|
-
const o = await
|
|
245
|
-
imageMaxSize:
|
|
246
|
-
imageAllowedType:
|
|
244
|
+
const o = await Ce(a, t, {
|
|
245
|
+
imageMaxSize: r.value.maxSize,
|
|
246
|
+
imageAllowedType: r.value.allowedType,
|
|
247
247
|
// imageAllowedMineType: mergeImageUploadOptions.value.allowedMineType,
|
|
248
|
-
imageMinWidth:
|
|
249
|
-
imageMinHeight:
|
|
250
|
-
imageMaxWidth:
|
|
251
|
-
imageMaxHeight:
|
|
248
|
+
imageMinWidth: r.value.minWidth,
|
|
249
|
+
imageMinHeight: r.value.minHeight,
|
|
250
|
+
imageMaxWidth: r.value.maxWidth,
|
|
251
|
+
imageMaxHeight: r.value.maxHeight
|
|
252
252
|
});
|
|
253
253
|
if (!o.success) {
|
|
254
254
|
v.value.show = !1, f.error((o == null ? void 0 : o.errorMessage) || "");
|
|
@@ -256,15 +256,15 @@ const da = /* @__PURE__ */ xe({
|
|
|
256
256
|
}
|
|
257
257
|
if (o.hasTransform) {
|
|
258
258
|
a = o.file;
|
|
259
|
-
const
|
|
260
|
-
|
|
259
|
+
const s = t == null ? void 0 : t.split(".");
|
|
260
|
+
s.pop(), t = `${s.join(",")}.jpg`;
|
|
261
261
|
}
|
|
262
|
-
const l = await
|
|
262
|
+
const l = await Q(a);
|
|
263
263
|
if (!l.success) {
|
|
264
264
|
v.value.show = !1, f.error((l == null ? void 0 : l.errorMessage) || "压缩失败");
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
|
-
const i = await ((
|
|
267
|
+
const i = await ((u = (n = r.value).handleRequest) == null ? void 0 : u.call(n, Y(l.file, t), t, { extParameters: m.extParameters }));
|
|
268
268
|
if (!i || !i.success) {
|
|
269
269
|
v.value.show = !1, f.error((i == null ? void 0 : i.errorMessage) || "");
|
|
270
270
|
return;
|
|
@@ -272,52 +272,65 @@ const da = /* @__PURE__ */ xe({
|
|
|
272
272
|
return v.value.show = !1, i.url;
|
|
273
273
|
}
|
|
274
274
|
const V = async (e) => {
|
|
275
|
-
|
|
275
|
+
var l, i, d;
|
|
276
|
+
const a = h.value, t = e.types;
|
|
276
277
|
if (t.includes("text/html")) {
|
|
277
|
-
const
|
|
278
|
-
|
|
278
|
+
const n = e.getData("text/html"), s = new DOMParser().parseFromString(n, "text/html"), p = Array.from(s.body.querySelectorAll("img")), b = Array.from(s.body.querySelectorAll("audio")), W = Array.from(s.body.querySelectorAll("video"));
|
|
279
|
+
p.length > 0 && (v.value = {
|
|
279
280
|
show: !0,
|
|
280
281
|
text: "图片加载中,请稍等"
|
|
281
282
|
});
|
|
282
|
-
for (const
|
|
283
|
-
|
|
284
|
-
for await (const
|
|
285
|
-
|
|
283
|
+
for (const D of [...b, ...W])
|
|
284
|
+
D == null || D.remove();
|
|
285
|
+
for await (const D of [...p])
|
|
286
|
+
if (D.removeAttribute("crossorigin"), D.src.startsWith("http"))
|
|
287
|
+
if ((l = r.value) != null && l.handleRequestByUrl) {
|
|
288
|
+
const g = await ((i = r.value) == null ? void 0 : i.handleRequestByUrl(D.src, { extParameters: m.extParameters }));
|
|
289
|
+
g != null && g.success && (g != null && g.url) ? D.src = g == null ? void 0 : g.url : D.remove();
|
|
290
|
+
} else {
|
|
291
|
+
const g = await Z(D.src);
|
|
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)) && D.remove();
|
|
293
|
+
}
|
|
294
|
+
else
|
|
295
|
+
D.remove(), f.error("不支持Word中批量复制图片或视频,请改为单个复制,或者从工具栏中手动插入上传");
|
|
286
296
|
v.value.show = !1;
|
|
287
|
-
const
|
|
288
|
-
a.insertContent(
|
|
297
|
+
const _e = new XMLSerializer().serializeToString(s.body);
|
|
298
|
+
a.insertContent(_e);
|
|
289
299
|
} else
|
|
290
300
|
t.includes("text/plain") && a.insertContent(e.getData("text/plain"));
|
|
291
301
|
const o = Array.from(e.items);
|
|
292
|
-
for await (const
|
|
293
|
-
const
|
|
294
|
-
if (
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
302
|
+
for await (const n of o) {
|
|
303
|
+
const u = n.getAsFile();
|
|
304
|
+
if (!u)
|
|
305
|
+
continue;
|
|
306
|
+
const s = ee(u.name);
|
|
307
|
+
if (u.type.indexOf("image") > -1 || (d = r.value.allowedType) != null && d.includes(s.toLowerCase())) {
|
|
308
|
+
const p = await G(u);
|
|
309
|
+
if (p) {
|
|
310
|
+
const b = `<img src="${p}" alt="" />`;
|
|
311
|
+
a.insertContent(b);
|
|
299
312
|
}
|
|
300
313
|
}
|
|
301
314
|
}
|
|
302
|
-
|
|
303
|
-
},
|
|
315
|
+
z("input", a.getContent());
|
|
316
|
+
}, X = (e) => {
|
|
304
317
|
var t;
|
|
305
318
|
e.preventDefault();
|
|
306
319
|
const a = e.clipboardData || ((t = e == null ? void 0 : e.originalEvent) == null ? void 0 : t.clipboardData);
|
|
307
320
|
V(a);
|
|
308
|
-
},
|
|
321
|
+
}, J = (e) => {
|
|
309
322
|
var t;
|
|
310
323
|
e.preventDefault();
|
|
311
324
|
const a = e.dataTransfer || ((t = e == null ? void 0 : e.originalEvent) == null ? void 0 : t.dataTransfer);
|
|
312
325
|
V(a);
|
|
313
326
|
};
|
|
314
|
-
|
|
327
|
+
Ae(() => {
|
|
315
328
|
var t;
|
|
316
329
|
const e = {
|
|
317
330
|
// 设置语言
|
|
318
331
|
language: "zh_CN",
|
|
319
332
|
// 实例
|
|
320
|
-
target:
|
|
333
|
+
target: E.value,
|
|
321
334
|
// 隐藏品牌
|
|
322
335
|
branding: !1,
|
|
323
336
|
// 隐藏右上角升级按钮
|
|
@@ -395,7 +408,7 @@ const da = /* @__PURE__ */ xe({
|
|
|
395
408
|
convert_urls: !1,
|
|
396
409
|
paste_webkit_styles: "all",
|
|
397
410
|
paste_data_images: !1,
|
|
398
|
-
images_file_types: ((t =
|
|
411
|
+
images_file_types: ((t = r.value.allowedType) == null ? void 0 : t.join(",")) || "jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp",
|
|
399
412
|
// 粘贴前处理
|
|
400
413
|
paste_preprocess(o, l) {
|
|
401
414
|
l == null || l.preventDefault();
|
|
@@ -476,12 +489,12 @@ const da = /* @__PURE__ */ xe({
|
|
|
476
489
|
// })
|
|
477
490
|
// },
|
|
478
491
|
setup(o) {
|
|
479
|
-
var i,
|
|
492
|
+
var i, d;
|
|
480
493
|
const l = () => {
|
|
481
|
-
|
|
482
|
-
var
|
|
483
|
-
const n = (
|
|
484
|
-
n && (n.innerHTML = ((
|
|
494
|
+
A.value.dialogVisible = !0, setTimeout(() => {
|
|
495
|
+
var u, s;
|
|
496
|
+
const n = (u = document == null ? void 0 : document.querySelector) == null ? void 0 : u.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
|
|
497
|
+
n && (n.innerHTML = ((s = r.value) == null ? void 0 : s.tipText) || "上传");
|
|
485
498
|
});
|
|
486
499
|
};
|
|
487
500
|
if (o.ui.registry.addMenuItem("localImage", {
|
|
@@ -492,12 +505,12 @@ const da = /* @__PURE__ */ xe({
|
|
|
492
505
|
icon: "image",
|
|
493
506
|
tooltip: "图片",
|
|
494
507
|
onAction: () => l()
|
|
495
|
-
}), (i =
|
|
508
|
+
}), (i = w == null ? void 0 : w.value) != null && i.enable) {
|
|
496
509
|
const n = () => {
|
|
497
|
-
|
|
498
|
-
var
|
|
499
|
-
const
|
|
500
|
-
|
|
510
|
+
x.value.dialogVisible = !0, setTimeout(() => {
|
|
511
|
+
var s, p;
|
|
512
|
+
const u = (s = document == null ? void 0 : document.querySelector) == null ? void 0 : s.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
|
|
513
|
+
u && (u.innerHTML = ((p = r.value) == null ? void 0 : p.tipText) || "上传");
|
|
501
514
|
});
|
|
502
515
|
};
|
|
503
516
|
o.ui.registry.addMenuItem("localAudio", {
|
|
@@ -510,9 +523,9 @@ const da = /* @__PURE__ */ xe({
|
|
|
510
523
|
onAction: () => n()
|
|
511
524
|
});
|
|
512
525
|
}
|
|
513
|
-
if ((
|
|
526
|
+
if ((d = c == null ? void 0 : c.value) != null && d.enable) {
|
|
514
527
|
const n = () => {
|
|
515
|
-
|
|
528
|
+
_.value.dialogVisible = !0;
|
|
516
529
|
};
|
|
517
530
|
o.ui.registry.addMenuItem("localVideo", {
|
|
518
531
|
text: "视频",
|
|
@@ -525,10 +538,10 @@ const da = /* @__PURE__ */ xe({
|
|
|
525
538
|
});
|
|
526
539
|
}
|
|
527
540
|
}
|
|
528
|
-
}, a =
|
|
541
|
+
}, a = C(
|
|
529
542
|
[
|
|
530
|
-
|
|
531
|
-
|
|
543
|
+
m.options,
|
|
544
|
+
P.options,
|
|
532
545
|
e
|
|
533
546
|
],
|
|
534
547
|
{
|
|
@@ -538,98 +551,98 @@ const da = /* @__PURE__ */ xe({
|
|
|
538
551
|
type: Object
|
|
539
552
|
}
|
|
540
553
|
);
|
|
541
|
-
|
|
554
|
+
ae.init(a).then(([o]) => {
|
|
542
555
|
var l;
|
|
543
|
-
o && (o.customProps = { ...
|
|
544
|
-
if (
|
|
545
|
-
|
|
556
|
+
o && (o.customProps = { ...m }, o.on("input", () => {
|
|
557
|
+
if (S.value) {
|
|
558
|
+
S.value = !1;
|
|
546
559
|
return;
|
|
547
560
|
}
|
|
548
|
-
|
|
561
|
+
M.value = !0, z("input", o.getContent());
|
|
549
562
|
}), o.on("paste", (i) => {
|
|
550
|
-
|
|
563
|
+
X(i);
|
|
551
564
|
}), o.on("drop", (i) => {
|
|
552
|
-
|
|
553
|
-
}), (l =
|
|
565
|
+
J(i);
|
|
566
|
+
}), (l = m.initComplete) == null || l.call(m, { editorIns: o }), h.value = o);
|
|
554
567
|
});
|
|
555
|
-
}),
|
|
568
|
+
}), Te(() => {
|
|
556
569
|
var e, a, t, o;
|
|
557
|
-
(e =
|
|
570
|
+
(e = h.value) == null || e.off("input"), (a = h.value) == null || a.off("paste"), (t = h.value) == null || t.off("drop"), (o = h.value) == null || o.destroy();
|
|
558
571
|
});
|
|
559
|
-
const
|
|
572
|
+
const me = () => {
|
|
560
573
|
var a, t;
|
|
561
|
-
const e = { ...
|
|
562
|
-
return ((t = (a =
|
|
563
|
-
},
|
|
574
|
+
const e = { ...x.value.additionalData || {} };
|
|
575
|
+
return ((t = (a = w.value) == null ? void 0 : a.data) == null ? void 0 : t.call(a, { ...e, extParameters: m.extParameters })) || {};
|
|
576
|
+
}, de = () => {
|
|
564
577
|
var a, t;
|
|
565
|
-
const e = { ...
|
|
566
|
-
return ((t = (a =
|
|
567
|
-
},
|
|
578
|
+
const e = { ...x.value.additionalData || {} };
|
|
579
|
+
return ((t = (a = w.value) == null ? void 0 : a.headers) == null ? void 0 : t.call(a, { ...e, extParameters: m.extParameters })) || {};
|
|
580
|
+
}, ce = (e, a, t) => {
|
|
568
581
|
var l, i;
|
|
569
|
-
const o = (i = (l =
|
|
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)),
|
|
571
|
-
},
|
|
572
|
-
var i,
|
|
582
|
+
const o = (i = (l = w == null ? void 0 : w.value) == null ? void 0 : l.handlerResponse) == null ? void 0 : i.call(l, e);
|
|
583
|
+
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)), x.value.formData.file = t;
|
|
584
|
+
}, pe = (e, a) => new Promise((t, o) => {
|
|
585
|
+
var i, d, n, u, s, p;
|
|
573
586
|
const l = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
|
|
574
|
-
if (!((
|
|
575
|
-
f.error(`请上传格式为${(
|
|
587
|
+
if (!((d = (i = w.value) == null ? void 0 : i.allowedType) != null && d.includes(l.toLowerCase()))) {
|
|
588
|
+
f.error(`请上传格式为${(u = (n = w.value) == null ? void 0 : n.allowedType) == null ? void 0 : u.map((b) => b.toUpperCase()).join("、")}的音频`), o();
|
|
576
589
|
return;
|
|
577
590
|
}
|
|
578
|
-
if (e.size > (((
|
|
579
|
-
f.error(`请上传${((p =
|
|
591
|
+
if (e.size > (((s = w.value) == null ? void 0 : s.maxSize) || 0) * 1024 * 1024) {
|
|
592
|
+
f.error(`请上传${((p = w.value) == null ? void 0 : p.maxSize) || 0}M内的音频`), o();
|
|
580
593
|
return;
|
|
581
594
|
}
|
|
582
|
-
|
|
583
|
-
}),
|
|
584
|
-
|
|
585
|
-
},
|
|
586
|
-
f.error("上传发生错误,请重试!"),
|
|
587
|
-
},
|
|
595
|
+
x.value.additionalData = { file: e }, t(!0);
|
|
596
|
+
}), fe = (e, a) => {
|
|
597
|
+
x.value.formData.file = a;
|
|
598
|
+
}, ve = (e, a, t) => {
|
|
599
|
+
f.error("上传发生错误,请重试!"), x.value.formData.file = t;
|
|
600
|
+
}, ge = () => {
|
|
588
601
|
var a, t;
|
|
589
|
-
const e = { ...
|
|
590
|
-
return ((t = (a =
|
|
591
|
-
},
|
|
602
|
+
const e = { ..._.value.additionalData || {} };
|
|
603
|
+
return ((t = (a = c.value) == null ? void 0 : a.data) == null ? void 0 : t.call(a, { ...e, extParameters: m.extParameters })) || {};
|
|
604
|
+
}, he = () => {
|
|
592
605
|
var a, t;
|
|
593
|
-
const e = { ...
|
|
594
|
-
return ((t = (a =
|
|
595
|
-
},
|
|
606
|
+
const e = { ..._.value.additionalData || {} };
|
|
607
|
+
return ((t = (a = c.value) == null ? void 0 : a.headers) == null ? void 0 : t.call(a, { ...e, extParameters: m.extParameters })) || {};
|
|
608
|
+
}, xe = (e, a, t) => {
|
|
596
609
|
var l, i;
|
|
597
|
-
const o = (i = (l =
|
|
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)),
|
|
599
|
-
},
|
|
600
|
-
var i,
|
|
610
|
+
const o = (i = (l = c == null ? void 0 : c.value) == null ? void 0 : l.handlerResponse) == null ? void 0 : i.call(l, e);
|
|
611
|
+
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)), _.value.formData.file = t;
|
|
612
|
+
}, we = (e, a) => new Promise((t, o) => {
|
|
613
|
+
var i, d, n, u, s, p;
|
|
601
614
|
const l = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
|
|
602
|
-
if (!((
|
|
603
|
-
f.error(`请上传格式为${(
|
|
615
|
+
if (!((d = (i = c == null ? void 0 : c.value) == null ? void 0 : i.allowedType) != null && d.includes(l.toLowerCase()))) {
|
|
616
|
+
f.error(`请上传格式为${(u = (n = c == null ? void 0 : c.value) == null ? void 0 : n.allowedType) == null ? void 0 : u.map((b) => b.toUpperCase()).join("、")}的视频`), o();
|
|
604
617
|
return;
|
|
605
618
|
}
|
|
606
|
-
if (e.size > (((
|
|
607
|
-
f.error(`请上传${((p =
|
|
619
|
+
if (e.size > (((s = c == null ? void 0 : c.value) == null ? void 0 : s.maxSize) || 0) * 1024 * 1024) {
|
|
620
|
+
f.error(`请上传${((p = c == null ? void 0 : c.value) == null ? void 0 : p.maxSize) || 0}M内的视频`), o();
|
|
608
621
|
return;
|
|
609
622
|
}
|
|
610
|
-
|
|
611
|
-
}),
|
|
612
|
-
|
|
613
|
-
},
|
|
614
|
-
f.error("上传发生错误,请重试!"),
|
|
623
|
+
_.value.additionalData = { file: e }, t(!0);
|
|
624
|
+
}), be = (e, a) => {
|
|
625
|
+
_.value.formData.file = a;
|
|
626
|
+
}, ye = (e, a, t) => {
|
|
627
|
+
f.error("上传发生错误,请重试!"), _.value.formData.file = t;
|
|
615
628
|
};
|
|
616
|
-
return k(() => [
|
|
629
|
+
return k(() => [m.disabled, h.value], () => {
|
|
617
630
|
var e, a;
|
|
618
|
-
(a = (e =
|
|
631
|
+
(a = (e = h.value) == null ? void 0 : e.mode) == null || a.set(m.disabled ? "readonly" : "design");
|
|
619
632
|
}, { immediate: !0 }), k(
|
|
620
|
-
() => [
|
|
633
|
+
() => [m.value, h.value],
|
|
621
634
|
() => {
|
|
622
635
|
var e;
|
|
623
|
-
if (
|
|
624
|
-
|
|
636
|
+
if (M.value) {
|
|
637
|
+
M.value = !1;
|
|
625
638
|
return;
|
|
626
639
|
}
|
|
627
|
-
|
|
640
|
+
S.value = !0, (e = h.value) == null || e.setContent(m.value ? m.value : "");
|
|
628
641
|
},
|
|
629
642
|
{ immediate: !0 }
|
|
630
|
-
), { __sfc: !0, defaultImageUploadOptions:
|
|
643
|
+
), { __sfc: !0, defaultImageUploadOptions: B, defaultVideoUploadOptions: j, defaultAudioUploadOptions: q, props: m, emits: z, insRef: E, editorRef: h, preventSettingContent: M, preventUpdatingModelValue: S, uploadLoadingConfig: v, mergeImageUploadOptions: r, mergeVideoUploadOptions: c, mergeAudioUploadOptions: w, mergeImgPondOptions: H, imgPondAccept: oe, uploadImageImgPondRef: U, audioImageImgPondRef: I, uploadImage: A, uploadImageFormRef: $, onUploadImageClose: R, onUploadImageConfirm: ie, uploadAudio: x, uploadAudioFormRef: F, onUploadAudioClose: N, onUploadAudioConfirm: le, uploadVideo: _, uploadVideoFormRef: O, onUploadVideoClose: L, onUploadVideoConfirm: ne, onImageUploadUploadExceed: re, onImageUploadUpload: se, processPastedImage: ue, uploadPasteOrDropFile: G, handleDataTransfer: V, onValuePaste: X, onValueDrop: J, getUploadAudioData: me, getUploadAudioHeaders: de, onUploadAudioSuccess: ce, onUploadAudioBeforeUpload: pe, onUploadAudioRemove: fe, onUploadAudioError: ve, getUploadVideoData: ge, getUploadVideoHeaders: he, onUploadVideoSuccess: xe, onUploadVideoBeforeUpload: we, onUploadVideoRemove: be, onUploadVideoError: ye, ImgPond: Me };
|
|
631
644
|
}
|
|
632
645
|
});
|
|
633
646
|
export {
|
|
634
|
-
|
|
647
|
+
va as default
|
|
635
648
|
};
|
package/es/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.tox-tinymce-aux{z-index:10000!important}.tox-statusbar__branding{display:none!important}.tinymce-editor-dialog .el-dialog{min-width:600px}.tinymce-editor-upload-image-dialog .uploadImageForm{display:flex;align-content:center}.tinymce-editor-upload-image-dialog .uploadImageForm .tips{margin-left:20px;display:flex;flex-direction:column}.tinymce-editor-upload-image-dialog .uploadImageForm .tips>span{margin-bottom:16px}.tinymce-editor-dialog .upload-hide .el-upload,.tinymce-editor-dialog .upload-hide .el-upload__tip{display:none}.tinymce-editor-loading-dialog{z-index:4000!important}.tinymce-editor-loading-dialog .el-dialog{margin-top:calc(50vh - 107px);width:388px;min-width:auto!important;height:214px;background-image:linear-gradient(-72deg,#d8faff,#fff);box-shadow:0 2px 20px #00000012;border-radius:16px}.tinymce-editor-loading-dialog .el-dialog .el-dialog__header{display:none!important}.tinymce-editor-loading-dialog .el-dialog .el-dialog__body{height:100%}.tinymce-editor-loading-dialog .el-dialog .el-dialog__body .tinymce-editor-loading-dialog-content{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center}.tinymce-editor-loading-dialog .el-dialog .el-dialog__body .tinymce-editor-loading-dialog-content span{margin-top:15px;font-size:16px;color:#1d2129;line-height:24px;font-weight:500}.tinymce-editor-spinner{width:60px;height:60px;position:relative;text-align:center;-webkit-animation:sk-rotate 2s infinite linear;animation:sk-rotate 2s infinite linear}.tinymce-editor-spinner-dot1,.tinymce-editor-spinner-dot2,.tinymce-editor-spinner-dot3{width:24px;height:24px;display:inline-block;position:absolute;top:0;background-color:#333;border-radius:100%;-webkit-animation:sk-bounce 2s infinite ease-in-out;animation:sk-bounce 2s infinite ease-in-out}.tinymce-editor-spinner-dot1{left:calc(50% - 12px);background-color:#5dff8e}.tinymce-editor-spinner-dot2{top:auto;bottom:0;right:0;-webkit-animation-delay:-1s;animation-delay:-1s;background-color:#21f4c7}.tinymce-editor-spinner-dot3{top:auto;bottom:0;left:0;-webkit-animation-delay:-1s;animation-delay:-1s;background-color:#98ff56}@-webkit-keyframes sk-rotate{to{-webkit-transform:rotate(360deg)}}@keyframes sk-rotate{to{transform:rotate(360deg);-webkit-transform:rotate(360deg)}}@-webkit-keyframes sk-bounce{0%,to{-webkit-transform:scale(0)}50%{-webkit-transform:scale(1)}}@keyframes sk-bounce{0%,to{transform:scale(0);-webkit-transform:scale(0)}50%{transform:scale(1);-webkit-transform:scale(1)}}
|
|
1
|
+
.tox-tinymce-aux{z-index:10000!important}.tox-statusbar__branding{display:none!important}.tinymce-editor-dialog .el-dialog{min-width:600px}.tinymce-editor-upload-image-dialog .uploadImageForm{display:flex;align-content:center}.tinymce-editor-upload-image-dialog .uploadImageForm .tips{margin-left:20px;display:flex;flex-direction:column}.tinymce-editor-upload-image-dialog .uploadImageForm .tips>span{margin-bottom:16px}.tinymce-editor-dialog .upload-hide .el-upload,.tinymce-editor-dialog .upload-hide .el-upload__tip{display:none}.tinymce-editor-loading-dialog{z-index:4000!important}.tinymce-editor-loading-dialog .el-dialog{margin-top:calc(50vh - 107px);width:388px;min-width:auto!important;height:214px;background-image:linear-gradient(-72deg,#d8faff,#fff);box-shadow:0 2px 20px #00000012;border-radius:16px}.tinymce-editor-loading-dialog .el-dialog .el-dialog__header{display:none!important}.tinymce-editor-loading-dialog .el-dialog .el-dialog__body{height:100%}.tinymce-editor-loading-dialog .el-dialog .el-dialog__body .tinymce-editor-loading-dialog-content{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center}.tinymce-editor-loading-dialog .el-dialog .el-dialog__body .tinymce-editor-loading-dialog-content span{margin-top:15px;font-size:16px;color:#1d2129;line-height:24px;font-weight:500}.tinymce-editor-spinner{width:60px;height:60px;position:relative;text-align:center;-webkit-animation:sk-rotate 2s infinite linear;animation:sk-rotate 2s infinite linear}.tinymce-editor-spinner-dot1,.tinymce-editor-spinner-dot2,.tinymce-editor-spinner-dot3{width:24px;height:24px;display:inline-block;position:absolute;top:0;background-color:#333;border-radius:100%;-webkit-animation:sk-bounce 2s infinite ease-in-out;animation:sk-bounce 2s infinite ease-in-out}.tinymce-editor-spinner-dot1{left:calc(50% - 12px);background-color:#5dff8e}.tinymce-editor-spinner-dot2{top:auto;bottom:0;right:0;-webkit-animation-delay:-1s;animation-delay:-1s;background-color:#21f4c7}.tinymce-editor-spinner-dot3{top:auto;bottom:0;left:0;-webkit-animation-delay:-1s;animation-delay:-1s;background-color:#98ff56}@-webkit-keyframes sk-rotate{to{-webkit-transform:rotate(360deg)}}@keyframes sk-rotate{to{transform:rotate(360deg);-webkit-transform:rotate(360deg)}}@-webkit-keyframes sk-bounce{0%,to{-webkit-transform:scale(0)}50%{-webkit-transform:scale(1)}}@keyframes sk-bounce{0%,to{transform:scale(0);-webkit-transform:scale(0)}50%{transform:scale(1);-webkit-transform:scale(1)}}.tinymce-editor-message{z-index:4000!important}
|
package/es/types.d.ts
CHANGED
|
@@ -24,6 +24,14 @@ export interface ImageUploadOptions {
|
|
|
24
24
|
url?: string;
|
|
25
25
|
errorMessage?: string;
|
|
26
26
|
}>;
|
|
27
|
+
/** 图片URL上传请求处理(前端跨域,交给后端处理) */
|
|
28
|
+
handleRequestByUrl?: (url: string, options?: {
|
|
29
|
+
extParameters?: Record<string, any>;
|
|
30
|
+
}) => Promise<{
|
|
31
|
+
success: boolean;
|
|
32
|
+
url?: string;
|
|
33
|
+
errorMessage?: string;
|
|
34
|
+
}>;
|
|
27
35
|
}
|
|
28
36
|
/** 视频选项 */
|
|
29
37
|
export interface VideoUploadOptions {
|
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.48",
|
|
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.14"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"vue": "^2.7.0",
|