@veltra/sheet 4.1.2 → 4.1.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.
@@ -1,5 +1,5 @@
1
- import { defaultToolRegistry } from "../../tools/registry.js";
2
1
  import { createSheetContext } from "../../tools/context.js";
2
+ import { defaultToolRegistry } from "../../tools/registry.js";
3
3
  import { resolveRenderSize } from "./sheet-context-menu.js";
4
4
  import { Workbook } from "infinitable/sheet";
5
5
  import { computed, onBeforeUnmount, onMounted, ref, shallowRef, watch } from "vue";
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
- import { defaultToolRegistry, registerTool, unregisterTool } from "./tools/registry.js";
2
- import "./tools/builtin.js";
3
1
  import { createSheetContext } from "./tools/context.js";
2
+ import { defaultToolRegistry, registerTool, unregisterTool } from "./tools/registry.js";
4
3
  import _sfc_main from "./components/sheet/sheet.js";
5
4
  export { _sfc_main as USheet, createSheetContext, defaultToolRegistry, registerTool, unregisterTool };
@@ -1,7 +1,6 @@
1
- import { registerTool } from "./registry.js";
1
+ import { rangesEqual } from "infinitable/sheet";
2
2
  import { FontColor } from "@veltra/icons/colorful";
3
3
  import { AlignBottom, AlignCenter, AlignTop, Bold, Border, Download, Fill, FontSize, Italic, MergeCells, PictureRounded, Rollback, Rollfront, Search, Strikethrough, Underline, UnmergeCells, Upload, Variable, VerticalAlignCenter, VerticalAlignLeft, VerticalAlignRight, Wrap } from "@veltra/icons/normal";
4
- import { rangesEqual } from "infinitable/sheet";
5
4
  //#region src/tools/builtin.ts
6
5
  /** 取活动格所在首选区;无选区返回 null */
