@a200888213/gbdocx 0.6.1 → 0.6.3

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 (95) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +215 -215
  3. package/index.html +31 -30
  4. package/package.json +49 -48
  5. package/serve.mjs +27 -23
  6. package/src/app/file-io.js +122 -122
  7. package/src/app/main.js +9 -9
  8. package/src/app/word/catalog.js +52 -52
  9. package/src/app/word/comments.js +112 -112
  10. package/src/app/word/doc.js +113 -113
  11. package/src/app/word/edit.js +72 -72
  12. package/src/app/word/file.js +191 -191
  13. package/src/app/word/hf.js +76 -76
  14. package/src/app/word/layout.js +155 -155
  15. package/src/app/word/menus.js +201 -201
  16. package/src/app/word/notes.js +110 -110
  17. package/src/app/word/shared.js +22 -22
  18. package/src/app/word/view.js +159 -159
  19. package/src/app/word-app.js +487 -487
  20. package/src/app/word-sheets.js +101 -101
  21. package/src/kernel/docx/catalog.js +41 -41
  22. package/src/kernel/docx/codec/blocks.js +123 -123
  23. package/src/kernel/docx/codec/carry.js +129 -129
  24. package/src/kernel/docx/codec/comments.js +25 -25
  25. package/src/kernel/docx/codec/docx.js +198 -198
  26. package/src/kernel/docx/codec/docxStyles.js +177 -177
  27. package/src/kernel/docx/codec/fonts.js +195 -195
  28. package/src/kernel/docx/codec/helpers.js +161 -161
  29. package/src/kernel/docx/codec/hfHtml.js +152 -152
  30. package/src/kernel/docx/codec/html.js +739 -739
  31. package/src/kernel/docx/codec/losses.js +420 -420
  32. package/src/kernel/docx/codec/markdown.js +170 -170
  33. package/src/kernel/docx/codec/parts.js +249 -249
  34. package/src/kernel/docx/codec/read.js +603 -603
  35. package/src/kernel/docx/codec/render.js +1156 -1156
  36. package/src/kernel/docx/codec/roundtrip.js +236 -236
  37. package/src/kernel/docx/codec/write.js +833 -833
  38. package/src/kernel/docx/comments.js +14 -14
  39. package/src/kernel/docx/menus.js +348 -348
  40. package/src/kernel/docx/pageGeometry.js +123 -123
  41. package/src/kernel/docx/pagination.js +481 -481
  42. package/src/kernel/docx/watermark.js +45 -45
  43. package/src/kernel/docx/wordShortcuts.js +37 -37
  44. package/src/kernel/editor/constants.js +8 -8
  45. package/src/kernel/editor/engine/blocks.js +594 -594
  46. package/src/kernel/editor/engine/blocksEnter.js +109 -109
  47. package/src/kernel/editor/engine/blocksInsert.js +254 -254
  48. package/src/kernel/editor/engine/blocksStructure.js +226 -226
  49. package/src/kernel/editor/engine/commands.js +181 -181
  50. package/src/kernel/editor/engine/dom.js +646 -646
  51. package/src/kernel/editor/engine/editor.js +213 -213
  52. package/src/kernel/editor/engine/history.js +149 -149
  53. package/src/kernel/editor/engine/inline.js +656 -656
  54. package/src/kernel/editor/engine/input.js +554 -554
  55. package/src/kernel/editor/engine/interaction.js +137 -137
  56. package/src/kernel/editor/engine/pointer.js +39 -39
  57. package/src/kernel/editor/engine/revision.js +138 -138
  58. package/src/kernel/editor/engine/schema.js +417 -417
  59. package/src/kernel/editor/engine/search.js +113 -113
  60. package/src/kernel/editor/engine/selection.js +119 -119
  61. package/src/kernel/editor/engine/state.js +118 -118
  62. package/src/kernel/editor/engine/tableClip.js +154 -154
  63. package/src/kernel/editor/engine/tableGrid.js +55 -55
  64. package/src/kernel/editor/engine/tableInteraction.js +388 -388
  65. package/src/kernel/editor/engine/tableMenu.js +250 -250
  66. package/src/kernel/editor/engine/tableOps.js +174 -174
  67. package/src/kernel/editor/engine/tables.js +732 -732
  68. package/src/kernel/editor/overlayGeometry.js +20 -20
  69. package/src/kernel/editor/pasteClean.js +293 -293
  70. package/src/kernel/editor/utils.js +48 -48
  71. package/src/kernel/keyboard.js +114 -114
  72. package/src/kernel/notify.js +54 -54
  73. package/src/kernel/textStyles.js +84 -84
  74. package/src/kernel/util/clipboard.js +89 -89
  75. package/src/kernel/util/imageFile.js +91 -91
  76. package/src/kernel/util/safeValue.js +25 -25
  77. package/src/kernel/util/shortcutKey.js +33 -33
  78. package/src/surface/editor-surface.js +603 -600
  79. package/src/ui/color-panel.js +69 -69
  80. package/src/ui/context-menu.js +135 -133
  81. package/src/ui/dialogs.js +249 -249
  82. package/src/ui/find-bar.js +151 -151
  83. package/src/ui/icons.js +245 -137
  84. package/src/ui/menubar.js +28 -28
  85. package/src/ui/panels.js +115 -115
  86. package/src/ui/popup.js +79 -79
  87. package/src/ui/prompt.js +89 -89
  88. package/src/ui/ribbon.js +485 -485
  89. package/src/ui/special-chars.js +39 -39
  90. package/src/ui/statusbar.js +81 -81
  91. package/src/ui/toolbar.js +32 -32
  92. package/styles/app.css +970 -970
  93. package/styles/editor-content.css +440 -440
  94. package/styles/tokens.css +154 -154
  95. package/styles/word-panel.css +410 -410
