NodeView setSelection is insufficient

I’m trying to use NodeViews setSelection to manually set selection inside the NodeView. My NodeView has a “dom” property and doesn’t have a “contentDOM”, i.e. I’m rendering everything inside on my own.

setSelection() works perfect but I don’t know the moment when cursor leaves the NodeView node element. I was expecting deselectNode() to do this, but it doesn’t fire for this event. Can I somehow (not with a plugin) detect that cursor left the NodeView node?

1 Like

deselectNode is called when a node selection is removed from the node, it’s not used for other kinds of selections. There’s nothing that will notify a node view when the DOM selection is moved out of it. What are you trying to accomplish?

It’s a pity, but it seems like this is the answer to my question. I have a NodeView for nodes of type “mediaGroup”. There are also “media” nodes instead of “mediaGroup” nodes. The NodeView for mediaGroup doesn’t provide contentDOM (there’s a React component inside, I just can’t do it), that’s why I render every media node inside this React component. On the other hand I want to react when user presses arrow-left / arrow-right inside the document to properly select the media nodes which are also React components. Currently it’s all done with a plugin which listens to all transactions and notifies these React components about new cursor position:

I just wanted to get rid of a plugin.