7
6
  function selectionRange(ctx) {
@@ -31,323 +30,326 @@ function toggleAlign(ctx, axis, value) {
31
30
  * 内置工具(dogfood 扩展机制)。
32
31
  *
33
32
  * 分组:history | cell | text | edit | insert | file。
33
+ * 纯数据:由 defaultToolRegistry 构造时装入,不在模块顶层注册。
34
34
  * 与第三方工具走同一注册通道,可由宿主 unregisterTool 移除或同 id 覆盖。
35
- * 本模块由包入口引入:经包入口导入即完成注册。
36
35
  */
37
- registerTool({
38
- id: "undo",
39
- title: "撤销",
40
- icon: Rollback,
41
- tooltip: "撤销(Ctrl/Cmd+Z)",
42
- group: "history",
43
- order: 0,
44
- disabled: (ctx) => !ctx.canUndo,
45
- onClick: (ctx) => {
46
- ctx.undo();
47
- }
48
- });
49
- registerTool({
50
- id: "redo",
51
- title: "重做",
52
- icon: Rollfront,
53
- tooltip: "重做(Ctrl/Cmd+Shift+Z 或 Ctrl+Y)",
54
- group: "history",
55
- order: 1,
56
- disabled: (ctx) => !ctx.canRedo,
57
- onClick: (ctx) => {
58
- ctx.redo();
59
- }
60
- });
61
- registerTool({
62
- id: "border",
63
- title: "边框",
64
- icon: Border,
65
- tooltip: "设置单元格边框",
66
- group: "cell",
67
- order: 0,
68
- popup: "border",
69
- disabled: (ctx) => !ctx.getSelection().activeCell,
70
- onClick: () => {}
71
- });
72
- registerTool({
73
- id: "fill-color",
74
- title: "填充颜色",
75
- icon: Fill,
76
- tooltip: "设置单元格背景填充",
77
- group: "cell",
78
- order: 1,
79
- popup: "fill-color",
80
- disabled: (ctx) => !ctx.getSelection().activeCell,
81
- onClick: () => {}
82
- });
83
- registerTool({
84
- id: "merge",
85
- title: "合并",
86
- icon: MergeCells,
87
- tooltip: "合并选中区域",
88
- group: "cell",
89
- order: 2,
90
- disabled: (ctx) => {
91
- const { activeCell, ranges } = ctx.getSelection();
92
- const range = ranges[0];
93
- if (!activeCell || !range) return true;
94
- if (range.start.row === range.end.row && range.start.col === range.end.col) return true;
95
- const mergeRange = ctx.getCellInfo(activeCell).mergeRange;
96
- return !!mergeRange && rangesEqual(mergeRange, range);
36
+ const BUILTIN_TOOLS = [
37
+ {
38
+ id: "undo",
39
+ title: "撤销",
40
+ icon: Rollback,
41
+ tooltip: "撤销(Ctrl/Cmd+Z)",
42
+ group: "history",
43
+ order: 0,
44
+ disabled: (ctx) => !ctx.canUndo,
45
+ onClick: (ctx) => {
46
+ ctx.undo();
47
+ }
97
48
  },
98
- onClick: (ctx) => {
99
- const range = ctx.getSelection().ranges[0];
100
- if (!range) return;
101
- ctx.mergeCells(range);
102
- }
103
- });
104
- registerTool({
105
- id: "unmerge",
106
- title: "取消合并",
107
- icon: UnmergeCells,
108
- tooltip: "取消活动格所在合并",
109
- group: "cell",
110
- order: 3,
111
- disabled: (ctx) => {
112
- const { activeCell } = ctx.getSelection();
113
- if (!activeCell) return true;
114
- return !ctx.getCellInfo(activeCell).mergeRange;
49
+ {
50
+ id: "redo",
51
+ title: "重做",
52
+ icon: Rollfront,
53
+ tooltip: "重做(Ctrl/Cmd+Shift+Z 或 Ctrl+Y)",
54
+ group: "history",
55
+ order: 1,
56
+ disabled: (ctx) => !ctx.canRedo,
57
+ onClick: (ctx) => {
58
+ ctx.redo();
59
+ }
115
60
  },
116
- onClick: (ctx) => {
117
- const { activeCell, ranges } = ctx.getSelection();
118
- if (!activeCell || !ranges[0]) return;
119
- ctx.unmergeCells(ranges[0]);
120
- }
121
- });
122
- registerTool({
123
- id: "bold",
124
- title: "加粗",
125
- icon: Bold,
126
- tooltip: "加粗",
127
- group: "text",
128
- order: 0,
129
- disabled: (ctx) => !ctx.getSelection().activeCell,
130
- active: (ctx) => {
131
- const active = ctx.getSelection().activeCell;
132
- return !!active && ctx.getEffectiveStyle(active)?.font?.bold === true;
61
+ {
62
+ id: "border",
63
+ title: "边框",
64
+ icon: Border,
65
+ tooltip: "设置单元格边框",
66
+ group: "cell",
67
+ order: 0,
68
+ popup: "border",
69
+ disabled: (ctx) => !ctx.getSelection().activeCell,
70
+ onClick: () => {}
71
+ },
72
+ {
73
+ id: "fill-color",
74
+ title: "填充颜色",
75
+ icon: Fill,
76
+ tooltip: "设置单元格背景填充",
77
+ group: "cell",
78
+ order: 1,
79
+ popup: "fill-color",
80
+ disabled: (ctx) => !ctx.getSelection().activeCell,
81
+ onClick: () => {}
82
+ },
83
+ {
84
+ id: "merge",
85
+ title: "合并",
86
+ icon: MergeCells,
87
+ tooltip: "合并选中区域",
88
+ group: "cell",
89
+ order: 2,
90
+ disabled: (ctx) => {
91
+ const { activeCell, ranges } = ctx.getSelection();
92
+ const range = ranges[0];
93
+ if (!activeCell || !range) return true;
94
+ if (range.start.row === range.end.row && range.start.col === range.end.col) return true;
95
+ const mergeRange = ctx.getCellInfo(activeCell).mergeRange;
96
+ return !!mergeRange && rangesEqual(mergeRange, range);
97
+ },
98
+ onClick: (ctx) => {
99
+ const range = ctx.getSelection().ranges[0];
100
+ if (!range) return;
101
+ ctx.mergeCells(range);
102
+ }
103
+ },
104
+ {
105
+ id: "unmerge",
106
+ title: "取消合并",
107
+ icon: UnmergeCells,
108
+ tooltip: "取消活动格所在合并",
109
+ group: "cell",
110
+ order: 3,
111
+ disabled: (ctx) => {
112
+ const { activeCell } = ctx.getSelection();
113
+ if (!activeCell) return true;
114
+ return !ctx.getCellInfo(activeCell).mergeRange;
115
+ },
116
+ onClick: (ctx) => {
117
+ const { activeCell, ranges } = ctx.getSelection();
118
+ if (!activeCell || !ranges[0]) return;
119
+ ctx.unmergeCells(ranges[0]);
120
+ }
121
+ },
122
+ {
123
+ id: "bold",
124
+ title: "加粗",
125
+ icon: Bold,
126
+ tooltip: "加粗",
127
+ group: "text",
128
+ order: 0,
129
+ disabled: (ctx) => !ctx.getSelection().activeCell,
130
+ active: (ctx) => {
131
+ const active = ctx.getSelection().activeCell;
132
+ return !!active && ctx.getEffectiveStyle(active)?.font?.bold === true;
133
+ },
134
+ onClick: (ctx) => toggleFontFlag(ctx, "bold")
135
+ },
136
+ {
137
+ id: "italic",
138
+ title: "斜体",
139
+ icon: Italic,
140
+ tooltip: "斜体",
141
+ group: "text",
142
+ order: 1,
143
+ disabled: (ctx) => !ctx.getSelection().activeCell,
144
+ active: (ctx) => {
145
+ const active = ctx.getSelection().activeCell;
146
+ return !!active && ctx.getEffectiveStyle(active)?.font?.italic === true;
147
+ },
148
+ onClick: (ctx) => toggleFontFlag(ctx, "italic")
149
+ },
150
+ {
151
+ id: "underline",
152
+ title: "下划线",
153
+ icon: Underline,
154
+ tooltip: "下划线",
155
+ group: "text",
156
+ order: 2,
157
+ disabled: (ctx) => !ctx.getSelection().activeCell,
158
+ active: (ctx) => {
159
+ const active = ctx.getSelection().activeCell;
160
+ return !!active && ctx.getEffectiveStyle(active)?.font?.underline === true;
161
+ },
162
+ onClick: (ctx) => toggleFontFlag(ctx, "underline")
163
+ },
164
+ {
165
+ id: "strikethrough",
166
+ title: "删除线",
167
+ icon: Strikethrough,
168
+ tooltip: "删除线",
169
+ group: "text",
170
+ order: 3,
171
+ disabled: (ctx) => !ctx.getSelection().activeCell,
172
+ active: (ctx) => {
173
+ const active = ctx.getSelection().activeCell;
174
+ return !!active && ctx.getEffectiveStyle(active)?.font?.strikethrough === true;
175
+ },
176
+ onClick: (ctx) => toggleFontFlag(ctx, "strikethrough")
177
+ },
178
+ {
179
+ id: "font-color",
180
+ title: "字体颜色",
181
+ icon: FontColor,
182
+ tooltip: "设置字体颜色",
183
+ group: "text",
184
+ order: 4,
185
+ popup: "font-color",
186
+ disabled: (ctx) => !ctx.getSelection().activeCell,
187
+ onClick: () => {}
188
+ },
189
+ {
190
+ id: "font-size",
191
+ title: "字号",
192
+ icon: FontSize,
193
+ tooltip: "设置字体大小",
194
+ group: "text",
195
+ order: 5,
196
+ popup: "font-size",
197
+ disabled: (ctx) => !ctx.getSelection().activeCell,
198
+ onClick: () => {}
199
+ },
200
+ {
201
+ id: "align-left",
202
+ title: "左对齐",
203
+ icon: VerticalAlignLeft,
204
+ tooltip: "水平左对齐",
205
+ group: "text",
206
+ order: 6,
207
+ disabled: (ctx) => !ctx.getSelection().activeCell,
208
+ active: (ctx) => {
209
+ const active = ctx.getSelection().activeCell;
210
+ return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === "left";
211
+ },
212
+ onClick: (ctx) => toggleAlign(ctx, "horizontal", "left")
133
213
  },
134
- onClick: (ctx) => toggleFontFlag(ctx, "bold")
135
- });
136
- registerTool({
137
- id: "italic",
138
- title: "斜体",
139
- icon: Italic,
140
- tooltip: "斜体",
141
- group: "text",
142
- order: 1,
143
- disabled: (ctx) => !ctx.getSelection().activeCell,
144
- active: (ctx) => {
145
- const active = ctx.getSelection().activeCell;
146
- return !!active && ctx.getEffectiveStyle(active)?.font?.italic === true;
214
+ {
215
+ id: "align-center",
216
+ title: "居中",
217
+ icon: VerticalAlignCenter,
218
+ tooltip: "水平居中",
219
+ group: "text",
220
+ order: 7,
221
+ disabled: (ctx) => !ctx.getSelection().activeCell,
222
+ active: (ctx) => {
223
+ const active = ctx.getSelection().activeCell;
224
+ return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === "center";
225
+ },
226
+ onClick: (ctx) => toggleAlign(ctx, "horizontal", "center")
147
227
  },
148
- onClick: (ctx) => toggleFontFlag(ctx, "italic")
149
- });
150
- registerTool({
151
- id: "underline",
152
- title: "下划线",
153
- icon: Underline,
154
- tooltip: "下划线",
155
- group: "text",
156
- order: 2,
157
- disabled: (ctx) => !ctx.getSelection().activeCell,
158
- active: (ctx) => {
159
- const active = ctx.getSelection().activeCell;
160
- return !!active && ctx.getEffectiveStyle(active)?.font?.underline === true;
228
+ {
229
+ id: "align-right",
230
+ title: "右对齐",
231
+ icon: VerticalAlignRight,
232
+ tooltip: "水平右对齐",
233
+ group: "text",
234
+ order: 8,
235
+ disabled: (ctx) => !ctx.getSelection().activeCell,
236
+ active: (ctx) => {
237
+ const active = ctx.getSelection().activeCell;
238
+ return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === "right";
239
+ },
240
+ onClick: (ctx) => toggleAlign(ctx, "horizontal", "right")
161
241
  },
162
- onClick: (ctx) => toggleFontFlag(ctx, "underline")
163
- });
164
- registerTool({
165
- id: "strikethrough",
166
- title: "删除线",
167
- icon: Strikethrough,
168
- tooltip: "删除线",
169
- group: "text",
170
- order: 3,
171
- disabled: (ctx) => !ctx.getSelection().activeCell,
172
- active: (ctx) => {
173
- const active = ctx.getSelection().activeCell;
174
- return !!active && ctx.getEffectiveStyle(active)?.font?.strikethrough === true;
242
+ {
243
+ id: "valign-top",
244
+ title: "顶端对齐",
245
+ icon: AlignTop,
246
+ tooltip: "垂直顶端对齐",
247
+ group: "text",
248
+ order: 9,
249
+ disabled: (ctx) => !ctx.getSelection().activeCell,
250
+ active: (ctx) => {
251
+ const active = ctx.getSelection().activeCell;
252
+ return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === "top";
253
+ },
254
+ onClick: (ctx) => toggleAlign(ctx, "vertical", "top")
175
255
  },
176
- onClick: (ctx) => toggleFontFlag(ctx, "strikethrough")
177
- });
178
- registerTool({
179
- id: "font-color",
180
- title: "字体颜色",
181
- icon: FontColor,
182
- tooltip: "设置字体颜色",
183
- group: "text",
184
- order: 4,
185
- popup: "font-color",
186
- disabled: (ctx) => !ctx.getSelection().activeCell,
187
- onClick: () => {}
188
- });
189
- registerTool({
190
- id: "font-size",
191
- title: "字号",
192
- icon: FontSize,
193
- tooltip: "设置字体大小",
194
- group: "text",
195
- order: 5,
196
- popup: "font-size",
197
- disabled: (ctx) => !ctx.getSelection().activeCell,
198
- onClick: () => {}
199
- });
200
- registerTool({
201
- id: "align-left",
202
- title: "左对齐",
203
- icon: VerticalAlignLeft,
204
- tooltip: "水平左对齐",
205
- group: "text",
206
- order: 6,
207
- disabled: (ctx) => !ctx.getSelection().activeCell,
208
- active: (ctx) => {
209
- const active = ctx.getSelection().activeCell;
210
- return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === "left";
256
+ {
257
+ id: "valign-middle",
258
+ title: "垂直居中",
259
+ icon: AlignCenter,
260
+ tooltip: "垂直居中对齐",
261
+ group: "text",
262
+ order: 10,
263
+ disabled: (ctx) => !ctx.getSelection().activeCell,
264
+ active: (ctx) => {
265
+ const active = ctx.getSelection().activeCell;
266
+ return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === "middle";
267
+ },
268
+ onClick: (ctx) => toggleAlign(ctx, "vertical", "middle")
211
269
  },
212
- onClick: (ctx) => toggleAlign(ctx, "horizontal", "left")
213
- });
214
- registerTool({
215
- id: "align-center",
216
- title: "居中",
217
- icon: VerticalAlignCenter,
218
- tooltip: "水平居中",
219
- group: "text",
220
- order: 7,
221
- disabled: (ctx) => !ctx.getSelection().activeCell,
222
- active: (ctx) => {
223
- const active = ctx.getSelection().activeCell;
224
- return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === "center";
270
+ {
271
+ id: "valign-bottom",
272
+ title: "底端对齐",
273
+ icon: AlignBottom,
274
+ tooltip: "垂直底端对齐",
275
+ group: "text",
276
+ order: 11,
277
+ disabled: (ctx) => !ctx.getSelection().activeCell,
278
+ active: (ctx) => {
279
+ const active = ctx.getSelection().activeCell;
280
+ return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === "bottom";
281
+ },
282
+ onClick: (ctx) => toggleAlign(ctx, "vertical", "bottom")
225
283
  },
226
- onClick: (ctx) => toggleAlign(ctx, "horizontal", "center")
227
- });
228
- registerTool({
229
- id: "align-right",
230
- title: "右对齐",
231
- icon: VerticalAlignRight,
232
- tooltip: "水平右对齐",
233
- group: "text",
234
- order: 8,
235
- disabled: (ctx) => !ctx.getSelection().activeCell,
236
- active: (ctx) => {
237
- const active = ctx.getSelection().activeCell;
238
- return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === "right";
284
+ {
285
+ id: "wrap-text",
286
+ title: "自动换行",
287
+ icon: Wrap,
288
+ tooltip: "自动换行",
289
+ group: "text",
290
+ order: 12,
291
+ disabled: (ctx) => !ctx.getSelection().activeCell,
292
+ active: (ctx) => {
293
+ const active = ctx.getSelection().activeCell;
294
+ return !!active && ctx.getEffectiveStyle(active)?.align?.wrap === true;
295
+ },
296
+ onClick: (ctx) => {
297
+ const sel = selectionRange(ctx);
298
+ if (!sel) return;
299
+ const on = ctx.getEffectiveStyle(sel.activeCell)?.align?.wrap === true;
300
+ ctx.applyStyle(sel.range, { align: { wrap: on ? null : true } });
301
+ }
239
302
  },
240
- onClick: (ctx) => toggleAlign(ctx, "horizontal", "right")
241
- });
242
- registerTool({
243
- id: "valign-top",
244
- title: "顶端对齐",
245
- icon: AlignTop,
246
- tooltip: "垂直顶端对齐",
247
- group: "text",
248
- order: 9,
249
- disabled: (ctx) => !ctx.getSelection().activeCell,
250
- active: (ctx) => {
251
- const active = ctx.getSelection().activeCell;
252
- return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === "top";
303
+ {
304
+ id: "find",
305
+ title: "查找",
306
+ icon: Search,
307
+ tooltip: "查找与替换(Ctrl/Cmd+F)",
308
+ group: "edit",
309
+ order: 0,
310
+ popup: "find",
311
+ onClick: () => {}
253
312
  },
254
- onClick: (ctx) => toggleAlign(ctx, "vertical", "top")
255
- });
256
- registerTool({
257
- id: "valign-middle",
258
- title: "垂直居中",
259
- icon: AlignCenter,
260
- tooltip: "垂直居中对齐",
261
- group: "text",
262
- order: 10,
263
- disabled: (ctx) => !ctx.getSelection().activeCell,
264
- active: (ctx) => {
265
- const active = ctx.getSelection().activeCell;
266
- return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === "middle";
313
+ {
314
+ id: "functions",
315
+ title: "函数",
316
+ icon: Variable,
317
+ tooltip: "按分类浏览并插入函数",
318
+ group: "edit",
319
+ order: 1,
320
+ popup: "functions",
321
+ onClick: () => {}
267
322
  },
268
- onClick: (ctx) => toggleAlign(ctx, "vertical", "middle")
269
- });
270
- registerTool({
271
- id: "valign-bottom",
272
- title: "底端对齐",
273
- icon: AlignBottom,
274
- tooltip: "垂直底端对齐",
275
- group: "text",
276
- order: 11,
277
- disabled: (ctx) => !ctx.getSelection().activeCell,
278
- active: (ctx) => {
279
- const active = ctx.getSelection().activeCell;
280
- return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === "bottom";
323
+ {
324
+ id: "insert-image",
325
+ title: "插入图片",
326
+ icon: PictureRounded,
327
+ tooltip: "插入浮动图片",
328
+ group: "insert",
329
+ order: 0,
330
+ popup: "insert-image",
331
+ disabled: (ctx) => !ctx.getSelection().activeCell,
332
+ onClick: () => {}
281
333
  },
282
- onClick: (ctx) => toggleAlign(ctx, "vertical", "bottom")
283
- });
284
- registerTool({
285
- id: "wrap-text",
286
- title: "自动换行",
287
- icon: Wrap,
288
- tooltip: "自动换行",
289
- group: "text",
290
- order: 12,
291
- disabled: (ctx) => !ctx.getSelection().activeCell,
292
- active: (ctx) => {
293
- const active = ctx.getSelection().activeCell;
294
- return !!active && ctx.getEffectiveStyle(active)?.align?.wrap === true;
334
+ {
335
+ id: "import",
336
+ title: "导入",
337
+ icon: Download,
338
+ tooltip: "从 .xlsx / .csv 文件导入",
339
+ group: "file",
340
+ order: 0,
341
+ onClick: () => {}
295
342
  },
296
- onClick: (ctx) => {
297
- const sel = selectionRange(ctx);
298
- if (!sel) return;
299
- const on = ctx.getEffectiveStyle(sel.activeCell)?.align?.wrap === true;
300
- ctx.applyStyle(sel.range, { align: { wrap: on ? null : true } });
343
+ {
344
+ id: "export",
345
+ title: "导出",
346
+ icon: Upload,
347
+ tooltip: "导出为 Excel 或 CSV",
348
+ group: "file",
349
+ order: 1,
350
+ popup: "export",
351
+ onClick: () => {}
301
352
  }
302
- });
303
- registerTool({
304
- id: "find",
305
- title: "查找",
306
- icon: Search,
307
- tooltip: "查找与替换(Ctrl/Cmd+F)",
308
- group: "edit",
309
- order: 0,
310
- popup: "find",
311
- onClick: () => {}
312
- });
313
- registerTool({
314
- id: "functions",
315
- title: "函数",
316
- icon: Variable,
317
- tooltip: "按分类浏览并插入函数",
318
- group: "edit",
319
- order: 1,
320
- popup: "functions",
321
- onClick: () => {}
322
- });
323
- registerTool({
324
- id: "insert-image",
325
- title: "插入图片",
326
- icon: PictureRounded,
327
- tooltip: "插入浮动图片",
328
- group: "insert",
329
- order: 0,
330
- popup: "insert-image",
331
- disabled: (ctx) => !ctx.getSelection().activeCell,
332
- onClick: () => {}
333
- });
334
- registerTool({
335
- id: "import",
336
- title: "导入",
337
- icon: Download,
338
- tooltip: "从 .xlsx / .csv 文件导入",
339
- group: "file",
340
- order: 0,
341
- onClick: () => {}
342
- });
343
- registerTool({
344
- id: "export",
345
- title: "导出",
346
- icon: Upload,
347
- tooltip: "导出为 Excel 或 CSV",
348
- group: "file",
349
- order: 1,
350
- popup: "export",
351
- onClick: () => {}
352
- });
353
+ ];
353
354
  //#endregion
355
+ export { BUILTIN_TOOLS };
@@ -46,6 +46,8 @@ export declare class ToolRegistry {
46
46
  private entries;
47
47
  private seq;
48
48
  private emitter;
49
+ /** 装入初始工具(仍经 register 校验);缺省空表 */
50
+ constructor(tools?: readonly SheetTool[]);
49
51
  /** 注册工具;同 id 重复注册 = 替换定义并保留原注册位置 */
50
52
  register(tool: SheetTool): void;
51
53
  /** 注销工具;id 不存在时返回 false(不触发 change) */
@@ -59,7 +61,7 @@ export declare class ToolRegistry {
59
61
  onChange(handler: () => void): () => void;
60
62
  }
61
63
  /**
62
- * 全局默认注册表(USheet 默认渲染这里的工具;内置工具也注册于此)。
64
+ * 全局默认注册表(USheet 默认渲染这里的工具;内置工具在构造时装入)。
63
65
  * 工具是应用级扩展:注册一次,所有 USheet 实例共享。
64
66
  */
65
67
  export declare const defaultToolRegistry: ToolRegistry;