@a200888213/gbdocx 0.4.0 → 0.5.1

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
@@ -82,7 +82,7 @@ app.setReadOnly(false); // 回到可编辑
82
82
  app.setMenuBarVisible(true); // 再显示菜单栏
83
83
  ```
84
84
 
85
- 只读档下:内核切到 `editMode='readonly'`(正文 `contenteditable` 关闭、`run()` 拒绝写命令),工具栏与文件头 `inert`,编辑/插入/表格/格式菜单禁用,状态栏的模式/页边距/分栏开关与查找栏的替换行一并锁定;选区、滚动、复制、查找、缩放、导出与打印仍可用。`hideMenuBar` 只隐藏 `.gbd-menubar-host` 那一行,下面的文件头与正文不受影响。
85
+ 只读档下:内核切到 `editMode='readonly'`(正文 `contenteditable` 关闭、`run()` 拒绝写命令),工具栏与文件头 `inert`,编辑/插入/表格/格式菜单禁用,状态栏的模式/页边距/分栏开关与查找栏的替换行一并锁定;选区、滚动、复制、查找、缩放、导出与打印仍可用。`hideMenuBar` 只隐藏 `.gbd-menubar-host` 那一行,文件头与正文不受影响。
86
86
 
87
87
  ## 只读写文件(codec)
88
88
 
package/index.html CHANGED
@@ -7,8 +7,12 @@
7
7
  <link rel="stylesheet" href="/styles/tokens.css" />
8
8
  <link rel="stylesheet" href="/styles/editor-content.css" />
9
9
  <link rel="stylesheet" href="/styles/word-panel.css" />
10
- <link rel="stylesheet" href="/styles/app.css" />
10
+ <link rel="stylesheet" href="/styles/app.css" />
11
11
  <link rel="stylesheet" href="/vendor/gbofficeui/office-chrome.css" />
12
+ <style>
13
+ /* 独立运行时撑满视口;嵌入宿主由宿主容器给高度,不依赖这条 */
14
+ html, body { height: 100%; margin: 0; }
15
+ </style>
12
16
  <script type="importmap">
13
17
  {
14
18
  "imports": {
package/package.json CHANGED
@@ -1,48 +1,48 @@
1
- {
2
- "name": "@a200888213/gbdocx",
3
- "version": "0.4.0",
4
- "description": "挂逼文档:独立 .docx 编辑器(内核移植自 guabi office/docx 编解码 + 自研 contenteditable 编辑器内核,UI 用原生 HTML 重写),只依赖 gbooxml。",
5
- "type": "module",
6
- "license": "MIT",
7
- "main": "./src/app/word-app.js",
8
- "exports": {
9
- ".": "./src/app/word-app.js",
10
- "./app": "./src/app/word-app.js",
11
- "./styles/*": "./styles/*",
12
- "./*": "./src/*.js",
13
- "./package.json": "./package.json"
14
- },
15
- "files": [
16
- "src",
17
- "styles",
18
- "index.html",
19
- "serve.mjs",
20
- "LICENSE"
21
- ],
22
- "keywords": [
23
- "docx",
24
- "document",
25
- "word",
26
- "ooxml",
27
- "editor",
28
- "contenteditable"
29
- ],
30
- "engines": {
31
- "node": ">=18"
32
- },
33
- "scripts": {
34
- "start": "node serve.mjs",
35
- "test": "node --test test/roundtrip.test.js test/ui.test.js test/mode.test.js"
36
- },
37
- "dependencies": {
38
- "gbooxml": "^0.1.1",
39
- "gbofficeui": "^0.1.0",
40
- "guabiutils": "^0.3.0"
41
- },
42
- "devDependencies": {
43
- "jsdom": "^30.1.3"
44
- },
45
- "publishConfig": {
46
- "access": "public"
47
- }
48
- }
1
+ {
2
+ "name": "@a200888213/gbdocx",
3
+ "version": "0.5.1",
4
+ "description": "挂逼文档:独立 .docx 编辑器(内核移植自 guabi office/docx 编解码 + 自研 contenteditable 编辑器内核,UI 用原生 HTML 重写),只依赖 gbooxml。",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "main": "./src/app/word-app.js",
8
+ "exports": {
9
+ ".": "./src/app/word-app.js",
10
+ "./app": "./src/app/word-app.js",
11
+ "./styles/*": "./styles/*",
12
+ "./*": "./src/*.js",
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "styles",
18
+ "index.html",
19
+ "serve.mjs",
20
+ "LICENSE"
21
+ ],
22
+ "keywords": [
23
+ "docx",
24
+ "document",
25
+ "word",
26
+ "ooxml",
27
+ "editor",
28
+ "contenteditable"
29
+ ],
30
+ "engines": {
31
+ "node": ">=18"
32
+ },
33
+ "scripts": {
34
+ "start": "node serve.mjs",
35
+ "test": "node --test test/roundtrip.test.js test/ui.test.js test/mode.test.js"
36
+ },
37
+ "dependencies": {
38
+ "gbooxml": "^0.1.1",
39
+ "gbofficeui": "^0.1.0",
40
+ "guabiutils": "^0.3.0"
41
+ },
42
+ "devDependencies": {
43
+ "jsdom": "^30.1.3"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ }
48
+ }
@@ -51,6 +51,19 @@ function menuCtx() {
51
51
  get align() { return app.editorState?.textAlign; },
52
52
  get lineHeight() { return app.editorState?.lineHeight; },
53
53
  get firstLineIndent() { return app.editorState?.firstLineIndent; },
54
+ get bold() { return app.editorState?.bold; },
55
+ get italic() { return app.editorState?.italic; },
56
+ get underline() { return app.editorState?.underline; },
57
+ get strike() { return app.editorState?.strike; },
58
+ get superscript() { return app.editorState?.superscript; },
59
+ get subscript() { return app.editorState?.subscript; },
60
+ get fontSize() { return app.editorState?.fontSize; },
61
+ get fontFamily() { return app.editorState?.fontFamily; },
62
+ get color() { return app.editorState?.color; },
63
+ get backgroundColor() { return app.editorState?.backgroundColor; },
64
+ get bulletList() { return app.editorState?.bulletList; },
65
+ get orderedList() { return app.editorState?.orderedList; },
66
+ get taskList() { return app.editorState?.taskList; },
54
67
  get inTable() { return app.editorState?.inTable; },
55
68
  get hasSelection() { return app.editorState?.hasSelection; },
56
69
  get columns() { return app.state.page.columns || 1; },
@@ -132,6 +145,19 @@ function menuCtx() {
132
145
  align: (v) => this.run('setBlockAlign', v),
133
146
  setLineHeight: (v) => this.run('setBlockLineHeight', v),
134
147
  firstLine: () => this.run('toggleFirstLineIndent'),
148
+ bold: () => this.run('toggleBold'),
149
+ italic: () => this.run('toggleItalic'),
150
+ underline: () => this.run('toggleUnderline'),
151
+ strike: () => this.run('toggleStrike'),
152
+ superscript: () => this.run('toggleSuperscript'),
153
+ subscript: () => this.run('toggleSubscript'),
154
+ setFontFamily: (v) => this.run('setFontFamily', v),
155
+ setFontSize: (v) => this.run('setFontSize', v),
156
+ setColor: (v) => this.run('setColor', v),
157
+ unsetColor: () => this.run('unsetColor'),
158
+ setHighlight: (v) => this.run('setBackgroundColor', v),
159
+ unsetHighlight: () => this.run('unsetBackgroundColor'),
160
+ indent: (command) => this.run(command),
135
161
  setHfMode: (mode) => { this.state.hfMode = mode; this.onDocUpdate(); },
136
162
  list: (command) => this.run(command),
137
163
  clearFormat: () => this.run('clearFormat'),
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { cleanHfHtml } from '../../kernel/docx/codec/helpers.js';
7
7
  import { openColumnDialog as openColumnDialogUI, openMarginDialog as openMarginDialogUI, openPageSetupDialog as openPageSetupDialogUI } from '../../ui/dialogs.js';
8
+ import { icon } from '../../ui/icons.js';
8
9
  import { savePrefs } from './shared.js';
9
10
 
10
11
  /** 预览模式:只读 + 收起编辑界面;按钮留在文件头行原位,再点或按 Esc 退出 */
@@ -35,6 +36,27 @@ function setPreview(on) {
35
36
  this.previewBtn.blur();
36
37
  }
37
38
 
39
+ /** 全屏/恢复:整个 Word 应用铺满网页(页面内覆盖;不用原生 Fullscreen,
40
+ * 否则 append 到 body 的菜单/弹窗在全屏层外不可见) */
41
+ function toggleFullscreen() {
42
+ this.setPageFullscreen(!this.pageFullscreen);
43
+ }
44
+
45
+ function setPageFullscreen(on) {
46
+ this.pageFullscreen = !!on;
47
+ this.root.classList.toggle('gbd-is-pagefullscreen', this.pageFullscreen);
48
+ if (this.pageFullscreen) document.addEventListener('keydown', this.onFullscreenEsc, true);
49
+ else document.removeEventListener('keydown', this.onFullscreenEsc, true);
50
+ this.renderFullscreenBtn();
51
+ }
52
+
53
+ function renderFullscreenBtn() {
54
+ const active = this.pageFullscreen;
55
+ this.fullscreenBtn.title = active ? '退出全屏' : '全屏';
56
+ this.fullscreenBtn.setAttribute('aria-pressed', String(active));
57
+ this.fullscreenBtn.innerHTML = `${icon(active ? 'fullscreenExit' : 'fullscreen')}<span>${active ? '恢复' : '全屏'}</span>`;
58
+ }
59
+
38
60
  function setView(key, on) {
39
61
  const next = on === undefined ? !this.flags[key] : !!on;
40
62
  this.flags = { ...this.flags, [key]: next };
@@ -53,6 +75,7 @@ function applyView() {
53
75
  if (!hasComments && this.commentsPanel.el.isConnected) this.commentsPanel.el.remove();
54
76
  if (hasCatalog) this.refreshCatalog();
55
77
  this.renderPanels();
78
+ this.ribbon?.refresh();
56
79
  }
57
80
 
58
81
  function renderPanels() {
@@ -114,4 +137,4 @@ function openColumnDialog() {
114
137
  });
115
138
  }
116
139
 
117
- export const viewMethods = { setView, applyView, renderPanels, renderHead, openPageSetupDialog, openMarginDialog, openColumnDialog, setPreview };
140
+ export const viewMethods = { setView, applyView, renderPanels, renderHead, openPageSetupDialog, openMarginDialog, openColumnDialog, setPreview, toggleFullscreen, setPageFullscreen, renderFullscreenBtn };
@@ -86,6 +86,7 @@ export class WordApp {
86
86
  this.editMode = 'edit';
87
87
  this.preview = false;
88
88
  this.previewRestore = null;
89
+ this.pageFullscreen = false;
89
90
  this.dirty = false;
90
91
  this.saving = false;
91
92
  this.suggestionCount = 0;
@@ -114,20 +115,19 @@ export class WordApp {
114
115
  root.className = 'word-app word-skin';
115
116
  if (this.embed) root.classList.add('gbd-is-embed');
116
117
  root.innerHTML = `
