diff --git a/packages/super-editor/src/extensions/track-changes/track-changes.js b/packages/super-editor/src/extensions/track-changes/track-changes.js index e34cb50a04..662679fbc5 100644 --- a/packages/super-editor/src/extensions/track-changes/track-changes.js +++ b/packages/super-editor/src/extensions/track-changes/track-changes.js @@ -246,7 +246,14 @@ export const TrackChanges = Extension.create({ insertTrackedChange: (options = {}) => ({ state, dispatch, editor }) => { - const { from = state.selection.from, to = state.selection.to, text = '', user, comment } = options; + const { + from = state.selection.from, + to = state.selection.to, + text = '', + user, + comment, + addToHistory = true, + } = options; // Validate bounds to prevent RangeError const docSize = state.doc.content.size; @@ -347,6 +354,10 @@ export const TrackChanges = Extension.create({ tr.setMeta(CommentsPluginKey, { type: 'force' }); tr.setMeta('skipTrackChanges', true); + if (!addToHistory) { + tr.setMeta('addToHistory', false); + } + dispatch(tr); // Handle comment if provided (guard for editors without comments extension) diff --git a/packages/super-editor/src/extensions/types/track-changes-commands.ts b/packages/super-editor/src/extensions/types/track-changes-commands.ts index 5377125124..ef36307598 100644 --- a/packages/super-editor/src/extensions/types/track-changes-commands.ts +++ b/packages/super-editor/src/extensions/types/track-changes-commands.ts @@ -36,6 +36,8 @@ export type InsertTrackedChangeOptions = { user?: Partial; /** Optional comment reply to attach to the tracked change */ comment?: string; + /** Whether to add the change to the undo history (defaults to true) */ + addToHistory?: boolean; }; export interface TrackChangesCommands {