@keyblade/tinymce-editor-vue2 0.0.12-alpha.45 → 0.0.12-alpha.47
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 +364 -244
- 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
|
|
5
|
+
import Me from "imgpond";
|
|
6
6
|
import { conclude as C } from "vue-global-config";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
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
|
|
38
|
-
import { Message as
|
|
39
|
-
const
|
|
37
|
+
import { globalProps as P } from "./index.js";
|
|
38
|
+
import { Message as f } from "element-ui";
|
|
39
|
+
const va = /* @__PURE__ */ De({
|
|
40
40
|
__name: "editor",
|
|
41
41
|
props: {
|
|
42
42
|
value: { default: "" },
|
|
@@ -50,88 +50,87 @@ const ma = /* @__PURE__ */ xe({
|
|
|
50
50
|
initComplete: null
|
|
51
51
|
},
|
|
52
52
|
emits: ["input"],
|
|
53
|
-
setup(
|
|
54
|
-
const m =
|
|
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,
|
|
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"],
|
|
70
69
|
accept: "video/mp4,video/3gpp"
|
|
71
|
-
},
|
|
70
|
+
}, q = {
|
|
72
71
|
enable: !0,
|
|
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
|
+
}, E = y(), h = y(), M = y(!1), S = y(!1), v = y({
|
|
77
76
|
show: !1,
|
|
78
77
|
text: "图片上传中,请稍等"
|
|
79
|
-
}),
|
|
80
|
-
var e,
|
|
81
|
-
return ((
|
|
82
|
-
}),
|
|
83
|
-
|
|
84
|
-
|
|
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
|
+
var e, a;
|
|
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, {
|
|
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 = y();
|
|
99
|
+
k(() => I.value, () => {
|
|
100
|
+
I.value && K(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 A = y({
|
|
117
116
|
dialogVisible: !1,
|
|
118
117
|
formData: {
|
|
119
118
|
images: []
|
|
120
119
|
}
|
|
121
|
-
}),
|
|
122
|
-
|
|
120
|
+
}), $ = y(), R = () => {
|
|
121
|
+
A.value.dialogVisible = !1, A.value.formData = {
|
|
123
122
|
images: []
|
|
124
123
|
};
|
|
125
|
-
},
|
|
124
|
+
}, ie = () => {
|
|
126
125
|
var e;
|
|
127
|
-
(e =
|
|
128
|
-
|
|
129
|
-
var
|
|
130
|
-
let
|
|
131
|
-
|
|
126
|
+
(e = $.value) == null || e.validate((a) => {
|
|
127
|
+
a && (A.value.formData.images.forEach((t) => {
|
|
128
|
+
var l;
|
|
129
|
+
let o = t;
|
|
130
|
+
H.value.srcAt && (o = (t == null ? void 0 : t[H.value.srcAt]) || ""), (l = h.value) == null || l.insertContent(`<img src=${o} alt="" />`);
|
|
132
131
|
}), R());
|
|
133
132
|
});
|
|
134
|
-
},
|
|
133
|
+
}, x = y({
|
|
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
|
+
}), F = y(), N = () => {
|
|
146
|
+
x.value.dialogVisible = !1, x.value.formData = {
|
|
148
147
|
name: "",
|
|
149
148
|
cover: [],
|
|
150
149
|
file: []
|
|
151
|
-
},
|
|
152
|
-
},
|
|
150
|
+
}, x.value.additionalData = {};
|
|
151
|
+
}, le = () => {
|
|
153
152
|
var e;
|
|
154
|
-
(e =
|
|
155
|
-
var
|
|
156
|
-
|
|
153
|
+
(e = F.value) == null || e.validate((a) => {
|
|
154
|
+
var t, 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());
|
|
157
156
|
});
|
|
158
|
-
},
|
|
157
|
+
}, _ = y({
|
|
159
158
|
dialogVisible: !1,
|
|
160
159
|
formData: {
|
|
161
160
|
// 文件
|
|
@@ -163,83 +162,175 @@ const ma = /* @__PURE__ */ xe({
|
|
|
163
162
|
},
|
|
164
163
|
// 用于临时保存上传前的参数 { file: File }
|
|
165
164
|
additionalData: {}
|
|
166
|
-
}),
|
|
167
|
-
|
|
165
|
+
}), O = y(), L = () => {
|
|
166
|
+
_.value.dialogVisible = !1, _.value.formData = {
|
|
168
167
|
file: []
|
|
169
|
-
},
|
|
170
|
-
},
|
|
168
|
+
}, _.value.additionalData = {};
|
|
169
|
+
}, ne = () => {
|
|
171
170
|
var e;
|
|
172
|
-
(e =
|
|
173
|
-
var
|
|
174
|
-
|
|
171
|
+
(e = O.value) == null || e.validate((a) => {
|
|
172
|
+
var t, 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());
|
|
175
174
|
});
|
|
176
|
-
},
|
|
175
|
+
}, re = () => {
|
|
177
176
|
document.querySelectorAll(".swal2-container .swal2-title").forEach((e) => {
|
|
178
|
-
e && (e.innerHTML = `单次最多可选择${
|
|
177
|
+
e && (e.innerHTML = `单次最多可选择${r.value.maxCount}张图片`);
|
|
179
178
|
});
|
|
180
|
-
},
|
|
181
|
-
var
|
|
182
|
-
const
|
|
183
|
-
if (!
|
|
184
|
-
|
|
185
|
-
|
|
179
|
+
}, se = (e, a) => new Promise(async (t, o) => {
|
|
180
|
+
var d, n;
|
|
181
|
+
const l = await Q(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 = (d = r.value).handleRequest) == null ? void 0 : n.call(d, Y(l.file, e.name), e.name, { extParameters: m.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
|
|
202
|
-
|
|
197
|
+
async function ue(e, a) {
|
|
198
|
+
const o = a.node.getElementsByTagName("img"), l = [];
|
|
199
|
+
for (let i = o.length - 1; i >= 0; i--) {
|
|
200
|
+
const d = o[i], n = "img-" + Pe();
|
|
201
|
+
d.classList.add(n), l.push(n);
|
|
203
202
|
}
|
|
204
203
|
setTimeout(async () => {
|
|
205
|
-
var
|
|
206
|
-
for (let n =
|
|
207
|
-
const
|
|
208
|
-
if (
|
|
204
|
+
var i, d;
|
|
205
|
+
for (let n = l.length - 1; n >= 0; n--) {
|
|
206
|
+
const u = e.dom.select(`.${l[n]}`);
|
|
207
|
+
if (u.length === 0)
|
|
209
208
|
continue;
|
|
210
|
-
const
|
|
209
|
+
const s = u[0], p = s.src;
|
|
211
210
|
if (p.startsWith("data:image")) {
|
|
212
|
-
e.dom.remove(
|
|
211
|
+
e.dom.remove(s);
|
|
213
212
|
continue;
|
|
214
213
|
} else if (p.startsWith("http://") || p.startsWith("https://")) {
|
|
215
|
-
const b = await
|
|
216
|
-
if (b && (b.width < (
|
|
217
|
-
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);
|
|
218
217
|
continue;
|
|
219
218
|
}
|
|
220
|
-
const
|
|
221
|
-
if (!((
|
|
222
|
-
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);
|
|
223
222
|
continue;
|
|
224
223
|
}
|
|
225
224
|
}
|
|
226
225
|
}
|
|
227
226
|
});
|
|
228
227
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
228
|
+
async function G(e) {
|
|
229
|
+
var d, n, u;
|
|
230
|
+
let a = e;
|
|
231
|
+
if (!((d = r.value) != null && d.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 Ce(a, t, {
|
|
245
|
+
imageMaxSize: r.value.maxSize,
|
|
246
|
+
imageAllowedType: r.value.allowedType,
|
|
247
|
+
// imageAllowedMineType: mergeImageUploadOptions.value.allowedMineType,
|
|
248
|
+
imageMinWidth: r.value.minWidth,
|
|
249
|
+
imageMinHeight: r.value.minHeight,
|
|
250
|
+
imageMaxWidth: r.value.maxWidth,
|
|
251
|
+
imageMaxHeight: r.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 s = t == null ? void 0 : t.split(".");
|
|
260
|
+
s.pop(), t = `${s.join(",")}.jpg`;
|
|
261
|
+
}
|
|
262
|
+
const l = await Q(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 ((u = (n = r.value).handleRequest) == null ? void 0 : u.call(n, Y(l.file, t), t, { extParameters: m.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
|
+
var l, i, d;
|
|
276
|
+
const a = h.value, t = e.types;
|
|
277
|
+
if (t.includes("text/html")) {
|
|
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 = {
|
|
280
|
+
show: !0,
|
|
281
|
+
text: "图片加载中,请稍等"
|
|
282
|
+
});
|
|
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中批量复制图片或视频,请改为单个复制,或者从工具栏中手动插入上传");
|
|
296
|
+
v.value.show = !1;
|
|
297
|
+
const _e = new XMLSerializer().serializeToString(s.body);
|
|
298
|
+
a.insertContent(_e);
|
|
299
|
+
} else
|
|
300
|
+
t.includes("text/plain") && a.insertContent(e.getData("text/plain"));
|
|
301
|
+
const o = Array.from(e.items);
|
|
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);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
z("input", a.getContent());
|
|
316
|
+
}, X = (e) => {
|
|
317
|
+
var t;
|
|
318
|
+
e.preventDefault();
|
|
319
|
+
const a = e.clipboardData || ((t = e == null ? void 0 : e.originalEvent) == null ? void 0 : t.clipboardData);
|
|
320
|
+
V(a);
|
|
321
|
+
}, J = (e) => {
|
|
322
|
+
var t;
|
|
323
|
+
e.preventDefault();
|
|
324
|
+
const a = e.dataTransfer || ((t = e == null ? void 0 : e.originalEvent) == null ? void 0 : t.dataTransfer);
|
|
325
|
+
V(a);
|
|
235
326
|
};
|
|
236
|
-
|
|
237
|
-
var
|
|
327
|
+
Ae(() => {
|
|
328
|
+
var t;
|
|
238
329
|
const e = {
|
|
239
330
|
// 设置语言
|
|
240
331
|
language: "zh_CN",
|
|
241
332
|
// 实例
|
|
242
|
-
target:
|
|
333
|
+
target: E.value,
|
|
243
334
|
// 隐藏品牌
|
|
244
335
|
branding: !1,
|
|
245
336
|
// 隐藏右上角升级按钮
|
|
@@ -316,213 +407,242 @@ const ma = /* @__PURE__ */ xe({
|
|
|
316
407
|
relative_urls: !1,
|
|
317
408
|
convert_urls: !1,
|
|
318
409
|
paste_webkit_styles: "all",
|
|
319
|
-
paste_data_images: !
|
|
320
|
-
images_file_types: ((
|
|
410
|
+
paste_data_images: !1,
|
|
411
|
+
images_file_types: ((t = r.value.allowedType) == null ? void 0 : t.join(",")) || "jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp",
|
|
321
412
|
// 粘贴前处理
|
|
322
|
-
paste_preprocess(
|
|
323
|
-
|
|
413
|
+
paste_preprocess(o, l) {
|
|
414
|
+
l == null || l.preventDefault();
|
|
324
415
|
},
|
|
325
|
-
// 粘贴后处理(处理异步操作)
|
|
326
|
-
paste_postprocess(
|
|
327
|
-
|
|
328
|
-
|
|
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
|
-
|
|
416
|
+
// // 粘贴后处理(处理异步操作)
|
|
417
|
+
// paste_postprocess(editor, args) {
|
|
418
|
+
// // 处理图片
|
|
419
|
+
// processPastedImage(editor, args)
|
|
420
|
+
// },
|
|
421
|
+
// images_upload_handler(blobInfo) {
|
|
422
|
+
// // eslint-disable-next-line no-async-promise-executor
|
|
423
|
+
// return new Promise(async (resolve, reject) => {
|
|
424
|
+
// // 校验图片配置
|
|
425
|
+
// if (!mergeImageUploadOptions.value?.handleRequest) {
|
|
426
|
+
// removeNotification()
|
|
427
|
+
// return reject({ message: '缺少图片上传配置', remove: true })
|
|
428
|
+
// }
|
|
429
|
+
//
|
|
430
|
+
// uploadLoadingConfig.value = {
|
|
431
|
+
// show: true,
|
|
432
|
+
// text: '图片上传中,请稍等'
|
|
433
|
+
// }
|
|
434
|
+
//
|
|
435
|
+
// // 获取文件 blob 数据
|
|
436
|
+
// // 1.从本地复制图片都是 File 对象,chrome 复制非图片文件,都是 blob,且为 png
|
|
437
|
+
// let file = blobInfo.blob()
|
|
438
|
+
// // 有名称,则取真实名称
|
|
439
|
+
// let filename = (file as File).name ? (file as File).name : blobInfo.filename()
|
|
440
|
+
// if (!(file as File)?.name && !(file as File)?.lastModified && file.type === 'image/png') {// chrome 复制非图片格式
|
|
441
|
+
// uploadLoadingConfig.value.show = false
|
|
442
|
+
// removeNotification()
|
|
443
|
+
// return reject({ message: '不允许粘贴', remove: true })
|
|
444
|
+
// }
|
|
445
|
+
//
|
|
446
|
+
// // 图片校验
|
|
447
|
+
// const checkRes = await oneTravelImageCheckAndTransform(file, filename, {
|
|
448
|
+
// imageMaxSize: mergeImageUploadOptions.value.maxSize,
|
|
449
|
+
// imageAllowedType: mergeImageUploadOptions.value.allowedType,
|
|
450
|
+
// imageMinWidth: mergeImageUploadOptions.value.minWidth,
|
|
451
|
+
// imageMinHeight: mergeImageUploadOptions.value.minHeight,
|
|
452
|
+
// imageMaxWidth: mergeImageUploadOptions.value.maxWidth,
|
|
453
|
+
// imageMaxHeight: mergeImageUploadOptions.value.maxHeight
|
|
454
|
+
// })
|
|
455
|
+
// if (!checkRes.success) {
|
|
456
|
+
// uploadLoadingConfig.value.show = false
|
|
457
|
+
// removeNotification()
|
|
458
|
+
// return reject({ message: checkRes?.errorMessage || '', remove: true })
|
|
459
|
+
// }
|
|
460
|
+
// if (checkRes.hasTransform) {// 被转换
|
|
461
|
+
// // 修改文件
|
|
462
|
+
// file = checkRes.file!
|
|
463
|
+
//
|
|
464
|
+
// // 修改名称
|
|
465
|
+
// const arr = filename?.split('.')
|
|
466
|
+
// arr.pop()
|
|
467
|
+
// const prefix = arr.join(',')
|
|
468
|
+
// filename = `${prefix}.jpg`
|
|
469
|
+
// }
|
|
470
|
+
//
|
|
471
|
+
// // 图片压缩
|
|
472
|
+
// const compressorRes = await oneTravelImageCompressor(file)
|
|
473
|
+
// if (!compressorRes.success) {
|
|
474
|
+
// uploadLoadingConfig.value.show = false
|
|
475
|
+
// removeNotification()
|
|
476
|
+
// return reject({ message: compressorRes?.errorMessage, remove: true })
|
|
477
|
+
// }
|
|
478
|
+
//
|
|
479
|
+
// // 上传图片
|
|
480
|
+
// const uploadRes = await mergeImageUploadOptions.value.handleRequest?.(blobToFile(compressorRes.file, filename), filename, { extParameters: props.extParameters })
|
|
481
|
+
// if (!uploadRes || !uploadRes.success) {
|
|
482
|
+
// uploadLoadingConfig.value.show = false
|
|
483
|
+
// removeNotification()
|
|
484
|
+
// return reject({ message: uploadRes.errorMessage, remove: true })
|
|
485
|
+
// }
|
|
486
|
+
//
|
|
487
|
+
// uploadLoadingConfig.value.show = false
|
|
488
|
+
// resolve(uploadRes.url!)
|
|
489
|
+
// })
|
|
490
|
+
// },
|
|
491
|
+
setup(o) {
|
|
492
|
+
var i, d;
|
|
493
|
+
const l = () => {
|
|
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) || "上传");
|
|
373
498
|
});
|
|
374
499
|
};
|
|
375
|
-
if (
|
|
500
|
+
if (o.ui.registry.addMenuItem("localImage", {
|
|
376
501
|
text: "图片",
|
|
377
502
|
icon: "image",
|
|
378
|
-
onAction: () =>
|
|
379
|
-
}),
|
|
503
|
+
onAction: () => l()
|
|
504
|
+
}), o.ui.registry.addButton("localImage", {
|
|
380
505
|
icon: "image",
|
|
381
506
|
tooltip: "图片",
|
|
382
|
-
onAction: () =>
|
|
383
|
-
}), (
|
|
507
|
+
onAction: () => l()
|
|
508
|
+
}), (i = w == null ? void 0 : w.value) != null && i.enable) {
|
|
384
509
|
const n = () => {
|
|
385
|
-
|
|
386
|
-
var
|
|
387
|
-
const
|
|
388
|
-
|
|
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) || "上传");
|
|
389
514
|
});
|
|
390
515
|
};
|
|
391
|
-
|
|
516
|
+
o.ui.registry.addMenuItem("localAudio", {
|
|
392
517
|
text: "音频",
|
|
393
518
|
icon: "arrow-right",
|
|
394
519
|
onAction: () => n()
|
|
395
|
-
}),
|
|
520
|
+
}), o.ui.registry.addButton("localAudio", {
|
|
396
521
|
icon: "arrow-right",
|
|
397
522
|
tooltip: "音频",
|
|
398
523
|
onAction: () => n()
|
|
399
524
|
});
|
|
400
525
|
}
|
|
401
|
-
if ((
|
|
526
|
+
if ((d = c == null ? void 0 : c.value) != null && d.enable) {
|
|
402
527
|
const n = () => {
|
|
403
|
-
|
|
528
|
+
_.value.dialogVisible = !0;
|
|
404
529
|
};
|
|
405
|
-
|
|
530
|
+
o.ui.registry.addMenuItem("localVideo", {
|
|
406
531
|
text: "视频",
|
|
407
532
|
icon: "embed",
|
|
408
533
|
onAction: () => n()
|
|
409
|
-
}),
|
|
534
|
+
}), o.ui.registry.addButton("localVideo", {
|
|
410
535
|
icon: "embed",
|
|
411
536
|
tooltip: "视频",
|
|
412
537
|
onAction: () => n()
|
|
413
538
|
});
|
|
414
539
|
}
|
|
415
540
|
}
|
|
416
|
-
},
|
|
541
|
+
}, a = C(
|
|
417
542
|
[
|
|
418
543
|
m.options,
|
|
419
|
-
|
|
544
|
+
P.options,
|
|
420
545
|
e
|
|
421
546
|
],
|
|
422
547
|
{
|
|
423
|
-
mergeFunction: (
|
|
424
|
-
|
|
548
|
+
mergeFunction: (o, l) => (...i) => {
|
|
549
|
+
o(...i), l(...i);
|
|
425
550
|
},
|
|
426
551
|
type: Object
|
|
427
552
|
}
|
|
428
553
|
);
|
|
429
|
-
|
|
430
|
-
var
|
|
431
|
-
|
|
432
|
-
if (
|
|
433
|
-
|
|
554
|
+
ae.init(a).then(([o]) => {
|
|
555
|
+
var l;
|
|
556
|
+
o && (o.customProps = { ...m }, o.on("input", () => {
|
|
557
|
+
if (S.value) {
|
|
558
|
+
S.value = !1;
|
|
434
559
|
return;
|
|
435
560
|
}
|
|
436
|
-
|
|
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);
|
|
561
|
+
M.value = !0, z("input", o.getContent());
|
|
562
|
+
}), o.on("paste", (i) => {
|
|
563
|
+
X(i);
|
|
564
|
+
}), o.on("drop", (i) => {
|
|
565
|
+
J(i);
|
|
566
|
+
}), (l = m.initComplete) == null || l.call(m, { editorIns: o }), h.value = o);
|
|
447
567
|
});
|
|
448
|
-
}),
|
|
449
|
-
var e,
|
|
450
|
-
(e =
|
|
568
|
+
}), Te(() => {
|
|
569
|
+
var e, a, t, o;
|
|
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();
|
|
451
571
|
});
|
|
452
|
-
const
|
|
453
|
-
var
|
|
454
|
-
const e = { ...
|
|
455
|
-
return ((
|
|
456
|
-
},
|
|
457
|
-
var
|
|
458
|
-
const e = { ...
|
|
459
|
-
return ((
|
|
460
|
-
},
|
|
461
|
-
var
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
},
|
|
465
|
-
var
|
|
466
|
-
const
|
|
467
|
-
if (!((
|
|
468
|
-
|
|
572
|
+
const me = () => {
|
|
573
|
+
var a, t;
|
|
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 = () => {
|
|
577
|
+
var a, t;
|
|
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) => {
|
|
581
|
+
var l, 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;
|
|
586
|
+
const l = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
|
|
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();
|
|
469
589
|
return;
|
|
470
590
|
}
|
|
471
|
-
if (e.size > (((
|
|
472
|
-
|
|
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();
|
|
473
593
|
return;
|
|
474
594
|
}
|
|
475
|
-
|
|
476
|
-
}),
|
|
477
|
-
|
|
478
|
-
},
|
|
479
|
-
|
|
480
|
-
},
|
|
481
|
-
var
|
|
482
|
-
const e = { ...
|
|
483
|
-
return ((
|
|
484
|
-
},
|
|
485
|
-
var
|
|
486
|
-
const e = { ...
|
|
487
|
-
return ((
|
|
488
|
-
},
|
|
489
|
-
var
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
},
|
|
493
|
-
var
|
|
494
|
-
const
|
|
495
|
-
if (!((
|
|
496
|
-
|
|
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 = () => {
|
|
601
|
+
var a, t;
|
|
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 = () => {
|
|
605
|
+
var a, t;
|
|
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) => {
|
|
609
|
+
var l, 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;
|
|
614
|
+
const l = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
|
|
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();
|
|
497
617
|
return;
|
|
498
618
|
}
|
|
499
|
-
if (e.size > (((
|
|
500
|
-
|
|
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();
|
|
501
621
|
return;
|
|
502
622
|
}
|
|
503
|
-
|
|
504
|
-
}),
|
|
505
|
-
|
|
506
|
-
},
|
|
507
|
-
|
|
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;
|
|
508
628
|
};
|
|
509
|
-
return
|
|
510
|
-
var e,
|
|
511
|
-
(
|
|
512
|
-
}, { immediate: !0 }),
|
|
513
|
-
() => [m.value,
|
|
629
|
+
return k(() => [m.disabled, h.value], () => {
|
|
630
|
+
var e, a;
|
|
631
|
+
(a = (e = h.value) == null ? void 0 : e.mode) == null || a.set(m.disabled ? "readonly" : "design");
|
|
632
|
+
}, { immediate: !0 }), k(
|
|
633
|
+
() => [m.value, h.value],
|
|
514
634
|
() => {
|
|
515
635
|
var e;
|
|
516
|
-
if (
|
|
517
|
-
|
|
636
|
+
if (M.value) {
|
|
637
|
+
M.value = !1;
|
|
518
638
|
return;
|
|
519
639
|
}
|
|
520
|
-
|
|
640
|
+
S.value = !0, (e = h.value) == null || e.setContent(m.value ? m.value : "");
|
|
521
641
|
},
|
|
522
642
|
{ immediate: !0 }
|
|
523
|
-
), { __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 };
|
|
524
644
|
}
|
|
525
645
|
});
|
|
526
646
|
export {
|
|
527
|
-
|
|
647
|
+
va as default
|
|
528
648
|
};
|
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.47",
|
|
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.13"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"vue": "^2.7.0",
|