How to control all events of NodeView?

Hi, guys!

I want to know how to control all events in one place. In ProseMirror we have the Plugin system and we have the NodeView, it can have own handlers by using document.addEventListener

I have such experience:

  1. In the NodeView I make the KeyboardEvent (keydown) on a div but It doesn’t work. My event just doesn’t want to work
  2. In the plugin I can watch all events but I can’t change something in the view of my NodeView from the plugin

What do I need to know?

keydown events fire on the currently focused element, which will be the editor’s outer element if the user has focused the editor.

Hmm is it because the editor’s outer element have the contentEditable=true property? If I understood correctly what you mean

Then how can I add event handlers and change something related to Node View in them? In NodView I can’t track events, and in plugins I can’t change something in NodeView :sweat_smile:

Node decorations can be used to control node views from a plugin (have them check their outer decorations in their update method). The way DOM events work isn’t something ProseMirror is responsible for.

Hmm, thanks! I’ll try to use your hint