f-docx-editor 0.1.4 → 0.1.5
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/FDocxEditor.common.594.js +688 -0
- package/FDocxEditor.common.817.js +1798 -0
- package/FDocxEditor.common.js +66350 -16035
- package/FDocxEditor.css +1 -1
- package/FDocxEditor.umd.828.js +1798 -0
- package/FDocxEditor.umd.844.js +688 -0
- package/FDocxEditor.umd.js +66511 -16176
- package/FDocxEditor.umd.min.642.js +1 -0
- package/FDocxEditor.umd.min.947.js +1 -0
- package/FDocxEditor.umd.min.js +2 -1
- package/README.md +22 -3
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ npm install f-docx-editor
|
|
|
13
13
|
f-docx-editor/
|
|
14
14
|
├── src/
|
|
15
15
|
│ ├── FDocxEditor.vue # 核心组件
|
|
16
|
+
│ ├── FDocxTemplateEditor.vue # 全文模板编辑组件
|
|
16
17
|
│ ├── index.js # 组件导出入口
|
|
17
18
|
│ ├── App.vue # 开发测试用 App
|
|
18
19
|
│ └── main.js # 开发入口
|
|
@@ -40,8 +41,7 @@ npm run build:lib
|
|
|
40
41
|
发布到 npm
|
|
41
42
|
|
|
42
43
|
npm run build:lib
|
|
43
|
-
|
|
44
|
-
npm publish --access public
|
|
44
|
+
npm run publish
|
|
45
45
|
|
|
46
46
|
```js
|
|
47
47
|
import FDocxEditor from 'f-docx-editor'
|
|
@@ -90,11 +90,28 @@ import 'f-docx-editor/FDocxEditor.css'
|
|
|
90
90
|
| 参数 | 类型 | 默认值 | 说明 |
|
|
91
91
|
| --- | --- | --- | --- |
|
|
92
92
|
| `renderData` | `Object` | `{}` | docxtemplater 渲染数据,包含普通变量、循环数据、图表数据和富文本数据 |
|
|
93
|
-
| `renderType` | `'view' \| 'edit'` | `'view'` | `view` 为只预览,`edit`
|
|
93
|
+
| `renderType` | `'view' \| 'edit' \| 'templateEdit'` | `'view'` | `view` 为只预览,`edit` 为定点可编辑,`templateEdit` 为全文模板编辑 |
|
|
94
94
|
| `templateUrl` | `String` | `''` | 推荐使用,指定 docx 模板文件地址 |
|
|
95
95
|
| `templateFileName` | `String` | `'运营报告.docx'` | 未传 `templateUrl` 时,从站点根路径加载该文件 |
|
|
96
96
|
| `exportFileName` | `String` | `''` | 自定义导出文件名 |
|
|
97
97
|
|
|
98
|
+
## 模板编辑
|
|
99
|
+
|
|
100
|
+
`renderType="templateEdit"` 会进入全文 Word 模板编辑模式。该模式直接加载原始 docx 模板,不执行变量渲染,也不会隐藏 `[EDITOR_START]` / `[EDITOR_END]` 等显性标签。
|
|
101
|
+
|
|
102
|
+
保存模板时通过组件 ref 调用 `saveTemplate()`,组件会抛出 `template-save` 事件,由外层把修改后的 docx 文件提交给后端。
|
|
103
|
+
|
|
104
|
+
```vue
|
|
105
|
+
<template>
|
|
106
|
+
<FDocxEditor
|
|
107
|
+
ref="editorRef"
|
|
108
|
+
render-type="templateEdit"
|
|
109
|
+
template-url="/api/report-template.docx"
|
|
110
|
+
@template-save="handleTemplateSave"
|
|
111
|
+
/>
|
|
112
|
+
</template>
|
|
113
|
+
```
|
|
114
|
+
|
|
98
115
|
## 暴露方法
|
|
99
116
|
|
|
100
117
|
通过 `ref` 可以调用:
|
|
@@ -106,6 +123,8 @@ import 'f-docx-editor/FDocxEditor.css'
|
|
|
106
123
|
| `getSavePayload()` | 获取建议提交给后端的保存结构 |
|
|
107
124
|
| `getEditorHtml()` | 获取当前弹窗编辑器 HTML |
|
|
108
125
|
| `getEditorJson()` | 获取当前弹窗编辑器 JSON |
|
|
126
|
+
| `saveTemplate()` | 保存全文模板编辑后的 docx,并触发 `template-save` |
|
|
127
|
+
| `reloadTemplate()` | 重新加载当前模板文件 |
|
|
109
128
|
|
|
110
129
|
## 数据安全建议
|
|
111
130
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "f-docx-editor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Vue 3 Word docx preview, editable rich-text regions and docx export component.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue3",
|
|
@@ -17,15 +17,19 @@
|
|
|
17
17
|
"unpkg": "./FDocxEditor.umd.min.js",
|
|
18
18
|
"jsdelivr": "./FDocxEditor.umd.min.js",
|
|
19
19
|
"files": [
|
|
20
|
+
"FDocxEditor.common.594.js",
|
|
21
|
+
"FDocxEditor.common.817.js",
|
|
20
22
|
"FDocxEditor.common.js",
|
|
23
|
+
"FDocxEditor.umd.828.js",
|
|
24
|
+
"FDocxEditor.umd.844.js",
|
|
21
25
|
"FDocxEditor.umd.js",
|
|
26
|
+
"FDocxEditor.umd.min.642.js",
|
|
27
|
+
"FDocxEditor.umd.min.947.js",
|
|
22
28
|
"FDocxEditor.umd.min.js",
|
|
23
29
|
"FDocxEditor.css",
|
|
24
30
|
"README.md"
|
|
25
31
|
],
|
|
26
32
|
"peerDependencies": {
|
|
27
|
-
"vue": "^3.2.13",
|
|
28
|
-
"element-plus": "^2.6.2",
|
|
29
33
|
"@element-plus/icons-vue": "^2.3.1",
|
|
30
34
|
"@tiptap/core": "3.23.5",
|
|
31
35
|
"@tiptap/extension-color": "3.23.5",
|
|
@@ -44,7 +48,9 @@
|
|
|
44
48
|
"docxtemplater": "^3.68.7",
|
|
45
49
|
"docxtemplater-image-module-free": "^1.1.1",
|
|
46
50
|
"echarts": "^5.5.0",
|
|
47
|
-
"
|
|
51
|
+
"element-plus": "2.6.2",
|
|
52
|
+
"pizzip": "^3.2.0",
|
|
53
|
+
"vue": "^3.2.13"
|
|
48
54
|
},
|
|
49
55
|
"sideEffects": [
|
|
50
56
|
"*.css"
|