@agilehub/agile-editor 1.6.0 → 1.8.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.
Files changed (47) hide show
  1. package/README.md +1 -0
  2. package/dist/agile-editor.css +1 -1
  3. package/dist/agile-editor.js +18325 -18426
  4. package/dist/i18n-DCR9QpaV.js +2785 -0
  5. package/dist/types/components/editor/index.vue.d.ts +2 -2
  6. package/dist/types/components/editor/smart-sheet-dialog.vue.d.ts +3 -0
  7. package/dist/types/components/index.d.ts +2 -1
  8. package/dist/types/components/index.vue.d.ts +384 -22
  9. package/dist/types/components/menus/button.vue.d.ts +1 -1
  10. package/dist/types/components/menus/toolbar/insert/bookmark.vue.d.ts +24 -0
  11. package/dist/types/components/menus/toolbar/insert/courseware.vue.d.ts +3 -0
  12. package/dist/types/components/menus/toolbar/insert/smart-sheet.vue.d.ts +3 -0
  13. package/dist/types/components/preview-toolbar/index.vue.d.ts +2 -2
  14. package/dist/types/components/toolbar/classic.vue.d.ts +19 -11
  15. package/dist/types/components/toolbar/ribbon.vue.d.ts +19 -11
  16. package/dist/types/composables/i18n.d.ts +375 -18
  17. package/dist/types/extensions/bookmark-transaction.d.ts +4 -0
  18. package/dist/types/extensions/bookmark.d.ts +8 -5
  19. package/dist/types/extensions/bubble-note.d.ts +1 -0
  20. package/dist/types/extensions/courseware/annotation-session.d.ts +4 -0
  21. package/dist/types/extensions/courseware/index.d.ts +49 -0
  22. package/dist/types/extensions/courseware/model.d.ts +20 -0
  23. package/dist/types/extensions/courseware/node-view.vue.d.ts +93 -0
  24. package/dist/types/extensions/courseware/reader.vue.d.ts +22 -0
  25. package/dist/types/extensions/smart-sheet/index.d.ts +47 -0
  26. package/dist/types/extensions/smart-sheet/model.d.ts +18 -0
  27. package/dist/types/extensions/smart-sheet/node-view.vue.d.ts +93 -0
  28. package/dist/types/extensions/smart-sheet/viewer.vue.d.ts +36 -0
  29. package/dist/types/i18n.d.ts +375 -18
  30. package/dist/types/options/config/index.d.ts +2 -0
  31. package/dist/types/utils/bubble-note-icon.d.ts +1 -0
  32. package/dist/types/utils/document-formatting.d.ts +41 -37
  33. package/dist/types/utils/document-import.d.ts +2 -0
  34. package/dist/types/utils/html-element-id.d.ts +9 -2
  35. package/dist/types/utils/md5.d.ts +2 -0
  36. package/dist/viewer-CyuLA7YS.js +97 -0
  37. package/docs/FORMATTING_TEMPLATES.md +253 -250
  38. package/docs/FORMATTING_TEMPLATE_BUSINESS_GUIDE.md +536 -0
  39. package/docs/README.md +1 -0
  40. package/docs/SECONDARY_DEVELOPMENT.md +1 -1
  41. package/docs/api.md +43 -0
  42. package/docs/configuration.md +82 -0
  43. package/docs/custom-components.md +1 -1
  44. package/docs/development.md +6 -2
  45. package/docs/menu-extension.md +26 -1
  46. package/package.json +165 -153
  47. /package/dist/types/components/{menus/toolbar/view/preview.vue.d.ts → editor/courseware-dialog.vue.d.ts} +0 -0
@@ -38,6 +38,7 @@
38
38
  | `theme` | `'light'` | `'light'`、`'dark'`、`'auto'` |
39
39
  | `skin` | `'default'` | `'default'` 或 `'modern'` |
40
40
  | `height` | `'100%'` | 父容器必须具有明确高度 |
41
+ | `preview` | `false` | 内容预览模式,自动只读并隐藏编辑工具栏 |
41
42
  | `fullscreenZIndex` | `10` | 全屏层级 |
42
43
  | `dicts` | 内置字典 | 字体、颜色、字号、页面预设等 |
