prosemirror-commands provides many very helpful commands for joining/lifting/etc. In the process of building complex commands, I find myself wanting to use these builtin commands as building blocks. Unfortunately their API is to take
onAction and actually apply the changes. I propose instead to refactor these commands into methods that operate on a
transform and returns either
false (could not execute command) or the new
transform. This would allow for easier chaining of builtin commands in creating custom commands.
As an example of one of these custom commands, I have a command that will lift all blocks within selection and then wrap selection in provided block type. This works by operating on a
transform to lift all blocks and then calling
wrapIn on the
transform.selection. I’d like to call the
wrapIn provided but that takes a
state and I need to operate on my
transform which has everything lifted. With this command I can turn a selection into a blockquote and remove bullets & headings.