@file-viewer/renderer-spreadsheet 3.3.1 → 3.3.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/README.en.md +14 -0
- package/README.md +14 -0
- package/README.zh-CN.md +14 -0
- package/dist/spreadsheet/autoRowHeight.d.ts +16 -0
- package/dist/spreadsheet/autoRowHeight.js +208 -0
- package/dist/spreadsheet/chartRenderer.js +0 -5
- package/dist/spreadsheet/chartSampling.d.ts +0 -4
- package/dist/spreadsheet/chartSampling.js +0 -6
- package/dist/spreadsheet/comments.d.ts +40 -0
- package/dist/spreadsheet/comments.js +388 -0
- package/dist/spreadsheet/drawingAutoHeight.d.ts +7 -0
- package/dist/spreadsheet/drawingAutoHeight.js +51 -0
- package/dist/spreadsheet/rangeNavigation.d.ts +0 -2
- package/dist/spreadsheet/rangeNavigation.js +0 -4
- package/dist/spreadsheet/sourceRegion.d.ts +37 -0
- package/dist/spreadsheet/sourceRegion.js +54 -0
- package/dist/spreadsheet/state.d.ts +7 -2
- package/dist/spreadsheet/state.js +6 -2
- package/dist/spreadsheet/view.d.ts +9 -4
- package/dist/spreadsheet/view.js +98 -39
- package/dist/spreadsheet/viewport.d.ts +0 -1
- package/dist/spreadsheet/viewport.js +0 -2
- package/dist/spreadsheet/worker/sheetjs/SheetJsModel.d.ts +61 -2
- package/dist/spreadsheet/worker/sheetjs/SheetJsModel.js +134 -43
- package/dist/spreadsheet/worker/sheetjs/chartParser.d.ts +3 -2
- package/dist/spreadsheet/worker/sheetjs/chartParser.js +13 -24
- package/dist/spreadsheet/worker/sheetjs/color.js +8 -10
- package/dist/spreadsheet/worker/sheetjs/commentParser.d.ts +7 -0
- package/dist/spreadsheet/worker/sheetjs/commentParser.js +232 -0
- package/dist/spreadsheet/worker/sheetjs/drawingRowAnchor.d.ts +4 -0
- package/dist/spreadsheet/worker/sheetjs/drawingRowAnchor.js +90 -0
- package/dist/spreadsheet/worker/sheetjs/formulaValues.js +0 -9
- package/dist/spreadsheet/worker/sheetjs/parser.d.ts +40 -4
- package/dist/spreadsheet/worker/sheetjs/parser.js +453 -78
- package/dist/spreadsheet/worker/sheetjs/richDataParser.js +5 -4
- package/dist/spreadsheet/worker/sheetjs/richText.js +0 -1
- package/dist/spreadsheet/worker/sheetjs/rowSizing.d.ts +10 -0
- package/dist/spreadsheet/worker/sheetjs/rowSizing.js +156 -0
- package/dist/spreadsheet/worker/sheetjs/sheetLayout.d.ts +2 -4
- package/dist/spreadsheet/worker/sheetjs/sheetLayout.js +0 -8
- package/dist/spreadsheet/worker/sheetjs/sourceAnchor.d.ts +10 -0
- package/dist/spreadsheet/worker/sheetjs/sourceAnchor.js +286 -0
- package/dist/spreadsheet/worker/sheetjs/textEncoding.d.ts +1 -1
- package/dist/spreadsheet/worker/sheetjs/textEncoding.js +1 -8
- package/dist/spreadsheet/worker/sheetjs/workbookFont.d.ts +4 -0
- package/dist/spreadsheet/worker/sheetjs/workbookFont.js +15 -0
- package/dist/spreadsheet/worker/sheetjs/xmlBudget.d.ts +11 -0
- package/dist/spreadsheet/worker/sheetjs/xmlBudget.js +39 -0
- package/dist/spreadsheet/worker/type.d.ts +145 -3
- package/dist/spreadsheet.js +150 -63
- package/dist/worker/sheet.worker.js +49 -65
- package/package.json +23 -3
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { createFileViewerTranslator, } from '@file-viewer/core';
|
|
2
|
+
const commentKeys = {
|
|
3
|
+
title: 'spreadsheet.comments.title',
|
|
4
|
+
close: 'spreadsheet.comments.close',
|
|
5
|
+
note: 'spreadsheet.comments.note',
|
|
6
|
+
thread: 'spreadsheet.comments.thread',
|
|
7
|
+
resolved: 'spreadsheet.comments.resolved',
|
|
8
|
+
unknown: 'spreadsheet.comments.unknown',
|
|
9
|
+
empty: 'spreadsheet.comments.empty',
|
|
10
|
+
more: 'spreadsheet.comments.more',
|
|
11
|
+
open: 'spreadsheet.comments.open',
|
|
12
|
+
jump: 'spreadsheet.comments.jump',
|
|
13
|
+
warning: 'spreadsheet.comments.warning',
|
|
14
|
+
count: 'spreadsheet.comments.count',
|
|
15
|
+
};
|
|
16
|
+
export const createSpreadsheetComments = ({ root, toolbar, body, options, i18n, navigate, getSheetId, }) => {
|
|
17
|
+
const document = root.ownerDocument;
|
|
18
|
+
const t = createFileViewerTranslator(i18n || options);
|
|
19
|
+
const label = (key, values) => t(commentKeys[key], values);
|
|
20
|
+
const isElement = (value) => { var _a; return value instanceof (((_a = document.defaultView) === null || _a === void 0 ? void 0 : _a.HTMLElement) || HTMLElement); };
|
|
21
|
+
let sheets = [];
|
|
22
|
+
let hasError = false;
|
|
23
|
+
let limit = 30;
|
|
24
|
+
let selectedId = '';
|
|
25
|
+
let returnFocus = null;
|
|
26
|
+
let focusedCell = null;
|
|
27
|
+
let activeList = null;
|
|
28
|
+
let shownPopover = null;
|
|
29
|
+
const toggle = document.createElement('button');
|
|
30
|
+
toggle.type = 'button';
|
|
31
|
+
toggle.className = 'excel-comments-toggle hidden';
|
|
32
|
+
toggle.setAttribute('aria-expanded', 'false');
|
|
33
|
+
const panel = document.createElement('aside');
|
|
34
|
+
panel.className = 'excel-comments-panel hidden';
|
|
35
|
+
panel.setAttribute('aria-label', label('title'));
|
|
36
|
+
const popover = document.createElement('section');
|
|
37
|
+
popover.className = 'excel-comment-popover hidden';
|
|
38
|
+
popover.setAttribute('role', 'dialog');
|
|
39
|
+
popover.setAttribute('aria-label', label('title'));
|
|
40
|
+
popover.tabIndex = -1;
|
|
41
|
+
const entries = () => sheets
|
|
42
|
+
.filter((sheet) => !sheet.hidden)
|
|
43
|
+
.flatMap((sheet) => (sheet.comments || []).map((comment) => ({
|
|
44
|
+
...comment,
|
|
45
|
+
sheetId: sheet.id,
|
|
46
|
+
sheetName: sheet.name,
|
|
47
|
+
key: `${sheet.id}:${comment.address}`,
|
|
48
|
+
})));
|
|
49
|
+
const textNode = (tag, value, className) => {
|
|
50
|
+
const node = document.createElement(tag);
|
|
51
|
+
node.textContent = value;
|
|
52
|
+
if (className)
|
|
53
|
+
node.className = className;
|
|
54
|
+
return node;
|
|
55
|
+
};
|
|
56
|
+
const button = (text, action, className) => {
|
|
57
|
+
const node = textNode('button', text, className);
|
|
58
|
+
node.type = 'button';
|
|
59
|
+
node.addEventListener('click', action);
|
|
60
|
+
return node;
|
|
61
|
+
};
|
|
62
|
+
const closeButton = (action) => {
|
|
63
|
+
const node = button('', action, 'excel-comments-close');
|
|
64
|
+
node.setAttribute('aria-label', label('close'));
|
|
65
|
+
const icon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
66
|
+
icon.setAttribute('viewBox', '0 0 24 24');
|
|
67
|
+
icon.setAttribute('width', '16');
|
|
68
|
+
icon.setAttribute('height', '16');
|
|
69
|
+
icon.setAttribute('aria-hidden', 'true');
|
|
70
|
+
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
71
|
+
path.setAttribute('d', 'M6 6l12 12M18 6 6 18');
|
|
72
|
+
path.setAttribute('stroke', 'currentColor');
|
|
73
|
+
path.setAttribute('stroke-width', '1.5');
|
|
74
|
+
path.setAttribute('stroke-linecap', 'round');
|
|
75
|
+
icon.append(path);
|
|
76
|
+
node.append(icon);
|
|
77
|
+
return node;
|
|
78
|
+
};
|
|
79
|
+
const findIndicator = (cell) => cell && cell.sheetId === getSheetId()
|
|
80
|
+
? Array.from(root.querySelectorAll('.excel-comment-indicator')).find((node) => node.dataset.cell === cell.address)
|
|
81
|
+
: null;
|
|
82
|
+
const focusin = (event) => {
|
|
83
|
+
const indicator = event
|
|
84
|
+
.composedPath()
|
|
85
|
+
.find((node) => isElement(node) &&
|
|
86
|
+
node.classList.contains('excel-comment-indicator') &&
|
|
87
|
+
root.contains(node));
|
|
88
|
+
focusedCell = indicator
|
|
89
|
+
? {
|
|
90
|
+
element: indicator,
|
|
91
|
+
address: indicator.dataset.cell || '',
|
|
92
|
+
sheetId: getSheetId(),
|
|
93
|
+
}
|
|
94
|
+
: null;
|
|
95
|
+
};
|
|
96
|
+
const closePopover = (restoreFocus = false) => {
|
|
97
|
+
popover.classList.add('hidden');
|
|
98
|
+
shownPopover = null;
|
|
99
|
+
if (restoreFocus)
|
|
100
|
+
(findIndicator(returnFocus) || toggle).focus({ preventScroll: true });
|
|
101
|
+
};
|
|
102
|
+
const renderThread = (entry, destination, { jump, close } = {}) => {
|
|
103
|
+
const heading = textNode('div', '', 'excel-comment-heading');
|
|
104
|
+
const location = textNode('div', '', 'excel-comment-location');
|
|
105
|
+
const reference = `${entry.sheetName}!${entry.address}`;
|
|
106
|
+
const cell = jump
|
|
107
|
+
? button(reference, jump, 'excel-comment-cell excel-comment-jump')
|
|
108
|
+
: textNode('span', reference, 'excel-comment-cell');
|
|
109
|
+
cell.title = reference;
|
|
110
|
+
if (jump)
|
|
111
|
+
cell.setAttribute('aria-label', label('jump', { cell: reference }));
|
|
112
|
+
if (jump)
|
|
113
|
+
cell.textContent = entry.address;
|
|
114
|
+
location.append(cell, textNode('span', entry.resolved ? label('resolved') : label(entry.kind), 'excel-comment-kind'));
|
|
115
|
+
heading.append(location);
|
|
116
|
+
if (close)
|
|
117
|
+
heading.append(close);
|
|
118
|
+
destination.append(heading);
|
|
119
|
+
for (const message of entry.messages) {
|
|
120
|
+
const item = textNode('div', '', 'excel-comment-message');
|
|
121
|
+
const metadata = textNode('div', '', 'excel-comment-metadata');
|
|
122
|
+
metadata.append(textNode('strong', message.author || label('unknown')));
|
|
123
|
+
const date = message.createdAt ? new Date(message.createdAt) : null;
|
|
124
|
+
if (date && Number.isFinite(date.getTime())) {
|
|
125
|
+
const time = textNode('time', t.formatDateTime(date, {
|
|
126
|
+
dateStyle: 'medium',
|
|
127
|
+
timeStyle: 'short',
|
|
128
|
+
}));
|
|
129
|
+
time.dateTime = date.toISOString();
|
|
130
|
+
time.title = t.formatDateTime(date);
|
|
131
|
+
metadata.append(time);
|
|
132
|
+
}
|
|
133
|
+
item.append(metadata, textNode('p', message.text));
|
|
134
|
+
destination.append(item);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const renderPanel = (revealSelected = false, focusKey = '') => {
|
|
138
|
+
var _a, _b, _c, _d;
|
|
139
|
+
const focused = root.querySelector(':focus');
|
|
140
|
+
const focusedKey = focused && panel.contains(focused)
|
|
141
|
+
? (_a = focused.closest('[data-entry-key]')) === null || _a === void 0 ? void 0 : _a.dataset.entryKey
|
|
142
|
+
: '';
|
|
143
|
+
const focusedClose = focused &&
|
|
144
|
+
panel.contains(focused) &&
|
|
145
|
+
focused.classList.contains('excel-comments-close');
|
|
146
|
+
const focusedMore = focused && panel.contains(focused) && focused.dataset.action === 'more';
|
|
147
|
+
const previousScroll = (activeList === null || activeList === void 0 ? void 0 : activeList.scrollTop) || 0;
|
|
148
|
+
panel.replaceChildren();
|
|
149
|
+
const heading = textNode('div', '', 'excel-comments-header');
|
|
150
|
+
heading.append(textNode('h2', label('title'), 'excel-comments-title'), closeButton(() => setOpen(false)));
|
|
151
|
+
panel.append(heading);
|
|
152
|
+
const list = textNode('div', '', 'excel-comments-list');
|
|
153
|
+
const all = entries();
|
|
154
|
+
if (hasError) {
|
|
155
|
+
const warning = textNode('p', label('warning'), 'excel-comments-warning');
|
|
156
|
+
warning.setAttribute('role', 'status');
|
|
157
|
+
list.append(warning);
|
|
158
|
+
}
|
|
159
|
+
if (!all.length && !hasError)
|
|
160
|
+
list.append(textNode('p', label('empty')));
|
|
161
|
+
let currentSheet;
|
|
162
|
+
let group;
|
|
163
|
+
const multipleSheets = new Set(all.map((entry) => entry.sheetId)).size > 1;
|
|
164
|
+
for (const entry of all.slice(0, limit)) {
|
|
165
|
+
if (currentSheet !== entry.sheetId) {
|
|
166
|
+
currentSheet = entry.sheetId;
|
|
167
|
+
const section = textNode('section', '', 'excel-comments-sheet-group');
|
|
168
|
+
if (multipleSheets)
|
|
169
|
+
section.append(textNode('h3', entry.sheetName, 'excel-comments-sheet-title'));
|
|
170
|
+
group = textNode('ul', '', 'excel-comments-sheet-entries');
|
|
171
|
+
section.append(group);
|
|
172
|
+
list.append(section);
|
|
173
|
+
}
|
|
174
|
+
const card = textNode('li', '', 'excel-comment-card');
|
|
175
|
+
card.dataset.entryKey = entry.key;
|
|
176
|
+
card.setAttribute('aria-current', String(entry.key === selectedId));
|
|
177
|
+
card.dataset.selected = String(entry.key === selectedId);
|
|
178
|
+
renderThread(entry, card, {
|
|
179
|
+
jump: () => {
|
|
180
|
+
selectedId = entry.key;
|
|
181
|
+
navigate(entry);
|
|
182
|
+
renderPanel(true);
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
group === null || group === void 0 ? void 0 : group.append(card);
|
|
186
|
+
}
|
|
187
|
+
if (all.length > limit) {
|
|
188
|
+
const more = button(label('more'), () => {
|
|
189
|
+
var _a;
|
|
190
|
+
const nextKey = (_a = all[limit]) === null || _a === void 0 ? void 0 : _a.key;
|
|
191
|
+
limit += 30;
|
|
192
|
+
renderPanel(false, nextKey);
|
|
193
|
+
}, 'excel-comment-jump');
|
|
194
|
+
more.dataset.action = 'more';
|
|
195
|
+
list.append(more);
|
|
196
|
+
}
|
|
197
|
+
panel.append(list);
|
|
198
|
+
activeList = list;
|
|
199
|
+
list.scrollTop = previousScroll;
|
|
200
|
+
const targetKey = focusKey || (revealSelected ? selectedId : focusedKey);
|
|
201
|
+
const target = Array.from(list.querySelectorAll('[data-entry-key]')).find((node) => node.dataset.entryKey === targetKey);
|
|
202
|
+
if (target) {
|
|
203
|
+
if (focusKey || revealSelected)
|
|
204
|
+
target.scrollIntoView({ block: 'nearest' });
|
|
205
|
+
(_b = target.querySelector('button')) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true });
|
|
206
|
+
}
|
|
207
|
+
else if (focusedClose || focusedKey)
|
|
208
|
+
(_c = panel
|
|
209
|
+
.querySelector('.excel-comments-close')) === null || _c === void 0 ? void 0 : _c.focus({ preventScroll: true });
|
|
210
|
+
else if (focusedMore)
|
|
211
|
+
(_d = (list.querySelector('[data-action=more]') ||
|
|
212
|
+
panel.querySelector('.excel-comments-close'))) === null || _d === void 0 ? void 0 : _d.focus({ preventScroll: true });
|
|
213
|
+
};
|
|
214
|
+
const setOpen = (open) => {
|
|
215
|
+
var _a;
|
|
216
|
+
closePopover();
|
|
217
|
+
panel.classList.toggle('hidden', !open);
|
|
218
|
+
toggle.setAttribute('aria-expanded', String(open));
|
|
219
|
+
if (open) {
|
|
220
|
+
renderPanel();
|
|
221
|
+
(_a = panel.querySelector('button')) === null || _a === void 0 ? void 0 : _a.focus();
|
|
222
|
+
}
|
|
223
|
+
else
|
|
224
|
+
toggle.focus();
|
|
225
|
+
};
|
|
226
|
+
const renderPopover = () => {
|
|
227
|
+
if (!shownPopover)
|
|
228
|
+
return;
|
|
229
|
+
const { entry, anchor } = shownPopover;
|
|
230
|
+
popover.replaceChildren();
|
|
231
|
+
const close = closeButton(() => closePopover(true));
|
|
232
|
+
renderThread(entry, popover, { close });
|
|
233
|
+
popover.classList.remove('hidden');
|
|
234
|
+
const hostRect = root.getBoundingClientRect();
|
|
235
|
+
const anchorRect = anchor.getBoundingClientRect();
|
|
236
|
+
const width = Math.min(320, hostRect.width - 16);
|
|
237
|
+
popover.style.width = `${width}px`;
|
|
238
|
+
popover.style.left = `${Math.max(8, Math.min(anchorRect.right - hostRect.left - width, hostRect.width - width - 8))}px`;
|
|
239
|
+
const height = popover.getBoundingClientRect().height;
|
|
240
|
+
popover.style.top = `${Math.max(8, Math.min(anchorRect.bottom - hostRect.top + 6, hostRect.height - height - 8))}px`;
|
|
241
|
+
};
|
|
242
|
+
const refreshLabels = () => {
|
|
243
|
+
var _a;
|
|
244
|
+
for (const indicator of root.querySelectorAll('.excel-comment-indicator')) {
|
|
245
|
+
const cell = indicator.dataset.cell;
|
|
246
|
+
if (cell)
|
|
247
|
+
indicator.setAttribute('aria-label', label('open', { cell }));
|
|
248
|
+
}
|
|
249
|
+
panel.setAttribute('aria-label', label('title'));
|
|
250
|
+
popover.setAttribute('aria-label', label('title'));
|
|
251
|
+
const count = entries().length;
|
|
252
|
+
toggle.textContent = label('count', { count });
|
|
253
|
+
toggle.classList.toggle('hidden', !count && !hasError);
|
|
254
|
+
if (toggle.getAttribute('aria-expanded') === 'true')
|
|
255
|
+
renderPanel();
|
|
256
|
+
if (shownPopover) {
|
|
257
|
+
const focusedClose = Boolean(popover.querySelector('.excel-comments-close:focus'));
|
|
258
|
+
const previousScroll = popover.scrollTop;
|
|
259
|
+
renderPopover();
|
|
260
|
+
popover.scrollTop = previousScroll;
|
|
261
|
+
if (focusedClose)
|
|
262
|
+
(_a = popover.querySelector('.excel-comments-close')) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
toggle.addEventListener('click', () => setOpen(toggle.getAttribute('aria-expanded') !== 'true'));
|
|
266
|
+
const keydown = (event) => {
|
|
267
|
+
if (event.key !== 'Escape')
|
|
268
|
+
return;
|
|
269
|
+
if (!popover.classList.contains('hidden')) {
|
|
270
|
+
closePopover(event.composedPath().includes(popover));
|
|
271
|
+
event.stopPropagation();
|
|
272
|
+
}
|
|
273
|
+
else if (!panel.classList.contains('hidden') &&
|
|
274
|
+
event.composedPath().includes(root)) {
|
|
275
|
+
setOpen(false);
|
|
276
|
+
event.stopPropagation();
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
const outside = (event) => {
|
|
280
|
+
if (!event.composedPath().includes(popover) &&
|
|
281
|
+
!event
|
|
282
|
+
.composedPath()
|
|
283
|
+
.some((node) => isElement(node) &&
|
|
284
|
+
node.classList.contains('excel-comment-indicator')))
|
|
285
|
+
closePopover();
|
|
286
|
+
};
|
|
287
|
+
const focusRoot = root.getRootNode();
|
|
288
|
+
focusRoot.addEventListener('focusin', focusin, true);
|
|
289
|
+
if (focusRoot !== document)
|
|
290
|
+
document.addEventListener('focusin', focusin, true);
|
|
291
|
+
document.addEventListener('keydown', keydown, true);
|
|
292
|
+
document.addEventListener('pointerdown', outside);
|
|
293
|
+
body.append(panel);
|
|
294
|
+
toolbar.prepend(toggle);
|
|
295
|
+
root.append(popover);
|
|
296
|
+
const unsubscribe = i18n === null || i18n === void 0 ? void 0 : i18n.subscribe(refreshLabels);
|
|
297
|
+
return {
|
|
298
|
+
restoreCellFocus() {
|
|
299
|
+
if (!focusedCell || focusedCell.element.isConnected)
|
|
300
|
+
return;
|
|
301
|
+
const indicator = findIndicator(focusedCell);
|
|
302
|
+
focusedCell = null;
|
|
303
|
+
indicator === null || indicator === void 0 ? void 0 : indicator.focus({ preventScroll: true });
|
|
304
|
+
},
|
|
305
|
+
update(nextSheets, error = false) {
|
|
306
|
+
if (sheets === nextSheets && hasError === error)
|
|
307
|
+
return;
|
|
308
|
+
sheets = nextSheets;
|
|
309
|
+
hasError = error;
|
|
310
|
+
refreshLabels();
|
|
311
|
+
},
|
|
312
|
+
label,
|
|
313
|
+
hide: () => closePopover(),
|
|
314
|
+
show(comment, sheet, anchor, focus = true) {
|
|
315
|
+
const entry = {
|
|
316
|
+
...comment,
|
|
317
|
+
sheetId: sheet.id,
|
|
318
|
+
sheetName: sheet.name,
|
|
319
|
+
key: `${sheet.id}:${comment.address}`,
|
|
320
|
+
};
|
|
321
|
+
returnFocus = { address: comment.address, sheetId: sheet.id };
|
|
322
|
+
selectedId = entry.key;
|
|
323
|
+
shownPopover = { entry, anchor };
|
|
324
|
+
renderPopover();
|
|
325
|
+
if (focus)
|
|
326
|
+
popover.focus({ preventScroll: true });
|
|
327
|
+
},
|
|
328
|
+
destroy() {
|
|
329
|
+
unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe();
|
|
330
|
+
shownPopover = null;
|
|
331
|
+
focusRoot.removeEventListener('focusin', focusin, true);
|
|
332
|
+
if (focusRoot !== document)
|
|
333
|
+
document.removeEventListener('focusin', focusin, true);
|
|
334
|
+
document.removeEventListener('keydown', keydown, true);
|
|
335
|
+
document.removeEventListener('pointerdown', outside);
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
export const spreadsheetCommentsStyle = `
|
|
340
|
+
.excel-wrapper .excel-comments-panel,.excel-wrapper .excel-comment-popover{--excel-comment-gutter:16px}
|
|
341
|
+
.excel-wrapper .excel-body{display:flex;position:relative;flex:1;min-height:0;min-width:0}
|
|
342
|
+
.excel-wrapper .excel-body .table-wrapper{width:auto;min-width:0;flex:1}
|
|
343
|
+
.excel-wrapper .excel-comments-toggle{align-self:flex-start;flex-shrink:0;border:0;border-radius:6px;background:transparent;min-height:32px;padding:4px 8px;color:inherit;font:inherit;font-size:12px;cursor:pointer}
|
|
344
|
+
.excel-wrapper .excel-comments-toggle:hover{background:#e8edf2}
|
|
345
|
+
.excel-wrapper .excel-comments-toggle[aria-expanded=true]{background:#e8edf2;color:#1f2937}
|
|
346
|
+
.excel-wrapper .excel-comments-panel{display:flex;flex-direction:column;width:min(360px,42%);min-width:220px;flex-shrink:0;border-left:1px solid #e5e7eb;background:#fff;color:#1f2937;font-size:14px}
|
|
347
|
+
.excel-wrapper .excel-comments-header{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:44px;box-sizing:border-box;padding:8px var(--excel-comment-gutter)}
|
|
348
|
+
.excel-wrapper .excel-comments-title{margin:0;font-size:14px;line-height:20px;font-weight:600}
|
|
349
|
+
.excel-wrapper .excel-comments-list{display:flex;flex-direction:column;gap:8px;overflow:auto;padding:4px 0 16px;min-height:0;scroll-padding:8px}
|
|
350
|
+
.excel-wrapper .excel-comments-sheet-group{display:flex;flex-direction:column;gap:4px;min-width:0}
|
|
351
|
+
.excel-wrapper .excel-comments-sheet-title{margin:0;padding:8px var(--excel-comment-gutter);font-size:12px;line-height:16px;font-weight:500;color:#64748b;overflow-wrap:anywhere}
|
|
352
|
+
.excel-wrapper .excel-comments-sheet-entries{display:flex;flex-direction:column;gap:8px;margin:0;padding:0;list-style:none;min-width:0}
|
|
353
|
+
.excel-wrapper .excel-comments-list>p{margin:0;padding:8px var(--excel-comment-gutter)}
|
|
354
|
+
.excel-wrapper .excel-comment-card{display:flex;flex-direction:column;gap:8px;min-width:0;padding:12px var(--excel-comment-gutter);border:0;background:transparent;overflow-wrap:anywhere}
|
|
355
|
+
.excel-wrapper .excel-comment-card[data-selected=true]{background:#f1f5f9}
|
|
356
|
+
.excel-wrapper .excel-comment-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;min-width:0}
|
|
357
|
+
.excel-wrapper .excel-comment-location{display:flex;flex-wrap:wrap;align-items:baseline;gap:6px;min-width:0;flex:1}
|
|
358
|
+
.excel-wrapper .excel-comment-cell{font-size:14px;font-weight:500;line-height:20px;min-width:0;max-width:100%;overflow-wrap:anywhere}
|
|
359
|
+
.excel-wrapper .excel-comment-kind{font-size:12px;line-height:16px;color:#64748b}
|
|
360
|
+
.excel-wrapper .excel-comment-message{display:flex;flex-direction:column;gap:4px;min-width:0}
|
|
361
|
+
.excel-wrapper .excel-comment-metadata{display:flex;flex-wrap:wrap;align-items:baseline;column-gap:8px;row-gap:2px;min-width:0;font-size:12px;line-height:20px;color:#64748b}
|
|
362
|
+
.excel-wrapper .excel-comment-metadata strong{min-width:0;max-width:100%;color:#1f2937;font-size:14px;font-weight:500;overflow-wrap:anywhere}
|
|
363
|
+
.excel-wrapper .excel-comment-message p{margin:0;min-width:0;white-space:pre-wrap;overflow-wrap:anywhere;line-height:20px;font-size:14px;color:inherit}
|
|
364
|
+
.excel-wrapper .excel-comments-close{display:flex;align-items:center;justify-content:center;border:0;background:transparent;color:inherit;font:inherit;font-size:20px;width:28px;height:28px;padding:0;cursor:pointer;border-radius:4px;flex-shrink:0}
|
|
365
|
+
.excel-wrapper .excel-comments-close:hover{background:#e8edf2}
|
|
366
|
+
.excel-wrapper .excel-comment-jump{border:0;padding:0;background:transparent;color:#166534;font:inherit;font-size:14px;font-weight:500;line-height:20px;text-align:left;cursor:pointer;overflow-wrap:anywhere;min-height:24px}
|
|
367
|
+
.excel-wrapper .excel-comment-jump:hover{text-decoration:underline;text-underline-offset:3px}
|
|
368
|
+
.excel-wrapper .excel-comments-list>.excel-comment-jump{align-self:flex-start;padding:8px var(--excel-comment-gutter);font-size:12px}
|
|
369
|
+
.excel-wrapper .excel-comment-popover{position:absolute;display:flex;flex-direction:column;gap:12px;box-sizing:border-box;outline:none;z-index:150;max-height:calc(100% - 16px);overflow:auto;padding:var(--excel-comment-gutter);border:1px solid #e5e7eb;border-radius:8px;background:#fff;color:#1f2937;box-shadow:0 8px 28px #0002;font-size:14px;overflow-wrap:anywhere}
|
|
370
|
+
.excel-wrapper .excel-comment-indicator{position:absolute;top:0;right:0;width:16px;height:16px;border:0;background:transparent;padding:0;pointer-events:auto;cursor:pointer;z-index:5}
|
|
371
|
+
.excel-wrapper .excel-comment-indicator::after{content:'';position:absolute;right:1px;top:1px;border-top:8px solid #7c3aed;border-left:8px solid transparent}
|
|
372
|
+
.excel-wrapper .excel-comment-indicator[data-kind=note]::after{border-top-color:#dc2626}
|
|
373
|
+
.excel-wrapper .excel-comment-indicator:focus-visible{outline:2px solid #2563eb;outline-offset:-2px}
|
|
374
|
+
.excel-wrapper .excel-comment-indicator[data-resolved=true]::after{border-top-color:#64748b}
|
|
375
|
+
.excel-wrapper .excel-comments-warning{margin:0;padding:8px var(--excel-comment-gutter);color:#92400e;font-size:12px}
|
|
376
|
+
.excel-wrapper[data-spreadsheet-theme=dark] .excel-comments-panel{background:#111827;color:#e5e7eb;border-color:#334155}
|
|
377
|
+
.excel-wrapper[data-spreadsheet-theme=dark] .excel-comment-popover{background:#18212f;color:#e5e7eb;border-color:#475569}
|
|
378
|
+
.excel-wrapper[data-spreadsheet-theme=dark] .excel-comment-card[data-selected=true],.excel-wrapper[data-spreadsheet-theme=dark] .excel-comments-close:hover,.excel-wrapper[data-spreadsheet-theme=dark] .excel-comments-toggle:hover{background:#243044}
|
|
379
|
+
.excel-wrapper[data-spreadsheet-theme=dark] .excel-comment-kind,.excel-wrapper[data-spreadsheet-theme=dark] .excel-comment-metadata{color:#94a3b8}
|
|
380
|
+
.excel-wrapper[data-spreadsheet-theme=dark] .excel-comment-metadata strong{color:#e5e7eb}
|
|
381
|
+
.excel-wrapper button:focus-visible{outline:2px solid #2563eb;outline-offset:2px}
|
|
382
|
+
.excel-wrapper[data-spreadsheet-theme=dark] .excel-comment-jump{color:#86efac}
|
|
383
|
+
.excel-wrapper[data-spreadsheet-theme=dark] .excel-comments-sheet-title{color:#94a3b8}
|
|
384
|
+
.excel-wrapper[data-spreadsheet-theme=dark] button:focus-visible{outline-color:#60a5fa}
|
|
385
|
+
.excel-wrapper[data-spreadsheet-theme=dark] .excel-comments-toggle[aria-expanded=true]{background:#243044;color:#e5e7eb}
|
|
386
|
+
@media(pointer:coarse){.excel-wrapper .excel-comment-jump{min-height:32px}}
|
|
387
|
+
@media(max-width:640px){.excel-wrapper .excel-body:has(>.excel-comments-panel:not(.hidden)){display:grid;grid-template-rows:minmax(0,55fr) minmax(0,45fr)}.excel-wrapper .excel-comments-panel{width:100%;min-width:0;min-height:0;border-left:0;border-top:1px solid #e5e7eb}.excel-wrapper[data-spreadsheet-theme=dark] .excel-comments-panel{border-color:#334155}}
|
|
388
|
+
`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SheetRowAnchor } from './worker/type.js';
|
|
2
|
+
import type { VirtualSheetState } from './state.js';
|
|
3
|
+
export declare const applyAutoRowDrawingGeometry: <T extends {
|
|
4
|
+
top: number;
|
|
5
|
+
height: number;
|
|
6
|
+
rowAnchor?: SheetRowAnchor;
|
|
7
|
+
}>(item: T, state: VirtualSheetState) => T;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const offsets = new WeakMap();
|
|
2
|
+
const offsetBefore = (state, row) => {
|
|
3
|
+
let cache = offsets.get(state);
|
|
4
|
+
if (!cache || cache.revision !== state.autoHeightRevision) {
|
|
5
|
+
const entries = [...state.autoRowHeights]
|
|
6
|
+
.filter(([index]) => !state.rowHeightOverrides.has(index) &&
|
|
7
|
+
!state.fixedHeightRows.has(index))
|
|
8
|
+
.map(([index, height]) => {
|
|
9
|
+
var _a;
|
|
10
|
+
return [
|
|
11
|
+
index,
|
|
12
|
+
Math.max(0, height -
|
|
13
|
+
((_a = state.sourceRowHeights.get(index)) !== null && _a !== void 0 ? _a : state.defaults.rowHeight)),
|
|
14
|
+
];
|
|
15
|
+
})
|
|
16
|
+
.filter(([, delta]) => delta > 0)
|
|
17
|
+
.sort((a, b) => a[0] - b[0]);
|
|
18
|
+
let sum = 0;
|
|
19
|
+
cache = {
|
|
20
|
+
revision: state.autoHeightRevision,
|
|
21
|
+
rows: entries.map(([index]) => index),
|
|
22
|
+
sums: entries.map(([, delta]) => (sum += delta)),
|
|
23
|
+
};
|
|
24
|
+
offsets.set(state, cache);
|
|
25
|
+
}
|
|
26
|
+
let left = 0, right = cache.rows.length;
|
|
27
|
+
while (left < right) {
|
|
28
|
+
const middle = (left + right) >>> 1;
|
|
29
|
+
if (cache.rows[middle] < row)
|
|
30
|
+
left = middle + 1;
|
|
31
|
+
else
|
|
32
|
+
right = middle;
|
|
33
|
+
}
|
|
34
|
+
return left ? cache.sums[left - 1] : 0;
|
|
35
|
+
};
|
|
36
|
+
export const applyAutoRowDrawingGeometry = (item, state) => {
|
|
37
|
+
const anchor = item.rowAnchor;
|
|
38
|
+
if (!anchor || anchor.mode === 'absolute')
|
|
39
|
+
return item;
|
|
40
|
+
const topDelta = offsetBefore(state, anchor.fromRow);
|
|
41
|
+
const bottomDelta = anchor.mode === 'cell'
|
|
42
|
+
? offsetBefore(state, anchor.fromRow + 1)
|
|
43
|
+
: anchor.mode === 'twoCell' && anchor.toRow !== undefined
|
|
44
|
+
? offsetBefore(state, anchor.toRow)
|
|
45
|
+
: topDelta;
|
|
46
|
+
return {
|
|
47
|
+
...item,
|
|
48
|
+
top: item.top + topDelta,
|
|
49
|
+
height: Math.max(0.1, item.height + bottomDelta - topDelta),
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -10,13 +10,11 @@ type Options = {
|
|
|
10
10
|
jump: (range: FileViewerSpreadsheetRange) => void;
|
|
11
11
|
clearJump: () => void;
|
|
12
12
|
};
|
|
13
|
-
/** Own requests from registration through parsing, virtual-window loading and paint. */
|
|
14
13
|
export declare const createSpreadsheetRangeNavigation: (options: Options) => {
|
|
15
14
|
provider: FileViewerViewStateProvider;
|
|
16
15
|
cancel: (result?: "cancelled" | "failed" | "disposed") => void;
|
|
17
16
|
notify: (action: FileViewerViewStateChange["action"], source?: FileViewerViewStateChange["source"], notify?: boolean) => void;
|
|
18
17
|
isPending: () => boolean;
|
|
19
|
-
/** Called after the target virtual window loads, before drawing the highlight. */
|
|
20
18
|
prepare(totalRows: number, totalCols: number): (() => void) | null;
|
|
21
19
|
contains(sheetId: number, row: number, col: number): boolean;
|
|
22
20
|
};
|
|
@@ -14,7 +14,6 @@ const cloneState = (state) => ({
|
|
|
14
14
|
range: state.spreadsheet.range ? { ...state.spreadsheet.range } : undefined,
|
|
15
15
|
} : undefined,
|
|
16
16
|
});
|
|
17
|
-
/** Own requests from registration through parsing, virtual-window loading and paint. */
|
|
18
17
|
export const createSpreadsheetRangeNavigation = (options) => {
|
|
19
18
|
let stopped;
|
|
20
19
|
let status = 'idle';
|
|
@@ -53,7 +52,6 @@ export const createSpreadsheetRangeNavigation = (options) => {
|
|
|
53
52
|
}
|
|
54
53
|
};
|
|
55
54
|
const cancel = (result = 'cancelled') => {
|
|
56
|
-
// Disposal is terminal, including when a late parser rejection arrives.
|
|
57
55
|
if (stopped === 'disposed')
|
|
58
56
|
return;
|
|
59
57
|
const hadHighlight = !!highlighted;
|
|
@@ -68,7 +66,6 @@ export const createSpreadsheetRangeNavigation = (options) => {
|
|
|
68
66
|
if (result === 'disposed')
|
|
69
67
|
listeners.clear();
|
|
70
68
|
};
|
|
71
|
-
// Consume failure even when no API request was made before parsing failed.
|
|
72
69
|
void options.ready.catch(() => { if (!stopped)
|
|
73
70
|
cancel('failed'); });
|
|
74
71
|
const provider = {
|
|
@@ -143,7 +140,6 @@ export const createSpreadsheetRangeNavigation = (options) => {
|
|
|
143
140
|
return {
|
|
144
141
|
provider, cancel, notify: emit,
|
|
145
142
|
isPending: () => !!(pending === null || pending === void 0 ? void 0 : pending.range),
|
|
146
|
-
/** Called after the target virtual window loads, before drawing the highlight. */
|
|
147
143
|
prepare(totalRows, totalCols) {
|
|
148
144
|
const request = pending;
|
|
149
145
|
if (!(request === null || request === void 0 ? void 0 : request.range))
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { SheetRegion, SheetSourceExtent, SheetSourcePoint } from './worker/type.js';
|
|
2
|
+
export declare const EXCEL_SOURCE_EXTENT: SheetSourceExtent;
|
|
3
|
+
export declare const REGION_LIMIT: {
|
|
4
|
+
readonly rows: 500;
|
|
5
|
+
readonly cols: 64;
|
|
6
|
+
};
|
|
7
|
+
export declare const assertSourcePoint: (point: SheetSourcePoint) => void;
|
|
8
|
+
export declare const assertSheetRegion: (region: SheetRegion) => void;
|
|
9
|
+
export declare const createSheetRegion: (target: SheetSourcePoint, id: number, extent?: SheetSourceExtent) => SheetRegion;
|
|
10
|
+
export declare const sourceToRegion: (region: SheetRegion, point: SheetSourcePoint) => SheetSourcePoint | null;
|
|
11
|
+
export declare const regionToSource: (region: SheetRegion, point: SheetSourcePoint) => SheetSourcePoint;
|
|
12
|
+
export declare const regionIntersects: (region: SheetRegion, range: {
|
|
13
|
+
row: number;
|
|
14
|
+
col: number;
|
|
15
|
+
rowspan: number;
|
|
16
|
+
colspan: number;
|
|
17
|
+
}) => boolean;
|
|
18
|
+
export declare const ORDINARY_GRID_BUDGET: {
|
|
19
|
+
readonly rows: 50000;
|
|
20
|
+
readonly cols: 1024;
|
|
21
|
+
readonly windowCells: 128000;
|
|
22
|
+
};
|
|
23
|
+
export declare const getSheetMaterialization: (extent: SheetSourceExtent) => {
|
|
24
|
+
scope: "default-renderer";
|
|
25
|
+
kind: "ordinary" | "region-required";
|
|
26
|
+
reasons: string[];
|
|
27
|
+
windowCells: number;
|
|
28
|
+
limits: {
|
|
29
|
+
rows: 50000;
|
|
30
|
+
cols: 1024;
|
|
31
|
+
windowCells: 128000;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare const OCCUPIED_INDEX_BUDGET: {
|
|
35
|
+
readonly tiles: 4096;
|
|
36
|
+
readonly visitedCells: 2000000;
|
|
37
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export const EXCEL_SOURCE_EXTENT = { rows: 1048576, cols: 16384 };
|
|
2
|
+
export const REGION_LIMIT = { rows: 500, cols: 64 };
|
|
3
|
+
const integer = (value, max, minimum = 0) => Number.isSafeInteger(value) && value >= minimum && value <= max;
|
|
4
|
+
export const assertSourcePoint = (point) => {
|
|
5
|
+
if (!integer(point.row, EXCEL_SOURCE_EXTENT.rows - 1) || !integer(point.col, EXCEL_SOURCE_EXTENT.cols - 1)) {
|
|
6
|
+
throw new RangeError('Invalid spreadsheet source address');
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
export const assertSheetRegion = (region) => {
|
|
10
|
+
if (!region || !integer(region.id, Number.MAX_SAFE_INTEGER)
|
|
11
|
+
|| !integer(region.rowCount, REGION_LIMIT.rows, 1)
|
|
12
|
+
|| !integer(region.colCount, REGION_LIMIT.cols, 1)) {
|
|
13
|
+
throw new RangeError('Invalid or oversized spreadsheet region');
|
|
14
|
+
}
|
|
15
|
+
assertSourcePoint({ row: region.startRow, col: region.startCol });
|
|
16
|
+
assertSourcePoint({ row: region.startRow + region.rowCount - 1, col: region.startCol + region.colCount - 1 });
|
|
17
|
+
};
|
|
18
|
+
export const createSheetRegion = (target, id, extent = EXCEL_SOURCE_EXTENT) => {
|
|
19
|
+
assertSourcePoint(target);
|
|
20
|
+
if (!integer(extent.rows, EXCEL_SOURCE_EXTENT.rows, 1) || !integer(extent.cols, EXCEL_SOURCE_EXTENT.cols, 1)
|
|
21
|
+
|| target.row >= extent.rows || target.col >= extent.cols)
|
|
22
|
+
throw new RangeError('Address outside source extent');
|
|
23
|
+
const rowCount = Math.min(extent.rows, REGION_LIMIT.rows), colCount = Math.min(extent.cols, REGION_LIMIT.cols);
|
|
24
|
+
const region = {
|
|
25
|
+
id,
|
|
26
|
+
startRow: Math.min(Math.max(0, target.row - Math.floor(rowCount / 2)), extent.rows - rowCount),
|
|
27
|
+
startCol: Math.min(Math.max(0, target.col - Math.floor(colCount / 2)), extent.cols - colCount),
|
|
28
|
+
rowCount, colCount,
|
|
29
|
+
};
|
|
30
|
+
assertSheetRegion(region);
|
|
31
|
+
return region;
|
|
32
|
+
};
|
|
33
|
+
export const sourceToRegion = (region, point) => {
|
|
34
|
+
const row = point.row - region.startRow, col = point.col - region.startCol;
|
|
35
|
+
return integer(row, region.rowCount - 1) && integer(col, region.colCount - 1) ? { row, col } : null;
|
|
36
|
+
};
|
|
37
|
+
export const regionToSource = (region, point) => {
|
|
38
|
+
if (!integer(point.row, region.rowCount - 1) || !integer(point.col, region.colCount - 1))
|
|
39
|
+
throw new RangeError('Address outside local region');
|
|
40
|
+
return { row: region.startRow + point.row, col: region.startCol + point.col };
|
|
41
|
+
};
|
|
42
|
+
export const regionIntersects = (region, range) => range.row < region.startRow + region.rowCount && range.row + range.rowspan > region.startRow
|
|
43
|
+
&& range.col < region.startCol + region.colCount && range.col + range.colspan > region.startCol;
|
|
44
|
+
export const ORDINARY_GRID_BUDGET = { rows: 50000, cols: 1024, windowCells: 128000 };
|
|
45
|
+
export const getSheetMaterialization = (extent) => {
|
|
46
|
+
const windowCells = Math.min(extent.rows, REGION_LIMIT.rows) * extent.cols;
|
|
47
|
+
const reasons = [
|
|
48
|
+
...(extent.rows > ORDINARY_GRID_BUDGET.rows ? ['row-count'] : []),
|
|
49
|
+
...(extent.cols > ORDINARY_GRID_BUDGET.cols ? ['column-count'] : []),
|
|
50
|
+
...(windowCells > ORDINARY_GRID_BUDGET.windowCells ? ['window-cells'] : []),
|
|
51
|
+
];
|
|
52
|
+
return { scope: 'default-renderer', kind: reasons.length ? 'region-required' : 'ordinary', reasons, windowCells, limits: { ...ORDINARY_GRID_BUDGET } };
|
|
53
|
+
};
|
|
54
|
+
export const OCCUPIED_INDEX_BUDGET = { tiles: 4096, visitedCells: 2000000 };
|
|
@@ -53,9 +53,14 @@ export interface VirtualSheetState {
|
|
|
53
53
|
columns: Column[];
|
|
54
54
|
cellCache: Map<string, CellStyleCache>;
|
|
55
55
|
mergeStartMap: Map<string, CellMerge>;
|
|
56
|
-
mergeCoveredMap: Map<string,
|
|
56
|
+
mergeCoveredMap: Map<string, string>;
|
|
57
57
|
rowHeightCache: Map<number, number>;
|
|
58
|
-
|
|
58
|
+
sourceRowHeights: Map<number, number>;
|
|
59
|
+
fixedHeightRows: Set<number>;
|
|
60
|
+
autoHeightDisabled: boolean;
|
|
61
|
+
autoHeightCells: Map<number, Set<number>>;
|
|
62
|
+
autoRowHeights: Map<number, number>;
|
|
63
|
+
autoHeightRevision: number;
|
|
59
64
|
rowHeightOverrides: Map<number, number>;
|
|
60
65
|
windowRows: Map<number, number[]>;
|
|
61
66
|
windowCells: Map<number, string[]>;
|
|
@@ -26,6 +26,12 @@ export const createEmptyVirtualState = () => ({
|
|
|
26
26
|
mergeStartMap: new Map(),
|
|
27
27
|
mergeCoveredMap: new Map(),
|
|
28
28
|
rowHeightCache: new Map(),
|
|
29
|
+
sourceRowHeights: new Map(),
|
|
30
|
+
fixedHeightRows: new Set(),
|
|
31
|
+
autoHeightDisabled: false,
|
|
32
|
+
autoHeightCells: new Map(),
|
|
33
|
+
autoRowHeights: new Map(),
|
|
34
|
+
autoHeightRevision: 0,
|
|
29
35
|
rowHeightOverrides: new Map(),
|
|
30
36
|
windowRows: new Map(),
|
|
31
37
|
windowCells: new Map(),
|
|
@@ -65,8 +71,6 @@ export const getWindowStart = (row = 0, totalRows = 0) => {
|
|
|
65
71
|
const start = Math.floor(Math.max(row, 0) / WINDOW_SIZE) * WINDOW_SIZE;
|
|
66
72
|
return clampWindowStart(start, totalRows);
|
|
67
73
|
};
|
|
68
|
-
// 视口周边始终保留一小圈热窗口,滚轮滚动和拖动滚动条都可以直接命中缓存,
|
|
69
|
-
// 避免每次跳转都同步等待 worker 回包。
|
|
70
74
|
export const collectWindowStarts = ({ startRow, endRow, direction, totalRows, far = false }) => {
|
|
71
75
|
const starts = new Set();
|
|
72
76
|
const firstWindow = getWindowStart(startRow, totalRows);
|