gbpptx 0.1.1 → 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.
- package/README.md +220 -158
- package/package.json +15 -4
- package/src/index.js +16 -8
- package/src/kernel/model.js +397 -91
- package/src/kernel/parts.js +3 -3
- package/src/kernel/pptx.js +17 -12
- package/src/kernel/read.js +747 -157
- package/src/kernel/roundtrip.js +118 -18
- package/src/kernel/text.js +133 -28
- package/src/kernel/write.js +160 -49
- 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 +243 -0
- package/web/app/slides/find.js +199 -0
- package/web/app/slides/history.js +100 -0
- package/web/app/slides/keys.js +174 -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 +130 -0
- package/web/app/slides-app.js +285 -844
- package/web/app/ui/backstage.js +255 -0
- package/web/app/ui/canvas.js +762 -277
- package/web/app/ui/color-panel.js +58 -58
- package/web/app/ui/dialogs.js +120 -120
- package/web/app/ui/file-io.js +116 -89
- package/web/app/ui/format-pane.js +427 -0
- package/web/app/ui/icons.js +129 -0
- package/web/app/ui/menu.js +75 -105
- package/web/app/ui/notify.js +45 -45
- package/web/app/ui/page-view.js +221 -150
- package/web/app/ui/popup.js +80 -80
- package/web/app/ui/present.js +292 -100
- package/web/app/ui/ribbon.js +878 -0
- package/web/app/ui/slide-pane.js +189 -0
- package/web/app/ui/statusbar.js +93 -0
- package/web/app/ui/text-styles.js +84 -84
- package/web/app/ui/titlebar.js +208 -0
- package/web/app/ui/transition.js +30 -0
- package/web/index.html +23 -21
- package/web/serve.mjs +20 -67
- package/web/styles/office.css +642 -0
- package/web/styles/slides.css +210 -212
- package/web/styles/tokens.css +154 -155
- package/src/kernel/menus.js +0 -123
- package/src/kernel/util/escape.js +0 -21
- package/src/kernel/util/id.js +0 -13
- package/web/app/ui/inspector.js +0 -209
- package/web/app/ui/slides-bar.js +0 -63
- package/web/app/ui/toolbar.js +0 -200
package/web/app/ui/menu.js
CHANGED
|
@@ -1,105 +1,75 @@
|
|
|
1
|
-
// [文件] gbpptx·菜单 —— 菜单栏 + 下拉/右键菜单渲染(条目口径:label/disabled/checked/danger/shortcut/divided/children/onClick)
|
|
2
|
-
import { openPopup, closeAll } from './popup.js';
|
|
3
|
-
|
|
4
|
-
const CHECK = '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12l5 5L20 7"/></svg>';
|
|
5
|
-
const SUB = '<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 6l6 6-6 6"/></svg>';
|
|
6
|
-
|
|
7
|
-
/** 构建条目列表 DOM(子菜单在 hover 时另开浮层) */
|
|
8
|
-
function buildList(items) {
|
|
9
|
-
const ul = document.createElement('div');
|
|
10
|
-
ul.className = '
|
|
11
|
-
let subHandle = null;
|
|
12
|
-
const closeSub = () => { subHandle?.close(); subHandle = null; };
|
|
13
|
-
for (const item of items || []) {
|
|
14
|
-
if (item.divided) {
|
|
15
|
-
const sep = document.createElement('div');
|
|
16
|
-
sep.className = '
|
|
17
|
-
ul.appendChild(sep);
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
const row = document.createElement('div');
|
|
21
|
-
row.className = '
|
|
22
|
-
if (item.disabled) row.classList.add('is-disabled');
|
|
23
|
-
if (item.danger) row.classList.add('is-danger');
|
|
24
|
-
if (item.checked) row.classList.add('is-checked');
|
|
25
|
-
const lead = document.createElement('span');
|
|
26
|
-
lead.className = '
|
|
27
|
-
lead.innerHTML = item.checked ? CHECK : (item.colorDot ? `<i class="
|
|
28
|
-
row.appendChild(lead);
|
|
29
|
-
const label = document.createElement('span');
|
|
30
|
-
label.className = '
|
|
31
|
-
label.textContent = item.label;
|
|
32
|
-
row.appendChild(label);
|
|
33
|
-
if (item.shortcut) {
|
|
34
|
-
const sc = document.createElement('span');
|
|
35
|
-
sc.className = '
|
|
36
|
-
sc.textContent = item.shortcut;
|
|
37
|
-
row.appendChild(sc);
|
|
38
|
-
}
|
|
39
|
-
if (item.children) {
|
|
40
|
-
const arrow = document.createElement('span');
|
|
41
|
-
arrow.className = '
|
|
42
|
-
arrow.innerHTML = SUB;
|
|
43
|
-
row.appendChild(arrow);
|
|
44
|
-
let timer = 0;
|
|
45
|
-
row.addEventListener('mouseenter', () => {
|
|
46
|
-
clearTimeout(timer);
|
|
47
|
-
timer = setTimeout(() => {
|
|
48
|
-
closeSub();
|
|
49
|
-
if (item.disabled) return;
|
|
50
|
-
subHandle = openPopup({ anchor: row.getBoundingClientRect(), content: buildList(item.children), placement: 'right-start', className: '
|
|
51
|
-
}, 60);
|
|
52
|
-
});
|
|
53
|
-
row.addEventListener('mouseleave', () => clearTimeout(timer));
|
|
54
|
-
} else {
|
|
55
|
-
row.addEventListener('click', (e) => {
|
|
56
|
-
if (item.disabled) return;
|
|
57
|
-
item.onClick?.(e);
|
|
58
|
-
document.dispatchEvent(new CustomEvent('gbpptx-menu-close'));
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
ul.appendChild(row);
|
|
62
|
-
}
|
|
63
|
-
return ul;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** 打开下拉菜单(锚点元素/矩形) */
|
|
67
|
-
export const openMenu = ({ anchor, items, placement = 'bottom-start' }) =>
|
|
68
|
-
openPopup({ anchor, content: buildList(items), placement, className: '
|
|
69
|
-
|
|
70
|
-
/** 打开右键菜单(客户端坐标) */
|
|
71
|
-
export const openContextMenu = ({ x, y, items }) =>
|
|
72
|
-
openPopup({ anchor: { left: x, top: y, right: x, bottom: y }, content: buildList(items), placement: 'bottom-start', className: '
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
export
|
|
76
|
-
const bar = document.createElement('div');
|
|
77
|
-
bar.className = 'sl-menubar';
|
|
78
|
-
for (const menu of menus) {
|
|
79
|
-
const btn = document.createElement('button');
|
|
80
|
-
btn.type = 'button';
|
|
81
|
-
btn.className = 'sl-menubar__btn';
|
|
82
|
-
btn.textContent = menu.label;
|
|
83
|
-
btn.addEventListener('click', () => {
|
|
84
|
-
const handle = openMenu({ anchor: btn, items: menu.items(), placement: 'bottom-start' });
|
|
85
|
-
btn.classList.add('is-open');
|
|
86
|
-
const clear = () => {
|
|
87
|
-
btn.classList.remove('is-open');
|
|
88
|
-
document.removeEventListener('gbpptx-menu-close', clear);
|
|
89
|
-
};
|
|
90
|
-
document.addEventListener('gbpptx-menu-close', clear);
|
|
91
|
-
const obs = new MutationObserver(() => {
|
|
92
|
-
if (!handle.el.isConnected) {
|
|
93
|
-
btn.classList.remove('is-open');
|
|
94
|
-
obs.disconnect();
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
obs.observe(document.body, { childList: true });
|
|
98
|
-
});
|
|
99
|
-
bar.appendChild(btn);
|
|
100
|
-
}
|
|
101
|
-
return bar;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** 关闭当前全部菜单/浮层(外部动作前调用) */
|
|
105
|
-
export { closeAll };
|
|
1
|
+
// [文件] gbpptx·菜单 —— 菜单栏 + 下拉/右键菜单渲染(条目口径:label/disabled/checked/danger/shortcut/divided/children/onClick)
|
|
2
|
+
import { openPopup, closeAll } from './popup.js';
|
|
3
|
+
|
|
4
|
+
const CHECK = '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12l5 5L20 7"/></svg>';
|
|
5
|
+
const SUB = '<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 6l6 6-6 6"/></svg>';
|
|
6
|
+
|
|
7
|
+
/** 构建条目列表 DOM(子菜单在 hover 时另开浮层) */
|
|
8
|
+
function buildList(items) {
|
|
9
|
+
const ul = document.createElement('div');
|
|
10
|
+
ul.className = 'gbp-menu__list';
|
|
11
|
+
let subHandle = null;
|
|
12
|
+
const closeSub = () => { subHandle?.close(); subHandle = null; };
|
|
13
|
+
for (const item of items || []) {
|
|
14
|
+
if (item.divided) {
|
|
15
|
+
const sep = document.createElement('div');
|
|
16
|
+
sep.className = 'gbp-menu__sep';
|
|
17
|
+
ul.appendChild(sep);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const row = document.createElement('div');
|
|
21
|
+
row.className = 'gbp-menu__item';
|
|
22
|
+
if (item.disabled) row.classList.add('gbp-is-disabled');
|
|
23
|
+
if (item.danger) row.classList.add('gbp-is-danger');
|
|
24
|
+
if (item.checked) row.classList.add('gbp-is-checked');
|
|
25
|
+
const lead = document.createElement('span');
|
|
26
|
+
lead.className = 'gbp-menu__lead';
|
|
27
|
+
lead.innerHTML = item.checked ? CHECK : (item.colorDot ? `<i class="gbp-menu__dot" style="background:${item.colorDot}"></i>` : '');
|
|
28
|
+
row.appendChild(lead);
|
|
29
|
+
const label = document.createElement('span');
|
|
30
|
+
label.className = 'gbp-menu__label';
|
|
31
|
+
label.textContent = item.label;
|
|
32
|
+
row.appendChild(label);
|
|
33
|
+
if (item.shortcut) {
|
|
34
|
+
const sc = document.createElement('span');
|
|
35
|
+
sc.className = 'gbp-menu__shortcut';
|
|
36
|
+
sc.textContent = item.shortcut;
|
|
37
|
+
row.appendChild(sc);
|
|
38
|
+
}
|
|
39
|
+
if (item.children) {
|
|
40
|
+
const arrow = document.createElement('span');
|
|
41
|
+
arrow.className = 'gbp-menu__arrow';
|
|
42
|
+
arrow.innerHTML = SUB;
|
|
43
|
+
row.appendChild(arrow);
|
|
44
|
+
let timer = 0;
|
|
45
|
+
row.addEventListener('mouseenter', () => {
|
|
46
|
+
clearTimeout(timer);
|
|
47
|
+
timer = setTimeout(() => {
|
|
48
|
+
closeSub();
|
|
49
|
+
if (item.disabled) return;
|
|
50
|
+
subHandle = openPopup({ anchor: row.getBoundingClientRect(), content: buildList(item.children), placement: 'right-start', className: 'gbp-menu' });
|
|
51
|
+
}, 60);
|
|
52
|
+
});
|
|
53
|
+
row.addEventListener('mouseleave', () => clearTimeout(timer));
|
|
54
|
+
} else {
|
|
55
|
+
row.addEventListener('click', (e) => {
|
|
56
|
+
if (item.disabled) return;
|
|
57
|
+
item.onClick?.(e);
|
|
58
|
+
document.dispatchEvent(new CustomEvent('gbpptx-menu-close'));
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
ul.appendChild(row);
|
|
62
|
+
}
|
|
63
|
+
return ul;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** 打开下拉菜单(锚点元素/矩形) */
|
|
67
|
+
export const openMenu = ({ anchor, items, placement = 'bottom-start', onClose }) =>
|
|
68
|
+
openPopup({ anchor, content: buildList(items), placement, className: 'gbp-menu', onClose });
|
|
69
|
+
|
|
70
|
+
/** 打开右键菜单(客户端坐标) */
|
|
71
|
+
export const openContextMenu = ({ x, y, items }) =>
|
|
72
|
+
openPopup({ anchor: { left: x, top: y, right: x, bottom: y }, content: buildList(items), placement: 'bottom-start', className: 'gbp-menu' });
|
|
73
|
+
|
|
74
|
+
/** 关闭当前全部菜单/浮层(外部动作前调用) */
|
|
75
|
+
export { closeAll };
|
package/web/app/ui/notify.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
// [文件] gbpptx·notify —— 轻量 toast 通知(success / error / warning / info)
|
|
2
|
-
|
|
3
|
-
const HOST_ID = 'gbpptx-notify-host';
|
|
4
|
-
const ICONS = { success: '✓', error: '✕', warning: '!', info: 'i' };
|
|
5
|
-
|
|
6
|
-
function host() {
|
|
7
|
-
let el = document.getElementById(HOST_ID);
|
|
8
|
-
if (!el) {
|
|
9
|
-
el = document.createElement('div');
|
|
10
|
-
el.id = HOST_ID;
|
|
11
|
-
el.className = 'gbdocs-notify-host';
|
|
12
|
-
document.body.appendChild(el);
|
|
13
|
-
}
|
|
14
|
-
return el;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function show(type, message, duration = 2600) {
|
|
18
|
-
const root = host();
|
|
19
|
-
const item = document.createElement('div');
|
|
20
|
-
item.className = `
|
|
21
|
-
const badge = document.createElement('span');
|
|
22
|
-
badge.className = '
|
|
23
|
-
badge.textContent = ICONS[type] || 'i';
|
|
24
|
-
const text = document.createElement('span');
|
|
25
|
-
text.className = '
|
|
26
|
-
text.textContent = String(message ?? '');
|
|
27
|
-
item.append(badge, text);
|
|
28
|
-
root.appendChild(item);
|
|
29
|
-
requestAnimationFrame(() => item.classList.add('is-in'));
|
|
30
|
-
const close = () => {
|
|
31
|
-
item.classList.remove('is-in');
|
|
32
|
-
setTimeout(() => item.remove(), 200);
|
|
33
|
-
};
|
|
34
|
-
item.addEventListener('click', close);
|
|
35
|
-
if (duration > 0) setTimeout(close, duration);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const notify = {
|
|
39
|
-
success: (m, d) => show('success', m, d),
|
|
40
|
-
error: (m, d) => show('error', m, d ?? 3600),
|
|
41
|
-
warning: (m, d) => show('warning', m, d ?? 3200),
|
|
42
|
-
info: (m, d) => show('info', m, d),
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export default notify;
|
|
1
|
+
// [文件] gbpptx·notify —— 轻量 toast 通知(success / error / warning / info)
|
|
2
|
+
|
|
3
|
+
const HOST_ID = 'gbpptx-notify-host';
|
|
4
|
+
const ICONS = { success: '✓', error: '✕', warning: '!', info: 'i' };
|
|
5
|
+
|
|
6
|
+
function host() {
|
|
7
|
+
let el = document.getElementById(HOST_ID);
|
|
8
|
+
if (!el) {
|
|
9
|
+
el = document.createElement('div');
|
|
10
|
+
el.id = HOST_ID;
|
|
11
|
+
el.className = 'gbdocs-notify-host';
|
|
12
|
+
document.body.appendChild(el);
|
|
13
|
+
}
|
|
14
|
+
return el;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function show(type, message, duration = 2600) {
|
|
18
|
+
const root = host();
|
|
19
|
+
const item = document.createElement('div');
|
|
20
|
+
item.className = `gbp-notify gbp-notify--${type}`;
|
|
21
|
+
const badge = document.createElement('span');
|
|
22
|
+
badge.className = 'gbp-notify__badge';
|
|
23
|
+
badge.textContent = ICONS[type] || 'i';
|
|
24
|
+
const text = document.createElement('span');
|
|
25
|
+
text.className = 'gbp-notify__text';
|
|
26
|
+
text.textContent = String(message ?? '');
|
|
27
|
+
item.append(badge, text);
|
|
28
|
+
root.appendChild(item);
|
|
29
|
+
requestAnimationFrame(() => item.classList.add('gbp-is-in'));
|
|
30
|
+
const close = () => {
|
|
31
|
+
item.classList.remove('gbp-is-in');
|
|
32
|
+
setTimeout(() => item.remove(), 200);
|
|
33
|
+
};
|
|
34
|
+
item.addEventListener('click', close);
|
|
35
|
+
if (duration > 0) setTimeout(close, duration);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const notify = {
|
|
39
|
+
success: (m, d) => show('success', m, d),
|
|
40
|
+
error: (m, d) => show('error', m, d ?? 3600),
|
|
41
|
+
warning: (m, d) => show('warning', m, d ?? 3200),
|
|
42
|
+
info: (m, d) => show('info', m, d),
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default notify;
|