@a200888213/gbdocx 0.6.1 → 0.6.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/LICENSE +21 -21
- package/README.md +215 -215
- package/index.html +31 -30
- package/package.json +49 -48
- package/serve.mjs +27 -23
- package/src/app/file-io.js +122 -122
- package/src/app/main.js +9 -9
- package/src/app/word/catalog.js +52 -52
- package/src/app/word/comments.js +112 -112
- package/src/app/word/doc.js +113 -113
- package/src/app/word/edit.js +72 -72
- package/src/app/word/file.js +191 -191
- package/src/app/word/hf.js +76 -76
- package/src/app/word/layout.js +155 -155
- package/src/app/word/menus.js +201 -201
- package/src/app/word/notes.js +110 -110
- package/src/app/word/shared.js +22 -22
- package/src/app/word/view.js +159 -159
- package/src/app/word-app.js +487 -487
- package/src/app/word-sheets.js +101 -101
- package/src/kernel/docx/catalog.js +41 -41
- package/src/kernel/docx/codec/blocks.js +123 -123
- package/src/kernel/docx/codec/carry.js +129 -129
- package/src/kernel/docx/codec/comments.js +25 -25
- package/src/kernel/docx/codec/docx.js +198 -198
- package/src/kernel/docx/codec/docxStyles.js +177 -177
- package/src/kernel/docx/codec/fonts.js +195 -195
- package/src/kernel/docx/codec/helpers.js +161 -161
- package/src/kernel/docx/codec/hfHtml.js +152 -152
- package/src/kernel/docx/codec/html.js +739 -739
- package/src/kernel/docx/codec/losses.js +420 -420
- package/src/kernel/docx/codec/markdown.js +170 -170
- package/src/kernel/docx/codec/parts.js +249 -249
- package/src/kernel/docx/codec/read.js +603 -603
- package/src/kernel/docx/codec/render.js +1156 -1156
- package/src/kernel/docx/codec/roundtrip.js +236 -236
- package/src/kernel/docx/codec/write.js +833 -833
- package/src/kernel/docx/comments.js +14 -14
- package/src/kernel/docx/menus.js +348 -348
- package/src/kernel/docx/pageGeometry.js +123 -123
- package/src/kernel/docx/pagination.js +481 -481
- package/src/kernel/docx/watermark.js +45 -45
- package/src/kernel/docx/wordShortcuts.js +37 -37
- package/src/kernel/editor/constants.js +8 -8
- package/src/kernel/editor/engine/blocks.js +594 -594
- package/src/kernel/editor/engine/blocksEnter.js +109 -109
- package/src/kernel/editor/engine/blocksInsert.js +254 -254
- package/src/kernel/editor/engine/blocksStructure.js +226 -226
- package/src/kernel/editor/engine/commands.js +181 -181
- package/src/kernel/editor/engine/dom.js +646 -646
- package/src/kernel/editor/engine/editor.js +213 -213
- package/src/kernel/editor/engine/history.js +149 -149
- package/src/kernel/editor/engine/inline.js +656 -656
- package/src/kernel/editor/engine/input.js +554 -554
- package/src/kernel/editor/engine/interaction.js +137 -137
- package/src/kernel/editor/engine/pointer.js +39 -39
- package/src/kernel/editor/engine/revision.js +138 -138
- package/src/kernel/editor/engine/schema.js +417 -417
- package/src/kernel/editor/engine/search.js +113 -113
- package/src/kernel/editor/engine/selection.js +119 -119
- package/src/kernel/editor/engine/state.js +118 -118
- package/src/kernel/editor/engine/tableClip.js +154 -154
- package/src/kernel/editor/engine/tableGrid.js +55 -55
- package/src/kernel/editor/engine/tableInteraction.js +388 -388
- package/src/kernel/editor/engine/tableMenu.js +250 -250
- package/src/kernel/editor/engine/tableOps.js +174 -174
- package/src/kernel/editor/engine/tables.js +732 -732
- package/src/kernel/editor/overlayGeometry.js +20 -20
- package/src/kernel/editor/pasteClean.js +293 -293
- package/src/kernel/editor/utils.js +48 -48
- package/src/kernel/keyboard.js +114 -114
- package/src/kernel/notify.js +54 -54
- package/src/kernel/textStyles.js +84 -84
- package/src/kernel/util/clipboard.js +89 -89
- package/src/kernel/util/imageFile.js +91 -91
- package/src/kernel/util/safeValue.js +25 -25
- package/src/kernel/util/shortcutKey.js +33 -33
- package/src/surface/editor-surface.js +603 -600
- package/src/ui/color-panel.js +69 -69
- package/src/ui/context-menu.js +135 -133
- package/src/ui/dialogs.js +249 -249
- package/src/ui/find-bar.js +151 -151
- package/src/ui/icons.js +245 -137
- package/src/ui/menubar.js +28 -28
- package/src/ui/panels.js +115 -115
- package/src/ui/popup.js +79 -79
- package/src/ui/prompt.js +89 -89
- package/src/ui/ribbon.js +485 -485
- package/src/ui/special-chars.js +39 -39
- package/src/ui/statusbar.js +81 -81
- package/src/ui/toolbar.js +32 -32
- package/styles/app.css +970 -970
- package/styles/editor-content.css +440 -440
- package/styles/tokens.css +154 -154
- package/styles/word-panel.css +410 -410
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 甲宁
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 甲宁
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,215 +1,215 @@
|
|
|
1
|
-
# @a200888213/gbdocx
|
|
2
|
-
|
|
3
|
-
独立 `.docx` 编辑器:**OOXML docx 编解码内核 + 自研 contenteditable 编辑器内核 + 原生 HTML 界面**。
|
|
4
|
-
|
|
5
|
-
没有 React/Vue,没有 ProseMirror/TipTap,没有 CKEditor。整个包只依赖 [`gbooxml`](https://www.npmjs.com/package/gbooxml) 做 ZIP 与 XML,其余全部自持:`.docx` 双向编解码、以 DOM 为文档模型的编辑器内核、分页/页眉页脚/脚注尾注/批注/修订,以及菜单、工具栏、查找、颜色面板这一整套 UI。
|
|
6
|
-
|
|
7
|
-
## 三层结构
|
|
8
|
-
|
|
9
|
-
| 层 | 入口 | 职责 |
|
|
10
|
-
| --- | --- | --- |
|
|
11
|
-
| 编解码 | `@a200888213/gbdocx/kernel/docx/codec/*` | `.docx` 字节 ⇄ 文档模型 ⇄ HTML |
|
|
12
|
-
| 编辑器内核 | `@a200888213/gbdocx/surface/editor-surface` | `EditorSurface` 承载 `EditorCore`:命令、状态快照、历史、表格、批注、修订 |
|
|
13
|
-
| 完整应用 | `@a200888213/gbdocx`(根入口) | `WordApp`:把上面两层装配成一个可用的 Word 界面 |
|
|
14
|
-
|
|
15
|
-
只想做一个在线文档编辑器 → 用 `WordApp`;已有自己的界面、只要编辑内核 → 用 `EditorSurface`;只要读写文件、不要编辑器 → 用 codec。
|
|
16
|
-
|
|
17
|
-
## 安装
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm install @a200888213/gbdocx
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## 样式隔离(0.3.0 起)
|
|
24
|
-
|
|
25
|
-
- CSS 自定义属性统一用包专属前缀 `--gbd-*`,类名统一用 `gbd-*` / `gbd-is-*`;四个 gb 包可同时挂在同一个宿主页面,不会互相覆盖,也不会撞上 Element Plus 的 `.is-*` 状态类。
|
|
26
|
-
- 页面级底座规则(`html,body` / `body` / `#app` / `*` / `button` / 滚动条)只挂在 `.gbd-root` 作用域内:**嵌入宿主时挂载点必须带 `gbd-root` 类**,否则字体、高度与盒模型底座不生效;宿主的 `body` / `#app` / 全局按钮不受任何影响。
|
|
27
|
-
- `:root` 的设计令牌保持全局可见(菜单与弹层会挂到 `body`),变量名已包专属;暗色令牌由 `[data-gbd-theme='dark']` 切换,不再被宿主的 `data-theme` 误触发。
|
|
28
|
-
|
|
29
|
-
## 先把它跑起来
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npm start # node serve.mjs,默认 http://localhost:5273/
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
`serve.mjs` 只是薄封装,静态服务器本体是 `guabiutils/dev-server`(三端共用同一份),端口可 `node serve.mjs 8080` 或用环境变量 `GBDOCX_PORT`。打开根路径即为完整编辑器,控制台里有 `window.gbdocx` 指向 `WordApp` 实例,可直接调 `await window.gbdocx.selfTest()` 做一次全链路自检。
|
|
36
|
-
|
|
37
|
-
页面本身只有 `index.html`,它加载四个样式表(顺序有意义):`tokens.css` → `editor-content.css` → `word-panel.css` → `app.css`。自己装配页面时请全部引入,否则正文排版和面板都会走形。
|
|
38
|
-
|
|
39
|
-
`index.html` 里有一条 importmap,把裸标识符 `gbooxml` / `guabiutils` 映射到 `/vendor/*`,而 `serve.mjs` 把 `/vendor/gbooxml/*`、`/vendor/gbofficeui/*` 指向 `packages/gboffice/` 下的同级源码,把 `/vendor/guabiutils/*` 指向仓库的 `packages/guabiutils/src`。这意味着这个自带 demo 只在仓库的 monorepo 布局下能跑;从 npm 单独安装后要用 demo 页面,请自行把 `gbooxml` 映射到 `node_modules/gbooxml/src/index.js`,并按下方顺序引入四份样式(顶栏皮肤来自 `gbofficeui`)。
|
|
40
|
-
|
|
41
|
-
## 嵌入到自己的页面
|
|
42
|
-
|
|
43
|
-
```js
|
|
44
|
-
import { WordApp } from '@a200888213/gbdocx';
|
|
45
|
-
import '@a200888213/gbdocx/styles/tokens.css';
|
|
46
|
-
import '@a200888213/gbdocx/styles/editor-content.css';
|
|
47
|
-
import '@a200888213/gbdocx/styles/word-panel.css';
|
|
48
|
-
import '@a200888213/gbdocx/styles/app.css';
|
|
49
|
-
import 'gbofficeui/styles/office-chrome.css'; // 菜单栏/文档头/功能区/状态栏共享皮肤
|
|
50
|
-
|
|
51
|
-
const app = new WordApp(document.getElementById('app'));
|
|
52
|
-
await app.start();
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
第一个参数是一个**已经挂在文档里的 DOM 元素**,编辑器 UI 会 `appendChild` 进去;第二个参数是可选 options:`embed` / `io` / `onDirty` / `isActive` 用于嵌入宿主,`readOnly` / `hideMenuBar` 见下一节。实例方法:
|
|
56
|
-
|
|
57
|
-
```js
|
|
58
|
-
app.setEditMode('readonly'); // 'edit' | 'suggest' | 'readonly'
|
|
59
|
-
app.setZoom(120); // 40–300,会持久化到 localStorage
|
|
60
|
-
app.setView('commentsPanel', true);
|
|
61
|
-
await app.saveAs(); // 另存为 .docx(优先 File System Access API,回落下载)
|
|
62
|
-
app.print();
|
|
63
|
-
app.destroy(); // 停观察器与定时器,但不会把 DOM 从挂载点摘掉
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
`destroy()` 只解除副作用(ResizeObserver、window resize、分页与自动保存定时器),**不会**移除它自己插入的 DOM;要彻底回收请连挂载点子树一起删。
|
|
67
|
-
|
|
68
|
-
## 文档头(0.6.0 起)
|
|
69
|
-
|
|
70
|
-
文档头骨架由 `gbofficeui` 的 `createOfficeHead` 统一生成(gbdocx / gbpptx / gbxlxs 三家同一套):标题 → 重命名 → 状态 → 自动保存 / 保存 → 下载 → 预览 → 全屏。
|
|
71
|
-
|
|
72
|
-
- 「重命名」是标题右侧的一枚图标钮(悬停出提示),「下载」紧挨「预览」;
|
|
73
|
-
- 嵌入模式由宿主接管:`io.rename(event)` / `io.download()`;`io.getTitle()` / `io.getPath()` 还能覆盖标题与路径显示。不提供就不渲染对应按钮;
|
|
74
|
-
- 独立模式走包内实现:重命名弹气泡改名,下载导出当前 `.docx`。
|
|
75
|
-
|
|
76
|
-
## 只读与隐藏菜单栏
|
|
77
|
-
|
|
78
|
-
`@a200888213/gbdocx` / `gbxlxs` / `gbpptx` 三个编辑器用同一套开关(`guabiutils` 的 `createReadOnlyGuard` 提供 DOM 层守卫,各包自己接模型层闸门):
|
|
79
|
-
|
|
80
|
-
| 能力 | 构造参数 | 运行时方法 |
|
|
81
|
-
| --- | --- | --- |
|
|
82
|
-
| 只读预览 | `readOnly: true` | `app.setReadOnly(on)` |
|
|
83
|
-
| 隐藏顶部菜单栏那一行 | `hideMenuBar: true` | `app.setMenuBarVisible(on)` |
|
|
84
|
-
|
|
85
|
-
```js
|
|
86
|
-
const app = new WordApp(mountEl, { embed: true, readOnly: true, hideMenuBar: true });
|
|
87
|
-
await app.start();
|
|
88
|
-
|
|
89
|
-
app.setReadOnly(false); // 回到可编辑
|
|
90
|
-
app.setMenuBarVisible(true); // 再显示菜单栏
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
只读档下:内核切到 `editMode='readonly'`(正文 `contenteditable` 关闭、`run()` 拒绝写命令),工具栏与文件头 `inert`,编辑/插入/表格/格式菜单禁用,状态栏的模式/页边距/分栏开关与查找栏的替换行一并锁定;选区、滚动、复制、查找、缩放、导出与打印仍可用。`hideMenuBar` 只隐藏 `.gbd-menubar-host` 那一行,文件头与正文不受影响。
|
|
94
|
-
|
|
95
|
-
## 只读写文件(codec)
|
|
96
|
-
|
|
97
|
-
```js
|
|
98
|
-
import { parseDocx } from '@a200888213/gbdocx/kernel/docx/codec/docx';
|
|
99
|
-
import { buildDocxVerified } from '@a200888213/gbdocx/kernel/docx/codec/roundtrip';
|
|
100
|
-
import { docToMarkdown } from '@a200888213/gbdocx/kernel/docx/codec/markdown';
|
|
101
|
-
import { lossText } from '@a200888213/gbdocx/kernel/docx/codec/losses';
|
|
102
|
-
|
|
103
|
-
const doc = await parseDocx(bytes); // Uint8Array | ArrayBuffer → Promise<Document>
|
|
104
|
-
console.log(lossText(doc.losses)); // 这次打开丢掉了哪些原文特性
|
|
105
|
-
const back = await buildDocxVerified(doc); // Promise<Uint8Array>
|
|
106
|
-
const md = docToMarkdown(doc); // 同步返回字符串
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
文档模型就是 codec 与编辑器之间唯一的接口:
|
|
110
|
-
|
|
111
|
-
```js
|
|
112
|
-
{
|
|
113
|
-
html: '<p>正文</p>', // 正文(编辑器的工作内容)
|
|
114
|
-
sections: [{
|
|
115
|
-
type: '', // 分节类型
|
|
116
|
-
page: { size: 'A4', orientation: 'portrait',
|
|
117
|
-
margins: { top: 25.4, right: 25.4, bottom: 25.4, left: 25.4 },
|
|
118
|
-
columns: 1, colGap: 8, colSeparator: false, headerTop: 0, footerBottom: 0 },
|
|
119
|
-
hfMode: 'all', header: '', footer: '', headerEven: '', footerEven: '', headerFirst: '', footerFirst: '',
|
|
120
|
-
pageNumbers: { enabled: false, align: 'center', format: 'arabic', start: 1 },
|
|
121
|
-
watermark: { data: '', color: '#AEB5C0', size: 120, opacity: 0.3 },
|
|
122
|
-
}],
|
|
123
|
-
comments: [], footnotes: [], endnotes: [],
|
|
124
|
-
props: null, // 标题/作者等文档属性
|
|
125
|
-
defaultTabStop: 720,
|
|
126
|
-
carry: [], // 整包透传的分节(主题、术语表、customXml…)
|
|
127
|
-
losses: [], // 只有读出来的 doc 上有
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
`WordApp.currentDoc()` 产出的就是这个形状,`applyDoc(model)` 接受它(传 `null` 得到空白文档)。
|
|
132
|
-
|
|
133
|
-
### 保存自检
|
|
134
|
-
|
|
135
|
-
`buildDocx()` 直接生成字节;`buildDocxVerified()` 生成后会**立刻读回来比对内容摘要**,任何不一致都抛 `保存自检未通过…` 并拒绝这次保存。应用内所有保存路径走的都是 `buildDocxVerified`。想强行写出未经自检的结果(比如调试),才用 `buildDocx`。
|
|
136
|
-
|
|
137
|
-
### 保住与丢失
|
|
138
|
-
|
|
139
|
-
往返会保住:段落对齐/缩进/行距、H1–H6、加粗斜体下划删除线、颜色字号字体高亮、等宽代码、超链接、有序无序列表、表格(列宽、单元格底纹、横纵合并)、内联图片、分隔线、引用块、分页符、页眉页脚与页码、纸张尺寸方向页边距分栏、批注、修订(含作者与时间)、脚注尾注、文档属性,以及主题等整包透传内容。
|
|
140
|
-
|
|
141
|
-
会丢的主要是:文本框/形状、域代码、SmartArt。丢失项在读入时就被清点进 `doc.losses`,用 `lossText()` 可以直接展示给用户。
|
|
142
|
-
|
|
143
|
-
旧版二进制 `.doc` 会在文件头就被拒绝:`旧版二进制 .doc 不支持,请先另存为 .docx`。
|
|
144
|
-
|
|
145
|
-
## 只用编辑内核
|
|
146
|
-
|
|
147
|
-
```js
|
|
148
|
-
import { EditorSurface } from '@a200888213/gbdocx/surface/editor-surface';
|
|
149
|
-
|
|
150
|
-
const surface = new EditorSurface({
|
|
151
|
-
mount: document.getElementById('editor'),
|
|
152
|
-
modelValue: '<p>正文</p>',
|
|
153
|
-
placeholder: '开始输入',
|
|
154
|
-
editable: true,
|
|
155
|
-
backdrop: (host) => { /* 自己画纸张、页眉页脚带 */ },
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
const editor = surface.editor; // EditorCore
|
|
159
|
-
editor.exec('toggleBold');
|
|
160
|
-
editor.state(); // 一次快照,供工具栏刷新
|
|
161
|
-
editor.run(() => editor.exec('insertText', 'hi'), { merge: 'insertText' });
|
|
162
|
-
await surface.insertImages(fileList);
|
|
163
|
-
surface.destroy();
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
这里的 **文档模型就是那段 contenteditable DOM**:进出只有 `normalizeBody` / `serializeBody` 两道规范化,对应 `editor.getHTML()` / `editor.setHTML(html)`。`exec(name, ...args)` 的命令名在 `COMMANDS` 注册表里,未知名返回 `false`;`can(name, ...args)` 用来置灰按钮。常用命令:`undo`、`redo`、`toggleBold/Italic/Underline/Strike/Code`、`setColor`、`setFontSize`、`setFontFamily`、`setLink`、`clearFormat`、`setHeading(level)`、`toggleBlockquote`、`toggleBulletList`、`insertPageBreak`、`insertTable({ rows, cols, withHeaderRow })`、`tableAction(action, counts)`、`setComment(key)`、`insertNote(spec)`、`resolveRevisions(accept)`、`convertBlock(kind, el)`。
|
|
167
|
-
|
|
168
|
-
## 导入路径
|
|
169
|
-
|
|
170
|
-
深层入口走通配 `./src/*.js`,**子路径不带 `.js`**:
|
|
171
|
-
|
|
172
|
-
```js
|
|
173
|
-
import { parseDocx } from '@a200888213/gbdocx/kernel/docx/codec/docx'; // ✔ → src/kernel/docx/codec/docx.js
|
|
174
|
-
import { EditorCore } from '@a200888213/gbdocx/kernel/editor/engine/editor';
|
|
175
|
-
import { useKeyboard } from '@a200888213/gbdocx/kernel/keyboard';
|
|
176
|
-
import { FONT_SIZES } from '@a200888213/gbdocx/kernel/textStyles';
|
|
177
|
-
import { notify } from '@a200888213/gbdocx/kernel/notify';
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
写成 `@a200888213/gbdocx/kernel/docx/codec/docx.js` 会解析成 `docx.js.js` 而报 `ERR_MODULE_NOT_FOUND`。
|
|
181
|
-
|
|
182
|
-
## 环境说明
|
|
183
|
-
|
|
184
|
-
**读方向(`parseDocx`)在纯 Node 可跑** —— 它只用 gbooxml 的纯 JS ZIP/XML。
|
|
185
|
-
|
|
186
|
-
**写方向(`buildDocx` / `buildDocxVerified`)和整套 UI 需要 DOM**:HTML → 块模型的转换用 `DOMParser`,界面层还用到 `ResizeObserver`、`localStorage`、`showOpenFilePicker`。在 Node 里跑写入请自备 jsdom,本包的测试就是这么做的:
|
|
187
|
-
|
|
188
|
-
```js
|
|
189
|
-
import { JSDOM } from 'jsdom';
|
|
190
|
-
const dom = new JSDOM('<!doctype html><html><body></body></html>', { url: 'http://localhost/' });
|
|
191
|
-
Object.assign(globalThis, {
|
|
192
|
-
window: dom.window, document: dom.window.document,
|
|
193
|
-
DOMParser: dom.window.DOMParser, XMLSerializer: dom.window.XMLSerializer,
|
|
194
|
-
Node: dom.window.Node, NodeFilter: dom.window.NodeFilter,
|
|
195
|
-
Element: dom.window.Element, HTMLElement: dom.window.HTMLElement,
|
|
196
|
-
DocumentFragment: dom.window.DocumentFragment,
|
|
197
|
-
});
|
|
198
|
-
const { parseDocx } = await import('@a200888213/gbdocx/kernel/docx/codec/docx');
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
注意要用**动态 import**:编解码模块在被加载时就会触碰 DOM 全局,必须在上面的赋值之后再导入。
|
|
202
|
-
|
|
203
|
-
`jsdom` 只是本包测试的 devDependency,不在运行时依赖里 —— 浏览器场景无需任何 polyfill。
|
|
204
|
-
|
|
205
|
-
## 已知坑
|
|
206
|
-
|
|
207
|
-
1. 批注键在写出时会被重编号成数字 id:读到的 `data-cmt="c1"` 存回去可能变成 `data-cmt="0"`,别把自己的业务 id 直接绑在这个属性上。
|
|
208
|
-
2. `new WordApp(mount)` 的挂载元素必须已在文档中,构造期间就会测量布局;先 `append` 再 `new`。
|
|
209
|
-
3. `WordApp` 不对外派发任何事件,它只消费编辑器内核的事件总线。要做联动,取 `app.editor` 后 `app.editor.on('state' | 'selection', fn)`。
|
|
210
|
-
4. 偏好(缩放、面板开关)持久化在 `localStorage['gbdocx.prefs']`,SSR 环境请在客户端实例化。
|
|
211
|
-
5. 自带 demo 的 `/vendor/gbooxml` 依赖仓库 `packages/gboffice/` 的分组布局,从 npm 单独安装需自己改 importmap。
|
|
212
|
-
|
|
213
|
-
## 许可
|
|
214
|
-
|
|
215
|
-
MIT
|
|
1
|
+
# @a200888213/gbdocx
|
|
2
|
+
|
|
3
|
+
独立 `.docx` 编辑器:**OOXML docx 编解码内核 + 自研 contenteditable 编辑器内核 + 原生 HTML 界面**。
|
|
4
|
+
|
|
5
|
+
没有 React/Vue,没有 ProseMirror/TipTap,没有 CKEditor。整个包只依赖 [`gbooxml`](https://www.npmjs.com/package/gbooxml) 做 ZIP 与 XML,其余全部自持:`.docx` 双向编解码、以 DOM 为文档模型的编辑器内核、分页/页眉页脚/脚注尾注/批注/修订,以及菜单、工具栏、查找、颜色面板这一整套 UI。
|
|
6
|
+
|
|
7
|
+
## 三层结构
|
|
8
|
+
|
|
9
|
+
| 层 | 入口 | 职责 |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| 编解码 | `@a200888213/gbdocx/kernel/docx/codec/*` | `.docx` 字节 ⇄ 文档模型 ⇄ HTML |
|
|
12
|
+
| 编辑器内核 | `@a200888213/gbdocx/surface/editor-surface` | `EditorSurface` 承载 `EditorCore`:命令、状态快照、历史、表格、批注、修订 |
|
|
13
|
+
| 完整应用 | `@a200888213/gbdocx`(根入口) | `WordApp`:把上面两层装配成一个可用的 Word 界面 |
|
|
14
|
+
|
|
15
|
+
只想做一个在线文档编辑器 → 用 `WordApp`;已有自己的界面、只要编辑内核 → 用 `EditorSurface`;只要读写文件、不要编辑器 → 用 codec。
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @a200888213/gbdocx
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 样式隔离(0.3.0 起)
|
|
24
|
+
|
|
25
|
+
- CSS 自定义属性统一用包专属前缀 `--gbd-*`,类名统一用 `gbd-*` / `gbd-is-*`;四个 gb 包可同时挂在同一个宿主页面,不会互相覆盖,也不会撞上 Element Plus 的 `.is-*` 状态类。
|
|
26
|
+
- 页面级底座规则(`html,body` / `body` / `#app` / `*` / `button` / 滚动条)只挂在 `.gbd-root` 作用域内:**嵌入宿主时挂载点必须带 `gbd-root` 类**,否则字体、高度与盒模型底座不生效;宿主的 `body` / `#app` / 全局按钮不受任何影响。
|
|
27
|
+
- `:root` 的设计令牌保持全局可见(菜单与弹层会挂到 `body`),变量名已包专属;暗色令牌由 `[data-gbd-theme='dark']` 切换,不再被宿主的 `data-theme` 误触发。
|
|
28
|
+
|
|
29
|
+
## 先把它跑起来
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm start # node serve.mjs,默认 http://localhost:5273/
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`serve.mjs` 只是薄封装,静态服务器本体是 `guabiutils/dev-server`(三端共用同一份),端口可 `node serve.mjs 8080` 或用环境变量 `GBDOCX_PORT`。打开根路径即为完整编辑器,控制台里有 `window.gbdocx` 指向 `WordApp` 实例,可直接调 `await window.gbdocx.selfTest()` 做一次全链路自检。
|
|
36
|
+
|
|
37
|
+
页面本身只有 `index.html`,它加载四个样式表(顺序有意义):`tokens.css` → `editor-content.css` → `word-panel.css` → `app.css`。自己装配页面时请全部引入,否则正文排版和面板都会走形。
|
|
38
|
+
|
|
39
|
+
`index.html` 里有一条 importmap,把裸标识符 `gbooxml` / `guabiutils` 映射到 `/vendor/*`,而 `serve.mjs` 把 `/vendor/gbooxml/*`、`/vendor/gbofficeui/*` 指向 `packages/gboffice/` 下的同级源码,把 `/vendor/guabiutils/*` 指向仓库的 `packages/guabiutils/src`。这意味着这个自带 demo 只在仓库的 monorepo 布局下能跑;从 npm 单独安装后要用 demo 页面,请自行把 `gbooxml` 映射到 `node_modules/gbooxml/src/index.js`,并按下方顺序引入四份样式(顶栏皮肤来自 `gbofficeui`)。
|
|
40
|
+
|
|
41
|
+
## 嵌入到自己的页面
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
import { WordApp } from '@a200888213/gbdocx';
|
|
45
|
+
import '@a200888213/gbdocx/styles/tokens.css';
|
|
46
|
+
import '@a200888213/gbdocx/styles/editor-content.css';
|
|
47
|
+
import '@a200888213/gbdocx/styles/word-panel.css';
|
|
48
|
+
import '@a200888213/gbdocx/styles/app.css';
|
|
49
|
+
import 'gbofficeui/styles/office-chrome.css'; // 菜单栏/文档头/功能区/状态栏共享皮肤
|
|
50
|
+
|
|
51
|
+
const app = new WordApp(document.getElementById('app'));
|
|
52
|
+
await app.start();
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
第一个参数是一个**已经挂在文档里的 DOM 元素**,编辑器 UI 会 `appendChild` 进去;第二个参数是可选 options:`embed` / `io` / `onDirty` / `isActive` 用于嵌入宿主,`readOnly` / `hideMenuBar` 见下一节。实例方法:
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
app.setEditMode('readonly'); // 'edit' | 'suggest' | 'readonly'
|
|
59
|
+
app.setZoom(120); // 40–300,会持久化到 localStorage
|
|
60
|
+
app.setView('commentsPanel', true);
|
|
61
|
+
await app.saveAs(); // 另存为 .docx(优先 File System Access API,回落下载)
|
|
62
|
+
app.print();
|
|
63
|
+
app.destroy(); // 停观察器与定时器,但不会把 DOM 从挂载点摘掉
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`destroy()` 只解除副作用(ResizeObserver、window resize、分页与自动保存定时器),**不会**移除它自己插入的 DOM;要彻底回收请连挂载点子树一起删。
|
|
67
|
+
|
|
68
|
+
## 文档头(0.6.0 起)
|
|
69
|
+
|
|
70
|
+
文档头骨架由 `gbofficeui` 的 `createOfficeHead` 统一生成(gbdocx / gbpptx / gbxlxs 三家同一套):标题 → 重命名 → 状态 → 自动保存 / 保存 → 下载 → 预览 → 全屏。
|
|
71
|
+
|
|
72
|
+
- 「重命名」是标题右侧的一枚图标钮(悬停出提示),「下载」紧挨「预览」;
|
|
73
|
+
- 嵌入模式由宿主接管:`io.rename(event)` / `io.download()`;`io.getTitle()` / `io.getPath()` 还能覆盖标题与路径显示。不提供就不渲染对应按钮;
|
|
74
|
+
- 独立模式走包内实现:重命名弹气泡改名,下载导出当前 `.docx`。
|
|
75
|
+
|
|
76
|
+
## 只读与隐藏菜单栏
|
|
77
|
+
|
|
78
|
+
`@a200888213/gbdocx` / `gbxlxs` / `gbpptx` 三个编辑器用同一套开关(`guabiutils` 的 `createReadOnlyGuard` 提供 DOM 层守卫,各包自己接模型层闸门):
|
|
79
|
+
|
|
80
|
+
| 能力 | 构造参数 | 运行时方法 |
|
|
81
|
+
| --- | --- | --- |
|
|
82
|
+
| 只读预览 | `readOnly: true` | `app.setReadOnly(on)` |
|
|
83
|
+
| 隐藏顶部菜单栏那一行 | `hideMenuBar: true` | `app.setMenuBarVisible(on)` |
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
const app = new WordApp(mountEl, { embed: true, readOnly: true, hideMenuBar: true });
|
|
87
|
+
await app.start();
|
|
88
|
+
|
|
89
|
+
app.setReadOnly(false); // 回到可编辑
|
|
90
|
+
app.setMenuBarVisible(true); // 再显示菜单栏
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
只读档下:内核切到 `editMode='readonly'`(正文 `contenteditable` 关闭、`run()` 拒绝写命令),工具栏与文件头 `inert`,编辑/插入/表格/格式菜单禁用,状态栏的模式/页边距/分栏开关与查找栏的替换行一并锁定;选区、滚动、复制、查找、缩放、导出与打印仍可用。`hideMenuBar` 只隐藏 `.gbd-menubar-host` 那一行,文件头与正文不受影响。
|
|
94
|
+
|
|
95
|
+
## 只读写文件(codec)
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
import { parseDocx } from '@a200888213/gbdocx/kernel/docx/codec/docx';
|
|
99
|
+
import { buildDocxVerified } from '@a200888213/gbdocx/kernel/docx/codec/roundtrip';
|
|
100
|
+
import { docToMarkdown } from '@a200888213/gbdocx/kernel/docx/codec/markdown';
|
|
101
|
+
import { lossText } from '@a200888213/gbdocx/kernel/docx/codec/losses';
|
|
102
|
+
|
|
103
|
+
const doc = await parseDocx(bytes); // Uint8Array | ArrayBuffer → Promise<Document>
|
|
104
|
+
console.log(lossText(doc.losses)); // 这次打开丢掉了哪些原文特性
|
|
105
|
+
const back = await buildDocxVerified(doc); // Promise<Uint8Array>
|
|
106
|
+
const md = docToMarkdown(doc); // 同步返回字符串
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
文档模型就是 codec 与编辑器之间唯一的接口:
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
{
|
|
113
|
+
html: '<p>正文</p>', // 正文(编辑器的工作内容)
|
|
114
|
+
sections: [{
|
|
115
|
+
type: '', // 分节类型
|
|
116
|
+
page: { size: 'A4', orientation: 'portrait',
|
|
117
|
+
margins: { top: 25.4, right: 25.4, bottom: 25.4, left: 25.4 },
|
|
118
|
+
columns: 1, colGap: 8, colSeparator: false, headerTop: 0, footerBottom: 0 },
|
|
119
|
+
hfMode: 'all', header: '', footer: '', headerEven: '', footerEven: '', headerFirst: '', footerFirst: '',
|
|
120
|
+
pageNumbers: { enabled: false, align: 'center', format: 'arabic', start: 1 },
|
|
121
|
+
watermark: { data: '', color: '#AEB5C0', size: 120, opacity: 0.3 },
|
|
122
|
+
}],
|
|
123
|
+
comments: [], footnotes: [], endnotes: [],
|
|
124
|
+
props: null, // 标题/作者等文档属性
|
|
125
|
+
defaultTabStop: 720,
|
|
126
|
+
carry: [], // 整包透传的分节(主题、术语表、customXml…)
|
|
127
|
+
losses: [], // 只有读出来的 doc 上有
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`WordApp.currentDoc()` 产出的就是这个形状,`applyDoc(model)` 接受它(传 `null` 得到空白文档)。
|
|
132
|
+
|
|
133
|
+
### 保存自检
|
|
134
|
+
|
|
135
|
+
`buildDocx()` 直接生成字节;`buildDocxVerified()` 生成后会**立刻读回来比对内容摘要**,任何不一致都抛 `保存自检未通过…` 并拒绝这次保存。应用内所有保存路径走的都是 `buildDocxVerified`。想强行写出未经自检的结果(比如调试),才用 `buildDocx`。
|
|
136
|
+
|
|
137
|
+
### 保住与丢失
|
|
138
|
+
|
|
139
|
+
往返会保住:段落对齐/缩进/行距、H1–H6、加粗斜体下划删除线、颜色字号字体高亮、等宽代码、超链接、有序无序列表、表格(列宽、单元格底纹、横纵合并)、内联图片、分隔线、引用块、分页符、页眉页脚与页码、纸张尺寸方向页边距分栏、批注、修订(含作者与时间)、脚注尾注、文档属性,以及主题等整包透传内容。
|
|
140
|
+
|
|
141
|
+
会丢的主要是:文本框/形状、域代码、SmartArt。丢失项在读入时就被清点进 `doc.losses`,用 `lossText()` 可以直接展示给用户。
|
|
142
|
+
|
|
143
|
+
旧版二进制 `.doc` 会在文件头就被拒绝:`旧版二进制 .doc 不支持,请先另存为 .docx`。
|
|
144
|
+
|
|
145
|
+
## 只用编辑内核
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
import { EditorSurface } from '@a200888213/gbdocx/surface/editor-surface';
|
|
149
|
+
|
|
150
|
+
const surface = new EditorSurface({
|
|
151
|
+
mount: document.getElementById('editor'),
|
|
152
|
+
modelValue: '<p>正文</p>',
|
|
153
|
+
placeholder: '开始输入',
|
|
154
|
+
editable: true,
|
|
155
|
+
backdrop: (host) => { /* 自己画纸张、页眉页脚带 */ },
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const editor = surface.editor; // EditorCore
|
|
159
|
+
editor.exec('toggleBold');
|
|
160
|
+
editor.state(); // 一次快照,供工具栏刷新
|
|
161
|
+
editor.run(() => editor.exec('insertText', 'hi'), { merge: 'insertText' });
|
|
162
|
+
await surface.insertImages(fileList);
|
|
163
|
+
surface.destroy();
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
这里的 **文档模型就是那段 contenteditable DOM**:进出只有 `normalizeBody` / `serializeBody` 两道规范化,对应 `editor.getHTML()` / `editor.setHTML(html)`。`exec(name, ...args)` 的命令名在 `COMMANDS` 注册表里,未知名返回 `false`;`can(name, ...args)` 用来置灰按钮。常用命令:`undo`、`redo`、`toggleBold/Italic/Underline/Strike/Code`、`setColor`、`setFontSize`、`setFontFamily`、`setLink`、`clearFormat`、`setHeading(level)`、`toggleBlockquote`、`toggleBulletList`、`insertPageBreak`、`insertTable({ rows, cols, withHeaderRow })`、`tableAction(action, counts)`、`setComment(key)`、`insertNote(spec)`、`resolveRevisions(accept)`、`convertBlock(kind, el)`。
|
|
167
|
+
|
|
168
|
+
## 导入路径
|
|
169
|
+
|
|
170
|
+
深层入口走通配 `./src/*.js`,**子路径不带 `.js`**:
|
|
171
|
+
|
|
172
|
+
```js
|
|
173
|
+
import { parseDocx } from '@a200888213/gbdocx/kernel/docx/codec/docx'; // ✔ → src/kernel/docx/codec/docx.js
|
|
174
|
+
import { EditorCore } from '@a200888213/gbdocx/kernel/editor/engine/editor';
|
|
175
|
+
import { useKeyboard } from '@a200888213/gbdocx/kernel/keyboard';
|
|
176
|
+
import { FONT_SIZES } from '@a200888213/gbdocx/kernel/textStyles';
|
|
177
|
+
import { notify } from '@a200888213/gbdocx/kernel/notify';
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
写成 `@a200888213/gbdocx/kernel/docx/codec/docx.js` 会解析成 `docx.js.js` 而报 `ERR_MODULE_NOT_FOUND`。
|
|
181
|
+
|
|
182
|
+
## 环境说明
|
|
183
|
+
|
|
184
|
+
**读方向(`parseDocx`)在纯 Node 可跑** —— 它只用 gbooxml 的纯 JS ZIP/XML。
|
|
185
|
+
|
|
186
|
+
**写方向(`buildDocx` / `buildDocxVerified`)和整套 UI 需要 DOM**:HTML → 块模型的转换用 `DOMParser`,界面层还用到 `ResizeObserver`、`localStorage`、`showOpenFilePicker`。在 Node 里跑写入请自备 jsdom,本包的测试就是这么做的:
|
|
187
|
+
|
|
188
|
+
```js
|
|
189
|
+
import { JSDOM } from 'jsdom';
|
|
190
|
+
const dom = new JSDOM('<!doctype html><html><body></body></html>', { url: 'http://localhost/' });
|
|
191
|
+
Object.assign(globalThis, {
|
|
192
|
+
window: dom.window, document: dom.window.document,
|
|
193
|
+
DOMParser: dom.window.DOMParser, XMLSerializer: dom.window.XMLSerializer,
|
|
194
|
+
Node: dom.window.Node, NodeFilter: dom.window.NodeFilter,
|
|
195
|
+
Element: dom.window.Element, HTMLElement: dom.window.HTMLElement,
|
|
196
|
+
DocumentFragment: dom.window.DocumentFragment,
|
|
197
|
+
});
|
|
198
|
+
const { parseDocx } = await import('@a200888213/gbdocx/kernel/docx/codec/docx');
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
注意要用**动态 import**:编解码模块在被加载时就会触碰 DOM 全局,必须在上面的赋值之后再导入。
|
|
202
|
+
|
|
203
|
+
`jsdom` 只是本包测试的 devDependency,不在运行时依赖里 —— 浏览器场景无需任何 polyfill。
|
|
204
|
+
|
|
205
|
+
## 已知坑
|
|
206
|
+
|
|
207
|
+
1. 批注键在写出时会被重编号成数字 id:读到的 `data-cmt="c1"` 存回去可能变成 `data-cmt="0"`,别把自己的业务 id 直接绑在这个属性上。
|
|
208
|
+
2. `new WordApp(mount)` 的挂载元素必须已在文档中,构造期间就会测量布局;先 `append` 再 `new`。
|
|
209
|
+
3. `WordApp` 不对外派发任何事件,它只消费编辑器内核的事件总线。要做联动,取 `app.editor` 后 `app.editor.on('state' | 'selection', fn)`。
|
|
210
|
+
4. 偏好(缩放、面板开关)持久化在 `localStorage['gbdocx.prefs']`,SSR 环境请在客户端实例化。
|
|
211
|
+
5. 自带 demo 的 `/vendor/gbooxml` 依赖仓库 `packages/gboffice/` 的分组布局,从 npm 单独安装需自己改 importmap。
|
|
212
|
+
|
|
213
|
+
## 许可
|
|
214
|
+
|
|
215
|
+
MIT
|
package/index.html
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="zh-CN">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
-
<title>挂逼文档 gbdocx</title>
|
|
7
|
-
<link rel="stylesheet" href="/styles/tokens.css" />
|
|
8
|
-
<link rel="stylesheet" href="/styles/editor-content.css" />
|
|
9
|
-
<link rel="stylesheet" href="/styles/word-panel.css" />
|
|
10
|
-
<link rel="stylesheet" href="/styles/app.css" />
|
|
11
|
-
<link rel="stylesheet" href="/vendor/gbofficeui/styles/office-chrome.css" />
|
|
12
|
-
<style>
|
|
13
|
-
/* 独立运行时撑满视口;嵌入宿主由宿主容器给高度,不依赖这条 */
|
|
14
|
-
html, body { height: 100%; margin: 0; }
|
|
15
|
-
</style>
|
|
16
|
-
<script type="importmap">
|
|
17
|
-
{
|
|
18
|
-
"imports": {
|
|
19
|
-
"gbooxml": "/vendor/gbooxml/src/index.js",
|
|
20
|
-
"guabiutils": "/vendor/guabiutils/index.js",
|
|
21
|
-
"gbofficeui/head": "/vendor/gbofficeui/src/head.js"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
</
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>挂逼文档 gbdocx</title>
|
|
7
|
+
<link rel="stylesheet" href="/styles/tokens.css" />
|
|
8
|
+
<link rel="stylesheet" href="/styles/editor-content.css" />
|
|
9
|
+
<link rel="stylesheet" href="/styles/word-panel.css" />
|
|
10
|
+
<link rel="stylesheet" href="/styles/app.css" />
|
|
11
|
+
<link rel="stylesheet" href="/vendor/gbofficeui/styles/office-chrome.css" />
|
|
12
|
+
<style>
|
|
13
|
+
/* 独立运行时撑满视口;嵌入宿主由宿主容器给高度,不依赖这条 */
|
|
14
|
+
html, body { height: 100%; margin: 0; }
|
|
15
|
+
</style>
|
|
16
|
+
<script type="importmap">
|
|
17
|
+
{
|
|
18
|
+
"imports": {
|
|
19
|
+
"gbooxml": "/vendor/gbooxml/src/index.js",
|
|
20
|
+
"guabiutils": "/vendor/guabiutils/index.js",
|
|
21
|
+
"gbofficeui/head": "/vendor/gbofficeui/src/head.js",
|
|
22
|
+
"gbicons/nodes": "/vendor/gbicons/src/nodes.js"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
</head>
|
|
27
|
+
<body>
|
|
28
|
+
<div id="app" class="gbd-root"></div>
|
|
29
|
+
<script type="module" src="/src/app/main.js"></script>
|
|
30
|
+
</body>
|
|
31
|
+
</html>
|