@veltra/sheet 4.1.2 → 4.1.4

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 (69) hide show
  1. package/dist/components/sheet/float-image-menu.js +1 -2
  2. package/dist/components/sheet/formula-bar.js +1 -2
  3. package/dist/components/sheet/formula-suggest-list.js +1 -2
  4. package/dist/components/sheet/import-file.js +3 -5
  5. package/dist/components/sheet/insert-count-menu-item.js +1 -2
  6. package/dist/components/sheet/insert-image.js +1 -2
  7. package/dist/components/sheet/popup-helpers.js +1 -2
  8. package/dist/components/sheet/popups/border-popup.js +1 -2
  9. package/dist/components/sheet/popups/border-preset-glyph.js +1 -2
  10. package/dist/components/sheet/popups/export-popup.js +1 -2
  11. package/dist/components/sheet/popups/fill-color-popup.js +1 -2
  12. package/dist/components/sheet/popups/find-popup.js +1 -2
  13. package/dist/components/sheet/popups/font-color-popup.js +1 -2
  14. package/dist/components/sheet/popups/font-size-popup.js +1 -2
  15. package/dist/components/sheet/popups/functions-popup.js +1 -2
  16. package/dist/components/sheet/popups/hyperlink-popup.js +1 -2
  17. package/dist/components/sheet/popups/import.worker.d.ts +1 -3
  18. package/dist/components/sheet/popups/import.worker.js +23462 -3
  19. package/dist/components/sheet/popups/insert-image-popup.js +1 -2
  20. package/dist/components/sheet/sheet-context-menu.js +0 -1
  21. package/dist/components/sheet/sheet-tabs.js +1 -2
  22. package/dist/components/sheet/sheet-toolbar.js +1 -2
  23. package/dist/components/sheet/sheet.js +1 -2
  24. package/dist/components/sheet/use-cell-link-tooltip.js +1 -2
  25. package/dist/components/sheet/use-find-replace.js +1 -2
  26. package/dist/components/sheet/use-formula-ref-select.js +1 -2
  27. package/dist/components/sheet/use-formula-suggest.js +0 -1
  28. package/dist/components/sheet/use-sheet-grid.js +1 -2
  29. package/dist/components/sheet/use-sheet-state.js +2 -3
  30. package/dist/components/sheet/use-sheet-tabs-bar.js +1 -2
  31. package/dist/components/sheet/use-tool-groups.js +1 -2
  32. package/dist/components/sheet/use-tool-popup.js +1 -2
  33. package/dist/components/sheet/use-toolbar-scroll.js +1 -2
  34. package/dist/index.js +1 -2
  35. package/dist/tools/apply-style.js +1 -2
  36. package/dist/tools/builtin.js +308 -307
  37. package/dist/tools/context.d.ts +1 -3
  38. package/dist/tools/context.js +0 -1
  39. package/dist/tools/download.js +9 -6
  40. package/dist/tools/export.worker.d.ts +1 -3
  41. package/dist/tools/export.worker.js +23459 -3
  42. package/dist/tools/registry.d.ts +4 -4
  43. package/dist/tools/registry.js +8 -4
  44. package/dist/types/sheet.d.ts +1 -3
  45. package/package.json +4 -6
  46. package/src/components/sheet/__test__/canvas-mock.ts +3 -1
  47. package/src/components/sheet/__test__/find-shortcut-anchor.test.ts +2 -0
  48. package/src/components/sheet/__test__/formula-bar.test.ts +6 -3
  49. package/src/components/sheet/__test__/formula-capability.test.ts +2 -0
  50. package/src/components/sheet/__test__/functions-popup.test.ts +2 -0
  51. package/src/components/sheet/__test__/hyperlink-popup.test.ts +2 -0
  52. package/src/components/sheet/__test__/import-file.test.ts +59 -4
  53. package/src/components/sheet/__test__/insert-count-menu-item.test.ts +2 -0
  54. package/src/components/sheet/__test__/insert-image-popup.test.ts +2 -0
  55. package/src/components/sheet/__test__/insert-image.test.ts +5 -3
  56. package/src/components/sheet/__test__/sheet-component.test.ts +4 -1
  57. package/src/components/sheet/__test__/sheet-context-menu.test.ts +2 -2
  58. package/src/components/sheet/__test__/sheet-grow-on-scroll.test.ts +2 -0
  59. package/src/components/sheet/__test__/sheet-scrollbar.test.ts +2 -0
  60. package/src/components/sheet/__test__/sheet-theme.test.ts +2 -0
  61. package/src/components/sheet/import-file.ts +3 -3
  62. package/src/index.ts +1 -3
  63. package/src/tools/__test__/builtin.test.ts +4 -4
  64. package/src/tools/__test__/context.test.ts +2 -2
  65. package/src/tools/__test__/download.test.ts +108 -0
  66. package/src/tools/builtin.ts +345 -344
  67. package/src/tools/download.ts +9 -5
  68. package/src/tools/registry.ts +8 -2
  69. package/src/tools/index.ts +0 -3
