fix: real footnote numbering and labels in the DOCX viewer

↗ view on GitHub · Eli Ziff · 2026-07-27 · c366efad

Three rendering defects, all in how docx-preview's per-page model was
surfaced: fabricated 'Page N' badges from DOM index (duplicating the
document's own rendered footer), footnote references restarting at 1 on
every page, and w:footnoteRef markers dropped entirely so note bodies
had no labels. Plus a fourth found during verification: notes opened by
w:customMarkFollows symbols (*, **) were force-numbered, shifting every
real number by one.

New docxNotes.ts tags references and note bodies in the parsed model,
then numbers/links them continuously in the DOM with bidirectional
anchors, honouring custom marks and de-duplicating notes repeated
across pages. DocxView drops decorateDocxPages, trims render options
to non-defaults, and caches parseAsync per ArrayBuffer so remounts do
not re-inflate the zip. Verified against two real documents (239-note
and 13-note) matching their XML exactly; 117 frontend tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUsMXzBsEJ27DjJVPSfW5o
Repository eliziff/Beaver
Author Eli Ziff <eliasziff@gmail.com>
Authored
Parents 557f6088
Stats 6 files changed , +621 , -119
Part of SourceDoc / DOCX engine: redlines, tracked changes, editing benchmark

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-c366efad.md from inside the repo you want the change in.

⬇ Download capture-commit-c366efad.md