DecorationSet.map with node Decorations

I’m trying to create a decoration that applies to an entire prosemirror node, like a paragraph. I dont want/need it to apply to any particular range, just the entire node.

It seemed like Decoration.node was the right tool for this. I’m able to create the Decoration and it persists if the node’s text is modified.

However, if the node is broken into 2 paragraphs, the Decoration is lost after applying the transaction mapping via decorations.map(transaction.mapping, transaction.doc) (confirmed via the onRemove callback)

Is this expected? I thought the mapping would keep the decoration on the first node (that became smaller) and a new node would be created.

Should I actually be using an inline decoration instead?

Node decorations will indeed be dropped when the node is split. If you’re just looking to style the node’s content, an inline decoration might work better.