theseus/addon-build/docx-editor
Local Dev 92ef408ac5 feat(docx-editor): edit Word documents without quietly eating what Word put in them
A .docx editor is easy to write badly: read the file into HTML, let someone
edit it, write a fresh document back, and hand them a file that lost its
headers, its page size and half its formatting without ever saying so.

Three things keep this one honest.

The reader doesn't use mammoth's HTML. mammoth's converter is deliberately
semantic, and HTML has nowhere to put a run's colour or a paragraph's line
spacing, so it drops them — and those are controls this editor puts in the
ribbon. Taking its parsed document model instead means what the ribbon offers
is what the file can actually carry. Six properties mammoth's model didn't
keep are added by build-time patches, each asserting its anchor so an upgrade
that moves the code fails the build rather than shipping a lossy reader.

The writer rebuilds the body but carries the rest of the package across:
headers, footers, footnotes, endnotes, the document's own style catalogue,
its theme and its page setup, with relationship ids and content types
re-wired. Word features the editor can't model are still lost, so they are
detected when the file opens and named in a banner before anyone edits.

Tracked changes get their own gate. mammoth renders insertions as ordinary
text and drops deletions, so saving would accept every pending revision
without Word ever asking. Such a document opens read-only until the user
says that is what they want.

Verified over 66 real documents: 65 round-trip with an identical model and a
structurally valid package, the one exception being a 7 MB WMF picture, which
no browser can display and the writer cannot emit. Also driven end to end
through a real Theseus over CDP — sidebar, ribbon, typing, save, reopen.
2026-09-20 20:46:29 +02:00
..
test feat(docx-editor): edit Word documents without quietly eating what Word put in them 2026-09-20 20:46:29 +02:00
.gitignore feat(docx-editor): edit Word documents without quietly eating what Word put in them 2026-09-20 20:46:29 +02:00
build.mjs feat(docx-editor): edit Word documents without quietly eating what Word put in them 2026-09-20 20:46:29 +02:00
package-lock.json feat(docx-editor): edit Word documents without quietly eating what Word put in them 2026-09-20 20:46:29 +02:00
package.json feat(docx-editor): edit Word documents without quietly eating what Word put in them 2026-09-20 20:46:29 +02:00
patches.mjs feat(docx-editor): edit Word documents without quietly eating what Word put in them 2026-09-20 20:46:29 +02:00
vendor-entry.js feat(docx-editor): edit Word documents without quietly eating what Word put in them 2026-09-20 20:46:29 +02:00