gbpptx 0.6.1 → 0.6.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.
Files changed (50) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +253 -253
  3. package/package.json +48 -47
  4. package/src/index.js +29 -29
  5. package/src/kernel/model.js +651 -651
  6. package/src/kernel/parts.js +173 -173
  7. package/src/kernel/pptx.js +72 -72
  8. package/src/kernel/print.js +76 -76
  9. package/src/kernel/read.js +1018 -1018
  10. package/src/kernel/roundtrip.js +174 -174
  11. package/src/kernel/text.js +278 -278
  12. package/src/kernel/write.js +385 -385
  13. package/web/app/main.js +8 -8
  14. package/web/app/slides/arrange.js +101 -101
  15. package/web/app/slides/clipboard.js +93 -93
  16. package/web/app/slides/file.js +240 -240
  17. package/web/app/slides/find.js +201 -201
  18. package/web/app/slides/history.js +100 -100
  19. package/web/app/slides/keys.js +187 -187
  20. package/web/app/slides/menus.js +105 -105
  21. package/web/app/slides/objects.js +254 -254
  22. package/web/app/slides/render.js +183 -183
  23. package/web/app/slides/shared.js +85 -85
  24. package/web/app/slides/slides.js +103 -103
  25. package/web/app/slides/table.js +102 -102
  26. package/web/app/slides/text.js +418 -418
  27. package/web/app/slides/view.js +182 -182
  28. package/web/app/slides-app.js +354 -354
  29. package/web/app/ui/canvas.js +769 -769
  30. package/web/app/ui/color-panel.js +58 -58
  31. package/web/app/ui/dialogs.js +120 -120
  32. package/web/app/ui/file-io.js +116 -116
  33. package/web/app/ui/format-pane.js +427 -427
  34. package/web/app/ui/icons.js +241 -133
  35. package/web/app/ui/menu.js +77 -75
  36. package/web/app/ui/notify.js +45 -45
  37. package/web/app/ui/page-view.js +221 -221
  38. package/web/app/ui/popup.js +80 -80
  39. package/web/app/ui/present.js +292 -292
  40. package/web/app/ui/ribbon.js +855 -855
  41. package/web/app/ui/slide-pane.js +197 -197
  42. package/web/app/ui/statusbar.js +93 -93
  43. package/web/app/ui/text-styles.js +84 -84
  44. package/web/app/ui/titlebar.js +253 -253
  45. package/web/app/ui/transition.js +30 -30
  46. package/web/index.html +30 -29
  47. package/web/serve.mjs +26 -23
  48. package/web/styles/office.css +463 -463
  49. package/web/styles/slides.css +97 -97
  50. package/web/styles/tokens.css +154 -154
