@keyblade/tinymce-editor-vue2 0.0.12-alpha.24 → 0.0.12-alpha.26

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
@@ -33,7 +33,7 @@ Vue.use(ImgPond, {})
33
33
  Vue.use(TinymceEditor, {
34
34
  // 图片
35
35
  imageUploadOptions: {
36
- handleRequest: (file: File | Blob, filename: string, parameters: { extParameters: Record<string, any> }) => {
36
+ handleRequest: (file: File, filename: string, parameters: { extParameters: Record<string, any> }) => {
37
37
  return new Promise((resolve) => {
38
38
  setTimeout(() => {
39
39
  resolve({
@@ -170,7 +170,7 @@ export interface ImageUploadOptions {
170
170
  /** 图片最大高度 */
171
171
  maxHeight?: number;
172
172
  /** 图片上传请求处理 */
173
- handleRequest?: (file: File | Blob, filename: string, options?: {
173
+ handleRequest?: (file: File, filename: string, options?: {
174
174
  extParameters?: Record<string, any>
175
175
  }) => Promise<{success: boolean; url?: string; errorMessage?: string}>;
176
176
  }
package/es/editor.vue2.js CHANGED
@@ -1,10 +1,10 @@
1
- import { defineComponent as ge, ref as h, computed as _, watch as S, onMounted as he, onUnmounted as xe } from "vue";
2
- import { oneTravelImgPondBeforeAddFile as J, oneTravelImageCheckAndTransform as be, oneTravelImageCompressor as K } from "@keyblade/one-travel";
3
- import { getFileExtension as Q, getImagePixel as ye } from "./util.js";
4
- import we from "imgpond";
1
+ import { defineComponent as he, ref as h, computed as _, watch as S, onMounted as xe, onUnmounted as be } from "vue";
2
+ import { oneTravelImgPondBeforeAddFile as J, oneTravelImageCheckAndTransform as ye, oneTravelImageCompressor as K } from "@keyblade/one-travel";
3
+ import { blobToFile as Q, getFileExtension as X, getImagePixel as we } from "./util.js";
4
+ import _e from "imgpond";
5
5
  import { conclude as C } from "vue-global-config";
6
- import X from "tinymce";
7
- import _e from "./langs/zh_CN.js";
6
+ import Y from "tinymce";
7
+ import Ce from "./langs/zh_CN.js";
8
8
  import "tinymce/skins/ui/oxide/skin";
9
9
  import "tinymce/models/dom";
10
10
  import "tinymce/themes/silver";
@@ -33,9 +33,9 @@ import "tinymce/plugins/table";
33
33
  import "tinymce/plugins/visualblocks";
34
34
  import "tinymce/plugins/visualchars";
35
35
  import "tinymce/plugins/wordcount";
36
- import { globalProps as A } from "./index.js";
36
+ import { globalProps as T } from "./index.js";
37
37
  import { Loading as k, Message as b } from "element-ui";
38
- const ra = /* @__PURE__ */ ge({
38
+ const sa = /* @__PURE__ */ he({
39
39
  __name: "editor",
40
40
  props: {
41
41
  value: { default: "" },
@@ -49,9 +49,9 @@ const ra = /* @__PURE__ */ ge({
49
49
  initComplete: null
50
50
  },
51
51
  emits: ["input"],
52
- setup(Y, { emit: z }) {
53
- const m = Y;
54
- X.addI18n("zh_CN", _e);
52
+ setup(Z, { emit: z }) {
53
+ const m = Z;
54
+ Y.addI18n("zh_CN", Ce);
55
55
  const V = {
56
56
  maxCount: 10,
57
57
  tipText: "上传",
@@ -70,7 +70,7 @@ const ra = /* @__PURE__ */ ge({
70
70
  enable: !0,
71
71
  maxSize: 200,
72
72
  allowedType: ["mp3", "m4a", "wav", "aac"]
73
- }, R = h(), x = h(), P = h(!1), T = h(!1), c = _(() => C([m.imageUploadOptions, A.imageUploadOptions, V]) || {}), d = _(() => C([m.videoUploadOptions, A.videoUploadOptions, B]) || {}), f = _(() => C([m.audioUploadOptions, A.audioUploadOptions, H]) || {}), U = _(() => C([m.imgPondOptions, A.imgPondOptions]) || {}), Z = _(() => {
73
+ }, R = h(), x = h(), A = h(!1), P = h(!1), c = _(() => C([m.imageUploadOptions, T.imageUploadOptions, V]) || {}), d = _(() => C([m.videoUploadOptions, T.videoUploadOptions, B]) || {}), f = _(() => C([m.audioUploadOptions, T.audioUploadOptions, H]) || {}), U = _(() => C([m.imgPondOptions, T.imgPondOptions]) || {}), ee = _(() => {
74
74
  var e, o;
75
75
  return ((o = (e = c == null ? void 0 : c.value) == null ? void 0 : e.allowedType) == null ? void 0 : o.map((i) => `.${i}`).join(",")) || "";
76
76
  }), D = h();
@@ -116,7 +116,7 @@ const ra = /* @__PURE__ */ ge({
116
116
  w.value.dialogVisible = !1, w.value.formData = {
117
117
  images: []
118
118
  };
119
- }, ee = () => {
119
+ }, ae = () => {
120
120
  var e;
121
121
  (e = W.value) == null || e.validate((o) => {
122
122
  o && (w.value.formData.images.forEach((i) => {
@@ -143,7 +143,7 @@ const ra = /* @__PURE__ */ ge({
143
143
  cover: [],
144
144
  file: []
145
145
  }, v.value.additionalData = {};
146
- }, ae = () => {
146
+ }, te = () => {
147
147
  var e;
148
148
  (e = $.value) == null || e.validate((o) => {
149
149
  var i, a;
@@ -161,13 +161,13 @@ const ra = /* @__PURE__ */ ge({
161
161
  g.value.dialogVisible = !1, g.value.formData = {
162
162
  file: []
163
163
  }, g.value.additionalData = {};
164
- }, te = () => {
164
+ }, oe = () => {
165
165
  var e;
166
166
  (e = I.value) == null || e.validate((o) => {
167
167
  var i, a;
168
168
  o && ((a = x.value) == null || a.insertContent(`<video controls controlslist="nodownload" src="${(i = g.value.formData.file[0]) == null ? void 0 : i.url}"></video>`), q());
169
169
  });
170
- }, oe = (e, o) => new Promise(async (i, a) => {
170
+ }, ie = (e, o) => new Promise(async (i, a) => {
171
171
  var r, l;
172
172
  const t = await K(e);
173
173
  if (!t.success) {
@@ -176,7 +176,7 @@ const ra = /* @__PURE__ */ ge({
176
176
  });
177
177
  return;
178
178
  }
179
- const n = await ((l = (r = c.value).handleRequest) == null ? void 0 : l.call(r, t.file, e.name, { extParameters: m.extParameters }));
179
+ const n = await ((l = (r = c.value).handleRequest) == null ? void 0 : l.call(r, Q(t.file, e.name), e.name, { extParameters: m.extParameters }));
180
180
  if (!n || !(n != null && n.success)) {
181
181
  a(), setTimeout(() => {
182
182
  o.onError(n == null ? void 0 : n.errorMessage);
@@ -193,12 +193,12 @@ const ra = /* @__PURE__ */ ge({
193
193
  if (s.startsWith("data:image"))
194
194
  (i = l == null ? void 0 : l.remove) == null || i.call(l);
195
195
  else if (s.startsWith("http://") || s.startsWith("https://")) {
196
- const u = await ye(s);
196
+ const u = await we(s);
197
197
  if (u && (u.width < (c.value.minWidth || 0) && u.height < (c.value.minHeight || 0) || u.width > (c.value.maxWidth || 0) && u.height > (c.value.maxHeight || 0))) {
198
198
  (a = l == null ? void 0 : l.remove) == null || a.call(l);
199
199
  return;
200
200
  }
201
- const p = Q(s);
201
+ const p = X(s);
202
202
  if (!((n = (t = c.value) == null ? void 0 : t.allowedType) != null && n.includes(p.toLowerCase()))) {
203
203
  (r = l == null ? void 0 : l.remove) == null || r.call(l);
204
204
  return;
@@ -206,7 +206,7 @@ const ra = /* @__PURE__ */ ge({
206
206
  }
207
207
  }
208
208
  }
209
- he(() => {
209
+ xe(() => {
210
210
  var i;
211
211
  const e = {
212
212
  // 设置语言
@@ -305,7 +305,7 @@ const ra = /* @__PURE__ */ ge({
305
305
  let l = a.blob(), s = l.name ? l.name : a.filename();
306
306
  if (!(l != null && l.name) && !(l != null && l.lastModified) && l.type === "image/png")
307
307
  return r == null || r.close(), n({ message: "不允许粘贴", remove: !0 });
308
- const u = await be(l, s, {
308
+ const u = await ye(l, s, {
309
309
  imageMaxSize: c.value.maxSize,
310
310
  imageAllowedType: c.value.allowedType,
311
311
  // imageAllowedMineType: mergeImageUploadOptions.value.allowedMineType,
@@ -324,7 +324,7 @@ const ra = /* @__PURE__ */ ge({
324
324
  const p = await K(l);
325
325
  if (!p.success)
326
326
  return r == null || r.close(), n({ message: p == null ? void 0 : p.errorMessage, remove: !0 });
327
- const y = await ((L = (O = c.value).handleRequest) == null ? void 0 : L.call(O, p.file, s, { extParameters: m.extParameters }));
327
+ const y = await ((L = (O = c.value).handleRequest) == null ? void 0 : L.call(O, Q(p.file, s), s, { extParameters: m.extParameters }));
328
328
  if (!y || !y.success)
329
329
  return r == null || r.close(), n({ message: y.errorMessage, remove: !0 });
330
330
  r == null || r.close(), t(y.url);
@@ -383,7 +383,7 @@ const ra = /* @__PURE__ */ ge({
383
383
  }, o = C(
384
384
  [
385
385
  m.options,
386
- A.options,
386
+ T.options,
387
387
  e
388
388
  ],
389
389
  {
@@ -393,40 +393,40 @@ const ra = /* @__PURE__ */ ge({
393
393
  type: Object
394
394
  }
395
395
  );
396
- X.init(o).then(([a]) => {
396
+ Y.init(o).then(([a]) => {
397
397
  var t;
398
398
  a && (a.customProps = { ...m }, a.on("change input Redo Undo SetContent", () => {
399
- if (T.value) {
400
- T.value = !1;
399
+ if (P.value) {
400
+ P.value = !1;
401
401
  return;
402
402
  }
403
- P.value = !0, z("input", a.getContent());
403
+ A.value = !0, z("input", a.getContent());
404
404
  }), a.on("paste", (n) => {
405
405
  var l, s;
406
406
  const r = ((l = n.clipboardData) == null ? void 0 : l.files) || [];
407
407
  for (let u of r) {
408
- const p = Q(u.name) || "";
408
+ const p = X(u.name) || "";
409
409
  (s = c.value.allowedType) != null && s.includes(p.toLowerCase()) || n.preventDefault();
410
410
  }
411
411
  }), (t = m.initComplete) == null || t.call(m, { editorIns: a }), x.value = a);
412
412
  });
413
- }), xe(() => {
413
+ }), be(() => {
414
414
  var e;
415
415
  (e = x.value) == null || e.destroy();
416
416
  });
417
- const ie = () => {
417
+ const le = () => {
418
418
  var o, i;
419
419
  const e = { ...v.value.additionalData || {} };
420
420
  return ((i = (o = f.value) == null ? void 0 : o.data) == null ? void 0 : i.call(o, { file: e, extParameters: m.extParameters })) || {};
421
- }, le = () => {
421
+ }, ne = () => {
422
422
  var o, i;
423
423
  const e = { ...v.value.additionalData || {} };
424
424
  return ((i = (o = f.value) == null ? void 0 : o.headers) == null ? void 0 : i.call(o, { file: e, extParameters: m.extParameters })) || {};
425
- }, ne = (e, o, i) => {
425
+ }, re = (e, o, i) => {
426
426
  var t, n;
427
427
  const a = (n = (t = f == null ? void 0 : f.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t, e);
428
428
  a != null && a.url ? i[i.length - 1].url = a.url : a != null && a.errorMessage && (b.error(a.errorMessage), i.splice(i.length - 1, 1)), v.value.formData.file = i;
429
- }, re = (e, o) => new Promise((i, a) => {
429
+ }, se = (e, o) => new Promise((i, a) => {
430
430
  var n, r, l, s, u, p;
431
431
  const t = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
432
432
  if (!((r = (n = f.value) == null ? void 0 : n.allowedType) != null && r.includes(t.toLowerCase()))) {
@@ -438,23 +438,23 @@ const ra = /* @__PURE__ */ ge({
438
438
  return;
439
439
  }
440
440
  v.value.additionalData = { file: e }, i(!0);
441
- }), se = (e, o) => {
441
+ }), ue = (e, o) => {
442
442
  v.value.formData.file = o;
443
- }, ue = (e, o, i) => {
443
+ }, ce = (e, o, i) => {
444
444
  b.error("上传发生错误,请重试!"), v.value.formData.file = i;
445
- }, ce = () => {
445
+ }, me = () => {
446
446
  var o, i;
447
447
  const e = { ...g.value.additionalData || {} };
448
448
  return ((i = (o = d.value) == null ? void 0 : o.data) == null ? void 0 : i.call(o, { file: e, extParameters: m.extParameters })) || {};
449
- }, me = () => {
449
+ }, de = () => {
450
450
  var o, i;
451
451
  const e = { ...g.value.additionalData || {} };
452
452
  return ((i = (o = d.value) == null ? void 0 : o.headers) == null ? void 0 : i.call(o, { file: e, extParameters: m.extParameters })) || {};
453
- }, de = (e, o, i) => {
453
+ }, pe = (e, o, i) => {
454
454
  var t, n;
455
455
  const a = (n = (t = d == null ? void 0 : d.value) == null ? void 0 : t.handlerResponse) == null ? void 0 : n.call(t, e);
456
456
  a != null && a.url ? i[i.length - 1].url = a.url : a != null && a.errorMessage && (b.error(a.errorMessage), i.splice(i.length - 1, 1)), g.value.formData.file = i;
457
- }, pe = (e, o) => new Promise((i, a) => {
457
+ }, ve = (e, o) => new Promise((i, a) => {
458
458
  var n, r, l, s, u, p;
459
459
  const t = e.name.split(".").filter(Boolean).pop() ? e.name.split(".").filter(Boolean).pop() : "";
460
460
  if (!((r = (n = d == null ? void 0 : d.value) == null ? void 0 : n.allowedType) != null && r.includes(t.toLowerCase()))) {
@@ -466,9 +466,9 @@ const ra = /* @__PURE__ */ ge({
466
466
  return;
467
467
  }
468
468
  g.value.additionalData = { file: e }, i(!0);
469
- }), ve = (e, o) => {
469
+ }), fe = (e, o) => {
470
470
  g.value.formData.file = o;
471
- }, fe = (e, o, i) => {
471
+ }, ge = (e, o, i) => {
472
472
  b.error("上传发生错误,请重试!"), g.value.formData.file = i;
473
473
  };
474
474
  return S(() => [m.disabled, x.value], () => {
@@ -478,16 +478,16 @@ const ra = /* @__PURE__ */ ge({
478
478
  () => [m.value, x.value],
479
479
  () => {
480
480
  var e;
481
- if (P.value) {
482
- P.value = !1;
481
+ if (A.value) {
482
+ A.value = !1;
483
483
  return;
484
484
  }
485
- T.value = !0, (e = x.value) == null || e.setContent(m.value ? m.value : "");
485
+ P.value = !0, (e = x.value) == null || e.setContent(m.value ? m.value : "");
486
486
  },
487
487
  { immediate: !0 }
488
- ), { __sfc: !0, defaultImageUploadOptions: V, defaultVideoUploadOptions: B, defaultAudioUploadOptions: H, props: m, emits: z, insRef: R, editorRef: x, preventSettingContent: P, preventUpdatingModelValue: T, mergeImageUploadOptions: c, mergeVideoUploadOptions: d, mergeAudioUploadOptions: f, mergeImgPondOptions: U, imgPondAccept: Z, uploadImageImgPondRef: D, audioImageImgPondRef: M, uploadImage: w, uploadImageFormRef: W, onUploadImageClose: j, onUploadImageConfirm: ee, uploadAudio: v, uploadAudioFormRef: $, onUploadAudioClose: E, onUploadAudioConfirm: ae, uploadVideo: g, uploadVideoFormRef: I, onUploadVideoClose: q, onUploadVideoConfirm: te, onImageUploadUpload: oe, processPastedImage: F, getUploadAudioData: ie, getUploadAudioHeaders: le, onUploadAudioSuccess: ne, onUploadAudioBeforeUpload: re, onUploadAudioRemove: se, onUploadAudioError: ue, getUploadVideoData: ce, getUploadVideoHeaders: me, onUploadVideoSuccess: de, onUploadVideoBeforeUpload: pe, onUploadVideoRemove: ve, onUploadVideoError: fe, ImgPond: we };
488
+ ), { __sfc: !0, defaultImageUploadOptions: V, defaultVideoUploadOptions: B, defaultAudioUploadOptions: H, props: m, emits: z, insRef: R, editorRef: x, preventSettingContent: A, preventUpdatingModelValue: P, mergeImageUploadOptions: c, mergeVideoUploadOptions: d, mergeAudioUploadOptions: f, mergeImgPondOptions: U, imgPondAccept: ee, uploadImageImgPondRef: D, audioImageImgPondRef: M, uploadImage: w, uploadImageFormRef: W, onUploadImageClose: j, onUploadImageConfirm: ae, uploadAudio: v, uploadAudioFormRef: $, onUploadAudioClose: E, onUploadAudioConfirm: te, uploadVideo: g, uploadVideoFormRef: I, onUploadVideoClose: q, onUploadVideoConfirm: oe, onImageUploadUpload: ie, processPastedImage: F, getUploadAudioData: le, getUploadAudioHeaders: ne, onUploadAudioSuccess: re, onUploadAudioBeforeUpload: se, onUploadAudioRemove: ue, onUploadAudioError: ce, getUploadVideoData: me, getUploadVideoHeaders: de, onUploadVideoSuccess: pe, onUploadVideoBeforeUpload: ve, onUploadVideoRemove: fe, onUploadVideoError: ge, ImgPond: _e };
489
489
  }
490
490
  });
491
491
  export {
492
- ra as default
492
+ sa as default
493
493
  };
package/es/index.js CHANGED
@@ -1,16 +1,17 @@
1
1
  import './style.css';
2
2
  import o from "./editor.vue.js";
3
- import { Button as s, Slider as i, Dialog as n, Upload as r, Tag as u, Form as m, FormItem as l, ButtonGroup as g, InputNumber as c, Loading as d } from "element-ui";
4
- import { getFileExtension as F, getImagePixel as I } from "./util.js";
5
- const b = {}, E = Object.assign(o, {
3
+ import { Button as s, Slider as i, Dialog as n, Upload as r, Tag as u, Form as m, FormItem as l, ButtonGroup as g, InputNumber as c, Loading as b } from "element-ui";
4
+ import { blobToFile as y, getFileExtension as I, getImagePixel as j } from "./util.js";
5
+ const d = {}, x = Object.assign(o, {
6
6
  install: (e, t) => {
7
- Object.assign(b, t || {}), e.use(s), e.use(i), e.use(n), e.use(r), e.use(u), e.use(m), e.use(l), e.use(g), e.use(c), e.use(d), e.component("KbTinymceEditor", o);
7
+ Object.assign(d, t || {}), e.use(s), e.use(i), e.use(n), e.use(r), e.use(u), e.use(m), e.use(l), e.use(g), e.use(c), e.use(b), e.component("KbTinymceEditor", o);
8
8
  }
9
9
  });
10
10
  export {
11
- E as TinymceEditor,
12
- E as default,
13
- F as getFileExtension,
14
- I as getImagePixel,
15
- b as globalProps
11
+ x as TinymceEditor,
12
+ y as blobToFile,
13
+ x as default,
14
+ I as getFileExtension,
15
+ j as getImagePixel,
16
+ d as globalProps
16
17
  };
package/es/types.d.ts CHANGED
@@ -17,7 +17,7 @@ export interface ImageUploadOptions {
17
17
  /** 图片最大高度 */
18
18
  maxHeight?: number;
19
19
  /** 图片上传请求处理 */
20
- handleRequest?: (file: File | Blob, filename: string, options?: {
20
+ handleRequest?: (file: File, filename: string, options?: {
21
21
  extParameters?: Record<string, any>;
22
22
  }) => Promise<{
23
23
  success: boolean;
package/es/util.d.ts CHANGED
@@ -12,3 +12,9 @@ export declare function getImagePixel(src: string): Promise<{
12
12
  * @param filename 文件名
13
13
  */
14
14
  export declare function getFileExtension(filename: string): string;
15
+ /**
16
+ * blob 转 file
17
+ * @param data
18
+ * @param filename
19
+ */
20
+ export declare function blobToFile(data: File | Blob, filename: string): File;
package/es/util.js CHANGED
@@ -1,18 +1,22 @@
1
- function o(e) {
1
+ function r(e) {
2
2
  return new Promise((n) => {
3
- const t = new Image();
4
- t.onload = function() {
5
- n({ width: t.width, height: t.height, image: t });
6
- }, t.onerror = function(i) {
3
+ const i = new Image();
4
+ i.onload = function() {
5
+ n({ width: i.width, height: i.height, image: i });
6
+ }, i.onerror = function(t) {
7
7
  n(void 0);
8
- }, t.src = e;
8
+ }, i.src = e;
9
9
  });
10
10
  }
11
- function r(e) {
11
+ function o(e) {
12
12
  const n = e.split(".");
13
13
  return n ? n[n.length - 1] : "";
14
14
  }
15
+ function u(e, n) {
16
+ return e.name ? e : new File([e], n, { type: e.type });
17
+ }
15
18
  export {
16
- r as getFileExtension,
17
- o as getImagePixel
19
+ u as blobToFile,
20
+ o as getFileExtension,
21
+ r as getImagePixel
18
22
  };
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.24",
5
+ "version": "0.0.12-alpha.26",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",
@@ -23,7 +23,7 @@
23
23
  "vue-global-config": "^0.2.6",
24
24
  "tinymce": "^7.1.0",
25
25
  "element-ui": "^2.15.14",
26
- "@keyblade/one-travel": "^2.0.2"
26
+ "@keyblade/one-travel": "^2.0.3"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "vue": "^2.7.0",