43
44
  | `toolbar` | 对象 | 工具栏模式、菜单和操作区 |
@@ -54,6 +55,87 @@
54
55
  | `diagrams` | 对象 | 绘图配置 |
55
56
  | `echarts` | 对象 | 图表配置 |
56
57
 
58
+ ## 内容预览
59
+
60
+ 通过顶层 `preview` 属性可以直接进入预览状态:
61
+
62
+ ```vue
63
+ <AgileEditor
64
+ :preview="true"
65
+ :document="{ content: html }"
66
+ />
67
+ ```
68
+
69
+ 开启后会自动:
70
+
71
+ - 设置编辑器为只读。
72
+ - 添加预览模式布局。
73
+ - 隐藏开始、插入、表格、工具等编辑工具栏。
74
+ - 保留阅读态气泡注释等只读交互。
75
+
76
+ 运行时可通过组件方法切换:
77
+
78
+ ```ts
79
+ editorRef.value.setPreview(true)
80
+ editorRef.value.setPreview(false)
81
+ ```
82
+
83
+ 业务端不需要再手动修改 `getPage().preview.enabled`。
84
+
85
+ 预览参数和编辑态工具配置是分开的。编辑态需要隐藏部分辅助功能时,仍通过
86
+ `document` 和 `page` 配置:
87
+
88
+ ```ts
89
+ const editorOptions = {
90
+ preview: false,
91
+ document: {
92
+ autofocus: false,
93
+ enableBubbleMenu: false,
94
+ enableBlockMenu: false,
95
+ },
96
+ page: {
97
+ showBookmark: false,
98
+ showBreakMarks: false,
99
+ showLineNumber: false,
100
+ showToc: false,
101
+ showAI: false,
102
+ },
103
+ }
104
+ ```
105
+
106
+ 这些配置只描述编辑态。`preview: true` 时编辑器会在内部派生预览状态并临时隐藏
107
+ 相关工具,但不会修改上述业务配置;调用 `setPreview(false)` 后会按原配置恢复。
108
+ 因此进入预览时只需要:
109
+
110
+ ```vue
111
+ <AgileEditor :preview="true" :document="{ content: html }" />
112
+ ```
113
+
114
+ ## 气泡注释图标
115
+
116
+ 业务端可通过 `bubbleNote.referenceIcons` 扩展内置图标。每个图标必须提供
117
+ `label`、`value`,并至少从 `svg`、`base64`、`url` 中选择一种来源,且只能选择一种:
118
+
119
+ ```ts
120
+ const options = {
121
+ bubbleNote: {
122
+ referenceIcons: [
123
+ {
124
+ label: {
125
+ zh_CN: '业务图标',
126
+ en_US: 'Business Icon',
127
+ },
128
+ value: 'business-icon',
129
+ url: 'https://example.com/icon.png',
130
+ },
131
+ ],
132
+ },
133
+ }
134
+ ```
135
+
136
+ `url` 支持 http/https 网络图片地址。保存文档时,解析后的实际图标地址会写入
137
+ `data-reference-icon-src`,刷新后不依赖业务端重新匹配图标定义。
138
+
57
139
  ## 文档参数
58
140
 
59
141
  ```js
@@ -39,7 +39,7 @@ import {
39
39
 
40
40
  `AgilePreviewToolbar` 不读取编辑器内部状态。业务侧通过 props 传入当前预览状态,并在事件中更新自己的状态:
41
41
 
42
- 该组件面向只读预览页面和预览弹框,右侧按钮用于隐藏工具栏。编辑器内置的演示模式工具栏是另一套组件,右侧按钮用于退出演示模式,两者用途和交互不同。
42
+ 该组件面向只读预览页面和预览弹框,右侧按钮用于隐藏工具栏。编辑器不再内置旧“演示模式”工具栏;业务端使用 `preview` 或 `setPreview()` 进入内容预览后,可按需组合 `AgilePreviewToolbar`。
43
43
 
44
44
  ```vue
45
45
  <template>
