@keyblade/tinymce-editor-vue2 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. package/README.md +125 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -5,3 +5,128 @@
5
5
  yarn add @keyblade/tinymce-editor-vue2
6
6
  ```
7
7
 
8
+ ## 二、使用
9
+ ### 1.注入组件并设置全局属性
10
+ ```typescript
11
+ import TinymceEditor from '@keyblade/tinymce-editor-vue2'
12
+ Vue.use(TinymceEditor, {
13
+ message: {
14
+ // 注入 loading 方法
15
+ loading: () => {
16
+ const ins = Loading.service({ text: '加载中' })
17
+ return {
18
+ close: () => {
19
+ ins.close()
20
+ }
21
+ }
22
+ }
23
+ },
24
+ // 配置图片上传
25
+ imageUploadHandle: (file, filename) => {
26
+ return new Promise((resolve) => {
27
+ resolve({
28
+ success: true,
29
+ url: 'https://object.gcongo.com.cn/onecode-travel/nonClassic/8cefe379c03b5f39cd8ef725293a3c02/2024/5/1715995588295/d0b5bb458b694130be0c63e2f1d0090b.png'
30
+ })
31
+ })
32
+ }
33
+ })
34
+ ```
35
+
36
+ ### 2.使用组件
37
+ ```text
38
+ <template>
39
+ <TinymceEditor
40
+ ref="editorRef"
41
+ v-model="text"
42
+ :initComplete="initComplete"
43
+ />
44
+ </template>
45
+
46
+ <script setup lang="ts">
47
+ import { onMounted, ref } from 'vue'
48
+ import TinymceEditor from '@keyblade/tinymce-editor-vue2'
49
+
50
+ const text = ref<string>('')
51
+ const editorRef = ref()
52
+
53
+ // 组件加载完成
54
+ const initComplete = () => {
55
+ console.log(editorRef.value.insRef)
56
+ console.log(editorRef.value.editorRef)
57
+ }
58
+
59
+ onMounted(() => {
60
+ console.log('onMounted')
61
+ })
62
+ </script>
63
+ ```
64
+
65
+ ## 三、Api
66
+ ### 1.全局属性
67
+ ```typescript
68
+ interface TinymceEditorGlobalOptions {
69
+ // 消息方法实例
70
+ message?: {
71
+ // 加载中
72
+ loading?: (message?: string) => { close: () => void }
73
+ // 成功
74
+ success?: (message?: string) => void
75
+ // 错误提示
76
+ error?: (message?: string) => void
77
+ // 销毁
78
+ destroy?: () => void
79
+ }
80
+ /** 图片上传请求处理,需要返回图片地址 */
81
+ imageUploadHandle?: (file: File | Blob, filename: string) => Promise<{success: boolean; url?: string; errorMessage?: string}>;
82
+ /** 接着默认配置进行处理 */
83
+ paste_preprocess?: (editor: Editor, args: {
84
+ content: string;
85
+ readonly internal: boolean;
86
+ }) => void;
87
+ /** 接着默认配置进行处理 */
88
+ paste_postprocess?: (editor: Editor, args: {
89
+ node: HTMLElement;
90
+ readonly internal: boolean;
91
+ }) => void;
92
+ tinymceOptions?: RawEditorOptions
93
+ }
94
+ ```
95
+
96
+ ### 2.全局属性
97
+ ```typescript
98
+ interface ComponentProps {
99
+ /** vue2 v-model */
100
+ value?: string
101
+ /** vue3 v-model */
102
+ modelValue?: string
103
+ /** 图片最大值(单位M,主要用于错误提示) */
104
+ imageMaxSize?: number;
105
+ /** 图片允许的类型 */
106
+ imageAllowedType?: string[];
107
+ /** 图片最小宽度 */
108
+ imageMinWidth?: number;
109
+ /** 图片最小高度 */
110
+ imageMinHeight?: number;
111
+ /** 图片最大宽度 */
112
+ imageMaxWidth?: number;
113
+ /** 图片最大高度 */
114
+ imageMaxHeight?: number;
115
+ /** 图片上传请求处理,需要返回图片地址 */
116
+ imageUploadHandle?: (file: File | Blob, filename: string) => Promise<{success: boolean; url?: string; errorMessage?: string}>;
117
+ /** 接着默认配置进行处理 */
118
+ paste_preprocess?: (editor: Editor, args: {
119
+ content: string;
120
+ readonly internal: boolean;
121
+ }) => void;
122
+ /** 接着默认配置进行处理 */
123
+ paste_postprocess?: (editor: Editor, args: {
124
+ node: HTMLElement;
125
+ readonly internal: boolean;
126
+ }) => void;
127
+ /** 初始化完成 */
128
+ initComplete?: () => void,
129
+ /** 富文本编辑器选项 */
130
+ options?: Partial<RawEditorOptions>
131
+ }
132
+ ```
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.1",
5
+ "version": "0.0.2",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",