Repository navigation
feat(app): preview Word, Excel and PowerPoint files - #53305
Merged
Merged
Conversation
Hona
force-pushed
the
office-preview
branch
2 times, most recently
from
October 6, 2026 08:38
fa4b945 to
ea1887e
Compare
Render .docx, .xlsx and .pptx read-only in the file viewer with the BetterOffice engines (Apache-2.0). Each format loads its own engine only when a file of that format opens; Word uses the Yrs engine alone, and only the five metric-compatible font families ship. Nothing leaves the machine. Add third-party notices to the About page.
Each open Word, Excel or PowerPoint file gets its own module worker that owns the engine and paints into an OffscreenCanvas, so no layout, recalculation or painting runs on the main thread, and closing a file frees its engine memory. Adds the Word text layer and links, Excel headers, selection, copy and links, per-deck PowerPoint fonts, speaker notes and hidden slides, file checks before any engine loads, and notices for the bundled fonts and Rust crates.
Moves the file bytes to each worker instead of copying them, skips media when PowerPoint inspects its text, caps decoded slide pictures, mounts and observes pages incrementally with cancellable paints, halves Excel frame requests while scrolling, and drops Office engine files the build emits but nothing loads.
Upgrades @betteroffice/docx to 0.4.3 and releases built pages more than 10 pages from the one being painted, so scrolling a long document no longer grows the Word worker's memory with every page. A 594-page document now stays under 1 GB of wasm instead of reaching the 4 GB limit.
The 17 font families shipped with the Office previews share the SIL Open Font License 1.1, so the notices list each family with its own copyright lines and the license text once, instead of 17 entries.
- worker-rpc: an aborted handler closes its bitmaps instead of replying, and a reply that crosses its cancel closes the bitmaps it carries. Word paints check their signal. - slide-text: bound central directory records and local offsets, so a malformed .pptx stays as it is. - Spreadsheet: only the newest sheet pick updates the view, and going back to the shown sheet withdraws a pending pick. External links allow only http, https and mailto, through one helper shared with Word. - Artifact viewer: check a viewer's problem only on freshly decoded bytes, and fail the file from the error boundary. - Word: queue the full layout after the first paints, keep page rows stable so a changed page repaints over its old bitmap, and listen for messageerror. - PowerPoint: keep the finer SVG raster, drop rasters for a withdrawn paint, and read each picture's blob once. - Unit tests for links, withoutMedia, sheet-cells and worker-rpc.
…views The font package maps East Asian families such as Microsoft YaHei, DengXian and Yu Gothic Medium to its CJK add-on, which the app does not ship. A deck that named only such families registered no font, so every slide failed to lay out, and Word laid out weight variants such as Microsoft YaHei Light as one unwrapped line in a browser font. Every lookup now returns a face the app ships, and a weight variant falls back by its base name, so a serif family stays serif. Also rename the base64 test, which runs the native codecs, so it no longer claims to cover the fallback.
Hona
enabled auto-merge (squash)
October 7, 2026 00:16
|
This is super cool! When will this ship to v2? |
Member
Author
|
about to release v2 in the next hour or 2 |
2 of 6 tasks
3 of 6 tasks
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.
Read-only previews for
.docx,.xlsxand.pptxin the file view. They are a new built-in GUI extension,microsoft-office, on BetterOffice (Apache-2.0), whose Rust engines are compiled to WASM.flowchart LR F[file view<br/>artifact-view.tsx] -->|kind not built in| R{{file.viewer registry}} R -->|"problem(bytes)?"| B[binary placeholder + reason] R --> V[microsoft-office viewer<br/>lazy chunk per kind] V <-->|worker-rpc: keyed calls,<br/>transferred bytes / ImageBitmaps| W[module worker per open file<br/>engine wasm + OffscreenCanvas] V --> D[DOM: text layer, headers,<br/>selection, notes, a11y]Registry
file/contract.tsaddsfile.viewer, so any extension can render file kinds the file view does not render itself. The file view handles the rest:problem()rejects show the binary placeholder with the reason.Viewers
aria-activedescendant.Performance
Workers:
worker-rpc.tsfollows the markdown worker's model:OffscreenCanvasand sendImageBitmaps back, which the main thread shows withbitmaprenderer.Main thread, before workers → after:
Other numbers:
releaseDisplayPagesFrame, docx 0.4.3). Scrolling through 149 pages peaks at 369 MB of WASM instead of 1,135 MB. Through 594 pages it peaks at 946 MB, where it used to reach the 4 GB WASM limit and crash the engine.Uint8Array.fromBase64/toBase64, with a fallback for older browsers. A 25 MiB file takes 30 ms instead of 3.7 s.Bundle
docx_edit19.7 MB,xlsx5.2 MB,pptx5.4 MB. A smallgenerateBundleplugin drops the Office files that nothing references (layout and opc WASM, the resident worker: 4.7 MB).opencode servecan come later.Licensing
About → Third-party notices opens a lazily loaded dialog with:
Known limits
TODAY()/NOW(): they use UTC..doc,.xls,.pptand encrypted files show the binary placeholder with a reason.@internal.