gbpptx 0.2.0 → 0.4.0

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.
Files changed (46) hide show
  1. package/README.md +237 -214
  2. package/package.json +5 -3
  3. package/src/kernel/model.js +1 -2
  4. package/src/kernel/parts.js +11 -15
  5. package/src/kernel/print.js +14 -16
  6. package/web/app/main.js +8 -8
  7. package/web/app/slides/arrange.js +101 -0
  8. package/web/app/slides/clipboard.js +93 -0
  9. package/web/app/slides/file.js +213 -0
  10. package/web/app/slides/find.js +201 -0
  11. package/web/app/slides/history.js +100 -0
  12. package/web/app/slides/keys.js +179 -0
  13. package/web/app/slides/menus.js +105 -0
  14. package/web/app/slides/objects.js +254 -0
  15. package/web/app/slides/render.js +183 -0
  16. package/web/app/slides/shared.js +85 -0
  17. package/web/app/slides/slides.js +103 -0
  18. package/web/app/slides/table.js +102 -0
  19. package/web/app/slides/text.js +418 -0
  20. package/web/app/slides/view.js +156 -0
  21. package/web/app/slides-app.js +323 -2446
  22. package/web/app/ui/canvas.js +769 -755
  23. package/web/app/ui/color-panel.js +58 -76
  24. package/web/app/ui/dialogs.js +120 -159
  25. package/web/app/ui/file-io.js +116 -132
  26. package/web/app/ui/format-pane.js +427 -427
  27. package/web/app/ui/icons.js +129 -129
  28. package/web/app/ui/menu.js +75 -89
  29. package/web/app/ui/notify.js +45 -45
  30. package/web/app/ui/page-view.js +221 -221
  31. package/web/app/ui/popup.js +80 -80
  32. package/web/app/ui/present.js +292 -292
  33. package/web/app/ui/ribbon.js +868 -878
  34. package/web/app/ui/slide-pane.js +197 -189
  35. package/web/app/ui/statusbar.js +93 -93
  36. package/web/app/ui/text-styles.js +84 -84
  37. package/web/app/ui/titlebar.js +184 -67
  38. package/web/app/ui/transition.js +30 -30
  39. package/web/index.html +23 -21
  40. package/web/serve.mjs +22 -67
  41. package/web/styles/office.css +466 -644
  42. package/web/styles/slides.css +97 -219
  43. package/web/styles/tokens.css +154 -155
  44. package/src/kernel/util/escape.js +0 -21
  45. package/src/kernel/util/id.js +0 -13
  46. package/web/app/ui/backstage.js +0 -255
