This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Given two commands (commandA and commandB), returns a new command that when applied | |
* to a ProseMirror state that uses the prosemirror-history plugin applies commandA and | |
* then commandB so that both commands are undone with a single undo action. | |
**/ | |
const combineCommands = | |
(commandA: Command, commandB: Command) => | |
(state: EditorState, dispatch?: (tr: Transaction) => void): boolean => { | |
return commandA(state, (transactionA: Transaction) => { | |
const { state: stateA } = state.applyTransaction(transactionA) |