8
0
Просмотр исходного кода

Fix: Corrected transformations for pasting and undo scenarios.

Szymon Cofalik 7 лет назад
Родитель
Сommit
4f0acf0f46

+ 3 - 2
packages/ckeditor5-engine/src/model/operation/transform.js

@@ -1692,9 +1692,10 @@ setTransformation( MoveOperation, MergeOperation, ( a, b, context ) => {
 			// removed nodes might be unexpected. This means that in this scenario we will reverse merging and remove the element.
 			//
 			if ( !context.aWasUndone ) {
-				const gyMove = new MoveOperation( b.graveyardPosition, 1, a.targetPosition.getShiftedBy( -1 ), 0 );
+				const gyMoveTarget = Position.createFromPosition( b.graveyardPosition );
+				const gyMove = new MoveOperation( b.graveyardPosition, 1, gyMoveTarget, 0 );
 
-				const targetPositionPath = gyMove.getMovedRangeStart().path.slice();
+				const targetPositionPath = b.graveyardPosition.path.slice();
 				targetPositionPath.push( 0 );
 
 				return [

+ 3 - 0
packages/ckeditor5-engine/tests/model/operation/transform/undo.js

@@ -384,5 +384,8 @@ describe( 'transform', () => {
 
 		john.redo();
 		expectClients( '<paragraph>Fo1</paragraph><paragraph>2ar</paragraph>' );
+
+		john.undo();
+		expectClients( '<paragraph>Foo</paragraph><paragraph>Bar</paragraph>' );
 	} );
 } );