diff --git a/src/model/operation/transform.js b/src/model/operation/transform.js
index 2bab3cd61..02a4992fe 100644
--- a/src/model/operation/transform.js
+++ b/src/model/operation/transform.js
@@ -449,6 +449,8 @@ class ContextFactory {
this._setRelation( opA, opB, 'insertAtSource' );
} else if ( opA.targetPosition.isEqual( opB.deletionPosition ) ) {
this._setRelation( opA, opB, 'insertBetween' );
+ } else if ( opA.targetPosition.isAfter( opB.sourcePosition ) ) {
+ this._setRelation( opA, opB, 'moveTargetAfter' );
}
break;
@@ -1568,7 +1570,7 @@ setTransformation( MoveOperation, SplitOperation, ( a, b, context ) => {
// Do not transform if target position is same as split insertion position and this split comes from undo.
// This should be done on relations but it is too much work for now as it would require relations working in collaboration.
// We need to make a decision how we will resolve such conflict and this is less harmful way.
- if ( !a.targetPosition.isEqual( b.insertionPosition ) || !b.graveyardPosition ) {
+ if ( !a.targetPosition.isEqual( b.insertionPosition ) || !b.graveyardPosition || context.abRelation == 'moveTargetAfter' ) {
newTargetPosition = a.targetPosition._getTransformedBySplitOperation( b );
}
diff --git a/tests/model/operation/transform/undo.js b/tests/model/operation/transform/undo.js
index 7ce5c517f..0ebe051a9 100644
--- a/tests/model/operation/transform/undo.js
+++ b/tests/model/operation/transform/undo.js
@@ -238,7 +238,7 @@ describe( 'transform', () => {
expectClients( 'FooBar' );
} );
- it.skip( 'delete split paragraphs', () => {
+ it( 'delete split paragraphs', () => {
john.setData( 'FooB[]ar' );
john.split();
@@ -321,4 +321,27 @@ describe( 'transform', () => {
john.undo();
expectClients( 'FooBar' );
} );
+
+ // https://github.com/ckeditor/ckeditor5/issues/1288
+ it( 'remove two groups of blocks then undo, undo', () => {
+ john.setData(
+ 'XAB[CD]'
+ );
+
+ john.delete();
+ john.setSelection( [ 0, 1 ], [ 2, 1 ] );
+ john.delete();
+
+ expectClients( 'X' );
+
+ john.undo();
+
+ expectClients( 'XAB' );
+
+ john.undo();
+
+ expectClients(
+ 'XABCD'
+ );
+ } );
} );