Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export type InsertTrackedChangeOptions = {
user?: Partial<User>;
/** 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 {
Expand Down
Loading