Commands

Paid add-on

All editor commands provided by the Tracked Changes extension.

enableTrackedChanges()

Enable track changes mode. All subsequent edits will become suggestions.

editor.commands.enableTrackedChanges()

disableTrackedChanges()

Disable track changes mode. Edits will be applied directly to the document.

editor.commands.disableTrackedChanges()

toggleTrackedChanges()

Toggle track changes mode on or off.

editor.commands.toggleTrackedChanges()

setTrackedChangesUser()

Change the current user for new suggestions.

ArgumentTypeDescription
userIdstringThe new user ID
userMetadataRecord<string, unknown> | nullOptional arbitrary metadata about the user
editor.commands.setTrackedChangesUser({
  userId: 'user-789',
  userMetadata: { name: 'Alice Johnson' },
})

acceptSuggestion()

Accept a suggestion, applying the proposed change. For insertions, the suggestion mark is removed and text is kept. For deletions, the marked text is removed. For replacements, the old text is removed and the new text is kept.

ArgumentTypeDescription
idstringOptional suggestion ID. If omitted, uses the suggestion at the current selection.
// Accept suggestion at selection
editor.commands.acceptSuggestion()

// Accept specific suggestion
editor.commands.acceptSuggestion({ id: 'suggestion-123' })

rejectSuggestion()

Reject a suggestion, reverting the proposed change. For insertions, the marked text is removed. For deletions, the suggestion mark is removed and text is kept. For replacements, the new text is removed and the old text is kept.

ArgumentTypeDescription
idstringOptional suggestion ID. If omitted, uses the suggestion at the current selection.
// Reject suggestion at selection
editor.commands.rejectSuggestion()

// Reject specific suggestion
editor.commands.rejectSuggestion({ id: 'suggestion-123' })

acceptAllSuggestions()

Accept all suggestions in the document.

editor.commands.acceptAllSuggestions()

rejectAllSuggestions()

Reject all suggestions in the document.

editor.commands.rejectAllSuggestions()

acceptSuggestionsInRange()

Accept all suggestions within a specific document position range.

ArgumentTypeDescription
fromnumberStart position of the range
tonumberEnd position of the range
editor.commands.acceptSuggestionsInRange({ from: 0, to: 100 })

rejectSuggestionsInRange()

Reject all suggestions within a specific document position range.

ArgumentTypeDescription
fromnumberStart position of the range
tonumberEnd position of the range
editor.commands.rejectSuggestionsInRange({ from: 0, to: 100 })

acceptSuggestionsByUser()

Accept all suggestions created by a specific user.

ArgumentTypeDescription
userIdstringThe user ID whose suggestions to accept
editor.commands.acceptSuggestionsByUser({ userId: 'user-123' })

rejectSuggestionsByUser()

Reject all suggestions created by a specific user.

ArgumentTypeDescription
userIdstringThe user ID whose suggestions to reject
editor.commands.rejectSuggestionsByUser({ userId: 'user-123' })

addTrackedInsertion()

Insert content as a tracked suggestion without enabling tracked changes mode for the whole editor. This is useful when you need to create suggestions programmatically and want the result to match a normal tracked typing transaction. The content argument accepts any Tiptap Content value, including text, HTML, or JSON node content such as an image node. When skipTrailingNode is true, the emitted transaction also sets skipTrailingNode: true, which is useful with the TrailingNode extension.

ArgumentTypeDescription
fromnumberDocument position where the tracked insertion should be added
contentContentThe content to insert as a suggestion
reasonstringOptional description included in the trackedChanges:suggestionCreated event payload
skipTrailingNodebooleanOptional flag that sets skipTrailingNode: true on the emitted tracked transaction
editor.commands.addTrackedInsertion({
  from: 7,
  content: 'big ',
  reason: 'Applied AI rewrite',
  skipTrailingNode: true,
})
editor.commands.addTrackedInsertion({
  from: 7,
  content: {
    type: 'image',
    attrs: {
      src: '/example.png',
      alt: 'Example image',
    },
  },
  reason: 'Inserted approved image asset',
})

