Tiptap: Detect editor blur?

Created on 6 Nov 2018  路  7Comments  路  Source: ueberdosis/tiptap

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?

feature request

Most helpful comment

There will be a focus and blur event in v1.0.

All 7 comments

@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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bernhardh picture bernhardh  路  3Comments

jameswragg picture jameswragg  路  3Comments

unikitty37 picture unikitty37  路  3Comments

git-mischa picture git-mischa  路  3Comments

pk-pressf1 picture pk-pressf1  路  3Comments