Events
Paid add-on
The extension emits events you can listen to with editor.on(). All events include the transaction that triggered them.
trackedChanges:suggestionCreated
Fired when a new suggestion is created (either from user editing or restored via undo/collaboration). Programmatic commands can also include an optional reason, which is exposed on this event payload.
editor.on('trackedChanges:suggestionCreated', ({ suggestion, reason, transaction }) => {
console.log('New suggestion:', suggestion.id, suggestion.type, reason)
})trackedChanges:suggestionAccepted
Fired when a suggestion is accepted.
editor.on('trackedChanges:suggestionAccepted', ({ suggestionId, suggestion, transaction }) => {
console.log('Accepted:', suggestionId)
})trackedChanges:suggestionRejected
Fired when a suggestion is rejected.
editor.on('trackedChanges:suggestionRejected', ({ suggestionId, suggestion, transaction }) => {
console.log('Rejected:', suggestionId)
})trackedChanges:suggestionRemoved
Fired when a suggestion is removed from the document (e.g., by deleting an "add" suggestion's content).
editor.on(
'trackedChanges:suggestionRemoved',
({ suggestionId, suggestion, removedBy, canRestore }) => {
// removedBy is 'edit' or 'delete'
console.log('Removed:', suggestionId, 'by', removedBy)
},
)trackedChanges:suggestionsUpdated
Fired after bulk operations like acceptAllSuggestions, rejectSuggestionsInRange, etc.
editor.on('trackedChanges:suggestionsUpdated', ({ suggestions, operation, affectedIds }) => {
// operation: 'acceptAll' | 'rejectAll' | 'acceptInRange' | 'rejectInRange' | 'acceptByUser' | 'rejectByUser'
console.log(`${operation} affected ${affectedIds.length} suggestions`)
})trackedChanges:suggestionRangeChanged
Fired when a suggestion's document position changes due to other edits in the document.
editor.on(
'trackedChanges:suggestionRangeChanged',
({ suggestionId, oldRange, newRange, suggestion }) => {
console.log(
`Suggestion ${suggestionId} moved from ${oldRange.from}-${oldRange.to} to ${newRange.from}-${newRange.to}`,
)
},
)trackedChanges:enabled
Fired when track changes mode is enabled.
editor.on('trackedChanges:enabled', ({ userId }) => {
console.log('Track changes enabled for', userId)
})trackedChanges:disabled
Fired when track changes mode is disabled.
editor.on('trackedChanges:disabled', ({ userId }) => {
console.log('Track changes disabled')
})