@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 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 ce, ref as m, computed as M, onMounted as ge, onUnmounted as fe, watch as F } from "vue";
2
- import { oneTravelImageCheck as N, oneTravelImageCompressor as q, getImagePixel as ve } from "./util.js";
3
- import he from "imgpond";
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 j from "tinymce";
6
- import Me from "./langs/zh_CN.js";
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 xe, Message as h } from "element-ui";
37
- const ia = /* @__PURE__ */ ce({
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: 2 },
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(G, { emit: S }) {
70
- const a = G;
71
- j.addI18n("zh_CN", Me);
72
- const k = m(), d = m(), U = m(!1), V = m(!1), g = m({
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
- }), z = m(), L = () => {
105
+ }), B = d(), X = () => {
78
106
  g.value.dialogVisible = !1, g.value.formData = {
79
107
  images: []
80
108
  };
81
- }, J = () => {
82
- var i;
83
- (i = z.value) == null || i.validate((l) => {
84
- l && (g.value.formData.images.forEach((o) => {
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 ($.value.srcAt)
87
- return (e = d.value) == null ? void 0 : e.insertContent(`<img src=${o == null ? void 0 : o[$.value.srcAt]} alt="" />`);
88
- (t = d.value) == null || t.insertContent(`<img src=${o} alt="" />`);
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 = m({
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
- }), H = m(), K = () => {
104
- var i;
105
- (i = H.value) == null || i.validate((l) => {
106
- var o, e;
107
- l && ((e = d.value) == null || e.insertContent(`<audio controls data-name="${r.value.formData.name}" data-poster="${r.value.formData.cover[0]}" src="${(o = r.value.formData.file[0]) == null ? void 0 : o.url}"></audio>`), r.value.dialogVisible = !1, r.value.formData = {
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
- }, Q = () => {
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 = m({
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
- }), W = m(), X = () => {
128
- var i;
129
- (i = W.value) == null || i.validate((l) => {
130
- var o, e;
131
- l && ((e = d.value) == null || e.insertContent(`<video controls controlslist="nodownload" src="${(o = s.value.formData.file[0]) == null ? void 0 : o.url}"></video>`), s.value.dialogVisible = !1, s.value.formData = {
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
- }, Y = () => {
163
+ }, oe = () => {
136
164
  s.value.dialogVisible = !1, s.value.formData = {
137
165
  file: []
138
166
  }, s.value.additionalData = {};
139
- }, Z = (i, l) => new Promise(async (o, e) => {
167
+ }, ie = (a, l) => new Promise(async (i, e) => {
140
168
  var p, c;
141
- const t = await N(i, {
142
- imageMaxSize: a.imageMaxSize,
143
- imageAllowedType: a.imageAllowedType,
144
- imageAllowedMineType: a.imageAllowedMineType,
145
- imageMinWidth: a.imageMinWidth,
146
- imageMinHeight: a.imageMinHeight,
147
- imageMaxWidth: a.imageMaxWidth,
148
- imageMaxHeight: a.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 w, A, T;
153
- (w = t.error) != null && w.size ? l.onError(`请上传大小不超过${a.imageMaxSize}M的图片`) : (A = t.error) != null && A.format ? l.onError(`请上传格式为${a.imageAllowedType.map((P) => P.toUpperCase()).join("、")}的图片`) : (T = t.error) != null && T.pixel && l.onError(`请上传像素不低于${a.imageMinWidth}*${a.imageMinHeight}且像素不高于${a.imageMaxWidth}*${a.imageMaxHeight}的图片`);
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 q(i);
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 u = i.name;
165
- n.hasConversion && (u = `${(p = u.split(".")) == null ? void 0 : p[0]}.jpeg`);
166
- const v = await ((c = f.value) == null ? void 0 : c.call(f, n.file, u, { extParameters: a.extParameters }));
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
- o(v.url);
174
- }), ee = M(() => a.imageAllowedMineType.map((i) => `.${i.split("/")[1]}`).join(",") || "");
175
- async function B(i) {
176
- var o, e;
177
- const l = i.getElementsByTagName("img");
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 u = await ve(n);
182
- if (u.width < a.imageMinWidth && u.height < a.imageMinHeight || u.width > a.imageMaxWidth && u.height > a.imageMaxHeight) {
183
- (o = t == null ? void 0 : t.remove) == null || o.call(t);
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 (!a.imageAllowedType.includes(p)) {
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([a.videoUploadOptions, y.videoUploadOptions]) || {}), _ = M(() => x([a.audioUploadOptions, y.audioUploadOptions]) || {}), $ = M(() => x([a.imgPondOptions, y.imgPondOptions]) || {}), C = M(
195
- () => x([a.paste_preprocess, y.paste_preprocess], {
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
- ), D = M(
199
- () => x([a.paste_postprocess, y.paste_postprocess], {
226
+ ), S = M(
227
+ () => x([o.paste_postprocess, y.paste_postprocess], {
200
228
  type: Function
201
229
  })
202
230
  ), f = M(
203
- () => x([a.imageUploadHandle, y.imageUploadHandle], {
231
+ () => x([o.imageUploadHandle, y.imageUploadHandle], {
204
232
  type: Function
205
233
  })
206
234
  );
207
- ge(() => {
208
- const i = {
235
+ Me(() => {
236
+ const a = {
209
237
  // 设置语言
210
238
  language: "zh_CN",
211
239
  // 实例
212
- target: k.value,
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(o, e) {
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 = C.value) == null || t.call(C, o, e);
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(o, e) {
321
+ paste_postprocess(i, e) {
294
322
  var n;
295
323
  const t = e.node;
296
- B(t), (n = D.value) == null || n.call(D, o, e);
324
+ O(t), (n = S.value) == null || n.call(S, i, e);
297
325
  },
298
- images_upload_handler(o) {
326
+ images_upload_handler(i) {
299
327
  return new Promise(async (e, t) => {
300
- var T, P, R, E, O;
301
- const n = xe.service({ text: "上传中" });
302
- let u = o.blob();
303
- const v = o.filename(), p = await N(u, {
304
- imageMaxSize: a.imageMaxSize,
305
- imageAllowedType: a.imageAllowedType,
306
- imageAllowedMineType: a.imageAllowedMineType,
307
- imageMinWidth: a.imageMinWidth,
308
- imageMinHeight: a.imageMinHeight,
309
- imageMaxWidth: a.imageMaxWidth,
310
- imageMaxHeight: a.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: `请上传大小不超过${a.imageMaxSize}M的图片`, remove: !0 });
315
- if ((P = p.error) != null && P.format)
316
- return t({ message: `请上传格式为${a.imageAllowedType.map((I) => I.toUpperCase()).join("、")}的图片`, remove: !0 });
317
- if ((R = p.error) != null && R.pixel)
318
- return t({ message: `请上传像素不低于${a.imageMinWidth}*${a.imageMinHeight}且像素不高于${a.imageMaxWidth}*${a.imageMaxHeight}的图片`, remove: !0 });
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 q(u);
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 w = o.filename();
326
- c.hasConversion && (w = `${(E = v.split(".")) == null ? void 0 : E[0]}.jpeg`);
327
- const A = await ((O = f.value) == null ? void 0 : O.call(f, c.file, w, { extParameters: a.extParameters }));
328
- if (!A.success)
329
- return n == null || n.close(), t({ message: A.errorMessage, remove: !0 });
330
- n == null || n.close(), e(A.url);
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(o) {
334
- o.ui.registry.addMenuItem("localImage", {
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 = a.imageUploadTip || "上传");
369
+ e && (e.innerHTML = o.imageUploadTip || "上传");
342
370
  });
343
371
  }
344
- }), o.ui.registry.addButton("localImage", {
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 = a.imageUploadTip || "上传");
379
+ e && (e.innerHTML = o.imageUploadTip || "上传");
352
380
  });
353
381
  }
354
- }), a.audioEnable && (o.ui.registry.addMenuItem("localAudio", {
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 = a.imageUploadTip || "上传");
389
+ e && (e.innerHTML = o.imageUploadTip || "上传");
362
390
  });
363
391
  }
364
- }), o.ui.registry.addButton("localAudio", {
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 = a.imageUploadTip || "上传");
399
+ e && (e.innerHTML = o.imageUploadTip || "上传");
372
400
  });
373
401
  }
374
- })), a.videoEnable && (o.ui.registry.addMenuItem("localVideo", {
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
- }), o.ui.registry.addButton("localVideo", {
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
- a.options,
418
+ o.options,
391
419
  y.tinymceOptions,
392
- i
420
+ a
393
421
  ],
394
422
  {
395
- mergeFunction: (o, e) => (...t) => {
396
- o(...t), e(...t);
423
+ mergeFunction: (i, e) => (...t) => {
424
+ i(...t), e(...t);
397
425
  },
398
426
  type: Object
399
427
  }
400
428
  );
401
- j.init(l).then(([o]) => {
429
+ K.init(l).then(([i]) => {
402
430
  var e;
403
- o && (o.customProps = { ...a }, o.on("change input Redo Undo SetContent", () => {
404
- if (V.value) {
405
- V.value = !1;
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, S("input", o.getContent()), S("update:modelValue", o.getContent());
409
- }), (e = a.initComplete) == null || e.call(a, { editorIns: o }), d.value = o);
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 ae = () => {
413
- var i, l;
414
- return ((l = (i = _.value) == null ? void 0 : i.data) == null ? void 0 : l.call(i, { ...r.value.additionalData || {}, extParameters: a.extParameters })) || {};
415
- }, ie = () => {
416
- var i, l;
417
- return ((l = (i = _.value) == null ? void 0 : i.headers) == null ? void 0 : l.call(i, { ...r.value.additionalData || {}, extParameters: a.extParameters })) || {};
418
- }, oe = (i, l, o) => {
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, i);
421
- e != null && e.url ? o[o.length - 1].url = e.url : e != null && e.errorMessage && (h.error(e.errorMessage), o.splice(o.length - 1, 1)), r.value.formData.file = o;
422
- }, te = (i, l) => new Promise((o, e) => {
423
- const t = i.name.split(".").filter(Boolean).pop() ? i.name.split(".").filter(Boolean).pop() : "";
424
- if (!a.audioAllowedType.includes(t.toUpperCase())) {
425
- h.info(`请上传格式为${a.audioAllowedType.join("、")}的音频`), e();
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 (i.size > a.audioMaxSize * 1024 * 1024) {
429
- h.info(`请上传${a.audioMaxSize}M内的音频`), e();
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: i }, o(!0);
433
- }), le = (i, l) => {
460
+ r.value.additionalData = { file: a }, i(!0);
461
+ }), de = (a, l) => {
434
462
  r.value.formData.file = l;
435
- }, ne = (i, l, o) => {
436
- h.error("上传发生错误,请重试!"), r.value.formData.file = o;
437
- }, re = () => {
438
- var i, l;
439
- return ((l = (i = b.value) == null ? void 0 : i.data) == null ? void 0 : l.call(i, { ...s.value.additionalData || {}, extParameters: a.extParameters })) || {};
440
- }, se = () => {
441
- var i, l;
442
- return ((l = (i = b.value) == null ? void 0 : i.headers) == null ? void 0 : l.call(i, { ...s.value.additionalData || {}, extParameters: a.extParameters })) || {};
443
- }, de = (i, l, o) => {
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, i);
446
- e != null && e.url ? o[o.length - 1].url = e.url : e != null && e.errorMessage && (h.error(e.errorMessage), o.splice(o.length - 1, 1)), s.value.formData.file = o;
447
- }, ue = (i, l) => new Promise((o, e) => {
448
- const t = i.name.split(".").filter(Boolean).pop() ? i.name.split(".").filter(Boolean).pop() : "";
449
- if (!a.videoAllowedType.includes(t.toUpperCase())) {
450
- h.info(`请上传格式为${a.videoAllowedType.join("、")}的视频`), e();
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 (i.size > a.videoMaxSize * 1024 * 1024) {
454
- h.info(`请上传${a.videoMaxSize}M内的视频`), e();
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: i }, o(!0);
458
- }), me = (i, l) => {
485
+ s.value.additionalData = { file: a }, i(!0);
486
+ }), fe = (a, l) => {
459
487
  s.value.formData.file = l;
460
- }, pe = (i, l, o) => {
461
- h.error("上传发生错误,请重试!"), s.value.formData.file = o;
488
+ }, ve = (a, l, i) => {
489
+ h.error("上传发生错误,请重试!"), s.value.formData.file = i;
462
490
  };
463
- return fe(() => {
464
- var i;
465
- (i = d.value) == null || i.destroy();
466
- }), F(() => [a.disabled, d.value], () => {
467
- var i, l;
468
- (l = (i = d.value) == null ? void 0 : i.mode) == null || l.set(a.disabled ? "readonly" : "design");
469
- }, { immediate: !0 }), F(
470
- () => [a.value, a.modelValue, d.value],
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 i;
500
+ var a;
473
501
  if (U.value) {
474
502
  U.value = !1;
475
503
  return;
476
504
  }
477
- V.value = !0, (i = d.value) == null || i.setContent(a.value ? a.value : a.modelValue ? a.modelValue : "");
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: k, editorRef: d, preventSettingContent: U, preventUpdatingModelValue: V, uploadImage: g, uploadImageFormRef: z, onUploadImageClose: L, onUploadImageConfirm: J, uploadAudio: r, uploadAudioFormRef: H, onUploadAudioConfirm: K, onUploadAudioClose: Q, uploadVideo: s, uploadVideoFormRef: W, onUploadVideoConfirm: X, onUploadVideoClose: Y, onImageUploadUpload: Z, props: a, emits: S, imgPondAccept: ee, processPastedImage: B, mergeVideoUploadOptions: b, mergeAudioUploadOptions: _, mergeImgPondOptions: $, paste_preprocess: C, paste_postprocess: D, imageUploadHandle: f, getUploadAudioData: ae, getUploadAudioHeaders: ie, onUploadAudioSuccess: oe, onUploadAudioBeforeUpload: te, onUploadAudioRemove: le, onUploadAudioError: ne, getUploadVideoData: re, getUploadVideoHeaders: se, onUploadVideoSuccess: de, onUploadVideoBeforeUpload: ue, onUploadVideoRemove: me, onUploadVideoError: pe, ImgPond: he };
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
- ia as default
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 t, Slider as r, Dialog as m, Upload as i, Tag as n, Form as u, FormItem as l, ButtonGroup as g, Loading as c } from "element-ui";
4
- import { getImagePixel as x, oneTravelImageCheck as y, oneTravelImageCompressor as E } from "./util.js";
5
- const d = {}, b = Object.assign(o, {
6
- install: (e, s) => {
7
- Object.assign(d, s || {}), e.use(t), e.use(r), e.use(m), e.use(i), e.use(n), e.use(u), e.use(l), e.use(g), e.use(c), e.component("KbTinymceEditor", o);
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
- x as getImagePixel,
14
- d as globalProps,
15
- y as oneTravelImageCheck,
16
- E as oneTravelImageCompressor
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 h } from "image-conversion";
2
- import w from "compressorjs";
3
- async function x(r, s) {
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: t = 30,
6
- imageAllowedType: i = ["jpg", "jpeg", "png", "bmp", "heif", "gif", "webp"],
7
- imageAllowedMineType: e = ["image/jpg", "image/jpeg", "image/png", "image/bmp", "image/heif", "image/heic", "image/gif", "image/webp"],
8
- imageMinWidth: a = 60,
9
- imageMinHeight: c = 60,
10
- imageMaxWidth: o = 6e3,
11
- imageMaxHeight: g = 6e3
12
- } = s || {}, n = r, p = await l(n);
13
- if (n.size > t * 1024 * 1024)
14
- return { success: !1, error: { size: !0 }, errorMessage: `请上传大小不超过${t}M的图片` };
15
- if (!e.includes(n.type))
16
- return { success: !1, error: { format: !0 }, errorMessage: `请上传格式为${i.map((f) => f.toUpperCase()).join("、")}的图片` };
17
- const m = await u(p);
18
- return m.width < a && m.height < c || m.width > o && m.height > g ? { success: !1, error: { pixel: !0 }, errorMessage: `请上传像素不低于${a}*${c}且像素不高于${o}*${g}的图片` } : { success: !0, file: n };
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 z(r) {
21
- var g;
22
- let s = r;
23
- const t = await l(s);
24
- let i = !1;
25
- const e = {};
26
- let a = "image-conversion", c = s.type;
27
- ["image/heif", "image/heic", "image/webp"].includes(s.type) && (a = "compressor", e.convertTypes = [s.type], e.convertSize = 0, e.quality = 1, c = "image/jpeg", i = !0);
28
- const o = 5 * 1024 * 1024;
29
- if (s.size > o)
30
- if (i) {
31
- const n = await u(t);
32
- a = "compressor", e.convertTypes = [s.type], e.convertSize = o, e.maxWidth = n.width * (o / s.size), e.quality = 0.92;
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
- a = "image-conversion", e.type = c, e.size = 5 * 1024;
35
- if (Object.keys(e).length > 0) {
36
- const n = await d(y(t), e, a);
37
- if (n.success)
38
- s = n.file;
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: s, success: !1, hasConversion: i, errorMessage: (g = n.error) == null ? void 0 : g.message };
41
+ return { file: e, success: !1, hasConversion: a, errorMessage: (l = f.error) == null ? void 0 : l.message };
41
42
  }
42
- return { file: s, hasConversion: i, success: !0 };
43
+ return { file: e, hasConversion: a, success: !0 };
43
44
  }
44
- function d(r, s = {}, t) {
45
- return new Promise((i) => {
46
- t === "compressor" ? new w(r, {
47
- ...s,
48
- success: async (e) => {
49
- i({ success: !0, file: e });
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(e) {
52
- i({ success: !1, error: e });
52
+ error(r) {
53
+ a({ success: !1, error: r });
53
54
  }
54
- }) : h(r, s).then((e) => {
55
- i({ success: !0, file: e });
56
- }).catch((e) => {
57
- i({ success: !1, error: (e == null ? void 0 : e.message) || "" });
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 u(r) {
62
- return new Promise((s) => {
63
- const t = new Image();
64
- t.onload = function() {
65
- s({ width: t.width, height: t.height, image: t });
66
- }, t.src = r;
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 y(r) {
70
- const s = r.split(","), t = s[0].match(/:(.*?);/)[1], i = atob(s[1]);
71
- let e = i.length;
72
- const a = new Uint8Array(e);
73
- for (; e--; )
74
- a[e] = i.charCodeAt(e);
75
- return new Blob([a], { type: t });
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 l(r) {
78
- return new Promise((s, t) => {
79
- const i = new FileReader();
80
- i.onloadend = () => {
81
- const e = i.result;
82
- s(e);
83
- }, i.onerror = t, i.readAsDataURL(r);
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
- u as getImagePixel,
88
- x as oneTravelImageCheck,
89
- z as oneTravelImageCompressor
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.14",
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
  // 注册组件