@keyblade/tinymce-editor-vue2 0.0.9-alpha.1 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/editor.vue2.js +24 -24
- package/package.json +1 -1
package/es/editor.vue2.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as N, ref as
|
|
1
|
+
import { defineComponent as N, ref as w, computed as k, onMounted as j, onUnmounted as L, watch as O } from "vue";
|
|
2
2
|
import q from "compressorjs";
|
|
3
3
|
import { conclude as _ } from "vue-global-config";
|
|
4
4
|
import R from "tinymce";
|
|
@@ -56,8 +56,8 @@ const ze = /* @__PURE__ */ N({
|
|
|
56
56
|
setup($, { emit: b }) {
|
|
57
57
|
const t = $;
|
|
58
58
|
R.addI18n("zh_CN", E);
|
|
59
|
-
const P =
|
|
60
|
-
async function
|
|
59
|
+
const P = w(), l = w(), g = w(!1), f = w(!1);
|
|
60
|
+
async function T(n) {
|
|
61
61
|
var a, e;
|
|
62
62
|
const s = n.getElementsByTagName("img");
|
|
63
63
|
for (let o of s) {
|
|
@@ -68,7 +68,7 @@ const ze = /* @__PURE__ */ N({
|
|
|
68
68
|
(a = o == null ? void 0 : o.remove) == null || a.call(o);
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
const
|
|
71
|
+
const y = i.split("."), C = y[y.length - 1].toLowerCase();
|
|
72
72
|
if (!t.imageAllowedType.includes(C)) {
|
|
73
73
|
(e = o == null ? void 0 : o.remove) == null || e.call(o);
|
|
74
74
|
return;
|
|
@@ -76,7 +76,7 @@ const ze = /* @__PURE__ */ N({
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
const
|
|
79
|
+
const W = (n) => {
|
|
80
80
|
const s = n.split(","), a = s[0].match(/:(.*?);/)[1], e = atob(s[1]);
|
|
81
81
|
let o = e.length;
|
|
82
82
|
const i = new Uint8Array(o);
|
|
@@ -92,7 +92,7 @@ const ze = /* @__PURE__ */ N({
|
|
|
92
92
|
}, a.src = n;
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function A(n, s) {
|
|
96
96
|
return new Promise((a) => {
|
|
97
97
|
new q(n, {
|
|
98
98
|
...s,
|
|
@@ -113,12 +113,12 @@ const ze = /* @__PURE__ */ N({
|
|
|
113
113
|
() => _([t.paste_postprocess, d.paste_postprocess], {
|
|
114
114
|
type: Function
|
|
115
115
|
})
|
|
116
|
-
),
|
|
116
|
+
), p = k(
|
|
117
117
|
() => _([t.imageUploadHandle, d.imageUploadHandle], {
|
|
118
118
|
type: Function
|
|
119
119
|
})
|
|
120
120
|
);
|
|
121
|
-
return
|
|
121
|
+
return j(() => {
|
|
122
122
|
const n = {
|
|
123
123
|
// 设置语言
|
|
124
124
|
language: "zh_CN",
|
|
@@ -196,34 +196,34 @@ const ze = /* @__PURE__ */ N({
|
|
|
196
196
|
paste_postprocess(a, e) {
|
|
197
197
|
var i;
|
|
198
198
|
const o = e.node;
|
|
199
|
-
|
|
199
|
+
T(o), (i = v.value) == null || i.call(v, a, e);
|
|
200
200
|
},
|
|
201
201
|
images_upload_handler(a) {
|
|
202
202
|
return new Promise(async (e, o) => {
|
|
203
|
-
var
|
|
204
|
-
const i = (
|
|
203
|
+
var x, U, V, B;
|
|
204
|
+
const i = (U = (x = d.message) == null ? void 0 : x.loading) == null ? void 0 : U.call(x);
|
|
205
205
|
let r = a.blob();
|
|
206
|
-
const
|
|
206
|
+
const y = a.base64(), C = a.filename(), F = r.type;
|
|
207
207
|
if (r.size > t.imageMaxSize * 1024 * 1024)
|
|
208
208
|
return i == null || i.close(), o({ message: `请上传大小不超过${t.imageMaxSize}M的图片`, remove: !0 });
|
|
209
209
|
if (!t.imageAllowedMineType.includes(r.type))
|
|
210
|
-
return i == null || i.close(), o({ message: `请上传格式为${t.imageAllowedType.map((
|
|
211
|
-
const
|
|
212
|
-
if (
|
|
210
|
+
return i == null || i.close(), o({ message: `请上传格式为${t.imageAllowedType.map((c) => c.toUpperCase()).join("、")}的图片`, remove: !0 });
|
|
211
|
+
const H = "data:" + r.type + ";base64," + y, u = await M(H);
|
|
212
|
+
if (u.width < t.imageMinWidth && u.height < t.imageMinHeight || u.width > t.imageMaxWidth && u.height > t.imageMaxHeight)
|
|
213
213
|
return i == null || i.close(), o({ message: `请上传像素不低于${t.imageMinWidth}*${t.imageMinHeight}且像素不高于${t.imageMaxWidth}*${t.imageMaxHeight}的图片`, remove: !0 });
|
|
214
214
|
const m = {};
|
|
215
215
|
["image/heif", "image/heic", "image/webp"].includes(F) && (m.convertTypes = [r.type], m.convertSize = 0);
|
|
216
216
|
const z = 5 * 1024 * 1024;
|
|
217
|
-
if (r.size > z && (m.convertTypes = [r.type], m.convertSize = z, m.maxWidth =
|
|
218
|
-
const
|
|
219
|
-
if (
|
|
220
|
-
r =
|
|
217
|
+
if (r.size > z && (m.convertTypes = [r.type], m.convertSize = z, m.maxWidth = u.width * (z / r.size)), Object.keys(m).length > 0) {
|
|
218
|
+
const c = await A(W(H), m);
|
|
219
|
+
if (c.success)
|
|
220
|
+
r = c.file;
|
|
221
221
|
else
|
|
222
|
-
return i == null || i.close(), o({ message:
|
|
222
|
+
return i == null || i.close(), o({ message: (V = c == null ? void 0 : c.error) == null ? void 0 : V.message, remove: !0 });
|
|
223
223
|
}
|
|
224
|
-
if (!
|
|
224
|
+
if (!p.value)
|
|
225
225
|
return i == null || i.close(), o({ message: "缺少图片上传配置", remove: !0 });
|
|
226
|
-
const S = await ((B =
|
|
226
|
+
const S = await ((B = p.value) == null ? void 0 : B.call(p, r, C, { extParameters: t.extParameters }));
|
|
227
227
|
if (!S.success)
|
|
228
228
|
return i == null || i.close(), o({ message: S.errorMessage, remove: !0 });
|
|
229
229
|
i == null || i.close(), e(S.url);
|
|
@@ -252,7 +252,7 @@ const ze = /* @__PURE__ */ N({
|
|
|
252
252
|
g.value = !0, b("input", a.getContent()), b("update:modelValue", a.getContent());
|
|
253
253
|
}), (e = t.initComplete) == null || e.call(t, { editorIns: a }), l.value = a);
|
|
254
254
|
});
|
|
255
|
-
}),
|
|
255
|
+
}), L(() => {
|
|
256
256
|
var n;
|
|
257
257
|
(n = l.value) == null || n.destroy();
|
|
258
258
|
}), O(() => [t.disabled, l.value], () => {
|
|
@@ -269,7 +269,7 @@ const ze = /* @__PURE__ */ N({
|
|
|
269
269
|
f.value = !0, (n = l.value) == null || n.setContent(t.value ? t.value : t.modelValue ? t.modelValue : "");
|
|
270
270
|
},
|
|
271
271
|
{ immediate: !0 }
|
|
272
|
-
), { __sfc: !0, insRef: P, editorRef: l, preventSettingContent: g, preventUpdatingModelValue: f, props: t, emits: b, processPastedImage:
|
|
272
|
+
), { __sfc: !0, insRef: P, editorRef: l, preventSettingContent: g, preventUpdatingModelValue: f, props: t, emits: b, processPastedImage: T, dataURLtoBlob: W, getImagePixel: M, compressorImage: A, paste_preprocess: h, paste_postprocess: v, imageUploadHandle: p };
|
|
273
273
|
}
|
|
274
274
|
});
|
|
275
275
|
export {
|
package/package.json
CHANGED