Commands inside a node view

Currently, using commands inside a node view works well but deriving whether a command is currently executable is a bit harder as there’s no real hook for receiving all state changes in an EditorView (I read in a thread somewhere that ideally a node view should only really rely on the state of the node and nothing outside it - edit here). However commands relating to that node need to rerun with the new document state (and without dispatch) to see whether they’re runnable in order to potentially disable UI elements for those commands. Would it be problematic to put this data into a decoration that perfectly sits over the node view, which will trigger updates whenever this derived state changes? Or will that break something I can’t think of? Or is there a better way?

That sounds like an entirely reasonable solution.

1 Like