{"version":3,"file":"index.cjs","names":["Extension","undo","redo","history"],"sources":["../../src/undo-redo/undo-redo.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { history, redo, undo } from '@tiptap/pm/history'\n\nexport interface UndoRedoOptions {\n  /**\n   * The amount of history events that are collected before the oldest events are discarded.\n   * @default 100\n   * @example 50\n   */\n  depth: number\n\n  /**\n   * The delay (in milliseconds) between changes after which a new group should be started.\n   * @default 500\n   * @example 1000\n   */\n  newGroupDelay: number\n}\n\ndeclare module '@tiptap/core' {\n  interface Commands<ReturnType> {\n    undoRedo: {\n      /**\n       * Undo recent changes\n       * @example editor.commands.undo()\n       */\n      undo: () => ReturnType\n      /**\n       * Reapply reverted changes\n       * @example editor.commands.redo()\n       */\n      redo: () => ReturnType\n    }\n  }\n}\n\n/**\n * This extension allows you to undo and redo recent changes.\n * @see https://www.tiptap.dev/api/extensions/undo-redo\n *\n * **Important**: If the `@tiptap/extension-collaboration` package is used, make sure to remove\n * the `undo-redo` extension, as it is not compatible with the `collaboration` extension.\n *\n * `@tiptap/extension-collaboration` uses its own history implementation.\n */\nexport const UndoRedo = Extension.create<UndoRedoOptions>({\n  name: 'undoRedo',\n\n  addOptions() {\n    return {\n      depth: 100,\n      newGroupDelay: 500,\n    }\n  },\n\n  addCommands() {\n    return {\n      undo:\n        () =>\n        ({ state, dispatch }) => {\n          return undo(state, dispatch)\n        },\n      redo:\n        () =>\n        ({ state, dispatch }) => {\n          return redo(state, dispatch)\n        },\n    }\n  },\n\n  addProseMirrorPlugins() {\n    return [history(this.options)]\n  },\n\n  addKeyboardShortcuts() {\n    return {\n      'Mod-z': () => this.editor.commands.undo(),\n      'Shift-Mod-z': () => this.editor.commands.redo(),\n      'Mod-y': () => this.editor.commands.redo(),\n\n      // Russian keyboard layouts\n      'Mod-я': () => this.editor.commands.undo(),\n      'Shift-Mod-я': () => this.editor.commands.redo(),\n    }\n  },\n})\n"],"mappings":";;;;;;;;;;;;;AA6CA,MAAa,WAAWA,aAAAA,UAAU,OAAwB;CACxD,MAAM;CAEN,aAAa;EACX,OAAO;GACL,OAAO;GACP,eAAe;EACjB;CACF;CAEA,cAAc;EACZ,OAAO;GACL,aAEG,EAAE,OAAO,eAAe;IACvB,QAAA,GAAOC,mBAAAA,KAAAA,CAAK,OAAO,QAAQ;GAC7B;GACF,aAEG,EAAE,OAAO,eAAe;IACvB,QAAA,GAAOC,mBAAAA,KAAAA,CAAK,OAAO,QAAQ;GAC7B;EACJ;CACF;CAEA,wBAAwB;EACtB,OAAO,EAAA,GAACC,mBAAAA,QAAAA,CAAQ,KAAK,OAAO,CAAC;CAC/B;CAEA,uBAAuB;EACrB,OAAO;GACL,eAAe,KAAK,OAAO,SAAS,KAAK;GACzC,qBAAqB,KAAK,OAAO,SAAS,KAAK;GAC/C,eAAe,KAAK,OAAO,SAAS,KAAK;GAGzC,eAAe,KAAK,OAAO,SAAS,KAAK;GACzC,qBAAqB,KAAK,OAAO,SAAS,KAAK;EACjD;CACF;AACF,CAAC"}