@keyblade/tinymce-editor-vue2 0.0.12-alpha.14 → 0.0.12-alpha.15
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 +36 -2
- package/es/editor.vue.js +2 -2
- package/es/editor.vue2.js +193 -165
- package/es/index.js +10 -9
- package/es/style.css +1 -1
- package/es/util.d.ts +4 -0
- package/es/util.js +109 -72
- package/package.json +2 -1
- package/src/index.ts +2 -1
package/README.md
CHANGED
|
@@ -99,14 +99,48 @@ onMounted(() => {
|
|
|
99
99
|
</script>
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
### 3
|
|
102
|
+
### 3.使用工具类(单独使用图片上传组件的,可使用以下工具类自行处理)
|
|
103
103
|
```typescript
|
|
104
|
-
import { oneTravelImageCheck, oneTravelImageCompressor } from '@keyblade/tinymce-editor-vue2'
|
|
104
|
+
import { oneTravelImageCheck, oneTravelImageCompressor, interceptImgPondBeforeAddFile } from '@keyblade/tinymce-editor-vue2'
|
|
105
105
|
|
|
106
106
|
// oneTravelImageCheck: 一码游图片检测工具
|
|
107
107
|
// oneTravelImageCompressor: 一码游图片压缩工具
|
|
108
|
+
// interceptImgPondBeforeAddFile 统一处理拦截ImgPond方法,内部包含heif格式转换
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### interceptImgPondBeforeAddFile
|
|
112
|
+
如果项目中单独有使用ImgPond组件,需要对内部方法进行拦截,否则上传 heif 格式的图片不能正常显示,以下是示例,使用组合式 Api 语法,选项式 Api 请自行替换
|
|
113
|
+
|
|
114
|
+
1.绑定 ref 对象
|
|
115
|
+
```html
|
|
116
|
+
<ImgPond
|
|
117
|
+
ref="audioImageImgPondRef"
|
|
118
|
+
v-model="uploadAudio.formData.cover"
|
|
119
|
+
>
|
|
120
|
+
</ImgPond>
|
|
108
121
|
```
|
|
109
122
|
|
|
123
|
+
2.拦截
|
|
124
|
+
```typescript
|
|
125
|
+
const uploadImageImgPondRef = ref()
|
|
126
|
+
watch(() => uploadImageImgPondRef.value, () => {
|
|
127
|
+
if (uploadImageImgPondRef.value) {
|
|
128
|
+
let loadingIns: ElLoadingComponent
|
|
129
|
+
interceptImgPondBeforeAddFile(uploadImageImgPondRef.value, {
|
|
130
|
+
onStart: () => {
|
|
131
|
+
loadingIns = Loading.service({text: '加载中...', fullscreen: true, customClass: 'tinymce-loading' })
|
|
132
|
+
},
|
|
133
|
+
onEnd: () => {
|
|
134
|
+
loadingIns?.close()
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
}, { immediate: true })
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
### 3.使用工具类(单独使用图片上传组件的,可使用这两个工具类自行处理)
|
|
143
|
+
|
|
110
144
|
```typescript
|
|
111
145
|
export async function oneTravelImageCheck(data: File | Blob, options?: {
|
|
112
146
|
imageMaxSize?: number;
|
package/es/editor.vue.js
CHANGED
|
@@ -4,11 +4,11 @@ import i from "./_virtual/_plugin-vue2_normalizer.js";
|
|
|
4
4
|
var d = function() {
|
|
5
5
|
var l;
|
|
6
6
|
var e = this, a = e._self._c, o = e._self._setupProxy;
|
|
7
|
-
return a("div", { staticClass: "tinymce-editor" }, [a("textarea", { ref: "insRef" }), e._v(" "), a("el-dialog", { staticClass: "tinymce-editor-dialog tinymce-editor-upload-image-dialog", attrs: { visible: o.uploadImage.dialogVisible, title: "插入图片", "append-to-body": !0, "close-on-click-modal": !1, "destroy-on-close": "" }, on: { close: o.onUploadImageClose } }, [a("el-form", { ref: "uploadImageFormRef", staticClass: "uploadImageForm", attrs: { model: o.uploadImage.formData } }, [a("el-form-item", { attrs: { prop: "images", rules: { required: !0, message: "必填项" } } }, [a(o.ImgPond, e._b({ attrs: { valueType: "array", accept: o.imgPondAccept, size: e.imageMaxSize, count: e.imageUploadMaxCount, upload: o.onImageUploadUpload }, model: { value: o.uploadImage.formData.images, callback: function(t) {
|
|
7
|
+
return a("div", { staticClass: "tinymce-editor" }, [a("textarea", { ref: "insRef" }), e._v(" "), a("el-dialog", { staticClass: "tinymce-editor-dialog tinymce-editor-upload-image-dialog", attrs: { visible: o.uploadImage.dialogVisible, title: "插入图片", "append-to-body": !0, "close-on-click-modal": !1, "destroy-on-close": "" }, on: { close: o.onUploadImageClose } }, [a("el-form", { ref: "uploadImageFormRef", staticClass: "uploadImageForm", attrs: { model: o.uploadImage.formData } }, [a("el-form-item", { attrs: { prop: "images", rules: { required: !0, message: "必填项" } } }, [a(o.ImgPond, e._b({ ref: "uploadImageImgPondRef", attrs: { valueType: "array", accept: o.imgPondAccept, size: e.imageMaxSize, count: e.imageUploadMaxCount, upload: o.onImageUploadUpload }, model: { value: o.uploadImage.formData.images, callback: function(t) {
|
|
8
8
|
e.$set(o.uploadImage.formData, "images", t);
|
|
9
9
|
}, expression: "uploadImage.formData.images" } }, "ImgPond", o.mergeImgPondOptions, !1))], 1), a("div", { staticClass: "tips" }, [a("span", { staticStyle: { "font-size": "15px", "font-weight": "bold" } }, [e._v("注意:")]), a("span", [e._v("1. 单次最多可同时选择" + e._s(e.imageUploadMaxCount) + "张图片")]), a("span", [e._v("2. 仅支持" + e._s(e.imageAllowedType.map((t) => t.toUpperCase()).join("、")) + "格式")]), a("span", [e._v("3. 单张图片大小不可超过" + e._s(e.imageMaxSize) + "M")]), a("span", [e._v("4. 像素不低于" + e._s(e.imageMinWidth) + "*" + e._s(e.imageMinHeight) + "且像素不高于" + e._s(e.imageMaxWidth) + "*" + e._s(e.imageMaxHeight))])])], 1), a("div", { attrs: { slot: "footer" }, slot: "footer" }, [a("el-button", { on: { click: o.onUploadImageClose } }, [e._v("取消")]), a("el-button", { attrs: { type: "primary" }, on: { click: o.onUploadImageConfirm } }, [e._v("确定")])], 1)], 1), a("el-dialog", { staticClass: "tinymce-editor-dialog tinymce-editor-upload-audio-dialog", attrs: { visible: o.uploadAudio.dialogVisible, title: "插入音频", "append-to-body": !0, "close-on-click-modal": !1, "destroy-on-close": "" }, on: { close: o.onUploadAudioClose } }, [a("el-form", { ref: "uploadAudioFormRef", staticClass: "uploadAudioForm", attrs: { model: o.uploadAudio.formData, "label-width": "auto" } }, [a("el-form-item", { attrs: { label: "名称", prop: "name", rules: { required: !0, message: "必填项" } } }, [a("el-input", { attrs: { maxlength: "14", "show-word-limit": "", placeholder: "请输入" }, model: { value: o.uploadAudio.formData.name, callback: function(t) {
|
|
10
10
|
e.$set(o.uploadAudio.formData, "name", t);
|
|
11
|
-
}, expression: "uploadAudio.formData.name" } })], 1), a("el-form-item", { attrs: { label: "封面", prop: "cover", rules: { required: !0, message: "必填项" } } }, [a(o.ImgPond, e._b({ attrs: { valueType: "array", size: e.imageMaxSize, accept: o.imgPondAccept, count: 1, upload: o.onImageUploadUpload }, model: { value: o.uploadAudio.formData.cover, callback: function(t) {
|
|
11
|
+
}, expression: "uploadAudio.formData.name" } })], 1), a("el-form-item", { attrs: { label: "封面", prop: "cover", rules: { required: !0, message: "必填项" } } }, [a(o.ImgPond, e._b({ ref: "audioImageImgPondRef", attrs: { valueType: "array", size: e.imageMaxSize, accept: o.imgPondAccept, count: 1, upload: o.onImageUploadUpload }, model: { value: o.uploadAudio.formData.cover, callback: function(t) {
|
|
12
12
|
e.$set(o.uploadAudio.formData, "cover", t);
|
|
13
13
|
}, expression: "uploadAudio.formData.cover" } }, "ImgPond", o.mergeImgPondOptions, !1))], 1), a("el-form-item", { attrs: { label: "音频", prop: "file", rules: { required: !0, message: "必填项" } } }, [a("el-upload", { class: ["upload", { "upload-hide": o.uploadAudio.formData.file.length >= 1 }], attrs: { name: "file", "file-list": o.uploadAudio.formData.file, action: ((l = o.mergeAudioUploadOptions) == null ? void 0 : l.action) || "", data: o.getUploadAudioData(), accept: "audio/*", "list-type": "headTextContent", "before-upload": o.onUploadAudioBeforeUpload, headers: o.getUploadAudioHeaders(), "on-remove": o.onUploadAudioRemove, "on-success": o.onUploadAudioSuccess, "on-error": o.onUploadAudioError, limit: 1 } }, [a("el-button", { attrs: { size: "small", type: "primary" } }, [e._v("上传文件"), a("i", { staticClass: "el-icon-upload el-icon--right" })]), a("div", { staticClass: "el-upload__tip", attrs: { slot: "tip" }, slot: "tip" }, [e._v("支持音频格式:" + e._s(e.audioAllowedType.join("、")))])], 1)], 1)], 1), a("div", { attrs: { slot: "footer" }, slot: "footer" }, [a("el-button", { on: { click: o.onUploadAudioClose } }, [e._v("取消")]), a("el-button", { attrs: { type: "primary" }, on: { click: o.onUploadAudioConfirm } }, [e._v("确定")])], 1)], 1), a("el-dialog", { staticClass: "tinymce-editor-dialog tinymce-editor-upload-video-dialog", attrs: { visible: o.uploadVideo.dialogVisible, title: "插入视频", "append-to-body": !0, "close-on-click-modal": !1, "destroy-on-close": "" }, on: { close: o.onUploadVideoClose } }, [a("el-form", { ref: "uploadVideoFormRef", staticClass: "uploadVideoForm", attrs: { model: o.uploadVideo.formData, "label-width": "auto" } }, [a("el-form-item", { attrs: { label: "视频", prop: "file", rules: { required: !0, message: "必填项" } } }, [a("el-upload", { class: ["upload", { "upload-hide": o.uploadVideo.formData.file.length >= 1 }], attrs: { name: "file", "file-list": o.uploadVideo.formData.file, action: o.mergeVideoUploadOptions.action || "", data: o.getUploadVideoData(), accept: "video/*", "list-type": "headTextContent", "before-upload": o.onUploadVideoBeforeUpload, headers: o.getUploadVideoHeaders(), "on-remove": o.onUploadVideoRemove, "on-success": o.onUploadVideoSuccess, "on-error": o.onUploadVideoError, limit: 1 } }, [a("el-button", { attrs: { size: "small", type: "primary" } }, [e._v("上传文件"), a("i", { staticClass: "el-icon-upload el-icon--right" })]), a("div", { staticClass: "el-upload__tip", attrs: { slot: "tip" }, slot: "tip" }, [e._v("支持视频格式:" + e._s(e.videoAllowedType.join("、")))])], 1)], 1)], 1), a("div", { attrs: { slot: "footer" }, slot: "footer" }, [a("el-button", { on: { click: o.onUploadVideoClose } }, [e._v("取消")]), a("el-button", { attrs: { type: "primary" }, on: { click: o.onUploadVideoConfirm } }, [e._v("确定")])], 1)], 1)], 1);
|
|
14
14
|
}, s = [], r = /* @__PURE__ */ i(
|
package/es/editor.vue2.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { oneTravelImageCheck as
|
|
3
|
-
import
|
|
1
|
+
import { defineComponent as he, ref as d, watch as k, computed as M, onMounted as Me, onUnmounted as xe } from "vue";
|
|
2
|
+
import { interceptImgPondBeforeAddFile as G, oneTravelImageCheck as L, oneTravelImageCompressor as J, getImagePixel as ye } from "./util.js";
|
|
3
|
+
import be from "imgpond";
|
|
4
4
|
import { conclude as x } from "vue-global-config";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import K from "tinymce";
|
|
6
|
+
import _e from "./langs/zh_CN.js";
|
|
7
7
|
import "tinymce/skins/ui/oxide/skin";
|
|
8
8
|
import "tinymce/models/dom";
|
|
9
9
|
import "tinymce/themes/silver";
|
|
@@ -33,15 +33,15 @@ import "tinymce/plugins/visualblocks";
|
|
|
33
33
|
import "tinymce/plugins/visualchars";
|
|
34
34
|
import "tinymce/plugins/wordcount";
|
|
35
35
|
import { globalProps as y } from "./index.js";
|
|
36
|
-
import { Loading as
|
|
37
|
-
const
|
|
36
|
+
import { Loading as W, Message as h } from "element-ui";
|
|
37
|
+
const la = /* @__PURE__ */ he({
|
|
38
38
|
__name: "editor",
|
|
39
39
|
props: {
|
|
40
40
|
value: { default: "" },
|
|
41
41
|
modelValue: { default: "" },
|
|
42
42
|
disabled: { type: Boolean },
|
|
43
43
|
extParameters: null,
|
|
44
|
-
imageUploadMaxCount: { default:
|
|
44
|
+
imageUploadMaxCount: { default: 10 },
|
|
45
45
|
imageUploadTip: { default: "上传" },
|
|
46
46
|
imageMaxSize: { default: 30 },
|
|
47
47
|
imageAllowedType: { default: () => ["jpg", "jpeg", "png", "bmp", "heif", "gif", "webp"] },
|
|
@@ -66,29 +66,57 @@ const ia = /* @__PURE__ */ ce({
|
|
|
66
66
|
imgPondOptions: null
|
|
67
67
|
},
|
|
68
68
|
emits: ["input", "update:modelValue"],
|
|
69
|
-
setup(
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const
|
|
69
|
+
setup(Q, { emit: z }) {
|
|
70
|
+
const o = Q;
|
|
71
|
+
K.addI18n("zh_CN", _e);
|
|
72
|
+
const R = d(), u = d(), U = d(!1), C = d(!1), V = d();
|
|
73
|
+
k(() => V.value, () => {
|
|
74
|
+
if (V.value) {
|
|
75
|
+
let a;
|
|
76
|
+
G(V.value, {
|
|
77
|
+
onStart: () => {
|
|
78
|
+
a = W.service({ text: "加载中...", fullscreen: !0, customClass: "tinymce-loading" });
|
|
79
|
+
},
|
|
80
|
+
onEnd: () => {
|
|
81
|
+
a == null || a.close();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}, { immediate: !0 });
|
|
86
|
+
const P = d();
|
|
87
|
+
k(() => P.value, () => {
|
|
88
|
+
if (P.value) {
|
|
89
|
+
let a;
|
|
90
|
+
G(P.value, {
|
|
91
|
+
onStart: () => {
|
|
92
|
+
a = W.service({ text: "加载中", fullscreen: !0, customClass: "tinymce-loading" });
|
|
93
|
+
},
|
|
94
|
+
onEnd: () => {
|
|
95
|
+
a == null || a.close();
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}, { immediate: !0 });
|
|
100
|
+
const g = d({
|
|
73
101
|
dialogVisible: !1,
|
|
74
102
|
formData: {
|
|
75
103
|
images: []
|
|
76
104
|
}
|
|
77
|
-
}),
|
|
105
|
+
}), B = d(), X = () => {
|
|
78
106
|
g.value.dialogVisible = !1, g.value.formData = {
|
|
79
107
|
images: []
|
|
80
108
|
};
|
|
81
|
-
},
|
|
82
|
-
var
|
|
83
|
-
(
|
|
84
|
-
l && (g.value.formData.images.forEach((
|
|
109
|
+
}, Y = () => {
|
|
110
|
+
var a;
|
|
111
|
+
(a = B.value) == null || a.validate((l) => {
|
|
112
|
+
l && (g.value.formData.images.forEach((i) => {
|
|
85
113
|
var e, t;
|
|
86
|
-
if (
|
|
87
|
-
return (e =
|
|
88
|
-
(t =
|
|
114
|
+
if (H.value.srcAt)
|
|
115
|
+
return (e = u.value) == null ? void 0 : e.insertContent(`<img src=${i == null ? void 0 : i[H.value.srcAt]} alt="" />`);
|
|
116
|
+
(t = u.value) == null || t.insertContent(`<img src=${i} alt="" />`);
|
|
89
117
|
}), g.value.dialogVisible = !1, g.value.formData.images = []);
|
|
90
118
|
});
|
|
91
|
-
}, r =
|
|
119
|
+
}, r = d({
|
|
92
120
|
dialogVisible: !1,
|
|
93
121
|
formData: {
|
|
94
122
|
// 名称
|
|
@@ -100,23 +128,23 @@ const ia = /* @__PURE__ */ ce({
|
|
|
100
128
|
},
|
|
101
129
|
// 用于临时保存上传前的参数 { file: File }
|
|
102
130
|
additionalData: {}
|
|
103
|
-
}),
|
|
104
|
-
var
|
|
105
|
-
(
|
|
106
|
-
var
|
|
107
|
-
l && ((e =
|
|
131
|
+
}), E = d(), Z = () => {
|
|
132
|
+
var a;
|
|
133
|
+
(a = E.value) == null || a.validate((l) => {
|
|
134
|
+
var i, e;
|
|
135
|
+
l && ((e = u.value) == null || e.insertContent(`<audio controls data-name="${r.value.formData.name}" data-poster="${r.value.formData.cover[0]}" src="${(i = r.value.formData.file[0]) == null ? void 0 : i.url}"></audio>`), r.value.dialogVisible = !1, r.value.formData = {
|
|
108
136
|
name: "",
|
|
109
137
|
cover: [],
|
|
110
138
|
file: []
|
|
111
139
|
}, r.value.additionalData = {});
|
|
112
140
|
});
|
|
113
|
-
},
|
|
141
|
+
}, ee = () => {
|
|
114
142
|
r.value.dialogVisible = !1, r.value.formData = {
|
|
115
143
|
name: "",
|
|
116
144
|
cover: [],
|
|
117
145
|
file: []
|
|
118
146
|
}, r.value.additionalData = {};
|
|
119
|
-
}, s =
|
|
147
|
+
}, s = d({
|
|
120
148
|
dialogVisible: !1,
|
|
121
149
|
formData: {
|
|
122
150
|
// 文件
|
|
@@ -124,92 +152,92 @@ const ia = /* @__PURE__ */ ce({
|
|
|
124
152
|
},
|
|
125
153
|
// 用于临时保存上传前的参数 { file: File }
|
|
126
154
|
additionalData: {}
|
|
127
|
-
}),
|
|
128
|
-
var
|
|
129
|
-
(
|
|
130
|
-
var
|
|
131
|
-
l && ((e =
|
|
155
|
+
}), I = d(), ae = () => {
|
|
156
|
+
var a;
|
|
157
|
+
(a = I.value) == null || a.validate((l) => {
|
|
158
|
+
var i, e;
|
|
159
|
+
l && ((e = u.value) == null || e.insertContent(`<video controls controlslist="nodownload" src="${(i = s.value.formData.file[0]) == null ? void 0 : i.url}"></video>`), s.value.dialogVisible = !1, s.value.formData = {
|
|
132
160
|
file: []
|
|
133
161
|
}, s.value.additionalData = {});
|
|
134
162
|
});
|
|
135
|
-
},
|
|
163
|
+
}, oe = () => {
|
|
136
164
|
s.value.dialogVisible = !1, s.value.formData = {
|
|
137
165
|
file: []
|
|
138
166
|
}, s.value.additionalData = {};
|
|
139
|
-
},
|
|
167
|
+
}, ie = (a, l) => new Promise(async (i, e) => {
|
|
140
168
|
var p, c;
|
|
141
|
-
const t = await
|
|
142
|
-
imageMaxSize:
|
|
143
|
-
imageAllowedType:
|
|
144
|
-
imageAllowedMineType:
|
|
145
|
-
imageMinWidth:
|
|
146
|
-
imageMinHeight:
|
|
147
|
-
imageMaxWidth:
|
|
148
|
-
imageMaxHeight:
|
|
169
|
+
const t = await L(a, {
|
|
170
|
+
imageMaxSize: o.imageMaxSize,
|
|
171
|
+
imageAllowedType: o.imageAllowedType,
|
|
172
|
+
imageAllowedMineType: o.imageAllowedMineType,
|
|
173
|
+
imageMinWidth: o.imageMinWidth,
|
|
174
|
+
imageMinHeight: o.imageMinHeight,
|
|
175
|
+
imageMaxWidth: o.imageMaxWidth,
|
|
176
|
+
imageMaxHeight: o.imageMaxHeight
|
|
149
177
|
});
|
|
150
178
|
if (!t.success) {
|
|
151
179
|
e(), setTimeout(() => {
|
|
152
|
-
var
|
|
153
|
-
(
|
|
180
|
+
var A, w, T;
|
|
181
|
+
(A = t.error) != null && A.size ? l.onError(`请上传大小不超过${o.imageMaxSize}M的图片`) : (w = t.error) != null && w.format ? l.onError(`请上传格式为${o.imageAllowedType.map(($) => $.toUpperCase()).join("、")}的图片`) : (T = t.error) != null && T.pixel && l.onError(`请上传像素不低于${o.imageMinWidth}*${o.imageMinHeight}且像素不高于${o.imageMaxWidth}*${o.imageMaxHeight}的图片`);
|
|
154
182
|
});
|
|
155
183
|
return;
|
|
156
184
|
}
|
|
157
|
-
const n = await
|
|
185
|
+
const n = await J(a);
|
|
158
186
|
if (!n.success) {
|
|
159
187
|
e(), setTimeout(() => {
|
|
160
188
|
l.onError(n.errorMessage);
|
|
161
189
|
});
|
|
162
190
|
return;
|
|
163
191
|
}
|
|
164
|
-
let
|
|
165
|
-
n.hasConversion && (
|
|
166
|
-
const v = await ((c = f.value) == null ? void 0 : c.call(f, n.file,
|
|
192
|
+
let m = a.name;
|
|
193
|
+
n.hasConversion && (m = `${(p = m.split(".")) == null ? void 0 : p[0]}.jpeg`);
|
|
194
|
+
const v = await ((c = f.value) == null ? void 0 : c.call(f, n.file, m, { extParameters: o.extParameters }));
|
|
167
195
|
if (!v.success) {
|
|
168
196
|
e(), setTimeout(() => {
|
|
169
197
|
l.onError(v.errorMessage);
|
|
170
198
|
});
|
|
171
199
|
return;
|
|
172
200
|
}
|
|
173
|
-
|
|
174
|
-
}),
|
|
175
|
-
async function
|
|
176
|
-
var
|
|
177
|
-
const l =
|
|
201
|
+
i(v.url);
|
|
202
|
+
}), te = M(() => o.imageAllowedMineType.map((a) => `.${a.split("/")[1]}`).join(",") || "");
|
|
203
|
+
async function O(a) {
|
|
204
|
+
var i, e;
|
|
205
|
+
const l = a.getElementsByTagName("img");
|
|
178
206
|
for (let t of l) {
|
|
179
207
|
const n = t.src;
|
|
180
208
|
if (n.startsWith("http://") || n.startsWith("https://")) {
|
|
181
|
-
const
|
|
182
|
-
if (
|
|
183
|
-
(
|
|
209
|
+
const m = await ye(n);
|
|
210
|
+
if (m.width < o.imageMinWidth && m.height < o.imageMinHeight || m.width > o.imageMaxWidth && m.height > o.imageMaxHeight) {
|
|
211
|
+
(i = t == null ? void 0 : t.remove) == null || i.call(t);
|
|
184
212
|
return;
|
|
185
213
|
}
|
|
186
214
|
const v = n.split("."), p = v[v.length - 1].toLowerCase();
|
|
187
|
-
if (!
|
|
215
|
+
if (!o.imageAllowedType.includes(p)) {
|
|
188
216
|
(e = t == null ? void 0 : t.remove) == null || e.call(t);
|
|
189
217
|
return;
|
|
190
218
|
}
|
|
191
219
|
}
|
|
192
220
|
}
|
|
193
221
|
}
|
|
194
|
-
const b = M(() => x([
|
|
195
|
-
() => x([
|
|
222
|
+
const b = M(() => x([o.videoUploadOptions, y.videoUploadOptions]) || {}), _ = M(() => x([o.audioUploadOptions, y.audioUploadOptions]) || {}), H = M(() => x([o.imgPondOptions, y.imgPondOptions]) || {}), D = M(
|
|
223
|
+
() => x([o.paste_preprocess, y.paste_preprocess], {
|
|
196
224
|
type: Function
|
|
197
225
|
})
|
|
198
|
-
),
|
|
199
|
-
() => x([
|
|
226
|
+
), S = M(
|
|
227
|
+
() => x([o.paste_postprocess, y.paste_postprocess], {
|
|
200
228
|
type: Function
|
|
201
229
|
})
|
|
202
230
|
), f = M(
|
|
203
|
-
() => x([
|
|
231
|
+
() => x([o.imageUploadHandle, y.imageUploadHandle], {
|
|
204
232
|
type: Function
|
|
205
233
|
})
|
|
206
234
|
);
|
|
207
|
-
|
|
208
|
-
const
|
|
235
|
+
Me(() => {
|
|
236
|
+
const a = {
|
|
209
237
|
// 设置语言
|
|
210
238
|
language: "zh_CN",
|
|
211
239
|
// 实例
|
|
212
|
-
target:
|
|
240
|
+
target: R.value,
|
|
213
241
|
// 隐藏品牌
|
|
214
242
|
branding: !1,
|
|
215
243
|
// 隐藏右上角升级按钮
|
|
@@ -285,99 +313,99 @@ const ia = /* @__PURE__ */ ce({
|
|
|
285
313
|
paste_webkit_styles: "all",
|
|
286
314
|
paste_data_images: !0,
|
|
287
315
|
// 粘贴前处理
|
|
288
|
-
paste_preprocess(
|
|
316
|
+
paste_preprocess(i, e) {
|
|
289
317
|
var t;
|
|
290
|
-
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>"), (t =
|
|
318
|
+
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>"), (t = D.value) == null || t.call(D, i, e);
|
|
291
319
|
},
|
|
292
320
|
// 粘贴后处理(处理异步操作)
|
|
293
|
-
paste_postprocess(
|
|
321
|
+
paste_postprocess(i, e) {
|
|
294
322
|
var n;
|
|
295
323
|
const t = e.node;
|
|
296
|
-
|
|
324
|
+
O(t), (n = S.value) == null || n.call(S, i, e);
|
|
297
325
|
},
|
|
298
|
-
images_upload_handler(
|
|
326
|
+
images_upload_handler(i) {
|
|
299
327
|
return new Promise(async (e, t) => {
|
|
300
|
-
var T,
|
|
301
|
-
const n =
|
|
302
|
-
let
|
|
303
|
-
const v =
|
|
304
|
-
imageMaxSize:
|
|
305
|
-
imageAllowedType:
|
|
306
|
-
imageAllowedMineType:
|
|
307
|
-
imageMinWidth:
|
|
308
|
-
imageMinHeight:
|
|
309
|
-
imageMaxWidth:
|
|
310
|
-
imageMaxHeight:
|
|
328
|
+
var T, $, F, N, q;
|
|
329
|
+
const n = W.service({ text: "上传中" });
|
|
330
|
+
let m = i.blob();
|
|
331
|
+
const v = i.filename(), p = await L(m, {
|
|
332
|
+
imageMaxSize: o.imageMaxSize,
|
|
333
|
+
imageAllowedType: o.imageAllowedType,
|
|
334
|
+
imageAllowedMineType: o.imageAllowedMineType,
|
|
335
|
+
imageMinWidth: o.imageMinWidth,
|
|
336
|
+
imageMinHeight: o.imageMinHeight,
|
|
337
|
+
imageMaxWidth: o.imageMaxWidth,
|
|
338
|
+
imageMaxHeight: o.imageMaxHeight
|
|
311
339
|
});
|
|
312
340
|
if (!p.success) {
|
|
313
341
|
if (n == null || n.close(), (T = p.error) != null && T.size)
|
|
314
|
-
return t({ message: `请上传大小不超过${
|
|
315
|
-
if ((
|
|
316
|
-
return t({ message: `请上传格式为${
|
|
317
|
-
if ((
|
|
318
|
-
return t({ message: `请上传像素不低于${
|
|
342
|
+
return t({ message: `请上传大小不超过${o.imageMaxSize}M的图片`, remove: !0 });
|
|
343
|
+
if (($ = p.error) != null && $.format)
|
|
344
|
+
return t({ message: `请上传格式为${o.imageAllowedType.map((j) => j.toUpperCase()).join("、")}的图片`, remove: !0 });
|
|
345
|
+
if ((F = p.error) != null && F.pixel)
|
|
346
|
+
return t({ message: `请上传像素不低于${o.imageMinWidth}*${o.imageMinHeight}且像素不高于${o.imageMaxWidth}*${o.imageMaxHeight}的图片`, remove: !0 });
|
|
319
347
|
}
|
|
320
|
-
const c = await
|
|
348
|
+
const c = await J(m);
|
|
321
349
|
if (!c.success)
|
|
322
350
|
return n == null || n.close(), t({ message: c == null ? void 0 : c.errorMessage, remove: !0 });
|
|
323
351
|
if (!f.value)
|
|
324
352
|
return n == null || n.close(), t({ message: "缺少图片上传配置", remove: !0 });
|
|
325
|
-
let
|
|
326
|
-
c.hasConversion && (
|
|
327
|
-
const
|
|
328
|
-
if (!
|
|
329
|
-
return n == null || n.close(), t({ message:
|
|
330
|
-
n == null || n.close(), e(
|
|
353
|
+
let A = i.filename();
|
|
354
|
+
c.hasConversion && (A = `${(N = v.split(".")) == null ? void 0 : N[0]}.jpeg`);
|
|
355
|
+
const w = await ((q = f.value) == null ? void 0 : q.call(f, c.file, A, { extParameters: o.extParameters }));
|
|
356
|
+
if (!w.success)
|
|
357
|
+
return n == null || n.close(), t({ message: w.errorMessage, remove: !0 });
|
|
358
|
+
n == null || n.close(), e(w.url);
|
|
331
359
|
});
|
|
332
360
|
},
|
|
333
|
-
setup(
|
|
334
|
-
|
|
361
|
+
setup(i) {
|
|
362
|
+
i.ui.registry.addMenuItem("localImage", {
|
|
335
363
|
text: "图片",
|
|
336
364
|
icon: "image",
|
|
337
365
|
onAction: () => {
|
|
338
366
|
g.value.dialogVisible = !0, setTimeout(() => {
|
|
339
367
|
var t;
|
|
340
368
|
const e = (t = document == null ? void 0 : document.querySelector) == null ? void 0 : t.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
|
|
341
|
-
e && (e.innerHTML =
|
|
369
|
+
e && (e.innerHTML = o.imageUploadTip || "上传");
|
|
342
370
|
});
|
|
343
371
|
}
|
|
344
|
-
}),
|
|
372
|
+
}), i.ui.registry.addButton("localImage", {
|
|
345
373
|
icon: "image",
|
|
346
374
|
tooltip: "图片",
|
|
347
375
|
onAction: () => {
|
|
348
376
|
g.value.dialogVisible = !0, setTimeout(() => {
|
|
349
377
|
var t;
|
|
350
378
|
const e = (t = document == null ? void 0 : document.querySelector) == null ? void 0 : t.call(document, ".tinymce-editor-upload-image-dialog .el-upload__text > div");
|
|
351
|
-
e && (e.innerHTML =
|
|
379
|
+
e && (e.innerHTML = o.imageUploadTip || "上传");
|
|
352
380
|
});
|
|
353
381
|
}
|
|
354
|
-
}),
|
|
382
|
+
}), o.audioEnable && (i.ui.registry.addMenuItem("localAudio", {
|
|
355
383
|
text: "音频",
|
|
356
384
|
icon: "arrow-right",
|
|
357
385
|
onAction: () => {
|
|
358
386
|
r.value.dialogVisible = !0, setTimeout(() => {
|
|
359
387
|
var t;
|
|
360
388
|
const e = (t = document == null ? void 0 : document.querySelector) == null ? void 0 : t.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
|
|
361
|
-
e && (e.innerHTML =
|
|
389
|
+
e && (e.innerHTML = o.imageUploadTip || "上传");
|
|
362
390
|
});
|
|
363
391
|
}
|
|
364
|
-
}),
|
|
392
|
+
}), i.ui.registry.addButton("localAudio", {
|
|
365
393
|
icon: "arrow-right",
|
|
366
394
|
tooltip: "音频",
|
|
367
395
|
onAction: () => {
|
|
368
396
|
r.value.dialogVisible = !0, setTimeout(() => {
|
|
369
397
|
var t;
|
|
370
398
|
const e = (t = document == null ? void 0 : document.querySelector) == null ? void 0 : t.call(document, ".tinymce-editor-upload-audio-dialog .el-upload__text > div");
|
|
371
|
-
e && (e.innerHTML =
|
|
399
|
+
e && (e.innerHTML = o.imageUploadTip || "上传");
|
|
372
400
|
});
|
|
373
401
|
}
|
|
374
|
-
})),
|
|
402
|
+
})), o.videoEnable && (i.ui.registry.addMenuItem("localVideo", {
|
|
375
403
|
text: "视频",
|
|
376
404
|
icon: "embed",
|
|
377
405
|
onAction: () => {
|
|
378
406
|
s.value.dialogVisible = !0;
|
|
379
407
|
}
|
|
380
|
-
}),
|
|
408
|
+
}), i.ui.registry.addButton("localVideo", {
|
|
381
409
|
icon: "embed",
|
|
382
410
|
tooltip: "视频",
|
|
383
411
|
onAction: () => {
|
|
@@ -387,99 +415,99 @@ const ia = /* @__PURE__ */ ce({
|
|
|
387
415
|
}
|
|
388
416
|
}, l = x(
|
|
389
417
|
[
|
|
390
|
-
|
|
418
|
+
o.options,
|
|
391
419
|
y.tinymceOptions,
|
|
392
|
-
|
|
420
|
+
a
|
|
393
421
|
],
|
|
394
422
|
{
|
|
395
|
-
mergeFunction: (
|
|
396
|
-
|
|
423
|
+
mergeFunction: (i, e) => (...t) => {
|
|
424
|
+
i(...t), e(...t);
|
|
397
425
|
},
|
|
398
426
|
type: Object
|
|
399
427
|
}
|
|
400
428
|
);
|
|
401
|
-
|
|
429
|
+
K.init(l).then(([i]) => {
|
|
402
430
|
var e;
|
|
403
|
-
|
|
404
|
-
if (
|
|
405
|
-
|
|
431
|
+
i && (i.customProps = { ...o }, i.on("change input Redo Undo SetContent", () => {
|
|
432
|
+
if (C.value) {
|
|
433
|
+
C.value = !1;
|
|
406
434
|
return;
|
|
407
435
|
}
|
|
408
|
-
U.value = !0,
|
|
409
|
-
}), (e =
|
|
436
|
+
U.value = !0, z("input", i.getContent()), z("update:modelValue", i.getContent());
|
|
437
|
+
}), (e = o.initComplete) == null || e.call(o, { editorIns: i }), u.value = i);
|
|
410
438
|
});
|
|
411
439
|
});
|
|
412
|
-
const
|
|
413
|
-
var
|
|
414
|
-
return ((l = (
|
|
415
|
-
},
|
|
416
|
-
var
|
|
417
|
-
return ((l = (
|
|
418
|
-
},
|
|
440
|
+
const le = () => {
|
|
441
|
+
var a, l;
|
|
442
|
+
return ((l = (a = _.value) == null ? void 0 : a.data) == null ? void 0 : l.call(a, { ...r.value.additionalData || {}, extParameters: o.extParameters })) || {};
|
|
443
|
+
}, ne = () => {
|
|
444
|
+
var a, l;
|
|
445
|
+
return ((l = (a = _.value) == null ? void 0 : a.headers) == null ? void 0 : l.call(a, { ...r.value.additionalData || {}, extParameters: o.extParameters })) || {};
|
|
446
|
+
}, re = (a, l, i) => {
|
|
419
447
|
var t, n;
|
|
420
|
-
const e = (n = (t = _ == null ? void 0 : _.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t,
|
|
421
|
-
e != null && e.url ?
|
|
422
|
-
},
|
|
423
|
-
const t =
|
|
424
|
-
if (!
|
|
425
|
-
h.info(`请上传格式为${
|
|
448
|
+
const e = (n = (t = _ == null ? void 0 : _.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t, a);
|
|
449
|
+
e != null && e.url ? i[i.length - 1].url = e.url : e != null && e.errorMessage && (h.error(e.errorMessage), i.splice(i.length - 1, 1)), r.value.formData.file = i;
|
|
450
|
+
}, se = (a, l) => new Promise((i, e) => {
|
|
451
|
+
const t = a.name.split(".").filter(Boolean).pop() ? a.name.split(".").filter(Boolean).pop() : "";
|
|
452
|
+
if (!o.audioAllowedType.includes(t.toUpperCase())) {
|
|
453
|
+
h.info(`请上传格式为${o.audioAllowedType.join("、")}的音频`), e();
|
|
426
454
|
return;
|
|
427
455
|
}
|
|
428
|
-
if (
|
|
429
|
-
h.info(`请上传${
|
|
456
|
+
if (a.size > o.audioMaxSize * 1024 * 1024) {
|
|
457
|
+
h.info(`请上传${o.audioMaxSize}M内的音频`), e();
|
|
430
458
|
return;
|
|
431
459
|
}
|
|
432
|
-
r.value.additionalData = { file:
|
|
433
|
-
}),
|
|
460
|
+
r.value.additionalData = { file: a }, i(!0);
|
|
461
|
+
}), de = (a, l) => {
|
|
434
462
|
r.value.formData.file = l;
|
|
435
|
-
},
|
|
436
|
-
h.error("上传发生错误,请重试!"), r.value.formData.file =
|
|
437
|
-
},
|
|
438
|
-
var
|
|
439
|
-
return ((l = (
|
|
440
|
-
},
|
|
441
|
-
var
|
|
442
|
-
return ((l = (
|
|
443
|
-
},
|
|
463
|
+
}, ue = (a, l, i) => {
|
|
464
|
+
h.error("上传发生错误,请重试!"), r.value.formData.file = i;
|
|
465
|
+
}, me = () => {
|
|
466
|
+
var a, l;
|
|
467
|
+
return ((l = (a = b.value) == null ? void 0 : a.data) == null ? void 0 : l.call(a, { ...s.value.additionalData || {}, extParameters: o.extParameters })) || {};
|
|
468
|
+
}, pe = () => {
|
|
469
|
+
var a, l;
|
|
470
|
+
return ((l = (a = b.value) == null ? void 0 : a.headers) == null ? void 0 : l.call(a, { ...s.value.additionalData || {}, extParameters: o.extParameters })) || {};
|
|
471
|
+
}, ce = (a, l, i) => {
|
|
444
472
|
var t, n;
|
|
445
|
-
const e = (n = (t = b == null ? void 0 : b.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t,
|
|
446
|
-
e != null && e.url ?
|
|
447
|
-
},
|
|
448
|
-
const t =
|
|
449
|
-
if (!
|
|
450
|
-
h.info(`请上传格式为${
|
|
473
|
+
const e = (n = (t = b == null ? void 0 : b.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t, a);
|
|
474
|
+
e != null && e.url ? i[i.length - 1].url = e.url : e != null && e.errorMessage && (h.error(e.errorMessage), i.splice(i.length - 1, 1)), s.value.formData.file = i;
|
|
475
|
+
}, ge = (a, l) => new Promise((i, e) => {
|
|
476
|
+
const t = a.name.split(".").filter(Boolean).pop() ? a.name.split(".").filter(Boolean).pop() : "";
|
|
477
|
+
if (!o.videoAllowedType.includes(t.toUpperCase())) {
|
|
478
|
+
h.info(`请上传格式为${o.videoAllowedType.join("、")}的视频`), e();
|
|
451
479
|
return;
|
|
452
480
|
}
|
|
453
|
-
if (
|
|
454
|
-
h.info(`请上传${
|
|
481
|
+
if (a.size > o.videoMaxSize * 1024 * 1024) {
|
|
482
|
+
h.info(`请上传${o.videoMaxSize}M内的视频`), e();
|
|
455
483
|
return;
|
|
456
484
|
}
|
|
457
|
-
s.value.additionalData = { file:
|
|
458
|
-
}),
|
|
485
|
+
s.value.additionalData = { file: a }, i(!0);
|
|
486
|
+
}), fe = (a, l) => {
|
|
459
487
|
s.value.formData.file = l;
|
|
460
|
-
},
|
|
461
|
-
h.error("上传发生错误,请重试!"), s.value.formData.file =
|
|
488
|
+
}, ve = (a, l, i) => {
|
|
489
|
+
h.error("上传发生错误,请重试!"), s.value.formData.file = i;
|
|
462
490
|
};
|
|
463
|
-
return
|
|
464
|
-
var
|
|
465
|
-
(
|
|
466
|
-
}),
|
|
467
|
-
var
|
|
468
|
-
(l = (
|
|
469
|
-
}, { immediate: !0 }),
|
|
470
|
-
() => [
|
|
491
|
+
return xe(() => {
|
|
492
|
+
var a;
|
|
493
|
+
(a = u.value) == null || a.destroy();
|
|
494
|
+
}), k(() => [o.disabled, u.value], () => {
|
|
495
|
+
var a, l;
|
|
496
|
+
(l = (a = u.value) == null ? void 0 : a.mode) == null || l.set(o.disabled ? "readonly" : "design");
|
|
497
|
+
}, { immediate: !0 }), k(
|
|
498
|
+
() => [o.value, o.modelValue, u.value],
|
|
471
499
|
() => {
|
|
472
|
-
var
|
|
500
|
+
var a;
|
|
473
501
|
if (U.value) {
|
|
474
502
|
U.value = !1;
|
|
475
503
|
return;
|
|
476
504
|
}
|
|
477
|
-
|
|
505
|
+
C.value = !0, (a = u.value) == null || a.setContent(o.value ? o.value : o.modelValue ? o.modelValue : "");
|
|
478
506
|
},
|
|
479
507
|
{ immediate: !0 }
|
|
480
|
-
), { __sfc: !0, insRef:
|
|
508
|
+
), { __sfc: !0, insRef: R, editorRef: u, preventSettingContent: U, preventUpdatingModelValue: C, uploadImageImgPondRef: V, audioImageImgPondRef: P, uploadImage: g, uploadImageFormRef: B, onUploadImageClose: X, onUploadImageConfirm: Y, uploadAudio: r, uploadAudioFormRef: E, onUploadAudioConfirm: Z, onUploadAudioClose: ee, uploadVideo: s, uploadVideoFormRef: I, onUploadVideoConfirm: ae, onUploadVideoClose: oe, onImageUploadUpload: ie, props: o, emits: z, imgPondAccept: te, processPastedImage: O, mergeVideoUploadOptions: b, mergeAudioUploadOptions: _, mergeImgPondOptions: H, paste_preprocess: D, paste_postprocess: S, imageUploadHandle: f, getUploadAudioData: le, getUploadAudioHeaders: ne, onUploadAudioSuccess: re, onUploadAudioBeforeUpload: se, onUploadAudioRemove: de, onUploadAudioError: ue, getUploadVideoData: me, getUploadVideoHeaders: pe, onUploadVideoSuccess: ce, onUploadVideoBeforeUpload: ge, onUploadVideoRemove: fe, onUploadVideoError: ve, ImgPond: be };
|
|
481
509
|
}
|
|
482
510
|
});
|
|
483
511
|
export {
|
|
484
|
-
|
|
512
|
+
la as default
|
|
485
513
|
};
|
package/es/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import './style.css';
|
|
2
2
|
import o from "./editor.vue.js";
|
|
3
|
-
import { Button as
|
|
4
|
-
import { getImagePixel as
|
|
5
|
-
const
|
|
6
|
-
install: (e,
|
|
7
|
-
Object.assign(
|
|
3
|
+
import { Button as r, Slider as s, Dialog as m, Upload as n, Tag as i, Form as u, FormItem as l, ButtonGroup as g, InputNumber as c, Loading as d } from "element-ui";
|
|
4
|
+
import { getImagePixel as y, interceptImgPondBeforeAddFile as B, oneTravelImageCheck as E, oneTravelImageCompressor as F } from "./util.js";
|
|
5
|
+
const I = {}, b = Object.assign(o, {
|
|
6
|
+
install: (e, t) => {
|
|
7
|
+
Object.assign(I, t || {}), e.use(r), e.use(s), e.use(m), e.use(n), e.use(i), e.use(u), e.use(l), e.use(g), e.use(c), e.use(d), e.component("KbTinymceEditor", o);
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
10
|
export {
|
|
11
11
|
b as TinymceEditor,
|
|
12
12
|
b as default,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
E as
|
|
13
|
+
y as getImagePixel,
|
|
14
|
+
I as globalProps,
|
|
15
|
+
B as interceptImgPondBeforeAddFile,
|
|
16
|
+
E as oneTravelImageCheck,
|
|
17
|
+
F as oneTravelImageCompressor
|
|
17
18
|
};
|
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}
|
|
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}.el-loading-mask.is-fullscreen.tinymce-loading{z-index:3000!important}
|
package/es/util.d.ts
CHANGED
|
@@ -42,3 +42,7 @@ export declare function getImagePixel(src: string): Promise<{
|
|
|
42
42
|
height: number;
|
|
43
43
|
image: HTMLImageElement;
|
|
44
44
|
}>;
|
|
45
|
+
export declare function interceptImgPondBeforeAddFile(imgPondIns: any, options?: {
|
|
46
|
+
onStart?: () => void;
|
|
47
|
+
onEnd?: () => void;
|
|
48
|
+
}): Promise<void>;
|
package/es/util.js
CHANGED
|
@@ -1,90 +1,127 @@
|
|
|
1
|
-
import { compressAccurately as
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { compressAccurately as b } from "image-conversion";
|
|
2
|
+
import x from "compressorjs";
|
|
3
|
+
import A from "image-resizor";
|
|
4
|
+
async function S(c, e) {
|
|
4
5
|
const {
|
|
5
|
-
imageMaxSize:
|
|
6
|
-
imageAllowedType:
|
|
7
|
-
imageAllowedMineType:
|
|
8
|
-
imageMinWidth:
|
|
9
|
-
imageMinHeight:
|
|
10
|
-
imageMaxWidth:
|
|
11
|
-
imageMaxHeight:
|
|
12
|
-
} =
|
|
13
|
-
if (
|
|
14
|
-
return { success: !1, error: { size: !0 }, errorMessage: `请上传大小不超过${
|
|
15
|
-
if (!
|
|
16
|
-
return { success: !1, error: { format: !0 }, errorMessage: `请上传格式为${
|
|
17
|
-
const m = await
|
|
18
|
-
return m.width <
|
|
6
|
+
imageMaxSize: i = 30,
|
|
7
|
+
imageAllowedType: a = ["jpg", "jpeg", "png", "bmp", "heif", "gif", "webp"],
|
|
8
|
+
imageAllowedMineType: r = ["image/jpg", "image/jpeg", "image/png", "image/bmp", "image/heif", "image/heic", "image/gif", "image/webp"],
|
|
9
|
+
imageMinWidth: t = 60,
|
|
10
|
+
imageMinHeight: g = 60,
|
|
11
|
+
imageMaxWidth: s = 6e3,
|
|
12
|
+
imageMaxHeight: l = 6e3
|
|
13
|
+
} = e || {}, f = c, n = await y(f);
|
|
14
|
+
if (f.size > i * 1024 * 1024)
|
|
15
|
+
return { success: !1, error: { size: !0 }, errorMessage: `请上传大小不超过${i}M的图片` };
|
|
16
|
+
if (!r.includes(f.type))
|
|
17
|
+
return { success: !1, error: { format: !0 }, errorMessage: `请上传格式为${a.map((u) => u.toUpperCase()).join("、")}的图片` };
|
|
18
|
+
const m = await d(n);
|
|
19
|
+
return m.width < t && m.height < g || m.width > s && m.height > l ? { success: !1, error: { pixel: !0 }, errorMessage: `请上传像素不低于${t}*${g}且像素不高于${s}*${l}的图片` } : { success: !0, file: f };
|
|
19
20
|
}
|
|
20
|
-
async function
|
|
21
|
-
var
|
|
22
|
-
let
|
|
23
|
-
const
|
|
24
|
-
let
|
|
25
|
-
const
|
|
26
|
-
let
|
|
27
|
-
["image/heif", "image/heic", "image/webp"].includes(
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
|
|
21
|
+
async function $(c) {
|
|
22
|
+
var l;
|
|
23
|
+
let e = c;
|
|
24
|
+
const i = await y(e);
|
|
25
|
+
let a = !1;
|
|
26
|
+
const r = {};
|
|
27
|
+
let t = "image-conversion", g = e.type;
|
|
28
|
+
["image/heif", "image/heic", "image/webp"].includes(e.type) && (t = "compressor", r.convertTypes = [e.type], r.convertSize = 0, r.quality = 1, g = "image/jpeg", a = !0);
|
|
29
|
+
const s = 5 * 1024 * 1024;
|
|
30
|
+
if (e.size > s)
|
|
31
|
+
if (a) {
|
|
32
|
+
const f = await d(i);
|
|
33
|
+
t = "compressor", r.convertTypes = [e.type], r.convertSize = s, r.maxWidth = f.width * (s / e.size), r.quality = 0.92;
|
|
33
34
|
} else
|
|
34
|
-
|
|
35
|
-
if (Object.keys(
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
|
|
35
|
+
t = "image-conversion", r.type = g, r.size = 5 * 1024;
|
|
36
|
+
if (Object.keys(r).length > 0) {
|
|
37
|
+
const f = await M(j(i), r, t);
|
|
38
|
+
if (f.success)
|
|
39
|
+
e = f.file;
|
|
39
40
|
else
|
|
40
|
-
return { file:
|
|
41
|
+
return { file: e, success: !1, hasConversion: a, errorMessage: (l = f.error) == null ? void 0 : l.message };
|
|
41
42
|
}
|
|
42
|
-
return { file:
|
|
43
|
+
return { file: e, hasConversion: a, success: !0 };
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
-
return new Promise((
|
|
46
|
-
|
|
47
|
-
...
|
|
48
|
-
success: async (
|
|
49
|
-
|
|
45
|
+
function M(c, e = {}, i) {
|
|
46
|
+
return new Promise((a) => {
|
|
47
|
+
i === "compressor" ? new x(c, {
|
|
48
|
+
...e,
|
|
49
|
+
success: async (r) => {
|
|
50
|
+
a({ success: !0, file: r });
|
|
50
51
|
},
|
|
51
|
-
error(
|
|
52
|
-
|
|
52
|
+
error(r) {
|
|
53
|
+
a({ success: !1, error: r });
|
|
53
54
|
}
|
|
54
|
-
}) :
|
|
55
|
-
|
|
56
|
-
}).catch((
|
|
57
|
-
|
|
55
|
+
}) : b(c, e).then((r) => {
|
|
56
|
+
a({ success: !0, file: r });
|
|
57
|
+
}).catch((r) => {
|
|
58
|
+
a({ success: !1, error: (r == null ? void 0 : r.message) || "" });
|
|
58
59
|
});
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
|
-
function
|
|
62
|
-
return new Promise((
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
},
|
|
62
|
+
function d(c) {
|
|
63
|
+
return new Promise((e) => {
|
|
64
|
+
const i = new Image();
|
|
65
|
+
i.onload = function() {
|
|
66
|
+
e({ width: i.width, height: i.height, image: i });
|
|
67
|
+
}, i.src = c;
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
|
-
function
|
|
70
|
-
const
|
|
71
|
-
let
|
|
72
|
-
const
|
|
73
|
-
for (;
|
|
74
|
-
|
|
75
|
-
return new Blob([
|
|
70
|
+
function j(c) {
|
|
71
|
+
const e = c.split(","), i = e[0].match(/:(.*?);/)[1], a = atob(e[1]);
|
|
72
|
+
let r = a.length;
|
|
73
|
+
const t = new Uint8Array(r);
|
|
74
|
+
for (; r--; )
|
|
75
|
+
t[r] = a.charCodeAt(r);
|
|
76
|
+
return new Blob([t], { type: i });
|
|
76
77
|
}
|
|
77
|
-
function
|
|
78
|
-
return new Promise((
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
},
|
|
78
|
+
function y(c) {
|
|
79
|
+
return new Promise((e, i) => {
|
|
80
|
+
const a = new FileReader();
|
|
81
|
+
a.onloadend = () => {
|
|
82
|
+
const r = a.result;
|
|
83
|
+
e(r);
|
|
84
|
+
}, a.onerror = i, a.readAsDataURL(c);
|
|
84
85
|
});
|
|
85
86
|
}
|
|
87
|
+
async function C(c, e) {
|
|
88
|
+
const i = c == null ? void 0 : c.beforeAddFile;
|
|
89
|
+
c.beforeAddFile = (a) => {
|
|
90
|
+
var r;
|
|
91
|
+
return e != null && e.onStart && ((r = e == null ? void 0 : e.onStart) == null || r.call(e)), new Promise(async (t) => {
|
|
92
|
+
var g;
|
|
93
|
+
if (a.file.type === "image/heic" || a.file.type === "image/heif") {
|
|
94
|
+
const s = a.file.name, l = s == null ? void 0 : s.split(".");
|
|
95
|
+
l.pop();
|
|
96
|
+
const f = l.join(",");
|
|
97
|
+
new A(a.file, {
|
|
98
|
+
outputType: "image/jpeg",
|
|
99
|
+
quality: 0.9,
|
|
100
|
+
maxWidth: 1 / 0,
|
|
101
|
+
maxHeight: 1 / 0
|
|
102
|
+
}).init().then(async (n) => {
|
|
103
|
+
var h;
|
|
104
|
+
const m = await n.toBlob();
|
|
105
|
+
if (!m)
|
|
106
|
+
return t(!1);
|
|
107
|
+
const u = new File([m], `${f}.jpeg`, { type: m == null ? void 0 : m.type });
|
|
108
|
+
a.file = u, a.fileList[a.fileList.length - 1].raw = u;
|
|
109
|
+
const w = await i(a);
|
|
110
|
+
t(w), e != null && e.onEnd && ((h = e == null ? void 0 : e.onEnd) == null || h.call(e));
|
|
111
|
+
}).catch(() => {
|
|
112
|
+
var n;
|
|
113
|
+
t(!1), e != null && e.onEnd && ((n = e == null ? void 0 : e.onEnd) == null || n.call(e));
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
const s = await i(a);
|
|
117
|
+
t(s), e != null && e.onEnd && ((g = e == null ? void 0 : e.onEnd) == null || g.call(e));
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
}
|
|
86
122
|
export {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
123
|
+
d as getImagePixel,
|
|
124
|
+
C as interceptImgPondBeforeAddFile,
|
|
125
|
+
S as oneTravelImageCheck,
|
|
126
|
+
$ as oneTravelImageCompressor
|
|
90
127
|
};
|
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.15",
|
|
6
6
|
"private": false,
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "es/index.js",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"*.css"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"image-resizor": "^1.1.3",
|
|
23
24
|
"compressorjs": "^1.2.1",
|
|
24
25
|
"image-conversion": "^2.1.1",
|
|
25
26
|
"vue-global-config": "^0.2.6",
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Editor, RawEditorOptions } from 'tinymce'
|
|
|
2
2
|
import _TinymceEditor from './editor.vue'
|
|
3
3
|
|
|
4
4
|
// 导入 ElementUI
|
|
5
|
-
import { Button, Slider, Dialog, Upload, Tag, Form, FormItem, ButtonGroup, Loading } from 'element-ui'
|
|
5
|
+
import { Button, Slider, Dialog, Upload, Tag, Form, FormItem, ButtonGroup, Loading, InputNumber } from 'element-ui'
|
|
6
6
|
|
|
7
7
|
interface TinymceEditorGlobalOptions {
|
|
8
8
|
/** 图片上传请求处理,需要返回图片地址 */
|
|
@@ -55,6 +55,7 @@ const TinymceEditor = Object.assign(_TinymceEditor, {
|
|
|
55
55
|
app.use(Form)
|
|
56
56
|
app.use(FormItem)
|
|
57
57
|
app.use(ButtonGroup)
|
|
58
|
+
app.use(InputNumber)
|
|
58
59
|
app.use(Loading)
|
|
59
60
|
|
|
60
61
|
// 注册组件
|