Deleting a node in a command

I have a simple situation where on certain keys I want to remove a paragraph entirely. So, in my command code I have the following:

tr.delete(nodeStart, nodeStart + theNode.nodeSize); dispatch(tr)

The problem is that as I have different types of paragraphs (one spec with a type parameter that changes margins depending on what that type is), the following paragraph is becoming the type of the one I deleted. The node I want gone is being deleted, but as I said, the one being thus moved up is taking on the type of the one I zapped. And so it’s toDOM puts the wrong class and the margins are not right.

I must be missing something simple, like a keep parameter or something, that makes the succeeding node stay as it is, with it’s existing attributes.

This sounds like nodeStart is the position at the start of the node, rather than the position before it. Thus, you’re deleting from the start of the node to the start of the node after it (or whatever happens to be one token after the end of the node).

Thanks once again, marjin, the code that seems to work is:

tr.delete(nodeStart-1, nodeStart + theNode.nodeSize);

You will also need to subtract one from the end of the range. Or, much better, get the actual position before the node (via ResolvedPos.before if this comes from a resolved position) and calculate with that.