Preview PDF, DOCX, XLSX & PPTX files in the browser#14
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
.pdf/.docx/.xlsx/.pptx(newisViewable), and/api/filesets the correctContent-Typeper extension so binary bytes aren't corrupted. Path-safety is untouched.web/viewers.jsregistry 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.show()— text files take the existing path; binary files read anArrayBuffer(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.mdPlan:
docs/plans/2026-06-25-office-pdf-viewing.mdNotable detail
pptx-previewis loaded from esm.sh rather than jsdelivr — jsdelivr's+esmbuild 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 sameinitnamed export.Test Plan
go test ./...— green (new tree + Content-Type/byte-integrity tests)npm test— 57 pass (newviewers.jsregistry tests)gofmt/go vetclean