@keyblade/tinymce-editor-vue2 0.0.12-alpha.4 → 0.0.12-alpha.41
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 +151 -68
- package/es/editor.vue.d.ts +25 -181
- package/es/editor.vue.js +20 -19
- package/es/editor.vue2.js +330 -248
- package/es/index.d.ts +85 -669
- package/es/index.js +12 -11
- package/es/style.css +1 -1
- package/es/types.d.ts +79 -0
- package/es/util.d.ts +13 -32
- package/es/util.js +20 -68
- package/package.json +3 -3
- package/src/index.ts +16 -31
- /package/es/{editor.vue3.js → style.less.js} +0 -0
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 {
|
|
5
|
-
const d = {},
|
|
6
|
-
install: (e,
|
|
7
|
-
Object.assign(d,
|
|
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 I, generateUUID as y, getFileExtension as U, getImagePixel as a } 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
|
-
|
|
12
|
-
|
|
13
|
-
x as
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
x as TinymceEditor,
|
|
12
|
+
I as blobToFile,
|
|
13
|
+
x as default,
|
|
14
|
+
y as generateUUID,
|
|
15
|
+
U as getFileExtension,
|
|
16
|
+
a as getImagePixel,
|
|
17
|
+
d as globalProps
|
|
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}.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,16 @@ 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;
|
|
21
|
+
export declare function generateUUID(): string;
|
package/es/util.js
CHANGED
|
@@ -1,75 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
});
|
|
1
|
+
function o(e) {
|
|
2
|
+
return new Promise((n) => {
|
|
3
|
+
const t = new Image();
|
|
4
|
+
t.onload = function() {
|
|
5
|
+
n({ width: t.width, height: t.height, image: t }), t.remove();
|
|
6
|
+
}, t.onerror = function(i) {
|
|
7
|
+
n(void 0), t.remove();
|
|
8
|
+
}, t.src = e;
|
|
44
9
|
});
|
|
45
10
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
i.onload = function() {
|
|
50
|
-
e({ width: i.width, height: i.height, image: i });
|
|
51
|
-
}, i.src = r;
|
|
52
|
-
});
|
|
11
|
+
function r(e) {
|
|
12
|
+
const n = e.split(".");
|
|
13
|
+
return n ? n[n.length - 1] : "";
|
|
53
14
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
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 });
|
|
15
|
+
function c(e, n) {
|
|
16
|
+
return e.name ? e : new File([e], n, { type: e.type });
|
|
61
17
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
t.onloadend = () => {
|
|
66
|
-
const s = t.result;
|
|
67
|
-
e(s);
|
|
68
|
-
}, t.onerror = i, t.readAsDataURL(r);
|
|
69
|
-
});
|
|
18
|
+
function g() {
|
|
19
|
+
const e = Date.now().toString(16), n = Math.random().toString(16).slice(2);
|
|
20
|
+
return `${e}-${n}`;
|
|
70
21
|
}
|
|
71
22
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
23
|
+
c as blobToFile,
|
|
24
|
+
g as generateUUID,
|
|
25
|
+
r as getFileExtension,
|
|
26
|
+
o as getImagePixel
|
|
75
27
|
};
|
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.41",
|
|
6
6
|
"private": false,
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "es/index.js",
|
|
@@ -20,10 +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
|
-
"element-ui": "^2.15.14"
|
|
25
|
+
"element-ui": "^2.15.14",
|
|
26
|
+
"@keyblade/one-travel": "^2.0.10"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"vue": "^2.7.0",
|
package/src/index.ts
CHANGED
|
@@ -1,41 +1,25 @@
|
|
|
1
|
-
import type {
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|