Skip to content

Commit

Permalink
fix: don't undo initial state (fix nhn#3266)
Browse files Browse the repository at this point in the history
  • Loading branch information
rawstream committed Sep 28, 2024
1 parent 0c5c11b commit 0fde029
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/editor/src/commands/defaultCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ export function getDefaultCommands(): Record<string, EditorCommand> {
return {
deleteSelection: () => deleteSelection,
selectAll: () => selectAll,
undo: () => undo,
undo: () => (state, dispatch) => {
const hist = state.history$;

// The initial state is not counted as a history event
if (!hist || hist.done.eventCount === 1) return false;
undo(state, dispatch);
return true;
},
redo: () => redo,
};
}

0 comments on commit 0fde029

Please sign in to comment.