@a200888213/gbdocx 0.5.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/package.json +2 -2
- package/src/app/word/view.js +23 -1
- package/src/app/word-app.js +12 -0
- package/src/ui/icons.js +2 -0
- package/styles/app.css +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a200888213/gbdocx",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "挂逼文档:独立 .docx 编辑器(内核移植自 guabi office/docx 编解码 + 自研 contenteditable 编辑器内核,UI 用原生 HTML 重写),只依赖 gbooxml。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"gbooxml": "^0.1.1",
|
|
39
|
-
"gbofficeui": "^0.
|
|
39
|
+
"gbofficeui": "^0.1.0",
|
|
40
40
|
"guabiutils": "^0.3.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
package/src/app/word/view.js
CHANGED
|
@@ -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 };
|
|
@@ -115,4 +137,4 @@ function openColumnDialog() {
|
|
|
115
137
|
});
|
|
116
138
|
}
|
|
117
139
|
|
|
118
|
-
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 };
|
package/src/app/word-app.js
CHANGED
|
@@ -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;
|
|
@@ -124,6 +125,7 @@ export class WordApp {
|
|
|
124
125
|
<button type="button" class="gbo-head__btn gbo-head__btn--primary" data-act="save">保存</button>
|
|
125
126
|
</span>
|
|
126
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>
|
|
127
129
|
</div>
|
|
128
130
|
<div class="gbd-menubar-host"></div>
|
|
129
131
|
<div class="gbd-toolbar-host"></div>
|
|
@@ -147,6 +149,7 @@ export class WordApp {
|
|
|
147
149
|
this.dirtyEl = root.querySelector('.word-head__dirty');
|
|
148
150
|
this.autosaveEl = root.querySelector('.gbo-head__autosave');
|
|
149
151
|
this.previewBtn = root.querySelector('[data-act="preview"]');
|
|
152
|
+
this.fullscreenBtn = root.querySelector('[data-act="fullscreen"]');
|
|
150
153
|
|
|
151
154
|
this.catalogPanel = new CatalogPanel((key) => this.locateCatalog(key));
|
|
152
155
|
this.commentsPanel = new CommentsPanel({
|
|
@@ -247,6 +250,14 @@ export class WordApp {
|
|
|
247
250
|
};
|
|
248
251
|
bind('save', 'save', this.save);
|
|
249
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
|
+
};
|
|
250
261
|
this.autosaveEl.addEventListener('change', () => {
|
|
251
262
|
const on = this.autosaveEl.checked;
|
|
252
263
|
if (this.embed && this.io?.setAutosave) return this.io.setAutosave(on);
|
|
@@ -434,6 +445,7 @@ export class WordApp {
|
|
|
434
445
|
cancelAnimationFrame(this.pageRaf);
|
|
435
446
|
// 菜单/浮层挂 body:宿主卸载后不收,会留下悬空浮层与 document 监听
|
|
436
447
|
closeAll();
|
|
448
|
+
document.removeEventListener('keydown', this.onFullscreenEsc, true);
|
|
437
449
|
this.guard.destroy();
|
|
438
450
|
this.surface.destroy();
|
|
439
451
|
this.scopeEl?.remove();
|
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"/>'),
|
package/styles/app.css
CHANGED
|
@@ -252,6 +252,16 @@
|
|
|
252
252
|
min-height: 0;
|
|
253
253
|
}
|
|
254
254
|
|
|
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
|
+
|
|
255
265
|
.word-scope .word-head .word-head__dirty {
|
|
256
266
|
color: var(--gbd-dt-warning);
|
|
257
267
|
}
|