Repository navigation
Warn on tracked changes in DOCX import and clamp table spans in export #677
Description
Goal
A DOCX import must tell the reader when it accepted tracked changes. One stored table span must not be able to exhaust the rest-api process during an export.
#662 led to this work. The commit is 508c9d607 on local main. It is not pushed yet, so the hash does not resolve on GitHub.
Facts
Tested through the real importDocx, exportDocx and renderDocumentHtml, on hand-built DOCX files. Not tested on a file authored in Word.
- mammoth 1.13.0 keeps tracked insertions as plain text and drops tracked deletions. It reports neither, so the warning list stayed the same as for a clean file.
encodeContentvalidates content expressions, not attribute values, so a storedcolspanis unbounded. A DOCXgridSpanreached the import result unchanged.- The renderer writes one
<col>per span. Before the fix, acolspanof 100,000 added 398 MB of RSS in one DOCX export, against the 512Mrest-apilimit. After the fix, it adds 2 MB. rowspanof 100,000 cost nothing measurable in a DOCX export, so it stays unclamped outside ODT. A low cap would break real long tables.
What changed
All code paths are under apps/hocuspocus.server/src/modules/document-conversion/.
domain/docxImport.tsscansword/*.xmlwith JSZip, the reader mammoth uses. On a hit,tracked-changes-acceptedgoes first inwarnings, because the panel lists only the first few.domain/portableJson.tsclampscolspantoMAX_TABLE_SPAN(64) for every writer.importDocxclamps it too, so an import cannot carry the value into a document.domain/mapNodes.tsnow walks a swapped node's children. Without this, an embed inside a clamped cell reaches the writer unconverted.jszip3.10.2is now a direct dependency of@docs.plus/hocuspocus. It is the version already in the tree.API.md, the OpenAPI enum andapps/hocuspocus.server/CLAUDE.mdare updated.
Decision
Accepting tracked changes with a warning is a deliberate exception to the Google Docs, Word and Notion rule. Maintainer ruling, 2026-11-02, recorded in AGENTS.md. Google Docs keeps them as suggestions, and Notion drops them and says so. docs.plus has no suggestion mode, and this issue does not build one.
Verification
- 76 tests pass across conversion, OpenAPI and MCP. 11 are new, in
docxImport.test.tsandportableJson.test.ts. - Each of 5 deliberate breaks of the fix made a test fail.
- Typecheck and format are clean. ESLint has no findings in the source files.
- A cold install passed: 1,709 packages, no integrity errors.
Still open
- Push and deploy with
back. - Check the warning in the import panel in a browser. Not done yet.
- Check a real file authored in Word.
Out of scope, and not fixed here:
- Comments, headers, charts and diagrams still drop with no warning.
API.mdsays so. The panel line "You'll see what changes" still promises too much. - A large
colspanalready stored, or set through Yjs, still reaches the table view in each browser. That effect is not verified. - The zip guard work stays in #577.
Activity