@a200888213/gbdocx 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": "@a200888213/gbdocx",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "挂逼文档:独立 .docx 编辑器(内核移植自 guabi office/docx 编解码 + 自研 contenteditable 编辑器内核,UI 用原生 HTML 重写),只依赖 gbooxml。",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -43,10 +43,22 @@ function toggleFullscreen() {
43
43
  }
44
44
 
45
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);
46
+ const next = !!on;
47
+ if (next === this.pageFullscreen) return;
48
+ this.pageFullscreen = next;
49
+ if (next) {
50
+ // [坑] 页面主容器常是 position:fixed(自带层叠上下文),留在原位压不过全局顶栏;
51
+ // 整个 .word-scope 挂到 body 顶层,作用域样式随节点一起走
52
+ this.fsHome = { parent: this.scopeEl.parentNode, next: this.scopeEl.nextSibling };
53
+ this.root.classList.add('gbd-is-pagefullscreen');
54
+ document.body.appendChild(this.scopeEl);
55
+ document.addEventListener('keydown', this.onFullscreenEsc, true);
56
+ } else {
57
+ this.root.classList.remove('gbd-is-pagefullscreen');
58
+ if (this.fsHome?.parent) this.fsHome.parent.insertBefore(this.scopeEl, this.fsHome.next);
59
+ this.fsHome = null;
60
+ document.removeEventListener('keydown', this.onFullscreenEsc, true);
61
+ }
50
62
  this.renderFullscreenBtn();
51
63
  }
52
64
 
@@ -435,6 +435,8 @@ export class WordApp {
435
435
  }
436
436
 
437
437
  destroy() {
438
+ // 全屏中的 .word-scope 挂着 body:先归还原位,再随挂载点一起移除
439
+ if (this.pageFullscreen) this.setPageFullscreen(false);
438
440
  this.unbindKeys?.();
439
441
  this.unbindWheel?.();
440
442
  this.layoutObs?.disconnect();