@@ -21,8 +21,12 @@ npm run dev
21
21
  ```
22
22
 
23
23
  - 默认端口:`9000`
24
- - Vite `base`:`/editor-demo`
25
- - 访问地址:`http://localhost:9000/editor-demo`
24
+ - Vite `base`:`/editor`
25
+ - 本机访问:`http://localhost:9000/editor`
26
+ - 局域网访问:启动后使用终端输出的 `Network` 地址,例如
27
+ `http://192.168.3.237:9000/editor`
28
+
29
+ 开发服务默认监听 `0.0.0.0`,同一局域网内的设备可直接访问 `Network` 地址。
26
30
 
27
31
  开发入口链路:
28
32
 
@@ -112,12 +112,37 @@ const editor = shallowRef<Editor>()
112
112
  | `toolbar_table` | “表格”工具栏 |
113
113
  | `toolbar_tools` | “工具”工具栏 |
114
114
  | `toolbar_view` | “视图”工具栏 |
115
- | `toolbar_copyediting` | “审阅/校对”工具栏 |
115
+ | `toolbar_review` | “审阅”工具栏,对应 `review` 菜单 |
116
+ | `toolbar_extension` | “扩展”工具栏,可通过 `extension` 菜单启用 |
117
+ | `toolbar_enhancement` | “增强”工具栏,可通过 `enhancement` 菜单启用 |
116
118
  | `toolbar_actions` | 工具栏右侧操作区 |
117
119
  | `bubble_menu` | 选区或节点浮动菜单 |
118
120
 
119
121
  插槽对应的菜单必须在 `toolbar.menus` 中启用。
120
122
 
123
+ ```vue
124
+ <AgileEditor
125
+ :toolbar="{
126
+ menus: ['base', 'insert', 'extension', 'enhancement'],
127
+ }"
128
+ >
129
+ <template #toolbar_extension="{ toolbarMode }">
130
+ <AgileMenuButton
131
+ ico="block-add"
132
+ text="扩展能力"
133
+ :data-toolbar-mode="toolbarMode"
134
+ />
135
+ </template>
136
+ <template #toolbar_enhancement="{ toolbarMode }">
137
+ <AgileMenuButton
138
+ ico="ai"
139
+ text="增强能力"
140
+ :data-toolbar-mode="toolbarMode"
141
+ />
142
+ </template>
143
+ </AgileEditor>
144
+ ```
145
+
121
146
  ### 按钮打开业务弹窗
122
147
 
