NodeView Redraw will reset the attributes


#1

When I try to insert a paragraph components to the editor , I observed that the constructors of previously exist paragraph nodes were called. Then the content (texts in the paragraph ) of the reconstructed nodes are preserved but the attributes of the nodes are reset to default. I wonder is this a normal behaviour? If so, is there any way to preserve the attributes just the content ?


#2

Could you describe what you’re doing a little more clearly? A (small, self-contained) code example would be useful.


#3

It turns out it there was a mistake in my code. I called setNodeMarkup somewhere else but did not handle the attribute update. Thats why the default attribute value is used because i did not provide a new value. The problem should be solved. Thanks for the assistance! @marijn


#4

when you use setNodeMarkup you have to clone the original attrs and add the ones you want. If your intention is to preserve the other attributes from being reset to default. On the nodeview issue. You have to return true if the nodeview still applies to the node passed to the nodeview. Also update each attribute individually since nodeviews override all update functionality on the dom node.

EDIT: except the inner content, prosemirror traverses the children if it has a contentDOM