gbpptx 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gbpptx",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Office-style PowerPoint (pptx) editor: real PresentationML read/write, ribbon UI, slide sorter, presenter view.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "gbooxml": "^0.1.0",
41
- "gbofficeui": "^0.2.0",
41
+ "gbofficeui": "^0.1.0",
42
42
  "guabiutils": "^0.3.0"
43
43
  },
44
44
  "devDependencies": {
@@ -21,10 +21,18 @@ function bindGlobal() {
21
21
  this.onResizeBound = () => {
22
22
  if (this.view === 'reading') this.renderReading();
23
23
  };
24
+ this.onFullscreenEsc = (e) => {
25
+ if (e.key !== 'Escape' || !this.pageFullscreen) return;
26
+ // 放映中 Esc 归放映器;菜单/弹窗开着时也先交给它们
27
+ if (this.presenter?.el || document.querySelector('.gbp-popup, .gbp-modal-overlay, .gbp-menu')) return;
28
+ e.stopPropagation();
29
+ this.setPageFullscreen(false);
30
+ };
24
31
 
25
32
  document.addEventListener('keydown', this.onKeyBound);
26
33
  document.addEventListener('selectionchange', this.onSelectionChangeBound);
27
34
  document.addEventListener('paste', this.onPasteBound);
35
+ document.addEventListener('keydown', this.onFullscreenEsc, true);
28
36
  window.addEventListener('beforeunload', this.onBeforeUnloadBound);
29
37
  window.addEventListener('dragover', this.onDragOverBound);
30
38
  window.addEventListener('drop', this.onDropBound);
@@ -124,6 +124,32 @@ function openFormatPane() {
124
124
  this.ribbon.refresh();
125
125
  }
126
126
 
127
+ /** 全屏/恢复:整个演示应用铺满网页(页面内覆盖;不用原生 Fullscreen,
128
+ * 否则 append 到 body 的菜单/弹窗在全屏层外不可见) */
129
+ function toggleFullscreen() {
130
+ this.setPageFullscreen(!this.pageFullscreen);
131
+ }
132
+
133
+ function setPageFullscreen(on) {
134
+ const next = !!on;
135
+ if (next === this.pageFullscreen) return;
136
+ this.pageFullscreen = next;
137
+ if (next) {
138
+ // [坑] 页面主容器常是 position:fixed(自带层叠上下文),留在原位压不过全局顶栏;
139
+ // 全屏期间临时挂到 body 顶层,并补上作用域类(重置/滚动条规则挂在 .gbp-root 上)
140
+ this.fsHome = { parent: this.root.parentNode, next: this.root.nextSibling };
141
+ this.root.classList.add('gbp-root', 'gbp-is-pagefullscreen');
142
+ document.body.appendChild(this.root);
143
+ document.addEventListener('keydown', this.onFullscreenEsc, true);
144
+ } else {
145
+ this.root.classList.remove('gbp-is-pagefullscreen', 'gbp-root');
146
+ if (this.fsHome?.parent) this.fsHome.parent.insertBefore(this.root, this.fsHome.next);
147
+ this.fsHome = null;
148
+ document.removeEventListener('keydown', this.onFullscreenEsc, true);
149
+ }
150
+ this.titlebar?.refresh();
151
+ }
152
+
127
153
  function togglePresenter() {
128
154
  this.presentOptions.presenter = !this.presentOptions.presenter;
129
155
  this.prefs.presenter = this.presentOptions.presenter;
@@ -153,4 +179,4 @@ function presentAt(index) {
153
179
  this.presenter.open(Number(index) || 0);
154
180
  }
155
181
 
156
- export const viewMethods = { setView, setZoom, fitToWindow, toggleNotes, toggleGrid, toggleGuides, setRibbonCollapsed, toggleFormatPane, openFormatPane, togglePresenter, toggleLoop, presentFromStart, presentFromCurrent, presentAt, setPreview };
182
+ export const viewMethods = { setView, setZoom, fitToWindow, toggleNotes, toggleGrid, toggleGuides, setRibbonCollapsed, toggleFormatPane, openFormatPane, togglePresenter, toggleLoop, presentFromStart, presentFromCurrent, presentAt, setPreview, toggleFullscreen, setPageFullscreen };
@@ -65,6 +65,7 @@ export class SlidesApp {
65
65
  this.view = 'normal';
66
66
  this.preview = false;
67
67
  this.previewRestore = null;
68
+ this.pageFullscreen = false;
68
69
  this.presentOptions = { presenter: !!prefs.presenter, loop: !!prefs.loop };
69
70
  this.lastBytes = null;
70
71
 
@@ -254,12 +255,15 @@ export class SlidesApp {
254
255
  }
255
256
 
256
257
  destroy() {
258
+ // 全屏中的根节点挂在 body 上:先归还原位,宿主随后清空挂载点时才能一并移除
259
+ if (this.pageFullscreen) this.setPageFullscreen(false);
257
260
  this.canvas?.unbindWheel?.();
258
261
  this.presenter?.close();
259
262
  clearTimeout(this.autosaveTimer);
260
263
  document.removeEventListener('keydown', this.onKeyBound);
261
264
  document.removeEventListener('paste', this.onPasteBound);
262
265
  document.removeEventListener('selectionchange', this.onSelectionChangeBound);
266
+ document.removeEventListener('keydown', this.onFullscreenEsc, true);
263
267
  window.removeEventListener('beforeunload', this.onBeforeUnloadBound);
264
268
  window.removeEventListener('dragover', this.onDragOverBound);
265
269
  window.removeEventListener('drop', this.onDropBound);
@@ -95,6 +95,8 @@ const BODY = {
95
95
  more: c(5, 12, 1.3) + c(12, 12, 1.3) + c(19, 12, 1.3),
96
96
  lock: r(5, 10, 14, 10, 2) + p('M8 10V7a4 4 0 0 1 8 0v3'),
97
97
  eye: p('M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z') + c(12, 12, 3),
98
+ fullscreen: p('M4 4h6v2H6v4H4zM14 4h6v6h-2V6h-4zM4 14h2v4h4v2H4zM18 14h2v6h-6v-2h4z'),
99
+ fullscreenExit: p('M9 4h2v6H5V8h4zM13 4h2v4h4v2h-6zM5 14h6v6H9v-4H5zM13 16h6v-2h-4v-4h-2z'),
98
100
  crop: p('M6 3v13a2 2 0 0 0 2 2h13M3 6h13a2 2 0 0 1 2 2v13'),
99
101
  resetImage: r(4, 4, 16, 16, 2) + p('M9 15l3-3 2 2 2-2 3 3M14 3v4h4'),
100
102
  replaceImage: r(4, 4, 16, 16, 2) + p('M8 15l3-3 2 2 2-2 3 3M17 2v5h-5'),
@@ -76,7 +76,13 @@ export class TitleBar {
76
76
 
77
77
  this.nameEl = title;
78
78
  this.stateEl = state;
79
- this.headEl.append(title, state, spacer, actions, this.previewBtn);
79
+ this.fullscreenBtn = el('button', 'gbo-head__btn gbo-head__preview', '全屏');
80
+ this.fullscreenBtn.type = 'button';
81
+ this.fullscreenBtn.title = '全屏';
82
+ this.fullscreenBtn.setAttribute('aria-pressed', 'false');
83
+ this.fullscreenBtn.innerHTML = `${icon('fullscreen', 14)}<span>全屏</span>`;
84
+ this.fullscreenBtn.addEventListener('click', () => this.app.toggleFullscreen());
85
+ this.headEl.append(title, state, spacer, actions, this.previewBtn, this.fullscreenBtn);
80
86
  }
81
87
 
82
88
  /** 预览档按钮态:同一位置从「预览」切成「退出预览」 */
@@ -242,6 +248,11 @@ export class TitleBar {
242
248
  this.stateEl.classList.toggle('gbp-is-dirty', app.dirty);
243
249
  this.saveBtn.disabled = app.readOnly || !app.snapshot.slides.length;
244
250
  this.autosaveEl.checked = app.autosave;
251
+ // 全屏态:同一位置切成「恢复」
252
+ const fullscreen = !!app.pageFullscreen;
253
+ this.fullscreenBtn.title = fullscreen ? '退出全屏' : '全屏';
254
+ this.fullscreenBtn.setAttribute('aria-pressed', String(fullscreen));
255
+ this.fullscreenBtn.innerHTML = `${icon(fullscreen ? 'fullscreenExit' : 'fullscreen', 14)}<span>${fullscreen ? '恢复' : '全屏'}</span>`;
245
256
  this.setPreview(app.preview);
246
257
  // 只读档锁掉纯编辑类菜单,放映/视图与文件菜单里的导出/打印照常可用
247
258
  const writeMenus = new Set(['edit', 'insert', 'slide', 'review']);
@@ -28,6 +28,9 @@
28
28
  .pp-ico { display: block; flex: none; }
29
29
  .pp-app { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--gbp-pp-workspace); }
30
30
 
31
+ /* 页面内全屏态:整个演示应用铺满视口(文档头留着,恢复按钮在同一位置) */
32
+ .pp-app.gbp-is-pagefullscreen { position: fixed; inset: 0; z-index: 500; width: 100%; height: 100%; }
33
+
31
34
  /* ==================== 只读档 ==================== */
32
35
  .pp-app.gb-is-readonly .pp-ribbon-host,
33
36
  .pp-app.gb-is-readonly .pp-main__right { opacity: .55; }