How does the Mappable interface work?

I’m planning to create a custom “Move” transaction which first deletes a range of nodes and then inserts them at a target location all within one transaction. I understand that after each step, the positions will change slightly and that I need to use the mappable attribute of the transaction.

What I don’t understand is how it works. Does it assume that the position passed to mappable.map is from the document before all of the steps are applied and then run that position through the array of step maps till it gets to the final step?

Yes.

Though it may be helpful to know that this abstraction isn’t powerful enough to represent move operations—it can only represent replacements, where some range of the document is replaced by a new range of a given size.

1 Like