f-docx-editor 0.1.3 → 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/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
- cd dist
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,99 +1,58 @@
1
- {
2
- "name": "f-docx-editor",
3
- "version": "0.1.3",
4
- "description": "Vue 3 Word docx preview, editable rich-text regions and docx export component.",
5
- "keywords": [
6
- "vue3",
7
- "docx",
8
- "docxtemplater",
9
- "docx-preview",
10
- "tiptap",
11
- "word"
12
- ],
13
- "license": "MIT",
14
- "main": "./dist/FDocxEditor.common.js",
15
- "unpkg": "./dist/FDocxEditor.umd.min.js",
16
- "jsdelivr": "./dist/FDocxEditor.umd.min.js",
17
- "files": [
18
- "dist"
19
- ],
20
- "scripts": {
21
- "dev": "vue-cli-service serve",
22
- "build": "vue-cli-service build",
23
- "build:lib": "vue-cli-service build --target lib --name FDocxEditor --dest dist src/index.js && node scripts/prepare-package.mjs",
24
- "lint": "vue-cli-service lint",
25
- "prepublishOnly": "npm run build:lib"
26
- },
27
- "peerDependencies": {
28
- "vue": "^3.2.13",
29
- "element-plus": "^2.6.2"
30
- },
31
- "dependencies": {
32
- "@element-plus/icons-vue": "^2.3.1",
33
- "@tiptap/core": "3.23.5",
34
- "@tiptap/extension-color": "3.23.5",
35
- "@tiptap/extension-highlight": "3.23.5",
36
- "@tiptap/extension-placeholder": "3.23.5",
37
- "@tiptap/extension-table": "3.23.5",
38
- "@tiptap/extension-table-cell": "3.23.5",
39
- "@tiptap/extension-table-header": "3.23.5",
40
- "@tiptap/extension-table-row": "3.23.5",
41
- "@tiptap/extension-text-align": "3.23.5",
42
- "@tiptap/extension-text-style": "3.23.5",
43
- "@tiptap/pm": "3.23.5",
44
- "@tiptap/starter-kit": "3.23.5",
45
- "@tiptap/vue-3": "3.23.5",
46
- "docx-preview": "^0.3.7",
47
- "docxtemplater": "^3.68.7",
48
- "docxtemplater-image-module-free": "^1.1.1",
49
- "echarts": "^5.5.0",
50
- "pizzip": "^3.2.0"
51
- },
52
- "devDependencies": {
53
- "@babel/core": "^7.12.16",
54
- "@babel/eslint-parser": "^7.12.16",
55
- "@vue/cli-plugin-babel": "~5.0.0",
56
- "@vue/cli-plugin-eslint": "~5.0.0",
57
- "@vue/cli-service": "~5.0.0",
58
- "core-js": "^3.8.3",
59
- "element-plus": "^2.6.2",
60
- "eslint": "^7.32.0",
61
- "eslint-plugin-vue": "^8.0.3",
62
- "less": "^4.0.0",
63
- "less-loader": "^8.0.0",
64
- "vue": "^3.2.13"
65
- },
66
- "eslintConfig": {
67
- "root": true,
68
- "env": {
69
- "node": true,
70
- "browser": true
71
- },
72
- "extends": [
73
- "plugin:vue/vue3-essential",
74
- "eslint:recommended"
75
- ],
76
- "parserOptions": {
77
- "parser": "@babel/eslint-parser",
78
- "ecmaVersion": 2020,
79
- "sourceType": "module"
80
- },
81
- "globals": {
82
- "defineProps": "readonly",
83
- "defineEmits": "readonly",
84
- "defineExpose": "readonly"
85
- },
86
- "rules": {
87
- "no-unused-vars": "error"
88
- }
89
- },
90
- "browserslist": [
91
- "> 1%",
92
- "last 2 versions",
93
- "not dead",
94
- "not ie 11"
95
- ],
96
- "sideEffects": [
97
- "*.css"
98
- ]
99
- }
1
+ {
2
+ "name": "f-docx-editor",
3
+ "version": "0.1.5",
4
+ "description": "Vue 3 Word docx preview, editable rich-text regions and docx export component.",
5
+ "keywords": [
6
+ "vue3",
7
+ "docx",
8
+ "docxtemplater",
9
+ "docx-preview",
10
+ "tiptap",
11
+ "word"
12
+ ],
13
+ "license": "MIT",
14
+ "main": "./FDocxEditor.common.js",
15
+ "module": "./FDocxEditor.common.js",
16
+ "style": "./FDocxEditor.css",
17
+ "unpkg": "./FDocxEditor.umd.min.js",
18
+ "jsdelivr": "./FDocxEditor.umd.min.js",
19
+ "files": [
20
+ "FDocxEditor.common.594.js",
21
+ "FDocxEditor.common.817.js",
22
+ "FDocxEditor.common.js",
23
+ "FDocxEditor.umd.828.js",
24
+ "FDocxEditor.umd.844.js",
25
+ "FDocxEditor.umd.js",
26
+ "FDocxEditor.umd.min.642.js",
27
+ "FDocxEditor.umd.min.947.js",
28
+ "FDocxEditor.umd.min.js",
29
+ "FDocxEditor.css",
30
+ "README.md"
31
+ ],
32
+ "peerDependencies": {
33
+ "@element-plus/icons-vue": "^2.3.1",
34
+ "@tiptap/core": "3.23.5",
35
+ "@tiptap/extension-color": "3.23.5",
36
+ "@tiptap/extension-highlight": "3.23.5",
37
+ "@tiptap/extension-placeholder": "3.23.5",
38
+ "@tiptap/extension-table": "3.23.5",
39
+ "@tiptap/extension-table-cell": "3.23.5",
40
+ "@tiptap/extension-table-header": "3.23.5",
41
+ "@tiptap/extension-table-row": "3.23.5",
42
+ "@tiptap/extension-text-align": "3.23.5",
43
+ "@tiptap/extension-text-style": "3.23.5",
44
+ "@tiptap/pm": "3.23.5",
45
+ "@tiptap/starter-kit": "3.23.5",
46
+ "@tiptap/vue-3": "3.23.5",
47
+ "docx-preview": "^0.3.7",
48
+ "docxtemplater": "^3.68.7",
49
+ "docxtemplater-image-module-free": "^1.1.1",
50
+ "echarts": "^5.5.0",
51
+ "element-plus": "2.6.2",
52
+ "pizzip": "^3.2.0",
53
+ "vue": "^3.2.13"
54
+ },
55
+ "sideEffects": [
56
+ "*.css"
57
+ ]
58
+ }