@@ -1,292 +1,292 @@
1
- // [文件] gbpptx·放映 —— 全屏放映 + 演讲者视图(切换动画/计时器/备注/下一页预览)
2
-
3
- import { transitionOf } from '../../../src/kernel/model.js';
4
- import { renderPage } from './page-view.js';
5
- import { icon } from './icons.js';
6
- import { animateSlideFrame } from './transition.js';
7
- import { notify } from './notify.js';
8
-
9
- export class Present {
10
- constructor(app) {
11
- this.app = app;
12
- this.el = null;
13
- this.fs = false;
14
- this.pos = 0;
15
- this.black = false;
16
- this.white = false;
17
- this.presenter = false;
18
- this.timer = null;
19
- this.startedAt = 0;
20
- this.controlsTimer = 0;
21
- this.onKey = (e) => this.handleKey(e);
22
- this.onResize = () => { if (this.el) this.render(true); };
23
- this.onFsChange = () => {
24
- if (this.el && this.fs && !document.fullscreenElement) this.close();
25
- };
26
- }
27
-
28
- get slides() {
29
- return this.app.snapshot.slides.filter((s) => !s.hidden);
30
- }
31
-
32
- get current() {
33
- return this.slides[this.pos] || null;
34
- }
35
-
36
- open(startIndex = 0) {
37
- const slides = this.slides;
38
- if (!slides.length) {
39
- notify.warning('没有可放映的幻灯片(可能全部被隐藏)');
40
- return;
41
- }
42
- this.close();
43
- this.presenter = !!this.app.presentOptions.presenter;
44
- const visibleIndex = Math.max(0, slides.findIndex((s) => this.app.snapshot.slides.indexOf(s) >= startIndex));
45
- this.pos = visibleIndex >= 0 ? visibleIndex : 0;
46
- this.startedAt = Date.now();
47
- const overlay = document.createElement('div');
48
- overlay.className = 'pp-show';
49
- overlay.tabIndex = 0;
50
- this.el = overlay;
51
- document.body.appendChild(overlay);
52
- this.bind();
53
- this.render(true);
54
- document.addEventListener('keydown', this.onKey, true);
55
- document.addEventListener('fullscreenchange', this.onFsChange);
56
- window.addEventListener('resize', this.onResize);
57
- this.timer = setInterval(() => this.tick(), 1000);
58
- const req = overlay.requestFullscreen?.({ navigationUI: 'hide' });
59
- if (req?.then) req.then(() => { this.fs = true; }).catch(() => { this.fs = false; });
60
- else this.fs = false;
61
- overlay.focus();
62
- this.hideControlsSoon();
63
- }
64
-
65
- bind() {
66
- const el = this.el;
67
- el.addEventListener('click', (e) => {
68
- if (e.target.closest('.pp-show__bar, .pp-show__side')) return;
69
- this.next();
70
- });
71
- el.addEventListener('contextmenu', (e) => {
72
- e.preventDefault();
73
- this.prev();
74
- });
75
- el.addEventListener('mousemove', () => this.showControls());
76
- }
77
-
78
- render(initial = false) {
79
- if (!this.el) return;
80
- const slide = this.current;
81
- if (!slide) return this.close();
82
- const size = this.app.size;
83
- const theme = this.app.snapshot.theme;
84
- this.el.classList.toggle('pp-show--presenter', this.presenter);
85
- this.el.classList.toggle('is-black', this.black);
86
- this.el.classList.toggle('is-white', this.white);
87
- this.el.replaceChildren();
88
- this.el.style.setProperty('--show-bg', this.black ? '#000' : this.white ? '#fff' : '#111');
89
-
90
- const stage = document.createElement('div');
91
- stage.className = 'pp-show__stage';
92
- const page = renderPage(slide, theme, { size });
93
- const fit = this.fitScale(size);
94
- page.style.transform = `scale(${fit})`;
95
- page.style.transformOrigin = '0 0';
96
- const frame = document.createElement('div');
97
- frame.className = 'pp-show__frame';
98
- frame.style.width = `${size.w * fit}px`;
99
- frame.style.height = `${size.h * fit}px`;
100
- frame.appendChild(page);
101
- stage.appendChild(frame);
102
- this.el.appendChild(stage);
103
-
104
- if (this.presenter) this.renderPresenter();
105
-
106
- const bar = this.renderBar();
107
- this.el.appendChild(bar);
108
-
109
- if (!initial) animateSlideFrame(page.parentElement, transitionOf(slide));
110
- this.showControls();
111
- this.updateSide();
112
- }
113
-
114
- fitScale(size) {
115
- const w = this.el.clientWidth || window.innerWidth;
116
- const h = this.el.clientHeight || window.innerHeight;
117
- if (this.presenter) return Math.min((w * 0.66) / size.w, (h - 40) / size.h, 1.35);
118
- return Math.min((w - 40) / size.w, (h - 40) / size.h);
119
- }
120
-
121
- renderBar() {
122
- const bar = document.createElement('div');
123
- bar.className = 'pp-show__bar';
124
- const prev = this.iconBtn('chevronLeft', '上一页', () => this.prev());
125
- const next = this.iconBtn('chevronRight', '下一页', () => this.next());
126
- const mode = this.iconBtn(this.presenter ? 'presenter' : 'monitor', this.presenter ? '演讲者视图' : '放映视图', () => this.togglePresenter());
127
- const black = this.iconBtn('eye', '黑屏 (B)', () => this.toggleBlack());
128
- const quit = this.iconBtn('close', '结束放映 (Esc)', () => this.close());
129
- const info = document.createElement('span');
130
- info.className = 'pp-show__count';
131
- info.textContent = `${this.pos + 1} / ${this.slides.length}`;
132
- bar.append(prev, info, next, mode, black, quit);
133
- return bar;
134
- }
135
-
136
- iconBtn(name, title, onClick) {
137
- const b = document.createElement('button');
138
- b.type = 'button';
139
- b.className = 'pp-show__btn';
140
- b.title = title;
141
- b.innerHTML = icon(name, 18);
142
- b.addEventListener('click', (e) => { e.stopPropagation(); onClick(); });
143
- return b;
144
- }
145
-
146
- renderPresenter() {
147
- const side = document.createElement('div');
148
- side.className = 'pp-show__side';
149
- const timer = document.createElement('div');
150
- timer.className = 'pp-show__timer';
151
- timer.dataset.k = 'timer';
152
- timer.textContent = '00:00';
153
- const next = document.createElement('div');
154
- next.className = 'pp-show__next';
155
- const nextLabel = document.createElement('div');
156
- nextLabel.className = 'pp-show__side-label';
157
- nextLabel.textContent = '下一页';
158
- next.appendChild(nextLabel);
159
- const nextSlide = this.slides[this.pos + 1];
160
- if (nextSlide) {
161
- const size = this.app.size;
162
- const preview = renderPage(nextSlide, this.app.snapshot.theme, { size });
163
- const scale = Math.min(260 / size.w, 160 / size.h);
164
- preview.style.transform = `scale(${scale})`;
165
- preview.style.transformOrigin = 'top left';
166
- const box = document.createElement('div');
167
- box.className = 'pp-show__nextbox';
168
- box.style.width = `${size.w * scale}px`;
169
- box.style.height = `${size.h * scale}px`;
170
- box.appendChild(preview);
171
- next.appendChild(box);
172
- } else {
173
- const end = document.createElement('div');
174
- end.className = 'pp-show__end';
175
- end.textContent = '演示结束';
176
- next.appendChild(end);
177
- }
178
- const notesLabel = document.createElement('div');
179
- notesLabel.className = 'pp-show__side-label';
180
- notesLabel.textContent = '备注';
181
- const notes = document.createElement('div');
182
- notes.className = 'pp-show__notes';
183
- notes.textContent = this.current?.notes || '(本页没有备注)';
184
- side.append(timer, next, notesLabel, notes);
185
- this.el.appendChild(side);
186
- }
187
-
188
- updateSide() {
189
- const timer = this.el?.querySelector('[data-k="timer"]');
190
- if (timer) timer.textContent = this.elapsed();
191
- }
192
-
193
- tick() {
194
- if (!this.el) return;
195
- if (this.presenter) this.updateSide();
196
- }
197
-
198
- elapsed() {
199
- const secs = Math.max(0, Math.floor((Date.now() - this.startedAt) / 1000));
200
- return `${String(Math.floor(secs / 60)).padStart(2, '0')}:${String(secs % 60).padStart(2, '0')}`;
201
- }
202
-
203
- next() {
204
- if (this.black || this.white) { this.black = false; this.white = false; this.render(); return; }
205
- if (this.pos < this.slides.length - 1) {
206
- this.pos += 1;
207
- } else if (this.app.presentOptions.loop) {
208
- this.pos = 0;
209
- } else {
210
- return;
211
- }
212
- this.render();
213
- }
214
-
215
- prev() {
216
- if (this.black || this.white) { this.black = false; this.white = false; this.render(); return; }
217
- if (this.pos > 0) this.pos -= 1;
218
- else if (this.app.presentOptions.loop) this.pos = this.slides.length - 1;
219
- else return;
220
- this.render();
221
- }
222
-
223
- toggleBlack() {
224
- this.black = !this.black;
225
- this.white = false;
226
- this.render();
227
- }
228
-
229
- toggleWhite() {
230
- this.white = !this.white;
231
- this.black = false;
232
- this.render();
233
- }
234
-
235
- togglePresenter() {
236
- this.presenter = !this.presenter;
237
- this.app.presentOptions.presenter = this.presenter;
238
- this.app.ribbon?.refresh();
239
- this.render();
240
- }
241
-
242
- showControls() {
243
- if (!this.el) return;
244
- this.el.classList.remove('is-idle');
245
- clearTimeout(this.controlsTimer);
246
- this.hideControlsSoon();
247
- }
248
-
249
- hideControlsSoon() {
250
- clearTimeout(this.controlsTimer);
251
- this.controlsTimer = setTimeout(() => {
252
- if (this.el && !this.el.matches(':hover')) this.el.classList.add('is-idle');
253
- }, 2800);
254
- }
255
-
256
- handleKey(e) {
257
- if (!this.el) return;
258
- const k = e.key;
259
- if (k === 'Escape') { e.preventDefault(); this.close(); return; }
260
- if (k === 'ArrowRight' || k === ' ' || k === 'PageDown' || k === 'Enter' || k === 'ArrowDown') {
261
- e.preventDefault();
262
- this.next();
263
- return;
264
- }
265
- if (k === 'ArrowLeft' || k === 'PageUp' || k === 'ArrowUp' || k === 'Backspace') {
266
- e.preventDefault();
267
- this.prev();
268
- return;
269
- }
270
- if (k === 'Home') { e.preventDefault(); this.pos = 0; this.render(); return; }
271
- if (k === 'End') { e.preventDefault(); this.pos = Math.max(0, this.slides.length - 1); this.render(); return; }
272
- if (k === 'b' || k === 'B' || k === '.') { e.preventDefault(); this.toggleBlack(); return; }
273
- if (k === 'w' || k === 'W' || k === ',') { e.preventDefault(); this.toggleWhite(); return; }
274
- if (k === 's' || k === 'S') { e.preventDefault(); this.togglePresenter(); }
275
- }
276
-
277
- close() {
278
- if (!this.el) return;
279
- clearInterval(this.timer);
280
- clearTimeout(this.controlsTimer);
281
- document.removeEventListener('keydown', this.onKey, true);
282
- document.removeEventListener('fullscreenchange', this.onFsChange);
283
- window.removeEventListener('resize', this.onResize);
284
- this.el.remove();
285
- this.el = null;
286
- if (document.fullscreenElement) document.exitFullscreen?.().catch(() => {});
287
- this.fs = false;
288
- this.black = false;
289
- this.white = false;
290
- this.app.ribbon?.refresh();
291
- }
292
- }
1
+ // [文件] gbpptx·放映 —— 全屏放映 + 演讲者视图(切换动画/计时器/备注/下一页预览)
2
+
3
+ import { transitionOf } from '../../../src/kernel/model.js';
4
+ import { renderPage } from './page-view.js';
5
+ import { icon } from './icons.js';
6
+ import { animateSlideFrame } from './transition.js';
7
+ import { notify } from './notify.js';
8
+
9
+ export class Present {
10
+ constructor(app) {
11
+ this.app = app;
12
+ this.el = null;
13
+ this.fs = false;
14
+ this.pos = 0;
15
+ this.black = false;
16
+ this.white = false;
17
+ this.presenter = false;
18
+ this.timer = null;
19
+ this.startedAt = 0;
20
+ this.controlsTimer = 0;
21
+ this.onKey = (e) => this.handleKey(e);
22
+ this.onResize = () => { if (this.el) this.render(true); };
23
+ this.onFsChange = () => {
24
+ if (this.el && this.fs && !document.fullscreenElement) this.close();
25
+ };
26
+ }
27
+
28
+ get slides() {
29
+ return this.app.snapshot.slides.filter((s) => !s.hidden);
30
+ }
31
+
32
+ get current() {
33
+ return this.slides[this.pos] || null;
34
+ }
35
+
36
+ open(startIndex = 0) {
37
+ const slides = this.slides;
38
+ if (!slides.length) {
39
+ notify.warning('没有可放映的幻灯片(可能全部被隐藏)');
40
+ return;
41
+ }
42
+ this.close();
43
+ this.presenter = !!this.app.presentOptions.presenter;
44
+ const visibleIndex = Math.max(0, slides.findIndex((s) => this.app.snapshot.slides.indexOf(s) >= startIndex));
45
+ this.pos = visibleIndex >= 0 ? visibleIndex : 0;
46
+ this.startedAt = Date.now();
47
+ const overlay = document.createElement('div');
48
+ overlay.className = 'pp-show';
49
+ overlay.tabIndex = 0;
50
+ this.el = overlay;
51
+ document.body.appendChild(overlay);
52
+ this.bind();
53
+ this.render(true);
54
+ document.addEventListener('keydown', this.onKey, true);
55
+ document.addEventListener('fullscreenchange', this.onFsChange);
56
+ window.addEventListener('resize', this.onResize);
57
+ this.timer = setInterval(() => this.tick(), 1000);
58
+ const req = overlay.requestFullscreen?.({ navigationUI: 'hide' });
59
+ if (req?.then) req.then(() => { this.fs = true; }).catch(() => { this.fs = false; });
60
+ else this.fs = false;
61
+ overlay.focus();
62
+ this.hideControlsSoon();
63
+ }
64
+
65
+ bind() {
66
+ const el = this.el;
67
+ el.addEventListener('click', (e) => {
68
+ if (e.target.closest('.pp-show__bar, .pp-show__side')) return;
69
+ this.next();
70
+ });
71
+ el.addEventListener('contextmenu', (e) => {
72
+ e.preventDefault();
73
+ this.prev();
74
+ });
75
+ el.addEventListener('mousemove', () => this.showControls());
76
+ }
77
+
78
+ render(initial = false) {
79
+ if (!this.el) return;
80
+ const slide = this.current;
81
+ if (!slide) return this.close();
82
+ const size = this.app.size;
83
+ const theme = this.app.snapshot.theme;
84
+ this.el.classList.toggle('pp-show--presenter', this.presenter);
85
+ this.el.classList.toggle('gbp-is-black', this.black);
86
+ this.el.classList.toggle('gbp-is-white', this.white);
87
+ this.el.replaceChildren();
88
+ this.el.style.setProperty('--gbp-show-bg', this.black ? '#000' : this.white ? '#fff' : '#111');
89
+
90
+ const stage = document.createElement('div');
91
+ stage.className = 'pp-show__stage';
92
+ const page = renderPage(slide, theme, { size });
93
+ const fit = this.fitScale(size);
94
+ page.style.transform = `scale(${fit})`;
95
+ page.style.transformOrigin = '0 0';
96
+ const frame = document.createElement('div');
97
+ frame.className = 'pp-show__frame';
98
+ frame.style.width = `${size.w * fit}px`;
99
+ frame.style.height = `${size.h * fit}px`;
100
+ frame.appendChild(page);
101
+ stage.appendChild(frame);
102
+ this.el.appendChild(stage);
103
+
104
+ if (this.presenter) this.renderPresenter();
105
+
106
+ const bar = this.renderBar();
107
+ this.el.appendChild(bar);
108
+
109
+ if (!initial) animateSlideFrame(page.parentElement, transitionOf(slide));
110
+ this.showControls();
111
+ this.updateSide();
112
+ }
113
+
114
+ fitScale(size) {
115
+ const w = this.el.clientWidth || window.innerWidth;
116
+ const h = this.el.clientHeight || window.innerHeight;
117
+ if (this.presenter) return Math.min((w * 0.66) / size.w, (h - 40) / size.h, 1.35);
118
+ return Math.min((w - 40) / size.w, (h - 40) / size.h);
119
+ }
120
+
121
+ renderBar() {
122
+ const bar = document.createElement('div');
123
+ bar.className = 'pp-show__bar';
124
+ const prev = this.iconBtn('chevronLeft', '上一页', () => this.prev());
125
+ const next = this.iconBtn('chevronRight', '下一页', () => this.next());
126
+ const mode = this.iconBtn(this.presenter ? 'presenter' : 'monitor', this.presenter ? '演讲者视图' : '放映视图', () => this.togglePresenter());
127
+ const black = this.iconBtn('eye', '黑屏 (B)', () => this.toggleBlack());
128
+ const quit = this.iconBtn('close', '结束放映 (Esc)', () => this.close());
129
+ const info = document.createElement('span');
130
+ info.className = 'pp-show__count';
131
+ info.textContent = `${this.pos + 1} / ${this.slides.length}`;
132
+ bar.append(prev, info, next, mode, black, quit);
133
+ return bar;
134
+ }
135
+
136
+ iconBtn(name, title, onClick) {
137
+ const b = document.createElement('button');
138
+ b.type = 'button';
139
+ b.className = 'pp-show__btn';
140
+ b.title = title;
141
+ b.innerHTML = icon(name, 18);
142
+ b.addEventListener('click', (e) => { e.stopPropagation(); onClick(); });
143
+ return b;
144
+ }
145
+
146
+ renderPresenter() {
147
+ const side = document.createElement('div');
148
+ side.className = 'pp-show__side';
149
+ const timer = document.createElement('div');
150
+ timer.className = 'pp-show__timer';
151
+ timer.dataset.k = 'timer';
152
+ timer.textContent = '00:00';
153
+ const next = document.createElement('div');
154
+ next.className = 'pp-show__next';
155
+ const nextLabel = document.createElement('div');
156
+ nextLabel.className = 'pp-show__side-label';
157
+ nextLabel.textContent = '下一页';
158
+ next.appendChild(nextLabel);
159
+ const nextSlide = this.slides[this.pos + 1];
160
+ if (nextSlide) {
161
+ const size = this.app.size;
162
+ const preview = renderPage(nextSlide, this.app.snapshot.theme, { size });
163
+ const scale = Math.min(260 / size.w, 160 / size.h);
164
+ preview.style.transform = `scale(${scale})`;
165
+ preview.style.transformOrigin = 'top left';
166
+ const box = document.createElement('div');
167
+ box.className = 'pp-show__nextbox';
168
+ box.style.width = `${size.w * scale}px`;
169
+ box.style.height = `${size.h * scale}px`;
170
+ box.appendChild(preview);
171
+ next.appendChild(box);
172
+ } else {
173
+ const end = document.createElement('div');
174
+ end.className = 'pp-show__end';
175
+ end.textContent = '演示结束';
176
+ next.appendChild(end);
177
+ }
178
+ const notesLabel = document.createElement('div');
179
+ notesLabel.className = 'pp-show__side-label';
180
+ notesLabel.textContent = '备注';
181
+ const notes = document.createElement('div');
182
+ notes.className = 'pp-show__notes';
183
+ notes.textContent = this.current?.notes || '(本页没有备注)';
184
+ side.append(timer, next, notesLabel, notes);
185
+ this.el.appendChild(side);
186
+ }
187
+
188
+ updateSide() {
189
+ const timer = this.el?.querySelector('[data-k="timer"]');
190
+ if (timer) timer.textContent = this.elapsed();
191
+ }
192
+
193
+ tick() {
194
+ if (!this.el) return;
195
+ if (this.presenter) this.updateSide();
196
+ }
197
+
198
+ elapsed() {
199
+ const secs = Math.max(0, Math.floor((Date.now() - this.startedAt) / 1000));
200
+ return `${String(Math.floor(secs / 60)).padStart(2, '0')}:${String(secs % 60).padStart(2, '0')}`;
201
+ }
202
+
203
+ next() {
204
+ if (this.black || this.white) { this.black = false; this.white = false; this.render(); return; }
205
+ if (this.pos < this.slides.length - 1) {
206
+ this.pos += 1;
207
+ } else if (this.app.presentOptions.loop) {
208
+ this.pos = 0;
209
+ } else {
210
+ return;
211
+ }
212
+ this.render();
213
+ }
214
+
215
+ prev() {
216
+ if (this.black || this.white) { this.black = false; this.white = false; this.render(); return; }
217
+ if (this.pos > 0) this.pos -= 1;
218
+ else if (this.app.presentOptions.loop) this.pos = this.slides.length - 1;
219
+ else return;
220
+ this.render();
221
+ }
222
+
223
+ toggleBlack() {
224
+ this.black = !this.black;
225
+ this.white = false;
226
+ this.render();
227
+ }
228
+
229
+ toggleWhite() {
230
+ this.white = !this.white;
231
+ this.black = false;
232
+ this.render();
233
+ }
234
+
235
+ togglePresenter() {
236
+ this.presenter = !this.presenter;
237
+ this.app.presentOptions.presenter = this.presenter;
238
+ this.app.ribbon?.refresh();
239
+ this.render();
240
+ }
241
+
242
+ showControls() {
243
+ if (!this.el) return;
244
+ this.el.classList.remove('gbp-is-idle');
245
+ clearTimeout(this.controlsTimer);
246
+ this.hideControlsSoon();
247
+ }
248
+
249
+ hideControlsSoon() {
250
+ clearTimeout(this.controlsTimer);
251
+ this.controlsTimer = setTimeout(() => {
252
+ if (this.el && !this.el.matches(':hover')) this.el.classList.add('gbp-is-idle');
253
+ }, 2800);
254
+ }
255
+
256
+ handleKey(e) {
257
+ if (!this.el) return;
258
+ const k = e.key;
259
+ if (k === 'Escape') { e.preventDefault(); this.close(); return; }
260
+ if (k === 'ArrowRight' || k === ' ' || k === 'PageDown' || k === 'Enter' || k === 'ArrowDown') {
261
+ e.preventDefault();
262
+ this.next();
263
+ return;
264
+ }
265
+ if (k === 'ArrowLeft' || k === 'PageUp' || k === 'ArrowUp' || k === 'Backspace') {
266
+ e.preventDefault();
267
+ this.prev();
268
+ return;
269
+ }
270
+ if (k === 'Home') { e.preventDefault(); this.pos = 0; this.render(); return; }
271
+ if (k === 'End') { e.preventDefault(); this.pos = Math.max(0, this.slides.length - 1); this.render(); return; }
272
+ if (k === 'b' || k === 'B' || k === '.') { e.preventDefault(); this.toggleBlack(); return; }
273
+ if (k === 'w' || k === 'W' || k === ',') { e.preventDefault(); this.toggleWhite(); return; }
274
+ if (k === 's' || k === 'S') { e.preventDefault(); this.togglePresenter(); }
275
+ }
276
+
277
+ close() {
278
+ if (!this.el) return;
279
+ clearInterval(this.timer);
280
+ clearTimeout(this.controlsTimer);
281
+ document.removeEventListener('keydown', this.onKey, true);
282
+ document.removeEventListener('fullscreenchange', this.onFsChange);
283
+ window.removeEventListener('resize', this.onResize);
284
+ this.el.remove();
285
+ this.el = null;
286
+ if (document.fullscreenElement) document.exitFullscreen?.().catch(() => {});
287
+ this.fs = false;
288
+ this.black = false;
289
+ this.white = false;
290
+ this.app.ribbon?.refresh();
291
+ }
292
+ }