What would be the optimal way to detect the editor blur event? I tried adding @blur on the editor containing div but it does not seem to work.
Would it make sense to expose an event handler (e.g. @blur) on the editor?
@Zanzavar for now you could use @init event of the editor componenet it will return an event where if you call a function with it like
inited(event) {
event.view.dom.addEventListener('blur', function() {
theEditorIsBlured=doSomething
});
},
you are able to catch the blur event.
There will be a focus and blur event in v1.0.
v1.0 is released.
Thanks!
@philippkuehn , is it possible to also pass the blur event data along with state and view in the Editor.js? For instance I need to access the relatedTarget property from the blur handler. Something like the following:
view.dom.addEventListener('blur', (event) => this.options.onBlur({
state: this.state,
view: this.view,
originalEvent: event
}))
The same for the focus event.
Thank you!
@panayotisk You are right! Will fix this in the next release!
@panayotisk The event is added in the latest version
Most helpful comment
There will be a
focusandblurevent in v1.0.