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.
- package/README.md +237 -214
- package/package.json +5 -3
- package/src/kernel/model.js +1 -2
- package/src/kernel/parts.js +11 -15
- package/src/kernel/print.js +14 -16
- package/web/app/main.js +8 -8
- package/web/app/slides/arrange.js +101 -0
- package/web/app/slides/clipboard.js +93 -0
- package/web/app/slides/file.js +213 -0
- package/web/app/slides/find.js +201 -0
- package/web/app/slides/history.js +100 -0
- package/web/app/slides/keys.js +179 -0
- package/web/app/slides/menus.js +105 -0
- package/web/app/slides/objects.js +254 -0
- package/web/app/slides/render.js +183 -0
- package/web/app/slides/shared.js +85 -0
- package/web/app/slides/slides.js +103 -0
- package/web/app/slides/table.js +102 -0
- package/web/app/slides/text.js +418 -0
- package/web/app/slides/view.js +156 -0
- package/web/app/slides-app.js +323 -2446
- package/web/app/ui/canvas.js +769 -755
- package/web/app/ui/color-panel.js +58 -76
- package/web/app/ui/dialogs.js +120 -159
- package/web/app/ui/file-io.js +116 -132
- package/web/app/ui/format-pane.js +427 -427
- package/web/app/ui/icons.js +129 -129
- package/web/app/ui/menu.js +75 -89
- package/web/app/ui/notify.js +45 -45
- package/web/app/ui/page-view.js +221 -221
- package/web/app/ui/popup.js +80 -80
- package/web/app/ui/present.js +292 -292
- package/web/app/ui/ribbon.js +868 -878
- package/web/app/ui/slide-pane.js +197 -189
- package/web/app/ui/statusbar.js +93 -93
- package/web/app/ui/text-styles.js +84 -84
- package/web/app/ui/titlebar.js +184 -67
- package/web/app/ui/transition.js +30 -30
- package/web/index.html +23 -21
- package/web/serve.mjs +22 -67
- package/web/styles/office.css +466 -644
- package/web/styles/slides.css +97 -219
- package/web/styles/tokens.css +154 -155
- package/src/kernel/util/escape.js +0 -21
- package/src/kernel/util/id.js +0 -13
- package/web/app/ui/backstage.js +0 -255
|
@@ -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;
|
package/web/app/ui/titlebar.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
// [文件] gbpptx
|
|
1
|
+
// [文件] gbpptx·顶部菜单栏 —— 与 gbdocx / 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,207 @@ 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-
|
|
20
|
+
this.el = el('header', 'pp-topbar');
|
|
18
21
|
this.build();
|
|
22
|
+
this.refresh();
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
build() {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.el
|
|
26
|
+
const defs = [
|
|
27
|
+
['file', '文件', () => this.fileItems()],
|
|
28
|
+
['edit', '编辑', () => this.editItems()],
|
|
29
|
+
['insert', '插入', () => this.insertItems()],
|
|
30
|
+
['slide', '幻灯片', () => this.slideItems()],
|
|
31
|
+
['show', '放映', () => this.showItems()],
|
|
32
|
+
['review', '审阅', () => this.reviewItems()],
|
|
33
|
+
['view', '视图', () => this.viewItems()],
|
|
34
|
+
];
|
|
35
|
+
const bar = el('div', 'pp-menubar');
|
|
36
|
+
for (const [key, label, items] of defs) {
|
|
37
|
+
const btn = el('button', 'pp-menubar__btn', label);
|
|
38
|
+
btn.type = 'button';
|
|
39
|
+
btn.dataset.menu = key;
|
|
40
|
+
btn.addEventListener('click', () => {
|
|
41
|
+
btn.classList.add('gbp-is-open');
|
|
42
|
+
openMenu({ anchor: btn, items: items(), onClose: () => btn.classList.remove('gbp-is-open') });
|
|
43
|
+
});
|
|
44
|
+
bar.appendChild(btn);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const info = el('div', 'pp-docinfo');
|
|
48
|
+
this.nameEl = el('span', 'pp-docinfo__name', '新建演示');
|
|
49
|
+
this.stateEl = el('span', 'pp-docinfo__state', '已保存');
|
|
50
|
+
this.saveBtn = el('button', 'pp-docinfo__save', '保存');
|
|
51
|
+
this.saveBtn.type = 'button';
|
|
52
|
+
this.saveBtn.title = '保存 (Ctrl+S)';
|
|
53
|
+
this.saveBtn.addEventListener('click', () => this.app.save());
|
|
54
|
+
info.append(this.nameEl, this.stateEl, this.saveBtn);
|
|
55
|
+
|
|
56
|
+
this.el.append(bar, info);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* ===================== 菜单条目 ===================== */
|
|
60
|
+
|
|
61
|
+
fileItems() {
|
|
62
|
+
const app = this.app;
|
|
63
|
+
const hasSlides = app.snapshot.slides.length > 0;
|
|
64
|
+
const items = [
|
|
65
|
+
{ label: '新建', shortcut: 'Ctrl+N', onClick: () => app.newDoc() },
|
|
66
|
+
{ label: '打开…', shortcut: 'Ctrl+O', onClick: () => app.openFile() },
|
|
67
|
+
{ divided: true },
|
|
68
|
+
{ label: '保存', shortcut: 'Ctrl+S', disabled: !hasSlides, onClick: () => app.save() },
|
|
69
|
+
{ label: '另存为…', shortcut: 'Ctrl+Shift+S', disabled: !hasSlides, onClick: () => app.saveAs(app.doc.name) },
|
|
70
|
+
{ label: '自动保存', checked: app.autosave, onClick: () => app.setAutosave(!app.autosave) },
|
|
71
|
+
{ divided: true },
|
|
72
|
+
{ label: '导出 PPTX', disabled: !hasSlides, onClick: () => app.exportPptx() },
|
|
73
|
+
{ label: '导出 PDF', disabled: !hasSlides, onClick: () => app.exportPdf() },
|
|
74
|
+
{ label: '打印…', disabled: !hasSlides, onClick: () => app.exportPdf() },
|
|
75
|
+
{ divided: true },
|
|
76
|
+
{ label: '关闭', onClick: () => app.closeDocument() },
|
|
77
|
+
];
|
|
78
|
+
// 只读档保留导出/打印,其余文件动作会替换或写回文档,一律禁用
|
|
79
|
+
if (!app.readOnly) return items;
|
|
80
|
+
const viewActions = new Set(['导出 PPTX', '导出 PDF', '打印…']);
|
|
81
|
+
return items.map((item) => ({ ...item, disabled: item.disabled || !viewActions.has(item.label) }));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
editItems() {
|
|
85
|
+
const app = this.app;
|
|
86
|
+
const hasSel = app.selectedIds.length > 0 || Boolean(app.editing);
|
|
87
|
+
return [
|
|
88
|
+
{ label: '撤销', shortcut: 'Ctrl+Z', disabled: !app.canUndo(), onClick: () => app.undo() },
|
|
89
|
+
{ label: '重做', shortcut: 'Ctrl+Y', disabled: !app.canRedo(), onClick: () => app.redo() },
|
|
90
|
+
{ divided: true },
|
|
91
|
+
{ label: '剪切', shortcut: 'Ctrl+X', disabled: !hasSel, onClick: () => app.cutSelected() },
|
|
92
|
+
{ label: '复制', shortcut: 'Ctrl+C', disabled: !hasSel, onClick: () => app.copySelected() },
|
|
93
|
+
{ label: '粘贴', shortcut: 'Ctrl+V', disabled: !app.canPaste(), onClick: () => app.paste() },
|
|
94
|
+
{ label: '粘贴为纯文本', onClick: () => app.pastePlain() },
|
|
95
|
+
{ divided: true },
|
|
96
|
+
{ label: '全选', shortcut: 'Ctrl+A', onClick: () => app.selectAll() },
|
|
97
|
+
{ label: '查找…', shortcut: 'Ctrl+F', onClick: () => app.openFind(false) },
|
|
98
|
+
{ label: '替换…', shortcut: 'Ctrl+H', onClick: () => app.openFind(true) },
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
insertItems() {
|
|
103
|
+
const app = this.app;
|
|
104
|
+
return [
|
|
105
|
+
{ label: '新建幻灯片', shortcut: 'Ctrl+M', onClick: () => app.addSlide() },
|
|
106
|
+
{ divided: true },
|
|
107
|
+
submenu('表格', [2, 3, 4, 5].map((n) => ({
|
|
108
|
+
label: `${n}×${n} 表格`,
|
|
109
|
+
onClick: () => app.insertTable(n, n),
|
|
110
|
+
}))),
|
|
111
|
+
{ label: '图片…', onClick: () => app.insert('image') },
|
|
112
|
+
submenu('形状', SHAPE_KINDS.map((s) => ({
|
|
113
|
+
label: s.label,
|
|
114
|
+
onClick: () => app.insert('shape', s.kind),
|
|
115
|
+
}))),
|
|
116
|
+
{ label: '文本框', onClick: () => app.insert('text') },
|
|
117
|
+
{ label: '线条', onClick: () => app.insert('line') },
|
|
118
|
+
{ label: '箭头', onClick: () => app.insert('arrow') },
|
|
119
|
+
{ divided: true },
|
|
120
|
+
{ label: '备注', checked: app.notesVisible, onClick: () => app.toggleNotes() },
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
slideItems() {
|
|
125
|
+
const app = this.app;
|
|
126
|
+
const count = app.snapshot.slides.length;
|
|
127
|
+
return [
|
|
128
|
+
{ label: '新建幻灯片', shortcut: 'Ctrl+M', onClick: () => app.addSlide() },
|
|
129
|
+
{ label: '复制幻灯片', onClick: () => app.dupSlide() },
|
|
130
|
+
{ label: '删除幻灯片', disabled: count <= 1, onClick: () => app.delSlide() },
|
|
131
|
+
{ divided: true },
|
|
132
|
+
{ label: '隐藏幻灯片', checked: Boolean(app.currentSlide()?.hidden), onClick: () => app.toggleSlideHidden() },
|
|
133
|
+
submenu('版式', SLIDE_LAYOUTS.map((l) => ({
|
|
134
|
+
label: l.label,
|
|
135
|
+
onClick: () => app.addSlide(l.key),
|
|
136
|
+
}))),
|
|
137
|
+
submenu('切换', TRANSITIONS.map((t) => ({
|
|
138
|
+
label: t.label,
|
|
139
|
+
onClick: () => app.setTransition({ type: t.key, dir: t.dir || 'l' }),
|
|
140
|
+
}))),
|
|
141
|
+
{ divided: true },
|
|
142
|
+
{ label: '重设位置与大小', disabled: !app.selectedIds.length, onClick: () => app.resetSelected() },
|
|
143
|
+
{ label: '设置背景格式…', onClick: () => app.openFormatPane() },
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
showItems() {
|
|
148
|
+
const app = this.app;
|
|
149
|
+
return [
|
|
150
|
+
{ label: '从头开始', shortcut: 'F5', onClick: () => app.presentFromStart() },
|
|
151
|
+
{ label: '从当前页', shortcut: 'Shift+F5', onClick: () => app.presentFromCurrent() },
|
|
152
|
+
{ divided: true },
|
|
153
|
+
{ label: '演讲者视图', checked: app.presentOptions.presenter, onClick: () => app.togglePresenter() },
|
|
154
|
+
{ label: '循环放映', checked: app.presentOptions.loop, onClick: () => app.toggleLoop() },
|
|
155
|
+
{ label: '隐藏幻灯片', checked: Boolean(app.currentSlide()?.hidden), onClick: () => app.toggleSlideHidden() },
|
|
156
|
+
];
|
|
47
157
|
}
|
|
48
158
|
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return b;
|
|
159
|
+
reviewItems() {
|
|
160
|
+
const app = this.app;
|
|
161
|
+
return [
|
|
162
|
+
{ label: '显示备注', checked: app.notesVisible, onClick: () => app.toggleNotes() },
|
|
163
|
+
{ label: '字数统计…', onClick: () => app.showWordCount() },
|
|
164
|
+
];
|
|
56
165
|
}
|
|
57
166
|
|
|
58
|
-
|
|
167
|
+
viewItems() {
|
|
59
168
|
const app = this.app;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
169
|
+
return [
|
|
170
|
+
{ label: '普通', checked: app.view === 'normal', onClick: () => app.setView('normal') },
|
|
171
|
+
{ label: '幻灯片浏览', checked: app.view === 'sorter', onClick: () => app.setView('sorter') },
|
|
172
|
+
{ label: '阅读视图', checked: app.view === 'reading', onClick: () => app.setView('reading') },
|
|
173
|
+
{ divided: true },
|
|
174
|
+
{ label: '网格线', checked: app.gridVisible, onClick: () => app.toggleGrid() },
|
|
175
|
+
{ label: '参考线', checked: app.guidesVisible, onClick: () => app.toggleGuides() },
|
|
176
|
+
{ label: '备注', checked: app.notesVisible, onClick: () => app.toggleNotes() },
|
|
177
|
+
{ label: '设置形状格式窗格', checked: app.formatPaneOpen, onClick: () => app.toggleFormatPane() },
|
|
178
|
+
{ divided: true },
|
|
179
|
+
{ label: '适应窗口', onClick: () => app.fitToWindow() },
|
|
180
|
+
{ label: '放大', shortcut: 'Ctrl+=', onClick: () => app.setZoom(app.zoom + 10) },
|
|
181
|
+
{ label: '缩小', shortcut: 'Ctrl+-', onClick: () => app.setZoom(app.zoom - 10) },
|
|
182
|
+
{ divided: true },
|
|
183
|
+
{ label: '关于挂逼演示…', onClick: () => this.showAbout() },
|
|
184
|
+
];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
showAbout() {
|
|
188
|
+
openModal({
|
|
189
|
+
title: '关于',
|
|
190
|
+
width: 400,
|
|
191
|
+
confirmText: '知道了',
|
|
192
|
+
build: (body) => {
|
|
193
|
+
const p = el('div', 'pp-about');
|
|
194
|
+
p.innerHTML = `${icon('logo', 40)}<h3>挂逼演示 gbpptx</h3><p>真实的 .pptx 读写 + Office 式演示编辑器。</p><p class="pp-muted">Pptx 文件进入 → 查看/编辑 → 原样导出</p>`;
|
|
195
|
+
body.appendChild(p);
|
|
196
|
+
},
|
|
85
197
|
});
|
|
86
198
|
}
|
|
87
199
|
|
|
200
|
+
/* ===================== 状态刷新 ===================== */
|
|
201
|
+
|
|
88
202
|
refresh() {
|
|
89
203
|
const app = this.app;
|
|
90
204
|
this.nameEl.textContent = app.doc.name || '新建演示';
|
|
205
|
+
this.nameEl.title = this.nameEl.textContent;
|
|
91
206
|
document.title = `${this.nameEl.textContent} - 挂逼演示`;
|
|
92
207
|
this.stateEl.textContent = app.dirty
|
|
93
|
-
? '
|
|
94
|
-
: app.doc.handle ? '
|
|
95
|
-
this.stateEl.classList.toggle('is-dirty', app.dirty);
|
|
96
|
-
this.saveBtn.disabled = !app.snapshot.slides.length;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
this.
|
|
208
|
+
? '未保存'
|
|
209
|
+
: app.doc.handle ? '已保存' : (app.doc.savedAt ? '已保存副本' : '尚未保存');
|
|
210
|
+
this.stateEl.classList.toggle('gbp-is-dirty', app.dirty);
|
|
211
|
+
this.saveBtn.disabled = app.readOnly || !app.snapshot.slides.length;
|
|
212
|
+
// 只读档锁掉纯编辑类菜单,放映/视图与文件菜单里的导出/打印照常可用
|
|
213
|
+
const writeMenus = new Set(['edit', 'insert', 'slide', 'review']);
|
|
214
|
+
this.el.querySelectorAll('[data-menu]').forEach((btn) => {
|
|
215
|
+
btn.disabled = app.readOnly && writeMenus.has(btn.dataset.menu);
|
|
216
|
+
});
|
|
100
217
|
}
|
|
101
218
|
}
|
package/web/app/ui/transition.js
CHANGED
|
@@ -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,24 @@
|
|
|
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" />
|
|
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
9
|
<link rel="stylesheet" href="/web/styles/office.css" />
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
<link rel="stylesheet" href="/vendor/gbofficeui/office-chrome.css" />
|
|
11
|
+
<script type="importmap">
|
|
12
|
+
{
|
|
13
|
+
"imports": {
|
|
14
|
+
"gbooxml": "/vendor/gbooxml/index.js",
|
|
15
|
+
"guabiutils": "/vendor/guabiutils/index.js"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<div id="app" class="gbp-root"></div>
|
|
22
|
+
<script type="module" src="/web/app/main.js"></script>
|
|
23
|
+
</body>
|
|
24
|
+
</html>
|