prosemirror-flat-list
Version:
Powerful list support for ProseMirror
16 lines (14 loc) • 442 B
text/typescript
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
}