@veltra/sheet 4.1.1 → 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.
- package/dist/components/sheet/formula-bar.js +95 -11
- package/dist/components/sheet/sheet.js +5 -3
- package/dist/components/sheet/use-formula-ref-select.js +11 -3
- package/dist/components/sheet/use-sheet-grid.js +11 -3
- package/dist/components/sheet/use-sheet-state.js +1 -1
- package/dist/index.js +1 -2
- package/dist/tools/builtin.js +307 -305
- package/dist/tools/registry.d.ts +3 -1
- package/dist/tools/registry.js +7 -2
- package/package.json +4 -8
- package/src/components/sheet/__test__/canvas-mock.ts +3 -1
- package/src/components/sheet/__test__/find-shortcut-anchor.test.ts +2 -0
- package/src/components/sheet/__test__/formula-bar.test.ts +205 -0
- package/src/components/sheet/__test__/formula-capability.test.ts +2 -0
- package/src/components/sheet/__test__/functions-popup.test.ts +2 -0
- package/src/components/sheet/__test__/hyperlink-popup.test.ts +2 -0
- package/src/components/sheet/__test__/import-file.test.ts +2 -0
- package/src/components/sheet/__test__/insert-count-menu-item.test.ts +2 -0
- package/src/components/sheet/__test__/insert-image-popup.test.ts +2 -0
- package/src/components/sheet/__test__/insert-image.test.ts +2 -0
- package/src/components/sheet/__test__/sheet-component.test.ts +4 -1
- package/src/components/sheet/__test__/sheet-grow-on-scroll.test.ts +2 -0
- package/src/components/sheet/__test__/sheet-scrollbar.test.ts +2 -0
- package/src/components/sheet/__test__/sheet-theme.test.ts +2 -0
- package/src/components/sheet/__test__/use-formula-ref-select.test.ts +12 -1
- package/src/components/sheet/formula-bar.vue +106 -14
- package/src/components/sheet/sheet.vue +28 -26
- package/src/components/sheet/use-formula-ref-select.ts +13 -0
- package/src/components/sheet/use-sheet-grid.ts +26 -7
- package/src/index.ts +1 -3
- package/src/tools/__test__/builtin.test.ts +2 -2
- package/src/tools/builtin.ts +345 -344
- package/src/tools/registry.ts +8 -2
- package/src/tools/index.ts +0 -3
package/src/tools/builtin.ts
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
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
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
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
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
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
|
+
]
|