What’s the best way to “listen” to transactions? Basically, I want to inspect the transaction, and based on what it is (e.g. using contentChanged or getMeta) perform certain actions (server API requests, etc.)
I don’t want to do anything custom to how the transaction is actually dispatched, I only want to inspect it.
What I’ve tried doing so far is to supply a dispatchTransaction
function that does the inspections on the tr
and then applies the transaction in the “default” way, binding this
to the EditorView and calling at the end of dispatchTransaction
:
this.updateState(this.state.apply(tr))
This worked well enough, until I tried to use the ProseMirror Dev Tools which apparently interfere with my `this binding.
This led me to wonder, is there a better way to listen in on all transactions if I have no need to modify how they’re dispatched?
Or, if dispatchTransaction
is the only way, is there a better way to implement “default” dispatch behavior than binding the EditorView to this
?