123
148
  ```vue
package/package.json CHANGED
@@ -1,154 +1,166 @@
1
- {
2
- "name": "@agilehub/agile-editor",
3
- "version": "1.6.0",
4
- "description": "Rich text editor based on Vue 3 and Tiptap 3",
5
- "author": "lytdev <lytdev@outlook.com>",
6
- "keywords": [
7
- "docs editor",
8
- "document editor",
9
- "editor",
10
- "office edtior",
11
- "online office",
12
- "richtext editor",
13
- "tiptap",
14
- "tiptap3",
15
- "vue editor",
16
- "vue3 editor",
17
- "web editor",
18
- "web office",
19
- "word editor"
20
- ],
21
- "license": "Apache-2.0",
22
- "repository": {
23
- "type": "git",
24
- "url": "https://github.com/lytdev/agile-editor.git"
25
- },
26
- "publishConfig": {
27
- "access": "public"
28
- },
29
- "files": [
30
- "dist",
31
- "docs"
32
- ],
33
- "type": "module",
34
- "types": "./dist/types/components/index.d.ts",
35
- "exports": {
36
- ".": {
37
- "types": "./dist/types/components/index.d.ts",
38
- "import": "./dist/agile-editor.js"
39
- },
40
- "./style": {
41
- "import": "./dist/agile-editor.css"
42
- }
43
- },
44
- "scripts": {
45
- "build": "vue-tsc --noEmit && vite build && vue-tsc -p tsconfig.types.json",
46
- "test:style-target": "node --test tests/style-target.test.mjs tests/style-schema.test.mjs tests/iframe.test.mjs",
47
- "typecheck": "vue-tsc --noEmit",
48
- "dev": "vite --port 9000 --open --force",
49
- "format": "oxfmt --write .",
50
- "lint": "oxlint --fix src",
51
- "analyzer": "vite-bundle-visualizer",
52
- "prepare": "husky",
53
- "prepublishOnly": "npm run build"
54
- },
55
- "dependencies": {
56
- "@agilehub/docx-converter": "1.2.1",
57
- "@agilehub/latex-formula": "1.2.0",
58
- "@eslint/object-schema": "3.0.5",
59
- "@floating-ui/dom": "1.8.0",
60
- "@tiptap/core": "3.32.0",
61
- "@tiptap/extension-bold": "3.32.0",
62
- "@tiptap/extension-code-block": "3.32.0",
63
- "@tiptap/extension-code-block-lowlight": "3.32.0",
64
- "@tiptap/extension-collaboration": "3.32.0",
65
- "@tiptap/extension-details": "3.32.0",
66
- "@tiptap/extension-document": "3.32.0",
67
- "@tiptap/extension-drag-handle": "3.32.0",
68
- "@tiptap/extension-drag-handle-vue-3": "3.32.0",
69
- "@tiptap/extension-heading": "3.32.0",
70
- "@tiptap/extension-horizontal-rule": "3.32.0",
71
- "@tiptap/extension-image": "3.32.0",
72
- "@tiptap/extension-invisible-characters": "3.32.0",
73
- "@tiptap/extension-link": "3.32.0",
74
- "@tiptap/extension-list": "3.32.0",
75
- "@tiptap/extension-mention": "3.32.0",
76
- "@tiptap/extension-node-range": "3.32.0",
77
- "@tiptap/extension-paragraph": "3.32.0",
78
- "@tiptap/extension-subscript": "3.32.0",
79
- "@tiptap/extension-superscript": "3.32.0",
80
- "@tiptap/extension-table": "3.32.0",
81
- "@tiptap/extension-table-of-contents": "3.32.0",
82
- "@tiptap/extension-text-align": "3.32.0",
83
- "@tiptap/extension-text-style": "3.32.0",
84
- "@tiptap/extension-typography": "3.32.0",
85
- "@tiptap/extension-unique-id": "3.32.0",
86
- "@tiptap/extensions": "3.32.0",
87
- "@tiptap/pm": "3.32.0",
88
- "@tiptap/starter-kit": "3.32.0",
89
- "@tiptap/suggestion": "3.32.0",
90
- "@tiptap/vue-3": "3.32.0",
91
- "@tiptap/y-tiptap": "3.0.10",
92
- "@tool-belt/type-predicates": "1.4.1",
93
- "@vueuse/core": "15.0.0",
94
- "@zumer/snapdom": "2.24.18",
95
- "cropperjs": "^2.3.1",
96
- "dom-to-image-more": "3.11.0",
97
- "es-drager": "1.3.4",
98
- "fast-glob": "3.3.3",
99
- "file-saver": "2.0.5",
100
- "flowchart.js": "1.18.0",
101
- "hotkeys-js": "4.0.8",
102
- "jsbarcode": "3.12.3",
103
- "lowlight": "3.3.0",
104
- "mermaid": "12.2.0",
105
- "nzh": "1.0.14",
106
- "plantuml-encoder": "1.4.0",
107
- "plyr": "3.8.5",
108
- "pretty-bytes": "7.2.0",
109
- "pure-svg-code": "1.0.6",
110
- "smooth-signature": "1.1.0",
111
- "swiper": "14.3.0",
112
- "tdesign-vue-next": "1.20.10",
113
- "vue-i18n": "11.4.16",
114
- "y-prosemirror": "1.3.7",
115
- "y-protocols": "1.0.7",
116
- "yjs": "13.6.33"
117
- },
118
- "devDependencies": {
119
- "@types/node": "^26.6.5",
120
- "@vitejs/plugin-vue": "^6.0.10",
121
- "@vue-macros/reactivity-transform": "^3.1.4",
122
- "esbuild": "^0.28.2",
123
- "husky": "^9.1.7",
124
- "less": "^4.9.1",
125
- "less-loader": "^13.0.0",
126
- "lint-staged": "^17.6.0",
127
- "oxfmt": "^0.74.0",
128
- "oxlint": "^1.89.0",
129
- "postcss": "^8.5.31",
130
- "postcss-html": "^2.0.0",
131
- "typescript": "~6.0.3",
132
- "unplugin-auto-import": "^21.1.0",
133
- "unplugin-vue": "^8.0.0",
134
- "unplugin-vue-components": "^32.1.0",
135
- "vite": "^8.3.4",
136
- "vite-bundle-visualizer": "^1.2.1",
137
- "vite-plugin-svg-icons": "^2.0.1",
138
- "vue": "^3.5.44",
139
- "vue-tsc": "^3.3.13"
140
- },
141
- "overrides": {
142
- "rolldown": "^1.2.14",
143
- "prosemirror-model": "1.25.12"
144
- },
145
- "lint-staged": {
146
- "*.{ts,vue,less}": [
147
- "oxfmt --write src",
148
- "oxlint --fix src"
149
- ]
150
- },
151
- "engines": {
152
- "node": "^22.22.1 || ^24.11.0 || >=26.0.0"
153
- }
1
+ {
2
+ "name": "@agilehub/agile-editor",
3
+ "version": "1.8.0",
4
+ "description": "Rich text editor based on Vue 3 and Tiptap 3",
5
+ "author": "lytdev <lytdev@outlook.com>",
6
+ "keywords": [
7
+ "docs editor",
8
+ "document editor",
9
+ "editor",
10
+ "office edtior",
11
+ "online office",
12
+ "richtext editor",
13
+ "tiptap",
14
+ "tiptap3",
15
+ "vue editor",
16
+ "vue3 editor",
17
+ "web editor",
18
+ "web office",
19
+ "word editor"
20
+ ],
21
+ "license": "Apache-2.0",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/lytdev/agile-editor.git"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "docs"
32
+ ],
33
+ "type": "module",
34
+ "types": "./dist/types/components/index.d.ts",
35
+ "exports": {
36
+ ".": {
37
+ "types": "./dist/types/components/index.d.ts",
38
+ "import": "./dist/agile-editor.js"
39
+ },
40
+ "./style": {
41
+ "import": "./dist/agile-editor.css"
42
+ }
43
+ },
44
+ "scripts": {
45
+ "build": "vue-tsc --noEmit && vite build && vue-tsc -p tsconfig.types.json",
46
+ "test:style-target": "node --test tests/style-target.test.mjs tests/style-schema.test.mjs tests/iframe.test.mjs tests/bookmark-transaction.test.mjs",
47
+ "typecheck": "vue-tsc --noEmit",
48
+ "dev": "vite --port 9000 --open --force",
49
+ "format": "oxfmt --write .",
50
+ "lint": "oxlint --fix src",
51
+ "lint:style": "stylelint \"src/**/*.{vue,less}\" \"dev/**/*.{vue,less}\"",
52
+ "lint:style:fix": "stylelint \"src/**/*.{vue,less}\" \"dev/**/*.{vue,less}\" --fix",
53
+ "analyzer": "vite-bundle-visualizer",
54
+ "prepare": "husky",
55
+ "prepublishOnly": "npm run build"
56
+ },
57
+ "dependencies": {
58
+ "@agilehub/docx-converter": "1.2.1",
59
+ "@agilehub/latex-formula": "1.2.0",
60
+ "@agilehub/vue-pdf-flipbook": "^2.1.1",
61
+ "@eslint/object-schema": "3.0.5",
62
+ "@floating-ui/dom": "1.8.0",
63
+ "@tiptap/core": "3.32.0",
64
+ "@tiptap/extension-bold": "3.32.0",
65
+ "@tiptap/extension-code-block": "3.32.0",
66
+ "@tiptap/extension-code-block-lowlight": "3.32.0",
67
+ "@tiptap/extension-collaboration": "3.32.0",
68
+ "@tiptap/extension-details": "3.32.0",
69
+ "@tiptap/extension-document": "3.32.0",
70
+ "@tiptap/extension-drag-handle": "3.32.0",
71
+ "@tiptap/extension-drag-handle-vue-3": "3.32.0",
72
+ "@tiptap/extension-heading": "3.32.0",
73
+ "@tiptap/extension-horizontal-rule": "3.32.0",
74
+ "@tiptap/extension-image": "3.32.0",
75
+ "@tiptap/extension-invisible-characters": "3.32.0",
76
+ "@tiptap/extension-link": "3.32.0",
77
+ "@tiptap/extension-list": "3.32.0",
78
+ "@tiptap/extension-node-range": "3.32.0",
79
+ "@tiptap/extension-paragraph": "3.32.0",
80
+ "@tiptap/extension-subscript": "3.32.0",
81
+ "@tiptap/extension-superscript": "3.32.0",
82
+ "@tiptap/extension-table": "3.32.0",
83
+ "@tiptap/extension-table-of-contents": "3.32.0",
84
+ "@tiptap/extension-text-align": "3.32.0",
85
+ "@tiptap/extension-text-style": "3.32.0",
86
+ "@tiptap/extension-typography": "3.32.0",
87
+ "@tiptap/extension-unique-id": "3.32.0",
88
+ "@tiptap/extensions": "3.32.0",
89
+ "@tiptap/pm": "3.32.0",
90
+ "@tiptap/starter-kit": "3.32.0",
91
+ "@tiptap/vue-3": "3.32.0",
92
+ "@tiptap/y-tiptap": "3.0.10",
93
+ "@tool-belt/type-predicates": "1.4.1",
94
+ "@vueuse/core": "15.0.0",
95
+ "@zumer/snapdom": "2.24.18",
96
+ "cropperjs": "^2.3.1",
97
+ "dom-to-image-more": "3.11.0",
98
+ "es-drager": "1.3.4",
99
+ "file-saver": "2.0.5",
100
+ "flowchart.js": "1.18.0",
101
+ "hotkeys-js": "4.0.8",
102
+ "hyperformula": "3.1.0",
103
+ "lowlight": "3.3.0",
104
+ "mermaid": "12.2.0",
105
+ "nzh": "1.0.14",
106
+ "ooxml-excel-editor": "1.16.3",
107
+ "plantuml-encoder": "1.4.0",
108
+ "plyr": "3.8.5",
109
+ "pretty-bytes": "7.2.0",
110
+ "swiper": "14.3.0",
111
+ "tdesign-vue-next": "1.20.10",
112
+ "vue-i18n": "11.4.16",
113
+ "y-protocols": "1.0.7",
114
+ "yjs": "13.6.33"
115
+ },
116
+ "devDependencies": {
117
+ "@types/node": "^26.6.5",
118
+ "@vitejs/plugin-vue": "^6.0.10",
119
+ "@vue-macros/reactivity-transform": "^3.1.4",
120
+ "esbuild": "^0.28.2",
121
+ "fast-glob": "3.3.3",
122
+ "husky": "^9.1.7",
123
+ "less": "^4.9.1",
124
+ "lint-staged": "^17.6.0",
125
+ "oxfmt": "^0.74.0",
126
+ "oxlint": "^1.89.0",
127
+ "postcss": "^8.5.31",
128
+ "postcss-html": "^2.0.0",
129
+ "stylelint": "^18.0.0",
130
+ "stylelint-config-html": "^2.0.0",
131
+ "stylelint-config-recommended": "^19.0.0",
132
+ "stylelint-config-recommended-less": "^5.0.0",
133
+ "stylelint-config-recommended-vue": "^2.0.0",
134
+ "stylelint-less": "^5.0.0",
135
+ "typescript": "~6.0.3",
136
+ "unplugin-auto-import": "^21.1.0",
137
+ "unplugin-vue-components": "^32.1.0",
138
+ "vite": "^8.3.4",
139
+ "vite-bundle-visualizer": "^1.2.1",
140
+ "vite-plugin-svg-icons": "^2.0.1",
141
+ "vue": "^3.5.44",
142
+ "vue-tsc": "^3.3.13"
143
+ },
144
+ "overrides": {
145
+ "rolldown": "^1.2.14",
146
+ "prosemirror-model": "1.25.12"
147
+ },
148
+ "lint-staged": {
149
+ "*.ts": [
150
+ "oxfmt --write",
151
+ "oxlint --fix"
152
+ ],
153
+ "*.vue": [
154
+ "oxfmt --write",
155
+ "oxlint --fix",
156
+ "stylelint --fix"
157
+ ],
158
+ "*.less": [
159
+ "oxfmt --write",
160
+ "stylelint --fix"
161
+ ]
162
+ },
163
+ "engines": {
164
+ "node": "^22.22.1 || ^24.11.0 || >=26.0.0"
165
+ }
154
166
  }