package/src/ui/icons.js CHANGED
@@ -1,137 +1,245 @@
1
- // [文件] gbdocx·UI 图标集 —— 工具栏/菜单用的内联 SVG(stroke 风格,currentColor 上色)
2
- const S = (body, size = 16) =>
3
- `<svg viewBox="0 0 24 24" width="${size}" height="${size}" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round">${body}</svg>`;
4
-
5
- export const ICONS = {
6
- bold: S('<path d="M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z"/>'),
7
- italic: S('<path d="M15 5h-5M14 19H9M14 5l-4 14"/>'),
8
- underline: S('<path d="M7 5v7a5 5 0 0 0 10 0V5M5 20h14"/>'),
9
- strike: S('<path d="M5 12h14M8 8a3 3 0 0 1 3-3h3a3 3 0 0 1 0 6M16 16a3 3 0 0 1-3 3h-3a3 3 0 0 1-2-1"/>'),
10
- superscript: S('<path d="M4 19l4.5-11L13 19M5.5 15h5.5"/><path d="M16 8h3l-3 4h3"/>'),
11
- subscript: S('<path d="M4 15l4.5-11L13 15M5.5 11h5.5"/><path d="M16 15h3l-3 4h3"/>'),
12
- colorIcon: S('<path d="M6 18h12M8 14l4-9 4 9M7 14h10"/><path d="M4 21h16"/>'),
13
- bgIcon: S('<path d="M4 20h16M6 14l4-9 4 9M7 14h10"/>'),
14
- alignLeft: S('<path d="M4 6h16M4 12h10M4 18h14"/>'),
15
- alignCenter: S('<path d="M4 6h16M7 12h10M5 18h14"/>'),
16
- alignRight: S('<path d="M4 6h16M10 12h10M6 18h14"/>'),
17
- alignJustify: S('<path d="M4 6h16M4 12h16M4 18h16"/>'),
18
- bullet: S('<path d="M9 6h11M9 12h11M9 18h11M5 6h.01M5 12h.01M5 18h.01"/>'),
19
- ordered: S('<path d="M10 6h10M10 12h10M10 18h10M4 5h1v3M4 11h2l-2 3h2M4 17h1.5a1 1 0 0 1 0 2H4h1.5a1 1 0 0 1 0 2H4"/>'),
20
- indentAdd: S('<path d="M4 6h16M10 12h10M4 18h16M6 9l3 3-3 3"/>'),
21
- indentReduce: S('<path d="M4 6h16M10 12h10M4 18h16M9 9l-3 3 3 3"/>'),
22
- quote: S('<path d="M7 7H4v6h5V8M17 7h-3v6h5V8"/>'),
23
- code: S('<path d="M9 8l-4 4 4 4M15 8l4 4-4 4"/>'),
24
- table: S('<rect x="3" y="4" width="18" height="16" rx="1.5"/><path d="M3 10h18M3 15h18M9 4v16M15 4v16"/>'),
25
- image: S('<rect x="3" y="4" width="18" height="16" rx="1.5"/><path d="M4 16l4-4 4 4 3-3 5 5"/><circle cx="9" cy="9" r="1.4"/>'),
26
- linkIcon: S('<path d="M10 13a4 4 0 0 0 5.7 0l2.3-2.3a4 4 0 0 0-5.7-5.7L11 6"/><path d="M14 11a4 4 0 0 0-5.7 0L6 13.3a4 4 0 0 0 5.7 5.7L13 18"/>'),
27
- divider: S('<path d="M3 12h18"/>'),
28
- pageBreak: S('<path d="M4 4h16v6H4zM4 14h6v6H4zM14 14h6v6h-6z"/>'),
29
- undo: S('<path d="M9 7L4 12l5 5M4 12h11a5 5 0 0 1 0 10"/>'),
30
- redo: S('<path d="M15 7l5 5-5 5M20 12H9a5 5 0 0 0 0 10"/>'),
31
- clear: S('<path d="M6 6l12 12M18 6L6 18"/>'),
32
- chevronDown: S('<path d="M6 9l6 6 6-6"/>'),
33
- // 选项卡面板专用(紧凑图标按钮,与上面同款 stroke 风格)
34
- find: S('<circle cx="10.5" cy="10.5" r="6.5"/><path d="M15.5 15.5L21 21"/>'),
35
- pageSetup: S('<path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2M4 7h16v12a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1z"/><path d="M8 12h8M8 16h5"/>'),
36
- columns: S('<rect x="3" y="4" width="18" height="16" rx="1"/><path d="M12 4v16"/>'),
37
- headerFooter: S('<rect x="3" y="4" width="18" height="16" rx="1"/><path d="M3 9h18M3 15h18"/>'),
38
- footnote: S('<path d="M5 5h14M5 12h9M5 19h6M17 11v8M15 19h4"/>'),
39
- comment: S('<path d="M20 15a3 3 0 0 1-3 3H8l-4 3V6a3 3 0 0 1 3-3h10a3 3 0 0 1 3 3z"/>'),
40
- toc: S('<path d="M4 6h3M4 12h3M4 18h3M11 6h9M11 12h9M11 18h9"/>'),
41
- watermark: S('<path d="M4 5h16v14H4z"/><path d="M9 15l2.5-6 2.5 6M9.8 13h3.4"/>'),
42
- pageNumber: S('<rect x="6" y="3" width="12" height="18" rx="1.5"/><path d="M9 18h6"/>'),
43
- suggest: S('<path d="M4 20h4L19 9a2 2 0 0 0-3-3L5 17z"/><path d="M14 7l3 3"/>'),
44
- accept: S('<path d="M5 13l4 4L19 7"/>'),
45
- reject: S('<path d="M6 6l12 12M18 6L6 18"/>'),
46
- print: S('<path d="M6 9V4h12v5M6 18H4a1 1 0 0 1-1-1v-5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v5a1 1 0 0 1-1 1h-2"/><path d="M6 15h12v5H6z"/>'),
47
- export: S('<path d="M12 3v12M8 11l4 4 4-4M4 17v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3"/>'),
48
- zoomIn: S('<circle cx="10.5" cy="10.5" r="6.5"/><path d="M15.5 15.5L21 21M10.5 7v7M7 10.5h7"/>'),
49
- zoomOut: S('<circle cx="10.5" cy="10.5" r="6.5"/><path d="M15.5 15.5L21 21M7 10.5h7"/>'),
50
- specialChars: S('<path d="M12 4v16M5 8h14M5 8c0 6 14 6 14 0"/>'),
51
- bookmark: S('<path d="M6 4h12v17l-6-4-6 4z"/>'),
52
- panel: S('<rect x="3" y="4" width="18" height="16" rx="1"/><path d="M15 4v16"/>'),
53
- eye: S('<path d="M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12z"/><circle cx="12" cy="12" r="2.8"/>'),
54
- fullscreen: S('<path d="M4 4h6v2H6v4H4zM14 4h6v6h-2V6h-4zM4 14h2v4h4v2H4zM18 14h2v6h-6v-2h4z"/>'),
55
- fullscreenExit: S('<path d="M9 4h2v6H5V8h4zM13 4h2v4h4v2h-6zM5 14h6v6H9v-4H5zM13 16h6v-2h-4v-4h-2z"/>'),
56
- margin: S('<rect x="3" y="3" width="18" height="18" rx="1"/><rect x="8" y="8" width="8" height="8" rx="0.5"/>'),
57
- zoomReset: S('<circle cx="10.5" cy="10.5" r="6.5"/><path d="M15.5 15.5L21 21M7.5 10.5h6"/>'),
58
- selectAll: S('<rect x="3" y="3" width="12" height="12" rx="1"/><path d="M9 21h10a2 2 0 0 0 2-2V9"/>'),
59
-
60
- // ---- WPS 风格功能区专用图标 ----
61
- // 剪贴板
62
- paste: S('<rect x="5" y="4" width="14" height="17" rx="1.5"/><path d="M9 4V3h6v1M8 9h8M8 13h8M8 17h5"/>'),
63
- cut: S('<circle cx="6" cy="17" r="2.5"/><circle cx="18" cy="17" r="2.5"/><path d="M8 15L19 4M16 4L5 15"/>'),
64
- copy: S('<rect x="8" y="8" width="12" height="12" rx="1.5"/><path d="M16 8V5a1.5 1.5 0 0 0-1.5-1.5H5A1.5 1.5 0 0 0 3.5 5v9.5A1.5 1.5 0 0 0 5 16h3"/>'),
65
- formatPainter: S('<path d="M14 4l6 6-8 8-6-6zM6 12l-2 6 6-2M9 9l6 6"/>'),
66
- // 字体
67
- growFont: S('<path d="M3 18l4.5-11L12 18M4.5 14h6M18 7v8M14 11h8"/>'),
68
- shrinkFont: S('<path d="M3 18l4.5-11L12 18M4.5 14h6M14 11h8"/>'),
69
- eraser: S('<path d="M4 15l8-8a2 2 0 0 1 3 0l4 4a2 2 0 0 1 0 3l-7 7H8zM12 19h9"/>'),
70
- highlight: S('<path d="M4 20h16M14 4l6 6-8 8-6-6zM9 15l6 6"/>'),
71
- pinyin: S('<path d="M4 6h16M12 6v13M7 12l3 3M17 12l-3 3M8 19h8"/>'),
72
- circleChar: S('<circle cx="12" cy="12" r="9"/><path d="M9 15l3-7 3 7M10 13h4"/>'),
73
- // 段落
74
- multiLevel: S('<path d="M9 6h11M9 12h11M9 18h11M4 5h1v3M4 11h2l-2 3h2M4 17h2v3H4z"/>'),
75
- outdent: S('<path d="M11 6h9M11 12h9M11 18h9M3 12h6M6 9l-3 3 3 3"/>'),
76
- distribute: S('<path d="M4 6h16M7 12h10M4 18h16M4 3v18M20 3v18"/>'),
77
- lineSpacing: S('<path d="M4 7h10M4 12h10M4 17h10M18 5v14M15 8l3-3 3 3M15 16l3 3 3-3"/>'),
78
- shading: S('<path d="M4 4h16v16H4zM4 9h16M4 14h16M9 4v16M15 4v16"/>'),
79
- borders: S('<rect x="3" y="3" width="18" height="18" rx="1"/><path d="M3 12h18M12 3v18"/>'),
80
- newStyle: S('<path d="M5 19h14M8 15l7-9 3 3-7 9H8zM13 8l3 3"/>'),
81
- // 插入
82
- coverPage: S('<rect x="5" y="3" width="14" height="18" rx="1"/><path d="M5 8h14M8 12h8M8 15h8"/>'),
83
- blankPage: S('<rect x="5" y="3" width="14" height="18" rx="1"/><path d="M9 9h6v6H9z"/>'),
84
- chart: S('<path d="M4 20h16M6 20V10M11 20V5M16 20v-7M21 20v-4"/>'),
85
- screenshot: S('<path d="M4 8V5a1 1 0 0 1 1-1h3M16 4h3a1 1 0 0 1 1 1v3M20 16v3a1 1 0 0 1-1 1h-3M8 20H5a1 1 0 0 1-1-1v-3M4 12h16"/>'),
86
- shape: S('<circle cx="8" cy="8" r="4"/><rect x="12" y="12" width="8" height="8" rx="1"/>'),
87
- iconGallery: S('<path d="M12 3l2.2 5.6L20 9l-5 4 1.5 6L12 16l-4.5 3L9 13 4 9l5.8-.4z"/>'),
88
- mindMap: S('<rect x="2" y="9" width="6" height="5" rx="1"/><rect x="16" y="3" width="6" height="5" rx="1"/><rect x="16" y="15" width="6" height="5" rx="1"/><path d="M8 11h4V6h4M12 11v7h4"/>'),
89
- flowChart: S('<rect x="2" y="4" width="7" height="5" rx="1"/><rect x="15" y="15" width="7" height="5" rx="1"/><path d="M9 6h4v12h2M5 9v6h10"/>'),
90
- textBox: S('<rect x="3" y="5" width="18" height="14" rx="1"/><path d="M7 9h10M12 9v9M9 18h6"/>'),
91
- wordArt: S('<path d="M4 18l4-11 4 11M5 14h6M14 18V7h6M14 12h5"/>'),
92
- equation: S('<path d="M8 4c-2 0-3 1-3 3 0 3 6 4 6 8a3 3 0 0 1-6 0M6 11h8M17 7l4 8M21 7l-4 8"/>'),
93
- insertText: S('<path d="M4 6h10M9 3v6M4 18h16M14 14h6M17 11v6"/>'),
94
- object: S('<path d="M12 3l9 5v8l-9 5-9-5V8zM3 8l9 5 9-5M12 13v8"/>'),
95
- date: S('<rect x="3" y="5" width="18" height="16" rx="2"/><path d="M3 10h18M8 3v4M16 3v4M8 14h3M8 17h6"/>'),
96
- attachment: S('<path d="M20 11l-8 8a5 5 0 0 1-7-7l9-9a3.5 3.5 0 0 1 5 5l-9 9a2 2 0 0 1-3-3l8-8"/>'),
97
- fileLink: S('<path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8M14 3l6 6h-6zM13 15a3 3 0 0 1 5-2M18 13a3 3 0 0 1 1 4l-2 2a3 3 0 0 1-4 0"/>'),
98
- crossReference: S('<path d="M6 4h8l4 4v12H6zM14 4v4h4M9 13h6M9 17h4M4 8v12a2 2 0 0 0 2 2"/>'),
99
- // 页面布局
100
- theme: S('<circle cx="12" cy="12" r="9"/><path d="M12 3a9 9 0 0 0 0 18M8 8h.01M12 6h.01M16 9h.01"/>'),
101
- colors: S('<circle cx="7" cy="8" r="3"/><circle cx="16" cy="7" r="3"/><circle cx="11" cy="16" r="3"/><path d="M7 11v2a2 2 0 0 0 2 2M16 10v3a3 3 0 0 1-3 3"/>'),
102
- effects: S('<path d="M5 3l1.5 4L10 9l-3.5 2L5 15l-1.5-4L0 9l3.5-2zM17 12l1 3 3 1-3 1-1 3-1-3-3-1 3-1z"/>'),
103
- fontCollection: S('<path d="M3 18l4-10 4 10M4 14h6M14 18l3-8 3 8M15 15h4"/>'),
104
- orientation: S('<rect x="6" y="3" width="12" height="18" rx="1"/><path d="M6 8h12M9 12h6M9 15h6"/>'),
105
- paperSize: S('<rect x="4" y="3" width="16" height="18" rx="1"/><path d="M4 17h16M16 17V3"/>'),
106
- textDirection: S('<path d="M12 3v18M9 6l3-3 3 3M9 18l3 3 3-3M6 9h4M6 12h3"/>'),
107
- separator: S('<path d="M3 12h5M16 12h5M9 6v12M12 6v12M15 6v12"/>'),
108
- lineNumbers: S('<path d="M8 4h13M8 10h13M8 16h13M3 4h.01M3 10h.01M3 16h.01"/>'),
109
- background: S('<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 14l4-4 4 4 3-3 4 4 3-3"/>'),
110
- pageBorder: S('<rect x="4" y="3" width="16" height="18" rx="1"/><rect x="7" y="6" width="10" height="12" rx="0.5"/>'),
111
- paperSettings: S('<rect x="4" y="3" width="16" height="18" rx="1"/><path d="M4 9h16M4 15h16M10 3v18M15 3v18"/>'),
112
- wrap: S('<path d="M4 6h16M4 18h16M8 10h8a3 3 0 0 1 0 6H9M8 13l-2 3 2 3"/>'),
113
- alignObjects: S('<path d="M4 3v18M9 7h11M9 14h8M6 4h.01M6 20h.01"/>'),
114
- groupObjects: S('<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/><path d="M10 10l4 4M14 6h4v4M10 18H6v-4"/>'),
115
- rotate: S('<path d="M20 12a8 8 0 1 1-2.3-5.6M20 4v5h-5"/>'),
116
- bringForward: S('<rect x="8" y="8" width="12" height="12" rx="1"/><path d="M4 16V4h12M12 14h4M14 12v4"/>'),
117
- sendBackward: S('<rect x="4" y="4" width="12" height="12" rx="1"/><path d="M20 8v12H8M10 10h4M12 8v4"/>'),
118
- // 引用
119
- updateToc: S('<path d="M4 6h10M4 12h7M4 18h10M18 8a4 4 0 1 1-1 5M17 5v3h3"/>'),
120
- tocLevel: S('<path d="M4 6h16M6 12h14M8 18h12M4 12h.01M4 18h.01"/>'),
121
- prevFootnote: S('<path d="M15 18l-6-6 6-6M8 12h8M4 4h.01M4 20h.01"/>'),
122
- nextFootnote: S('<path d="M9 6l6 6-6 6M8 12h8M20 4h.01M20 20h.01"/>'),
123
- insertEndnote: S('<path d="M12 4v12M8 12l4 4 4-4M5 20h14"/>'),
124
- prevEndnote: S('<path d="M15 18l-6-6 6-6M8 12h8M4 20h16"/>'),
125
- nextEndnote: S('<path d="M9 6l6 6-6 6M8 12h8M4 20h16"/>'),
126
- footnoteSep: S('<path d="M4 6h16M4 18h16M4 12h4M16 12h4M9 12h6"/>'),
127
- caption: S('<path d="M4 5h16v11H4zM8 9h8M8 13h5M4 20h10"/>'),
128
- markCitation: S('<path d="M8 6c-2 0-3 1-3 3s1 3 3 3c-1 2-2 3-4 4M16 6c-2 0-3 1-3 3s1 3 3 3c-1 2-2 3-4 4"/>'),
129
- insertIndex: S('<path d="M4 5h16M4 11h16M4 17h10M17 15v6M14 18h6"/>'),
130
- updateIndex: S('<path d="M4 5h16M4 11h16M4 17h10M18 14a3 3 0 1 1-1 4M17 12v2h2"/>'),
131
- mail: S('<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/>'),
132
- download: S('<path d="M12 3v12M8 11l4 4 4-4M4 17v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3"/>'),
133
- rename: S('<path d="M4 20h4L19 9a2 2 0 0 0-3-3L5 17v3z"/><path d="M14.5 6.5l3 3"/>'),
134
- };
135
-
136
- /** 取图标 SVG 串(未登记返回空串) */
137
- export const icon = (name) => ICONS[name] || '';
1
+ // [文件] gbdocx·UI 图标集 —— 工具栏/菜单图标注册表:字形数据取自开源 lucide 图标库(ISC 许可),
2
+ // 本文件只维护「业务键名 → lucide 图标」映射,不再手写任何 path。
3
+ import {
4
+ AArrowDown,
5
+ AArrowUp,
6
+ ALargeSmall,
7
+ AlignCenter,
8
+ AlignCenterVertical,
9
+ AlignHorizontalDistributeCenter,
10
+ AlignJustify,
11
+ AlignLeft,
12
+ AlignRight,
13
+ AlignVerticalSpaceAround,
14
+ ArrowDownToLine,
15
+ ArrowDownUp,
16
+ Asterisk,
17
+ Baseline,
18
+ Bold,
19
+ BookMarked,
20
+ BookOpen,
21
+ Bookmark,
22
+ Box,
23
+ BringToFront,
24
+ Calendar,
25
+ Captions,
26
+ CaseUpper,
27
+ ChartColumn,
28
+ Check,
29
+ ChevronDown,
30
+ ChevronUp,
31
+ Circle,
32
+ ClipboardPaste,
33
+ CodeXml,
34
+ Columns2,
35
+ Contrast,
36
+ Copy,
37
+ Download,
38
+ Droplets,
39
+ Eraser,
40
+ Eye,
41
+ File,
42
+ FileDigit,
43
+ FileSymlink,
44
+ FileText,
45
+ Frame,
46
+ GalleryVerticalEnd,
47
+ GitBranch,
48
+ Grid2X2,
49
+ Group,
50
+ Highlighter,
51
+ Image,
52
+ IndentDecrease,
53
+ IndentIncrease,
54
+ Italic,
55
+ Languages,
56
+ Link,
57
+ List,
58
+ ListEnd,
59
+ ListOrdered,
60
+ ListTree,
61
+ Mail,
62
+ Maximize,
63
+ MessageSquare,
64
+ Minimize,
65
+ Minus,
66
+ Omega,
67
+ PaintBucket,
68
+ PaintRoller,
69
+ Paintbrush,
70
+ Palette,
71
+ PanelRight,
72
+ Paperclip,
73
+ Pencil,
74
+ Printer,
75
+ Quote,
76
+ RectangleVertical,
77
+ Redo2,
78
+ RefreshCw,
79
+ RotateCcw,
80
+ RotateCw,
81
+ Ruler,
82
+ Scan,
83
+ Scissors,
84
+ Search,
85
+ SendToBack,
86
+ SeparatorHorizontal,
87
+ SeparatorVertical,
88
+ Shapes,
89
+ Sigma,
90
+ Sparkles,
91
+ SquareDashed,
92
+ SquareSplitVertical,
93
+ Star,
94
+ Strikethrough,
95
+ Subscript,
96
+ Superscript,
97
+ SwatchBook,
98
+ Table,
99
+ TableProperties,
100
+ Tag,
101
+ Tally4,
102
+ Text,
103
+ TextSelect,
104
+ Type,
105
+ Underline,
106
+ Undo2,
107
+ Wallpaper,
108
+ Workflow,
109
+ WrapText,
110
+ X,
111
+ ZoomIn,
112
+ ZoomOut,
113
+ } from 'gbicons/nodes';
114
+ import { iconNodeSvg } from 'gbicons/nodes';
115
+
116
+ /** 业务键名 → lucide IconNode */
117
+ const NODES = {
118
+ bold: Bold,
119
+ italic: Italic,
120
+ underline: Underline,
121
+ strike: Strikethrough,
122
+ superscript: Superscript,
123
+ subscript: Subscript,
124
+ colorIcon: Baseline,
125
+ bgIcon: PaintBucket,
126
+ alignLeft: AlignLeft,
127
+ alignCenter: AlignCenter,
128
+ alignRight: AlignRight,
129
+ alignJustify: AlignJustify,
130
+ bullet: List,
131
+ ordered: ListOrdered,
132
+ indentAdd: IndentIncrease,
133
+ indentReduce: IndentDecrease,
134
+ quote: Quote,
135
+ code: CodeXml,
136
+ table: Table,
137
+ image: Image,
138
+ linkIcon: Link,
139
+ divider: Minus,
140
+ pageBreak: SquareSplitVertical,
141
+ undo: Undo2,
142
+ redo: Redo2,
143
+ clear: X,
144
+ chevronDown: ChevronDown,
145
+ find: Search,
146
+ pageSetup: FileText,
147
+ columns: Columns2,
148
+ headerFooter: GalleryVerticalEnd,
149
+ footnote: Asterisk,
150
+ comment: MessageSquare,
151
+ toc: ListTree,
152
+ watermark: Droplets,
153
+ pageNumber: FileDigit,
154
+ suggest: Pencil,
155
+ accept: Check,
156
+ reject: X,
157
+ print: Printer,
158
+ export: Download,
159
+ zoomIn: ZoomIn,
160
+ zoomOut: ZoomOut,
161
+ specialChars: Omega,
162
+ bookmark: Bookmark,
163
+ panel: PanelRight,
164
+ eye: Eye,
165
+ fullscreen: Maximize,
166
+ fullscreenExit: Minimize,
167
+ margin: SquareDashed,
168
+ zoomReset: RotateCcw,
169
+ selectAll: TextSelect,
170
+ paste: ClipboardPaste,
171
+ cut: Scissors,
172
+ copy: Copy,
173
+ formatPainter: PaintRoller,
174
+ growFont: AArrowUp,
175
+ shrinkFont: AArrowDown,
176
+ eraser: Eraser,
177
+ highlight: Highlighter,
178
+ pinyin: Languages,
179
+ circleChar: Circle,
180
+ multiLevel: ListTree,
181
+ outdent: IndentDecrease,
182
+ distribute: AlignHorizontalDistributeCenter,
183
+ lineSpacing: AlignVerticalSpaceAround,
184
+ shading: Paintbrush,
185
+ borders: Grid2X2,
186
+ newStyle: Palette,
187
+ coverPage: BookOpen,
188
+ blankPage: File,
189
+ chart: ChartColumn,
190
+ screenshot: Scan,
191
+ shape: Shapes,
192
+ iconGallery: Star,
193
+ mindMap: GitBranch,
194
+ flowChart: Workflow,
195
+ textBox: Type,
196
+ wordArt: CaseUpper,
197
+ equation: Sigma,
198
+ insertText: Text,
199
+ object: Box,
200
+ date: Calendar,
201
+ attachment: Paperclip,
202
+ fileLink: FileSymlink,
203
+ crossReference: BookMarked,
204
+ theme: Contrast,
205
+ colors: SwatchBook,
206
+ effects: Sparkles,
207
+ fontCollection: ALargeSmall,
208
+ orientation: RectangleVertical,
209
+ paperSize: Ruler,
210
+ textDirection: ArrowDownUp,
211
+ separator: SeparatorVertical,
212
+ lineNumbers: Tally4,
213
+ background: Wallpaper,
214
+ pageBorder: Frame,
215
+ paperSettings: TableProperties,
216
+ wrap: WrapText,
217
+ alignObjects: AlignCenterVertical,
218
+ groupObjects: Group,
219
+ rotate: RotateCw,
220
+ bringForward: BringToFront,
221
+ sendBackward: SendToBack,
222
+ updateToc: RefreshCw,
223
+ tocLevel: ListEnd,
224
+ prevFootnote: ChevronUp,
225
+ nextFootnote: ChevronDown,
226
+ insertEndnote: ArrowDownToLine,
227
+ prevEndnote: ChevronUp,
228
+ nextEndnote: ChevronDown,
229
+ footnoteSep: SeparatorHorizontal,
230
+ caption: Captions,
231
+ markCitation: Quote,
232
+ insertIndex: Tag,
233
+ updateIndex: RefreshCw,
234
+ mail: Mail,
235
+ download: Download,
236
+ rename: Pencil,
237
+ };
238
+
239
+ /** 预渲染成 16px / 1.9 描边的内联串(24 网格 stroke 风,与功能区排版对齐) */
240
+ const ICONS = Object.fromEntries(
241
+ Object.entries(NODES).map(([name, node]) => [name, iconNodeSvg(node, { sw: 1.9 })]),
242
+ );
243
+
244
+ /** 取图标 SVG 串(未登记返回空串) */
245
+ export const icon = (name) => ICONS[name] || '';
package/src/ui/menubar.js CHANGED
@@ -1,28 +1,28 @@
1
- // [文件] gbdocx·MenuBar —— 顶部菜单栏(结构来自 docx/menus.js 的 buildMenus;条目为函数,每次打开现求值)
2
- import { openMenu } from './context-menu.js';
3
-
4
- /** 构建菜单栏 DOM:menus = [{key,label,items:()=>条目[]}];disabledKeys 里的菜单只读档不可点 */
5
- export function buildMenuBar(menus, disabledKeys = []) {
6
- const bar = document.createElement('div');
7
- bar.className = 'gbd-menubar';
8
- for (const menu of menus) {
9
- const btn = document.createElement('button');
10
- btn.type = 'button';
11
- btn.className = 'gbd-menubar__btn';
12
- btn.disabled = disabledKeys.includes(menu.key);
13
- btn.textContent = menu.label;
14
- btn.addEventListener('click', () => {
15
- // 按钮态由浮层关闭回调统一收:Esc / 外点 / 点条目都会经过它,
16
- // 不再挂 gbdocx-menu-close 监听(那条路径只在点条目时触发,其余关闭方式会残留监听)
17
- btn.classList.add('gbd-is-open');
18
- openMenu({
19
- anchor: btn,
20
- items: menu.items(),
21
- placement: 'bottom-start',
22
- onClose: () => btn.classList.remove('gbd-is-open'),
23
- });
24
- });
25
- bar.appendChild(btn);
26
- }
27
- return bar;
28
- }
1
+ // [文件] gbdocx·MenuBar —— 顶部菜单栏(结构来自 docx/menus.js 的 buildMenus;条目为函数,每次打开现求值)
2
+ import { openMenu } from './context-menu.js';
3
+
4
+ /** 构建菜单栏 DOM:menus = [{key,label,items:()=>条目[]}];disabledKeys 里的菜单只读档不可点 */
5
+ export function buildMenuBar(menus, disabledKeys = []) {
6
+ const bar = document.createElement('div');
7
+ bar.className = 'gbd-menubar';
8
+ for (const menu of menus) {
9
+ const btn = document.createElement('button');
10
+ btn.type = 'button';
11
+ btn.className = 'gbd-menubar__btn';
12
+ btn.disabled = disabledKeys.includes(menu.key);
13
+ btn.textContent = menu.label;
14
+ btn.addEventListener('click', () => {
15
+ // 按钮态由浮层关闭回调统一收:Esc / 外点 / 点条目都会经过它,
16
+ // 不再挂 gbdocx-menu-close 监听(那条路径只在点条目时触发,其余关闭方式会残留监听)
17
+ btn.classList.add('gbd-is-open');
18
+ openMenu({
19
+ anchor: btn,
20
+ items: menu.items(),
21
+ placement: 'bottom-start',
22
+ onClose: () => btn.classList.remove('gbd-is-open'),
23
+ });
24
+ });
25
+ bar.appendChild(btn);
26
+ }
27
+ return bar;
28
+ }