gbxlxs 0.5.0 → 0.5.2
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/web/app/sheets-app.js +49 -0
- package/web/app/toolbar.js +3 -5
- package/web/app/ui/icons.js +1 -0
- package/web/styles/sheets.css +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gbxlxs",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Standalone spreadsheet (XLSX) engine with a self-contained HTML editor: read/write xlsx, workbook model ops, CSV/HTML import-export and a full spreadsheet UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"gbooxml": "^0.1.3",
|
|
30
|
-
"gbofficeui": "^0.
|
|
30
|
+
"gbofficeui": "^0.1.0",
|
|
31
31
|
"guabiutils": "^0.3.0"
|
|
32
32
|
},
|
|
33
33
|
"keywords": [
|
package/web/app/sheets-app.js
CHANGED
|
@@ -74,6 +74,7 @@ export class SheetEditor {
|
|
|
74
74
|
this.menuBarVisible = !options.hideMenuBar;
|
|
75
75
|
this.preview = false;
|
|
76
76
|
this.previewRestore = null;
|
|
77
|
+
this.pageFullscreen = false;
|
|
77
78
|
this.active = !this.embedded;
|
|
78
79
|
this.ready = false;
|
|
79
80
|
this.saving = false;
|
|
@@ -144,6 +145,7 @@ export class SheetEditor {
|
|
|
144
145
|
<button type="button" class="gbo-head__btn gbo-head__btn--primary sheets-save" data-act="save">保存</button>
|
|
145
146
|
</span>
|
|
146
147
|
<button type="button" class="gbo-head__btn gbo-head__preview" data-act="preview" title="预览模式" aria-pressed="false">${icon('view', 14)}<span>预览</span></button>
|
|
148
|
+
<button type="button" class="gbo-head__btn gbo-head__preview" data-act="fullscreen" title="全屏" aria-pressed="false">${icon('fullscreen', 14)}<span>全屏</span></button>
|
|
147
149
|
</div>
|
|
148
150
|
<div class="sheets-menubar">
|
|
149
151
|
<div class="gbx-menubar">${MENU_LABELS.map((m) => `<button type="button" class="gbx-menubar-btn" data-menu="${m.key}">${m.label}</button>`).join('')}</div>
|
|
@@ -169,6 +171,7 @@ export class SheetEditor {
|
|
|
169
171
|
this.saveBtn = this.root.querySelector('[data-act="save"]');
|
|
170
172
|
this.autosaveEl = this.root.querySelector('.gbo-head__autosave');
|
|
171
173
|
this.previewBtn = this.root.querySelector('[data-act="preview"]');
|
|
174
|
+
this.fullscreenBtn = this.root.querySelector('[data-act="fullscreen"]');
|
|
172
175
|
this.toolbarHost = this.root.querySelector('.sheet-toolbar-host');
|
|
173
176
|
this.formulaHost = this.root.querySelector('.sheet-formula-host');
|
|
174
177
|
this.gridHost = this.root.querySelector('.sheet-grid-host');
|
|
@@ -230,9 +233,52 @@ export class SheetEditor {
|
|
|
230
233
|
this.previewBtn.querySelector('span').textContent = active ? '退出预览' : '预览';
|
|
231
234
|
}
|
|
232
235
|
|
|
236
|
+
/** 全屏/恢复:整个表格应用铺满网页(页面内覆盖;不用原生 Fullscreen,
|
|
237
|
+
* 否则 append 到 body 的菜单/弹窗在全屏层外不可见) */
|
|
238
|
+
toggleFullscreen() {
|
|
239
|
+
this.setPageFullscreen(!this.pageFullscreen);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
setPageFullscreen(on) {
|
|
243
|
+
const next = !!on;
|
|
244
|
+
if (next === this.pageFullscreen) return;
|
|
245
|
+
this.pageFullscreen = next;
|
|
246
|
+
if (next) {
|
|
247
|
+
// [坑] 页面主容器常是 position:fixed(自带层叠上下文),留在原位时再高的 z-index 也压不过全局顶栏;
|
|
248
|
+
// 全屏期间临时挂到 body 顶层层叠上下文,同时补上作用域类(box-sizing/滚动条规则挂在 .gbx-root 上)
|
|
249
|
+
this.fsHome = { parent: this.root.parentNode, next: this.root.nextSibling };
|
|
250
|
+
this.root.classList.add('gbx-root', 'gbx-is-pagefullscreen');
|
|
251
|
+
document.body.appendChild(this.root);
|
|
252
|
+
document.addEventListener('keydown', this.onFullscreenEsc, true);
|
|
253
|
+
} else {
|
|
254
|
+
this.root.classList.remove('gbx-is-pagefullscreen', 'gbx-root');
|
|
255
|
+
if (this.fsHome?.parent) this.fsHome.parent.insertBefore(this.root, this.fsHome.next);
|
|
256
|
+
this.fsHome = null;
|
|
257
|
+
document.removeEventListener('keydown', this.onFullscreenEsc, true);
|
|
258
|
+
}
|
|
259
|
+
this.renderFullscreenBtn();
|
|
260
|
+
// 视图选项卡里的同名入口跟着换选中态
|
|
261
|
+
this.toolbar?.render?.();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
renderFullscreenBtn() {
|
|
265
|
+
const active = this.pageFullscreen;
|
|
266
|
+
this.fullscreenBtn.title = active ? '退出全屏' : '全屏';
|
|
267
|
+
this.fullscreenBtn.setAttribute('aria-pressed', String(active));
|
|
268
|
+
this.fullscreenBtn.innerHTML = `${icon(active ? 'fullscreenExit' : 'fullscreen', 14)}<span>${active ? '恢复' : '全屏'}</span>`;
|
|
269
|
+
}
|
|
270
|
+
|
|
233
271
|
bindEvents() {
|
|
234
272
|
this.saveBtn.addEventListener('click', () => this.saveNow());
|
|
235
273
|
this.previewBtn.addEventListener('click', () => this.setPreview(!this.preview));
|
|
274
|
+
this.fullscreenBtn.addEventListener('click', () => this.toggleFullscreen());
|
|
275
|
+
this.onFullscreenEsc = (event) => {
|
|
276
|
+
if (event.key !== 'Escape' || !this.pageFullscreen) return;
|
|
277
|
+
// 菜单/弹窗开着时先交给它们自己关,别一按 Esc 就退出全屏
|
|
278
|
+
if (document.querySelector('.gbx-menu, .gbx-modal-mask, .gbx-prompt')) return;
|
|
279
|
+
event.stopPropagation();
|
|
280
|
+
this.setPageFullscreen(false);
|
|
281
|
+
};
|
|
236
282
|
this.autosaveEl.addEventListener('change', () => this.setAutoSave(this.autosaveEl.checked));
|
|
237
283
|
this.menuBarEl.addEventListener('click', (event) => {
|
|
238
284
|
const btn = event.target.closest('[data-menu]');
|
|
@@ -1003,6 +1049,8 @@ export class SheetEditor {
|
|
|
1003
1049
|
}
|
|
1004
1050
|
|
|
1005
1051
|
dispose() {
|
|
1052
|
+
// 全屏中的根节点挂在 body 上:先归还原位,宿主随后清空挂载点时才能一并移除
|
|
1053
|
+
if (this.pageFullscreen) this.setPageFullscreen(false);
|
|
1006
1054
|
closeMenus();
|
|
1007
1055
|
closePrompt();
|
|
1008
1056
|
closeColorPanel();
|
|
@@ -1011,6 +1059,7 @@ export class SheetEditor {
|
|
|
1011
1059
|
document.removeEventListener('mousedown', this.onPointerDown, true);
|
|
1012
1060
|
document.removeEventListener('mouseup', this.onPointerUp, true);
|
|
1013
1061
|
document.removeEventListener('keydown', this.onKeydown);
|
|
1062
|
+
document.removeEventListener('keydown', this.onFullscreenEsc, true);
|
|
1014
1063
|
this.root.removeEventListener('paste', this.onPaste);
|
|
1015
1064
|
this.unbindWheelZoom?.();
|
|
1016
1065
|
window.removeEventListener('beforeunload', this.onBeforeUnload);
|
package/web/app/toolbar.js
CHANGED
|
@@ -782,13 +782,11 @@ export class SheetToolbar {
|
|
|
782
782
|
key: 'fullscreen',
|
|
783
783
|
kind: 'sel',
|
|
784
784
|
icon: 'fullscreen',
|
|
785
|
-
label: '全屏',
|
|
785
|
+
label: () => (this.app.pageFullscreen ? '恢复' : '全屏'),
|
|
786
786
|
tip: '全屏显示',
|
|
787
787
|
grid: [2, 2],
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
else document.documentElement.requestFullscreen();
|
|
791
|
-
},
|
|
788
|
+
active: () => this.app.pageFullscreen,
|
|
789
|
+
onClick: () => this.app.toggleFullscreen(),
|
|
792
790
|
},
|
|
793
791
|
],
|
|
794
792
|
},
|
package/web/app/ui/icons.js
CHANGED
|
@@ -37,6 +37,7 @@ const paths = {
|
|
|
37
37
|
cf: '<rect x="3.8" y="3.8" width="7.2" height="7.2" rx="1.2" fill="currentColor"/><rect x="13" y="3.8" width="7.2" height="7.2" rx="1.2" fill="currentColor" opacity="0.4"/><rect x="3.8" y="13" width="7.2" height="7.2" rx="1.2" fill="currentColor" opacity="0.4"/><rect x="13" y="13" width="7.2" height="7.2" rx="1.2" fill="currentColor" opacity="0.7"/>',
|
|
38
38
|
freeze: '<rect x="3.5" y="3.5" width="17" height="17" rx="1" fill="none" stroke="currentColor" stroke-width="1.6"/><rect x="4.5" y="4.5" width="15" height="4.6" fill="currentColor" opacity="0.35"/><path d="M3.5 9.1h17" fill="none" stroke="currentColor" stroke-width="1.6"/>',
|
|
39
39
|
fullscreen: '<path d="M3.5 3.5h7v2.4H5.9v4.6H3.5zM13.5 3.5h7v7h-2.4V5.9h-4.6zM3.5 13.5h2.4v4.6h4.6v2.4h-7zM18.1 13.5h2.4v7h-7v-2.4h4.6z"/>',
|
|
40
|
+
fullscreenExit: '<path d="M3.5 9.5h6v-6H7.1v3.6H3.5zM14.5 9.5h6V7.1h-3.6V3.5h-2.4zM3.5 14.5h3.6v3.6h2.4v-6h-6zM20.5 14.5h-6v6h2.4v-3.6h3.6z"/>',
|
|
40
41
|
check: '<path d="M9.6 16.2 5.4 12l-1.5 1.5 5.7 5.7L20 8.7 18.5 7.2z"/>',
|
|
41
42
|
close: '<path d="M6.4 5 5 6.4 10.6 12 5 17.6 6.4 19 12 13.4 17.6 19 19 17.6 13.4 12 19 6.4 17.6 5 12 10.6z"/>',
|
|
42
43
|
chevronRight: '<path d="M9.2 4.6 16.6 12l-7.4 7.4-1.6-1.6L13.4 12 7.6 6.2z"/>',
|
package/web/styles/sheets.css
CHANGED
|
@@ -39,6 +39,16 @@
|
|
|
39
39
|
color: var(--gbx-dt-text);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/* 页面内全屏态:整个表格应用铺满视口(文档头留着,恢复按钮在同一位置) */
|
|
43
|
+
.sheets-app.gbx-is-pagefullscreen {
|
|
44
|
+
position: fixed;
|
|
45
|
+
inset: 0;
|
|
46
|
+
z-index: 500;
|
|
47
|
+
width: 100%;
|
|
48
|
+
height: 100%;
|
|
49
|
+
background: var(--gbx-dt-surface);
|
|
50
|
+
}
|
|
51
|
+
|
|
42
52
|
.sheets-app.dark {
|
|
43
53
|
--gbx-sg-bg: #1e1f22;
|
|
44
54
|
--gbx-sg-text: #d9dce1;
|