Trigger plugin update when view gets focus?

Hi, I am trying to develop an editor based on ProseMirror with contextual toolbar. My approach is to develop a plugin with an update method that calculate selection position. I found that that when ProseMirror view gets focus when it is in empty state or the cursor is at the very end of the editor, the view would not call update of the plugin, which would be a problem. And I couldn’t find out from documentation that ProseMirror provides a way to hook something like onFocus in to the view. So my question: is there a way for a plugin to be triggered when ProseMirror gets focus at empty state or the cursor at the very end? Thanks.

By the way, it is a great joy to develop with ProseMirror.

Focus state is not stored in EditorState, and as such state plugins aren’t notified when it changes. But you should be able to listen for DOM focus and blur events (with handleDOMEvents) and either fire transactions for them or imperatively do something.

Yes. Tried it and worked. Thanks.