gbpptx 0.2.0 → 0.3.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 +220 -214
  2. package/package.json +4 -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 +243 -0
  10. package/web/app/slides/find.js +199 -0
  11. package/web/app/slides/history.js +100 -0
  12. package/web/app/slides/keys.js +174 -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 +130 -0
  21. package/web/app/slides-app.js +285 -2446
  22. package/web/app/ui/backstage.js +255 -255
  23. package/web/app/ui/canvas.js +762 -755
  24. package/web/app/ui/color-panel.js +58 -76
  25. package/web/app/ui/dialogs.js +120 -159
  26. package/web/app/ui/file-io.js +116 -132
  27. package/web/app/ui/format-pane.js +427 -427
  28. package/web/app/ui/icons.js +129 -129
  29. package/web/app/ui/menu.js +75 -89
  30. package/web/app/ui/notify.js +45 -45
  31. package/web/app/ui/page-view.js +221 -221
  32. package/web/app/ui/popup.js +80 -80
  33. package/web/app/ui/present.js +292 -292
  34. package/web/app/ui/ribbon.js +878 -878
  35. package/web/app/ui/slide-pane.js +189 -189
  36. package/web/app/ui/statusbar.js +93 -93
  37. package/web/app/ui/text-styles.js +84 -84
  38. package/web/app/ui/titlebar.js +173 -66
  39. package/web/app/ui/transition.js +30 -30
  40. package/web/index.html +23 -22
  41. package/web/serve.mjs +20 -67
  42. package/web/styles/office.css +642 -644
  43. package/web/styles/slides.css +210 -219
  44. package/web/styles/tokens.css +154 -155
  45. package/src/kernel/util/escape.js +0 -21
  46. package/src/kernel/util/id.js +0 -13
@@ -1,84 +1,84 @@
1
- // [文件] web·core·文字样式常量 —— 字号/字体/调色板/对齐/字体效果/组合色的单一来源(富文本编辑器与演示文稿工具条共用,禁各域再建第二张表)
2
- // [通用:常量] textStyles —— FONT_SIZES / FONT_FAMILIES / TEXT_COLORS / BG_COLORS / ALIGN_OPTIONS / FONT_EFFECTS / COMBO_STYLES / RECENT_STYLE_LIMIT
3
-
4
- /** 字号预设(px,12~72) */
5
- export const FONT_SIZES = [12, 13, 14, 15, 16, 18, 20, 24, 28, 32, 36, 42, 48, 54, 62, 72];
6
-
7
- /** 字体(系统字体 + Web 安全字体;内网不回源加载,命中本机字体即生效) */
8
- export const FONT_FAMILIES = [
9
- { label: '微软雅黑', value: 'Microsoft YaHei, "微软雅黑"' },
10
- { label: '苹方', value: 'PingFang SC, "苹方-简"' },
11
- { label: '宋体', value: 'SimSun, "宋体", serif' },
12
- { label: '黑体', value: 'SimHei, "黑体", sans-serif' },
13
- { label: '楷体', value: 'KaiTi, "楷体", serif' },
14
- { label: '仿宋', value: 'FangSong, "仿宋", serif' },
15
- { label: '思源黑体', value: '"Noto Sans SC", "Source Han Sans SC", sans-serif' },
16
- { label: '思源宋体', value: '"Noto Serif SC", "Source Han Serif SC", serif' },
17
- { label: 'Arial', value: 'Arial, Helvetica, sans-serif' },
18
- { label: 'Helvetica', value: '"Helvetica Neue", Helvetica, sans-serif' },
19
- { label: 'Inter', value: 'Inter, -apple-system, sans-serif' },
20
- { label: 'Roboto', value: 'Roboto, "Segoe UI", sans-serif' },
21
- { label: 'Times New Roman', value: '"Times New Roman", Times, serif' },
22
- { label: 'Georgia', value: 'Georgia, "Times New Roman", serif' },
23
- { label: 'Courier New', value: '"Courier New", Courier, monospace' },
24
- { label: 'Consolas', value: 'Consolas, "Courier New", monospace' },
25
- { label: 'Monaco', value: 'Monaco, Consolas, monospace' },
26
- ];
27
-
28
- /** 对齐方式(互斥高亮) */
29
- export const ALIGN_OPTIONS = [
30
- { value: 'left', title: '左对齐', icon: 'alignLeft' },
31
- { value: 'center', title: '居中', icon: 'alignCenter' },
32
- { value: 'right', title: '右对齐', icon: 'alignRight' },
33
- { value: 'justify', title: '两端对齐', icon: 'alignJustify' },
34
- ];
35
-
36
- /** 文字色调色板(淡→深,两行:灰阶 + 彩色) */
37
- export const TEXT_COLORS = [
38
- '#000000', '#434343', '#666666', '#999999', '#b7b7b7', '#cccccc', '#d9d9d9', '#efefef', '#f3f3f3', '#ffffff',
39
- '#980000', '#ff0000', '#ff9900', '#bf9000', '#38761d', '#00ff00', '#00ffff', '#4a86e8', '#0000ff', '#9900ff',
40
- '#cc4125', '#e06666', '#f6b26b', '#ffd966', '#93c47d', '#76a5af', '#6d9eeb', '#8e7cc3', '#c27ba0', '#ff00ff',
41
- ];
42
-
43
- /** 背景色(高亮)调色板:每组由浅到深,共 6 列 */
44
- export const BG_COLORS = [
45
- '#ffffff', '#f2f3f5', '#e7e9eb', '#d4d5d9', '#c9c7c6', '#a8adb3',
46
- '#fde9e9', '#fddede', '#ffd4d4', '#fbc1c1', '#f8b0b0', '#f5a3a3',
47
- '#fff3d6', '#ffe9b3', '#ffdf8f', '#ffd25e', '#ffc233', '#ffb500',
48
- '#fffbd0', '#fdf2bc', '#fbea93', '#f8e35e', '#f5dc33', '#f5d500',
49
- '#e8fad4', '#d3f2b3', '#b9ec8e', '#a5e266', '#8fd354', '#71b823',
50
- '#d6f5f5', '#b3e9e9', '#8fdcdc', '#66cccc', '#4db8b8', '#339999',
51
- '#dae8fc', '#d0e4f7', '#b4d6f5', '#9cc2f0', '#7db3ea', '#5698e0',
52
- ];
53
-
54
- /**
55
- * 字体效果(互斥布尔样式;key 即内核标记键,value 是落到内联 style 的 CSS 值)
56
- * 空心 = -webkit-text-stroke 描边 + 透明填充;阴影 = 多层 text-shadow。
57
- */
58
- export const FONT_EFFECTS = [
59
- {
60
- key: 'textStroke',
61
- label: '空心',
62
- value: '0.2px currentColor',
63
- preview: { WebkitTextStroke: '0.2px currentColor', WebkitTextFillColor: 'transparent' },
64
- },
65
- {
66
- key: 'textShadow',
67
- label: '阴影',
68
- value: '1px 1px var(--dt-border-strong), 2px 2px var(--dt-border-strong)',
69
- preview: { textShadow: '1px 1px var(--dt-border-strong), 2px 2px var(--dt-border-strong)' },
70
- },
71
- ];
72
-
73
- /** 组合色(前景 + 背景一体应用);取值同调色板的 hex */
74
- export const COMBO_STYLES = [
75
- { color: '#000000', backgroundColor: '#fde9e9' },
76
- { color: '#980000', backgroundColor: '#ffd4d4' },
77
- { color: '#bf9000', backgroundColor: '#fff3d6' },
78
- { color: '#38761d', backgroundColor: '#e8fad4' },
79
- { color: '#4a86e8', backgroundColor: '#dae8fc' },
80
- { color: '#9900ff', backgroundColor: '#e7e9eb' },
81
- ];
82
-
83
- /** 「最近使用的外观」保留条数 */
84
- export const RECENT_STYLE_LIMIT = 14;
1
+ // [文件] web·core·文字样式常量 —— 字号/字体/调色板/对齐/字体效果/组合色的单一来源(富文本编辑器与演示文稿工具条共用,禁各域再建第二张表)
2
+ // [通用:常量] textStyles —— FONT_SIZES / FONT_FAMILIES / TEXT_COLORS / BG_COLORS / ALIGN_OPTIONS / FONT_EFFECTS / COMBO_STYLES / RECENT_STYLE_LIMIT
3
+
4
+ /** 字号预设(px,12~72) */
5
+ export const FONT_SIZES = [12, 13, 14, 15, 16, 18, 20, 24, 28, 32, 36, 42, 48, 54, 62, 72];
6
+
7
+ /** 字体(系统字体 + Web 安全字体;内网不回源加载,命中本机字体即生效) */
8
+ export const FONT_FAMILIES = [
9
+ { label: '微软雅黑', value: 'Microsoft YaHei, "微软雅黑"' },
10
+ { label: '苹方', value: 'PingFang SC, "苹方-简"' },
11
+ { label: '宋体', value: 'SimSun, "宋体", serif' },
12
+ { label: '黑体', value: 'SimHei, "黑体", sans-serif' },
13
+ { label: '楷体', value: 'KaiTi, "楷体", serif' },
14
+ { label: '仿宋', value: 'FangSong, "仿宋", serif' },
15
+ { label: '思源黑体', value: '"Noto Sans SC", "Source Han Sans SC", sans-serif' },
16
+ { label: '思源宋体', value: '"Noto Serif SC", "Source Han Serif SC", serif' },
17
+ { label: 'Arial', value: 'Arial, Helvetica, sans-serif' },
18
+ { label: 'Helvetica', value: '"Helvetica Neue", Helvetica, sans-serif' },
19
+ { label: 'Inter', value: 'Inter, -apple-system, sans-serif' },
20
+ { label: 'Roboto', value: 'Roboto, "Segoe UI", sans-serif' },
21
+ { label: 'Times New Roman', value: '"Times New Roman", Times, serif' },
22
+ { label: 'Georgia', value: 'Georgia, "Times New Roman", serif' },
23
+ { label: 'Courier New', value: '"Courier New", Courier, monospace' },
24
+ { label: 'Consolas', value: 'Consolas, "Courier New", monospace' },
25
+ { label: 'Monaco', value: 'Monaco, Consolas, monospace' },
26
+ ];
27
+
28
+ /** 对齐方式(互斥高亮) */
29
+ export const ALIGN_OPTIONS = [
30
+ { value: 'left', title: '左对齐', icon: 'alignLeft' },
31
+ { value: 'center', title: '居中', icon: 'alignCenter' },
32
+ { value: 'right', title: '右对齐', icon: 'alignRight' },
33
+ { value: 'justify', title: '两端对齐', icon: 'alignJustify' },
34
+ ];
35
+
36
+ /** 文字色调色板(淡→深,两行:灰阶 + 彩色) */
37
+ export const TEXT_COLORS = [
38
+ '#000000', '#434343', '#666666', '#999999', '#b7b7b7', '#cccccc', '#d9d9d9', '#efefef', '#f3f3f3', '#ffffff',
39
+ '#980000', '#ff0000', '#ff9900', '#bf9000', '#38761d', '#00ff00', '#00ffff', '#4a86e8', '#0000ff', '#9900ff',
40
+ '#cc4125', '#e06666', '#f6b26b', '#ffd966', '#93c47d', '#76a5af', '#6d9eeb', '#8e7cc3', '#c27ba0', '#ff00ff',
41
+ ];
42
+
43
+ /** 背景色(高亮)调色板:每组由浅到深,共 6 列 */
44
+ export const BG_COLORS = [
45
+ '#ffffff', '#f2f3f5', '#e7e9eb', '#d4d5d9', '#c9c7c6', '#a8adb3',
46
+ '#fde9e9', '#fddede', '#ffd4d4', '#fbc1c1', '#f8b0b0', '#f5a3a3',
47
+ '#fff3d6', '#ffe9b3', '#ffdf8f', '#ffd25e', '#ffc233', '#ffb500',
48
+ '#fffbd0', '#fdf2bc', '#fbea93', '#f8e35e', '#f5dc33', '#f5d500',
49
+ '#e8fad4', '#d3f2b3', '#b9ec8e', '#a5e266', '#8fd354', '#71b823',
50
+ '#d6f5f5', '#b3e9e9', '#8fdcdc', '#66cccc', '#4db8b8', '#339999',
51
+ '#dae8fc', '#d0e4f7', '#b4d6f5', '#9cc2f0', '#7db3ea', '#5698e0',
52
+ ];
53
+
54
+ /**
55
+ * 字体效果(互斥布尔样式;key 即内核标记键,value 是落到内联 style 的 CSS 值)
56
+ * 空心 = -webkit-text-stroke 描边 + 透明填充;阴影 = 多层 text-shadow。
57
+ */
58
+ export const FONT_EFFECTS = [
59
+ {
60
+ key: 'textStroke',
61
+ label: '空心',
62
+ value: '0.2px currentColor',
63
+ preview: { WebkitTextStroke: '0.2px currentColor', WebkitTextFillColor: 'transparent' },
64
+ },
65
+ {
66
+ key: 'textShadow',
67
+ label: '阴影',
68
+ value: '1px 1px var(--gbp-dt-border-strong), 2px 2px var(--gbp-dt-border-strong)',
69
+ preview: { textShadow: '1px 1px var(--gbp-dt-border-strong), 2px 2px var(--gbp-dt-border-strong)' },
70
+ },
71
+ ];
72
+
73
+ /** 组合色(前景 + 背景一体应用);取值同调色板的 hex */
74
+ export const COMBO_STYLES = [
75
+ { color: '#000000', backgroundColor: '#fde9e9' },
76
+ { color: '#980000', backgroundColor: '#ffd4d4' },
77
+ { color: '#bf9000', backgroundColor: '#fff3d6' },
78
+ { color: '#38761d', backgroundColor: '#e8fad4' },
79
+ { color: '#4a86e8', backgroundColor: '#dae8fc' },
80
+ { color: '#9900ff', backgroundColor: '#e7e9eb' },
81
+ ];
82
+
83
+ /** 「最近使用的外观」保留条数 */
84
+ export const RECENT_STYLE_LIMIT = 14;
@@ -1,5 +1,6 @@
1
- // [文件] gbpptx·标题栏 —— Office 快速访问工具栏 + 文档名/保存状态 + 自动保存与设置
1
+ // [文件] gbpptx·顶部菜单栏 —— 与 gbdocs / gbxlxs 一致:左侧菜单栏 + 右侧文档名/保存状态/保存按钮
2
2
 
