Skip to content

Document viewers: PDF, Word, Excel, Markdown, CSV, code and logs - #174

Merged
mateof merged 1 commit into
developfrom
feat/document-viewers
Dec 4, 2026
Merged

mateof merged 1 commit into
developfrom
feat/document-viewers

Conversation

@mateof

@mateof mateof commented Dec 4, 2026

Copy link
Copy Markdown
Owner

The viewer of the web app (and installed PWA) now previews documents instead of offering a download. Old binary Office formats (.doc, .xls, .ppt) are intentionally not supported.

Format Viewer
PDF pdf.js: selectable text, search with match count, zoom, fit to width, page jump. Replaces the <iframe>, which does not work inside a page on Android or iOS.
Word (.docx) docx-preview, pages scaled down to fit narrow screens
Excel (.xlsx) read-excel-file: one tab per sheet, values only, virtualized table
Markdown react-markdown + GFM (tables, task lists), fenced code highlighted, "Source" toggle
CSV / TSV Table (delimiter detected, ; included) with a "Source" toggle
Code and config highlight.js (only the ~25 languages we map)
Text, logs, subtitles Plain, with line wrapping toggle

Big text files and logs. Text is read in 2 MB windows (8 MB for CSV) with Range requests. Bigger files show their start or end and can switch between both. .log files open at their end, scrolled to the last line. Encoding: UTF-16 with BOM, UTF-8, else Windows-1252. A window cut inside a UTF-8 character is trimmed instead of falling back.

Safety.

  • Markdown raw HTML is not rendered (no rehype-raw); react-markdown drops javascript: URLs.
  • Word: embedded HTML parts (altChunks) are not rendered, and only http(s), mailto and # links are kept.
  • pdf.js runs without the scripting manager.
  • Word and Excel files above 30 MB are offered as a download.

Bundle. Every viewer is its own lazy chunk (opening a .txt does not load pdf.js). The heavy ones are excluded from the PWA precache: they are useless offline, where documents cannot be read. Precache stays at 2.05 MB (was 2.00), initial JS 242.9 KB gzip of 250 KB. The "CSS" figure of check-chunks.mjs grew because it sums every .css in the output, including the lazy pdf.js stylesheet; index.html still links only the main CSS.

Also.

  • The viewer is always dark, so the document panels use fixed colours. The old text view used the theme's neutral scale, which is reversed in the light theme.
  • Chat attachments that are documents (docx, xlsx, md, log...) open in the viewer too.

New dependencies (all MIT or Apache-2.0, npm audit clean): pdfjs-dist, docx-preview, read-excel-file, react-markdown, remark-gfm, highlight.js, papaparse.

Checks.

  • Typecheck, lint (0 errors) and 369 web tests (45 new) pass.
  • Build passes.
  • PDF, Word, Excel, Markdown, CSV, JSON and a 5.8 MB log were also checked in headless Chrome with generated sample files, at desktop and phone sizes.

@mateof
mateof merged commit 0d9500a into develop Dec 4, 2026
2 checks passed
@mateof
mateof deleted the feat/document-viewers branch December 4, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant