@keyblade/tinymce-editor-vue2 0.0.11 → 0.0.12-alpha.3
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 +13 -13
- package/es/editor.vue.d.ts +89 -3
- package/es/editor.vue.js +18 -11
- package/es/editor.vue2.js +279 -124
- package/es/index.d.ts +407 -86
- package/es/index.js +11 -6
- package/es/style.css +1 -1
- package/es/util.d.ts +40 -0
- package/es/util.js +75 -0
- package/package.json +7 -3
- package/src/index.ts +35 -12
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
## 一、安装
|
|
5
5
|
```shell
|
|
6
6
|
yarn add @keyblade/tinymce-editor-vue2
|
|
7
|
+
yarn add pic-viewer@0.5.1 (如项目中有,怎不需要再次安装)
|
|
8
|
+
yarn add imgpond@0.6.2 (如项目中有,怎不需要再次安装)
|
|
7
9
|
```
|
|
8
10
|
|
|
9
11
|
## 二、使用
|
|
@@ -11,20 +13,18 @@ yarn add @keyblade/tinymce-editor-vue2
|
|
|
11
13
|
```typescript
|
|
12
14
|
import TinymceEditor from '@keyblade/tinymce-editor-vue2'
|
|
13
15
|
|
|
16
|
+
// 如原项目中,则不需要
|
|
17
|
+
import PicViewer from 'pic-viewer'
|
|
18
|
+
import 'pic-viewer/dist/style.css'
|
|
19
|
+
|
|
20
|
+
// 如原项目中,则不需要
|
|
21
|
+
import ImgPond from 'imgpond'
|
|
22
|
+
import 'imgpond/dist/style.css'
|
|
23
|
+
|
|
24
|
+
Vue.use(PicViewer, {})
|
|
25
|
+
Vue.use(ImgPond, {})
|
|
26
|
+
|
|
14
27
|
Vue.use(TinymceEditor, {
|
|
15
|
-
// 配置消息提示
|
|
16
|
-
message: {
|
|
17
|
-
// 注入 loading 方法
|
|
18
|
-
loading: () => {
|
|
19
|
-
// 可以使用项目中的UI组件,这里以ElementUI为例
|
|
20
|
-
const ins = Loading.service({ text: '加载中' })
|
|
21
|
-
return {
|
|
22
|
-
close: () => {
|
|
23
|
-
ins.close()
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
28
|
// 配置图片上传
|
|
29
29
|
imageUploadHandle: (file, filename, { extParameters }) => {
|
|
30
30
|
return new Promise((resolve) => {
|
package/es/editor.vue.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
9
9
|
disabled?: boolean | undefined;
|
|
10
10
|
/** 额外参数 */
|
|
11
11
|
extParameters?: Record<string, any> | undefined;
|
|
12
|
+
/** 图片上传组件最大数量 */
|
|
13
|
+
imageUploadMaxCount?: number | undefined;
|
|
14
|
+
/** 图片上传提示 */
|
|
15
|
+
imageUploadTip?: string | undefined;
|
|
12
16
|
/** 图片最大值(单位M,主要用于错误提示) */
|
|
13
17
|
imageMaxSize?: number | undefined;
|
|
14
18
|
/** 图片允许的类型 */
|
|
@@ -23,6 +27,34 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
23
27
|
imageMaxWidth?: number | undefined;
|
|
24
28
|
/** 图片最大高度 */
|
|
25
29
|
imageMaxHeight?: number | undefined;
|
|
30
|
+
/** 音频最大尺寸(M) */
|
|
31
|
+
audioMaxSize?: number | undefined;
|
|
32
|
+
/** 音频结尾格式 */
|
|
33
|
+
audioAllowedType?: string[] | undefined;
|
|
34
|
+
/** 音频上传选项 */
|
|
35
|
+
audioUploadOptions?: {
|
|
36
|
+
action: string;
|
|
37
|
+
handlerResponse: (response: any) => {
|
|
38
|
+
url?: string;
|
|
39
|
+
errorMessage?: string;
|
|
40
|
+
};
|
|
41
|
+
headers?: Record<string, any> | undefined;
|
|
42
|
+
data?: Record<string, any> | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
/** 视频最大尺寸(M) */
|
|
45
|
+
videoMaxSize?: number | undefined;
|
|
46
|
+
/** 视频结尾格式 */
|
|
47
|
+
videoAllowedType?: string[] | undefined;
|
|
48
|
+
/** 视频上传选项 */
|
|
49
|
+
videoUploadOptions?: {
|
|
50
|
+
action: string;
|
|
51
|
+
handlerResponse: (response: any) => {
|
|
52
|
+
url?: string;
|
|
53
|
+
errorMessage?: string;
|
|
54
|
+
};
|
|
55
|
+
headers?: Record<string, any> | undefined;
|
|
56
|
+
data?: Record<string, any> | undefined;
|
|
57
|
+
} | undefined;
|
|
26
58
|
/** 图片上传请求处理,需要返回图片地址 */
|
|
27
59
|
imageUploadHandle?: ((file: File | Blob, filename: string, options?: {
|
|
28
60
|
extParameters?: Record<string, any>;
|
|
@@ -47,9 +79,13 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
47
79
|
}) => void) | undefined;
|
|
48
80
|
/** 富文本编辑器选项 */
|
|
49
81
|
options?: Partial<RawEditorOptions> | undefined;
|
|
82
|
+
/** imgPond 选项 */
|
|
83
|
+
imgPondOptions?: Record<string, any> | undefined;
|
|
50
84
|
}>, {
|
|
51
85
|
value: string;
|
|
52
86
|
modelValue: string;
|
|
87
|
+
imageUploadMaxCount: number;
|
|
88
|
+
imageUploadTip: string;
|
|
53
89
|
imageMaxSize: number;
|
|
54
90
|
imageAllowedType: () => string[];
|
|
55
91
|
imageAllowedMineType: () => string[];
|
|
@@ -57,6 +93,10 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
57
93
|
imageMinHeight: number;
|
|
58
94
|
imageMaxWidth: number;
|
|
59
95
|
imageMaxHeight: number;
|
|
96
|
+
audioMaxSize: number;
|
|
97
|
+
videoMaxSize: number;
|
|
98
|
+
audioAllowedType: () => string[];
|
|
99
|
+
videoAllowedType: () => string[];
|
|
60
100
|
options: () => {};
|
|
61
101
|
}>, {}, {}, {}, {}, import('vue/types/v3-component-options').ComponentOptionsMixin, import('vue/types/v3-component-options').ComponentOptionsMixin, {
|
|
62
102
|
input: (value: string) => void;
|
|
@@ -70,6 +110,10 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
70
110
|
disabled?: boolean | undefined;
|
|
71
111
|
/** 额外参数 */
|
|
72
112
|
extParameters?: Record<string, any> | undefined;
|
|
113
|
+
/** 图片上传组件最大数量 */
|
|
114
|
+
imageUploadMaxCount?: number | undefined;
|
|
115
|
+
/** 图片上传提示 */
|
|
116
|
+
imageUploadTip?: string | undefined;
|
|
73
117
|
/** 图片最大值(单位M,主要用于错误提示) */
|
|
74
118
|
imageMaxSize?: number | undefined;
|
|
75
119
|
/** 图片允许的类型 */
|
|
@@ -84,6 +128,34 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
84
128
|
imageMaxWidth?: number | undefined;
|
|
85
129
|
/** 图片最大高度 */
|
|
86
130
|
imageMaxHeight?: number | undefined;
|
|
131
|
+
/** 音频最大尺寸(M) */
|
|
132
|
+
audioMaxSize?: number | undefined;
|
|
133
|
+
/** 音频结尾格式 */
|
|
134
|
+
audioAllowedType?: string[] | undefined;
|
|
135
|
+
/** 音频上传选项 */
|
|
136
|
+
audioUploadOptions?: {
|
|
137
|
+
action: string;
|
|
138
|
+
handlerResponse: (response: any) => {
|
|
139
|
+
url?: string;
|
|
140
|
+
errorMessage?: string;
|
|
141
|
+
};
|
|
142
|
+
headers?: Record<string, any> | undefined;
|
|
143
|
+
data?: Record<string, any> | undefined;
|
|
144
|
+
} | undefined;
|
|
145
|
+
/** 视频最大尺寸(M) */
|
|
146
|
+
videoMaxSize?: number | undefined;
|
|
147
|
+
/** 视频结尾格式 */
|
|
148
|
+
videoAllowedType?: string[] | undefined;
|
|
149
|
+
/** 视频上传选项 */
|
|
150
|
+
videoUploadOptions?: {
|
|
151
|
+
action: string;
|
|
152
|
+
handlerResponse: (response: any) => {
|
|
153
|
+
url?: string;
|
|
154
|
+
errorMessage?: string;
|
|
155
|
+
};
|
|
156
|
+
headers?: Record<string, any> | undefined;
|
|
157
|
+
data?: Record<string, any> | undefined;
|
|
158
|
+
} | undefined;
|
|
87
159
|
/** 图片上传请求处理,需要返回图片地址 */
|
|
88
160
|
imageUploadHandle?: ((file: File | Blob, filename: string, options?: {
|
|
89
161
|
extParameters?: Record<string, any>;
|
|
@@ -108,9 +180,13 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
108
180
|
}) => void) | undefined;
|
|
109
181
|
/** 富文本编辑器选项 */
|
|
110
182
|
options?: Partial<RawEditorOptions> | undefined;
|
|
183
|
+
/** imgPond 选项 */
|
|
184
|
+
imgPondOptions?: Record<string, any> | undefined;
|
|
111
185
|
}>, {
|
|
112
186
|
value: string;
|
|
113
187
|
modelValue: string;
|
|
188
|
+
imageUploadMaxCount: number;
|
|
189
|
+
imageUploadTip: string;
|
|
114
190
|
imageMaxSize: number;
|
|
115
191
|
imageAllowedType: () => string[];
|
|
116
192
|
imageAllowedMineType: () => string[];
|
|
@@ -118,17 +194,27 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
118
194
|
imageMinHeight: number;
|
|
119
195
|
imageMaxWidth: number;
|
|
120
196
|
imageMaxHeight: number;
|
|
197
|
+
audioMaxSize: number;
|
|
198
|
+
videoMaxSize: number;
|
|
199
|
+
audioAllowedType: () => string[];
|
|
200
|
+
videoAllowedType: () => string[];
|
|
121
201
|
options: () => {};
|
|
122
202
|
}>>>, {
|
|
123
|
-
value: string;
|
|
124
|
-
modelValue: string;
|
|
125
203
|
imageMaxSize: number;
|
|
126
|
-
imageAllowedType: string[];
|
|
127
204
|
imageAllowedMineType: string[];
|
|
128
205
|
imageMinWidth: number;
|
|
129
206
|
imageMinHeight: number;
|
|
130
207
|
imageMaxWidth: number;
|
|
131
208
|
imageMaxHeight: number;
|
|
209
|
+
value: string;
|
|
210
|
+
modelValue: string;
|
|
211
|
+
imageUploadMaxCount: number;
|
|
212
|
+
imageUploadTip: string;
|
|
213
|
+
imageAllowedType: string[];
|
|
214
|
+
audioMaxSize: number;
|
|
215
|
+
audioAllowedType: string[];
|
|
216
|
+
videoMaxSize: number;
|
|
217
|
+
videoAllowedType: string[];
|
|
132
218
|
options: Partial<RawEditorOptions>;
|
|
133
219
|
}>;
|
|
134
220
|
export default _default;
|
package/es/editor.vue.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import d from "./editor.vue2.js";
|
|
2
2
|
import "./editor.vue3.js";
|
|
3
|
-
import
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
}, o
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import s from "./_virtual/_plugin-vue2_normalizer.js";
|
|
4
|
+
var r = function() {
|
|
5
|
+
var l, i, u;
|
|
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", size: e.imageMaxSize, count: e.imageUploadMaxCount, upload: o.onImageUploadUpload }, model: { value: o.uploadImage.formData.images, callback: function(t) {
|
|
8
|
+
e.$set(o.uploadImage.formData, "images", t);
|
|
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
|
+
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, count: 1, upload: o.onImageUploadUpload }, model: { value: o.uploadAudio.formData.cover, callback: function(t) {
|
|
12
|
+
e.$set(o.uploadAudio.formData, "cover", t);
|
|
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: (i = o.mergeAudioUploadOptions) == null ? void 0 : i.data, accept: "audio/*", "list-type": "headTextContent", "before-upload": o.onUploadAudioBeforeUpload, headers: (u = o.mergeAudioUploadOptions) == null ? void 0 : u.headers, "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.mergeVideoUploadOptions.data, accept: "video/*", "list-type": "headTextContent", "before-upload": o.onUploadVideoBeforeUpload, headers: o.mergeVideoUploadOptions.headers, "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
|
+
}, p = [], n = /* @__PURE__ */ s(
|
|
15
|
+
d,
|
|
16
|
+
r,
|
|
17
|
+
p
|
|
11
18
|
);
|
|
12
|
-
const
|
|
19
|
+
const F = n.exports;
|
|
13
20
|
export {
|
|
14
|
-
|
|
21
|
+
F as default
|
|
15
22
|
};
|