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,76 +1,58 @@
|
|
|
1
|
-
// [文件] gbpptx·色板 —— 预设色格 + 系统色轮 + Hex +
|
|
2
|
-
import { openPopup } from './popup.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
apply
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
handle.close();
|
|
60
|
-
onPick(/^#?[0-9a-f]{6}$/i.test(v) ? (v.startsWith('#') ? v : `#${v}`) : '');
|
|
61
|
-
});
|
|
62
|
-
actions.appendChild(apply);
|
|
63
|
-
if (allowNone) {
|
|
64
|
-
const clear = document.createElement('button');
|
|
65
|
-
clear.type = 'button';
|
|
66
|
-
clear.className = 'gb-btn';
|
|
67
|
-
clear.textContent = noneLabel;
|
|
68
|
-
clear.addEventListener('mousedown', (e) => e.preventDefault());
|
|
69
|
-
clear.addEventListener('click', () => { handle.close(); onPick(''); });
|
|
70
|
-
actions.appendChild(clear);
|
|
71
|
-
}
|
|
72
|
-
box.appendChild(actions);
|
|
73
|
-
|
|
74
|
-
const handle = openPopup({ anchor, content: box, placement: 'bottom-start', className: 'gb-popup--color' });
|
|
75
|
-
return handle;
|
|
76
|
-
}
|
|
1
|
+
// [文件] gbpptx·色板 —— 预设色格 + 系统色轮 + Hex + 清除
|
|
2
|
+
import { openPopup } from './popup.js';
|
|
3
|
+
|
|
4
|
+
/** 打开色板;onPick(color) 回调(清除传空串) */
|
|
5
|
+
export function openColorPanel({ anchor, colors, value, title = '颜色', columns = 10, onPick }) {
|
|
6
|
+
const box = document.createElement('div');
|
|
7
|
+
box.className = 'gbp-color';
|
|
8
|
+
const grid = document.createElement('div');
|
|
9
|
+
grid.className = 'gbp-color__grid';
|
|
10
|
+
grid.style.gridTemplateColumns = `repeat(${columns}, 18px)`;
|
|
11
|
+
for (const color of colors) {
|
|
12
|
+
const sw = document.createElement('button');
|
|
13
|
+
sw.type = 'button';
|
|
14
|
+
sw.className = 'gbp-color__swatch';
|
|
15
|
+
sw.style.background = color;
|
|
16
|
+
if (value && String(value).toLowerCase() === color.toLowerCase()) sw.classList.add('gbp-is-active');
|
|
17
|
+
sw.title = color;
|
|
18
|
+
sw.addEventListener('click', () => { handle.close(); onPick(color); });
|
|
19
|
+
grid.appendChild(sw);
|
|
20
|
+
}
|
|
21
|
+
box.appendChild(grid);
|
|
22
|
+
|
|
23
|
+
const custom = document.createElement('div');
|
|
24
|
+
custom.className = 'gbp-color__custom';
|
|
25
|
+
const wheel = document.createElement('input');
|
|
26
|
+
wheel.type = 'color';
|
|
27
|
+
wheel.value = /^#[0-9a-f]{6}$/i.test(value || '') ? value : '#000000';
|
|
28
|
+
const hex = document.createElement('input');
|
|
29
|
+
hex.type = 'text';
|
|
30
|
+
hex.className = 'gbp-input';
|
|
31
|
+
hex.value = value || '';
|
|
32
|
+
hex.placeholder = '#rrggbb';
|
|
33
|
+
wheel.addEventListener('input', () => { hex.value = wheel.value; });
|
|
34
|
+
custom.append(wheel, hex);
|
|
35
|
+
box.appendChild(custom);
|
|
36
|
+
|
|
37
|
+
const actions = document.createElement('div');
|
|
38
|
+
actions.className = 'gbp-color__actions';
|
|
39
|
+
const apply = document.createElement('button');
|
|
40
|
+
apply.type = 'button';
|
|
41
|
+
apply.className = 'gbp-btn gbp-btn--primary';
|
|
42
|
+
apply.textContent = '应用';
|
|
43
|
+
const clear = document.createElement('button');
|
|
44
|
+
clear.type = 'button';
|
|
45
|
+
clear.className = 'gbp-btn';
|
|
46
|
+
clear.textContent = '清除';
|
|
47
|
+
apply.addEventListener('click', () => {
|
|
48
|
+
const v = String(hex.value || '').trim();
|
|
49
|
+
handle.close();
|
|
50
|
+
onPick(/^#?[0-9a-f]{6}$/i.test(v) ? (v.startsWith('#') ? v : `#${v}`) : '');
|
|
51
|
+
});
|
|
52
|
+
clear.addEventListener('click', () => { handle.close(); onPick(''); });
|
|
53
|
+
actions.append(apply, clear);
|
|
54
|
+
box.appendChild(actions);
|
|
55
|
+
|
|
56
|
+
const handle = openPopup({ anchor, content: box, placement: 'bottom-start', className: 'gbp-popup--color' });
|
|
57
|
+
return handle;
|
|
58
|
+
}
|
package/web/app/ui/dialogs.js
CHANGED
|
@@ -1,159 +1,120 @@
|
|
|
1
|
-
// [文件] gbpptx·对话框 —— 通用模态 + 单字段输入(供背景色/尺寸/页主题等表单复用)
|
|
2
|
-
|
|
3
|
-
/** 通用模态:build(bodyEl, close) 填充内容;onConfirm() 返回 false 可阻止关闭;onClose 在任意方式关闭后调用 */
|
|
4
|
-
export function openModal({ title, build, onConfirm, onClose, confirmText = '确定', width = 420
|
|
5
|
-
const overlay = document.createElement('div');
|
|
6
|
-
overlay.className = '
|
|
7
|
-
const box = document.createElement('div');
|
|
8
|
-
box.className = '
|
|
9
|
-
box.style.width = `${width}px`;
|
|
10
|
-
box.innerHTML = `
|
|
11
|
-
<div class="
|
|
12
|
-
<div class="
|
|
13
|
-
<div class="
|
|
14
|
-
<button type="button" class="
|
|
15
|
-
<button type="button" class="
|
|
16
|
-
</div>`;
|
|
17
|
-
box.querySelector('.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
box.querySelector('[data-act="
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
span
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
input.
|
|
66
|
-
input.
|
|
67
|
-
input
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
input.
|
|
75
|
-
input.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
input
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
opt
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
p.textContent = message;
|
|
122
|
-
body.appendChild(p);
|
|
123
|
-
},
|
|
124
|
-
onConfirm: () => {
|
|
125
|
-
value = true;
|
|
126
|
-
},
|
|
127
|
-
confirmText,
|
|
128
|
-
danger,
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** 询问一个文本值(确认返回字符串,取消返回 null) */
|
|
134
|
-
export function promptText({ title, label, value = '', placeholder = '' }) {
|
|
135
|
-
return new Promise((resolve) => {
|
|
136
|
-
let input = null;
|
|
137
|
-
let done = false;
|
|
138
|
-
openModal({
|
|
139
|
-
title: title || label || '输入',
|
|
140
|
-
width: 360,
|
|
141
|
-
onClose: () => { if (!done) resolve(null); },
|
|
142
|
-
build: (body) => {
|
|
143
|
-
input = textInput(value, placeholder);
|
|
144
|
-
body.appendChild(field(label || '', input));
|
|
145
|
-
requestAnimationFrame(() => { input.focus(); input.select(); });
|
|
146
|
-
input.addEventListener('keydown', (e) => {
|
|
147
|
-
if (e.key === 'Enter') {
|
|
148
|
-
e.preventDefault();
|
|
149
|
-
body.closest('.gb-modal').querySelector('[data-act="ok"]').click();
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
},
|
|
153
|
-
onConfirm: () => {
|
|
154
|
-
done = true;
|
|
155
|
-
resolve(input ? input.value : '');
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
}
|
|
1
|
+
// [文件] gbpptx·对话框 —— 通用模态 + 单字段输入(供背景色/尺寸/页主题等表单复用)
|
|
2
|
+
|
|
3
|
+
/** 通用模态:build(bodyEl, close) 填充内容;onConfirm() 返回 false 可阻止关闭;onClose 在任意方式关闭后调用 */
|
|
4
|
+
export function openModal({ title, build, onConfirm, onClose, confirmText = '确定', width = 420 }) {
|
|
5
|
+
const overlay = document.createElement('div');
|
|
6
|
+
overlay.className = 'gbp-modal-overlay';
|
|
7
|
+
const box = document.createElement('div');
|
|
8
|
+
box.className = 'gbp-modal';
|
|
9
|
+
box.style.width = `${width}px`;
|
|
10
|
+
box.innerHTML = `
|
|
11
|
+
<div class="gbp-modal__head"><span class="gbp-modal__title"></span><button type="button" class="gbp-modal__close">✕</button></div>
|
|
12
|
+
<div class="gbp-modal__body"></div>
|
|
13
|
+
<div class="gbp-modal__foot">
|
|
14
|
+
<button type="button" class="gbp-btn" data-act="cancel">取消</button>
|
|
15
|
+
<button type="button" class="gbp-btn gbp-btn--primary" data-act="ok"></button>
|
|
16
|
+
</div>`;
|
|
17
|
+
box.querySelector('.gbp-modal__title').textContent = title;
|
|
18
|
+
box.querySelector('[data-act="ok"]').textContent = confirmText;
|
|
19
|
+
const bodyEl = box.querySelector('.gbp-modal__body');
|
|
20
|
+
|
|
21
|
+
let closed = false;
|
|
22
|
+
const close = () => {
|
|
23
|
+
if (closed) return;
|
|
24
|
+
closed = true;
|
|
25
|
+
document.removeEventListener('keydown', onKey, true);
|
|
26
|
+
overlay.remove();
|
|
27
|
+
onClose?.();
|
|
28
|
+
};
|
|
29
|
+
const onKey = (e) => {
|
|
30
|
+
if (e.key === 'Escape') {
|
|
31
|
+
e.stopPropagation();
|
|
32
|
+
close();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const confirm = () => {
|
|
36
|
+
if (onConfirm && onConfirm() === false) return;
|
|
37
|
+
close();
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
box.querySelector('[data-act="cancel"]').addEventListener('click', close);
|
|
41
|
+
box.querySelector('.gbp-modal__close').addEventListener('click', close);
|
|
42
|
+
box.querySelector('[data-act="ok"]').addEventListener('click', confirm);
|
|
43
|
+
overlay.addEventListener('mousedown', (e) => { if (e.target === overlay) close(); });
|
|
44
|
+
document.addEventListener('keydown', onKey, true);
|
|
45
|
+
build?.(bodyEl, close);
|
|
46
|
+
overlay.appendChild(box);
|
|
47
|
+
document.body.appendChild(overlay);
|
|
48
|
+
return { close };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function field(labelText, control) {
|
|
52
|
+
const row = document.createElement('label');
|
|
53
|
+
row.className = 'gbp-field';
|
|
54
|
+
const span = document.createElement('span');
|
|
55
|
+
span.className = 'gbp-field__label';
|
|
56
|
+
span.textContent = labelText;
|
|
57
|
+
row.append(span, control);
|
|
58
|
+
return row;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function textInput(value = '', placeholder = '') {
|
|
62
|
+
const input = document.createElement('input');
|
|
63
|
+
input.type = 'text';
|
|
64
|
+
input.className = 'gbp-input';
|
|
65
|
+
input.value = value;
|
|
66
|
+
input.placeholder = placeholder;
|
|
67
|
+
return input;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function numberInput(value, { min, max, step = 1 } = {}) {
|
|
71
|
+
const input = document.createElement('input');
|
|
72
|
+
input.type = 'number';
|
|
73
|
+
input.className = 'gbp-input';
|
|
74
|
+
if (min !== undefined) input.min = min;
|
|
75
|
+
if (max !== undefined) input.max = max;
|
|
76
|
+
input.step = step;
|
|
77
|
+
input.value = value;
|
|
78
|
+
return input;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function selectInput(options, value) {
|
|
82
|
+
const sel = document.createElement('select');
|
|
83
|
+
sel.className = 'gbp-input';
|
|
84
|
+
for (const o of options) {
|
|
85
|
+
const opt = document.createElement('option');
|
|
86
|
+
opt.value = o.value;
|
|
87
|
+
opt.textContent = o.label;
|
|
88
|
+
sel.appendChild(opt);
|
|
89
|
+
}
|
|
90
|
+
sel.value = value ?? '';
|
|
91
|
+
return sel;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** 询问一个文本值(确认返回字符串,取消返回 null) */
|
|
95
|
+
export function promptText({ title, label, value = '', placeholder = '' }) {
|
|
96
|
+
return new Promise((resolve) => {
|
|
97
|
+
let input = null;
|
|
98
|
+
let done = false;
|
|
99
|
+
openModal({
|
|
100
|
+
title: title || label || '输入',
|
|
101
|
+
width: 360,
|
|
102
|
+
onClose: () => { if (!done) resolve(null); },
|
|
103
|
+
build: (body) => {
|
|
104
|
+
input = textInput(value, placeholder);
|
|
105
|
+
body.appendChild(field(label || '', input));
|
|
106
|
+
requestAnimationFrame(() => { input.focus(); input.select(); });
|
|
107
|
+
input.addEventListener('keydown', (e) => {
|
|
108
|
+
if (e.key === 'Enter') {
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
body.closest('.gbp-modal').querySelector('[data-act="ok"]').click();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
onConfirm: () => {
|
|
115
|
+
done = true;
|
|
116
|
+
resolve(input ? input.value : '');
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|