将修订记录导出为 DOCX
修订记录附加组件
Tracked Changes is a paid add-on that isn't included in any plan. Test it during the free trial or purchase it in your dashboard. Once integrated in your editor, it works with Conversion to round-trip reviews between Word and Tiptap.
Text carrying a tracked changes suggestion is exported as a real Word revision, so it appears in Word's review pane and can be accepted or rejected there.
工作原理
Nothing to configure. If the content you export has suggestions on it, they become revisions:
editor.chain().exportDocx().run()| Mark type | Becomes |
|---|---|
add | A Word insertion |
delete | A Word deletion |
replaceInsertion | The insertion half of an edit |
replaceDeletion | The deletion half of an edit |
These are the values on the suggestion mark itself. The tracked changes query API reports the last two together as a single replace suggestion, so you see replace there and the two halves here.
A replacement is written as a deletion immediately followed by an insertion, which is how Word represents text being swapped for other text. Imported documents only ever carry add and delete, so the two halves come from edits made in the editor.
整个块
A suggestion that covers a whole node, the shape Compare produces for an added or removed paragraph and the editor produces for an inserted image, is exported the way Word tracks it. The content inside the node becomes revisions, and the node itself is marked as inserted or deleted, so accepting or rejecting in Word removes or restores the whole thing without leaving an empty line behind.
This covers paragraphs, headings, blockquotes, lists and list items, task items, table rows and cells, images and horizontal rules. A suggestion on a container such as a list or a table cell reaches everything inside it.
A suggestion on a link keeps both the link and the revision, matching how Word writes a tracked link.
作者和日期
Each revision carries the reviewer's name and a timestamp, taken from the suggestion:
- The name comes from
userMetadata.name. Without one it falls back touserId, and failing that toanonymous. - The date comes from
createdAt. A suggestion with no usable timestamp gets a fixed placeholder date, because Word rejects a revision with an empty one.
Opening the file in Word shows these in the review pane, grouped by reviewer, exactly as if the edits had been made in Word.
尚未导出的内容(开发中)
In each of these the content itself is exported, so the document reads correctly in Word. What is missing is the record that a particular thing was a tracked change.
- Formatting suggestions. A suggestion recording that text was made bold is not written as a Word formatting revision. The formatting is exported, so the text looks right, but it does not appear as a tracked change.
- The checkbox of a task item. The text of a tracked task item is exported as a revision, the checkbox is not, because Word does not allow a checkbox control inside a revision. Accepting the deletion in Word leaves the empty box behind.
- One stacking order of overlapping suggestions. Where a deletion and an insertion sit on the same text, one reviewer deleting what another inserted is written with both revisions nested, so Word shows both authors. The opposite stacking order is written as the deletion alone.
往返转换
A document imported from Word with trackedChanges: 'preserve' and exported again keeps its revisions, along with each reviewer's name and date.
One detail changes shape. Word writes one revision record per run of text, and the export does the same, so a single suggestion that spans differently formatted text is written as several adjacent revisions rather than one. Word groups them back together in its review pane, so a reader sees the same set of changes.
Accepting in Word matches accepting in Tiptap
Accepting every change in Word produces the same text as importing the same file with
trackedChanges: 'accept', and rejecting everything matches trackedChanges: 'reject'. The
exceptions are the cases in what is not exported, where
the revision is not written and so cannot be accepted or rejected.