Move one child of an element node to another index among its siblings.
Composing a move out of a remove and an insert produces the same document,
but not the same positions: every position inside the moved node is
mapped through a replacement that no longer contains it, and collapses to
the parent. That is why a caret has to be restored by hand after a
rebuild-the-whole-table move. Here the subtree keeps its identity, so a
selection, a decoration or a pending upload placeholder inside the moved
node travels with it and needs no repair.
It is also one undo step rather than two, and inverts to a plain move back.
to is the index the node ends up at, the way Array.prototype.splice
counts: removed first, then inserted. Moving child 0 to index 2 of
[a, b, c] gives [b, c, a].
Moving back is just the move with its ends swapped, under splice
semantics that restores the original order for every element, not only
the one that moved.
Move one child of an element node to another index among its siblings.
Composing a move out of a remove and an insert produces the same document, but not the same positions: every position inside the moved node is mapped through a replacement that no longer contains it, and collapses to the parent. That is why a caret has to be restored by hand after a rebuild-the-whole-table move. Here the subtree keeps its identity, so a selection, a decoration or a pending upload placeholder inside the moved node travels with it and needs no repair.
It is also one undo step rather than two, and inverts to a plain move back.
tois the index the node ends up at, the wayArray.prototype.splicecounts: removed first, then inserted. Moving child 0 to index 2 of[a, b, c]gives[b, c, a].