3
+ import { SHAPE_KINDS, SLIDE_LAYOUTS, TRANSITIONS } from '../../../src/kernel/model.js';
3
4
  import { icon } from './icons.js';
4
5
  import { openMenu } from './menu.js';
5
6
  import { openModal } from './dialogs.js';
@@ -11,91 +12,197 @@ const el = (tag, cls, text) => {
11
12
  return node;
12
13
  };
13
14
 
15
+ const submenu = (label, items) => ({ label, children: items });
16
+
14
17
  export class TitleBar {
15
18
  constructor(app) {
16
19
  this.app = app;
17
- this.el = el('header', 'pp-titlebar');
20
+ this.el = el('header', 'pp-topbar');
18
21
  this.build();
22
+ this.refresh();
19
23
  }
20
24
 
21
25
  build() {
22
- const appIcon = el('span', 'pp-titlebar__app');
23
- appIcon.innerHTML = icon('logo', 18);
24
- appIcon.title = '挂逼演示';
25
- const qa = el('div', 'pp-titlebar__qa');
26
- this.saveBtn = this.tool('save', '保存 (Ctrl+S)', () => this.app.save());
27
- this.undoBtn = this.tool('undo', '撤销 (Ctrl+Z)', () => this.app.undo());
28
- this.redoBtn = this.tool('redo', '重做 (Ctrl+Y)', () => this.app.redo());
29
- const playBtn = this.tool('play', '从头开始放映 (F5)', () => this.app.presentFromStart());
30
- qa.append(this.saveBtn, this.undoBtn, this.redoBtn, playBtn);
31
-
32
- const doc = el('div', 'pp-titlebar__doc');
33
- this.nameEl = el('span', 'pp-titlebar__name', '新建演示');
34
- this.stateEl = el('span', 'pp-titlebar__state', '已保存');
35
- doc.append(this.nameEl, this.stateEl);
36
-
37
- const right = el('div', 'pp-titlebar__right');
38
- this.autosaveBtn = el('button', 'pp-titlebar__auto');
39
- this.autosaveBtn.type = 'button';
40
- this.autosaveBtn.title = '自动保存(需要已关联本地文件)';
41
- this.autosaveBtn.innerHTML = '<span class="pp-switch"><i></i></span><span>自动保存</span>';
42
- this.autosaveBtn.addEventListener('click', () => this.app.setAutosave(!this.app.autosave));
43
- const settings = this.tool('more', '设置', () => this.openSettings(settings));
44
- right.append(this.autosaveBtn, settings);
45
-
46
- this.el.append(appIcon, qa, doc, right);
26
+ const defs = [
27
+ ['文件', () => this.fileItems()],
28
+ ['编辑', () => this.editItems()],
29
+ ['插入', () => this.insertItems()],
30
+ ['幻灯片', () => this.slideItems()],
31
+ ['放映', () => this.showItems()],
32
+ ['审阅', () => this.reviewItems()],
33
+ ['视图', () => this.viewItems()],
34
+ ];
35
+ const bar = el('div', 'pp-menubar');
36
+ for (const [label, items] of defs) {
37
+ const btn = el('button', 'pp-menubar__btn', label);
38
+ btn.type = 'button';
39
+ btn.addEventListener('click', () => {
40
+ btn.classList.add('gbp-is-open');
41
+ openMenu({ anchor: btn, items: items(), onClose: () => btn.classList.remove('gbp-is-open') });
42
+ });
43
+ bar.appendChild(btn);
44
+ }
45
+
46
+ const info = el('div', 'pp-docinfo');
47
+ this.nameEl = el('span', 'pp-docinfo__name', '新建演示');
48
+ this.stateEl = el('span', 'pp-docinfo__state', '已保存');
49
+ this.saveBtn = el('button', 'pp-docinfo__save', '保存');
50
+ this.saveBtn.type = 'button';
51
+ this.saveBtn.title = '保存 (Ctrl+S)';
52
+ this.saveBtn.addEventListener('click', () => this.app.save());
53
+ info.append(this.nameEl, this.stateEl, this.saveBtn);
54
+
55
+ this.el.append(bar, info);
56
+ }
57
+
58
+ /* ===================== 菜单条目 ===================== */
59
+
60
+ fileItems() {
61
+ const app = this.app;
62
+ const hasSlides = app.snapshot.slides.length > 0;
63
+ return [
64
+ { label: '新建', shortcut: 'Ctrl+N', onClick: () => app.newDoc() },
65
+ { label: '打开…', shortcut: 'Ctrl+O', onClick: () => app.openFile() },
66
+ { divided: true },
67
+ { label: '保存', shortcut: 'Ctrl+S', disabled: !hasSlides, onClick: () => app.save() },
68
+ { label: '另存为…', shortcut: 'Ctrl+Shift+S', disabled: !hasSlides, onClick: () => app.saveAs(app.doc.name) },
69
+ { label: '自动保存', checked: app.autosave, onClick: () => app.setAutosave(!app.autosave) },
70
+ { divided: true },
71
+ { label: '导出 PPTX', disabled: !hasSlides, onClick: () => app.exportPptx() },
72
+ { label: '导出 PDF', disabled: !hasSlides, onClick: () => app.exportPdf() },
73
+ { label: '打印…', disabled: !hasSlides, onClick: () => app.exportPdf() },
74
+ { divided: true },
75
+ { label: '关闭', onClick: () => app.closeDocument() },
76
+ ];
77
+ }
78
+
79
+ editItems() {
80
+ const app = this.app;
81
+ const hasSel = app.selectedIds.length > 0 || Boolean(app.editing);
82
+ return [
83
+ { label: '撤销', shortcut: 'Ctrl+Z', disabled: !app.canUndo(), onClick: () => app.undo() },
84
+ { label: '重做', shortcut: 'Ctrl+Y', disabled: !app.canRedo(), onClick: () => app.redo() },
85
+ { divided: true },
86
+ { label: '剪切', shortcut: 'Ctrl+X', disabled: !hasSel, onClick: () => app.cutSelected() },
87
+ { label: '复制', shortcut: 'Ctrl+C', disabled: !hasSel, onClick: () => app.copySelected() },
88
+ { label: '粘贴', shortcut: 'Ctrl+V', disabled: !app.canPaste(), onClick: () => app.paste() },
89
+ { label: '粘贴为纯文本', onClick: () => app.pastePlain() },
90
+ { divided: true },
91
+ { label: '全选', shortcut: 'Ctrl+A', onClick: () => app.selectAll() },
92
+ { label: '查找…', shortcut: 'Ctrl+F', onClick: () => app.openFind(false) },
93
+ { label: '替换…', shortcut: 'Ctrl+H', onClick: () => app.openFind(true) },
94
+ ];
47
95
  }
48
96
 
49
- tool(name, title, onClick) {
50
- const b = el('button', 'pp-titlebar__tool');
51
- b.type = 'button';
52
- b.title = title;
53
- b.innerHTML = icon(name, 16);
54
- b.addEventListener('click', onClick);
55
- return b;
97
+ insertItems() {
98
+ const app = this.app;
99
+ return [
100
+ { label: '新建幻灯片', shortcut: 'Ctrl+M', onClick: () => app.addSlide() },
101
+ { divided: true },
102
+ submenu('表格', [2, 3, 4, 5].map((n) => ({
103
+ label: `${n}×${n} 表格`,
104
+ onClick: () => app.insertTable(n, n),
105
+ }))),
106
+ { label: '图片…', onClick: () => app.insert('image') },
107
+ submenu('形状', SHAPE_KINDS.map((s) => ({
108
+ label: s.label,
109
+ onClick: () => app.insert('shape', s.kind),
110
+ }))),
111
+ { label: '文本框', onClick: () => app.insert('text') },
112
+ { label: '线条', onClick: () => app.insert('line') },
113
+ { label: '箭头', onClick: () => app.insert('arrow') },
114
+ { divided: true },
115
+ { label: '备注', checked: app.notesVisible, onClick: () => app.toggleNotes() },
116
+ ];
56
117
  }
57
118
 
58
- openSettings(anchor) {
119
+ slideItems() {
59
120
  const app = this.app;
60
- openMenu({
61
- anchor,
62
- placement: 'bottom-end',
63
- items: [
64
- { header: '显示' },
65
- { label: '网格线', checked: app.gridVisible, onClick: () => app.toggleGrid() },
66
- { label: '参考线', checked: app.guidesVisible, onClick: () => app.toggleGuides() },
67
- { label: '备注', checked: app.notesVisible, onClick: () => app.toggleNotes() },
68
- { label: '设置形状格式窗格', checked: app.formatPaneOpen, onClick: () => app.toggleFormatPane() },
69
- { divided: true },
70
- { label: '演讲者视图', checked: app.presentOptions.presenter, onClick: () => app.togglePresenter() },
71
- { label: '循环放映', checked: app.presentOptions.loop, onClick: () => app.toggleLoop() },
72
- { divided: true },
73
- { label: '自动保存', checked: app.autosave, onClick: () => app.setAutosave(!app.autosave) },
74
- { label: '关于挂逼演示…', onClick: () => openModal({
75
- title: '关于',
76
- width: 400,
77
- confirmText: '知道了',
78
- build: (body) => {
79
- const p = el('div', 'pp-about');
80
- p.innerHTML = `${icon('logo', 40)}<h3>挂逼演示 gbpptx</h3><p>真实的 .pptx 读写 + Office 式演示编辑器。</p><p class="pp-backstage__muted">Pptx 文件进入 → 查看/编辑 → 原样导出</p>`;
81
- body.appendChild(p);
82
- },
83
- }) },
84
- ],
121
+ const count = app.snapshot.slides.length;
122
+ return [
123
+ { label: '新建幻灯片', shortcut: 'Ctrl+M', onClick: () => app.addSlide() },
124
+ { label: '复制幻灯片', onClick: () => app.dupSlide() },
125
+ { label: '删除幻灯片', disabled: count <= 1, onClick: () => app.delSlide() },
126
+ { divided: true },
127
+ { label: '隐藏幻灯片', checked: Boolean(app.currentSlide()?.hidden), onClick: () => app.toggleSlideHidden() },
128
+ submenu('版式', SLIDE_LAYOUTS.map((l) => ({
129
+ label: l.label,
130
+ onClick: () => app.addSlide(l.key),
131
+ }))),
132
+ submenu('切换', TRANSITIONS.map((t) => ({
133
+ label: t.label,
134
+ onClick: () => app.setTransition({ type: t.key, dir: t.dir || 'l' }),
135
+ }))),
136
+ { divided: true },
137
+ { label: '重设位置与大小', disabled: !app.selectedIds.length, onClick: () => app.resetSelected() },
138
+ { label: '设置背景格式…', onClick: () => app.openFormatPane() },
139
+ ];
140
+ }
141
+
142
+ showItems() {
143
+ const app = this.app;
144
+ return [
145
+ { label: '从头开始', shortcut: 'F5', onClick: () => app.presentFromStart() },
146
+ { label: '从当前页', shortcut: 'Shift+F5', onClick: () => app.presentFromCurrent() },
147
+ { divided: true },
148
+ { label: '演讲者视图', checked: app.presentOptions.presenter, onClick: () => app.togglePresenter() },
149
+ { label: '循环放映', checked: app.presentOptions.loop, onClick: () => app.toggleLoop() },
150
+ { label: '隐藏幻灯片', checked: Boolean(app.currentSlide()?.hidden), onClick: () => app.toggleSlideHidden() },
151
+ ];
152
+ }
153
+
154
+ reviewItems() {
155
+ const app = this.app;
156
+ return [
157
+ { label: '显示备注', checked: app.notesVisible, onClick: () => app.toggleNotes() },
158
+ { label: '字数统计…', onClick: () => app.showWordCount() },
159
+ ];
160
+ }
161
+
162
+ viewItems() {
163
+ const app = this.app;
164
+ return [
165
+ { label: '普通', checked: app.view === 'normal', onClick: () => app.setView('normal') },
166
+ { label: '幻灯片浏览', checked: app.view === 'sorter', onClick: () => app.setView('sorter') },
167
+ { label: '阅读视图', checked: app.view === 'reading', onClick: () => app.setView('reading') },
168
+ { divided: true },
169
+ { label: '网格线', checked: app.gridVisible, onClick: () => app.toggleGrid() },
170
+ { label: '参考线', checked: app.guidesVisible, onClick: () => app.toggleGuides() },
171
+ { label: '备注', checked: app.notesVisible, onClick: () => app.toggleNotes() },
172
+ { label: '设置形状格式窗格', checked: app.formatPaneOpen, onClick: () => app.toggleFormatPane() },
173
+ { divided: true },
174
+ { label: '适应窗口', onClick: () => app.fitToWindow() },
175
+ { label: '放大', shortcut: 'Ctrl+=', onClick: () => app.setZoom(app.zoom + 10) },
176
+ { label: '缩小', shortcut: 'Ctrl+-', onClick: () => app.setZoom(app.zoom - 10) },
177
+ { divided: true },
178
+ { label: '关于挂逼演示…', onClick: () => this.showAbout() },
179
+ ];
180
+ }
181
+
182
+ showAbout() {
183
+ openModal({
184
+ title: '关于',
185
+ width: 400,
186
+ confirmText: '知道了',
187
+ build: (body) => {
188
+ const p = el('div', 'pp-about');
189
+ p.innerHTML = `${icon('logo', 40)}<h3>挂逼演示 gbpptx</h3><p>真实的 .pptx 读写 + Office 式演示编辑器。</p><p class="pp-backstage__muted">Pptx 文件进入 → 查看/编辑 → 原样导出</p>`;
190
+ body.appendChild(p);
191
+ },
85
192
  });
86
193
  }
87
194
 
195
+ /* ===================== 状态刷新 ===================== */
196
+
88
197
  refresh() {
89
198
  const app = this.app;
90
199
  this.nameEl.textContent = app.doc.name || '新建演示';
200
+ this.nameEl.title = this.nameEl.textContent;
91
201
  document.title = `${this.nameEl.textContent} - 挂逼演示`;
92
202
  this.stateEl.textContent = app.dirty
93
- ? '未保存的更改'
94
- : app.doc.handle ? '已保存到本地' : (app.doc.savedAt ? '已保存副本' : '尚未保存');
95
- this.stateEl.classList.toggle('is-dirty', app.dirty);
203
+ ? '未保存'
204
+ : app.doc.handle ? '已保存' : (app.doc.savedAt ? '已保存副本' : '尚未保存');
205
+ this.stateEl.classList.toggle('gbp-is-dirty', app.dirty);
96
206
  this.saveBtn.disabled = !app.snapshot.slides.length;
97
- this.undoBtn.disabled = !app.canUndo();
98
- this.redoBtn.disabled = !app.canRedo();
99
- this.autosaveBtn.classList.toggle('is-active', app.autosave);
100
207
  }
101
208
  }
@@ -1,30 +1,30 @@
1
- // [文件] gbpptx·切换动画 —— 放映与画布预览共用同一套 CSS 动画口径
2
-
3
- const SPEED_MS = { fast: 500, med: 800, slow: 1500 };
4
-
5
- /**
6
- * 对「刚进入的页容器」播放切换动画
7
- * @param {HTMLElement} wrap 承载页面的容器
8
- * @param {{type:string,dir:string,speed:string}} tr
9
- */
10
- export function animateSlideFrame(wrap, tr) {
11
- if (!wrap || !tr || tr.type === 'none') return;
12
- const dur = SPEED_MS[tr.speed] || SPEED_MS.med;
13
- const dir = tr.dir || 'l';
14
- const tx = dir === 'l' ? '60px' : dir === 'r' ? '-60px' : '0';
15
- const ty = dir === 'u' ? '60px' : dir === 'd' ? '-60px' : '0';
16
- const easing = 'cubic-bezier(.2,.7,.2,1)';
17
- if (tr.type === 'wipe') {
18
- const from = dir === 'r' ? 'inset(0 0 0 100%)' : dir === 'u' ? 'inset(100% 0 0 0)' : dir === 'd' ? 'inset(0 0 100% 0)' : 'inset(0 100% 0 0)';
19
- wrap.animate([{ clipPath: from }, { clipPath: 'inset(0 0 0 0)' }], { duration: dur, easing });
20
- return;
21
- }
22
- if (tr.type === 'split') {
23
- wrap.animate([{ clipPath: 'inset(0 50% 0 50%)' }, { clipPath: 'inset(0 0 0 0)' }], { duration: dur, easing });
24
- return;
25
- }
26
- let frames = [{ opacity: 0 }, { opacity: 1 }];
27
- if (tr.type === 'push' || tr.type === 'cover') frames = [{ transform: `translate(${tx}, ${ty})` }, { transform: 'translate(0, 0)' }];
28
- if (tr.type === 'zoom') frames = [{ opacity: 0, transform: 'scale(1.08)' }, { opacity: 1, transform: 'scale(1)' }];
29
- wrap.animate(frames, { duration: dur, easing, fill: 'both' });
30
- }
1
+ // [文件] gbpptx·切换动画 —— 放映与画布预览共用同一套 CSS 动画口径
2
+
3
+ const SPEED_MS = { fast: 500, med: 800, slow: 1500 };
4
+
5
+ /**
6
+ * 对「刚进入的页容器」播放切换动画
7
+ * @param {HTMLElement} wrap 承载页面的容器
8
+ * @param {{type:string,dir:string,speed:string}} tr
9
+ */
10
+ export function animateSlideFrame(wrap, tr) {
11
+ if (!wrap || !tr || tr.type === 'none') return;
12
+ const dur = SPEED_MS[tr.speed] || SPEED_MS.med;
13
+ const dir = tr.dir || 'l';
14
+ const tx = dir === 'l' ? '60px' : dir === 'r' ? '-60px' : '0';
15
+ const ty = dir === 'u' ? '60px' : dir === 'd' ? '-60px' : '0';
16
+ const easing = 'cubic-bezier(.2,.7,.2,1)';
17
+ if (tr.type === 'wipe') {
18
+ const from = dir === 'r' ? 'inset(0 0 0 100%)' : dir === 'u' ? 'inset(100% 0 0 0)' : dir === 'd' ? 'inset(0 0 100% 0)' : 'inset(0 100% 0 0)';
19
+ wrap.animate([{ clipPath: from }, { clipPath: 'inset(0 0 0 0)' }], { duration: dur, easing });
20
+ return;
21
+ }
22
+ if (tr.type === 'split') {
23
+ wrap.animate([{ clipPath: 'inset(0 50% 0 50%)' }, { clipPath: 'inset(0 0 0 0)' }], { duration: dur, easing });
24
+ return;
25
+ }
26
+ let frames = [{ opacity: 0 }, { opacity: 1 }];
27
+ if (tr.type === 'push' || tr.type === 'cover') frames = [{ transform: `translate(${tx}, ${ty})` }, { transform: 'translate(0, 0)' }];
28
+ if (tr.type === 'zoom') frames = [{ opacity: 0, transform: 'scale(1.08)' }, { opacity: 1, transform: 'scale(1)' }];
29
+ wrap.animate(frames, { duration: dur, easing, fill: 'both' });
30
+ }
package/web/index.html CHANGED
@@ -1,22 +1,23 @@
1
- <!doctype html>
2
- <html lang="zh-CN">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>挂逼演示 gbpptx</title>
7
- <link rel="stylesheet" href="/web/styles/tokens.css" />
8
- <link rel="stylesheet" href="/web/styles/slides.css" />
9
- <link rel="stylesheet" href="/web/styles/office.css" />
10
- <script type="importmap">
11
- {
12
- "imports": {
13
- "gbooxml": "/vendor/gbooxml/index.js"
14
- }
15
- }
16
- </script>
17
- </head>
18
- <body>
19
- <div id="app"></div>
20
- <script type="module" src="/web/app/main.js"></script>
21
- </body>
22
- </html>
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>挂逼演示 gbpptx</title>
7
+ <link rel="stylesheet" href="/web/styles/tokens.css" />
8
+ <link rel="stylesheet" href="/web/styles/slides.css" />
9
+ <link rel="stylesheet" href="/web/styles/office.css" />
10
+ <script type="importmap">
11
+ {
12
+ "imports": {
13
+ "gbooxml": "/vendor/gbooxml/index.js",
14
+ "guabiutils": "/vendor/guabiutils/index.js"
15
+ }
16
+ }
17
+ </script>
18
+ </head>
19
+ <body>
20
+ <div id="app" class="gbp-root"></div>
21
+ <script type="module" src="/web/app/main.js"></script>
22
+ </body>
23
+ </html>