Repository navigation
FE-376: Add a DOCX preview to the entity editor - #9995
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Merging this PR will not alter performance
|
820ac5e to
3629eb7
Compare
3629eb7 to
5442758
Compare
FE-47 moves HASH to the ProseMirror versions folio uses, so each ProseMirror package installs once and folio's imports no longer need redirecting to folio-core's copies. `next.config.js` is back to its state before this branch.
folio-core 0.60.0 expects the host to install ProseMirror, yjs, `y-prosemirror` and `y-protocols`. The frontend now lists the ones it lacked, and raises `prosemirror-commands`, `-inputrules`, `-keymap` and `-dropcursor` to folio's ranges, so each installs once. folio-react 0.28.0, folio-core 0.60.0 and docx-core 0.37.0 are younger than the 7-day age gate, so `npmPreapprovedPackages` admits exactly these versions.
Editing an entity's "File URL" property changes the URL of the mounted PDF or DOCX preview, and the preview kept the old file's page, zoom and search state. The PDF preview then drew the new file at the old zoom and asked for a page it does not have. Keying both previews by the file URL mounts a fresh preview for each file. The file-preview spec gains a test per preview that edits the File URL to a second file and checks its page, zoom and search state.
`file-preview.spec.ts` becomes `file-preview/pdf.spec.ts` and `file-preview/docx.spec.ts`. Their helpers, test document and generators move to `shared/file-preview/`. The File URL tests now check only that the new file shows after an edit made on a later page, the case where the PDF preview showed no page at all. Both formats share one test body, and `editFileUrl` focuses the value cell through the grid's accessibility table instead of clicking a pixel offset and walking rows with the arrow keys.
…w tests Focusing the cell while the grid has no selection let the canvas's focus handler move the selection back to the first cell, so Enter opened no editor and both File URL tests timed out.
`generatePdf` and `generateDocx` take the pages to render, and the specs pass `testDocumentPages` themselves. The `generateTestPdf` and `generateTestDocx` shorthands, whose pages defaulted to the test document, are gone, and `FileFormat.generate` points at the generators directly.
…ersions folio asks for newer versions of these four as peers, but the read-only preview runs on the versions HASH's editors already use. Keeping them leaves the supply-chain status editor on the versions it was tested with and stops this branch changing `hash-isomorphic-utils`. Yarn now warns about the four unmet peers.
folio's dependencies ask for `@babel/runtime@^7.29.7` and `reselect@^5.2.0`, which the locked 7.29.7 and 5.2.0 already satisfy, so the lockfile resolves them there instead of moving HASH to 7.29.10 and 5.3.0.
The test clicked the centre of the page, which is blank, so it could not catch a link that runs script. It now clicks each link's text, waits for a popup, and counts requests from every tab.
The page polling now goes through useEffectEvent instead of useCallback, so the hooks need no manual memoization.
folio's ctrl+wheel zoom changes the zoom without telling HASH, so the zoom label went stale. With it off, ctrl+wheel zooms the browser, as in the PDF preview.
Zooming out had no floor, so the fifth click took the pages to 0%. The bounds are folio's own.
getFolioMessages bundles all 17 locales. Importing the English catalog alone takes about 83 KB gzip off the DOCX preview chunk.
Nothing depends on the search function's identity, so it needs no useCallback with React Compiler on.
handleError becomes a plain function, so the download effect only depends on the URL and needs no useCallback with React Compiler on.
The DOCX download effect no longer depends on it, so it needs no useCallback with React Compiler on.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2a35212. Configure here.

🌟 Purpose
The entity editor's File Preview now shows
.docxfiles as pages instead of a file icon, with rough parity to the PDF preview. The file is drawn in the browser, so it never leaves HASH. Closes FE-376 (internal).Same as the PDF preview: paging with a page counter, zoom, full screen, search with a case toggle and next / previous, select and copy, read-only, Download, and a fresh state when the File URL changes.
Different for DOCX:
🔍 Approach
@stll/folio-react(folio) is used read-only and imported only indocx-preview/folio-document.tsx. The rest of the preview uses itsDocxDocumentControls.FilePreviewSearchand fetch the file withfetchPresignedFileUrl. The PDF preview behaves as before.javascript:anddata:links do nothing, and nothing is requested from outside HASH.Why folio: of three browser DOCX libraries that passed fixed criteria (in-browser, licence, size, speed, no outbound requests), folio lets readers select and copy text, which eigenpal docx-editor's view mode blocks, and stays usable with the JavaScript JIT blocked (first page up to 2.6 s, against about 1.2 s in Chrome).
@silurus/ooxmlscored lower on fidelity and backing.Dependencies:
prosemirror-commands,-inputrules,-keymapand-dropcursor, which the read-only preview works with.@stll/folio-react0.28.0,@stll/folio-core0.60.0 and@stll/docx-core0.37.0 are younger than the 7-daynpmMinimalAgeGate, so.yarnrc.ymlpre-approves exactly these versions. They carry npm provenance from verified, tagged commits and add no install scripts, network calls or known advisories..d.tsshims expose folio'smessages/enandai-editssubpaths to the frontend'smoduleResolution: "node".🛡 Tests
file-preview/docx.spec.tshas one test per behaviour: paging, zoom and its limits, the page counter, search, read-only, copy, a hostile document, File URL edits,.docfiles and unreadable.docxfiles. The PDF tests from #9972 move tofile-preview/pdf.spec.ts. Test documents are generated in code, so the PR adds no binary file..docfiles keep the icon view.🐾 Follow-ups
Already on
mainin the PDF preview, so left out here:🚫 Blocked by