npmapps 1.0.24 → 1.0.26
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/app/.codegraph/daemon.pid +6 -0
- package/app/.eslintrc.js +19 -0
- package/app/README.md +24 -0
- package/app/babel.config.js +5 -0
- package/app/devtool-windows-amd64.zip +0 -0
- package/app/docs/superpowers/plans/2026-05-29-quill-editor.md +836 -0
- package/app/docs/superpowers/specs/2026-05-29-quill-editor-design.md +210 -0
- package/app/docs/superpowers/specs/2026-06-06-lazy-cascader-design.md +400 -0
- package/app/jsconfig.json +19 -0
- package/app/package-lock.json +21347 -0
- package/app/package.json +63 -0
- package/app/postcss.config.js +10 -0
- package/app/public/favicon.ico +0 -0
- package/app/public/index.html +17 -0
- package/app/public//344/270/200/351/224/256/351/273/221/346/232/227.html +136 -0
- package/app/src/App.vue +110 -0
- package/app/src/assets/bpmn-camunda.jpg +0 -0
- package/app/src/assets/css/diagram.less +17 -0
- package/app/src/assets/icon/Icon.less +31 -0
- package/app/src/assets/icon/font/app-codes.css +26 -0
- package/app/src/assets/icon/font/app.eot +0 -0
- package/app/src/assets/icon/font/app.svg +60 -0
- package/app/src/assets/icon/font/app.ttf +0 -0
- package/app/src/assets/icon/font/app.woff +0 -0
- package/app/src/assets/icon/font/app.woff2 +0 -0
- package/app/src/assets/icon/font/config.json +248 -0
- package/app/src/assets/icon/font/source/raw/align-bottom-tool.svg +30 -0
- package/app/src/assets/icon/font/source/raw/align-horizontal-center-tool.svg +85 -0
- package/app/src/assets/icon/font/source/raw/align-left-tool.svg +84 -0
- package/app/src/assets/icon/font/source/raw/align-right-tool.svg +80 -0
- package/app/src/assets/icon/font/source/raw/align-top-tool.svg +84 -0
- package/app/src/assets/icon/font/source/raw/align-vertical-center-tool.svg +89 -0
- package/app/src/assets/icon/font/source/raw/distribute-horizontally-tool.svg +95 -0
- package/app/src/assets/icon/font/source/raw/distribute-vertically-tool.svg +99 -0
- package/app/src/assets/icon/font/source/raw/set-color-tool.svg +111 -0
- package/app/src/assets/icon/font/source/symbols/align-bottom-tool.svg +30 -0
- package/app/src/assets/icon/font/source/symbols/align-horizontal-center-tool.svg +30 -0
- package/app/src/assets/icon/font/source/symbols/align-left-tool.svg +30 -0
- package/app/src/assets/icon/font/source/symbols/align-right-tool.svg +30 -0
- package/app/src/assets/icon/font/source/symbols/align-top-tool.svg +30 -0
- package/app/src/assets/icon/font/source/symbols/align-vertical-center-tool.svg +30 -0
- package/app/src/assets/icon/font/source/symbols/distribute-horizontally-tool.svg +30 -0
- package/app/src/assets/icon/font/source/symbols/distribute-vertically-tool.svg +30 -0
- package/app/src/assets/icon/font/source/symbols/set-color-tool.svg +63 -0
- package/app/src/assets/logo.png +0 -0
- package/app/src/components/EllTable/README.md +70 -0
- package/app/src/components/EllTable/article.md +184 -0
- package/app/src/components/EllTable/index.js +213 -0
- package/app/src/components/FormulaEditor/FunctionSelector.vue +123 -0
- package/app/src/components/FormulaEditor/OperatorSelector.vue +184 -0
- package/app/src/components/FormulaEditor/ParameterSelector.vue +123 -0
- package/app/src/components/FormulaEditor/api.js +69 -0
- package/app/src/components/FormulaEditor/index.vue +435 -0
- package/app/src/components/HelloWorld.vue +58 -0
- package/app/src/components/PageHeader/index.vue +158 -0
- package/app/src/components/Splitter/README.md +144 -0
- package/app/src/components/Splitter/example.vue +88 -0
- package/app/src/components/Splitter/index.vue +203 -0
- package/app/src/components/diagram/ToolBar.vue +357 -0
- package/app/src/components/diagram/customTranslate/customTranslate.js +12 -0
- package/app/src/components/diagram/customTranslate/translationsGerman.js +241 -0
- package/app/src/components/diagram/index.vue +261 -0
- package/app/src/components/diagram/xmlData.js +29 -0
- package/app/src/directives/filldown.js +155 -0
- package/app/src/directives/filldownTable.js +291 -0
- package/app/src/main.js +40 -0
- package/app/src/router/index.js +63 -0
- package/app/src/store/index.js +23 -0
- package/app/src/utils/winBox.js +23 -0
- package/app/src/views/Extend/A.vue +12 -0
- package/app/src/views/Extend/B.vue +10 -0
- package/app/src/views/Extend/MagicalComponentsForELFormItem.vue +87 -0
- package/app/src/views/Extend/index.vue +59 -0
- package/app/src/views/Extend/tableMouseHorizontalWheel.vue +193 -0
- package/app/src/views/Home.vue +37 -0
- package/app/src/views/RouterJump.vue +155 -0
- package/app/src/views/css.vue +57 -0
- package/app/src/views/cssComponents/EllipsisText.vue +83 -0
- package/app/src/views/cssComponents/HoverCard.vue +79 -0
- package/app/src/views/cssComponents/TableHover.vue +140 -0
- package/app/src/views/cssComponents/inputSlo.vue +52 -0
- package/app/src/views/cssComponents/tableFixed.vue +158 -0
- package/app/src/views/echarts/echart-dome.vue +82 -0
- package/app/src/views/echarts/index.vue +118 -0
- package/app/src/views/echarts/pei3d.vue +667 -0
- package/app/src/views/element/bpmn/index.vue +18 -0
- package/app/src/views/element/components/attendanceCycle/index.vue +131 -0
- package/app/src/views/element/components/attendanceGroup/index.vue +147 -0
- package/app/src/views/element/components/attendancePersonnel/index.vue +158 -0
- package/app/src/views/element/components/companyCalendar/index.vue +147 -0
- package/app/src/views/element/components/shift/index.vue +147 -0
- package/app/src/views/element/components/shiftRotationSystem/index.vue +147 -0
- package/app/src/views/element/elTableJsx/columnManagement.vue +340 -0
- package/app/src/views/element/elTableJsx/dialogInput.vue +71 -0
- package/app/src/views/element/elTableJsx/elTableJsx.vue +1826 -0
- package/app/src/views/element/elTableJsx/formTable.vue +598 -0
- package/app/src/views/element/elTableJsx/index.vue +29 -0
- package/app/src/views/element/elTableJsx/simpleTable.vue +192 -0
- package/app/src/views/element/elTableJsx.zip +0 -0
- package/app/src/views/element/index.vue +44 -0
- package/app/src/views/element/lazyCascader/LazyCascader.vue +302 -0
- package/app/src/views/element/lazyCascader/data.js +205 -0
- package/app/src/views/element/lazyCascader/index.vue +315 -0
- package/app/src/views/element/quillEditor/README.md +163 -0
- package/app/src/views/element/quillEditor/example.vue +314 -0
- package/app/src/views/element/quillEditor/index.vue +409 -0
- package/app/src/views/element/quillEditor/toolbar.js +122 -0
- package/app/vue.config.js +15 -0
- package/package.json +1 -1
- package/app/wujie-vue3-child/.claude/settings.local.json +0 -8
- package/app/wujie-vue3-child/.vscode/extensions.json +0 -3
- package/app/wujie-vue3-child/PROJECT_MEMORY.md +0 -427
- package/app/wujie-vue3-child/README.md +0 -5
- package/app/wujie-vue3-child/index.html +0 -13
- package/app/wujie-vue3-child/package-lock.json +0 -5744
- package/app/wujie-vue3-child/package.json +0 -28
- package/app/wujie-vue3-child/public/vite.svg +0 -1
- package/app/wujie-vue3-child/src/App.vue +0 -130
- package/app/wujie-vue3-child/src/assets/vue.svg +0 -1
- package/app/wujie-vue3-child/src/components/HelloWorld.vue +0 -43
- package/app/wujie-vue3-child/src/components/tags-view.vue +0 -193
- package/app/wujie-vue3-child/src/components/tags-view1.vue +0 -131
- package/app/wujie-vue3-child/src/directives/aiLoading.js +0 -182
- package/app/wujie-vue3-child/src/hooks/useClickOutside.js +0 -11
- package/app/wujie-vue3-child/src/hooks/useTableDragSort.js +0 -28
- package/app/wujie-vue3-child/src/main.js +0 -18
- package/app/wujie-vue3-child/src/router/index.js +0 -104
- package/app/wujie-vue3-child/src/store/tagsViewStroe.js +0 -34
- package/app/wujie-vue3-child/src/style.css +0 -171
- package/app/wujie-vue3-child/src/views/aiCoach/collapseExpand/index.jsx +0 -108
- package/app/wujie-vue3-child/src/views/aiCoach/collapseExpand/index.module.scss +0 -97
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/README.md +0 -836
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/REFLEX_EXAMPLES.md +0 -728
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/DepartmentPersonnelSelector.jsx +0 -687
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/DepartmentPersonnelSelector.module.scss +0 -560
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/DepartmentSelector.jsx +0 -570
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/DepartmentSelector.module.scss +0 -330
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/DepartmentSelectorV2.jsx +0 -378
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/DepartmentSelectorV2.module.scss +0 -228
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/OptionsSelector.jsx +0 -399
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/OptionsSelector.module.scss +0 -252
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/PersonnelSelector.jsx +0 -585
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/PersonnelSelector.module.scss +0 -331
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/PopoverSelector.jsx +0 -392
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/PopoverSelector.module.scss +0 -39
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/README.md +0 -248
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/components/SelectorTrigger.jsx +0 -194
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/index.jsx +0 -1459
- package/app/wujie-vue3-child/src/views/aiCoach/departmentPersonnel/mockData.js +0 -301
- package/app/wujie-vue3-child/src/views/aiCoach/dialogueSegment/index.jsx +0 -182
- package/app/wujie-vue3-child/src/views/aiCoach/dialogueSegment/index.module.scss +0 -28
- package/app/wujie-vue3-child/src/views/aiCoach/index.jsx +0 -293
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/ChartsPanel/index.jsx +0 -121
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/ChartsPanel/index.module.scss +0 -76
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/DonutChart/index.jsx +0 -104
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/PracticeTable/index.jsx +0 -75
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/PracticeTable/index.module.scss +0 -12
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/RankBarChart/index.jsx +0 -62
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/RankBarChart/index.module.scss +0 -43
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/RankingGroup/index.jsx +0 -29
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/RankingGroup/index.module.scss +0 -5
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/RankingList/index.jsx +0 -58
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/RankingList/index.module.scss +0 -85
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/ScriptStatsPanel/index.jsx +0 -92
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/ScriptStatsPanel/index.module.scss +0 -56
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/StatCardsRow/index.jsx +0 -40
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/StatCardsRow/index.module.scss +0 -53
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/echarts/EchartsDonut.jsx +0 -106
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/components/echarts/EchartsRankBar.jsx +0 -132
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/index.jsx +0 -176
- package/app/wujie-vue3-child/src/views/aiCoach/practiceStatus/index.module.scss +0 -96
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/CoachReport/index.jsx +0 -162
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/CoachReport/index.module.scss +0 -16
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/ComprehensiveEvaluation/index.jsx +0 -29
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/ComprehensiveEvaluation/index.module.scss +0 -25
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DialogueBubble/index.jsx +0 -106
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DialogueBubble/index.module.scss +0 -164
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DialogueRecord/index.jsx +0 -182
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DialogueRecord/index.module.scss +0 -203
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DimensionDetail/index.jsx +0 -145
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DimensionDetail/index.module.scss +0 -126
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DimensionScores/index.jsx +0 -67
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/DimensionScores/index.module.scss +0 -105
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/ReportHeader/index.jsx +0 -81
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/ReportHeader/index.module.scss +0 -47
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/RoleInfo/index.jsx +0 -64
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/RoleInfo/index.module.scss +0 -85
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/ScoreBadge/index.jsx +0 -39
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/ScoreBadge/index.module.scss +0 -44
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/SubDimensionItem/index.jsx +0 -83
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/components/SubDimensionItem/index.module.scss +0 -101
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/index.jsx +0 -50
- package/app/wujie-vue3-child/src/views/aiCoach/reportDetail/index.module.scss +0 -25
- package/app/wujie-vue3-child/src/views/aiCoach/scriptTable/index.jsx +0 -196
- package/app/wujie-vue3-child/src/views/aiCoach/scriptTable/index.module.scss +0 -41
- package/app/wujie-vue3-child/src/views/aiCoach/scriptTable/inputColumn/index.jsx +0 -183
- package/app/wujie-vue3-child/src/views/aiCoach/scriptTable/inputColumn/index.module.scss +0 -115
- package/app/wujie-vue3-child/src/views/child-to-parent.vue +0 -117
- package/app/wujie-vue3-child/src/views/home.vue +0 -53
- package/app/wujie-vue3-child/src/views/jsx/btnSelect/btnSelect.vue +0 -169
- package/app/wujie-vue3-child/src/views/jsx/btnSelect/index.vue +0 -69
- package/app/wujie-vue3-child/src/views/jsx/com.vue +0 -44
- package/app/wujie-vue3-child/src/views/jsx/dialog.jsx +0 -66
- package/app/wujie-vue3-child/src/views/jsx/index.vue +0 -72
- package/app/wujie-vue3-child/src/views/jsx/props.vue +0 -33
- package/app/wujie-vue3-child/src/views/parent-to-child.vue +0 -225
- package/app/wujie-vue3-child/src/views/phone-code.vue +0 -318
- package/app/wujie-vue3-child/src/views/router-jump.vue +0 -123
- package/app/wujie-vue3-child/src/views/test.vue +0 -192
- package/app/wujie-vue3-child/vite.config.js +0 -15
|
@@ -0,0 +1,836 @@
|
|
|
1
|
+
# QuillEditor组件封装 Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- []`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** 在 `src/views/element/quillEditor/`目录下封装一个 Quill2.x 富文本编辑器组件(全量工具栏 +表格 + base64 图片),并在 example.vue演示三实例对比。
|
|
6
|
+
|
|
7
|
+
**Architecture:** 单文件 Vue2组件 `QuillEditor.vue`,在 `mounted` 中初始化 Quill 实例,通过 props/events/methods 对外暴露能力。工具栏配置集中到 `toolbar.js`,example.vue演示三个实例(基础/只读/禁用)。不污染全局 CSS,所有样式在组件内 import。
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Vue2.6 + Element UI2.15 + Quill2.0.2 + quill-table-better1.2.3 + vue-cli5
|
|
10
|
+
|
|
11
|
+
**Spec:** `docs/superpowers/specs/2026-05-29-quill-editor-design.md`
|
|
12
|
+
|
|
13
|
+
**Working Directory:** `D:\web\wujie\wujie-wk\wujie-vue2-child`
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 文件结构
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
src/views/element/quillEditor/
|
|
21
|
+
├── index.vue # QuillEditor组件(对外暴露,已存在 tab引用)
|
|
22
|
+
├── example.vue # Demo 页(三实例对比)
|
|
23
|
+
├── toolbar.js # 默认工具栏 + handlers
|
|
24
|
+
└── README.md # 使用文档
|
|
25
|
+
|
|
26
|
+
package.json # 新增 quill + quill-table-better依赖
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**职责划分:**
|
|
30
|
+
- `index.vue`:Vue2组件,管理 Quill生命周期、props/events/methods、v-model同步、图片 base64 处理
|
|
31
|
+
- `toolbar.js`:默认工具栏数组 + image handler(委托给组件内部 file input)+ table-better 配置
|
|
32
|
+
- `example.vue`:三个实例 + v-model演示 +初始内容(含表格)
|
|
33
|
+
- `README.md`:API文档 + 使用示例
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Task1: 安装依赖
|
|
38
|
+
|
|
39
|
+
**Files:**
|
|
40
|
+
- Modify: `package.json`
|
|
41
|
+
|
|
42
|
+
- [] **Step1.1: 安装 Quill2.x**
|
|
43
|
+
|
|
44
|
+
Run:
|
|
45
|
+
```bash
|
|
46
|
+
cd "D:\web\wujie\wujie-wk\wujie-vue2-child" && npm install quill@2.0.2 --save
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Expected: `package.json` dependencies 中新增 `"quill": "^2.0.2"`,`node_modules/quill`存在
|
|
50
|
+
|
|
51
|
+
- [] **Step1.2: 安装 quill-table-better**
|
|
52
|
+
|
|
53
|
+
Run:
|
|
54
|
+
```bash
|
|
55
|
+
cd "D:\web\wujie\wujie-wk\wujie-vue2-child" && npm install quill-table-better@1.2.3 --save
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Expected: `package.json` dependencies 中新增 `"quill-table-better": "^1.2.3"`,`node_modules/quill-table-better`存在
|
|
59
|
+
|
|
60
|
+
- [] **Step1.3:验证安装**
|
|
61
|
+
|
|
62
|
+
Run:
|
|
63
|
+
```bash
|
|
64
|
+
cd "D:\web\wujie\wujie-wk\wujie-vue2-child" && ls node_modules/quill/dist/quill.snow.css node_modules/quill-table-better/dist/quill-table-better.css node_modules/quill-table-better/dist/quill-table-better.js
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Expected:三个文件都存在
|
|
68
|
+
|
|
69
|
+
- [] **Step1.4: Commit**
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
git -C "D:\web\wujie\wujie-wk\wujie-vue2-child" add package.json package-lock.json
|
|
73
|
+
git -C "D:\web\wujie\wujie-wk\wujie-vue2-child" commit -m "deps: add quill@2.0.2 and quill-table-better@1.2.3"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Task2:写 toolbar.js(默认工具栏配置)
|
|
79
|
+
|
|
80
|
+
**Files:**
|
|
81
|
+
- Create: `src/views/element/quillEditor/toolbar.js`
|
|
82
|
+
|
|
83
|
+
- [] **Step2.1: 创建 toolbar.js**
|
|
84
|
+
|
|
85
|
+
Write the following content to `src/views/element/quillEditor/toolbar.js`:
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
/**
|
|
89
|
+
* QuillEditor 默认工具栏配置
|
|
90
|
+
*
|
|
91
|
+
*暴露:
|
|
92
|
+
* - defaultToolbar:工具栏按钮数组(传给 Quill 的 modules.toolbar)
|
|
93
|
+
* - defaultTableBetterConfig:table-better 模块配置
|
|
94
|
+
* - defaultModules:组装好的 modules 对象(含 toolbar + table-better + keyboard)
|
|
95
|
+
*
|
|
96
|
+
* 注意:image handler 在 QuillEditor组件中注册,这里只占位声明,
|
|
97
|
+
*组件会在 initQuill 时通过 modules.toolbar.handlers.image覆盖。
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
export const defaultToolbar = [
|
|
101
|
+
[{ header: [1,2,3,4,5,6, false] }],
|
|
102
|
+
[{ font: [] }],
|
|
103
|
+
[{ size: ['small', false, 'large', 'huge'] }],
|
|
104
|
+
['bold', 'italic', 'underline', 'strike'],
|
|
105
|
+
[{ color: [] }, { background: [] }],
|
|
106
|
+
[{ script: 'sub' }, { script: 'super' }],
|
|
107
|
+
['blockquote', 'code-block'],
|
|
108
|
+
[{ list: 'ordered' }, { list: 'bullet' }],
|
|
109
|
+
[{ indent: '-1' }, { indent: '+1' }],
|
|
110
|
+
[{ align: [] }],
|
|
111
|
+
['link', 'image', 'video'],
|
|
112
|
+
['table-better'],
|
|
113
|
+
['clean'],
|
|
114
|
+
['undo', 'redo'],
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
export const defaultTableBetterConfig = {
|
|
118
|
+
language: 'zh_CN',
|
|
119
|
+
menus: ['column', 'row', 'merge', 'table', 'cell', 'wrap', 'copy', 'delete'],
|
|
120
|
+
toolbarTable: true,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export function buildDefaultModules(quillTableBetter) {
|
|
124
|
+
return {
|
|
125
|
+
toolbar: defaultToolbar,
|
|
126
|
+
table: false,
|
|
127
|
+
'table-better': defaultTableBetterConfig,
|
|
128
|
+
keyboard: {
|
|
129
|
+
bindings: quillTableBetter.keyboardBindings,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- [] **Step2.2:验证文件创建**
|
|
136
|
+
|
|
137
|
+
Run:
|
|
138
|
+
```bash
|
|
139
|
+
ls -la "D:\web\wujie\wujie-wk\wujie-vue2-child\src\views\element\quillEditor\toolbar.js"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Expected: 文件存在,大小约1.5KB
|
|
143
|
+
|
|
144
|
+
- [] **Step2.3: Commit**
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
git -C "D:\web\wujie\wujie-wk\wujie-vue2-child" add src/views/element/quillEditor/toolbar.js
|
|
148
|
+
git -C "D:\web\wujie\wujie-wk\wujie-vue2-child" commit -m "feat(quillEditor): add default toolbar config"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Task3:写 QuillEditor 主组件(index.vue)
|
|
154
|
+
|
|
155
|
+
**Files:**
|
|
156
|
+
- Create: `src/views/element/quillEditor/index.vue`
|
|
157
|
+
|
|
158
|
+
- [] **Step3.1: 创建 QuillEditor.vue**
|
|
159
|
+
|
|
160
|
+
Write the following content to `src/views/element/quillEditor/index.vue`:
|
|
161
|
+
|
|
162
|
+
```vue
|
|
163
|
+
<template>
|
|
164
|
+
<div class="quill-editor-wrapper" :class="{ 'is-disabled': disabled }">
|
|
165
|
+
<div ref="editor" :style="editorStyle"></div>
|
|
166
|
+
<input
|
|
167
|
+
ref="fileInput"
|
|
168
|
+
type="file"
|
|
169
|
+
accept="image/*"
|
|
170
|
+
style="display: none"
|
|
171
|
+
@change="onFileChange"
|
|
172
|
+
/>
|
|
173
|
+
</div>
|
|
174
|
+
</template>
|
|
175
|
+
|
|
176
|
+
<script>
|
|
177
|
+
import Quill from 'quill';
|
|
178
|
+
import QuillTableBetter from 'quill-table-better';
|
|
179
|
+
import 'quill/dist/quill.snow.css';
|
|
180
|
+
import 'quill-table-better/dist/quill-table-better.css';
|
|
181
|
+
import { defaultToolbar, buildDefaultModules } from './toolbar.js';
|
|
182
|
+
|
|
183
|
+
const SIZE_THRESHOLD =5 *1024 *1024; //5MB
|
|
184
|
+
|
|
185
|
+
export default {
|
|
186
|
+
name: 'QuillEditor',
|
|
187
|
+
|
|
188
|
+
model: {
|
|
189
|
+
prop: 'value',
|
|
190
|
+
event: 'input',
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
props: {
|
|
194
|
+
value: {
|
|
195
|
+
type: String,
|
|
196
|
+
default: '',
|
|
197
|
+
},
|
|
198
|
+
placeholder: {
|
|
199
|
+
type: String,
|
|
200
|
+
default: '请输入内容...',
|
|
201
|
+
},
|
|
202
|
+
readonly: {
|
|
203
|
+
type: Boolean,
|
|
204
|
+
default: false,
|
|
205
|
+
},
|
|
206
|
+
disabled: {
|
|
207
|
+
type: Boolean,
|
|
208
|
+
default: false,
|
|
209
|
+
},
|
|
210
|
+
height: {
|
|
211
|
+
type: [String, Number],
|
|
212
|
+
default:300,
|
|
213
|
+
},
|
|
214
|
+
toolbar: {
|
|
215
|
+
type: [Array, Object],
|
|
216
|
+
default: null,
|
|
217
|
+
},
|
|
218
|
+
imageHandler: {
|
|
219
|
+
type: Function,
|
|
220
|
+
default: null,
|
|
221
|
+
},
|
|
222
|
+
theme: {
|
|
223
|
+
type: String,
|
|
224
|
+
default: 'snow',
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
data() {
|
|
229
|
+
return {
|
|
230
|
+
quill: null,
|
|
231
|
+
isInternalChange: false,
|
|
232
|
+
changeTimer: null,
|
|
233
|
+
};
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
computed: {
|
|
237
|
+
editorStyle() {
|
|
238
|
+
const h = typeof this.height === 'number' ? `${this.height}px` : this.height;
|
|
239
|
+
return { minHeight: h };
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
watch: {
|
|
244
|
+
value(newVal) {
|
|
245
|
+
if (this.isInternalChange) {
|
|
246
|
+
this.isInternalChange = false;
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (this.quill && newVal !== this.getHtml()) {
|
|
250
|
+
this.setHtml(newVal);
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
readonly(val) {
|
|
254
|
+
if (this.quill) {
|
|
255
|
+
this.quill.enable(!val);
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
disabled(val) {
|
|
259
|
+
if (this.quill) {
|
|
260
|
+
this.quill.enable(!val);
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
mounted() {
|
|
266
|
+
this.$nextTick(() => {
|
|
267
|
+
this.initQuill();
|
|
268
|
+
});
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
beforeDestroy() {
|
|
272
|
+
if (this.changeTimer) {
|
|
273
|
+
clearTimeout(this.changeTimer);
|
|
274
|
+
this.changeTimer = null;
|
|
275
|
+
}
|
|
276
|
+
if (this.quill) {
|
|
277
|
+
try {
|
|
278
|
+
this.quill.off('text-change', this.onTextChange);
|
|
279
|
+
} catch (e) {
|
|
280
|
+
// ignore
|
|
281
|
+
}
|
|
282
|
+
this.quill = null;
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
methods: {
|
|
287
|
+
initQuill() {
|
|
288
|
+
if (typeof Quill === 'undefined' || !Quill) {
|
|
289
|
+
this.renderError('Quill 未安装,请先执行 npm install quill');
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// 注册 table-better 模块
|
|
294
|
+
Quill.register(
|
|
295
|
+
{ 'modules/table-better': QuillTableBetter },
|
|
296
|
+
true
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
const modules = this.buildModules();
|
|
300
|
+
|
|
301
|
+
this.quill = new Quill(this.$refs.editor, {
|
|
302
|
+
theme: this.theme,
|
|
303
|
+
placeholder: this.placeholder,
|
|
304
|
+
readOnly: this.readonly || this.disabled,
|
|
305
|
+
modules,
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
//初始内容
|
|
309
|
+
if (this.value) {
|
|
310
|
+
this.setHtml(this.value);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
//监听内容变化
|
|
314
|
+
this.quill.on('text-change', this.onTextChange);
|
|
315
|
+
|
|
316
|
+
//焦点事件
|
|
317
|
+
this.quill.on('selection-change', this.onSelectionChange);
|
|
318
|
+
|
|
319
|
+
this.$emit('ready', this.quill);
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
buildModules() {
|
|
323
|
+
const baseModules = buildDefaultModules(QuillTableBetter);
|
|
324
|
+
const toolbarConfig = this.toolbar || defaultToolbar;
|
|
325
|
+
|
|
326
|
+
//复制 toolbar 配置,添加 image handler
|
|
327
|
+
const modules = {
|
|
328
|
+
...baseModules,
|
|
329
|
+
toolbar: Array.isArray(toolbarConfig)
|
|
330
|
+
? { container: toolbarConfig, handlers: { image: this.handleImage } }
|
|
331
|
+
: { ...toolbarConfig, handlers: { image: this.handleImage, ...(toolbarConfig.handlers || {}) } },
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
return modules;
|
|
335
|
+
},
|
|
336
|
+
|
|
337
|
+
onTextChange(delta, oldDelta, source) {
|
|
338
|
+
if (source === Quill.sources.SILENT) return;
|
|
339
|
+
const html = this.getHtml();
|
|
340
|
+
this.isInternalChange = true;
|
|
341
|
+
this.$emit('input', html);
|
|
342
|
+
|
|
343
|
+
if (this.changeTimer) clearTimeout(this.changeTimer);
|
|
344
|
+
this.changeTimer = setTimeout(() => {
|
|
345
|
+
this.$emit('change', html);
|
|
346
|
+
},300);
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
onSelectionChange(range, oldRange) {
|
|
350
|
+
if (range === null && oldRange !== null) {
|
|
351
|
+
this.$emit('blur');
|
|
352
|
+
} else if (range !== null && oldRange === null) {
|
|
353
|
+
this.$emit('focus');
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
handleImage() {
|
|
358
|
+
if (this.disabled || this.readonly) return;
|
|
359
|
+
this.$refs.fileInput.value = '';
|
|
360
|
+
this.$refs.fileInput.click();
|
|
361
|
+
},
|
|
362
|
+
|
|
363
|
+
onFileChange(e) {
|
|
364
|
+
const file = e.target.files && e.target.files[0];
|
|
365
|
+
if (!file) return;
|
|
366
|
+
|
|
367
|
+
if (this.imageHandler) {
|
|
368
|
+
const range = this.quill.getSelection(true);
|
|
369
|
+
Promise.resolve(this.imageHandler(file, range, this.quill))
|
|
370
|
+
.then((result) => {
|
|
371
|
+
if (result === false) {
|
|
372
|
+
this.insertImageAsBase64(file);
|
|
373
|
+
}
|
|
374
|
+
})
|
|
375
|
+
.catch(() => {
|
|
376
|
+
this.insertImageAsBase64(file);
|
|
377
|
+
});
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
this.insertImageAsBase64(file);
|
|
382
|
+
},
|
|
383
|
+
|
|
384
|
+
insertImageAsBase64(file) {
|
|
385
|
+
if (file.size > SIZE_THRESHOLD) {
|
|
386
|
+
if (this.$message && this.$message.warning) {
|
|
387
|
+
this.$message.warning('图片过大(>5MB),建议压缩后上传');
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const reader = new FileReader();
|
|
391
|
+
reader.onload = (e) => {
|
|
392
|
+
const dataUrl = e.target.result;
|
|
393
|
+
const range = this.quill.getSelection(true);
|
|
394
|
+
const index = range ? range.index : this.quill.getLength();
|
|
395
|
+
this.quill.insertEmbed(index, 'image', dataUrl, Quill.sources.USER);
|
|
396
|
+
};
|
|
397
|
+
reader.readAsDataURL(file);
|
|
398
|
+
},
|
|
399
|
+
|
|
400
|
+
renderError(msg) {
|
|
401
|
+
console.error('[QuillEditor]', msg);
|
|
402
|
+
const el = this.$refs.editor;
|
|
403
|
+
if (el) {
|
|
404
|
+
el.innerHTML = `<div class="quill-editor-error" style="padding:16px;border:1px dashed #f56c6c;color:#f56c6c;">${msg}</div>`;
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
// ====== Public Methods ======
|
|
409
|
+
|
|
410
|
+
getHtml() {
|
|
411
|
+
if (!this.quill) return String(this.value || '');
|
|
412
|
+
return this.quill.root.innerHTML;
|
|
413
|
+
},
|
|
414
|
+
|
|
415
|
+
getText() {
|
|
416
|
+
if (!this.quill) return '';
|
|
417
|
+
return this.quill.getText();
|
|
418
|
+
},
|
|
419
|
+
|
|
420
|
+
setHtml(html) {
|
|
421
|
+
if (!this.quill) return;
|
|
422
|
+
const safe = String(html || '');
|
|
423
|
+
this.quill.clipboard.dangerouslyPasteHTML(0, safe);
|
|
424
|
+
},
|
|
425
|
+
|
|
426
|
+
clear() {
|
|
427
|
+
if (!this.quill) return;
|
|
428
|
+
this.quill.setText('');
|
|
429
|
+
},
|
|
430
|
+
|
|
431
|
+
focus() {
|
|
432
|
+
if (this.quill) this.quill.focus();
|
|
433
|
+
},
|
|
434
|
+
|
|
435
|
+
getQuill() {
|
|
436
|
+
return this.quill;
|
|
437
|
+
},
|
|
438
|
+
},
|
|
439
|
+
};
|
|
440
|
+
</script>
|
|
441
|
+
|
|
442
|
+
<style scoped>
|
|
443
|
+
.quill-editor-wrapper {
|
|
444
|
+
background: #fff;
|
|
445
|
+
border:1px solid #dcdfe6;
|
|
446
|
+
border-radius:4px;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.quill-editor-wrapper.is-disabled {
|
|
450
|
+
background: #f5f7fa;
|
|
451
|
+
pointer-events: none;
|
|
452
|
+
opacity:0.7;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.quill-editor-wrapper >>> .ql-toolbar {
|
|
456
|
+
border-bottom:1px solid #dcdfe6;
|
|
457
|
+
border-top-left-radius:4px;
|
|
458
|
+
border-top-right-radius:4px;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
.quill-editor-wrapper >>> .ql-container {
|
|
462
|
+
border-bottom-left-radius:4px;
|
|
463
|
+
border-bottom-right-radius:4px;
|
|
464
|
+
font-size:14px;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
.quill-editor-wrapper >>> .ql-editor {
|
|
468
|
+
min-height:200px;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
.quill-editor-wrapper >>> .ql-editor img {
|
|
472
|
+
max-width:100%;
|
|
473
|
+
}
|
|
474
|
+
</style>
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
- [] **Step3.2:验证文件创建**
|
|
478
|
+
|
|
479
|
+
Run:
|
|
480
|
+
```bash
|
|
481
|
+
ls -la "D:\web\wujie\wujie-wk\wujie-vue2-child\src\views\element\quillEditor\index.vue"
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
Expected: 文件存在
|
|
485
|
+
|
|
486
|
+
- [] **Step3.3: Commit**
|
|
487
|
+
|
|
488
|
+
```bash
|
|
489
|
+
git -C "D:\web\wujie\wujie-wk\wujie-vue2-child" add src/views/element/quillEditor/index.vue
|
|
490
|
+
git -C "D:\web\wujie\wujie-wk\wujie-vue2-child" commit -m "feat(quillEditor): add QuillEditor component with v-model, table, base64 image"
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
---
|
|
494
|
+
|
|
495
|
+
## Task4:写 example.vue(三个实例对比 Demo)
|
|
496
|
+
|
|
497
|
+
**Files:**
|
|
498
|
+
- Create: `src/views/element/quillEditor/example.vue`
|
|
499
|
+
|
|
500
|
+
- [] **Step4.1: 创建 example.vue**
|
|
501
|
+
|
|
502
|
+
Write the following content to `src/views/element/quillEditor/example.vue`:
|
|
503
|
+
|
|
504
|
+
```vue
|
|
505
|
+
<template>
|
|
506
|
+
<div class="quill-demo">
|
|
507
|
+
<h3>实例1:基础编辑器(v-model双向绑定)</h3>
|
|
508
|
+
<QuillEditor
|
|
509
|
+
v-model="content1"
|
|
510
|
+
:height="280"
|
|
511
|
+
@change="onChange"
|
|
512
|
+
@ready="onReady"
|
|
513
|
+
/>
|
|
514
|
+
|
|
515
|
+
<h3>实例2:只读模式(readonly)</h3>
|
|
516
|
+
<QuillEditor v-model="content2" :readonly="true" :height="200" />
|
|
517
|
+
|
|
518
|
+
<h3>实例3:禁用模式(disabled,工具栏灰掉)</h3>
|
|
519
|
+
<QuillEditor v-model="content3" :disabled="true" :height="200" />
|
|
520
|
+
|
|
521
|
+
<h3>当前实例1 的 v-model 内容:</h3>
|
|
522
|
+
<pre class="content-preview">{{ content1 }}</pre>
|
|
523
|
+
</div>
|
|
524
|
+
</template>
|
|
525
|
+
|
|
526
|
+
<script>
|
|
527
|
+
import QuillEditor from './index.vue';
|
|
528
|
+
|
|
529
|
+
const SAMPLE_WITH_TABLE = `<h2>富文本编辑器示例</h2>
|
|
530
|
+
<p>这是一个 <strong>Quill</strong> 富文本编辑器示例,包含以下功能:</p>
|
|
531
|
+
<ul>
|
|
532
|
+
<li>基础格式:加粗、斜体、下划线、删除线</li>
|
|
533
|
+
<li>标题、段落、引用、列表</li>
|
|
534
|
+
<li>字体、颜色、对齐、缩进</li>
|
|
535
|
+
<li>图片(支持 base64 内联)</li>
|
|
536
|
+
<li>表格(quill-table-better)</li>
|
|
537
|
+
</ul>
|
|
538
|
+
<table>
|
|
539
|
+
<thead>
|
|
540
|
+
<tr><th>姓名</th><th>年龄</th><th>城市</th></tr>
|
|
541
|
+
</thead>
|
|
542
|
+
<tbody>
|
|
543
|
+
<tr><td>张三</td><td>28</td><td>北京</td></tr>
|
|
544
|
+
<tr><td>李四</td><td>32</td><td>上海</td></tr>
|
|
545
|
+
</tbody>
|
|
546
|
+
</table>
|
|
547
|
+
<p>试着编辑上方内容,查看下方 <code>v-model</code> 输出。</p>`;
|
|
548
|
+
|
|
549
|
+
export default {
|
|
550
|
+
name: 'QuillEditorDemo',
|
|
551
|
+
components: { QuillEditor },
|
|
552
|
+
data() {
|
|
553
|
+
return {
|
|
554
|
+
content1: SAMPLE_WITH_TABLE,
|
|
555
|
+
content2: SAMPLE_WITH_TABLE,
|
|
556
|
+
content3: SAMPLE_WITH_TABLE,
|
|
557
|
+
};
|
|
558
|
+
},
|
|
559
|
+
methods: {
|
|
560
|
+
onChange(html) {
|
|
561
|
+
// eslint-disable-next-line no-console
|
|
562
|
+
console.log('[QuillDemo] change:', html.slice(0,80) + '...');
|
|
563
|
+
},
|
|
564
|
+
onReady(quill) {
|
|
565
|
+
// eslint-disable-next-line no-console
|
|
566
|
+
console.log('[QuillDemo] ready, Quill version:', quill.version);
|
|
567
|
+
},
|
|
568
|
+
},
|
|
569
|
+
};
|
|
570
|
+
</script>
|
|
571
|
+
|
|
572
|
+
<style scoped>
|
|
573
|
+
.quill-demo {
|
|
574
|
+
padding:20px;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
.quill-demo h3 {
|
|
578
|
+
margin:24px012px;
|
|
579
|
+
font-size:16px;
|
|
580
|
+
color: #303133;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
.quill-demo h3:first-child {
|
|
584
|
+
margin-top:0;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
.content-preview {
|
|
588
|
+
background: #f5f7fa;
|
|
589
|
+
border:1px solid #dcdfe6;
|
|
590
|
+
border-radius:4px;
|
|
591
|
+
padding:12px;
|
|
592
|
+
font-size:12px;
|
|
593
|
+
font-family: Consolas, 'Courier New', monospace;
|
|
594
|
+
white-space: pre-wrap;
|
|
595
|
+
word-break: break-all;
|
|
596
|
+
max-height:200px;
|
|
597
|
+
overflow: auto;
|
|
598
|
+
}
|
|
599
|
+
</style>
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
- [] **Step4.2:验证文件创建**
|
|
603
|
+
|
|
604
|
+
Run:
|
|
605
|
+
```bash
|
|
606
|
+
ls -la "D:\web\wujie\wujie-wk\wujie-vue2-child\src\views\element\quillEditor\example.vue"
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
Expected: 文件存在
|
|
610
|
+
|
|
611
|
+
- [] **Step4.3: Commit**
|
|
612
|
+
|
|
613
|
+
```bash
|
|
614
|
+
git -C "D:\web\wujie\wujie-wk\wujie-vue2-child" add src/views/element/quillEditor/example.vue
|
|
615
|
+
git -C "D:\web\wujie\wujie-wk\wujie-vue2-child" commit -m "feat(quillEditor): add demo page with three editor instances"
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
---
|
|
619
|
+
|
|
620
|
+
## Task5:写 README.md(使用文档)
|
|
621
|
+
|
|
622
|
+
**Files:**
|
|
623
|
+
- Create: `src/views/element/quillEditor/README.md`
|
|
624
|
+
|
|
625
|
+
- [] **Step5.1: 创建 README.md**
|
|
626
|
+
|
|
627
|
+
Write the following content to `src/views/element/quillEditor/README.md`:
|
|
628
|
+
|
|
629
|
+
```markdown
|
|
630
|
+
# QuillEditor
|
|
631
|
+
|
|
632
|
+
基于 Quill2.x + quill-table-better 的 Vue2 富文本编辑器组件,支持表格、图片、全部基础格式。
|
|
633
|
+
|
|
634
|
+
## 安装依赖
|
|
635
|
+
|
|
636
|
+
依赖已添加到 `package.json`,首次使用需安装:
|
|
637
|
+
|
|
638
|
+
```bash
|
|
639
|
+
npm install
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
依赖列表:
|
|
643
|
+
- `quill@2.0.2`
|
|
644
|
+
- `quill-table-better@1.2.3`
|
|
645
|
+
|
|
646
|
+
##快速使用
|
|
647
|
+
|
|
648
|
+
```vue
|
|
649
|
+
<template>
|
|
650
|
+
<QuillEditor v-model="content" :height="400" />
|
|
651
|
+
</template>
|
|
652
|
+
|
|
653
|
+
<script>
|
|
654
|
+
import QuillEditor from '@/views/element/quillEditor/index.vue';
|
|
655
|
+
|
|
656
|
+
export default {
|
|
657
|
+
components: { QuillEditor },
|
|
658
|
+
data() {
|
|
659
|
+
return { content: '<p>Hello Quill!</p>' };
|
|
660
|
+
},
|
|
661
|
+
};
|
|
662
|
+
</script>
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
## Props
|
|
666
|
+
|
|
667
|
+
| Prop | 类型 | 默认值 | 说明 |
|
|
668
|
+
|------|------|--------|------|
|
|
669
|
+
| `value` | String | `''` | 编辑器 HTML 内容,支持 v-model |
|
|
670
|
+
| `placeholder` | String | `'请输入内容...'` | 占位文字 |
|
|
671
|
+
| `readonly` | Boolean | `false` | 是否只读(可看不可改) |
|
|
672
|
+
| `disabled` | Boolean | `false` | 是否禁用(工具栏灰掉,不可编辑) |
|
|
673
|
+
| `height` | String \| Number | `300` | 编辑区高度,数字按 px,字符串按原值 |
|
|
674
|
+
| `toolbar` | Array \| Object | 默认全量工具栏 | 自定义工具栏配置;不传则用默认全量 |
|
|
675
|
+
| `imageHandler` | Function | `null` | 自定义图片处理函数;不传则走 base64 内联 |
|
|
676
|
+
| `theme` | String | `'snow'` |主题,目前只支持 snow |
|
|
677
|
+
|
|
678
|
+
## Events
|
|
679
|
+
|
|
680
|
+
|事件 |触发时机 | 参数 |
|
|
681
|
+
|------|---------|------|
|
|
682
|
+
| `input` | 内容变化 | `(html: String)` |
|
|
683
|
+
| `change` | 内容变化(去抖300ms) | `(html: String)` |
|
|
684
|
+
| `ready` | Quill 实例初始化完成 | `(quill: Quill)` |
|
|
685
|
+
| `focus` | 编辑器获得焦点 | `()` |
|
|
686
|
+
| `blur` | 编辑器失去焦点 | `()` |
|
|
687
|
+
|
|
688
|
+
## Methods(通过 ref 调用)
|
|
689
|
+
|
|
690
|
+
| 方法 | 返回值 | 说明 |
|
|
691
|
+
|------|--------|------|
|
|
692
|
+
| `getHtml()` | String | 获取当前 HTML |
|
|
693
|
+
| `getText()` | String | 获取纯文本 |
|
|
694
|
+
| `setHtml(html)` | - | 设置内容 |
|
|
695
|
+
| `clear()` | - | 清空内容 |
|
|
696
|
+
| `focus()` | - |聚焦 |
|
|
697
|
+
| `getQuill()` | Quill | 获取底层 Quill 实例(高级用法) |
|
|
698
|
+
|
|
699
|
+
## 自定义图片上传示例
|
|
700
|
+
|
|
701
|
+
```vue
|
|
702
|
+
<QuillEditor
|
|
703
|
+
v-model="content"
|
|
704
|
+
:image-handler="uploadImage"
|
|
705
|
+
/>
|
|
706
|
+
|
|
707
|
+
<script>
|
|
708
|
+
methods: {
|
|
709
|
+
async uploadImage(file, range, quill) {
|
|
710
|
+
const form = new FormData();
|
|
711
|
+
form.append('file', file);
|
|
712
|
+
const res = await fetch('/api/upload', { method: 'POST', body: form });
|
|
713
|
+
const { url } = await res.json();
|
|
714
|
+
quill.insertEmbed(range.index, 'image', url);
|
|
715
|
+
return true; // 返回 true 表示已处理,跳过 base64 回退
|
|
716
|
+
},
|
|
717
|
+
}
|
|
718
|
+
</script>
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
## 默认工具栏(全量)
|
|
722
|
+
|
|
723
|
+
```javascript
|
|
724
|
+
[
|
|
725
|
+
[{ header: [1,2,3,4,5,6, false] }],
|
|
726
|
+
[{ font: [] }],
|
|
727
|
+
[{ size: ['small', false, 'large', 'huge'] }],
|
|
728
|
+
['bold', 'italic', 'underline', 'strike'],
|
|
729
|
+
[{ color: [] }, { background: [] }],
|
|
730
|
+
[{ script: 'sub' }, { script: 'super' }],
|
|
731
|
+
['blockquote', 'code-block'],
|
|
732
|
+
[{ list: 'ordered' }, { list: 'bullet' }],
|
|
733
|
+
[{ indent: '-1' }, { indent: '+1' }],
|
|
734
|
+
[{ align: [] }],
|
|
735
|
+
['link', 'image', 'video'],
|
|
736
|
+
['table-better'],
|
|
737
|
+
['clean'],
|
|
738
|
+
['undo', 'redo'],
|
|
739
|
+
]
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
##表格功能
|
|
743
|
+
|
|
744
|
+
点击工具栏的 `table-better`按钮可插入表格,右键单元格可弹出操作菜单(增删行列、合并/拆分、单元格背景色、复制/删除)。
|
|
745
|
+
|
|
746
|
+
表格配置见 `toolbar.js` 中 `defaultTableBetterConfig`:
|
|
747
|
+
- `language: 'zh_CN'` 中文界面
|
|
748
|
+
- `toolbarTable: true` 显示表格工具栏
|
|
749
|
+
- `menus`包含 column/row/merge/table/cell/wrap/copy/delete全部操作
|
|
750
|
+
|
|
751
|
+
##主题与样式
|
|
752
|
+
|
|
753
|
+
组件内部已 `import 'quill/dist/quill.snow.css'` 和 `quill-table-better/dist/quill-table-better.css`,
|
|
754
|
+
**不需要在 main.js 全局引入**。外层容器样式 scoped,不污染全局。
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
- [] **Step5.2:验证文件创建**
|
|
758
|
+
|
|
759
|
+
Run:
|
|
760
|
+
```bash
|
|
761
|
+
ls -la "D:\web\wujie\wujie-wk\wujie-vue2-child\src\views\element\quillEditor\README.md"
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
Expected: 文件存在
|
|
765
|
+
|
|
766
|
+
- [] **Step5.3: Commit**
|
|
767
|
+
|
|
768
|
+
```bash
|
|
769
|
+
git -C "D:\web\wujie\wujie-wk\wujie-vue2-child" add src/views/element/quillEditor/README.md
|
|
770
|
+
git -C "D:\web\wujie\wujie-wk\wujie-vue2-child" commit -m "docs(quillEditor): add README with API docs and usage examples"
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
---
|
|
774
|
+
|
|
775
|
+
## Task6:人工验证(无测试框架)
|
|
776
|
+
|
|
777
|
+
**Files:** 无
|
|
778
|
+
|
|
779
|
+
本项目无 jest/vitest,通过运行 dev 服务器 +浏览器人工验证。
|
|
780
|
+
|
|
781
|
+
- [] **Step6.1:启动 dev 服务器**
|
|
782
|
+
|
|
783
|
+
Run:
|
|
784
|
+
```bash
|
|
785
|
+
cd "D:\web\wujie\wujie-wk\wujie-vue2-child" && npm run serve
|
|
786
|
+
```
|
|
787
|
+
|
|
788
|
+
Expected:编译成功,无报错;浏览器访问 `http://localhost:8080/element`(或对应路由)
|
|
789
|
+
|
|
790
|
+
- [] **Step6.2:验证三个实例都正常渲染**
|
|
791
|
+
|
|
792
|
+
打开 element页面 → 点击 "Quill编辑器" tab
|
|
793
|
+
|
|
794
|
+
Expected:
|
|
795
|
+
- 实例1:显示初始内容(含表格),工具栏可用
|
|
796
|
+
- 实例2:显示同样内容,但内容区和工具栏都不可交互(只读)
|
|
797
|
+
- 实例3:显示同样内容,工具栏灰掉,不可编辑
|
|
798
|
+
|
|
799
|
+
- [] **Step6.3:验证 v-model双向同步**
|
|
800
|
+
|
|
801
|
+
在实例1 中输入/删除/修改任意文字
|
|
802
|
+
|
|
803
|
+
Expected:下方 "当前实例1 的 v-model 内容"区域的 `<pre>`实时更新
|
|
804
|
+
|
|
805
|
+
- [] **Step6.4:验证表格功能**
|
|
806
|
+
|
|
807
|
+
在实例1 中点击工具栏的 `table-better`按钮 →弹出表格插入对话框 →插入3x3表格
|
|
808
|
+
|
|
809
|
+
Expected:表格正确插入,右键单元格弹出操作菜单
|
|
810
|
+
|
|
811
|
+
- [] **Step6.5:验证图片 base64 内联**
|
|
812
|
+
|
|
813
|
+
在实例1 中点击工具栏的图片按钮 → 选择本地图片
|
|
814
|
+
|
|
815
|
+
Expected: 图片以 base64形式插入到编辑器;浏览器 DevTools Network面板无图片请求(说明是内联)
|
|
816
|
+
|
|
817
|
+
- [] **Step6.6:验证组件销毁无报错**
|
|
818
|
+
|
|
819
|
+
切换到其他 tab 再切回 "Quill编辑器" tab
|
|
820
|
+
|
|
821
|
+
Expected:浏览器 Console 无报错(无 Quill重复挂载、事件未清理等)
|
|
822
|
+
|
|
823
|
+
- [] **Step6.7:提交验证记录**
|
|
824
|
+
|
|
825
|
+
如果所有验证通过,提交一条说明 commit:
|
|
826
|
+
|
|
827
|
+
```bash
|
|
828
|
+
git -C "D:\web\wujie\wujie-wk\wujie-vue2-child" commit --allow-empty -m "chore(quillEditor): manual verification passed (3 instances, table, base64 image)"
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
---
|
|
832
|
+
|
|
833
|
+
## 完成
|
|
834
|
+
|
|
835
|
+
所有任务完成后,QuillEditor组件即在 `src/views/element/quillEditor/` 下可用,
|
|
836
|
+
`src/views/element/index.vue` 中已 import 该组件,无需修改 tab 文件。
|