UNPKG

prosemirror-flat-list

Version:
16 lines (14 loc) 442 B
import type { Command, Transaction } from 'prosemirror-state' export function patchCommand(patch: (tr: Transaction) => Transaction) { const withPatch = (command: Command): Command => { const patchedCommand: Command = (state, dispatch, view) => { return command( state, dispatch ? (tr: Transaction) => dispatch(patch(tr)) : undefined, view, ) } return patchedCommand } return withPatch }