Skip to content

Preview PDF, DOCX, XLSX & PPTX files in the browser#14

Merged
exilis merged 20 commits into
masterfrom
feat/office-pdf-viewing
Jun 25, 2026
Merged

Preview PDF, DOCX, XLSX & PPTX files in the browser#14
exilis merged 20 commits into
masterfrom
feat/office-pdf-viewing

Conversation

@exilis

@exilis exilis commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

Adds client-side preview of four binary document formats — PDF, DOCX, XLSX, and PPTX — alongside the existing markdown/mermaid/allium support. Consistent with reefdoc's "thin server, client renders everything" architecture:

  • Server (Go): the tree now lists .pdf/.docx/.xlsx/.pptx (new isViewable), and /api/file sets the correct Content-Type per extension so binary bytes aren't corrupted. Path-safety is untouched.
  • Frontend: a new web/viewers.js registry maps each extension to an async viewer (PDF.js → canvas, docx-preview, SheetJS, pptx-preview), each lazy-loaded from CDN on first use, so the markdown-only path pays nothing.
  • Integration: one branch in show() — text files take the existing path; binary files read an ArrayBuffer (no size cap), clear the Outline, and render a static preview.

Per the design, binary documents are static previews: no TOC, no live-reload, no favorites star, no scroll-restore. Best-effort error handling.

Design: docs/specs/2026-06-25-office-pdf-viewing-design.md
Plan: docs/plans/2026-06-25-office-pdf-viewing.md

Notable detail

pptx-preview is loaded from esm.sh rather than jsdelivr — jsdelivr's +esm build of the library has a broken lodash transitive import (does not provide an export named 'get') that fails to load in the browser. esm.sh resolves it correctly with the same init named export.

Test Plan

  • go test ./... — green (new tree + Content-Type/byte-integrity tests)
  • npm test — 57 pass (new viewers.js registry tests)
  • gofmt / go vet clean
  • Browser e2e (Playwright): PDF renders to canvas; DOCX/XLSX/PPTX render real content; markdown unaffected; binary rows have no favorite star; Outline cleared on binary tabs; no console errors (besides pre-existing favicon 404)

@exilis exilis merged commit 5c3d6b9 into master Jun 25, 2026
2 checks passed
@exilis exilis deleted the feat/office-pdf-viewing branch July 4, 2026 12:40
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