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.
Files changed (46) hide show
  1. package/README.md +237 -214
  2. package/package.json +5 -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 +213 -0
  10. package/web/app/slides/find.js +201 -0
  11. package/web/app/slides/history.js +100 -0
  12. package/web/app/slides/keys.js +179 -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 +156 -0
  21. package/web/app/slides-app.js +323 -2446
  22. package/web/app/ui/canvas.js +769 -755
  23. package/web/app/ui/color-panel.js +58 -76
  24. package/web/app/ui/dialogs.js +120 -159
  25. package/web/app/ui/file-io.js +116 -132
  26. package/web/app/ui/format-pane.js +427 -427
  27. package/web/app/ui/icons.js +129 -129
  28. package/web/app/ui/menu.js +75 -89
  29. package/web/app/ui/notify.js +45 -45
  30. package/web/app/ui/page-view.js +221 -221
  31. package/web/app/ui/popup.js +80 -80
  32. package/web/app/ui/present.js +292 -292
  33. package/web/app/ui/ribbon.js +868 -878
  34. package/web/app/ui/slide-pane.js +197 -189
  35. package/web/app/ui/statusbar.js +93 -93
  36. package/web/app/ui/text-styles.js +84 -84
  37. package/web/app/ui/titlebar.js +184 -67
  38. package/web/app/ui/transition.js +30 -30
  39. package/web/index.html +23 -21
  40. package/web/serve.mjs +22 -67
  41. package/web/styles/office.css +466 -644
  42. package/web/styles/slides.css +97 -219
  43. package/web/styles/tokens.css +154 -155
  44. package/src/kernel/util/escape.js +0 -21
  45. package/src/kernel/util/id.js +0 -13
  46. package/web/app/ui/backstage.js +0 -255
@@ -1,129 +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]);
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]);
@@ -1,89 +1,75 @@
1
- // [文件] gbpptx·菜单 —— 下拉/右键菜单渲染(条目口径:label/icon/disabled/checked/danger/shortcut/divided/children/onClick)
2
- import { openPopup, closeAll } from './popup.js';
3
- import { icon } from './icons.js';
4
-
5
- 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>';
6
- 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>';
7
-
8
- /** 构建条目列表 DOM(子菜单在 hover 时另开浮层) */
9
- export function buildList(items, { compact = false } = {}) {
10
- const box = document.createElement('div');
11
- box.className = `gb-menu__list${compact ? ' gb-menu__list--compact' : ''}`;
12
- let subHandle = null;
13
- const closeSub = () => { subHandle?.close(); subHandle = null; };
14
- for (const item of items || []) {
15
- if (item.divided) {
16
- const sep = document.createElement('div');
17
- sep.className = 'gb-menu__sep';
18
- box.appendChild(sep);
19
- continue;
20
- }
21
- if (item.header) {
22
- const head = document.createElement('div');
23
- head.className = 'gb-menu__header';
24
- head.textContent = item.header;
25
- box.appendChild(head);
26
- continue;
27
- }
28
- const row = document.createElement('div');
29
- row.className = 'gb-menu__item';
30
- if (item.disabled) row.classList.add('is-disabled');
31
- if (item.danger) row.classList.add('is-danger');
32
- if (item.checked) row.classList.add('is-checked');
33
- const lead = document.createElement('span');
34
- lead.className = 'gb-menu__lead';
35
- if (item.checked) lead.innerHTML = CHECK;
36
- else if (item.icon) lead.innerHTML = icon(item.icon, 16);
37
- else if (item.colorDot) lead.innerHTML = `<i class="gb-menu__dot" style="background:${item.colorDot}"></i>`;
38
- row.appendChild(lead);
39
- const label = document.createElement('span');
40
- label.className = 'gb-menu__label';
41
- label.textContent = item.label;
42
- row.appendChild(label);
43
- if (item.shortcut) {
44
- const sc = document.createElement('span');
45
- sc.className = 'gb-menu__shortcut';
46
- sc.textContent = item.shortcut;
47
- row.appendChild(sc);
48
- }
49
- if (item.children) {
50
- const arrow = document.createElement('span');
51
- arrow.className = 'gb-menu__arrow';
52
- arrow.innerHTML = SUB;
53
- row.appendChild(arrow);
54
- let timer = 0;
55
- row.addEventListener('mouseenter', () => {
56
- clearTimeout(timer);
57
- timer = setTimeout(() => {
58
- closeSub();
59
- if (item.disabled) return;
60
- subHandle = openPopup({
61
- anchor: row.getBoundingClientRect(),
62
- content: buildList(item.children, { compact }),
63
- placement: 'right-start',
64
- className: 'gb-menu',
65
- });
66
- }, 60);
67
- });
68
- row.addEventListener('mouseleave', () => clearTimeout(timer));
69
- } else {
70
- row.addEventListener('click', (e) => {
71
- if (item.disabled) return;
72
- item.onClick?.(e);
73
- document.dispatchEvent(new CustomEvent('gbpptx-menu-close'));
74
- });
75
- }
76
- box.appendChild(row);
77
- }
78
- return box;
79
- }
80
-
81
- /** 打开下拉菜单(锚点元素/矩形) */
82
- export const openMenu = ({ anchor, items, placement = 'bottom-start', className = '' }) =>
83
- openPopup({ anchor, content: buildList(items), placement, className: `gb-menu ${className}`.trim() });
84
-
85
- /** 打开右键菜单(客户端坐标) */
86
- export const openContextMenu = ({ x, y, items }) =>
87
- openPopup({ anchor: { left: x, top: y, right: x, bottom: y }, content: buildList(items), placement: 'bottom-start', className: 'gb-menu' });
88
-
89
- 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 };
@@ -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 = `gb-notify gb-notify--${type}`;
21
- const badge = document.createElement('span');
22
- badge.className = 'gb-notify__badge';
23
- badge.textContent = ICONS[type] || 'i';
24
- const text = document.createElement('span');
25
- text.className = 'gb-notify__text';
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 = 'gbdocx-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;