ai-word-editor 0.0.1 → 0.0.3
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 +31 -7
- package/dist/index.js +374 -376
- package/package.json +4 -19
package/README.md
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ai-word-editor(作为组件包使用)
|
|
2
2
|
|
|
3
3
|
本仓库已改造为 **Vue3 组件包**:你可以把它当成另一个 Vue3 + Vite 项目的依赖来 `import` 使用。
|
|
4
4
|
|
|
5
|
+
## 0. 安装
|
|
6
|
+
|
|
7
|
+
在你的 Vue3 项目中安装本包(内部会自动依赖所需库):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install ai-word-editor
|
|
11
|
+
```
|
|
12
|
+
|
|
5
13
|
## 1. 打包
|
|
6
14
|
|
|
7
15
|
在本仓库执行:
|
|
@@ -21,7 +29,7 @@ npm run build:lib
|
|
|
21
29
|
```json
|
|
22
30
|
{
|
|
23
31
|
"dependencies": {
|
|
24
|
-
"
|
|
32
|
+
"ai-word-editor": "file:../umo-edior"
|
|
25
33
|
}
|
|
26
34
|
}
|
|
27
35
|
```
|
|
@@ -35,7 +43,7 @@ npm i
|
|
|
35
43
|
### 方式 B:发布到私有 npm(适合多人/多环境复用)
|
|
36
44
|
|
|
37
45
|
- 把 `package.json` 的 `"private": true` 改为 `false`,并设置合适的 `name/version` 后发布到你的 npm 仓库。
|
|
38
|
-
- 宿主项目正常 `npm i
|
|
46
|
+
- 宿主项目正常 `npm i ai-word-editor` 安装即可。
|
|
39
47
|
|
|
40
48
|
## 3. 宿主项目使用
|
|
41
49
|
|
|
@@ -44,8 +52,8 @@ npm i
|
|
|
44
52
|
```ts
|
|
45
53
|
import { createApp } from 'vue'
|
|
46
54
|
import App from './App.vue'
|
|
47
|
-
import { UmoEditorAppPlugin } from '
|
|
48
|
-
import '
|
|
55
|
+
import { UmoEditorAppPlugin } from 'ai-word-editor'
|
|
56
|
+
import 'ai-word-editor/style.css'
|
|
49
57
|
|
|
50
58
|
createApp(App).use(UmoEditorAppPlugin, {}).mount('#app')
|
|
51
59
|
```
|
|
@@ -61,10 +69,26 @@ createApp(App).use(UmoEditorAppPlugin, {}).mount('#app')
|
|
|
61
69
|
你也可以按需直接导入组件:
|
|
62
70
|
|
|
63
71
|
```ts
|
|
64
|
-
import { UmoEditorApp } from '
|
|
72
|
+
import { UmoEditorApp } from 'ai-word-editor'
|
|
65
73
|
```
|
|
66
74
|
|
|
67
|
-
## 4.
|
|
75
|
+
## 4. 单独使用 Word 导出工具(`exportToDocx`)
|
|
76
|
+
|
|
77
|
+
如果你只想复用导出 `.docx` 的能力,可以单独按需引入工具函数,而不使用整个编辑器组件:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { exportToDocx } from 'ai-word-editor/word-docx-export'
|
|
81
|
+
|
|
82
|
+
await exportToDocx(html, comments, '文件名')
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- `html`:编辑器生成的 HTML 字符串(例如 Tiptap 的 `editor.getHTML()`)
|
|
86
|
+
- `comments`:批注数组,形如 `[{ id, note, author, createdAt, resolved }]`
|
|
87
|
+
- `'文件名'`:导出的文件名(不含 `.docx` 扩展名)
|
|
88
|
+
|
|
89
|
+
需要在宿主项目中安装 `file-saver`、`jszip` 作为依赖。
|
|
90
|
+
|
|
91
|
+
## 5. 重要:`cdnUrl` 静态资源
|
|
68
92
|
|
|
69
93
|
`@umoteam/editor` 需要加载 `@umoteam/editor-external` 的静态资源。**不要依赖** `'/node_modules/@umoteam/editor-external'` 这种路径(线上通常不可用)。
|
|
70
94
|
|