CodeMirror v6 - onBlur call my function

I want to format my code when user types, I found an formatter & call dispatch with the formatted code, I want to do this when user clicks outside of the editor.

I am doing this as v6 doesn’t support formating.

How to listen to onBlur ? and call my function after that.

Any help is highly appreciated :pray:, thanks in advance.

You can use EditorView.domEventHandlers to create an extension that adds event handlers.

@marijn Thanks, but editor.value.contentDOM.addEventListener is working for me.