gbxlxs 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/web/app/sheets-app.js +35 -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.1",
|
|
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,40 @@ 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
|
+
this.pageFullscreen = !!on;
|
|
244
|
+
this.root.classList.toggle('gbx-is-pagefullscreen', this.pageFullscreen);
|
|
245
|
+
if (this.pageFullscreen) document.addEventListener('keydown', this.onFullscreenEsc, true);
|
|
246
|
+
else document.removeEventListener('keydown', this.onFullscreenEsc, true);
|
|
247
|
+
this.renderFullscreenBtn();
|
|
248
|
+
// 视图选项卡里的同名入口跟着换选中态
|
|
249
|
+
this.toolbar?.render?.();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
renderFullscreenBtn() {
|
|
253
|
+
const active = this.pageFullscreen;
|
|
254
|
+
this.fullscreenBtn.title = active ? '退出全屏' : '全屏';
|
|
255
|
+
this.fullscreenBtn.setAttribute('aria-pressed', String(active));
|
|
256
|
+
this.fullscreenBtn.innerHTML = `${icon(active ? 'fullscreenExit' : 'fullscreen', 14)}<span>${active ? '恢复' : '全屏'}</span>`;
|
|
257
|
+
}
|
|
258
|
+
|
|
233
259
|
bindEvents() {
|
|
234
260
|
this.saveBtn.addEventListener('click', () => this.saveNow());
|
|
235
261
|
this.previewBtn.addEventListener('click', () => this.setPreview(!this.preview));
|
|
262
|
+
this.fullscreenBtn.addEventListener('click', () => this.toggleFullscreen());
|
|
263
|
+
this.onFullscreenEsc = (event) => {
|
|
264
|
+
if (event.key !== 'Escape' || !this.pageFullscreen) return;
|
|
265
|
+
// 菜单/弹窗开着时先交给它们自己关,别一按 Esc 就退出全屏
|
|
266
|
+
if (document.querySelector('.gbx-menu, .gbx-modal-mask, .gbx-prompt')) return;
|
|
267
|
+
event.stopPropagation();
|
|
268
|
+
this.setPageFullscreen(false);
|
|
269
|
+
};
|
|
236
270
|
this.autosaveEl.addEventListener('change', () => this.setAutoSave(this.autosaveEl.checked));
|
|
237
271
|
this.menuBarEl.addEventListener('click', (event) => {
|
|
238
272
|
const btn = event.target.closest('[data-menu]');
|
|
@@ -1011,6 +1045,7 @@ export class SheetEditor {
|
|
|
1011
1045
|
document.removeEventListener('mousedown', this.onPointerDown, true);
|
|
1012
1046
|
document.removeEventListener('mouseup', this.onPointerUp, true);
|
|
1013
1047
|
document.removeEventListener('keydown', this.onKeydown);
|
|
1048
|
+
document.removeEventListener('keydown', this.onFullscreenEsc, true);
|
|
1014
1049
|
this.root.removeEventListener('paste', this.onPaste);
|
|
1015
1050
|
this.unbindWheelZoom?.();
|
|
1016
1051
|
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;
|