@@ -1,182 +1,182 @@
1
- // [文件] gbpptx·slides·view —— 视图与放映 —— 缩放/网格/参考线/窗格/放映
2
-
3
- // [设计] 方法以独立函数导出,由 slides-app.js 末尾 Object.assign 装配到 SlidesApp.prototype:
4
- // 仍是同一个 this(方法调用时绑定),调用方形状与拆分前完全一致。
5
-
6
- import { clamp } from 'guabiutils';
7
- import { savePrefs, ZOOM_MIN, ZOOM_MAX } from './shared.js';
8
-
9
- /** 预览模式:只读 + 阅读视图 + 收起菜单/功能窗格;同一按钮或 Esc 退出并恢复原视图 */
10
- function setPreview(on) {
11
- const next = !!on;
12
- if (next === this.preview) return;
13
- if (next) {
14
- this.previewRestore = { readOnly: this.readOnly, menuBar: this.menuBarVisible, view: this.view };
15
- this.preview = true;
16
- this.root.classList.add('gbp-is-preview');
17
- this.titlebar.setPreview(true);
18
- this.commitEditing({ render: false });
19
- this.setView('reading');
20
- this.setReadOnly(true);
21
- this.setMenuBarVisible(false);
22
- } else {
23
- const restore = this.previewRestore || { readOnly: false, menuBar: true, view: 'normal' };
24
- this.preview = false;
25
- this.root.classList.remove('gbp-is-preview');
26
- this.titlebar.setPreview(false);
27
- this.setView(restore.view);
28
- this.setReadOnly(restore.readOnly);
29
- this.setMenuBarVisible(restore.menuBar);
30
- this.previewRestore = null;
31
- }
32
- }
33
-
34
- function setView(view) {
35
- if (!['normal', 'sorter', 'reading'].includes(view)) return;
36
- this.commitEditing({ render: false });
37
- this.view = view;
38
- if (view !== 'normal') {
39
- this.selectedIds = [];
40
- this.findEl && (this.findEl.hidden = true);
41
- }
42
- this.updateLayout();
43
- this.renderAll();
44
- this.statusbar.refresh();
45
- this.ribbon.refresh();
46
- }
47
-
48
- function setZoom(z, opts = {}) {
49
- this.zoom = clamp(Math.round(Number(z) || 100), ZOOM_MIN, ZOOM_MAX);
50
- this.prefs.zoom = this.zoom;
51
- savePrefs(this.prefs);
52
- if (this.view === 'normal') this.canvas.rescale();
53
- else if (this.view === 'sorter') this.renderSorter();
54
- else this.renderReading();
55
- this.statusbar.refresh();
56
- if (!opts.fromSlider) this.statusbar.slider.value = String(this.zoom);
57
- }
58
-
59
- function fitToWindow() {
60
- if (this.view !== 'normal') return;
61
- const w = Math.max(200, this.canvas.scroll.clientWidth - 72);
62
- const h = Math.max(150, this.canvas.scroll.clientHeight - 72);
63
- const size = this.size;
64
- this.setZoom(Math.min(w / size.w, h / size.h) * 100);
65
- }
66
-
67
- function toggleNotes() {
68
- this.commitEditing({ render: false });
69
- this.notesVisible = !this.notesVisible;
70
- this.prefs.notesVisible = this.notesVisible;
71
- savePrefs(this.prefs);
72
- this.updateLayout();
73
- this.renderNotes();
74
- this.ribbon.refresh();
75
- this.statusbar.refresh();
76
- }
77
-
78
- function toggleGrid() {
79
- this.commitEditing({ render: false });
80
- this.gridVisible = !this.gridVisible;
81
- this.prefs.grid = this.gridVisible;
82
- savePrefs(this.prefs);
83
- if (this.view === 'normal') this.canvas.render();
84
- this.ribbon.refresh();
85
- }
86
-
87
- function toggleGuides() {
88
- this.commitEditing({ render: false });
89
- this.guidesVisible = !this.guidesVisible;
90
- this.prefs.guides = this.guidesVisible;
91
- savePrefs(this.prefs);
92
- if (this.view === 'normal') this.canvas.render();
93
- this.ribbon.refresh();
94
- }
95
-
96
- function setRibbonCollapsed(on) {
97
- this.ribbonCollapsed = !!on;
98
- this.prefs.ribbonCollapsed = this.ribbonCollapsed;
99
- savePrefs(this.prefs);
100
- this.ribbon.setCollapsed(this.ribbonCollapsed);
101
- }
102
-
103
- function toggleFormatPane() {
104
- if (this.formatPaneOpen && this.view === 'normal') {
105
- this.formatPaneOpen = false;
106
- this.formatPane.close();
107
- } else {
108
- this.openFormatPane();
109
- return;
110
- }
111
- this.prefs.formatPaneOpen = this.formatPaneOpen;
112
- savePrefs(this.prefs);
113
- this.updateLayout();
114
- this.ribbon.refresh();
115
- }
116
-
117
- function openFormatPane() {
118
- if (this.view !== 'normal') this.setView('normal');
119
- this.formatPaneOpen = true;
120
- this.prefs.formatPaneOpen = true;
121
- savePrefs(this.prefs);
122
- this.updateLayout();
123
- this.formatPane.open();
124
- this.ribbon.refresh();
125
- }
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
-
153
- function togglePresenter() {
154
- this.presentOptions.presenter = !this.presentOptions.presenter;
155
- this.prefs.presenter = this.presentOptions.presenter;
156
- savePrefs(this.prefs);
157
- this.ribbon.refresh();
158
- }
159
-
160
- function toggleLoop() {
161
- this.presentOptions.loop = !this.presentOptions.loop;
162
- this.prefs.loop = this.presentOptions.loop;
163
- savePrefs(this.prefs);
164
- this.ribbon.refresh();
165
- }
166
-
167
- function presentFromStart() {
168
- this.commitEditing({ render: false });
169
- this.presenter.open(0);
170
- }
171
-
172
- function presentFromCurrent() {
173
- this.commitEditing({ render: false });
174
- this.presenter.open(this.index);
175
- }
176
-
177
- function presentAt(index) {
178
- this.commitEditing({ render: false });
179
- this.presenter.open(Number(index) || 0);
180
- }
181
-
182
- export const viewMethods = { setView, setZoom, fitToWindow, toggleNotes, toggleGrid, toggleGuides, setRibbonCollapsed, toggleFormatPane, openFormatPane, togglePresenter, toggleLoop, presentFromStart, presentFromCurrent, presentAt, setPreview, toggleFullscreen, setPageFullscreen };
1
+ // [文件] gbpptx·slides·view —— 视图与放映 —— 缩放/网格/参考线/窗格/放映
2
+
3
+ // [设计] 方法以独立函数导出,由 slides-app.js 末尾 Object.assign 装配到 SlidesApp.prototype:
4
+ // 仍是同一个 this(方法调用时绑定),调用方形状与拆分前完全一致。
5
+
6
+ import { clamp } from 'guabiutils';
7
+ import { savePrefs, ZOOM_MIN, ZOOM_MAX } from './shared.js';
8
+
9
+ /** 预览模式:只读 + 阅读视图 + 收起菜单/功能窗格;同一按钮或 Esc 退出并恢复原视图 */
10
+ function setPreview(on) {
11
+ const next = !!on;
12
+ if (next === this.preview) return;
13
+ if (next) {
14
+ this.previewRestore = { readOnly: this.readOnly, menuBar: this.menuBarVisible, view: this.view };
15
+ this.preview = true;
16
+ this.root.classList.add('gbp-is-preview');
17
+ this.titlebar.setPreview(true);
18
+ this.commitEditing({ render: false });
19
+ this.setView('reading');
20
+ this.setReadOnly(true);
21
+ this.setMenuBarVisible(false);
22
+ } else {
23
+ const restore = this.previewRestore || { readOnly: false, menuBar: true, view: 'normal' };
24
+ this.preview = false;
25
+ this.root.classList.remove('gbp-is-preview');
26
+ this.titlebar.setPreview(false);
27
+ this.setView(restore.view);
28
+ this.setReadOnly(restore.readOnly);
29
+ this.setMenuBarVisible(restore.menuBar);
30
+ this.previewRestore = null;
31
+ }
32
+ }
33
+
34
+ function setView(view) {
35
+ if (!['normal', 'sorter', 'reading'].includes(view)) return;
36
+ this.commitEditing({ render: false });
37
+ this.view = view;
38
+ if (view !== 'normal') {
39
+ this.selectedIds = [];
40
+ this.findEl && (this.findEl.hidden = true);
41
+ }
42
+ this.updateLayout();
43
+ this.renderAll();
44
+ this.statusbar.refresh();
45
+ this.ribbon.refresh();
46
+ }
47
+
48
+ function setZoom(z, opts = {}) {
49
+ this.zoom = clamp(Math.round(Number(z) || 100), ZOOM_MIN, ZOOM_MAX);
50
+ this.prefs.zoom = this.zoom;
51
+ savePrefs(this.prefs);
52
+ if (this.view === 'normal') this.canvas.rescale();
53
+ else if (this.view === 'sorter') this.renderSorter();
54
+ else this.renderReading();
55
+ this.statusbar.refresh();
56
+ if (!opts.fromSlider) this.statusbar.slider.value = String(this.zoom);
57
+ }
58
+
59
+ function fitToWindow() {
60
+ if (this.view !== 'normal') return;
61
+ const w = Math.max(200, this.canvas.scroll.clientWidth - 72);
62
+ const h = Math.max(150, this.canvas.scroll.clientHeight - 72);
63
+ const size = this.size;
64
+ this.setZoom(Math.min(w / size.w, h / size.h) * 100);
65
+ }
66
+
67
+ function toggleNotes() {
68
+ this.commitEditing({ render: false });
69
+ this.notesVisible = !this.notesVisible;
70
+ this.prefs.notesVisible = this.notesVisible;
71
+ savePrefs(this.prefs);
72
+ this.updateLayout();
73
+ this.renderNotes();
74
+ this.ribbon.refresh();
75
+ this.statusbar.refresh();
76
+ }
77
+
78
+ function toggleGrid() {
79
+ this.commitEditing({ render: false });
80
+ this.gridVisible = !this.gridVisible;
81
+ this.prefs.grid = this.gridVisible;
82
+ savePrefs(this.prefs);
83
+ if (this.view === 'normal') this.canvas.render();
84
+ this.ribbon.refresh();
85
+ }
86
+
87
+ function toggleGuides() {
88
+ this.commitEditing({ render: false });
89
+ this.guidesVisible = !this.guidesVisible;
90
+ this.prefs.guides = this.guidesVisible;
91
+ savePrefs(this.prefs);
92
+ if (this.view === 'normal') this.canvas.render();
93
+ this.ribbon.refresh();
94
+ }
95
+
96
+ function setRibbonCollapsed(on) {
97
+ this.ribbonCollapsed = !!on;
98
+ this.prefs.ribbonCollapsed = this.ribbonCollapsed;
99
+ savePrefs(this.prefs);
100
+ this.ribbon.setCollapsed(this.ribbonCollapsed);
101
+ }
102
+
103
+ function toggleFormatPane() {
104
+ if (this.formatPaneOpen && this.view === 'normal') {
105
+ this.formatPaneOpen = false;
106
+ this.formatPane.close();
107
+ } else {
108
+ this.openFormatPane();
109
+ return;
110
+ }
111
+ this.prefs.formatPaneOpen = this.formatPaneOpen;
112
+ savePrefs(this.prefs);
113
+ this.updateLayout();
114
+ this.ribbon.refresh();
115
+ }
116
+
117
+ function openFormatPane() {
118
+ if (this.view !== 'normal') this.setView('normal');
119
+ this.formatPaneOpen = true;
120
+ this.prefs.formatPaneOpen = true;
121
+ savePrefs(this.prefs);
122
+ this.updateLayout();
123
+ this.formatPane.open();
124
+ this.ribbon.refresh();
125
+ }
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
+
153
+ function togglePresenter() {
154
+ this.presentOptions.presenter = !this.presentOptions.presenter;
155
+ this.prefs.presenter = this.presentOptions.presenter;
156
+ savePrefs(this.prefs);
157
+ this.ribbon.refresh();
158
+ }
159
+
160
+ function toggleLoop() {
161
+ this.presentOptions.loop = !this.presentOptions.loop;
162
+ this.prefs.loop = this.presentOptions.loop;
163
+ savePrefs(this.prefs);
164
+ this.ribbon.refresh();
165
+ }
166
+
167
+ function presentFromStart() {
168
+ this.commitEditing({ render: false });
169
+ this.presenter.open(0);
170
+ }
171
+
172
+ function presentFromCurrent() {
173
+ this.commitEditing({ render: false });
174
+ this.presenter.open(this.index);
175
+ }
176
+
177
+ function presentAt(index) {
178
+ this.commitEditing({ render: false });
179
+ this.presenter.open(Number(index) || 0);
180
+ }
181
+
182
+ export const viewMethods = { setView, setZoom, fitToWindow, toggleNotes, toggleGrid, toggleGuides, setRibbonCollapsed, toggleFormatPane, openFormatPane, togglePresenter, toggleLoop, presentFromStart, presentFromCurrent, presentAt, setPreview, toggleFullscreen, setPageFullscreen };