gbxlxs 0.5.1 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gbxlxs",
3
- "version": "0.5.1",
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",
@@ -240,10 +240,22 @@ export class SheetEditor {
240
240
  }
241
241
 
242
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);
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
+ }
247
259
  this.renderFullscreenBtn();
248
260
  // 视图选项卡里的同名入口跟着换选中态
249
261
  this.toolbar?.render?.();
@@ -1037,6 +1049,8 @@ export class SheetEditor {
1037
1049
  }
1038
1050
 
1039
1051
  dispose() {
1052
+ // 全屏中的根节点挂在 body 上:先归还原位,宿主随后清空挂载点时才能一并移除
1053
+ if (this.pageFullscreen) this.setPageFullscreen(false);
1040
1054
  closeMenus();
1041
1055
  closePrompt();
1042
1056
  closeColorPanel();