NodeView constructor being called multiple times

Any update on this issue?

I’m noticing the same behavior mentioned above: my custom inline nodeview is being re-created each time when there’s no characters before or after the nodeview, and a new character is inserted either before or after the nodeview.

The recreation of the nodeview is only an issue right after it is inserted, when the x^2 is deleted. However, I think this has to do more with how I’m using inputRules to initially insert the node.

new InputRule(/(?:\$)([^\$]+)(?:\$)$/, (state, match, start, end) => {
    const attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs
    const [matchedText, content] = match;
    const {tr} = state;
    if (matchedText) {
        // Create new Math node with content.
        const node = type.create(attrs, schema.text(content));
        tr.replaceWith(start, end, node);
        const cpos = tr.doc.resolve(tr.selection.anchor - tr.selection.$anchor.nodeBefore.nodeSize);
        tr.setSelection(new NodeSelection(cpos));
    }
    return tr
})

I’m guessing it’s because when I replace the selection with a new node, the text content within the node is not being synchronized with the editor.

A temporary solution, which I got from Inline Nodes With Content, is to add a space before and after the nodeview. This stops the nodeview from being re-created.

Edit Solution was, as marijn said, to update prosemirror-view. I had only updated prosemirror-view for my dependencies and not the main libraries themselves. :slight_smile: