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.
Files changed (55) hide show
  1. package/README.md +220 -158
  2. package/package.json +15 -4
  3. package/src/index.js +16 -8
  4. package/src/kernel/model.js +397 -91
  5. package/src/kernel/parts.js +3 -3
  6. package/src/kernel/pptx.js +17 -12
  7. package/src/kernel/read.js +747 -157
  8. package/src/kernel/roundtrip.js +118 -18
  9. package/src/kernel/text.js +133 -28
  10. package/src/kernel/write.js +160 -49
  11. package/web/app/main.js +8 -8
  12. package/web/app/slides/arrange.js +101 -0
  13. package/web/app/slides/clipboard.js +93 -0
  14. package/web/app/slides/file.js +243 -0
  15. package/web/app/slides/find.js +199 -0
  16. package/web/app/slides/history.js +100 -0
  17. package/web/app/slides/keys.js +174 -0
  18. package/web/app/slides/menus.js +105 -0
  19. package/web/app/slides/objects.js +254 -0
  20. package/web/app/slides/render.js +183 -0
  21. package/web/app/slides/shared.js +85 -0
  22. package/web/app/slides/slides.js +103 -0
  23. package/web/app/slides/table.js +102 -0
  24. package/web/app/slides/text.js +418 -0
  25. package/web/app/slides/view.js +130 -0
  26. package/web/app/slides-app.js +285 -844
  27. package/web/app/ui/backstage.js +255 -0
  28. package/web/app/ui/canvas.js +762 -277
  29. package/web/app/ui/color-panel.js +58 -58
  30. package/web/app/ui/dialogs.js +120 -120
  31. package/web/app/ui/file-io.js +116 -89
  32. package/web/app/ui/format-pane.js +427 -0
  33. package/web/app/ui/icons.js +129 -0
  34. package/web/app/ui/menu.js +75 -105
  35. package/web/app/ui/notify.js +45 -45
  36. package/web/app/ui/page-view.js +221 -150
  37. package/web/app/ui/popup.js +80 -80
  38. package/web/app/ui/present.js +292 -100
  39. package/web/app/ui/ribbon.js +878 -0
  40. package/web/app/ui/slide-pane.js +189 -0
  41. package/web/app/ui/statusbar.js +93 -0
  42. package/web/app/ui/text-styles.js +84 -84
  43. package/web/app/ui/titlebar.js +208 -0
  44. package/web/app/ui/transition.js +30 -0
  45. package/web/index.html +23 -21
  46. package/web/serve.mjs +20 -67
  47. package/web/styles/office.css +642 -0
  48. package/web/styles/slides.css +210 -212
  49. package/web/styles/tokens.css +154 -155
  50. package/src/kernel/menus.js +0 -123
  51. package/src/kernel/util/escape.js +0 -21
  52. package/src/kernel/util/id.js +0 -13
  53. package/web/app/ui/inspector.js +0 -209
  54. package/web/app/ui/slides-bar.js +0 -63
  55. package/web/app/ui/toolbar.js +0 -200
@@ -0,0 +1,427 @@
1
+ // [文件] gbpptx·格式窗格 —— Office「设置形状格式」任务窗格(大小/填充/线条/文本/图片/表格)
2
+
3
+ import { SLIDE_SIZES, TABLE_STYLES, THEME_KEYS, TRANSITIONS, THEMES, themeOf } from '../../../src/kernel/model.js';
4
+ import { FONT_FAMILIES, TEXT_COLORS } from './text-styles.js';
5
+ import { openColorPanel } from './color-panel.js';
6
+ import { icon } from './icons.js';
7
+
8
+ const el = (tag, cls, text) => {
9
+ const node = document.createElement(tag);
10
+ if (cls) node.className = cls;
11
+ if (text != null) node.textContent = text;
12
+ return node;
13
+ };
14
+
15
+ const field = (label, control) => {
16
+ const row = el('label', 'pp-fp-field');
17
+ const span = el('span', 'pp-fp-field__label', label);
18
+ row.append(span, control);
19
+ return row;
20
+ };
21
+
22
+ const numberInput = (value, onChange, { min = -10000, max = 10000, step = 1 } = {}) => {
23
+ const input = el('input', 'pp-input pp-input--num');
24
+ input.type = 'number';
25
+ input.min = String(min);
26
+ input.max = String(max);
27
+ input.step = String(step);
28
+ input.value = String(Math.round(value * 100) / 100);
29
+ input.addEventListener('change', () => {
30
+ const v = Number(input.value);
31
+ if (Number.isFinite(v)) onChange(v);
32
+ });
33
+ input.addEventListener('keydown', (e) => { if (e.key === 'Enter') input.blur(); });
34
+ return input;
35
+ };
36
+
37
+ const selectInput = (options, value, onChange) => {
38
+ const sel = el('select', 'pp-input');
39
+ for (const o of options) {
40
+ const opt = document.createElement('option');
41
+ opt.value = o.value;
42
+ opt.textContent = o.label;
43
+ sel.appendChild(opt);
44
+ }
45
+ sel.value = value ?? '';
46
+ sel.addEventListener('change', () => onChange(sel.value));
47
+ return sel;
48
+ };
49
+
50
+ const toggleButton = (label, on, onClick) => {
51
+ const b = el('button', `pp-toggle${on ? ' gbp-is-active' : ''}`, label);
52
+ b.type = 'button';
53
+ b.addEventListener('click', onClick);
54
+ return b;
55
+ };
56
+
57
+ const colorControl = (value, onPick, { allowNone = true, title = '颜色', noneLabel = '无颜色' } = {}) => {
58
+ const b = el('button', 'pp-colorfield');
59
+ b.type = 'button';
60
+ const dot = el('i', 'pp-colorfield__dot');
61
+ dot.style.background = value || 'transparent';
62
+ const text = el('span', '', value || '默认');
63
+ b.append(dot, text);
64
+ b.addEventListener('click', () => {
65
+ openColorPanel({ anchor: b, colors: TEXT_COLORS, value, title, columns: 10, allowNone, noneLabel, onPick });
66
+ });
67
+ return b;
68
+ };
69
+
70
+ export class FormatPane {
71
+ constructor(app) {
72
+ this.app = app;
73
+ this.el = el('aside', 'pp-formatpane');
74
+ this.el.hidden = true;
75
+ this.closedSections = new Set();
76
+ this.title = '';
77
+ this.body = null;
78
+ }
79
+
80
+ open() {
81
+ this.app.formatPaneOpen = true;
82
+ this.el.hidden = false;
83
+ this.render();
84
+ }
85
+
86
+ close() {
87
+ this.app.formatPaneOpen = false;
88
+ this.app.prefs.formatPaneOpen = false;
89
+ this.app.persistPrefs();
90
+ this.el.hidden = true;
91
+ this.app.updateLayout();
92
+ this.app.ribbon.refresh();
93
+ }
94
+
95
+ toggle() {
96
+ if (this.app.formatPaneOpen) this.close();
97
+ else this.open();
98
+ }
99
+
100
+ render() {
101
+ if (!this.app.formatPaneOpen || (this.app.view && this.app.view !== 'normal')) {
102
+ this.el.hidden = true;
103
+ return;
104
+ }
105
+ const bodyScroll = this.body?.scrollTop || 0;
106
+ this.el.hidden = false;
107
+ this.el.replaceChildren();
108
+ const head = el('div', 'pp-formatpane__head');
109
+ const title = el('span', 'pp-formatpane__title');
110
+ const close = el('button', 'pp-iconbtn');
111
+ close.type = 'button';
112
+ close.innerHTML = icon('close', 16);
113
+ close.title = '关闭';
114
+ close.addEventListener('click', () => this.close());
115
+ head.append(title, close);
116
+ const body = el('div', 'pp-formatpane__body');
117
+ this.el.append(head, body);
118
+ this.body = body;
119
+
120
+ const objs = this.app.selectedObjects();
121
+ if (objs.length === 0) {
122
+ title.textContent = '设置背景格式';
123
+ this.renderSlide(body);
124
+ } else if (objs.length > 1) {
125
+ title.textContent = `设置 ${objs.length} 个对象`;
126
+ this.renderMulti(body, objs);
127
+ } else {
128
+ const o = objs[0];
129
+ title.textContent = o.type === 'image' ? '设置图片格式' : o.type === 'table' ? '设置表格格式' : o.type === 'line' ? '设置线条格式' : '设置形状格式';
130
+ this.renderObject(body, o);
131
+ }
132
+ body.scrollTop = bodyScroll;
133
+ this.title = title.textContent;
134
+ }
135
+
136
+ section(body, key, title, content, { open = !this.closedSections.has(key) } = {}) {
137
+ const sec = el('section', `pp-fp-section${open ? ' gbp-is-open' : ''}`);
138
+ const head = el('button', 'pp-fp-section__head');
139
+ head.type = 'button';
140
+ head.innerHTML = `<span>${title}</span>${icon('chevronDown', 14)}`;
141
+ const box = el('div', 'pp-fp-section__body');
142
+ box.append(...(Array.isArray(content) ? content : [content]));
143
+ head.addEventListener('click', () => {
144
+ const isOpen = sec.classList.toggle('gbp-is-open');
145
+ box.hidden = !isOpen;
146
+ if (isOpen) this.closedSections.delete(key);
147
+ else this.closedSections.add(key);
148
+ });
149
+ box.hidden = !open;
150
+ sec.append(head, box);
151
+ body.appendChild(sec);
152
+ return sec;
153
+ }
154
+
155
+ /* ===================== 幻灯片 ===================== */
156
+
157
+ renderSlide(body) {
158
+ const app = this.app;
159
+ const slide = app.currentSlide();
160
+ const bg = slide.bg || '';
161
+ const theme = themeOf(app.snapshot.theme);
162
+
163
+ this.section(body, 'slide', '幻灯片', [
164
+ field('背景色', colorControl(bg || theme.bg, (c) => app.setSlideBg(c), { title: '页面背景色', noneLabel: '跟随主题' })),
165
+ field('画幅', selectInput(
166
+ [...SLIDE_SIZES.map((s) => ({ value: s.key, label: s.label })), { value: 'custom', label: `自定义 ${app.size.w}×${app.size.h}` }],
167
+ SLIDE_SIZES.find((s) => s.w === app.size.w && s.h === app.size.h)?.key || 'custom',
168
+ (v) => { if (v !== 'custom') app.setSlideSize(v); },
169
+ )),
170
+ field('主题', selectInput(THEME_KEYS.map((k) => ({ value: k, label: THEMES[k].label })), app.snapshot.theme, (v) => app.setTheme(v))),
171
+ ]);
172
+
173
+ this.section(body, 'transition', '切换', [
174
+ field('效果', selectInput(TRANSITIONS.map((t) => ({ value: t.key, label: t.label })), slide.transition?.type || 'none', (v) => app.setTransition({ type: v }))),
175
+ field('速度', selectInput([
176
+ { value: 'fast', label: '0.5 秒' }, { value: 'med', label: '1 秒' }, { value: 'slow', label: '2 秒' },
177
+ ], slide.transition?.speed || 'med', (v) => app.setTransition({ speed: v }))),
178
+ field('状态', (() => {
179
+ const row = el('div', 'pp-inline');
180
+ row.append(toggleButton(slide.hidden ? '已隐藏' : '显示', !slide.hidden, () => app.toggleSlideHidden()));
181
+ row.append(el('span', 'pp-fp-hint', `第 ${app.index + 1} / ${app.snapshot.slides.length} 页`));
182
+ return row;
183
+ })()),
184
+ ]);
185
+ }
186
+
187
+ /* ===================== 多选 ===================== */
188
+
189
+ renderMulti(body, objs) {
190
+ const app = this.app;
191
+ const align = el('div', 'pp-grid-buttons');
192
+ for (const [key, label] of [['left', '左对齐'], ['centerH', '水平居中'], ['right', '右对齐'], ['top', '顶端'], ['middle', '垂直居中'], ['bottom', '底端']]) {
193
+ const b = el('button', 'pp-chip', label);
194
+ b.type = 'button';
195
+ b.addEventListener('click', () => app.alignToSlide(key));
196
+ align.appendChild(b);
197
+ }
198
+ const dist = el('div', 'pp-grid-buttons');
199
+ for (const [key, label] of [['h', '横向分布'], ['v', '纵向分布']]) {
200
+ const b = el('button', 'pp-chip', label);
201
+ b.type = 'button';
202
+ b.disabled = objs.length < 3;
203
+ b.addEventListener('click', () => app.distribute(key));
204
+ dist.appendChild(b);
205
+ }
206
+ const order = el('div', 'pp-grid-buttons');
207
+ for (const [key, label] of [['front', '置于顶层'], ['forward', '上移一层'], ['backward', '下移一层'], ['back', '置于底层']]) {
208
+ const b = el('button', 'pp-chip', label);
209
+ b.type = 'button';
210
+ b.addEventListener('click', () => app.arrange(key));
211
+ order.appendChild(b);
212
+ }
213
+ this.section(body, 'align', '对齐', align);
214
+ this.section(body, 'dist', '分布', dist);
215
+ this.section(body, 'order', '排列', order);
216
+ }
217
+
218
+ /* ===================== 对象 ===================== */
219
+
220
+ renderObject(body, o) {
221
+ const app = this.app;
222
+ const p = o.props;
223
+
224
+ /* 大小与位置 */
225
+ const sizeBox = [
226
+ field('宽度', numberInput(Math.abs(o.w), (v) => app.updateObject(o.id, { w: o.w < 0 ? -Math.abs(v) : Math.abs(v) }), { min: 1 })),
227
+ field('高度', numberInput(Math.abs(o.h), (v) => app.updateObject(o.id, { h: o.h < 0 ? -Math.abs(v) : Math.abs(v) }), { min: 1 })),
228
+ field('X 位置', numberInput(o.x, (v) => app.updateObject(o.id, { x: v }))),
229
+ field('Y 位置', numberInput(o.y, (v) => app.updateObject(o.id, { y: v }))),
230
+ field('旋转', numberInput(o.rot || 0, (v) => app.updateObject(o.id, { rot: v }), { min: -360, max: 360 })),
231
+ ];
232
+ this.section(body, 'size', '大小与位置', sizeBox);
233
+
234
+ if (o.type === 'text') {
235
+ this.section(body, 'text', '文本选项', this.textControls(o, true));
236
+ this.section(body, 'fill', '填充与线条', this.fillControls(o, { text: true }));
237
+ } else if (o.type === 'shape') {
238
+ this.section(body, 'fill', '填充与线条', this.fillControls(o));
239
+ this.section(body, 'text', '文本选项', this.textControls(o, true));
240
+ } else if (o.type === 'line') {
241
+ this.section(body, 'line', '线条', this.lineControls(o));
242
+ } else if (o.type === 'image') {
243
+ this.section(body, 'image', '图片', this.imageControls(o));
244
+ this.section(body, 'alt', '替代文字', [
245
+ field('说明', (() => {
246
+ const input = el('input', 'pp-input');
247
+ input.type = 'text';
248
+ input.value = p.alt || '';
249
+ input.placeholder = '描述图片内容';
250
+ input.addEventListener('change', () => app.updateProps(o.id, { alt: input.value }));
251
+ return input;
252
+ })()),
253
+ ]);
254
+ } else if (o.type === 'table') {
255
+ this.section(body, 'table', '表格', this.tableControls(o));
256
+ this.section(body, 'text', '文字', this.tableTextControls(o));
257
+ }
258
+ }
259
+
260
+ textControls(o, includeAnchor) {
261
+ const app = this.app;
262
+ const p = o.props;
263
+ const font = selectInput(
264
+ [{ value: '', label: '默认' }, ...FONT_FAMILIES.map((f) => ({ value: f.value, label: f.label }))],
265
+ p.font || '',
266
+ (v) => app.updateProps(o.id, { font: v }),
267
+ );
268
+ const size = numberInput(p.fontSize || 24, (v) => app.setFontSize(v), { min: 6, max: 200 });
269
+ const styleRow = el('div', 'pp-inline');
270
+ for (const [key, label, iconName] of [['bold', '粗体', 'bold'], ['italic', '斜体', 'italic'], ['underline', '下划线', 'underline'], ['strike', '删除线', 'strike']]) {
271
+ const b = el('button', `pp-toggle${p[key] ? ' gbp-is-active' : ''}`);
272
+ b.type = 'button';
273
+ b.title = label;
274
+ b.innerHTML = icon(iconName, 15);
275
+ b.addEventListener('click', () => app.updateProps(o.id, { [key]: !p[key] }));
276
+ styleRow.appendChild(b);
277
+ }
278
+ const alignRow = el('div', 'pp-segmented');
279
+ for (const [key, name] of [['left', 'alignLeft'], ['center', 'alignCenter'], ['right', 'alignRight'], ['justify', 'alignJustify']]) {
280
+ const b = el('button', `pp-segmented__btn${p.align === key ? ' gbp-is-active' : ''}`);
281
+ b.type = 'button';
282
+ b.title = key;
283
+ b.innerHTML = icon(name, 15);
284
+ b.addEventListener('click', () => app.updateProps(o.id, { align: key }));
285
+ alignRow.appendChild(b);
286
+ }
287
+ const color = colorControl(
288
+ o.type === 'shape' ? (p.textColor || '') : (p.color || ''),
289
+ (c) => app.updateProps(o.id, o.type === 'shape' ? { textColor: c || '#ffffff' } : { color: c }),
290
+ { title: '字体颜色' },
291
+ );
292
+ const controls = [
293
+ field('字体', font),
294
+ field('字号', size),
295
+ field('样式', styleRow),
296
+ field('对齐', alignRow),
297
+ field('颜色', color),
298
+ field('行距', numberInput(p.lineSpacing || 1, (v) => app.updateProps(o.id, { lineSpacing: v }), { min: 0.6, max: 4, step: 0.05 })),
299
+ ];
300
+ if (includeAnchor) {
301
+ const anchorRow = el('div', 'pp-segmented');
302
+ for (const [key, label] of [['top', '顶端'], ['middle', '中部'], ['bottom', '底端']]) {
303
+ const b = el('button', `pp-segmented__btn${(p.anchor || 'top') === key ? ' gbp-is-active' : ''}`, label);
304
+ b.type = 'button';
305
+ b.addEventListener('click', () => app.updateProps(o.id, { anchor: key }));
306
+ anchorRow.appendChild(b);
307
+ }
308
+ controls.push(field('垂直对齐', anchorRow));
309
+ }
310
+ return controls;
311
+ }
312
+
313
+ fillControls(o, { text = false } = {}) {
314
+ const app = this.app;
315
+ const p = o.props;
316
+ const fillMode = el('div', 'pp-segmented');
317
+ for (const [key, label] of [['solid', '纯色'], ['none', '无填充']]) {
318
+ const b = el('button', `pp-segmented__btn${(p.fill ? 'solid' : 'none') === key ? ' gbp-is-active' : ''}`, label);
319
+ b.type = 'button';
320
+ b.addEventListener('click', () => app.updateProps(o.id, { fill: key === 'none' ? '' : (p.fill || themeOf(app.snapshot.theme).accent) }));
321
+ fillMode.appendChild(b);
322
+ }
323
+ const fillColor = colorControl(p.fill || '', (c) => app.updateProps(o.id, { fill: c }), { title: '填充颜色' });
324
+ const lineMode = el('div', 'pp-segmented');
325
+ for (const [key, label] of [['solid', '实线'], ['none', '无线条']]) {
326
+ const b = el('button', `pp-segmented__btn${(p.stroke && p.strokeW > 0 ? 'solid' : 'none') === key ? ' gbp-is-active' : ''}`, label);
327
+ b.type = 'button';
328
+ b.addEventListener('click', () => app.updateProps(o.id, {
329
+ stroke: key === 'none' ? '' : (p.stroke || themeOf(app.snapshot.theme).text),
330
+ strokeW: key === 'none' ? 0 : Math.max(1, p.strokeW || 1),
331
+ }));
332
+ lineMode.appendChild(b);
333
+ }
334
+ const lineColor = colorControl(p.stroke || '', (c) => app.updateProps(o.id, {
335
+ stroke: c,
336
+ strokeW: c ? Math.max(1, p.strokeW || 1) : 0,
337
+ }), { title: '线条颜色' });
338
+ const width = numberInput(p.strokeW || 0, (v) => app.updateProps(o.id, { strokeW: v, stroke: p.stroke || themeOf(app.snapshot.theme).text }), { min: 0, max: 40, step: 1 });
339
+ const dash = selectInput([
340
+ { value: 'solid', label: '实线' }, { value: 'dash', label: '虚线' }, { value: 'dot', label: '点线' },
341
+ { value: 'lgDash', label: '长虚线' }, { value: 'dashDot', label: '点划线' },
342
+ ], p.dash || 'solid', (v) => app.updateProps(o.id, { dash: v }));
343
+ return [
344
+ field('填充', fillMode),
345
+ field('填充色', fillColor),
346
+ field('线条', lineMode),
347
+ field('线条色', lineColor),
348
+ field('线宽', width),
349
+ field('线型', dash),
350
+ field('阴影', toggleButton(p.shadow ? '已开启' : '关闭', !!p.shadow, () => app.updateProps(o.id, { shadow: !p.shadow }))),
351
+ ];
352
+ }
353
+
354
+ lineControls(o) {
355
+ const app = this.app;
356
+ const p = o.props;
357
+ return [
358
+ field('颜色', colorControl(p.stroke || '', (c) => app.updateProps(o.id, { stroke: c }), { title: '线条颜色' })),
359
+ field('线宽', numberInput(p.strokeW || 2, (v) => app.updateProps(o.id, { strokeW: v }), { min: 1, max: 40 })),
360
+ field('线型', selectInput([
361
+ { value: 'solid', label: '实线' }, { value: 'dash', label: '虚线' }, { value: 'dot', label: '点线' },
362
+ { value: 'lgDash', label: '长虚线' }, { value: 'dashDot', label: '点划线' },
363
+ ], p.dash || 'solid', (v) => app.updateProps(o.id, { dash: v }))),
364
+ field('箭头', (() => {
365
+ const row = el('div', 'pp-inline');
366
+ row.append(
367
+ toggleButton('起点', !!p.arrowStart, () => app.updateProps(o.id, { arrowStart: !p.arrowStart })),
368
+ toggleButton('终点', !!p.arrowEnd, () => app.updateProps(o.id, { arrowEnd: !p.arrowEnd })),
369
+ );
370
+ return row;
371
+ })()),
372
+ ];
373
+ }
374
+
375
+ imageControls(o) {
376
+ const app = this.app;
377
+ const p = o.props;
378
+ const crop = p.crop || { l: 0, t: 0, r: 0, b: 0 };
379
+ const setCrop = (key, v) => app.updateProps(o.id, { crop: { ...crop, [key]: Math.max(0, Math.min(49, v)) } });
380
+ const cropBox = [
381
+ field('左', numberInput(crop.l || 0, (v) => setCrop('l', v), { min: 0, max: 49 })),
382
+ field('上', numberInput(crop.t || 0, (v) => setCrop('t', v), { min: 0, max: 49 })),
383
+ field('右', numberInput(crop.r || 0, (v) => setCrop('r', v), { min: 0, max: 49 })),
384
+ field('下', numberInput(crop.b || 0, (v) => setCrop('b', v), { min: 0, max: 49 })),
385
+ field('', (() => {
386
+ const row = el('div', 'pp-inline');
387
+ const reset = el('button', 'pp-chip', '重置裁剪');
388
+ reset.type = 'button';
389
+ reset.addEventListener('click', () => app.updateProps(o.id, { crop: { l: 0, t: 0, r: 0, b: 0 } }));
390
+ row.appendChild(reset);
391
+ return row;
392
+ })()),
393
+ ];
394
+ return [
395
+ field('替换', (() => {
396
+ const b = el('button', 'pp-chip', '选择新图片…');
397
+ b.type = 'button';
398
+ b.addEventListener('click', () => app.replaceSelectedImage());
399
+ return b;
400
+ })()),
401
+ ...cropBox,
402
+ field('阴影', toggleButton(p.shadow ? '已开启' : '关闭', !!p.shadow, () => app.updateProps(o.id, { shadow: !p.shadow }))),
403
+ ];
404
+ }
405
+
406
+ tableControls(o) {
407
+ const app = this.app;
408
+ const p = o.props;
409
+ return [
410
+ field('样式', selectInput(TABLE_STYLES.map((s) => ({ value: s.key, label: s.label })), p.tableStyle || 'plain', (v) => app.setTableStyle(v))),
411
+ field('标题行', toggleButton(p.headerRow ? '已开启' : '关闭', !!p.headerRow, () => app.toggleHeaderRow())),
412
+ field('镶边行', toggleButton(p.bandedRows ? '已开启' : '关闭', !!p.bandedRows, () => app.toggleBandedRows())),
413
+ field('行数', numberInput(p.rows.length, (v) => app.resizeTable(o.id, Math.round(v), p.rows[0].length), { min: 1, max: 50 })),
414
+ field('列数', numberInput(p.rows[0].length, (v) => app.resizeTable(o.id, p.rows.length, Math.round(v)), { min: 1, max: 30 })),
415
+ ];
416
+ }
417
+
418
+ tableTextControls(o) {
419
+ const app = this.app;
420
+ const p = o.props;
421
+ return [
422
+ field('字体', selectInput([{ value: '', label: '默认' }, ...FONT_FAMILIES.map((f) => ({ value: f.value, label: f.label }))], p.font || '', (v) => app.updateProps(o.id, { font: v }))),
423
+ field('字号', numberInput(p.fontSize || 16, (v) => app.updateProps(o.id, { fontSize: v }), { min: 6, max: 100 })),
424
+ field('颜色', colorControl(p.color || '', (c) => app.updateProps(o.id, { color: c }), { title: '表格文字颜色' })),
425
+ ];
426
+ }
427
+ }
@@ -0,0 +1,129 @@
1
+ // [文件] gbpptx·图标 —— Office 风格的线性 SVG 图标库(全部内联,无外部依赖)
2
+
3
+ const p = (d, extra = '') => `<path d="${d}" ${extra}/>`;
4
+ const r = (x, y, w, h, rx = 1, extra = '') => `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="${rx}" ${extra}/>`;
5
+ const c = (cx, cy, rad) => `<circle cx="${cx}" cy="${cy}" r="${rad}"/>`;
6
+
7
+ const BODY = {
8
+ save: p('M5 3h11l3 3v15H5z') + p('M8 3v6h8V3M8 21v-7h8v7'),
9
+ saveAs: p('M5 3h11l3 3v10M8 3v6h8V3M13 21l6-6 2 2-6 6h-2z'),
10
+ open: p('M3 7h6l2 2h10v10H3z'),
11
+ new: p('M6 3h8l4 4v14H6z') + p('M14 3v4h4M12 11v6M9 14h6'),
12
+ close: p('M6 6l12 12M18 6L6 18'),
13
+ back: p('M15 5l-7 7 7 7'),
14
+ home: p('M4 11l8-7 8 7v9h-5v-6H9v6H4z'),
15
+ undo: p('M9 7L4 12l5 5M4 12h10a6 6 0 0 1 0 12'),
16
+ redo: p('M15 7l5 5-5 5M20 12H10a6 6 0 0 0 0 12'),
17
+ present: r(3, 4, 18, 12, 1) + p('M12 16v4M8 20h8'),
18
+ play: `<path d="M7 4l13 8-13 8z" fill="currentColor" stroke="none"/>`,
19
+ pause: p('M8 5v14M16 5v14', 'stroke-width="3"'),
20
+ paste: p('M9 5V3h6v2') + r(5, 5, 14, 16, 2) + p('M9 11h6M9 15h6'),
21
+ cut: c(6, 7, 2.4) + c(6, 17, 2.4) + p('M8 8.5L20 18M8 15.5L20 6'),
22
+ copy: r(8, 8, 12, 12, 2) + p('M4 16V6a2 2 0 0 1 2-2h8'),
23
+ formatPainter: p('M5 4h10v4H5zM10 8v4h6v8') + p('M14 20h4'),
24
+ delete: p('M4 7h16M9 7V4h6v3M6 7l1 14h10l1-14M10 11v6M14 11v6'),
25
+ newSlide: r(3, 5, 18, 14, 2) + p('M12 9v6M9 12h6'),
26
+ layout: r(3, 4, 18, 16, 2) + p('M3 9h18M10 9v11'),
27
+ duplicate: r(4, 4, 12, 12, 2) + r(8, 8, 12, 12, 2),
28
+ hide: p('M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z') + c(12, 12, 3) + p('M4 20L20 4'),
29
+ reset: p('M4 4v6h6M20 20v-6h-6M5 15a8 8 0 0 0 13 2M19 9A8 8 0 0 0 6 7'),
30
+ bold: p('M7 4h7a4 4 0 0 1 0 8H7zM7 12h8a4 4 0 0 1 0 8H7z', 'stroke-width="2.2"'),
31
+ italic: p('M16 4h-5M13 20H8M15 4L9 20', 'stroke-width="2.2"'),
32
+ underline: p('M7 4v7a5 5 0 0 0 10 0V4M4 21h16', 'stroke-width="2.2"'),
33
+ strike: p('M4 12h16M8 7a4 4 0 0 1 8-1M16 17a4 4 0 0 1-8 1', 'stroke-width="2"'),
34
+ fontColor: p('M5 19h14M7 15l5-11 5 11M9 11h6'),
35
+ fill: `<path d="M5 13l7-7 7 7-7 7z" fill="currentColor" fill-opacity=".22"/>` + p('M5 13l7-7 7 7-7 7zM19 16c0 1.4 1 2.5 2 2.5s2-1.1 2-2.5-2-3.3-2-3.3S19 14.6 19 16z'),
36
+ outline: r(4, 4, 16, 16, 2, 'stroke-dasharray="3 2.5"'),
37
+ effects: r(4, 4, 11, 11, 2) + r(9, 9, 11, 11, 2),
38
+ clearFormat: p('M4 6h16M9 6l-3 14M14 6l-2 8') + p('M16 15l5 5M21 15l-5 5'),
39
+ increaseFont: p('M3 19h10M5 15l4-9 4 9M7 11h4M18 6v10M15 9l3-3 3 3'),
40
+ decreaseFont: p('M3 19h10M5 15l4-9 4 9M7 11h4M15 11h6'),
41
+ alignLeft: p('M4 6h16M4 10h10M4 14h16M4 18h10'),
42
+ alignCenter: p('M4 6h16M7 10h10M4 14h16M7 18h10'),
43
+ alignRight: p('M4 6h16M10 10h10M4 14h16M10 18h10'),
44
+ alignJustify: p('M4 6h16M4 10h16M4 14h16M4 18h16'),
45
+ bullets: p('M5 7h14M5 12h14M5 17h14') + c(3, 7, 0.9) + c(3, 12, 0.9) + c(3, 17, 0.9),
46
+ numbering: p('M9 6h11M9 12h11M9 18h11M3 5h2v4M3 9h3M3 15h2l-2 3h3', 'stroke-width="1.7"'),
47
+ indentIncrease: p('M4 6h16M9 12h11M9 18h11M4 10l3 2-3 2'),
48
+ indentDecrease: p('M4 6h16M9 12h11M9 18h11M7 10l-3 2 3 2'),
49
+ lineSpacing: p('M4 5h16M4 10h16M4 15h16M4 20h16') + p('M2 7v10M2 7l-1 2M2 7l1 2M2 17l-1-2M2 17l1-2', 'stroke-width="1.4"'),
50
+ shape: r(3, 4, 18, 16, 2),
51
+ shapes: r(3, 3, 9, 9, 1) + c(17, 7, 4) + p('M7 14l4 7H3z'),
52
+ textBox: p('M4 5h16v14H4zM8 9h8M12 9v7M10 16h4'),
53
+ image: r(3, 4, 18, 16, 2) + p('M4 16l4-4 4 4 3-3 5 5') + c(9, 9, 1.4),
54
+ table: r(3, 4, 18, 16, 1.5) + p('M3 10h18M3 15h18M9 4v16M15 4v16'),
55
+ line: p('M4 20L20 4'),
56
+ arrow: p('M4 12h14M14 7l5 5-5 5'),
57
+ symbol: p('M5 5h6v6H5zM13 13h6v6h-6zM13 5h6v6h-6z'),
58
+ notes: r(3, 4, 18, 16, 2) + p('M7 9h10M7 13h10M7 17h6'),
59
+ comment: p('M4 5h16v11H9l-5 4z') + p('M8 9h8M8 12h5'),
60
+ link: p('M10 8H7a4 4 0 0 0 0 8h3M14 8h3a4 4 0 0 1 0 8h-3M9 12h6'),
61
+ arrange: p('M4 8h10M4 16h16') + p('M14 5v6M18 13v6'),
62
+ bringForward: r(4, 4, 12, 12, 1) + r(9, 9, 11, 11, 1),
63
+ sendBackward: r(9, 9, 11, 11, 1) + r(4, 4, 11, 11, 1),
64
+ rotate: p('M20 8a8 8 0 1 0 1 7') + p('M20 3v5h-5'),
65
+ theme: r(3, 4, 18, 16, 2) + p('M3 9h18M8 9v11M16 9v11') + c(6, 6.5, 1),
66
+ background: r(3, 4, 18, 16, 2) + p('M4 17l5-5 4 4 3-3 4 4'),
67
+ size: r(3, 4, 18, 16, 2) + p('M8 8h8M12 8v8'),
68
+ variants: c(8, 8, 4) + c(16, 8, 4) + c(8, 16, 4) + c(16, 16, 4),
69
+ transition: p('M3 7h8v10H3zM13 7h8v10h-8z') + p('M9 12h6M13 9l3 3-3 3'),
70
+ duration: c(12, 12, 8) + p('M12 7v5l4 2'),
71
+ slideShow: r(3, 5, 18, 12, 1) + p('M12 17v3M8 20h8M9 9l4 2.5L9 14z'),
72
+ presenter: r(3, 5, 18, 12, 1) + p('M12 17v3M8 20h8') + p('M7 9h4M7 12h3'),
73
+ monitor: r(3, 4, 18, 12, 1) + p('M9 20h6M12 16v4'),
74
+ loop: p('M4 8a8 8 0 0 1 14-2l2 2M20 4v4h-4M20 16a8 8 0 0 1-14 2l-2-2M4 20v-4h4'),
75
+ find: c(10, 10, 6) + p('M15 15l6 6'),
76
+ replace: c(9, 9, 5) + p('M13 13l6 6M6 9h6M9 6v6') + p('M17 5h4v4'),
77
+ selectAll: p('M4 4h4M16 4h4M20 8v4M20 16v4M16 20h-4M8 20H4M4 16v-4') + r(9, 9, 6, 6, 1),
78
+ wordCount: p('M4 5h16M4 10h10M4 15h13M4 20h7') + p('M18 12l3 4-3 4'),
79
+ viewNormal: r(4, 5, 16, 14, 1) + p('M8 5v14'),
80
+ viewSorter: r(3, 4, 8, 7, 1) + r(13, 4, 8, 7, 1) + r(3, 13, 8, 7, 1) + r(13, 13, 8, 7, 1),
81
+ viewReading: p('M3 5h7c1 0 2 .7 2 2v12c0-1.3-1-2-2-2H3zM21 5h-7c-1 0-2 .7-2 2v12c0-1.3 1-2 2-2h7z'),
82
+ zoomIn: c(10, 10, 6) + p('M15 15l6 6M10 7v6M7 10h6'),
83
+ zoomOut: c(10, 10, 6) + p('M15 15l6 6M7 10h6'),
84
+ fitWindow: p('M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5'),
85
+ grid: p('M4 4h16v16H4zM4 8h16M4 12h16M4 16h16M8 4v16M12 4v16M16 4v16'),
86
+ guides: p('M4 4v16M20 4v16M4 4h16M4 20h16') + p('M12 2v20M2 12h20', 'stroke-dasharray="2 2"'),
87
+ formatPane: r(3, 4, 18, 16, 2) + p('M14 4v16M17 8h2M17 12h2M17 16h1'),
88
+ check: p('M5 12l5 5L20 7'),
89
+ chevronDown: p('M6 9l6 6 6-6'),
90
+ chevronUp: p('M6 15l6-6 6 6'),
91
+ chevronRight: p('M9 6l6 6-6 6'),
92
+ chevronLeft: p('M15 6l-6 6 6 6'),
93
+ plus: p('M12 5v14M5 12h14'),
94
+ minus: p('M5 12h14'),
95
+ more: c(5, 12, 1.3) + c(12, 12, 1.3) + c(19, 12, 1.3),
96
+ lock: r(5, 10, 14, 10, 2) + p('M8 10V7a4 4 0 0 1 8 0v3'),
97
+ eye: p('M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z') + c(12, 12, 3),
98
+ crop: p('M6 3v13a2 2 0 0 0 2 2h13M3 6h13a2 2 0 0 1 2 2v13'),
99
+ resetImage: r(4, 4, 16, 16, 2) + p('M9 15l3-3 2 2 2-2 3 3M14 3v4h4'),
100
+ replaceImage: r(4, 4, 16, 16, 2) + p('M8 15l3-3 2 2 2-2 3 3M17 2v5h-5'),
101
+ shadow: r(5, 5, 12, 12, 2) + p('M9 21h10a2 2 0 0 0 2-2V9', 'stroke-dasharray="2 2"'),
102
+ position: p('M12 3v18M3 12h18') + c(12, 12, 3),
103
+ textOptions: p('M4 6h16M8 6v13M5 19h6M14 12h6M17 12v7M14 19h6'),
104
+ warning: p('M12 3l10 18H2z') + p('M12 9v5M12 17v.5'),
105
+ info: c(12, 12, 9) + p('M12 11v6M12 7.5v.5'),
106
+ error: c(12, 12, 9) + p('M8 8l8 8M16 8l-8 8'),
107
+ success: c(12, 12, 9) + p('M7.5 12.5l3 3 6-7'),
108
+ cursor: `<path d="M5 3l6 16 2-6 6-2z" fill="currentColor" stroke="none"/>`,
109
+ logo: r(3, 4, 18, 16, 2) + p('M7 9l7 3-7 3z') + p('M17 8v8'),
110
+ text: p('M6 5h12M12 5v14M9 19h6'),
111
+ imageFill: r(3, 4, 18, 16, 2) + p('M4 16l4-4 4 4 3-3 5 5'),
112
+ tableStyle: r(3, 4, 18, 16, 1.5) + p('M3 10h18M9 4v16') + `<rect x="3" y="4" width="18" height="6" fill="currentColor" fill-opacity=".18" stroke="none"/>`,
113
+ rowAbove: r(3, 4, 18, 16, 1.5) + p('M3 10h18M9 10v10M15 10v10M12 2v5M9.5 4.5L12 2l2.5 2.5'),
114
+ rowBelow: r(3, 4, 18, 16, 1.5) + p('M3 10h18M9 10v10M15 10v10M12 17v5M9.5 19.5L12 22l2.5-2.5'),
115
+ colLeft: r(3, 4, 18, 16, 1.5) + p('M3 10h18M9 4v16M15 4v16M2 12h5M4.5 9.5L2 12l2.5 2.5'),
116
+ colRight: r(3, 4, 18, 16, 1.5) + p('M3 10h18M9 4v16M15 4v16M17 12h5M19.5 9.5L22 12l-2.5 2.5'),
117
+ merge: r(3, 4, 18, 16, 1.5) + p('M3 10h18M9 10v10M15 10v10') + p('M8 7h8'),
118
+ };
119
+
120
+ const svg = (body, size) =>
121
+ `<svg class="pp-ico" viewBox="0 0 24 24" width="${size}" height="${size}" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${body}</svg>`;
122
+
123
+ /** 取图标 SVG 字符串;未知名字返回空串 */
124
+ export function icon(name, size = 16) {
125
+ const body = BODY[name];
126
+ return body ? svg(body, size) : '';
127
+ }
128
+
129
+ export const hasIcon = (name) => Boolean(BODY[name]);