So I think the simplest way to do this is to override the dispatch fn, but after seeing how complex the transactions can be, I’m no long sure this is a right approach.
If the old editor state is a valid lezer parse, and the new editor state would be an invalid editor state, then reject.
The problem here is that this requires we first construct the new editor state, then decide whether to go through with the transaction … all in the dispatch fn.
Is this the right approach? My current idea above is:
if we are currently in an invalid lezer state, let the user do whatever they want, as they’re probably trying to fix something (might be the case the file we loaded is in invalid lezer parser)
if we are currently in a valid lezer state, only let the transaction through if the new state is also valid, but this requires that we, in the dispatch fn, construct the new editor state & try to parse it
Is this the right approach, or is something else better ?