|
|
@@ -68,9 +68,14 @@ export function getMarkerDelta( name, oldRange, newRange, version ) {
|
|
|
export function getMergeDelta( position, howManyInPrev, howManyInNext, version ) {
|
|
|
const delta = new MergeDelta();
|
|
|
|
|
|
- const sourcePosition = position.getMovedToChild();
|
|
|
+ const sourcePath = position.path.slice();
|
|
|
+ sourcePath.push( 0 );
|
|
|
+ const sourcePosition = new Position( position.root, sourcePath );
|
|
|
|
|
|
- const targetPosition = position.getShiftedBy( -1 ).getMovedToChild( howManyInPrev );
|
|
|
+ const targetPath = position.getShiftedBy( -1 ).path.slice();
|
|
|
+ targetPath.push( howManyInPrev );
|
|
|
+
|
|
|
+ const targetPosition = new Position( position.root, targetPath );
|
|
|
|
|
|
const move = new MoveOperation( sourcePosition, howManyInNext, targetPosition, version );
|
|
|
move.isSticky = true;
|
|
|
@@ -126,9 +131,15 @@ export function getRenameDelta( position, oldName, newName, baseVersion ) {
|
|
|
export function getSplitDelta( position, nodeCopy, howManyMove, version ) {
|
|
|
const delta = new SplitDelta();
|
|
|
|
|
|
- const insertPosition = position.getMovedToParent().getShiftedBy( 1 );
|
|
|
+ const insertPath = position.getParentPath();
|
|
|
+ insertPath[ insertPath.length - 1 ]++;
|
|
|
+
|
|
|
+ const insertPosition = new Position( position.root, insertPath );
|
|
|
+
|
|
|
+ const targetPath = insertPosition.path.slice();
|
|
|
+ targetPath.push( 0 );
|
|
|
|
|
|
- const targetPosition = insertPosition.getMovedToChild();
|
|
|
+ const targetPosition = new Position( insertPosition.root, targetPath );
|
|
|
|
|
|
delta.addOperation( new InsertOperation( insertPosition, [ nodeCopy ], version ) );
|
|
|
|
|
|
@@ -147,7 +158,9 @@ export function getWrapDelta( range, element, version ) {
|
|
|
|
|
|
const insert = new InsertOperation( range.end, element, version );
|
|
|
|
|
|
- const targetPosition = range.end.getMovedToChild();
|
|
|
+ const targetPath = range.end.path.slice();
|
|
|
+ targetPath.push( 0 );
|
|
|
+ const targetPosition = new Position( range.end.root, targetPath );
|
|
|
|
|
|
const move = new MoveOperation( range.start, range.end.offset - range.start.offset, targetPosition, version + 1 );
|
|
|
|
|
|
@@ -162,7 +175,9 @@ export function getWrapDelta( range, element, version ) {
|
|
|
export function getUnwrapDelta( positionBefore, howManyChildren, version ) {
|
|
|
const delta = new UnwrapDelta();
|
|
|
|
|
|
- const sourcePosition = positionBefore.getMovedToChild();
|
|
|
+ const sourcePath = positionBefore.path.slice();
|
|
|
+ sourcePath.push( 0 );
|
|
|
+ const sourcePosition = new Position( positionBefore.root, sourcePath );
|
|
|
|
|
|
const move = new MoveOperation( sourcePosition, howManyChildren, positionBefore, version );
|
|
|
move.isSticky = true;
|