@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.
- package/dist/components/sheet/float-image-menu.js +1 -2
- package/dist/components/sheet/formula-bar.js +1 -2
- package/dist/components/sheet/formula-suggest-list.js +1 -2
- package/dist/components/sheet/import-file.js +3 -5
- package/dist/components/sheet/insert-count-menu-item.js +1 -2
- package/dist/components/sheet/insert-image.js +1 -2
- package/dist/components/sheet/popup-helpers.js +1 -2
- package/dist/components/sheet/popups/border-popup.js +1 -2
- package/dist/components/sheet/popups/border-preset-glyph.js +1 -2
- package/dist/components/sheet/popups/export-popup.js +1 -2
- package/dist/components/sheet/popups/fill-color-popup.js +1 -2
- package/dist/components/sheet/popups/find-popup.js +1 -2
- package/dist/components/sheet/popups/font-color-popup.js +1 -2
- package/dist/components/sheet/popups/font-size-popup.js +1 -2
- package/dist/components/sheet/popups/functions-popup.js +1 -2
- package/dist/components/sheet/popups/hyperlink-popup.js +1 -2
- package/dist/components/sheet/popups/import.worker.d.ts +1 -3
- package/dist/components/sheet/popups/import.worker.js +23462 -3
- package/dist/components/sheet/popups/insert-image-popup.js +1 -2
- package/dist/components/sheet/sheet-context-menu.js +0 -1
- package/dist/components/sheet/sheet-tabs.js +1 -2
- package/dist/components/sheet/sheet-toolbar.js +1 -2
- package/dist/components/sheet/sheet.js +1 -2
- package/dist/components/sheet/use-cell-link-tooltip.js +1 -2
- package/dist/components/sheet/use-find-replace.js +1 -2
- package/dist/components/sheet/use-formula-ref-select.js +1 -2
- package/dist/components/sheet/use-formula-suggest.js +0 -1
- package/dist/components/sheet/use-sheet-grid.js +1 -2
- package/dist/components/sheet/use-sheet-state.js +2 -3
- package/dist/components/sheet/use-sheet-tabs-bar.js +1 -2
- package/dist/components/sheet/use-tool-groups.js +1 -2
- package/dist/components/sheet/use-tool-popup.js +1 -2
- package/dist/components/sheet/use-toolbar-scroll.js +1 -2
- package/dist/index.js +1 -2
- package/dist/tools/apply-style.js +1 -2
- package/dist/tools/builtin.js +308 -307
- package/dist/tools/context.d.ts +1 -3
- package/dist/tools/context.js +0 -1
- package/dist/tools/download.js +9 -6
- package/dist/tools/export.worker.d.ts +1 -3
- package/dist/tools/export.worker.js +23459 -3
- package/dist/tools/registry.d.ts +4 -4
- package/dist/tools/registry.js +8 -4
- package/dist/types/sheet.d.ts +1 -3
- package/package.json +4 -6
- 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 +6 -3
- 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 +59 -4
- 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 +5 -3
- package/src/components/sheet/__test__/sheet-component.test.ts +4 -1
- package/src/components/sheet/__test__/sheet-context-menu.test.ts +2 -2
- 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/import-file.ts +3 -3
- package/src/index.ts +1 -3
- package/src/tools/__test__/builtin.test.ts +4 -4
- package/src/tools/__test__/context.test.ts +2 -2
- package/src/tools/__test__/download.test.ts +108 -0
- package/src/tools/builtin.ts +345 -344
- package/src/tools/download.ts +9 -5
- package/src/tools/registry.ts +8 -2
- package/src/tools/index.ts +0 -3
package/dist/tools/builtin.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
5
|
-
//#region src/tools/builtin.ts
|
|
4
|
+
// src/tools/builtin.ts
|
|
6
5
|
/** 取活动格所在首选区;无选区返回 null */
|
|
7
6
|
function selectionRange(ctx) {
|
|
8
7
|
const { activeCell, ranges } = ctx.getSelection();
|
|
@@ -31,323 +30,325 @@ 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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
ctx
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
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
|
-
|
|
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
|
-
//#endregion
|
|
353
|
+
];
|
|
354
|
+
export { BUILTIN_TOOLS };
|
package/dist/tools/context.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CellAddress, CellData, CellImagePayload, CellInfo, CellLinkPayload, CellRange, CellStyle, CellStylePatch, CellValue, FrozenState, HistoryState, ImageInput, ImageUpdateFields, SelectionState, SetCellValueItem, Sheet, SheetImage, Workbook } from "infinitable/sheet";
|
|
2
|
-
//#region src/tools/context.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* SheetContext:工具的唯一操作门面。
|
|
5
4
|
*
|
|
@@ -151,5 +150,4 @@ export interface SheetContextOptions {
|
|
|
151
150
|
* @param options.resolveGridSize 渲染尺寸解析器(整行/整列样式路由)
|
|
152
151
|
* @param options.syncAxisSizes 行列尺寸写模型后的即时同步钩子(USheet 接活动 grid)
|
|
153
152
|
*/
|
|
154
|
-
export declare function createSheetContext(resolveSheet: Sheet | (() => Sheet), workbook?: Workbook | (() => Workbook), options?: SheetContextOptions): SheetContext;
|
|
155
|
-
//#endregion
|
|
153
|
+
export declare function createSheetContext(resolveSheet: Sheet | (() => Sheet), workbook?: Workbook | (() => Workbook), options?: SheetContextOptions): SheetContext;
|