mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-10 01:09:43 +02:00
fix(preview): address review of the XLSX preview
- Normalize the value shapes ExcelJS loads before formatting: Date cells are formatted from their serial (UTC), so they no longer render as a local-time string a day early at negative UTC offsets; rich text joins its runs, hyperlinks show their text, error values show the error, and formula and shared-formula results (including error results) recurse. Excel serials are rounded to whole milliseconds so 00:05 no longer shows as 00:04. - sendTile() skips hidden rows and columns, and at the 2500-cell cap returns a truncated tile with a warning instead of failing the whole preview. - ExcelJS now parses a STORE-only archive rebuilt from exactly the entries admitXlsx() inflated and counted, never the fetched bytes. Admission walks local headers while JSZip reads the central directory, so overlapping entries could show the two readers different sheets. A duplicate local entry name is refused. The theme fallback reads the admitted entry too. - Row and column headings take their size from the same axis math as cells. - Document the admission, worker-only loading and SPREADSHEET_ASSET_VERSION rules in architecture-invariants, and list .xlsx in the attachments panel help and the `codeman attach` error text (built from the accepted list).
This commit is contained in:
@@ -15,6 +15,8 @@ async function workbookBytes(): Promise<Buffer> {
|
||||
const summary = workbook.addWorksheet('Summary');
|
||||
summary.getCell('A1').value = 'Local workbook';
|
||||
summary.getCell('B2').value = 42;
|
||||
summary.getColumn(2).width = 18;
|
||||
summary.getRow(2).height = 30;
|
||||
summary.mergeCells('A3:C3');
|
||||
summary.getCell('A3').value = 'Merged cells';
|
||||
summary.getCell('A100').value = 'Far row';
|
||||
@@ -92,6 +94,24 @@ describe('spreadsheet preview browser boundary', () => {
|
||||
});
|
||||
expect(initialGeometry.left).toBeGreaterThanOrEqual(36);
|
||||
expect(initialGeometry.top).toBeGreaterThanOrEqual(20);
|
||||
// Headings line up with a custom-width column and a custom-height row.
|
||||
const headingFit = await page.locator('.spreadsheet-grid').evaluate((grid) => {
|
||||
const rect = (selector: string, text: string) => {
|
||||
const element = [...grid.querySelectorAll(selector)].find((node) => node.textContent === text);
|
||||
if (!element) throw new Error(`Missing ${selector} ${text}`);
|
||||
return element.getBoundingClientRect();
|
||||
};
|
||||
const cell = rect('.spreadsheet-cell', '42');
|
||||
const column = rect('.spreadsheet-column-heading', 'B');
|
||||
const row = rect('.spreadsheet-row-heading', '2');
|
||||
return {
|
||||
cell: [cell.left, cell.width, cell.top, cell.height],
|
||||
heading: [column.left, column.width, row.top, row.height],
|
||||
};
|
||||
});
|
||||
expect(headingFit.cell[1]).toBe(126);
|
||||
expect(headingFit.cell[3]).toBe(40);
|
||||
expect(headingFit.heading).toEqual(headingFit.cell);
|
||||
await page.locator('.spreadsheet-grid').evaluate((grid) => {
|
||||
grid.scrollTop = 400;
|
||||
grid.scrollLeft = 400;
|
||||
|
||||
Reference in New Issue
Block a user