Skip to content

Comments

feat(docx-io): add tracked changes and comments import/export#4836

Draft
arthrod wants to merge 97 commits intoudecode:mainfrom
arthrod:feat/docx-import-export-suggestions-comments
Draft

feat(docx-io): add tracked changes and comments import/export#4836
arthrod wants to merge 97 commits intoudecode:mainfrom
arthrod:feat/docx-import-export-suggestions-comments

Conversation

@arthrod
Copy link
Collaborator

@arthrod arthrod commented Feb 8, 2026

Add full round-trip support for DOCX tracked changes (suggestions) and comments with threading. This enables import/export of Word documents while preserving revision history and comment discussions.

Import pipeline:

  • Custom mammoth.js fork emits [[DOCX_*:...]] tokens for ins/del/comments
  • importTrackChanges.ts parses tokens, applies suggestion marks
  • importComments.ts parses comment tokens, creates discussion structures
  • importDocx.ts orchestrates full pipeline with token cleanup
  • searchRange.ts provides text-based range finding for token placement

Export pipeline:

  • exportTrackChanges.ts injects tracking tokens into serialized HTML
  • exportComments.ts handles comment-specific OOXML generation
  • html-to-docx enhanced with comments.xml, commentsExtended.xml, commentsIds.xml, commentsExtensible.xml, and people.xml generation
  • Proper paraId threading for reply chains

App integration:

  • import-toolbar-button.tsx: full DOCX import with user registration
  • export-toolbar-button.tsx: export with discussions and suggestions
  • suggestion-node-docx.tsx: DOCX-safe suggestion rendering (no ins/del)
  • discussion-kit.tsx: paraId fields for round-trip fidelity
  • docx-export-kit.tsx: SuggestionLeafDocx override for clean export

Key features:

  • Suggestion authorship preserved through round-trip
  • Comment threading via paraId/parentParaId linking
  • UTC date handling for cross-timezone compatibility
  • Overlapping comment ranges supported
  • ImportedUser type for user store registration

Checklist

  • yarn typecheck
  • yarn lint:fix
  • yarn test
  • yarn brl
  • yarn changeset
  • ui changelog

Add full round-trip support for DOCX tracked changes (suggestions) and
comments with threading. This enables import/export of Word documents
while preserving revision history and comment discussions.

Import pipeline:
- Custom mammoth.js fork emits [[DOCX_*:...]] tokens for ins/del/comments
- importTrackChanges.ts parses tokens, applies suggestion marks
- importComments.ts parses comment tokens, creates discussion structures
- importDocx.ts orchestrates full pipeline with token cleanup
- searchRange.ts provides text-based range finding for token placement

Export pipeline:
- exportTrackChanges.ts injects tracking tokens into serialized HTML
- exportComments.ts handles comment-specific OOXML generation
- html-to-docx enhanced with comments.xml, commentsExtended.xml,
  commentsIds.xml, commentsExtensible.xml, and people.xml generation
- Proper paraId threading for reply chains

App integration:
- import-toolbar-button.tsx: full DOCX import with user registration
- export-toolbar-button.tsx: export with discussions and suggestions
- suggestion-node-docx.tsx: DOCX-safe suggestion rendering (no ins/del)
- discussion-kit.tsx: paraId fields for round-trip fidelity
- docx-export-kit.tsx: SuggestionLeafDocx override for clean export

Key features:
- Suggestion authorship preserved through round-trip
- Comment threading via paraId/parentParaId linking
- UTC date handling for cross-timezone compatibility
- Overlapping comment ranges supported
- ImportedUser type for user store registration
@codesandbox
Copy link

codesandbox bot commented Feb 8, 2026

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@changeset-bot
Copy link

changeset-bot bot commented Feb 8, 2026

⚠️ No Changeset found

Latest commit: 79fd49e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Feb 8, 2026
@vercel
Copy link

vercel bot commented Feb 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plate Ignored Ignored Feb 22, 2026 3:42am

Request Review

@dosubot dosubot bot added the plugin:docx label Feb 8, 2026
@arthrod arthrod force-pushed the feat/docx-import-export-suggestions-comments branch 2 times, most recently from 52af579 to 04d04d8 Compare February 14, 2026 20:49
claude and others added 2 commits February 15, 2026 10:17
…oth.js

- Remove redundant biome suppression comment in roundtrip.spec.tsx
- Use literal key instead of computed expression in export-comment-ids.spec.ts
- Exclude vendored mammoth.js directory from biome linting

https://claude.ai/code/session_016HSa8FaK9T51SfKE9TvZX4
fix(docx-io): fix lint errors in test files and exclude vendored mamm…
@arthrod arthrod requested a review from a team February 15, 2026 10:45
claude and others added 19 commits February 15, 2026 12:16
- Fix roundtrip test: replace registry imports with Base* plugins,
  resolve mammoth fixtures from npm package, add render.as config
  for table/link plugins to enable proper HTML serialization
- Fix export-replies test: update date expectations to match
  normalizeDate output format (no milliseconds)
- Fix lists test: unskip and update expected output to match
  BaseListPlugin indent-based flat paragraph behavior
- Fix testDocxImporter: rewrite to use Base* plugins instead of
  React plugin variants that required unavailable packages
- Add missing devDependencies for test plugins
- Fix type error: use any[] for editorPlugins array in tests

All 300 tests pass, 0 failures, 0 skipped.

https://claude.ai/code/session_01Re6XP9ZEbTqXe4ng3mFRr1
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Removed the 'generate_from_rules' setting from skills.
Removed 'mammoth' dependency from package.json.
Removes ~700MB of downloads (puppeteer ~500MB Chromium, playwright ~200MB).
These caused OOM during CI builds. Scripts now print install instructions
instead of failing silently.

https://claude.ai/code/session_01Re6XP9ZEbTqXe4ng3mFRr1
- Fix DocxExportPlugin import in DocxIOPlugin.spec.tsx (not re-exported from DocxIOPlugin)
- Fix SlatePlugin[] type incompatibility in roundtrip.spec.tsx
- Add @playwright/test as devDep to @platejs/playwright (was only peerDep, needed for typecheck after removing from root)
- Fix biome lint error (template literal)

https://claude.ai/code/session_01Re6XP9ZEbTqXe4ng3mFRr1
Skiller moved .claude/rules/ to .claude/skills/ and added SKILL.md
metadata files. Also includes external spec file updates.

https://claude.ai/code/session_01Re6XP9ZEbTqXe4ng3mFRr1
@arthrod
Copy link
Collaborator Author

arthrod commented Feb 18, 2026

@zbeyens @felixfeng33 guys you can check the demo here: https://www-staging-9495.up.railway.app/ (vercel also broke my bank haha)

@arthrod
Copy link
Collaborator Author

arthrod commented Feb 18, 2026

Also, any suggestions on dealing with that template? I found several versions-mismatches there and fixed, but can't find a solution for this component.

arthrod and others added 5 commits February 20, 2026 04:24
Move buildEnvironment and useLegacyStacker to environments.production
per Railway schema (additionalProperties: false at root level).
Decouple buildCommand from nested yarn scripts into explicit steps.
- Import and export are working
- Known issue: import (docx → html/plate) is losing styles somewhere in the code
- Needs investigation to determine where styles are being dropped during conversion

Amp-Thread-ID: https://ampcode.com/threads/T-6fd783d6-8524-4046-aed8-95fbbc1c5f6a
Co-authored-by: Amp <amp@ampcode.com>
@arthrod arthrod closed this Feb 22, 2026
@arthrod arthrod reopened this Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin:docx size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants