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

Fixed: Tweaked SplitDelta transformation to act better when deltas are undone.

Szymon Cofalik 8 лет назад
Родитель
Сommit
b44e57b96b

+ 1 - 1
packages/ckeditor5-engine/src/model/delta/basic-transformations.js

@@ -225,7 +225,7 @@ addTransformationCase( SplitDelta, SplitDelta, ( a, b, context ) => {
 	if ( a.position.root == b.position.root && compareArrays( pathA, pathB ) == 'same' ) {
 	if ( a.position.root == b.position.root && compareArrays( pathA, pathB ) == 'same' ) {
 		a = a.clone();
 		a = a.clone();
 
 
-		if ( a.position.offset <= b.position.offset ) {
+		if ( a.position.offset < b.position.offset || ( a.position.offset == b.position.offset && context.isStrong ) ) {
 			// If both first operations are `ReinsertOperation`s, we might need to transform `a._cloneOperation`,
 			// If both first operations are `ReinsertOperation`s, we might need to transform `a._cloneOperation`,
 			// so it will take correct node from graveyard.
 			// so it will take correct node from graveyard.
 			if (
 			if (

+ 0 - 3
packages/ckeditor5-engine/src/model/delta/transform.js

@@ -559,9 +559,6 @@ function getNormalizedDeltas( DeltaClass, operations ) {
 					} else {
 					} else {
 						delta = new MoveDelta();
 						delta = new MoveDelta();
 					}
 					}
-
-					// Unsticky the operation. Only operations in "special" deltas can be sticky.
-					o.isSticky = false;
 				}
 				}
 
 
 				delta.addOperation( o );
 				delta.addOperation( o );

+ 5 - 2
packages/ckeditor5-engine/tests/model/delta/transform/splitdelta.js

@@ -69,11 +69,14 @@ describe( 'transform', () => {
 					operations: [
 					operations: [
 						{
 						{
 							type: InsertOperation,
 							type: InsertOperation,
-							position: new Position( root, [ 3, 3, 4 ] ),
+							position: new Position( root, [ 3, 3, 5 ] ),
 							baseVersion
 							baseVersion
 						},
 						},
 						{
 						{
-							type: NoOperation,
+							type: MoveOperation,
+							sourcePosition: new Position( root, [ 3, 3, 4, 0 ] ),
+							howMany: 9,
+							targetPosition: new Position( root, [ 3, 3, 5, 0 ] ),
 							baseVersion: baseVersion + 1
 							baseVersion: baseVersion + 1
 						}
 						}
 					]
 					]