Hi,
We have been using codemirror in a text editor for a custom language, and have implemented linter to show error markers for any error as the user types into the text editor. When the user is satisfied with the typed in query, they can click on Execute button to execute it.
This feature is well received and there is an enhancement we are hoping to receive help on. The enhancement is to
Enable the Execute button when typed in query is valid
Disable the Execute button when the typed query has errors
Is there an event that can be raised when errors are detected by linter, or the view/state objects that can be subscribed to, to enable/disable the button?
You can check transactions for the setDiagnosticsEffect to see when the diagnostics are reset. Or use diagnosticCount to see whether a given state has active diagnostics.
Thank you Marijn. How to check transactions, just need a bit more help to understand this.
To give a background:
The structure of objects and their initialization direction is as shown below - Container (has editor, execute button) => CM6 Editor => Linter (extension)
Depends on what you want to do with them. If you want to run some imperative code in response to them, configure your editor with an update listener. If you want to track something inside the editor state, the update method of a state field would be more appropriate.