quadratichq/quadratic

Undo / Redo Functionality

davidkircos opened this issue · 1 comments

Research Command Pattern & Memento Pattern

For undo and redo, commands should also save the interaction state (cursor position) when they were run. When pressing Command Z in Excel it also reverts to the cursor position of when the previous command was run. This should be relatively easy to do because we store all the GridInteractionState in a single object.

export const gridInteractionStateDefault: GridInteractionState = {
  keyboardMovePosition: { x: 0, y: 0 },
  cursorPosition: { x: 0, y: 0 },
  showMultiCursor: false,
  multiCursorPosition: {
    originPosition: { x: 0, y: 0 },
    terminalPosition: { x: 0, y: 0 },
  },
  showInput: false,
  inputInitialValue: '',
};

https://github.com/quadratichq/quadratic/blob/main/src/atoms/gridInteractionStateAtom.ts