@keyblade/tinymce-editor-vue2 0.0.12-alpha.3 → 0.0.12-alpha.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/index.js CHANGED
@@ -1,17 +1,17 @@
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 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
+ install: (e, t) => {
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
- b as TinymceEditor,
12
- b as default,
13
- x as getImagePixel,
14
- d as globalProps,
15
- y as oneTravelImageCheck,
16
- E as oneTravelImageCompressor
11
+ x as TinymceEditor,
12
+ y as blobToFile,
13
+ x as default,
14
+ I as getFileExtension,
15
+ j as getImagePixel,
16
+ d as globalProps
17
17
  };
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}.tinymce-editor-loading-dialog{z-index:4000!important}.tinymce-editor-loading-dialog .el-dialog{margin-top:calc(50vh - 107px);width:388px;min-width:auto!important;height:214px;background-image:linear-gradient(-72deg,#d8faff,#fff);box-shadow:0 2px 20px #00000012;border-radius:16px}.tinymce-editor-loading-dialog .el-dialog .el-dialog__header{display:none!important}.tinymce-editor-loading-dialog .el-dialog .el-dialog__body{height:100%}.tinymce-editor-loading-dialog .el-dialog .el-dialog__body .tinymce-editor-loading-dialog-content{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center}.tinymce-editor-loading-dialog .el-dialog .el-dialog__body .tinymce-editor-loading-dialog-content span{margin-top:15px;font-size:16px;color:#1d2129;line-height:24px;font-weight:500}.tinymce-editor-spinner{width:60px;height:60px;position:relative;text-align:center;-webkit-animation:sk-rotate 2s infinite linear;animation:sk-rotate 2s infinite linear}.tinymce-editor-spinner-dot1,.tinymce-editor-spinner-dot2,.tinymce-editor-spinner-dot3{width:24px;height:24px;display:inline-block;position:absolute;top:0;background-color:#333;border-radius:100%;-webkit-animation:sk-bounce 2s infinite ease-in-out;animation:sk-bounce 2s infinite ease-in-out}.tinymce-editor-spinner-dot1{left:calc(50% - 12px);background-color:#5dff8e}.tinymce-editor-spinner-dot2{top:auto;bottom:0;right:0;-webkit-animation-delay:-1s;animation-delay:-1s;background-color:#21f4c7}.tinymce-editor-spinner-dot3{top:auto;bottom:0;left:0;-webkit-animation-delay:-1s;animation-delay:-1s;background-color:#98ff56}@-webkit-keyframes sk-rotate{to{-webkit-transform:rotate(360deg)}}@keyframes sk-rotate{to{transform:rotate(360deg);-webkit-transform:rotate(360deg)}}@-webkit-keyframes sk-bounce{0%,to{-webkit-transform:scale(0)}50%{-webkit-transform:scale(1)}}@keyframes sk-bounce{0%,to{transform:scale(0);-webkit-transform:scale(0)}50%{transform:scale(1);-webkit-transform:scale(1)}}
package/es/types.d.ts ADDED
@@ -0,0 +1,79 @@
1
+ /** 图片选项 */
2
+ export interface ImageUploadOptions {
3
+ /** 图片上传组件最大数量 */
4
+ maxCount?: number;
5
+ /** 图片上传组件下方文字 */
6
+ tipText?: string;
7
+ /** 图片最大值(单位M,主要用于错误提示) */
8
+ maxSize?: number;
9
+ /** 图片允许的后缀类型(小写,如: png、jpg) */
10
+ allowedType?: string[];
11
+ /** 图片最小宽度 */
12
+ minWidth?: number;
13
+ /** 图片最小高度 */
14
+ minHeight?: number;
15
+ /** 图片最大宽度 */
16
+ maxWidth?: number;
17
+ /** 图片最大高度 */
18
+ maxHeight?: number;
19
+ /** 图片上传请求处理 */
20
+ handleRequest?: (file: File, filename: string, options?: {
21
+ extParameters?: Record<string, any>;
22
+ }) => Promise<{
23
+ success: boolean;
24
+ url?: string;
25
+ errorMessage?: string;
26
+ }>;
27
+ }
28
+ /** 视频选项 */
29
+ export interface VideoUploadOptions {
30
+ /** 是否启用 */
31
+ enable?: boolean;
32
+ /** 最大尺寸(M) */
33
+ maxSize?: number;
34
+ /** 允许的后缀类型(小写,如: mp4) */
35
+ allowedType?: string[];
36
+ /** 上传地址(启用必传) */
37
+ action?: string;
38
+ /** 请求头 */
39
+ headers?: (parameters: {
40
+ file: File | Blob;
41
+ extParameters?: Record<string, any>;
42
+ }) => Record<string, any>;
43
+ /** 额外请求体 */
44
+ data?: (parameters: {
45
+ file: File | Blob;
46
+ extParameters?: Record<string, any>;
47
+ }) => Record<string, any>;
48
+ /** 响应处理(启用必传) */
49
+ handlerResponse?: (response: any) => {
50
+ url?: string;
51
+ errorMessage?: string;
52
+ };
53
+ }
54
+ /** 音频选项 */
55
+ export interface AudioUploadOptions {
56
+ /** 是否启用 */
57
+ enable?: boolean;
58
+ /** 最大尺寸(M) */
59
+ maxSize?: number;
60
+ /** 允许的后缀类型(小写,如: mp4) */
61
+ allowedType?: string[];
62
+ /** 上传地址(启用必传) */
63
+ action?: string;
64
+ /** 请求头 */
65
+ headers?: (parameters: {
66
+ file: File | Blob;
67
+ extParameters?: Record<string, any>;
68
+ }) => Record<string, any>;
69
+ /** 额外请求体 */
70
+ data?: (parameters: {
71
+ file: File | Blob;
72
+ extParameters?: Record<string, any>;
73
+ }) => Record<string, any>;
74
+ /** 响应处理(启用必传) */
75
+ handlerResponse?: (response: any) => {
76
+ url?: string;
77
+ errorMessage?: string;
78
+ };
79
+ }
package/es/util.d.ts CHANGED
@@ -1,34 +1,3 @@
1
- /**
2
- * 一码游图片检测
3
- */
4
- export declare function oneTravelImageCheck(data: File | Blob, options?: {
5
- imageMaxSize?: number;
6
- imageAllowedMineType?: string[];
7
- imageMinWidth?: number;
8
- imageMinHeight?: number;
9
- imageMaxWidth?: number;
10
- imageMaxHeight?: number;
11
- }): Promise<{
12
- /** 是否成功 */
13
- success: boolean;
14
- /** 处理完成的文件(有可能不需要处理) */
15
- file?: File | Blob;
16
- /** 失败 */
17
- error?: {
18
- size?: boolean;
19
- format?: boolean;
20
- pixel?: boolean;
21
- message?: string;
22
- };
23
- }>;
24
- /**
25
- * 一码游图片压缩
26
- */
27
- export declare function oneTravelImageCompressor(data: File | Blob): Promise<{
28
- file: File | Blob;
29
- success: boolean;
30
- errorMessage?: string;
31
- }>;
32
1
  /**
33
2
  * 获取图片像素
34
3
  * @param src url或 base64
@@ -37,4 +6,15 @@ export declare function getImagePixel(src: string): Promise<{
37
6
  width: number;
38
7
  height: number;
39
8
  image: HTMLImageElement;
40
- }>;
9
+ } | undefined>;
10
+ /**
11
+ * 获取文件扩展名
12
+ * @param filename 文件名
13
+ */
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,75 +1,22 @@
1
- import f from "compressorjs";
2
- async function d(r, e) {
3
- const {
4
- imageMaxSize: i = 30,
5
- imageAllowedMineType: t = ["image/jpg", "image/jpeg", "image/png", "image/bmp", "image/heif", "image/heic", "image/gif", "image/webp"],
6
- imageMinWidth: s = 60,
7
- imageMinHeight: n = 60,
8
- imageMaxWidth: o = 6e3,
9
- imageMaxHeight: a = 6e3
10
- } = e || {}, c = r, l = await u(c);
11
- if (c.size > i * 1024 * 1024)
12
- return { success: !1, error: { size: !0 } };
13
- if (!t.includes(c.type))
14
- return { success: !1, error: { format: !0 } };
15
- const m = await g(l);
16
- return m.width < s && m.height < n || m.width > o && m.height > a ? { success: !1, error: { pixel: !0 } } : { success: !0, file: c };
17
- }
18
- async function y(r) {
19
- var o;
20
- let e = r;
21
- const i = await u(e), t = await g(i), s = {};
22
- ["image/heif", "image/heic", "image/webp"].includes(e.type) && (s.convertTypes = [e.type], s.convertSize = 0);
23
- const n = 5 * 1024 * 1024;
24
- if (e.size > n && (s.convertTypes = [e.type], s.convertSize = n, s.maxWidth = t.width * (n / e.size)), Object.keys(s).length > 0) {
25
- const a = await h(p(i), s);
26
- if (a.success)
27
- e = a.file;
28
- else
29
- return { file: e, success: !1, errorMessage: (o = a.error) == null ? void 0 : o.message };
30
- }
31
- return { file: e, success: !0 };
32
- }
33
- function h(r, e) {
34
- return new Promise((i) => {
35
- new f(r, {
36
- ...e,
37
- success: async (t) => {
38
- i({ success: !0, file: t });
39
- },
40
- error(t) {
41
- i({ success: !1, error: t });
42
- }
43
- });
44
- });
45
- }
46
- function g(r) {
47
- return new Promise((e) => {
1
+ function r(e) {
2
+ return new Promise((n) => {
48
3
  const i = new Image();
49
4
  i.onload = function() {
50
- e({ width: i.width, height: i.height, image: i });
51
- }, i.src = r;
5
+ n({ width: i.width, height: i.height, image: i });
6
+ }, i.onerror = function(t) {
7
+ n(void 0);
8
+ }, i.src = e;
52
9
  });
53
10
  }
54
- function p(r) {
55
- const e = r.split(","), i = e[0].match(/:(.*?);/)[1], t = atob(e[1]);
56
- let s = t.length;
57
- const n = new Uint8Array(s);
58
- for (; s--; )
59
- n[s] = t.charCodeAt(s);
60
- return new Blob([n], { type: i });
11
+ function o(e) {
12
+ const n = e.split(".");
13
+ return n ? n[n.length - 1] : "";
61
14
  }
62
- function u(r) {
63
- return new Promise((e, i) => {
64
- const t = new FileReader();
65
- t.onloadend = () => {
66
- const s = t.result;
67
- e(s);
68
- }, t.onerror = i, t.readAsDataURL(r);
69
- });
15
+ function u(e, n) {
16
+ return e.name ? e : new File([e], n, { type: e.type });
70
17
  }
71
18
  export {
72
- g as getImagePixel,
73
- d as oneTravelImageCheck,
74
- y as oneTravelImageCompressor
19
+ u as blobToFile,
20
+ o as getFileExtension,
21
+ r as getImagePixel
75
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.03",
5
+ "version": "0.0.12-alpha.31",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",
@@ -20,11 +20,10 @@
20
20
  "*.css"
21
21
  ],
22
22
  "dependencies": {
23
- "compressorjs": "^1.2.1",
24
23
  "vue-global-config": "^0.2.6",
25
24
  "tinymce": "^7.1.0",
26
- "imgpond": "^0.6.2",
27
- "element-ui": "^2.15.14"
25
+ "element-ui": "^2.15.14",
26
+ "@keyblade/one-travel": "^2.0.3"
28
27
  },
29
28
  "peerDependencies": {
30
29
  "vue": "^2.7.0",
package/src/index.ts CHANGED
@@ -1,41 +1,25 @@
1
- import type { Editor, RawEditorOptions } from 'tinymce'
1
+ import type { 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
+ import { AudioUploadOptions, ImageUploadOptions, VideoUploadOptions } from './types'
6
7
 
7
8
  interface TinymceEditorGlobalOptions {
8
- /** 图片上传请求处理,需要返回图片地址 */
9
- imageUploadHandle?: (file: File | Blob, filename: string, options?: {
10
- extParameters?: Record<string, any>
11
- }) => Promise<{success: boolean; url?: string; errorMessage?: string}>;
12
- /** 接着默认配置进行处理 */
13
- paste_preprocess?: (editor: Editor, args: {
14
- content: string;
15
- readonly internal: boolean;
16
- }) => void;
17
- /** 接着默认配置进行处理 */
18
- paste_postprocess?: (editor: Editor, args: {
19
- node: HTMLElement;
20
- readonly internal: boolean;
21
- }) => void;
22
- tinymceOptions?: RawEditorOptions;
23
- /** imgPond 选项 */
24
- imgPondOptions?: Record<string, any>
9
+ /** 富文本编辑器选项 */
10
+ options?: RawEditorOptions;
11
+
12
+ /** 图片上传选项 */
13
+ imageUploadOptions?: ImageUploadOptions;
14
+
15
+ /** imgPond选项 */
16
+ imgPondOptions?: Record<string, any>;
17
+
25
18
  /** 音频上传选项 */
26
- audioUploadOptions?: {
27
- action: string;
28
- handlerResponse: (response: any) => { url?: string; errorMessage?: string }
29
- headers?: Record<string, any>;
30
- data?: Record<string, any>;
31
- },
19
+ audioUploadOptions?: AudioUploadOptions;
20
+
32
21
  /** 视频上传选项 */
33
- videoUploadOptions?: {
34
- action: string;
35
- handlerResponse: (response: any) => { url?: string; errorMessage?: string }
36
- headers?: Record<string, any>;
37
- data?: Record<string, any>;
38
- }
22
+ videoUploadOptions?: VideoUploadOptions;
39
23
  }
40
24
 
41
25
  // 全局属性
@@ -55,6 +39,7 @@ const TinymceEditor = Object.assign(_TinymceEditor, {
55
39
  app.use(Form)
56
40
  app.use(FormItem)
57
41
  app.use(ButtonGroup)
42
+ app.use(InputNumber)
58
43
  app.use(Loading)
59
44
 
60
45
  // 注册组件
File without changes