@keyblade/tinymce-editor-vue2 0.0.3 → 0.0.5-alpha.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/es/editor.vue.d.ts +4 -4
- package/es/editor.vue2.js +38 -39
- package/package.json +3 -10
package/es/editor.vue.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Editor, RawEditorOptions } from 'tinymce';
|
|
2
2
|
|
|
3
|
-
declare const _default: import('vue
|
|
3
|
+
declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
4
4
|
/** vue2 v-model */
|
|
5
5
|
value?: string | undefined;
|
|
6
6
|
/** vue3 v-model */
|
|
@@ -51,12 +51,12 @@ declare const _default: import('vue-demi').DefineComponent<__VLS_WithDefaults<__
|
|
|
51
51
|
imageMaxHeight: number;
|
|
52
52
|
options: () => {};
|
|
53
53
|
}>, {
|
|
54
|
-
insRef: import('vue
|
|
55
|
-
editorRef: import('vue
|
|
54
|
+
insRef: import('vue').Ref<HTMLElement | undefined>;
|
|
55
|
+
editorRef: import('vue').Ref<Editor | undefined>;
|
|
56
56
|
}, {}, {}, {}, import('vue/types/v3-component-options').ComponentOptionsMixin, import('vue/types/v3-component-options').ComponentOptionsMixin, {
|
|
57
57
|
input: (value: string) => void;
|
|
58
58
|
"update:modelValue": (value: string) => void;
|
|
59
|
-
}, string, Readonly<import('vue
|
|
59
|
+
}, string, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
60
60
|
/** vue2 v-model */
|
|
61
61
|
value?: string | undefined;
|
|
62
62
|
/** vue3 v-model */
|
package/es/editor.vue2.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { defineComponent as F } from "vue";
|
|
2
|
-
import { ref as y, computed as W, onMounted as N, onUnmounted as j, watch as L } from "vue-demi";
|
|
1
|
+
import { defineComponent as F, ref as y, computed as W, onMounted as N, onUnmounted as j, watch as L } from "vue";
|
|
3
2
|
import q from "compressorjs";
|
|
4
3
|
import { conclude as _ } from "vue-global-config";
|
|
5
4
|
import E from "tinymce";
|
|
@@ -33,7 +32,7 @@ import "tinymce/plugins/visualblocks";
|
|
|
33
32
|
import "tinymce/plugins/visualchars";
|
|
34
33
|
import "tinymce/plugins/wordcount";
|
|
35
34
|
import { globalProps as d } from "./index.js";
|
|
36
|
-
const
|
|
35
|
+
const ke = /* @__PURE__ */ F({
|
|
37
36
|
__name: "editor",
|
|
38
37
|
props: {
|
|
39
38
|
value: { default: "" },
|
|
@@ -53,23 +52,23 @@ const ze = /* @__PURE__ */ F({
|
|
|
53
52
|
},
|
|
54
53
|
emits: ["input", "update:modelValue"],
|
|
55
54
|
setup(O, { expose: R, emit: b }) {
|
|
56
|
-
const
|
|
55
|
+
const i = O;
|
|
57
56
|
G();
|
|
58
57
|
const M = y(), m = y(), g = y(!1), f = y(!1);
|
|
59
58
|
async function A(n) {
|
|
60
59
|
var o, e;
|
|
61
60
|
const s = n.getElementsByTagName("img");
|
|
62
|
-
for (let
|
|
63
|
-
const t =
|
|
61
|
+
for (let a of s) {
|
|
62
|
+
const t = a.src;
|
|
64
63
|
if (t.startsWith("http://") || t.startsWith("https://")) {
|
|
65
64
|
const r = await C(t);
|
|
66
|
-
if (r.width <
|
|
67
|
-
(o =
|
|
65
|
+
if (r.width < i.imageMinWidth && r.height < i.imageMinHeight || r.width > i.imageMaxWidth && r.height > i.imageMaxHeight) {
|
|
66
|
+
(o = a == null ? void 0 : a.remove) == null || o.call(a);
|
|
68
67
|
return;
|
|
69
68
|
}
|
|
70
69
|
const w = t.split("."), S = w[w.length - 1].toLowerCase();
|
|
71
|
-
if (!
|
|
72
|
-
(e =
|
|
70
|
+
if (!i.imageAllowedType.includes(S)) {
|
|
71
|
+
(e = a == null ? void 0 : a.remove) == null || e.call(a);
|
|
73
72
|
return;
|
|
74
73
|
}
|
|
75
74
|
}
|
|
@@ -77,10 +76,10 @@ const ze = /* @__PURE__ */ F({
|
|
|
77
76
|
}
|
|
78
77
|
const H = (n) => {
|
|
79
78
|
const s = n.split(","), o = s[0].match(/:(.*?);/)[1], e = atob(s[1]);
|
|
80
|
-
let
|
|
81
|
-
const t = new Uint8Array(
|
|
82
|
-
for (;
|
|
83
|
-
t[
|
|
79
|
+
let a = e.length;
|
|
80
|
+
const t = new Uint8Array(a);
|
|
81
|
+
for (; a--; )
|
|
82
|
+
t[a] = e.charCodeAt(a);
|
|
84
83
|
return new Blob([t], { type: o });
|
|
85
84
|
};
|
|
86
85
|
function C(n) {
|
|
@@ -105,15 +104,15 @@ const ze = /* @__PURE__ */ F({
|
|
|
105
104
|
});
|
|
106
105
|
}
|
|
107
106
|
const h = W(
|
|
108
|
-
() => _([
|
|
107
|
+
() => _([i.paste_preprocess, d.paste_preprocess], {
|
|
109
108
|
type: Function
|
|
110
109
|
})
|
|
111
110
|
), v = W(
|
|
112
|
-
() => _([
|
|
111
|
+
() => _([i.paste_postprocess, d.paste_postprocess], {
|
|
113
112
|
type: Function
|
|
114
113
|
})
|
|
115
114
|
), c = W(
|
|
116
|
-
() => _([
|
|
115
|
+
() => _([i.imageUploadHandle, d.imageUploadHandle], {
|
|
117
116
|
type: Function
|
|
118
117
|
})
|
|
119
118
|
);
|
|
@@ -189,28 +188,28 @@ const ze = /* @__PURE__ */ F({
|
|
|
189
188
|
paste_data_images: !0,
|
|
190
189
|
// 粘贴前处理
|
|
191
190
|
paste_preprocess(o, e) {
|
|
192
|
-
var
|
|
193
|
-
e.content = e.content.replace(/<video[^>]*(?:\/>|>[\s\S]*?<\/video>)/g, ""), e.content = e.content.replace(/<audio[^>]*(?:\/>|>[\s\S]*?<\/audio>)/g, ""), e.content = e.content.replace(/<nav/g, "<div").replace(/<\/nav>/g, "</div>"), e.content = e.content.replace(/<header/g, "<div").replace(/<\/header>/g, "</div>"), e.content = e.content.replace(/<footer/g, "<div").replace(/<\/footer>/g, "</div>"), e.content = e.content.replace(/<aside/g, "<div").replace(/<\/aside>/g, "</div>"), e.content = e.content.replace(/<section/g, "<div").replace(/<\/section>/g, "</div>"), e.content = e.content.replace(/<main/g, "<div").replace(/<\/main>/g, "</div>"), e.content = e.content.replace(/<article/g, "<div").replace(/<\/article>/g, "</div>"), e.content = e.content.replace(/<details/g, "<div").replace(/<\/details>/g, "</div>"), (
|
|
191
|
+
var a;
|
|
192
|
+
e.content = e.content.replace(/<video[^>]*(?:\/>|>[\s\S]*?<\/video>)/g, ""), e.content = e.content.replace(/<audio[^>]*(?:\/>|>[\s\S]*?<\/audio>)/g, ""), e.content = e.content.replace(/<nav/g, "<div").replace(/<\/nav>/g, "</div>"), e.content = e.content.replace(/<header/g, "<div").replace(/<\/header>/g, "</div>"), e.content = e.content.replace(/<footer/g, "<div").replace(/<\/footer>/g, "</div>"), e.content = e.content.replace(/<aside/g, "<div").replace(/<\/aside>/g, "</div>"), e.content = e.content.replace(/<section/g, "<div").replace(/<\/section>/g, "</div>"), e.content = e.content.replace(/<main/g, "<div").replace(/<\/main>/g, "</div>"), e.content = e.content.replace(/<article/g, "<div").replace(/<\/article>/g, "</div>"), e.content = e.content.replace(/<details/g, "<div").replace(/<\/details>/g, "</div>"), (a = h.value) == null || a.call(h, o, e);
|
|
194
193
|
},
|
|
195
194
|
// 粘贴后处理(处理异步操作)
|
|
196
195
|
paste_postprocess(o, e) {
|
|
197
196
|
var t;
|
|
198
|
-
const
|
|
199
|
-
A(
|
|
197
|
+
const a = e.node;
|
|
198
|
+
A(a), (t = v.value) == null || t.call(v, o, e);
|
|
200
199
|
},
|
|
201
200
|
images_upload_handler(o) {
|
|
202
|
-
return new Promise(async (e,
|
|
201
|
+
return new Promise(async (e, a) => {
|
|
203
202
|
var x, V, B;
|
|
204
203
|
const t = (V = (x = d.message) == null ? void 0 : x.loading) == null ? void 0 : V.call(x);
|
|
205
204
|
let r = o.blob();
|
|
206
205
|
const w = o.base64(), S = o.filename(), P = r.name.split("."), $ = P[P.length - 1].toLowerCase();
|
|
207
|
-
if (r.size >
|
|
208
|
-
return t == null || t.close(),
|
|
209
|
-
if (!
|
|
210
|
-
return t == null || t.close(),
|
|
206
|
+
if (r.size > i.imageMaxSize * 1024 * 1024)
|
|
207
|
+
return t == null || t.close(), a({ message: `请上传大小不超过${i.imageMaxSize}M的图片`, remove: !0 });
|
|
208
|
+
if (!i.imageAllowedMineType.includes(r.type))
|
|
209
|
+
return t == null || t.close(), a({ message: `请上传格式为${i.imageAllowedType.map((u) => u.toUpperCase()).join("、")}的图片`, remove: !0 });
|
|
211
210
|
const U = "data:" + r.type + ";base64," + w, p = await C(U);
|
|
212
|
-
if (p.width <
|
|
213
|
-
return t == null || t.close(),
|
|
211
|
+
if (p.width < i.imageMinWidth && p.height < i.imageMinHeight || p.width > i.imageMaxWidth && p.height > i.imageMaxHeight)
|
|
212
|
+
return t == null || t.close(), a({ message: `请上传像素不低于${i.imageMinWidth}*${i.imageMinHeight}且像素不高于${i.imageMaxWidth}*${i.imageMaxHeight}的图片`, remove: !0 });
|
|
214
213
|
const l = {};
|
|
215
214
|
["image/heif", "image/heic", "image/webp"].includes($) && (l.convertTypes = [r.type], l.convertSize = 0);
|
|
216
215
|
const k = 5 * 1024 * 1024;
|
|
@@ -219,25 +218,25 @@ const ze = /* @__PURE__ */ F({
|
|
|
219
218
|
if (u.success)
|
|
220
219
|
r = u.file;
|
|
221
220
|
else
|
|
222
|
-
return t == null || t.close(),
|
|
221
|
+
return t == null || t.close(), a({ message: u.error, remove: !0 });
|
|
223
222
|
}
|
|
224
223
|
if (!c.value)
|
|
225
|
-
return t == null || t.close(),
|
|
224
|
+
return t == null || t.close(), a({ message: "缺少图片上传配置", remove: !0 });
|
|
226
225
|
const z = await ((B = c.value) == null ? void 0 : B.call(c, r, S));
|
|
227
226
|
if (!z.success)
|
|
228
|
-
return t == null || t.close(),
|
|
227
|
+
return t == null || t.close(), a({ message: z.errorMessage, remove: !0 });
|
|
229
228
|
t == null || t.close(), e(z.url);
|
|
230
229
|
});
|
|
231
230
|
}
|
|
232
231
|
}, s = _(
|
|
233
232
|
[
|
|
234
|
-
|
|
233
|
+
i.options,
|
|
235
234
|
d.tinymceOptions,
|
|
236
235
|
n
|
|
237
236
|
],
|
|
238
237
|
{
|
|
239
|
-
mergeFunction: (o, e) => (...
|
|
240
|
-
o(...
|
|
238
|
+
mergeFunction: (o, e) => (...a) => {
|
|
239
|
+
o(...a), e(...a);
|
|
241
240
|
},
|
|
242
241
|
type: Object
|
|
243
242
|
}
|
|
@@ -250,28 +249,28 @@ const ze = /* @__PURE__ */ F({
|
|
|
250
249
|
return;
|
|
251
250
|
}
|
|
252
251
|
g.value = !0, b("input", o.getContent()), b("update:modelValue", o.getContent());
|
|
253
|
-
}), m.value = o, (e =
|
|
252
|
+
}), m.value = o, (e = i.initComplete) == null || e.call(i);
|
|
254
253
|
});
|
|
255
254
|
}), j(() => {
|
|
256
255
|
var n;
|
|
257
256
|
(n = m.value) == null || n.destroy();
|
|
258
257
|
}), L(
|
|
259
|
-
() => [
|
|
258
|
+
() => [i.value, i.modelValue, m.value],
|
|
260
259
|
() => {
|
|
261
260
|
var n;
|
|
262
261
|
if (g.value) {
|
|
263
262
|
g.value = !1;
|
|
264
263
|
return;
|
|
265
264
|
}
|
|
266
|
-
f.value = !0, (n = m.value) == null || n.setContent(
|
|
265
|
+
f.value = !0, (n = m.value) == null || n.setContent(i.value ? i.value : i.modelValue ? i.modelValue : "");
|
|
267
266
|
},
|
|
268
267
|
{ immediate: !0 }
|
|
269
268
|
), R({
|
|
270
269
|
insRef: M,
|
|
271
270
|
editorRef: m
|
|
272
|
-
}), { __sfc: !0, insRef: M, editorRef: m, preventSettingContent: g, preventUpdatingModelValue: f, props:
|
|
271
|
+
}), { __sfc: !0, insRef: M, editorRef: m, preventSettingContent: g, preventUpdatingModelValue: f, props: i, emits: b, processPastedImage: A, dataURLtoBlob: H, getImagePixel: C, compressorImage: T, paste_preprocess: h, paste_postprocess: v, imageUploadHandle: c };
|
|
273
272
|
}
|
|
274
273
|
});
|
|
275
274
|
export {
|
|
276
|
-
|
|
275
|
+
ke as default
|
|
277
276
|
};
|
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.
|
|
5
|
+
"version": "0.0.5-alpha.01",
|
|
6
6
|
"private": false,
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "es/index.js",
|
|
@@ -22,18 +22,11 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"compressorjs": "^1.2.1",
|
|
24
24
|
"vue-global-config": "^0.6.1",
|
|
25
|
-
"tinymce": "^7.1.0"
|
|
26
|
-
"vue-demi": "^0.14.7"
|
|
25
|
+
"tinymce": "^7.1.0"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {},
|
|
29
28
|
"peerDependencies": {
|
|
30
|
-
"
|
|
31
|
-
"vue": "^2.0.0 || >=3.3.4"
|
|
32
|
-
},
|
|
33
|
-
"peerDependenciesMeta": {
|
|
34
|
-
"@vue/composition-api": {
|
|
35
|
-
"optional": true
|
|
36
|
-
}
|
|
29
|
+
"vue": "^2.7.0"
|
|
37
30
|
},
|
|
38
31
|
"scripts": {
|
|
39
32
|
"build": "vite build",
|