@itshixun/qckeditor-vue3 1.1.2 → 1.1.4
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 +91 -1
- package/dist/index.css +2 -2
- package/dist/index.d.ts +234 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3197 -3082
- package/dist/src/components/QCKClassic.vue.d.ts +89 -13
- package/dist/src/components/QCKClassic.vue.d.ts.map +1 -1
- package/dist/src/components/QCKEditor.vue.d.ts +57 -0
- package/dist/src/components/QCKEditor.vue.d.ts.map +1 -0
- package/dist/src/components/QCKEditorPro.vue.d.ts +90 -17
- package/dist/src/components/QCKEditorPro.vue.d.ts.map +1 -1
- package/dist/src/types.d.ts +10 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/headingConfig.d.ts +3 -0
- package/dist/src/utils/headingConfig.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Vue 3 组件库,用于 CKEditor 5 富文本编辑器。
|
|
4
4
|
|
|
5
|
+
> 本次更新为**文档补充**:将 `v1.1.1` ~ `v1.1.3` 期间已发布的能力完整收录进 README,便于查阅。
|
|
6
|
+
>
|
|
7
|
+
> 已收录的近期能力:
|
|
8
|
+
>
|
|
9
|
+
> - `QCKEditor` 组件,支持 `classic` / `inline` / `document` 三种编辑器类型(v1.1.3)
|
|
10
|
+
> - `dataNormalizer` 属性,透传 `CKEditor` / `QCKEditor` / `QCKClassic` / `QCKEditorPro`,用于格式化初始值与外部 `modelValue` 变更(v1.1.1 / v1.1.2)
|
|
11
|
+
> - `CKEditor` 与 `QCKContent` 的 `fontSize` 属性(px),通过 CSS 变量 `--ck-content-font-size` 应用
|
|
12
|
+
> - `QCKEditor` 默认合并「段落 + 标题 1~5」的标题配置与「标记(marker)」高亮配置,与历史版本行为保持一致
|
|
13
|
+
> - `QCKEditorPro` 的 `disableExit` 属性与 `exit-blocked` 事件,用于在编辑器内部异步操作(`PendingActions`)期间控制是否退出编辑模式
|
|
14
|
+
|
|
5
15
|
## 安装
|
|
6
16
|
|
|
7
17
|
```bash
|
|
@@ -54,6 +64,45 @@ const editorConfig = {
|
|
|
54
64
|
</script>
|
|
55
65
|
```
|
|
56
66
|
|
|
67
|
+
### 通用编辑器(QCKEditor)
|
|
68
|
+
|
|
69
|
+
支持三种编辑器类型,由 `type` prop 切换:
|
|
70
|
+
|
|
71
|
+
- `classic`(默认):经典编辑器,工具栏固定在顶部
|
|
72
|
+
- `inline`:行内编辑器,工具栏在选中内容时浮动显示
|
|
73
|
+
- `document`:文档编辑器(基于 `DecoupledEditor`),工具栏与编辑区分离挂载,高度自适应容器
|
|
74
|
+
|
|
75
|
+
`QCKEditor` 在用户传入 `config` 之上,预设了与历史版本一致的默认配置:
|
|
76
|
+
|
|
77
|
+
- **标题**:在官方「段落 + 标题 1~3」基础上扩展支持「标题 4 / 标题 5」(`heading4` / `heading5`),并通过 `src/styles/index.css` 统一定义了 h1~h5 字号样式
|
|
78
|
+
- **高亮(Highlight)**:仅提供「标记(marker)」一项,配套样式 `.marker-default`
|
|
79
|
+
|
|
80
|
+
用户 `config` 中显式提供的同名字段会覆盖默认配置(深度合并)。
|
|
81
|
+
|
|
82
|
+
```vue
|
|
83
|
+
<template>
|
|
84
|
+
<!-- 经典编辑器(默认) -->
|
|
85
|
+
<QCKEditor v-model="content" :config="editorConfig" />
|
|
86
|
+
|
|
87
|
+
<!-- 行内编辑器 -->
|
|
88
|
+
<QCKEditor v-model="content" type="inline" :config="editorConfig" />
|
|
89
|
+
|
|
90
|
+
<!-- 文档编辑器(工具栏与编辑区独立容器) -->
|
|
91
|
+
<QCKEditor v-model="content" type="document" :config="editorConfig" />
|
|
92
|
+
</template>
|
|
93
|
+
|
|
94
|
+
<script setup lang="ts">
|
|
95
|
+
import { ref } from 'vue';
|
|
96
|
+
import { QCKEditor } from '@itshixun/qckeditor-vue3';
|
|
97
|
+
import '@itshixun/qckeditor-vue3/dist/index.css';
|
|
98
|
+
|
|
99
|
+
const content = ref('');
|
|
100
|
+
const editorConfig = {
|
|
101
|
+
toolbar: ['bold', 'italic', 'link'],
|
|
102
|
+
};
|
|
103
|
+
</script>
|
|
104
|
+
```
|
|
105
|
+
|
|
57
106
|
### 经典编辑器(QCKClassic)
|
|
58
107
|
|
|
59
108
|
预配置的经典编辑器组件:
|
|
@@ -267,6 +316,23 @@ const editorConfig = {
|
|
|
267
316
|
| tagName | String | 'div' | 渲染标签 |
|
|
268
317
|
| disabled | Boolean | false | 是否禁用 |
|
|
269
318
|
| disableTwoWayDataBinding | Boolean | false | 禁用双向绑定 |
|
|
319
|
+
| dataNormalizer | Function | `(data) => data` | 格式化初始值与外部 `modelValue` 变更的函数 |
|
|
320
|
+
| fontSize | Number | - | 编辑区正文字号(px),通过 CSS 变量 `--ck-content-font-size` 应用 |
|
|
321
|
+
|
|
322
|
+
### QCKEditor
|
|
323
|
+
|
|
324
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
325
|
+
|------|------|--------|------|
|
|
326
|
+
| type | `'classic' \| 'inline' \| 'document'` | `'classic'` | 编辑器类型,非法值兜底为 `classic` |
|
|
327
|
+
| config | Object | {} | 编辑器配置(与默认 highlight / heading 配置深度合并) |
|
|
328
|
+
| tagName | String | 'div' | 渲染标签 |
|
|
329
|
+
| disabled | Boolean | false | 是否禁用 |
|
|
330
|
+
| disableTwoWayDataBinding | Boolean | false | 禁用双向绑定 |
|
|
331
|
+
| dataNormalizer | Function | `(data) => data` | 格式化初始值与外部 `modelValue` 变更的函数 |
|
|
332
|
+
|
|
333
|
+
默认配置说明:`QCKEditor` 预置了「段落 + 标题 1~5」的标题选项,以及「标记(marker)」高亮选项,与历史版本编辑器一致。用户 `config` 中显式提供同名字段会覆盖默认值。
|
|
334
|
+
|
|
335
|
+
`QCKEditor` 在 `ready` 等事件中传入的编辑器实例类型为 `ClassicEditor | InlineEditor | DecoupledEditor`(即 `QEditorInstance` 联合类型)。
|
|
270
336
|
|
|
271
337
|
### QCKClassic
|
|
272
338
|
|
|
@@ -276,6 +342,7 @@ const editorConfig = {
|
|
|
276
342
|
| tagName | String | 'div' | 渲染标签 |
|
|
277
343
|
| disabled | Boolean | false | 是否禁用 |
|
|
278
344
|
| disableTwoWayDataBinding | Boolean | false | 禁用双向绑定 |
|
|
345
|
+
| dataNormalizer | Function | `(data) => data` | 格式化初始值与外部 `modelValue` 变更的函数 |
|
|
279
346
|
|
|
280
347
|
### QCKEditorPro
|
|
281
348
|
|
|
@@ -292,6 +359,8 @@ const editorConfig = {
|
|
|
292
359
|
| borderRadius | Number | 4 | 圆角大小 |
|
|
293
360
|
| sanitize | Boolean | true | 是否清洗 HTML |
|
|
294
361
|
| imagePreview | Boolean \| Object | false | 预览态图片预览(见 QCKContent 图片预览说明) |
|
|
362
|
+
| dataNormalizer | Function | `(data) => data` | 格式化初始内容与外部变更的函数 |
|
|
363
|
+
| disableExit | Boolean | false | 外部禁用退出编辑模式;与编辑器内部异步操作(`PendingActions`)共同决定 `exit-blocked` |
|
|
295
364
|
|
|
296
365
|
### QCKContent
|
|
297
366
|
|
|
@@ -300,6 +369,9 @@ const editorConfig = {
|
|
|
300
369
|
| content | String | - | HTML 内容 |
|
|
301
370
|
| containerClass | String | '' | 容器类名 |
|
|
302
371
|
| sanitize | Boolean | true | 是否清洗 HTML |
|
|
372
|
+
| math | Boolean | true | 是否渲染 `span.math-tex` 中的 KaTeX 公式 |
|
|
373
|
+
| highlightCode | Boolean | true | 是否对 `pre code` 应用 highlight.js 高亮 |
|
|
374
|
+
| fontSize | Number | - | 渲染区正文字号(px),通过 CSS 变量 `--ck-content-font-size` 应用 |
|
|
303
375
|
| imagePreview | Boolean \| Object | false | 图片预览,true 或 QCKImagePreviewOptions 对象(见上文) |
|
|
304
376
|
|
|
305
377
|
## 事件
|
|
@@ -314,10 +386,22 @@ const editorConfig = {
|
|
|
314
386
|
| focus | (event, editor) | 获得焦点 |
|
|
315
387
|
| input | (data, event, editor) | 内容变化 |
|
|
316
388
|
|
|
389
|
+
`QCKEditorPro` 还会发出:
|
|
390
|
+
|
|
391
|
+
| 事件 | 参数 | 说明 |
|
|
392
|
+
|------|------|------|
|
|
393
|
+
| exit-blocked | (reason: `'pending-actions' \| 'prop'`) | 退出编辑模式被阻止。`pending-actions` 表示编辑器内部仍有异步操作(如上传未完成),`prop` 表示 `disableExit` 为 `true` |
|
|
394
|
+
|
|
317
395
|
## 类型导出
|
|
318
396
|
|
|
319
397
|
```typescript
|
|
320
|
-
import type {
|
|
398
|
+
import type {
|
|
399
|
+
Props,
|
|
400
|
+
ExtractEditorType,
|
|
401
|
+
QCKImagePreviewOptions,
|
|
402
|
+
QEditorType,
|
|
403
|
+
QEditorInstance,
|
|
404
|
+
} from '@itshixun/qckeditor-vue3';
|
|
321
405
|
```
|
|
322
406
|
|
|
323
407
|
## 注意事项
|
|
@@ -328,6 +412,12 @@ import type { Props, ExtractEditorType, QCKImagePreviewOptions } from '@itshixun
|
|
|
328
412
|
|
|
329
413
|
3. **HTML 清洗**: `QCKContent` 和 `QCKEditorPro` 默认开启 XSS 防护,会自动过滤危险标签和属性。
|
|
330
414
|
|
|
415
|
+
4. **`QCKEditor` 默认配置**: `QCKEditor` 会自动合并「段落 + 标题 1~5」的标题选项与「标记(marker)」高亮选项。覆盖方式:在 `config.heading.options` 或 `config.highlight.options` 中提供完整数组(lodash `merge` 按索引合并)。
|
|
416
|
+
|
|
417
|
+
5. **`dataNormalizer`**: 用于在写入编辑器前格式化内容(初始值与外部 `modelValue` 变更都会经过此函数)。返回值为字符串;常见用途:清理历史版本遗留的脏标签、统一空白与编码。
|
|
418
|
+
|
|
419
|
+
6. **异步操作与退出编辑**: `QCKEditorPro` 在 `PendingActions` 仍有任务时(即文件上传、撤销恢复队列非空等)会阻止退出编辑模式,并通过 `exit-blocked` 事件通知业务方。可结合 `disableExit` 强制阻止。
|
|
420
|
+
|
|
331
421
|
## License
|
|
332
422
|
|
|
333
423
|
MIT
|