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.

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
editor.commands.addTrackedInsertion({
  from: 7,
  content: 'big ',
  reason: 'Applied AI rewrite',
})
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.

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
editor.commands.addTrackedReplacement({
  from: 7,
  to: 12,
  content: 'earth',
  reason: 'Replaced with approved terminology',
})
editor.commands.addTrackedReplacement({
  from: 7,
  to: 8,
  content: {
    type: 'image',
    attrs: {
      src: '/updated-diagram.png',
      alt: 'Updated diagram',
    },
  },
  reason: 'Replaced placeholder with final diagram',
})