feat(preview): render XLSX spreadsheets in the file-preview overlay

xlsx files were download-only. Add a read-only, virtualized preview (sheet
tabs, number formats, merges, theme colours) parsed entirely in a browser
Web Worker with exceljs and fflate, loaded only when a spreadsheet is
opened. The workbook is checked against ZIP-bomb, entry and cell limits
before exceljs loads; cell text is written with textContent, formulas are
never evaluated and nothing referenced by the workbook is fetched. On the
server xlsx only joins the existing allowlist and classification, with a
10 MB cap on ?preview=true. xls and ods stay download-only.
This commit is contained in:
Aamer Akhter committed 2026-09-26 23:13:21 -04:00
1 parent 45ea2e1d32
commit 0b122e2c76
27 files changed
+3765 -13

No files matched your search

+3
View File
@@ -62,6 +62,8 @@ const SUPPORTED_ATTACHMENT_EXTENSIONS = new Set([
'pdf',
'docx',
'pptx',
// Previewed client-side (spreadsheet-preview-worker.js); served raw like the rest.
'xlsx',
'md',
'txt',
...VIDEO_ATTACHMENT_EXTENSIONS,
@@ -154,6 +156,7 @@ export function getAttachmentType(extension: string): AttachmentDetectedType {
if (AUDIO_ATTACHMENT_EXTENSIONS.has(normalized)) return 'audio';
if (normalized === 'pdf') return 'pdf';
if (normalized === 'pptx') return 'presentation';
if (normalized === 'xlsx') return 'spreadsheet';
if (normalized === 'md') return 'markdown';
// Everything else in the text family reads as text, including code and
// config: the card and the preview both treat it as a plain-text file.