gbpptx 0.4.0 → 0.5.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.
- package/package.json +47 -47
- package/web/app/slides/view.js +2 -2
- package/web/app/slides-app.js +6 -3
- package/web/app/ui/ribbon.js +0 -13
- package/web/app/ui/titlebar.js +41 -7
- package/web/index.html +5 -1
- package/web/styles/office.css +5 -11
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "gbpptx",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Office-style PowerPoint (pptx) editor: real PresentationML read/write, ribbon UI, slide sorter, presenter view.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"sideEffects": false,
|
|
8
|
-
"main": "./src/index.js",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": "./src/index.js",
|
|
11
|
-
"./model": "./src/kernel/model.js",
|
|
12
|
-
"./pptx": "./src/kernel/pptx.js",
|
|
13
|
-
"./package.json": "./package.json",
|
|
14
|
-
"./web/*": "./web/*",
|
|
15
|
-
"./*": "./src/*.js"
|
|
16
|
-
},
|
|
17
|
-
"files": [
|
|
18
|
-
"src",
|
|
19
|
-
"web",
|
|
20
|
-
"LICENSE"
|
|
21
|
-
],
|
|
22
|
-
"keywords": [
|
|
23
|
-
"pptx",
|
|
24
|
-
"presentation",
|
|
25
|
-
"powerpoint",
|
|
26
|
-
"ooxml",
|
|
27
|
-
"slides",
|
|
28
|
-
"editor",
|
|
29
|
-
"office",
|
|
30
|
-
"ribbon"
|
|
31
|
-
],
|
|
32
|
-
"engines": {
|
|
33
|
-
"node": ">=18"
|
|
34
|
-
},
|
|
35
|
-
"scripts": {
|
|
36
|
-
"start": "node web/serve.mjs",
|
|
37
|
-
"test": "node --test test/roundtrip.test.js test/external-import.test.js test/ui-zoom.test.js test/mode.test.js"
|
|
38
|
-
},
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"gbooxml": "^0.1.0",
|
|
41
|
-
"gbofficeui": "^0.
|
|
42
|
-
"guabiutils": "^0.3.0"
|
|
43
|
-
},
|
|
44
|
-
"devDependencies": {
|
|
45
|
-
"jsdom": "^30.1.3"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "gbpptx",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Office-style PowerPoint (pptx) editor: real PresentationML read/write, ribbon UI, slide sorter, presenter view.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"main": "./src/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./src/index.js",
|
|
11
|
+
"./model": "./src/kernel/model.js",
|
|
12
|
+
"./pptx": "./src/kernel/pptx.js",
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
"./web/*": "./web/*",
|
|
15
|
+
"./*": "./src/*.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"src",
|
|
19
|
+
"web",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"pptx",
|
|
24
|
+
"presentation",
|
|
25
|
+
"powerpoint",
|
|
26
|
+
"ooxml",
|
|
27
|
+
"slides",
|
|
28
|
+
"editor",
|
|
29
|
+
"office",
|
|
30
|
+
"ribbon"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"start": "node web/serve.mjs",
|
|
37
|
+
"test": "node --test test/roundtrip.test.js test/external-import.test.js test/ui-zoom.test.js test/mode.test.js"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"gbooxml": "^0.1.0",
|
|
41
|
+
"gbofficeui": "^0.2.0",
|
|
42
|
+
"guabiutils": "^0.3.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"jsdom": "^30.1.3"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/web/app/slides/view.js
CHANGED
|
@@ -14,7 +14,7 @@ function setPreview(on) {
|
|
|
14
14
|
this.previewRestore = { readOnly: this.readOnly, menuBar: this.menuBarVisible, view: this.view };
|
|
15
15
|
this.preview = true;
|
|
16
16
|
this.root.classList.add('gbp-is-preview');
|
|
17
|
-
this.
|
|
17
|
+
this.titlebar.setPreview(true);
|
|
18
18
|
this.commitEditing({ render: false });
|
|
19
19
|
this.setView('reading');
|
|
20
20
|
this.setReadOnly(true);
|
|
@@ -23,7 +23,7 @@ function setPreview(on) {
|
|
|
23
23
|
const restore = this.previewRestore || { readOnly: false, menuBar: true, view: 'normal' };
|
|
24
24
|
this.preview = false;
|
|
25
25
|
this.root.classList.remove('gbp-is-preview');
|
|
26
|
-
this.
|
|
26
|
+
this.titlebar.setPreview(false);
|
|
27
27
|
this.setView(restore.view);
|
|
28
28
|
this.setReadOnly(restore.readOnly);
|
|
29
29
|
this.setMenuBarVisible(restore.menuBar);
|
package/web/app/slides-app.js
CHANGED
|
@@ -56,7 +56,7 @@ export class SlidesApp {
|
|
|
56
56
|
this.editing = null;
|
|
57
57
|
this.tableCursor = null;
|
|
58
58
|
this.notesSession = false;
|
|
59
|
-
this.autosave = !!prefs.autosave;
|
|
59
|
+
this.autosave = options.autoSave !== undefined ? !!options.autoSave : !!prefs.autosave;
|
|
60
60
|
this.notesVisible = prefs.notesVisible !== false;
|
|
61
61
|
this.gridVisible = !!prefs.grid;
|
|
62
62
|
this.guidesVisible = prefs.guides === true;
|
|
@@ -88,6 +88,7 @@ export class SlidesApp {
|
|
|
88
88
|
build() {
|
|
89
89
|
const root = el('div', 'pp-app');
|
|
90
90
|
root.innerHTML = `
|
|
91
|
+
<div class="pp-head-host"></div>
|
|
91
92
|
<div class="pp-topbar-host"></div>
|
|
92
93
|
<div class="pp-ribbon-host"></div>
|
|
93
94
|
<div class="pp-main">
|
|
@@ -108,6 +109,7 @@ export class SlidesApp {
|
|
|
108
109
|
this.mount.appendChild(root);
|
|
109
110
|
this.root = root;
|
|
110
111
|
this.topbarHost = root.querySelector('.pp-topbar-host');
|
|
112
|
+
this.headHost = root.querySelector('.pp-head-host');
|
|
111
113
|
this.ribbonHost = root.querySelector('.pp-ribbon-host');
|
|
112
114
|
this.formatPaneHost = root.querySelector('.pp-main__right');
|
|
113
115
|
this.left = root.querySelector('.pp-main__left');
|
|
@@ -125,6 +127,7 @@ export class SlidesApp {
|
|
|
125
127
|
this.statusbar = new StatusBar(this);
|
|
126
128
|
|
|
127
129
|
root.querySelector('.pp-topbar-host').appendChild(this.titlebar.el);
|
|
130
|
+
root.querySelector('.pp-head-host').appendChild(this.titlebar.headEl);
|
|
128
131
|
root.querySelector('.pp-ribbon-host').appendChild(this.ribbon.el);
|
|
129
132
|
this.left.appendChild(this.slidePane.el);
|
|
130
133
|
this.canvasHost.appendChild(this.canvas.el);
|
|
@@ -140,7 +143,7 @@ export class SlidesApp {
|
|
|
140
143
|
this.buildSorterEvents();
|
|
141
144
|
|
|
142
145
|
this.bindNotes(root.querySelector('[data-act="notes-close"]'));
|
|
143
|
-
// 只 inert
|
|
146
|
+
// 只 inert 功能区与各选项卡本身:文档头的预览按钮在 inert 之外,预览档里仍可点「退出预览」
|
|
144
147
|
this.guard = createReadOnlyGuard(root, {
|
|
145
148
|
editZones: () => [
|
|
146
149
|
this.ribbon.bodyEl,
|
|
@@ -158,7 +161,7 @@ export class SlidesApp {
|
|
|
158
161
|
if (this.readOnly) this.setReadOnly(true);
|
|
159
162
|
}
|
|
160
163
|
|
|
161
|
-
/**
|
|
164
|
+
/** 显示/隐藏顶部菜单栏那一行;文档头(标题/自动保存/保存/预览)不受影响 */
|
|
162
165
|
setMenuBarVisible(on) {
|
|
163
166
|
this.menuBarVisible = !!on;
|
|
164
167
|
this.topbarHost.style.display = this.menuBarVisible ? '' : 'none';
|
package/web/app/ui/ribbon.js
CHANGED
|
@@ -213,10 +213,6 @@ export class Ribbon {
|
|
|
213
213
|
this.tabsEl.appendChild(this.contextHost);
|
|
214
214
|
const spacer = el('div', 'pp-rb-tabs__spacer');
|
|
215
215
|
this.tabsEl.appendChild(spacer);
|
|
216
|
-
this.previewBtn = button('pp-rb-preview', `${icon('eye', 15)}<span>预览</span>`, '预览模式');
|
|
217
|
-
this.previewBtn.setAttribute('aria-pressed', 'false');
|
|
218
|
-
this.previewBtn.addEventListener('click', () => this.app.setPreview(!this.app.preview));
|
|
219
|
-
this.tabsEl.appendChild(this.previewBtn);
|
|
220
216
|
this.collapseBtn = button('pp-rb-collapse', icon('chevronDown', 14), '收起功能区');
|
|
221
217
|
this.collapseBtn.addEventListener('click', () => {
|
|
222
218
|
this.app.setRibbonCollapsed(!this.app.ribbonCollapsed);
|
|
@@ -224,15 +220,6 @@ export class Ribbon {
|
|
|
224
220
|
this.tabsEl.appendChild(this.collapseBtn);
|
|
225
221
|
}
|
|
226
222
|
|
|
227
|
-
/** 预览档按钮态:同一位置从「预览」切成「退出预览」 */
|
|
228
|
-
setPreview(on) {
|
|
229
|
-
const active = !!on;
|
|
230
|
-
this.previewBtn.classList.toggle('gbp-is-active', active);
|
|
231
|
-
this.previewBtn.title = active ? '退出预览' : '预览模式';
|
|
232
|
-
this.previewBtn.setAttribute('aria-pressed', String(active));
|
|
233
|
-
this.previewBtn.querySelector('span').textContent = active ? '退出预览' : '预览';
|
|
234
|
-
}
|
|
235
|
-
|
|
236
223
|
buildPanels() {
|
|
237
224
|
const builders = {
|
|
238
225
|
home: (p) => this.buildHome(p),
|
package/web/app/ui/titlebar.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [文件] gbpptx
|
|
1
|
+
// [文件] gbpptx·顶部菜单栏与文档头 —— 与 gbdocx / gbxlxs 一致:菜单栏一行 + 文档头一行(标题/自动保存/保存/预览)
|
|
2
2
|
|
|
3
3
|
import { SHAPE_KINDS, SLIDE_LAYOUTS, TRANSITIONS } from '../../../src/kernel/model.js';
|
|
4
4
|
import { icon } from './icons.js';
|
|
@@ -18,7 +18,9 @@ export class TitleBar {
|
|
|
18
18
|
constructor(app) {
|
|
19
19
|
this.app = app;
|
|
20
20
|
this.el = el('header', 'pp-topbar');
|
|
21
|
+
this.headEl = el('header', 'gbo-head pp-head');
|
|
21
22
|
this.build();
|
|
23
|
+
this.buildHead();
|
|
22
24
|
this.refresh();
|
|
23
25
|
}
|
|
24
26
|
|
|
@@ -43,17 +45,47 @@ export class TitleBar {
|
|
|
43
45
|
});
|
|
44
46
|
bar.appendChild(btn);
|
|
45
47
|
}
|
|
48
|
+
this.el.append(bar);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
buildHead() {
|
|
52
|
+
const title = el('span', 'gbo-head__title');
|
|
53
|
+
const state = el('span', 'gbo-head__sub');
|
|
54
|
+
const spacer = el('span', 'gbo-head__spacer');
|
|
46
55
|
|
|
47
|
-
const
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
56
|
+
const auto = el('label', 'gbo-head__auto');
|
|
57
|
+
this.autosaveEl = el('input', 'gbo-head__autosave');
|
|
58
|
+
this.autosaveEl.type = 'checkbox';
|
|
59
|
+
this.autosaveEl.addEventListener('change', () => this.app.setAutosave(this.autosaveEl.checked));
|
|
60
|
+
auto.append(this.autosaveEl, document.createTextNode('自动保存'));
|
|
61
|
+
|
|
62
|
+
this.saveBtn = el('button', 'gbo-head__btn gbo-head__btn--primary', '保存');
|
|
51
63
|
this.saveBtn.type = 'button';
|
|
52
64
|
this.saveBtn.title = '保存 (Ctrl+S)';
|
|
53
65
|
this.saveBtn.addEventListener('click', () => this.app.save());
|
|
54
|
-
info.append(this.nameEl, this.stateEl, this.saveBtn);
|
|
55
66
|
|
|
56
|
-
|
|
67
|
+
const actions = el('span', 'gbo-head__actions');
|
|
68
|
+
actions.append(auto, this.saveBtn);
|
|
69
|
+
|
|
70
|
+
this.previewBtn = el('button', 'gbo-head__btn gbo-head__preview', '预览');
|
|
71
|
+
this.previewBtn.type = 'button';
|
|
72
|
+
this.previewBtn.title = '预览模式';
|
|
73
|
+
this.previewBtn.setAttribute('aria-pressed', 'false');
|
|
74
|
+
this.previewBtn.innerHTML = `${icon('eye', 14)}<span>预览</span>`;
|
|
75
|
+
this.previewBtn.addEventListener('click', () => this.app.setPreview(!this.app.preview));
|
|
76
|
+
|
|
77
|
+
this.nameEl = title;
|
|
78
|
+
this.stateEl = state;
|
|
79
|
+
this.headEl.append(title, state, spacer, actions, this.previewBtn);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** 预览档按钮态:同一位置从「预览」切成「退出预览」 */
|
|
83
|
+
setPreview(on) {
|
|
84
|
+
const active = !!on;
|
|
85
|
+
this.previewBtn.classList.toggle('gbo-head__preview--on', active);
|
|
86
|
+
this.previewBtn.title = active ? '退出预览' : '预览模式';
|
|
87
|
+
this.previewBtn.setAttribute('aria-pressed', String(active));
|
|
88
|
+
this.previewBtn.querySelector('span').textContent = active ? '退出预览' : '预览';
|
|
57
89
|
}
|
|
58
90
|
|
|
59
91
|
/* ===================== 菜单条目 ===================== */
|
|
@@ -209,6 +241,8 @@ export class TitleBar {
|
|
|
209
241
|
: app.doc.handle ? '已保存' : (app.doc.savedAt ? '已保存副本' : '尚未保存');
|
|
210
242
|
this.stateEl.classList.toggle('gbp-is-dirty', app.dirty);
|
|
211
243
|
this.saveBtn.disabled = app.readOnly || !app.snapshot.slides.length;
|
|
244
|
+
this.autosaveEl.checked = app.autosave;
|
|
245
|
+
this.setPreview(app.preview);
|
|
212
246
|
// 只读档锁掉纯编辑类菜单,放映/视图与文件菜单里的导出/打印照常可用
|
|
213
247
|
const writeMenus = new Set(['edit', 'insert', 'slide', 'review']);
|
|
214
248
|
this.el.querySelectorAll('[data-menu]').forEach((btn) => {
|
package/web/index.html
CHANGED
|
@@ -6,8 +6,12 @@
|
|
|
6
6
|
<title>挂逼演示 gbpptx</title>
|
|
7
7
|
<link rel="stylesheet" href="/web/styles/tokens.css" />
|
|
8
8
|
<link rel="stylesheet" href="/web/styles/slides.css" />
|
|
9
|
-
<link rel="stylesheet" href="/web/styles/office.css" />
|
|
9
|
+
<link rel="stylesheet" href="/web/styles/office.css" />
|
|
10
10
|
<link rel="stylesheet" href="/vendor/gbofficeui/office-chrome.css" />
|
|
11
|
+
<style>
|
|
12
|
+
/* 独立运行时撑满视口;嵌入宿主由宿主容器给高度,不依赖这条 */
|
|
13
|
+
html, body { height: 100%; margin: 0; }
|
|
14
|
+
</style>
|
|
11
15
|
<script type="importmap">
|
|
12
16
|
{
|
|
13
17
|
"imports": {
|
package/web/styles/office.css
CHANGED
|
@@ -34,23 +34,17 @@
|
|
|
34
34
|
.pp-menubar__btn:disabled { opacity: .5; }
|
|
35
35
|
|
|
36
36
|
/* ==================== 预览模式 ==================== */
|
|
37
|
-
/*
|
|
37
|
+
/* 只留文档头(标题 + 退出预览)与阅读视图;菜单、功能区、缩略图/格式窗格、备注、状态栏全部收起 */
|
|
38
38
|
.pp-app.gbp-is-preview .pp-topbar-host,
|
|
39
|
+
.pp-app.gbp-is-preview .pp-ribbon-host,
|
|
40
|
+
.pp-app.gbp-is-preview .gbo-head__actions,
|
|
39
41
|
.pp-app.gbp-is-preview .pp-main__left,
|
|
40
42
|
.pp-app.gbp-is-preview .pp-main__right,
|
|
41
43
|
.pp-app.gbp-is-preview .pp-notes,
|
|
42
44
|
.pp-app.gbp-is-preview .pp-statusbar-host,
|
|
43
|
-
.pp-app.gbp-is-preview .pp-ribbon__body,
|
|
44
|
-
.pp-app.gbp-is-preview .pp-rb-tab,
|
|
45
|
-
.pp-app.gbp-is-preview .pp-rb-tabs__context,
|
|
46
|
-
.pp-app.gbp-is-preview .pp-rb-collapse,
|
|
47
45
|
.pp-app.gbp-is-preview .pp-reading__quit {
|
|
48
46
|
display: none;
|
|
49
47
|
}
|
|
50
|
-
/* 预览档本体也是只读档,但退出按钮不能被只读档的 55% 透明度压暗 */
|
|
51
|
-
.pp-app.gbp-is-preview .pp-ribbon-host {
|
|
52
|
-
opacity: 1;
|
|
53
|
-
}
|
|
54
48
|
|
|
55
49
|
/* ==================== 顶部菜单栏 ==================== */
|
|
56
50
|
/* 菜单栏 / 文档头 / Ribbon 的视觉由 gbofficeui/styles/office-chrome.css 统一,
|
|
@@ -71,7 +65,7 @@
|
|
|
71
65
|
.pp-menubar::-webkit-scrollbar {
|
|
72
66
|
display: none;
|
|
73
67
|
}
|
|
74
|
-
.pp-
|
|
68
|
+
.pp-head .gbo-head__sub.gbp-is-dirty {
|
|
75
69
|
color: var(--gbp-pp-accent);
|
|
76
70
|
}
|
|
77
71
|
|
|
@@ -360,7 +354,7 @@
|
|
|
360
354
|
|
|
361
355
|
.pp-reading {
|
|
362
356
|
position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
|
|
363
|
-
gap: 18px; background: #2b2b2b;
|
|
357
|
+
gap: 18px; background: #2b2b2b; overflow: hidden;
|
|
364
358
|
}
|
|
365
359
|
.pp-reading__stage { flex: none; overflow: hidden; box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5); background: #fff; }
|
|
366
360
|
.pp-reading__stage .sl-page { transform-origin: 0 0; }
|