Showing external content in a NodeView

Hello! I’m working on a project that allows users to create variables containing arbitrary text, then reference them in their ProseMirror document. If the variable’s value changes, that should be reflected in the DOM output for the document. I found a conversation from a few years ago about the same thing, though I haven’t been able to replicate the solution locally.

I have a custom “Field” node and a plugin which adds a decoration containing the desired external data in its spec. The Field node’s view sets its content to the data from the decoration’s spec. This all works fine, but naturally the decoration is only updated when something changes in the editor, so when the external data changes, it doesn’t update in the editor until the user focuses it.

How can I trigger an update in the editor from an external source? Or is my approach fundamentally wrong?

Dispatch a transaction.

1 Like