@itshixun/qckeditor-vue3 1.0.0

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 ADDED
@@ -0,0 +1,191 @@
1
+ # @itshixun/qckeditor-vue3
2
+
3
+ Vue 3 组件库,用于 CKEditor 5 富文本编辑器。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install @itshixun/qckeditor-vue3
9
+ # 或
10
+ pnpm add @itshixun/qckeditor-vue3
11
+ # 或
12
+ yarn add @itshixun/qckeditor-vue3
13
+ ```
14
+
15
+ ### 对等依赖
16
+
17
+ 本库需要以下对等依赖:
18
+
19
+ ```bash
20
+ npm install vue@^3.0.0 ckeditor5@>=42.0.0
21
+ ```
22
+
23
+ ## 使用
24
+
25
+ ### 引入样式
26
+
27
+ 在使用组件前,需要先引入 CKEditor 的样式文件:
28
+
29
+ ```typescript
30
+ import 'ckeditor5/ckeditor5.css';
31
+ ```
32
+
33
+ ### 基础编辑器(CKEditor)
34
+
35
+ 底层 CKEditor 封装组件,支持任意 CKEditor 构建:
36
+
37
+ ```vue
38
+ <template>
39
+ <CKEditor v-model="content" :editor="ClassicEditor" :config="editorConfig" />
40
+ </template>
41
+
42
+ <script setup lang="ts">
43
+ import { ref } from 'vue';
44
+ import { ClassicEditor } from 'ckeditor5';
45
+ import { CKEditor } from '@itshixun/qckeditor-vue3';
46
+ import 'ckeditor5/ckeditor5.css';
47
+
48
+ const content = ref('');
49
+ const editorConfig = {
50
+ toolbar: ['bold', 'italic', 'link', 'bulletedList', 'numberedList'],
51
+ };
52
+ </script>
53
+ ```
54
+
55
+ ### 经典编辑器(QCKClassic)
56
+
57
+ 预配置的经典编辑器组件:
58
+
59
+ ```vue
60
+ <template>
61
+ <QCKClassic v-model="content" :config="editorConfig" />
62
+ </template>
63
+
64
+ <script setup lang="ts">
65
+ import { ref } from 'vue';
66
+ import { QCKClassic } from '@itshixun/qckeditor-vue3';
67
+ import 'ckeditor5/ckeditor5.css';
68
+
69
+ const content = ref('');
70
+ const editorConfig = {
71
+ toolbar: ['bold', 'italic', 'link'],
72
+ };
73
+ </script>
74
+ ```
75
+
76
+ ### 专业版编辑器(QCKEditorPro)
77
+
78
+ 点击激活的编辑器,提升页面性能:
79
+
80
+ ```vue
81
+ <template>
82
+ <QCKEditorPro
83
+ v-model="content"
84
+ :config="editorConfig"
85
+ placeholder="点击编辑内容"
86
+ :min-height="100"
87
+ />
88
+ </template>
89
+
90
+ <script setup lang="ts">
91
+ import { ref } from 'vue';
92
+ import { QCKEditorPro } from '@itshixun/qckeditor-vue3';
93
+ import 'ckeditor5/ckeditor5.css';
94
+
95
+ const content = ref('');
96
+ const editorConfig = {
97
+ toolbar: ['bold', 'italic'],
98
+ };
99
+ </script>
100
+ ```
101
+
102
+ ### 内容展示(QCKContent)
103
+
104
+ 安全渲染编辑器内容:
105
+
106
+ ```vue
107
+ <template>
108
+ <QCKContent :content="htmlContent" />
109
+ </template>
110
+
111
+ <script setup lang="ts">
112
+ import { QCKContent } from '@itshixun/qckeditor-vue3';
113
+ import 'ckeditor5/ckeditor5.css';
114
+
115
+ const htmlContent = '<p>Hello <strong>World</strong></p>';
116
+ </script>
117
+ ```
118
+
119
+ ## Props
120
+
121
+ ### CKEditor
122
+
123
+ | 属性 | 类型 | 默认值 | 说明 |
124
+ |------|------|--------|------|
125
+ | editor | Function | 必填 | CKEditor 构建类 |
126
+ | config | Object | {} | 编辑器配置 |
127
+ | tagName | String | 'div' | 渲染标签 |
128
+ | disabled | Boolean | false | 是否禁用 |
129
+ | disableTwoWayDataBinding | Boolean | false | 禁用双向绑定 |
130
+
131
+ ### QCKClassic
132
+
133
+ | 属性 | 类型 | 默认值 | 说明 |
134
+ |------|------|--------|------|
135
+ | config | Object | {} | 编辑器配置 |
136
+ | tagName | String | 'div' | 渲染标签 |
137
+ | disabled | Boolean | false | 是否禁用 |
138
+ | disableTwoWayDataBinding | Boolean | false | 禁用双向绑定 |
139
+
140
+ ### QCKEditorPro
141
+
142
+ | 属性 | 类型 | 默认值 | 说明 |
143
+ |------|------|--------|------|
144
+ | config | Object | {} | 编辑器配置 |
145
+ | content | String | - | 初始内容 |
146
+ | placeholder | String | '点击编辑内容' | 占位文本 |
147
+ | minHeight | Number | 95 | 最小高度(px) |
148
+ | height | Number | 0 | 固定高度(px) |
149
+ | fitHeight | Boolean | false | 适应父容器高度 |
150
+ | contentBgColor | String | 'rgb(0 0 0 / 2%)' | 背景色 |
151
+ | contentBgHoverColor | String | 'rgb(0 0 0 / 4%)' | 悬停背景色 |
152
+ | borderRadius | Number | 4 | 圆角大小 |
153
+ | sanitize | Boolean | true | 是否清洗 HTML |
154
+
155
+ ### QCKContent
156
+
157
+ | 属性 | 类型 | 默认值 | 说明 |
158
+ |------|------|--------|------|
159
+ | content | String | - | HTML 内容 |
160
+ | containerClass | String | '' | 容器类名 |
161
+ | sanitize | Boolean | true | 是否清洗 HTML |
162
+
163
+ ## 事件
164
+
165
+ 所有编辑器组件都支持以下事件:
166
+
167
+ | 事件 | 参数 | 说明 |
168
+ |------|------|------|
169
+ | ready | (editor) | 编辑器就绪 |
170
+ | destroy | - | 编辑器销毁 |
171
+ | blur | (event, editor) | 失去焦点 |
172
+ | focus | (event, editor) | 获得焦点 |
173
+ | input | (data, event, editor) | 内容变化 |
174
+
175
+ ## 类型导出
176
+
177
+ ```typescript
178
+ import type { Props, ExtractEditorType } from '@itshixun/qckeditor-vue3';
179
+ ```
180
+
181
+ ## 注意事项
182
+
183
+ 1. **CKEditor 授权**: 本库使用 CKEditor 5 的 GPL 授权。如需商业使用,请购买 [CKEditor 商业授权](https://ckeditor.com/pricing/)。
184
+
185
+ 2. **样式文件**: 必须导入 `ckeditor5/ckeditor5.css` 以确保编辑器样式正确。
186
+
187
+ 3. **HTML 清洗**: `QCKContent` 和 `QCKEditorPro` 默认开启 XSS 防护,会自动过滤危险标签和属性。
188
+
189
+ ## License
190
+
191
+ MIT