117
- <div class="gbd-menubar-host"></div>
118
- <div class="word-head">
119
- <span class="word-head__title"></span>
120
- <span class="word-head__path"></span>
118
+ <div class="gbo-head word-head">
119
+ <span class="gbo-head__title"></span>
120
+ <span class="gbo-head__sub"></span>
121
121
  <span class="word-head__dirty" hidden>●</span>
122
- <span class="word-head__spacer"></span>
123
- <span class="word-head__actions">
124
- <label class="word-head__auto"><input type="checkbox" class="word-head__autosave" />自动保存</label>
125
- <button type="button" class="gbd-btn" data-act="open">打开</button>
126
- <button type="button" class="gbd-btn" data-act="save">保存</button>
127
- <button type="button" class="gbd-btn" data-act="export">导出副本</button>
122
+ <span class="gbo-head__spacer"></span>
123
+ <span class="gbo-head__actions">
124
+ <label class="gbo-head__auto"><input type="checkbox" class="gbo-head__autosave" />自动保存</label>
125
+ <button type="button" class="gbo-head__btn gbo-head__btn--primary" data-act="save">保存</button>
128
126
  </span>
129
- <button type="button" class="gbd-btn word-head__preview" data-act="preview" title="预览模式" aria-pressed="false">${icon('eye')}<span>预览</span></button>
127
+ <button type="button" class="gbo-head__btn gbo-head__preview" data-act="preview" title="预览模式" aria-pressed="false">${icon('eye')}<span>预览</span></button>
128
+ <button type="button" class="gbo-head__btn gbo-head__preview" data-act="fullscreen" title="全屏" aria-pressed="false">${icon('fullscreen')}<span>全屏</span></button>
130
129
  </div>