@@ -28,7 +28,7 @@ import { rangesEqual } from 'infinitable/sheet'
28
28
  import type { HorizontalAlign, VerticalAlign } from 'infinitable/sheet'
29
29
 
30
30
  import type { SheetContext } from './context'
31
- import { registerTool } from './registry'
31
+ import type { SheetTool } from './registry'
32
32
 
33
33
  /** 取活动格所在首选区;无选区返回 null */
34
34
  function selectionRange(ctx: SheetContext) {
@@ -69,363 +69,364 @@ function toggleAlign(
69
69
  * 内置工具(dogfood 扩展机制)。
70
70
  *
71
71
  * 分组:history | cell | text | edit | insert | file。
72
+ * 纯数据:由 defaultToolRegistry 构造时装入,不在模块顶层注册。
72
73
  * 与第三方工具走同一注册通道,可由宿主 unregisterTool 移除或同 id 覆盖。
73
- * 本模块由包入口引入:经包入口导入即完成注册。
74
74
  */
75
+ export const BUILTIN_TOOLS: readonly SheetTool[] = [
76
+ // ─── history ───────────────────────────────────────────────
77
+
78
+ {
79
+ id: 'undo',
80
+ title: '撤销',
81
+ icon: Rollback,
82
+ tooltip: '撤销(Ctrl/Cmd+Z)',
83
+ group: 'history',
84
+ order: 0,
85
+ disabled: (ctx) => !ctx.canUndo,
86
+ onClick: (ctx) => {
87
+ ctx.undo()
88
+ }
89
+ },
75
90
 
76
- // ─── history ───────────────────────────────────────────────
77
-
78
- registerTool({
79
- id: 'undo',
80
- title: '撤销',
81
- icon: Rollback,
82
- tooltip: '撤销(Ctrl/Cmd+Z)',
83
- group: 'history',
84
- order: 0,
85
- disabled: (ctx) => !ctx.canUndo,
86
- onClick: (ctx) => {
87
- ctx.undo()
88
- }
89
- })
90
-
91
- registerTool({
92
- id: 'redo',
93
- title: '重做',
94
- icon: Rollfront,
95
- tooltip: '重做(Ctrl/Cmd+Shift+Z 或 Ctrl+Y)',
96
- group: 'history',
97
- order: 1,
98
- disabled: (ctx) => !ctx.canRedo,
99
- onClick: (ctx) => {
100
- ctx.redo()
101
- }
102
- })
103
-
104
- // ─── cell(边框 / 填充颜色 / 合并 / 取消合并)────────────────
105
-
106
- registerTool({
107
- id: 'border',
108
- title: '边框',
109
- icon: Border,
110
- tooltip: '设置单元格边框',
111
- group: 'cell',
112
- order: 0,
113
- popup: 'border',
114
- disabled: (ctx) => !ctx.getSelection().activeCell,
115
- onClick: () => {}
116
- })
117
-
118
- registerTool({
119
- id: 'fill-color',
120
- title: '填充颜色',
121
- icon: Fill,
122
- tooltip: '设置单元格背景填充',
123
- group: 'cell',
124
- order: 1,
125
- popup: 'fill-color',
126
- disabled: (ctx) => !ctx.getSelection().activeCell,
127
- onClick: () => {}
128
- })
129
-
130
- registerTool({
131
- id: 'merge',
132
- title: '合并',
133
- icon: MergeCells,
134
- tooltip: '合并选中区域',
135
- group: 'cell',
136
- order: 2,
137
- disabled: (ctx) => {
138
- const { activeCell, ranges } = ctx.getSelection()
139
- const range = ranges[0]
140
- if (!activeCell || !range) return true
141
- // 单格无可合并
142
- if (range.start.row === range.end.row && range.start.col === range.end.col) return true
143
- // 选区恰好等于既有合并区域 → 无操作必要
144
- const mergeRange = ctx.getCellInfo(activeCell).mergeRange
145
- return !!mergeRange && rangesEqual(mergeRange, range)
91
+ {
92
+ id: 'redo',
93
+ title: '重做',
94
+ icon: Rollfront,
95
+ tooltip: '重做(Ctrl/Cmd+Shift+Z 或 Ctrl+Y)',
96
+ group: 'history',
97
+ order: 1,
98
+ disabled: (ctx) => !ctx.canRedo,
99
+ onClick: (ctx) => {
100
+ ctx.redo()
101
+ }
146
102
  },
147
- onClick: (ctx) => {
148
- const range = ctx.getSelection().ranges[0]
149
- if (!range) return
150
- ctx.mergeCells(range)
151
- }
152
- })
153
-
154
- registerTool({
155
- id: 'unmerge',
156
- title: '取消合并',
157
- icon: UnmergeCells,
158
- tooltip: '取消活动格所在合并',
159
- group: 'cell',
160
- order: 3,
161
- disabled: (ctx) => {
162
- const { activeCell } = ctx.getSelection()
163
- if (!activeCell) return true
164
- return !ctx.getCellInfo(activeCell).mergeRange
103
+
104
+ // ─── cell(边框 / 填充颜色 / 合并 / 取消合并)────────────────
105
+
106
+ {
107
+ id: 'border',
108
+ title: '边框',
109
+ icon: Border,
110
+ tooltip: '设置单元格边框',
111
+ group: 'cell',
112
+ order: 0,
113
+ popup: 'border',
114
+ disabled: (ctx) => !ctx.getSelection().activeCell,
115
+ onClick: () => {}
165
116
  },
166
- onClick: (ctx) => {
167
- const { activeCell, ranges } = ctx.getSelection()
168
- if (!activeCell || !ranges[0]) return
169
- ctx.unmergeCells(ranges[0])
170
- }
171
- })
172
-
173
- // ─── text(B/I/U/S / 字体颜色 / 字号 / 对齐×6 / 自动换行)────
174
-
175
- registerTool({
176
- id: 'bold',
177
- title: '加粗',
178
- icon: Bold,
179
- tooltip: '加粗',
180
- group: 'text',
181
- order: 0,
182
- disabled: (ctx) => !ctx.getSelection().activeCell,
183
- active: (ctx) => {
184
- const active = ctx.getSelection().activeCell
185
- return !!active && ctx.getEffectiveStyle(active)?.font?.bold === true
117
+
118
+ {
119
+ id: 'fill-color',
120
+ title: '填充颜色',
121
+ icon: Fill,
122
+ tooltip: '设置单元格背景填充',
123
+ group: 'cell',
124
+ order: 1,
125
+ popup: 'fill-color',
126
+ disabled: (ctx) => !ctx.getSelection().activeCell,
127
+ onClick: () => {}
128
+ },
129
+
130
+ {
131
+ id: 'merge',
132
+ title: '合并',
133
+ icon: MergeCells,
134
+ tooltip: '合并选中区域',
135
+ group: 'cell',
136
+ order: 2,
137
+ disabled: (ctx) => {
138
+ const { activeCell, ranges } = ctx.getSelection()
139
+ const range = ranges[0]
140
+ if (!activeCell || !range) return true
141
+ // 单格无可合并
142
+ if (range.start.row === range.end.row && range.start.col === range.end.col) return true
143
+ // 选区恰好等于既有合并区域 → 无操作必要
144
+ const mergeRange = ctx.getCellInfo(activeCell).mergeRange
145
+ return !!mergeRange && rangesEqual(mergeRange, range)
146
+ },
147
+ onClick: (ctx) => {
148
+ const range = ctx.getSelection().ranges[0]
149
+ if (!range) return
150
+ ctx.mergeCells(range)
151
+ }
152
+ },
153
+
154
+ {
155
+ id: 'unmerge',
156
+ title: '取消合并',
157
+ icon: UnmergeCells,
158
+ tooltip: '取消活动格所在合并',
159
+ group: 'cell',
160
+ order: 3,
161
+ disabled: (ctx) => {
162
+ const { activeCell } = ctx.getSelection()
163
+ if (!activeCell) return true
164
+ return !ctx.getCellInfo(activeCell).mergeRange
165
+ },
166
+ onClick: (ctx) => {
167
+ const { activeCell, ranges } = ctx.getSelection()
168
+ if (!activeCell || !ranges[0]) return
169
+ ctx.unmergeCells(ranges[0])
170
+ }
171
+ },
172
+
173
+ // ─── text(B/I/U/S / 字体颜色 / 字号 / 对齐×6 / 自动换行)────
174
+
175
+ {
176
+ id: 'bold',
177
+ title: '加粗',
178
+ icon: Bold,
179
+ tooltip: '加粗',
180
+ group: 'text',
181
+ order: 0,
182
+ disabled: (ctx) => !ctx.getSelection().activeCell,
183
+ active: (ctx) => {
184
+ const active = ctx.getSelection().activeCell
185
+ return !!active && ctx.getEffectiveStyle(active)?.font?.bold === true
186
+ },
187
+ onClick: (ctx) => toggleFontFlag(ctx, 'bold')
188
+ },
189
+
190
+ {
191
+ id: 'italic',
192
+ title: '斜体',
193
+ icon: Italic,
194
+ tooltip: '斜体',
195
+ group: 'text',
196
+ order: 1,
197
+ disabled: (ctx) => !ctx.getSelection().activeCell,
198
+ active: (ctx) => {
199
+ const active = ctx.getSelection().activeCell
200
+ return !!active && ctx.getEffectiveStyle(active)?.font?.italic === true
201
+ },
202
+ onClick: (ctx) => toggleFontFlag(ctx, 'italic')
203
+ },
204
+
205
+ {
206
+ id: 'underline',
207
+ title: '下划线',
208
+ icon: Underline,
209
+ tooltip: '下划线',
210
+ group: 'text',
211
+ order: 2,
212
+ disabled: (ctx) => !ctx.getSelection().activeCell,
213
+ active: (ctx) => {
214
+ const active = ctx.getSelection().activeCell
215
+ return !!active && ctx.getEffectiveStyle(active)?.font?.underline === true
216
+ },
217
+ onClick: (ctx) => toggleFontFlag(ctx, 'underline')
218
+ },
219
+
220
+ {
221
+ id: 'strikethrough',
222
+ title: '删除线',
223
+ icon: Strikethrough,
224
+ tooltip: '删除线',
225
+ group: 'text',
226
+ order: 3,
227
+ disabled: (ctx) => !ctx.getSelection().activeCell,
228
+ active: (ctx) => {
229
+ const active = ctx.getSelection().activeCell
230
+ return !!active && ctx.getEffectiveStyle(active)?.font?.strikethrough === true
231
+ },
232
+ onClick: (ctx) => toggleFontFlag(ctx, 'strikethrough')
186
233
  },
187
- onClick: (ctx) => toggleFontFlag(ctx, 'bold')
188
- })
189
-
190
- registerTool({
191
- id: 'italic',
192
- title: '斜体',
193
- icon: Italic,
194
- tooltip: '斜体',
195
- group: 'text',
196
- order: 1,
197
- disabled: (ctx) => !ctx.getSelection().activeCell,
198
- active: (ctx) => {
199
- const active = ctx.getSelection().activeCell
200
- return !!active && ctx.getEffectiveStyle(active)?.font?.italic === true
234
+
235
+ {
236
+ id: 'font-color',
237
+ title: '字体颜色',
238
+ icon: FontColor,
239
+ tooltip: '设置字体颜色',
240
+ group: 'text',
241
+ order: 4,
242
+ popup: 'font-color',
243
+ disabled: (ctx) => !ctx.getSelection().activeCell,
244
+ onClick: () => {}
201
245
  },
202
- onClick: (ctx) => toggleFontFlag(ctx, 'italic')
203
- })
204
-
205
- registerTool({
206
- id: 'underline',
207
- title: '下划线',
208
- icon: Underline,
209
- tooltip: '下划线',
210
- group: 'text',
211
- order: 2,
212
- disabled: (ctx) => !ctx.getSelection().activeCell,
213
- active: (ctx) => {
214
- const active = ctx.getSelection().activeCell
215
- return !!active && ctx.getEffectiveStyle(active)?.font?.underline === true
246
+
247
+ {
248
+ id: 'font-size',
249
+ title: '字号',
250
+ icon: FontSize,
251
+ tooltip: '设置字体大小',
252
+ group: 'text',
253
+ order: 5,
254
+ popup: 'font-size',
255
+ disabled: (ctx) => !ctx.getSelection().activeCell,
256
+ onClick: () => {}
257
+ },
258
+
259
+ {
260
+ id: 'align-left',
261
+ title: '左对齐',
262
+ icon: VerticalAlignLeft,
263
+ tooltip: '水平左对齐',
264
+ group: 'text',
265
+ order: 6,
266
+ disabled: (ctx) => !ctx.getSelection().activeCell,
267
+ active: (ctx) => {
268
+ const active = ctx.getSelection().activeCell
269
+ return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === 'left'
270
+ },
271
+ onClick: (ctx) => toggleAlign(ctx, 'horizontal', 'left')
272
+ },
273
+
274
+ {
275
+ id: 'align-center',
276
+ title: '居中',
277
+ icon: VerticalAlignCenter,
278
+ tooltip: '水平居中',
279
+ group: 'text',
280
+ order: 7,
281
+ disabled: (ctx) => !ctx.getSelection().activeCell,
282
+ active: (ctx) => {
283
+ const active = ctx.getSelection().activeCell
284
+ return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === 'center'
285
+ },
286
+ onClick: (ctx) => toggleAlign(ctx, 'horizontal', 'center')
287
+ },
288
+
289
+ {
290
+ id: 'align-right',
291
+ title: '右对齐',
292
+ icon: VerticalAlignRight,
293
+ tooltip: '水平右对齐',
294
+ group: 'text',
295
+ order: 8,
296
+ disabled: (ctx) => !ctx.getSelection().activeCell,
297
+ active: (ctx) => {
298
+ const active = ctx.getSelection().activeCell
299
+ return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === 'right'
300
+ },
301
+ onClick: (ctx) => toggleAlign(ctx, 'horizontal', 'right')
216
302
  },
217
- onClick: (ctx) => toggleFontFlag(ctx, 'underline')
218
- })
219
-
220
- registerTool({
221
- id: 'strikethrough',
222
- title: '删除线',
223
- icon: Strikethrough,
224
- tooltip: '删除线',
225
- group: 'text',
226
- order: 3,
227
- disabled: (ctx) => !ctx.getSelection().activeCell,
228
- active: (ctx) => {
229
- const active = ctx.getSelection().activeCell
230
- return !!active && ctx.getEffectiveStyle(active)?.font?.strikethrough === true
303
+
304
+ {
305
+ id: 'valign-top',
306
+ title: '顶端对齐',
307
+ icon: AlignTop,
308
+ tooltip: '垂直顶端对齐',
309
+ group: 'text',
310
+ order: 9,
311
+ disabled: (ctx) => !ctx.getSelection().activeCell,
312
+ active: (ctx) => {
313
+ const active = ctx.getSelection().activeCell
314
+ return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === 'top'
315
+ },
316
+ onClick: (ctx) => toggleAlign(ctx, 'vertical', 'top')
231
317
  },
232
- onClick: (ctx) => toggleFontFlag(ctx, 'strikethrough')
233
- })
234
-
235
- registerTool({
236
- id: 'font-color',
237
- title: '字体颜色',
238
- icon: FontColor,
239
- tooltip: '设置字体颜色',
240
- group: 'text',
241
- order: 4,
242
- popup: 'font-color',
243
- disabled: (ctx) => !ctx.getSelection().activeCell,
244
- onClick: () => {}
245
- })
246
-
247
- registerTool({
248
- id: 'font-size',
249
- title: '字号',
250
- icon: FontSize,
251
- tooltip: '设置字体大小',
252
- group: 'text',
253
- order: 5,
254
- popup: 'font-size',
255
- disabled: (ctx) => !ctx.getSelection().activeCell,
256
- onClick: () => {}
257
- })
258
-
259
- registerTool({
260
- id: 'align-left',
261
- title: '左对齐',
262
- icon: VerticalAlignLeft,
263
- tooltip: '水平左对齐',
264
- group: 'text',
265
- order: 6,
266
- disabled: (ctx) => !ctx.getSelection().activeCell,
267
- active: (ctx) => {
268
- const active = ctx.getSelection().activeCell
269
- return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === 'left'
318
+
319
+ {
320
+ id: 'valign-middle',
321
+ title: '垂直居中',
322
+ icon: AlignCenter,
323
+ tooltip: '垂直居中对齐',
324
+ group: 'text',
325
+ order: 10,
326
+ disabled: (ctx) => !ctx.getSelection().activeCell,
327
+ active: (ctx) => {
328
+ const active = ctx.getSelection().activeCell
329
+ return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === 'middle'
330
+ },
331
+ onClick: (ctx) => toggleAlign(ctx, 'vertical', 'middle')
270
332
  },
271
- onClick: (ctx) => toggleAlign(ctx, 'horizontal', 'left')
272
- })
273
-
274
- registerTool({
275
- id: 'align-center',
276
- title: '居中',
277
- icon: VerticalAlignCenter,
278
- tooltip: '水平居中',
279
- group: 'text',
280
- order: 7,
281
- disabled: (ctx) => !ctx.getSelection().activeCell,
282
- active: (ctx) => {
283
- const active = ctx.getSelection().activeCell
284
- return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === 'center'
333
+
334
+ {
335
+ id: 'valign-bottom',
336
+ title: '底端对齐',
337
+ icon: AlignBottom,
338
+ tooltip: '垂直底端对齐',
339
+ group: 'text',
340
+ order: 11,
341
+ disabled: (ctx) => !ctx.getSelection().activeCell,
342
+ active: (ctx) => {
343
+ const active = ctx.getSelection().activeCell
344
+ return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === 'bottom'
345
+ },
346
+ onClick: (ctx) => toggleAlign(ctx, 'vertical', 'bottom')
285
347
  },
286
- onClick: (ctx) => toggleAlign(ctx, 'horizontal', 'center')
287
- })
288
-
289
- registerTool({
290
- id: 'align-right',
291
- title: '右对齐',
292
- icon: VerticalAlignRight,
293
- tooltip: '水平右对齐',
294
- group: 'text',
295
- order: 8,
296
- disabled: (ctx) => !ctx.getSelection().activeCell,
297
- active: (ctx) => {
298
- const active = ctx.getSelection().activeCell
299
- return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === 'right'
348
+
349
+ {
350
+ id: 'wrap-text',
351
+ title: '自动换行',
352
+ icon: Wrap,
353
+ tooltip: '自动换行',
354
+ group: 'text',
355
+ order: 12,
356
+ disabled: (ctx) => !ctx.getSelection().activeCell,
357
+ active: (ctx) => {
358
+ const active = ctx.getSelection().activeCell
359
+ return !!active && ctx.getEffectiveStyle(active)?.align?.wrap === true
360
+ },
361
+ onClick: (ctx) => {
362
+ const sel = selectionRange(ctx)
363
+ if (!sel) return
364
+ const on = ctx.getEffectiveStyle(sel.activeCell)?.align?.wrap === true
365
+ ctx.applyStyle(sel.range, { align: { wrap: on ? null : true } })
366
+ }
300
367
  },
301
- onClick: (ctx) => toggleAlign(ctx, 'horizontal', 'right')
302
- })
303
-
304
- registerTool({
305
- id: 'valign-top',
306
- title: '顶端对齐',
307
- icon: AlignTop,
308
- tooltip: '垂直顶端对齐',
309
- group: 'text',
310
- order: 9,
311
- disabled: (ctx) => !ctx.getSelection().activeCell,
312
- active: (ctx) => {
313
- const active = ctx.getSelection().activeCell
314
- return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === 'top'
368
+
369
+ // ─── edit(查找 / 函数)──────────────────────────────────────
370
+
371
+ {
372
+ id: 'find',
373
+ title: '查找',
374
+ icon: Search,
375
+ tooltip: '查找与替换(Ctrl/Cmd+F)',
376
+ group: 'edit',
377
+ order: 0,
378
+ popup: 'find',
379
+ onClick: () => {}
315
380
  },
316
- onClick: (ctx) => toggleAlign(ctx, 'vertical', 'top')
317
- })
318
-
319
- registerTool({
320
- id: 'valign-middle',
321
- title: '垂直居中',
322
- icon: AlignCenter,
323
- tooltip: '垂直居中对齐',
324
- group: 'text',
325
- order: 10,
326
- disabled: (ctx) => !ctx.getSelection().activeCell,
327
- active: (ctx) => {
328
- const active = ctx.getSelection().activeCell
329
- return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === 'middle'
381
+
382
+ {
383
+ id: 'functions',
384
+ title: '函数',
385
+ icon: Variable,
386
+ tooltip: '按分类浏览并插入函数',
387
+ group: 'edit',
388
+ order: 1,
389
+ popup: 'functions',
390
+ onClick: () => {}
330
391
  },
331
- onClick: (ctx) => toggleAlign(ctx, 'vertical', 'middle')
332
- })
333
-
334
- registerTool({
335
- id: 'valign-bottom',
336
- title: '底端对齐',
337
- icon: AlignBottom,
338
- tooltip: '垂直底端对齐',
339
- group: 'text',
340
- order: 11,
341
- disabled: (ctx) => !ctx.getSelection().activeCell,
342
- active: (ctx) => {
343
- const active = ctx.getSelection().activeCell
344
- return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === 'bottom'
392
+
393
+ // ─── insert(插入图片)─────────────────────────────────────
394
+
395
+ {
396
+ id: 'insert-image',
397
+ title: '插入图片',
398
+ icon: PictureRounded,
399
+ tooltip: '插入浮动图片',
400
+ group: 'insert',
401
+ order: 0,
402
+ popup: 'insert-image',
403
+ disabled: (ctx) => !ctx.getSelection().activeCell,
404
+ onClick: () => {}
345
405
  },
346
- onClick: (ctx) => toggleAlign(ctx, 'vertical', 'bottom')
347
- })
348
-
349
- registerTool({
350
- id: 'wrap-text',
351
- title: '自动换行',
352
- icon: Wrap,
353
- tooltip: '自动换行',
354
- group: 'text',
355
- order: 12,
356
- disabled: (ctx) => !ctx.getSelection().activeCell,
357
- active: (ctx) => {
358
- const active = ctx.getSelection().activeCell
359
- return !!active && ctx.getEffectiveStyle(active)?.align?.wrap === true
406
+
407
+ // ─── file(导入 / 导出)────────────────────────────────────
408
+ // 导出 = 弹层选 xlsx / csv;导入 = 点击直接系统文件选择(components/sheet/import-file.ts,
409
+ // sheet.vue 覆盖 onClick;tools 层不 import 组件层)。
410
+ // 下载逻辑见 tools/download.ts(core/io 保持纯 TS 无头可测)。
411
+
412
+ {
413
+ id: 'import',
414
+ title: '导入',
415
+ icon: Download,
416
+ tooltip: '从 .xlsx / .csv 文件导入',
417
+ group: 'file',
418
+ order: 0,
419
+ onClick: () => {}
360
420
  },
361
- onClick: (ctx) => {
362
- const sel = selectionRange(ctx)
363
- if (!sel) return
364
- const on = ctx.getEffectiveStyle(sel.activeCell)?.align?.wrap === true
365
- ctx.applyStyle(sel.range, { align: { wrap: on ? null : true } })
421
+
422
+ {
423
+ id: 'export',
424
+ title: '导出',
425
+ icon: Upload,
426
+ tooltip: '导出为 Excel 或 CSV',
427
+ group: 'file',
428
+ order: 1,
429
+ popup: 'export',
430
+ onClick: () => {}
366
431
  }
367
- })
368
-
369
- // ─── edit(查找 / 函数)──────────────────────────────────────
370
-
371
- registerTool({
372
- id: 'find',
373
- title: '查找',
374
- icon: Search,
375
- tooltip: '查找与替换(Ctrl/Cmd+F)',
376
- group: 'edit',
377
- order: 0,
378
- popup: 'find',
379
- onClick: () => {}
380
- })
381
-
382
- registerTool({
383
- id: 'functions',
384
- title: '函数',
385
- icon: Variable,
386
- tooltip: '按分类浏览并插入函数',
387
- group: 'edit',
388
- order: 1,
389
- popup: 'functions',
390
- onClick: () => {}
391
- })
392
-
393
- // ─── insert(插入图片)─────────────────────────────────────
394
-
395
- registerTool({
396
- id: 'insert-image',
397
- title: '插入图片',
398
- icon: PictureRounded,
399
- tooltip: '插入浮动图片',
400
- group: 'insert',
401
- order: 0,
402
- popup: 'insert-image',
403
- disabled: (ctx) => !ctx.getSelection().activeCell,
404
- onClick: () => {}
405
- })
406
-
407
- // ─── file(导入 / 导出)────────────────────────────────────
408
- // 导出 = 弹层选 xlsx / csv;导入 = 点击直接系统文件选择(components/sheet/import-file.ts,
409
- // sheet.vue 覆盖 onClick;tools 层不 import 组件层)。
410
- // 下载逻辑见 tools/download.ts(core/io 保持纯 TS 无头可测)。
411
-
412
- registerTool({
413
- id: 'import',
414
- title: '导入',
415
- icon: Download,
416
- tooltip: '从 .xlsx / .csv 文件导入',
417
- group: 'file',
418
- order: 0,
419
- onClick: () => {}
420
- })
421
-
422
- registerTool({
423
- id: 'export',
424
- title: '导出',
425
- icon: Upload,
426
- tooltip: '导出为 Excel 或 CSV',
427
- group: 'file',
428
- order: 1,
429
- popup: 'export',
430
- onClick: () => {}
431
- })
432
+ ]