InputRules on text deletion?

I love that with InputRules, you can perform operations when a regex matches.

How can I handle the user “delete”-ing the text to cause the string to not match anymore?

Because InputRules only handle onTextInput (prosemirror-inputrules/src/inputrules.ts at master · ProseMirror/prosemirror-inputrules · GitHub), they won’t even get called back on text deletion.

Any idea of how I should go about an InputRule that also works when text gets deleted (in addition to inserted)?

1 Like

That’s not something input rules will help with, as you found. You could bind an additional command to backspace / delete, or install a transaction appender that looks for certain edit patterns in the changes, but there is nothing that will be as convenient as defining a regexp.

1 Like

After a good deal of thought we opted for appendTransaction to handle this. It’s arduous compared to InputRule, but it’s robust.

1 Like