130
+ <div class="gbd-menubar-host"></div>
131
131
  <div class="gbd-toolbar-host"></div>
132
132
  <div class="word-main">
133
133
  <div class="word-editor"><div class="word-editor-mount"></div></div>
@@ -140,15 +140,16 @@ export class WordApp {
140
140
  this.menubarHost = root.querySelector('.gbd-menubar-host');
141
141
  this.headEl = root.querySelector('.word-head');
142
142
  this.toolbarHost = root.querySelector('.gbd-toolbar-host');
143
- this.headActionsEl = root.querySelector('.word-head__actions');
143
+ this.headActionsEl = root.querySelector('.gbo-head__actions');
144
144
  // 预览按钮不随只读被 inert:它要能在预览档里继续点「退出预览」
145
145
  this.guard = createReadOnlyGuard(root, { editZones: () => [this.headActionsEl, this.toolbarHost] });
146
146
  this.editorWrap = root.querySelector('.word-editor');
147
- this.titleEl = root.querySelector('.word-head__title');
148
- this.pathEl = root.querySelector('.word-head__path');
147
+ this.titleEl = root.querySelector('.gbo-head__title');
148
+ this.pathEl = root.querySelector('.gbo-head__sub');
149
149
  this.dirtyEl = root.querySelector('.word-head__dirty');
150
- this.autosaveEl = root.querySelector('.word-head__autosave');
150
+ this.autosaveEl = root.querySelector('.gbo-head__autosave');
151
151
  this.previewBtn = root.querySelector('[data-act="preview"]');
152
+ this.fullscreenBtn = root.querySelector('[data-act="fullscreen"]');
152
153
 
153
154
  this.catalogPanel = new CatalogPanel((key) => this.locateCatalog(key));
154
155
  this.commentsPanel = new CommentsPanel({
@@ -247,10 +248,16 @@ export class WordApp {
247
248
  return hostAction ? hostAction() : fallback.call(this);
248
249
  });
249
250
  };
250
- bind('open', 'open', this.openFile);
251
251
  bind('save', 'save', this.save);
252
- bind('export', 'exportCopy', this.exportDocx);
253
252
  this.previewBtn.addEventListener('click', () => this.setPreview(!this.preview));
253
+ this.fullscreenBtn.addEventListener('click', () => this.toggleFullscreen());
254
+ this.onFullscreenEsc = (event) => {
255
+ if (event.key !== 'Escape' || !this.pageFullscreen) return;
256
+ // 菜单/弹窗开着时先交给它们自己关,别一按 Esc 就退出全屏
257
+ if (document.querySelector('.gbd-menu, .gbd-modal-mask, .gbd-prompt, .gbrt-modal')) return;
258
+ event.stopPropagation();
259
+ this.setPageFullscreen(false);
260
+ };
254
261
  this.autosaveEl.addEventListener('change', () => {
255
262
  const on = this.autosaveEl.checked;
256
263
  if (this.embed && this.io?.setAutosave) return this.io.setAutosave(on);
@@ -438,6 +445,7 @@ export class WordApp {
438
445
  cancelAnimationFrame(this.pageRaf);
439
446
  // 菜单/浮层挂 body:宿主卸载后不收,会留下悬空浮层与 document 监听
440
447
  closeAll();
448
+ document.removeEventListener('keydown', this.onFullscreenEsc, true);
441
449
  this.guard.destroy();
442
450
  this.surface.destroy();
443
451
  this.scopeEl?.remove();
@@ -9,6 +9,7 @@
9
9
  */
10
10
  import { LINE_HEIGHTS } from '../editor/constants.js';
11
11
  import { tableMenuItems as buildTableMenuItems } from '../editor/engine/tableMenu.js';
12
+ import { FONT_FAMILIES, FONT_SIZES } from '../textStyles.js';
12
13
  import { HF_MODES, PAGE_NUMBER_ALIGNS, PARA_STYLES } from './constants.js';
13
14
 
14
15
  /** 行距预设(空串 = 跟随正文默认行高;档位复用内核) */
@@ -25,6 +26,32 @@ const ALIGN_ITEMS = [
25
26
  { label: '两端对齐', v: 'justify' },
26
27
  ];
27
28
 
29
+ /** 右键菜单色板:常用 12 色,够用又不把子菜单撑出屏幕 */
30
+ const TEXT_PALETTE = [
31
+ { label: '黑色', value: '#000000' },
32
+ { label: '深灰', value: '#666666' },
33
+ { label: '浅灰', value: '#999999' },
34
+ { label: '白色', value: '#ffffff' },
35
+ { label: '红色', value: '#ff0000' },
36
+ { label: '橙色', value: '#ff9900' },
37
+ { label: '黄色', value: '#ffd966' },
38
+ { label: '绿色', value: '#38761d' },
39
+ { label: '青色', value: '#00b0f0' },
40
+ { label: '蓝色', value: '#2a6bff' },
41
+ { label: '紫色', value: '#9900ff' },
42
+ { label: '粉色', value: '#c27ba0' },
43
+ ];
44
+
45
+ /** 突出显示色板:浅底色,避免正文看不清 */
46
+ const HIGHLIGHT_PALETTE = [
47
+ { label: '黄色', value: '#fff3b0' },
48
+ { label: '绿色', value: '#d3f2b3' },
49
+ { label: '青色', value: '#b3e9e9' },
50
+ { label: '蓝色', value: '#d0e4f7' },
51
+ { label: '粉色', value: '#fddede' },
52
+ { label: '灰色', value: '#e7e9eb' },
53
+ ];
54
+
28
55
  /** 页眉页脚重复模式 */
29
56
  const HF_ITEMS = HF_MODES.map((m) => ({ label: m.label, v: m.value }));
30
57
 
@@ -36,20 +63,130 @@ export const VIEW_TOGGLES = [
36
63
 
37
64
  /**
38
65
  * 正文右键菜单(编辑面非表格区的右键;条目与菜单栏「编辑 / 格式 / 插入」同源,禁各写一份)
66
+ * [设计] 字体 / 段落 / 项目符号和编号 / 更换背景用二级菜单承载,打开即见当前状态勾选;
67
+ * 只挂真实可执行的命令,没有实现的能力(AI 排版、划词翻译、格式刷)不摆假入口。
39
68
  * @param {Object} ctx 页面注入的 menuCtx(state/edit/format/insert 与菜单栏同一份)
40
69
  */
41
70
  export const textMenuItems = (ctx) => {
42
71
  const has = () => Boolean(ctx.state.hasSelection);
72
+ const state = () => ctx.state;
43
73
  return [
44
- { label: '剪切', shortcut: 'Ctrl+X', disabled: !has(), onClick: ctx.edit.cut },
45
- { label: '复制', shortcut: 'Ctrl+C', disabled: !has(), onClick: ctx.edit.copy },
46
- { label: '粘贴', shortcut: 'Ctrl+V', onClick: ctx.edit.paste },
74
+ { label: '剪切', icon: 'cut', shortcut: 'Ctrl+X', disabled: !has(), onClick: ctx.edit.cut },
75
+ { label: '复制', icon: 'copy', shortcut: 'Ctrl+C', disabled: !has(), onClick: ctx.edit.copy },
76
+ { label: '粘贴', icon: 'paste', shortcut: 'Ctrl+V', onClick: ctx.edit.paste },
47
77
  { divided: true },
48
- { label: '全选', shortcut: 'Ctrl+A', onClick: ctx.edit.selectAll },
49
- { label: '清除格式', disabled: !has(), onClick: ctx.format.clearFormat },
78
+ {
79
+ label: '字体',
80
+ icon: 'fontCollection',
81
+ children: [
82
+ {
83
+ label: '字体',
84
+ children: FONT_FAMILIES.map((f) => ({
85
+ label: f.label,
86
+ checked: state().fontFamily === f.value,
87
+ onClick: () => ctx.format.setFontFamily(f.value),
88
+ })),
89
+ },
90
+ {
91
+ label: '字号',
92
+ children: FONT_SIZES.map((v) => ({
93
+ label: String(v),
94
+ checked: state().fontSize === `${v}px`,
95
+ onClick: () => ctx.format.setFontSize(`${v}px`),
96
+ })),
97
+ },
98
+ { divided: true },
99
+ { label: '加粗', checked: state().bold, onClick: ctx.format.bold },
100
+ { label: '斜体', checked: state().italic, onClick: ctx.format.italic },
101
+ { label: '下划线', checked: state().underline, onClick: ctx.format.underline },
102
+ { label: '删除线', checked: state().strike, onClick: ctx.format.strike },
103
+ { label: '上标', checked: state().superscript, onClick: ctx.format.superscript },
104
+ { label: '下标', checked: state().subscript, onClick: ctx.format.subscript },
105
+ { divided: true },
106
+ {
107
+ label: '字体颜色',
108
+ icon: 'colorIcon',
109
+ children: [
110
+ { label: '自动', onClick: ctx.format.unsetColor },
111
+ ...TEXT_PALETTE.map((c) => ({
112
+ label: c.label,
113
+ colorDot: c.value,
114
+ checked: state().color === c.value,
115
+ onClick: () => ctx.format.setColor(c.value),
116
+ })),
117
+ ],
118
+ },
119
+ ],
120
+ },
121
+ {
122
+ label: '段落',
123
+ icon: 'lineSpacing',
124
+ children: [
125
+ {
126
+ label: '对齐方式',
127
+ children: ALIGN_ITEMS.map((a) => ({
128
+ label: a.label,
129
+ checked: state().align === a.v,
130
+ onClick: () => ctx.format.align(a.v),
131
+ })),
132
+ },
133
+ {
134
+ label: '行距',
135
+ children: LINE_SPACING_ITEMS.map((s) => ({
136
+ label: s.label,
137
+ checked: state().lineHeight === s.v,
138
+ onClick: () => ctx.format.setLineHeight(s.v),
139
+ })),
140
+ },
141
+ {
142
+ label: '段落样式',
143
+ children: PARA_STYLES.map((s) => ({
144
+ label: s.label,
145
+ checked: state().blockType === s.value,
146
+ onClick: () => ctx.format.paragraphStyle(s.value),
147
+ })),
148
+ },
149
+ { divided: true },
150
+ { label: '首行缩进 2 字符', checked: state().firstLineIndent, onClick: ctx.format.firstLine },
151
+ { label: '增加缩进', onClick: () => ctx.format.indent('increaseBlockIndent') },
152
+ { label: '减少缩进', onClick: () => ctx.format.indent('decreaseBlockIndent') },
153
+ ],
154
+ },
155
+ {
156
+ label: '项目符号和编号',
157
+ icon: 'multiLevel',
158
+ children: [
159
+ { label: '无序列表', checked: state().bulletList, onClick: () => ctx.format.list('toggleBulletList') },
160
+ { label: '有序列表', checked: state().orderedList, onClick: () => ctx.format.list('toggleOrderedList') },
161
+ { label: '待办列表', checked: state().taskList, onClick: () => ctx.format.list('toggleTaskList') },
162
+ ],
163
+ },
164
+ { divided: true },
165
+ {
166
+ label: '更换背景',
167
+ icon: 'background',
168
+ children: [
169
+ {
170
+ label: '突出显示',
171
+ icon: 'highlight',
172
+ children: [
173
+ { label: '无', onClick: ctx.format.unsetHighlight },
174
+ ...HIGHLIGHT_PALETTE.map((c) => ({
175
+ label: c.label,
176
+ colorDot: c.value,
177
+ checked: state().backgroundColor === c.value,
178
+ onClick: () => ctx.format.setHighlight(c.value),
179
+ })),
180
+ ],
181
+ },
182
+ { label: '页面水印...', onClick: ctx.insert.watermark },
183
+ ],
184
+ },
185
+ { label: '超链接...', icon: 'linkIcon', shortcut: 'Ctrl+K', disabled: !has(), onClick: ctx.insert.link },
186
+ { label: '插入批注...', icon: 'comment', disabled: !has(), onClick: ctx.insert.comment },
50
187
  { divided: true },
51
- { label: '批注...', disabled: !has(), onClick: ctx.insert.comment },
52
- { label: '链接...', disabled: !has(), onClick: ctx.insert.link },
188
+ { label: '全选', icon: 'selectAll', shortcut: 'Ctrl+A', onClick: ctx.edit.selectAll },
189
+ { label: '清除格式', icon: 'eraser', disabled: !has(), onClick: ctx.format.clearFormat },
53
190
  ];
54
191
  };
55
192
 
@@ -1,5 +1,6 @@
1
- // [文件] gbdocx·ContextMenu —— 右键/下拉菜单渲染(条目口径:label/disabled/checked/icon/colorDot/shortcut/divided/children/input/onClick)
1
+ // [文件] gbdocx·ContextMenu —— 右键/下拉菜单渲染(条目口径:label/icon/disabled/checked/colorDot/shortcut/divided/children/input/onClick)
2
2
  import { openPopup } from './popup.js';
3
+ import { icon } from './icons.js';
3
4
 
4
5
  const CHECK = '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12l5 5L20 7"/></svg>';
5
6
  const SUB = '<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 6l6 6-6 6"/></svg>';
@@ -58,6 +59,8 @@ function buildList(items) {
58
59
  if (item.checked) lead.innerHTML = CHECK;
59
60
  else if (item.colorDot) {
60
61
  lead.innerHTML = `<i class="gbd-menu__dot" style="background:${item.colorDot}"></i>`;
62
+ } else if (item.icon) {
63
+ lead.innerHTML = icon(item.icon);
61
64
  }
62
65
  row.appendChild(lead);
63
66
 
package/src/ui/icons.js CHANGED
@@ -51,6 +51,8 @@ export const ICONS = {
51
51
  bookmark: S('<path d="M6 4h12v17l-6-4-6 4z"/>'),
52
52
  panel: S('<rect x="3" y="4" width="18" height="16" rx="1"/><path d="M15 4v16"/>'),
53
53
  eye: S('<path d="M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12z"/><circle cx="12" cy="12" r="2.8"/>'),
54
+ fullscreen: S('<path d="M4 4h6v2H6v4H4zM14 4h6v6h-2V6h-4zM4 14h2v4h4v2H4zM18 14h2v6h-6v-2h4z"/>'),
55
+ fullscreenExit: S('<path d="M9 4h2v6H5V8h4zM13 4h2v4h4v2h-6zM5 14h6v6H9v-4H5zM13 16h6v-2h-4v-4h-2z"/>'),
54
56
  margin: S('<rect x="3" y="3" width="18" height="18" rx="1"/><rect x="8" y="8" width="8" height="8" rx="0.5"/>'),
55
57
  zoomReset: S('<circle cx="10.5" cy="10.5" r="6.5"/><path d="M15.5 15.5L21 21M7.5 10.5h6"/>'),
56
58
  selectAll: S('<rect x="3" y="3" width="12" height="12" rx="1"/><path d="M9 21h10a2 2 0 0 0 2-2V9"/>'),
@@ -71,7 +73,6 @@ export const ICONS = {
71
73
  // 段落
72
74
  multiLevel: S('<path d="M9 6h11M9 12h11M9 18h11M4 5h1v3M4 11h2l-2 3h2M4 17h2v3H4z"/>'),
73
75
  outdent: S('<path d="M11 6h9M11 12h9M11 18h9M3 12h6M6 9l-3 3 3 3"/>'),
74
- showMarks: S('<path d="M8 4v13a3 3 0 1 1-3-3M4 14h4M12 6h9M12 12h7M12 18h9"/>'),
75
76
  distribute: S('<path d="M4 6h16M7 12h10M4 18h16M4 3v18M20 3v18"/>'),
76
77
  lineSpacing: S('<path d="M4 7h10M4 12h10M4 17h10M18 5v14M15 8l3-3 3 3M15 16l3 3 3-3"/>'),
77
78
  shading: S('<path d="M4 4h16v16H4zM4 9h16M4 14h16M9 4v16M15 4v16"/>'),
package/styles/app.css CHANGED
@@ -67,6 +67,7 @@
67
67
  pointer-events: none;
68
68
  }
69
69
 
70
+
70
71
  .word-scope .rich-edit-surface .re-table-layer {
71
72
  --gbd-re-handle-thickness: 12px;
72
73
  position: absolute;
@@ -251,7 +252,17 @@
251
252
  min-height: 0;
252
253
  }
253
254
 
254
- .word-scope .word-head__dirty {
255
+ /* 页面内全屏态:整个 Word 应用铺满视口(文档头留着,恢复按钮在同一位置) */
256
+ .word-scope .word-app.gbd-is-pagefullscreen {
257
+ position: fixed;
258
+ inset: 0;
259
+ z-index: 500;
260
+ width: 100%;
261
+ height: 100%;
262
+ background: var(--gbd-dt-bg);
263
+ }
264
+
265
+ .word-scope .word-head .word-head__dirty {
255
266
  color: var(--gbd-dt-warning);
256
267
  }
257
268
 
@@ -521,14 +532,16 @@
521
532
  }
522
533
 
523
534
  .word-scope .gbd-menu__list {
524
- min-width: 160px;
525
- padding: 4px;
535
+ min-width: 190px;
536
+ padding: 5px;
526
537
  }
527
538
  .word-scope .gbd-menu__item {
528
539
  display: flex;
529
540
  align-items: center;
530
- gap: 6px;
531
- padding: 5px 8px;
541
+ gap: 8px;
542
+ box-sizing: border-box;
543
+ min-height: 30px;
544
+ padding: 0 8px;
532
545
  border-radius: 4px;
533
546
  font-size: 13px;
534
547
  white-space: nowrap;
@@ -548,9 +561,19 @@
548
561
  color: var(--gbd-dt-danger);
549
562
  }
550
563
  .word-scope .gbd-menu__lead {
551
- width: 14px;
564
+ width: 18px;
552
565
  display: inline-flex;
566
+ align-items: center;
553
567
  justify-content: center;
568
+ flex: none;
569
+ color: var(--gbd-dt-text-secondary);
570
+ }
571
+ .word-scope .gbd-menu__lead svg {
572
+ width: 15px;
573
+ height: 15px;
574
+ }
575
+ .word-scope .gbd-menu__item.gbd-is-disabled .gbd-menu__lead {
576
+ opacity: 0.55;
554
577
  }
555
578
  .word-scope .gbd-menu__dot {
556
579
  width: 12px;
@@ -562,15 +585,18 @@
562
585
  flex: 1;
563
586
  }
564
587
  .word-scope .gbd-menu__shortcut {
588
+ margin-left: 16px;
565
589
  color: var(--gbd-dt-text-tertiary);
566
590
  font-size: 11px;
567
591
  }
568
592
  .word-scope .gbd-menu__arrow {
593
+ display: inline-flex;
594
+ margin-left: 8px;
569
595
  color: var(--gbd-dt-text-tertiary);
570
596
  }
571
597
  .word-scope .gbd-menu__sep {
572
598
  height: 1px;
573
- margin: 4px 0;
599
+ margin: 4px 2px;
574
600
  background: var(--gbd-dt-border);
575
601
  }
576
602
  .word-scope .gbd-menu__input {
@@ -896,21 +922,21 @@
896
922
  word-break: break-word;
897
923
  }
898
924
 
899
- /* ==================== 预览模式 ==================== */
900
- /* 只留文件头(标题/路径 + 退出预览)与正文;菜单、功能区、状态栏、侧栏等编辑界面全部收起 */
901
- .word-scope .word-app.gb-is-preview .word-head__actions,
902
- .word-scope .word-app.gb-is-preview .gbd-toolbar-host,
903
- .word-scope .word-app.gb-is-preview .gbd-statusbar-host,
904
- .word-scope .word-app.gb-is-preview .gbd-panel,
905
- .word-scope .word-app.gb-is-preview .gbd-findbar,
906
- .word-scope .word-app.gb-is-preview .word-chars-pop {
907
- display: none;
908
- }
909
- /* 预览档本体也是只读档,但退出按钮不能被只读档的 55% 透明度压暗 */
910
- .word-scope .word-app.gb-is-preview .word-head {
911
- opacity: 1;
912
- }
913
-
925
+ /* ==================== 预览模式 ==================== */
926
+ /* 只留文件头(标题/路径 + 退出预览)与正文;菜单、功能区、状态栏、侧栏等编辑界面全部收起 */
927
+ .word-scope .word-app.gb-is-preview .gbo-head__actions,
928
+ .word-scope .word-app.gb-is-preview .gbd-toolbar-host,
929
+ .word-scope .word-app.gb-is-preview .gbd-statusbar-host,
930
+ .word-scope .word-app.gb-is-preview .gbd-panel,
931
+ .word-scope .word-app.gb-is-preview .gbd-findbar,
932
+ .word-scope .word-app.gb-is-preview .word-chars-pop {
933
+ display: none;
934
+ }
935
+ /* 预览档本体也是只读档,但退出按钮不能被只读档的 55% 透明度压暗 */
936
+ .word-scope .word-app.gb-is-preview .word-head {
937
+ opacity: 1;
938
+ }
939
+
914
940
  /* ==================== 只读档 ==================== */
915
941
  /* 编辑控件已被 inert,压低视觉权重但不改底色;禁用态背景属状态反馈,不受静态背景约束 */
916
942
  .word-scope .word-app.gb-is-readonly:not(.gb-is-preview) .word-head,