Question on node views

I have encountered a strange behaviour with NodeViews.

I have a case where in addition to the basic prosemirror schema, I have a section node, which can have any number of blocks as content (e.g. paragraphs).

For this section node I want to take control and use a NodeView to render it.

Now, let’s say I wrap a paragraph in a section block and then hit undo.

Even though the section node no longer exists in the state, the nodeview itself appears to be in the dom.

I’ve created an example here to demonstrate:

To reproduce:

  1. Focus on “Hello” and then click on the “Wrap in section” button
  2. Undo (using shortcut e.g. cmd + z)

(Please make sure you refresh the page if you want to repeat the experiment)

I would expect the paragraph to be rendered as whatever the paragraph schema defined (i.e. a p tag) but instead it’s rendered inside a pre, which is what is used by the section block.

Is this the expected behaviour? Shouldn’t the section NodeView be destroyed and then replaced by a paragraph nodeview?

  update() {
    return true;

There’s your problem. See the docs for update. It should only return true if the node it is given is of the type that the node view can display.