@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
package/README.en.md
CHANGED
|
@@ -54,6 +54,20 @@ const options = {
|
|
|
54
54
|
|
|
55
55
|
This changes only the display: workbook data, used range, original-file downloads/exports, search results and content counts remain unchanged.
|
|
56
56
|
|
|
57
|
+
## Row numbers and legacy record ordinals
|
|
58
|
+
|
|
59
|
+
The gutter now defaults to source row numbers: the header is row 1 and the next row is 2, matching A1 addresses such as `Sales!A2`. Previous versions guessed whether the first row was a field header and could leave its number blank. To keep that display explicitly, set:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
const options = {
|
|
63
|
+
spreadsheet: { rowNumberMode: 'legacy-records' },
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`rowNumberMode: 'source'` is the default. In `legacy-records` mode, the gutter is headed `#` and shows record ordinals, **not source cell addresses**. The original heuristic skips numbering the first row only when there are at least two rows, no merged cells in the initially loaded window, enough nonempty text cells in the first row, and at least two values in the second. It can also treat ordinary all-text data or negative numeric text as a header; this opt-in mode preserves that behavior rather than claiming reliable header detection. Blank and hidden rows are not compacted. Merged cells in the initial window prevent the offset; merges loaded in later windows do not trigger renumbering.
|
|
68
|
+
|
|
69
|
+
Both modes retain every data row, including the first row. Search labels still use source A1 addresses, and public spreadsheet ranges remain zero-based source coordinates. Window loading, sheet switching, viewport padding and original-file downloads do not change these coordinates. This option changes only gutter display; use `source` when reading cell addresses.
|
|
70
|
+
|
|
57
71
|
## Offline Assets
|
|
58
72
|
|
|
59
73
|
The optional worker path is:
|
package/README.md
CHANGED
|
@@ -54,6 +54,20 @@ const options = {
|
|
|
54
54
|
|
|
55
55
|
This changes only the display: workbook data, used range, original-file downloads/exports, search results and content counts remain unchanged.
|
|
56
56
|
|
|
57
|
+
## Row numbers and legacy record ordinals
|
|
58
|
+
|
|
59
|
+
The gutter now defaults to source row numbers: the header is row 1 and the next row is 2, matching A1 addresses such as `Sales!A2`. Previous versions guessed whether the first row was a field header and could leave its number blank. To keep that display explicitly, set:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
const options = {
|
|
63
|
+
spreadsheet: { rowNumberMode: 'legacy-records' },
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`rowNumberMode: 'source'` is the default. In `legacy-records` mode, the gutter is headed `#` and shows record ordinals, **not source cell addresses**. The original heuristic skips numbering the first row only when there are at least two rows, no merged cells in the initially loaded window, enough nonempty text cells in the first row, and at least two values in the second. It can also treat ordinary all-text data or negative numeric text as a header; this opt-in mode preserves that behavior rather than claiming reliable header detection. Blank and hidden rows are not compacted. Merged cells in the initial window prevent the offset; merges loaded in later windows do not trigger renumbering.
|
|
68
|
+
|
|
69
|
+
Both modes retain every data row, including the first row. Search labels still use source A1 addresses, and public spreadsheet ranges remain zero-based source coordinates. Window loading, sheet switching, viewport padding and original-file downloads do not change these coordinates. This option changes only gutter display; use `source` when reading cell addresses.
|
|
70
|
+
|
|
57
71
|
## Offline Assets
|
|
58
72
|
|
|
59
73
|
The optional worker path is:
|
package/README.zh-CN.md
CHANGED
|
@@ -54,6 +54,20 @@ const options = {
|
|
|
54
54
|
|
|
55
55
|
补充部分只用于显示,不改变工作簿数据、used-range、原文件下载/导出、搜索结果或内容统计。
|
|
56
56
|
|
|
57
|
+
## 行号与旧记录序号
|
|
58
|
+
|
|
59
|
+
左侧编号现在默认使用源表格行号:表头为第 1 行,下一行为第 2 行,与 `Sales!A2` 等 A1 地址一致。旧版本会猜测首行是否为字段头,并可能不显示首行编号。需要保留旧显示方式时,请显式设置:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
const options = {
|
|
63
|
+
spreadsheet: { rowNumberMode: 'legacy-records' },
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`rowNumberMode: 'source'` 为默认值。`legacy-records` 模式的编号栏以 `#` 标识,显示的是**记录序号,不是源单元格地址**。它保留原启发式:至少两行、首个加载窗口中没有合并单元格、首行有足够的非空文本单元格且第二行至少有两个值时,首行不编号,后续从 1 开始。普通纯文本数据和负数字符串也可能被误判为字段头;这个显式兼容模式保留旧行为,并不保证正确识别表头。空行与隐藏行不会被压缩重编号;首窗口有合并单元格时不偏移,后续窗口中的合并不会触发重新编号。
|
|
68
|
+
|
|
69
|
+
两种模式均保留首行及全部数据。搜索标签仍使用源 A1 地址,公开 spreadsheet range 仍使用从零开始的源坐标;窗口加载、切换工作表、视口空白补齐和原文件下载均不改变坐标。该选项只改变左侧编号;需要读取单元格地址时请使用 `source`。
|
|
70
|
+
|
|
57
71
|
## 离线资产
|
|
58
72
|
|
|
59
73
|
默认可选 Worker 路径为:
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type VirtualSheetState } from './state.js';
|
|
2
|
+
export declare const canAutoSizeRow: (state: VirtualSheetState, row: number) => boolean;
|
|
3
|
+
interface Options {
|
|
4
|
+
host: HTMLElement;
|
|
5
|
+
getState(): VirtualSheetState;
|
|
6
|
+
getZoom(): number;
|
|
7
|
+
getFirstVisibleRow(): number;
|
|
8
|
+
commit(changes: Map<number, number>): void;
|
|
9
|
+
}
|
|
10
|
+
export declare const createAutoRowHeight: (options: Options) => {
|
|
11
|
+
enqueue: (rows: Iterable<number>) => void;
|
|
12
|
+
invalidate: (clearCache?: boolean) => void;
|
|
13
|
+
cancel: () => void;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { displayCellKey, getDataKey } from './state.js';
|
|
2
|
+
import { createAutoHeightProbe, getDisplayColumns } from './view.js';
|
|
3
|
+
const MAX_BATCH_CELLS = 32;
|
|
4
|
+
const MAX_CACHE_ENTRIES = 2048;
|
|
5
|
+
const MAX_CACHE_CHARACTERS = 1024 * 1024;
|
|
6
|
+
export const canAutoSizeRow = (state, row) => {
|
|
7
|
+
var _a;
|
|
8
|
+
return !state.autoHeightDisabled &&
|
|
9
|
+
!state.fixedHeightRows.has(row) &&
|
|
10
|
+
!state.rowHeightOverrides.has(row) &&
|
|
11
|
+
((_a = state.sourceRowHeights.get(row)) !== null && _a !== void 0 ? _a : state.defaults.rowHeight) > 0.1;
|
|
12
|
+
};
|
|
13
|
+
export const createAutoRowHeight = (options) => {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
const document = options.host.ownerDocument, view = document.defaultView;
|
|
16
|
+
const host = document.createElement('div');
|
|
17
|
+
host.dataset.spreadsheetAutoHeight = 'true';
|
|
18
|
+
host.setAttribute('aria-hidden', 'true');
|
|
19
|
+
host.inert = true;
|
|
20
|
+
Object.assign(host.style, {
|
|
21
|
+
position: 'absolute',
|
|
22
|
+
left: '0',
|
|
23
|
+
top: '0',
|
|
24
|
+
width: '0',
|
|
25
|
+
height: '0',
|
|
26
|
+
overflow: 'hidden',
|
|
27
|
+
visibility: 'hidden',
|
|
28
|
+
pointerEvents: 'none',
|
|
29
|
+
contain: 'layout style',
|
|
30
|
+
});
|
|
31
|
+
options.host.append(host);
|
|
32
|
+
const cache = new Map();
|
|
33
|
+
let cacheCharacters = 0, frame = 0, disposed = false, generation = 0;
|
|
34
|
+
let state = options.getState(), zoom = options.getZoom(), jobs = [];
|
|
35
|
+
const queued = new Set();
|
|
36
|
+
const cacheSet = (key, value) => {
|
|
37
|
+
if (key.length > MAX_CACHE_CHARACTERS / 16 || value <= 0)
|
|
38
|
+
return;
|
|
39
|
+
if (cache.has(key))
|
|
40
|
+
cacheCharacters -= key.length;
|
|
41
|
+
cache.delete(key);
|
|
42
|
+
cache.set(key, value);
|
|
43
|
+
cacheCharacters += key.length;
|
|
44
|
+
while (cache.size > MAX_CACHE_ENTRIES ||
|
|
45
|
+
cacheCharacters > MAX_CACHE_CHARACTERS) {
|
|
46
|
+
const first = cache.keys().next().value;
|
|
47
|
+
if (first === undefined)
|
|
48
|
+
break;
|
|
49
|
+
cache.delete(first);
|
|
50
|
+
cacheCharacters -= first.length;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const scheduleFrame = () => {
|
|
54
|
+
if (!disposed && !frame && jobs.length && view)
|
|
55
|
+
frame = view.requestAnimationFrame(flush);
|
|
56
|
+
};
|
|
57
|
+
function flush() {
|
|
58
|
+
var _a;
|
|
59
|
+
frame = 0;
|
|
60
|
+
if (disposed || state !== options.getState() || zoom !== options.getZoom())
|
|
61
|
+
return;
|
|
62
|
+
const token = generation, changes = new Map();
|
|
63
|
+
const columns = new Map(getDisplayColumns(state.columns, zoom).map((column) => [
|
|
64
|
+
`${column.key}`,
|
|
65
|
+
column,
|
|
66
|
+
]));
|
|
67
|
+
const measurements = [];
|
|
68
|
+
let processed = 0;
|
|
69
|
+
const started = (view === null || view === void 0 ? void 0 : view.performance.now()) || 0;
|
|
70
|
+
while (jobs.length &&
|
|
71
|
+
processed < MAX_BATCH_CELLS &&
|
|
72
|
+
(!processed || ((view === null || view === void 0 ? void 0 : view.performance.now()) || 0) - started < 8)) {
|
|
73
|
+
const job = jobs[0];
|
|
74
|
+
if (!canAutoSizeRow(state, job.row)) {
|
|
75
|
+
jobs.shift();
|
|
76
|
+
queued.delete(job.row);
|
|
77
|
+
processed++;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (job.index >= job.columns.length) {
|
|
81
|
+
jobs.shift();
|
|
82
|
+
queued.delete(job.row);
|
|
83
|
+
changes.set(job.row, job.height);
|
|
84
|
+
processed++;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const col = job.columns[job.index++];
|
|
88
|
+
processed++;
|
|
89
|
+
const column = columns.get(getDataKey(col)), width = Number(column === null || column === void 0 ? void 0 : column.width);
|
|
90
|
+
const key = displayCellKey(job.row, col + 1);
|
|
91
|
+
const style = state.cellCache.get(key), value = (_a = state.rows[job.row]) === null || _a === void 0 ? void 0 : _a[getDataKey(col)];
|
|
92
|
+
if (!(style === null || style === void 0 ? void 0 : style.wrapText) ||
|
|
93
|
+
!column ||
|
|
94
|
+
column.hide ||
|
|
95
|
+
!(width > 0) ||
|
|
96
|
+
value === undefined ||
|
|
97
|
+
value === null ||
|
|
98
|
+
value === '' ||
|
|
99
|
+
state.mergeStartMap.has(key) ||
|
|
100
|
+
state.mergeCoveredMap.has(key))
|
|
101
|
+
continue;
|
|
102
|
+
const cacheKey = JSON.stringify([zoom, width, value, style]);
|
|
103
|
+
const cached = cache.get(cacheKey);
|
|
104
|
+
if (cached !== undefined) {
|
|
105
|
+
cache.delete(cacheKey);
|
|
106
|
+
cache.set(cacheKey, cached);
|
|
107
|
+
job.height = Math.max(job.height, cached / zoom);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const probe = createAutoHeightProbe(document, value, style, width, zoom);
|
|
111
|
+
host.append(probe);
|
|
112
|
+
measurements.push({ job, key: cacheKey, probe });
|
|
113
|
+
}
|
|
114
|
+
for (const item of measurements) {
|
|
115
|
+
const height = Math.ceil(Math.max(item.probe.getBoundingClientRect().height, item.probe.scrollHeight));
|
|
116
|
+
if (height > 0) {
|
|
117
|
+
cacheSet(item.key, height);
|
|
118
|
+
item.job.height = Math.max(item.job.height, height / zoom);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
host.replaceChildren();
|
|
122
|
+
for (const item of measurements)
|
|
123
|
+
if (!queued.has(item.job.row))
|
|
124
|
+
changes.set(item.job.row, item.job.height);
|
|
125
|
+
if (jobs[0] && jobs[0].index >= jobs[0].columns.length) {
|
|
126
|
+
const job = jobs.shift();
|
|
127
|
+
queued.delete(job.row);
|
|
128
|
+
changes.set(job.row, job.height);
|
|
129
|
+
}
|
|
130
|
+
if (disposed ||
|
|
131
|
+
token !== generation ||
|
|
132
|
+
state !== options.getState() ||
|
|
133
|
+
zoom !== options.getZoom())
|
|
134
|
+
return;
|
|
135
|
+
for (const [row] of changes)
|
|
136
|
+
if (!canAutoSizeRow(state, row))
|
|
137
|
+
changes.delete(row);
|
|
138
|
+
if (changes.size)
|
|
139
|
+
options.commit(changes);
|
|
140
|
+
scheduleFrame();
|
|
141
|
+
}
|
|
142
|
+
const enqueue = (rows) => {
|
|
143
|
+
var _a;
|
|
144
|
+
if (disposed)
|
|
145
|
+
return;
|
|
146
|
+
if (state !== options.getState() || zoom !== options.getZoom())
|
|
147
|
+
reset(false);
|
|
148
|
+
const first = options.getFirstVisibleRow();
|
|
149
|
+
const sorted = [...rows].sort((a, b) => Math.abs(a - first) - Math.abs(b - first));
|
|
150
|
+
for (const row of sorted) {
|
|
151
|
+
if (queued.has(row) || !canAutoSizeRow(state, row))
|
|
152
|
+
continue;
|
|
153
|
+
const columns = [...(state.autoHeightCells.get(row) || [])];
|
|
154
|
+
if (!columns.length && !state.autoRowHeights.has(row))
|
|
155
|
+
continue;
|
|
156
|
+
queued.add(row);
|
|
157
|
+
jobs.push({
|
|
158
|
+
row,
|
|
159
|
+
columns,
|
|
160
|
+
index: 0,
|
|
161
|
+
height: (_a = state.sourceRowHeights.get(row)) !== null && _a !== void 0 ? _a : state.defaults.rowHeight,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
scheduleFrame();
|
|
165
|
+
};
|
|
166
|
+
function reset(clearCache = false) {
|
|
167
|
+
generation++;
|
|
168
|
+
if (frame && view)
|
|
169
|
+
view.cancelAnimationFrame(frame);
|
|
170
|
+
frame = 0;
|
|
171
|
+
jobs = [];
|
|
172
|
+
queued.clear();
|
|
173
|
+
host.replaceChildren();
|
|
174
|
+
state = options.getState();
|
|
175
|
+
zoom = options.getZoom();
|
|
176
|
+
if (clearCache) {
|
|
177
|
+
cache.clear();
|
|
178
|
+
cacheCharacters = 0;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const invalidate = (clearCache = false) => {
|
|
182
|
+
reset(clearCache);
|
|
183
|
+
enqueue(new Set([
|
|
184
|
+
...state.autoHeightCells.keys(),
|
|
185
|
+
...state.autoRowHeights.keys(),
|
|
186
|
+
]));
|
|
187
|
+
};
|
|
188
|
+
const fontReady = () => invalidate(true);
|
|
189
|
+
(_b = (_a = document.fonts) === null || _a === void 0 ? void 0 : _a.addEventListener) === null || _b === void 0 ? void 0 : _b.call(_a, 'loadingdone', fontReady);
|
|
190
|
+
void ((_c = document.fonts) === null || _c === void 0 ? void 0 : _c.ready.then(() => {
|
|
191
|
+
if (!disposed)
|
|
192
|
+
fontReady();
|
|
193
|
+
}).catch(() => { }));
|
|
194
|
+
return {
|
|
195
|
+
enqueue,
|
|
196
|
+
invalidate,
|
|
197
|
+
cancel: () => reset(false),
|
|
198
|
+
destroy() {
|
|
199
|
+
var _a, _b;
|
|
200
|
+
if (disposed)
|
|
201
|
+
return;
|
|
202
|
+
disposed = true;
|
|
203
|
+
reset(true);
|
|
204
|
+
host.remove();
|
|
205
|
+
(_b = (_a = document.fonts) === null || _a === void 0 ? void 0 : _a.removeEventListener) === null || _b === void 0 ? void 0 : _b.call(_a, 'loadingdone', fontReady);
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
};
|
|
@@ -24,9 +24,6 @@ const svgText = (documentRef, value, x, y, options = {}) => {
|
|
|
24
24
|
text.textContent = value;
|
|
25
25
|
return text;
|
|
26
26
|
};
|
|
27
|
-
// The fixed plot coordinate system is letterboxed into the authored chart box.
|
|
28
|
-
// Compensate font units once for that intrinsic scale; sheet zoom is still
|
|
29
|
-
// applied by the containing renderer, so user zoom never gets cancelled out.
|
|
30
27
|
const axisFontSize = (chart, size, fallback) => {
|
|
31
28
|
const scale = Math.min(chart.width / 640, chart.height / 360);
|
|
32
29
|
return size !== undefined && Number.isFinite(size) && size > 0 && Number.isFinite(scale) && scale > 0
|
|
@@ -398,7 +395,6 @@ const polarPoint = (cx, cy, radius, angle) => {
|
|
|
398
395
|
};
|
|
399
396
|
};
|
|
400
397
|
const pieSlicePath = (cx, cy, outerRadius, innerRadius, startAngle, endAngle) => {
|
|
401
|
-
// A single SVG arc with identical endpoints is empty, not a full circle.
|
|
402
398
|
if (endAngle - startAngle >= 360 - 1e-7) {
|
|
403
399
|
const a = polarPoint(cx, cy, outerRadius, startAngle);
|
|
404
400
|
const b = polarPoint(cx, cy, outerRadius, startAngle + 180);
|
|
@@ -453,7 +449,6 @@ const drawLegend = (documentRef, svg, chart) => {
|
|
|
453
449
|
}
|
|
454
450
|
const right = chart.legendPosition === 'right';
|
|
455
451
|
const categorySeries = chart.type === 'pie' || chart.type === 'doughnut' ? chart.series[0] : undefined;
|
|
456
|
-
// Build only visible entries when a pie has a large category cache.
|
|
457
452
|
const entries = chart.type === 'pie' || chart.type === 'doughnut'
|
|
458
453
|
? ((categorySeries === null || categorySeries === void 0 ? void 0 : categorySeries.values) || []).slice(0, MAX_LEGEND_ITEMS).map((_, index) => ({
|
|
459
454
|
...categorySeries,
|
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
export declare const MAX_TRANSFERRED_LINE_CHART_POINTS = 4096;
|
|
2
|
-
/** Keep absent points as explicit separators through both transfer and SVG
|
|
3
|
-
* sampling. Otherwise an omitted gap becomes an invented connecting segment.
|
|
4
|
-
* Reserve at most one separator per retained interval, keeping a strict budget.
|
|
5
|
-
*/
|
|
6
2
|
export declare const extremaPointIndexes: (values: number[], maxPoints: number, spanBlankIndexes?: number[]) => number[];
|
|
@@ -36,10 +36,6 @@ const sampleExtrema = (values, maxPoints) => {
|
|
|
36
36
|
result.push(values.length - 1);
|
|
37
37
|
return Array.from(new Set(result));
|
|
38
38
|
};
|
|
39
|
-
/** Keep absent points as explicit separators through both transfer and SVG
|
|
40
|
-
* sampling. Otherwise an omitted gap becomes an invented connecting segment.
|
|
41
|
-
* Reserve at most one separator per retained interval, keeping a strict budget.
|
|
42
|
-
*/
|
|
43
39
|
export const extremaPointIndexes = (values, maxPoints, spanBlankIndexes = []) => {
|
|
44
40
|
const limit = Math.max(2, Number.isFinite(maxPoints) ? Math.floor(maxPoints) : 2);
|
|
45
41
|
if (values.length <= limit)
|
|
@@ -50,8 +46,6 @@ export const extremaPointIndexes = (values, maxPoints, spanBlankIndexes = []) =>
|
|
|
50
46
|
const spanning = new Set(spanBlankIndexes);
|
|
51
47
|
const hardGap = (index) => !Number.isFinite(values[index]) && !spanning.has(index);
|
|
52
48
|
if (limit === 2) {
|
|
53
|
-
// There is no room for both endpoints and a separator. Prefer dropping one
|
|
54
|
-
// endpoint over inventing a connecting line across an absent interval.
|
|
55
49
|
const gap = values.findIndex((_, index) => hardGap(index));
|
|
56
50
|
return gap > 0 && gap < values.length - 1 ? [0, gap] : [0, values.length - 1];
|
|
57
51
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type FileViewerI18nContext, type FileViewerMessageParams, type FileViewerOptions } from '@file-viewer/core';
|
|
2
|
+
import type { SheetComment, SheetDefinition } from './worker/type.js';
|
|
3
|
+
export type SpreadsheetCommentEntry = SheetComment & {
|
|
4
|
+
sheetId: number;
|
|
5
|
+
sheetName: string;
|
|
6
|
+
key: string;
|
|
7
|
+
};
|
|
8
|
+
interface Options {
|
|
9
|
+
root: HTMLDivElement;
|
|
10
|
+
toolbar: HTMLDivElement;
|
|
11
|
+
body: HTMLDivElement;
|
|
12
|
+
options?: FileViewerOptions;
|
|
13
|
+
i18n?: FileViewerI18nContext;
|
|
14
|
+
navigate: (entry: SpreadsheetCommentEntry) => void;
|
|
15
|
+
getSheetId: () => number;
|
|
16
|
+
}
|
|
17
|
+
declare const commentKeys: {
|
|
18
|
+
title: "spreadsheet.comments.title";
|
|
19
|
+
close: "spreadsheet.comments.close";
|
|
20
|
+
note: "spreadsheet.comments.note";
|
|
21
|
+
thread: "spreadsheet.comments.thread";
|
|
22
|
+
resolved: "spreadsheet.comments.resolved";
|
|
23
|
+
unknown: "spreadsheet.comments.unknown";
|
|
24
|
+
empty: "spreadsheet.comments.empty";
|
|
25
|
+
more: "spreadsheet.comments.more";
|
|
26
|
+
open: "spreadsheet.comments.open";
|
|
27
|
+
jump: "spreadsheet.comments.jump";
|
|
28
|
+
warning: "spreadsheet.comments.warning";
|
|
29
|
+
count: "spreadsheet.comments.count";
|
|
30
|
+
};
|
|
31
|
+
export declare const createSpreadsheetComments: ({ root, toolbar, body, options, i18n, navigate, getSheetId, }: Options) => {
|
|
32
|
+
restoreCellFocus(): void;
|
|
33
|
+
update(nextSheets: SheetDefinition[], error?: boolean): void;
|
|
34
|
+
label: (key: keyof typeof commentKeys, values?: FileViewerMessageParams) => string;
|
|
35
|
+
hide: () => void;
|
|
36
|
+
show(comment: SheetComment, sheet: SheetDefinition, anchor: HTMLElement, focus?: boolean): void;
|
|
37
|
+
destroy(): void;
|
|
38
|
+
};
|
|
39
|
+
export declare const spreadsheetCommentsStyle = "\n.excel-wrapper .excel-comments-panel,.excel-wrapper .excel-comment-popover{--excel-comment-gutter:16px}\n.excel-wrapper .excel-body{display:flex;position:relative;flex:1;min-height:0;min-width:0}\n.excel-wrapper .excel-body .table-wrapper{width:auto;min-width:0;flex:1}\n.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}\n.excel-wrapper .excel-comments-toggle:hover{background:#e8edf2}\n.excel-wrapper .excel-comments-toggle[aria-expanded=true]{background:#e8edf2;color:#1f2937}\n.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}\n.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)}\n.excel-wrapper .excel-comments-title{margin:0;font-size:14px;line-height:20px;font-weight:600}\n.excel-wrapper .excel-comments-list{display:flex;flex-direction:column;gap:8px;overflow:auto;padding:4px 0 16px;min-height:0;scroll-padding:8px}\n.excel-wrapper .excel-comments-sheet-group{display:flex;flex-direction:column;gap:4px;min-width:0}\n.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}\n.excel-wrapper .excel-comments-sheet-entries{display:flex;flex-direction:column;gap:8px;margin:0;padding:0;list-style:none;min-width:0}\n.excel-wrapper .excel-comments-list>p{margin:0;padding:8px var(--excel-comment-gutter)}\n.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}\n.excel-wrapper .excel-comment-card[data-selected=true]{background:#f1f5f9}\n.excel-wrapper .excel-comment-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;min-width:0}\n.excel-wrapper .excel-comment-location{display:flex;flex-wrap:wrap;align-items:baseline;gap:6px;min-width:0;flex:1}\n.excel-wrapper .excel-comment-cell{font-size:14px;font-weight:500;line-height:20px;min-width:0;max-width:100%;overflow-wrap:anywhere}\n.excel-wrapper .excel-comment-kind{font-size:12px;line-height:16px;color:#64748b}\n.excel-wrapper .excel-comment-message{display:flex;flex-direction:column;gap:4px;min-width:0}\n.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}\n.excel-wrapper .excel-comment-metadata strong{min-width:0;max-width:100%;color:#1f2937;font-size:14px;font-weight:500;overflow-wrap:anywhere}\n.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}\n.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}\n.excel-wrapper .excel-comments-close:hover{background:#e8edf2}\n.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}\n.excel-wrapper .excel-comment-jump:hover{text-decoration:underline;text-underline-offset:3px}\n.excel-wrapper .excel-comments-list>.excel-comment-jump{align-self:flex-start;padding:8px var(--excel-comment-gutter);font-size:12px}\n.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}\n.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}\n.excel-wrapper .excel-comment-indicator::after{content:'';position:absolute;right:1px;top:1px;border-top:8px solid #7c3aed;border-left:8px solid transparent}\n.excel-wrapper .excel-comment-indicator[data-kind=note]::after{border-top-color:#dc2626}\n.excel-wrapper .excel-comment-indicator:focus-visible{outline:2px solid #2563eb;outline-offset:-2px}\n.excel-wrapper .excel-comment-indicator[data-resolved=true]::after{border-top-color:#64748b}\n.excel-wrapper .excel-comments-warning{margin:0;padding:8px var(--excel-comment-gutter);color:#92400e;font-size:12px}\n.excel-wrapper[data-spreadsheet-theme=dark] .excel-comments-panel{background:#111827;color:#e5e7eb;border-color:#334155}\n.excel-wrapper[data-spreadsheet-theme=dark] .excel-comment-popover{background:#18212f;color:#e5e7eb;border-color:#475569}\n.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}\n.excel-wrapper[data-spreadsheet-theme=dark] .excel-comment-kind,.excel-wrapper[data-spreadsheet-theme=dark] .excel-comment-metadata{color:#94a3b8}\n.excel-wrapper[data-spreadsheet-theme=dark] .excel-comment-metadata strong{color:#e5e7eb}\n.excel-wrapper button:focus-visible{outline:2px solid #2563eb;outline-offset:2px}\n.excel-wrapper[data-spreadsheet-theme=dark] .excel-comment-jump{color:#86efac}\n.excel-wrapper[data-spreadsheet-theme=dark] .excel-comments-sheet-title{color:#94a3b8}\n.excel-wrapper[data-spreadsheet-theme=dark] button:focus-visible{outline-color:#60a5fa}\n.excel-wrapper[data-spreadsheet-theme=dark] .excel-comments-toggle[aria-expanded=true]{background:#243044;color:#e5e7eb}\n@media(pointer:coarse){.excel-wrapper .excel-comment-jump{min-height:32px}}\n@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}}\n";
|
|
40
|
+
export {};
|