addTrackedDeletion()

Convert an existing document range into a tracked deletion suggestion. This mirrors what happens when a user deletes content while tracked changes mode is enabled.

ArgumentTypeDescription
fromnumberStart position of the range to mark as deleted
tonumberEnd position of the range to mark as deleted
reasonstringOptional description included in the trackedChanges:suggestionCreated event payload
editor.commands.addTrackedDeletion({
  from: 7,
  to: 12,
  reason: 'Removed outdated wording',
})

addTrackedReplacement()

Replace an existing range with a tracked replacement suggestion. The replaced content becomes the deletion part of the suggestion, and the new content becomes the insertion part. The content argument accepts any Tiptap Content value, so you can replace text with a different node by passing JSON content. When skipTrailingNode is true, the emitted transaction also sets skipTrailingNode: true, which is useful with the TrailingNode extension.

ArgumentTypeDescription
fromnumberStart position of the range to replace
tonumberEnd position of the range to replace
contentContentReplacement content to insert as a tracked suggestion
reasonstringOptional description included in the trackedChanges:suggestionCreated event payload
skipTrailingNodebooleanOptional flag that sets skipTrailingNode: true on the emitted tracked transaction
editor.commands.addTrackedReplacement({
  from: 7,
  to: 12,
  content: 'earth',
  reason: 'Replaced with approved terminology',
  skipTrailingNode: true,
})
editor.commands.addTrackedReplacement({
  from: 7,
  to: 8,
  content: {
    type: 'image',
    attrs: {
      src: '/updated-diagram.png',
      alt: 'Updated diagram',
    },
  },
  reason: 'Replaced placeholder with final diagram',
})

addTrackedMark()

Apply a mark to an existing range as a tracked markChange suggestion. Use this when you want to suggest formatting or another mark-level change programmatically without enabling tracked changes mode globally.

ArgumentTypeDescription
fromnumberStart position of the range to mark
tonumberEnd position of the range to mark
markNamestringName of the schema mark to add
markAttrsRecord<string, unknown> | nullOptional attributes for the mark being tracked
reasonstringOptional description included in the trackedChanges:suggestionCreated event payload
editor.commands.addTrackedMark({
  from: 7,
  to: 12,
  markName: 'bold',
  reason: 'Emphasized the approved term',
})
editor.commands.addTrackedMark({
  from: 7,
  to: 12,
  markName: 'link',
  markAttrs: {
    href: 'https://tiptap.dev',
    target: '_blank',
  },
  reason: 'Linked to the canonical reference',
})

removeTrackedMark()

Remove a mark from an existing range as a tracked markChange suggestion. This mirrors what happens when a user removes formatting while tracked changes mode is enabled.

ArgumentTypeDescription
fromnumberStart position of the range to unmark
tonumberEnd position of the range to unmark
markNamestringName of the schema mark to remove
markAttrsRecord<string, unknown> | nullOptional attributes used to identify the mark variant
reasonstringOptional description included in the trackedChanges:suggestionCreated event payload
editor.commands.removeTrackedMark({
  from: 7,
  to: 12,
  markName: 'bold',
  reason: 'Removed emphasis from the label',
})

toggleTrackedMark()

Toggle a mark on an existing range with tracked mark suggestions. On mixed selections, marked segments become tracked removals and unmarked segments become tracked additions inside one command.

ArgumentTypeDescription
fromnumberStart position of the range to toggle
tonumberEnd position of the range to toggle
markNamestringName of the schema mark to toggle
markAttrsRecord<string, unknown> | nullOptional attributes used to identify or create the mark variant
reasonstringOptional description included in the trackedChanges:suggestionCreated event payload
editor.commands.toggleTrackedMark({
  from: 7,
  to: 12,
  markName: 'bold',
  reason: 'Toggled emphasis based on editorial review',
})