|
|
@@ -4,6 +4,7 @@
|
|
|
*/
|
|
|
|
|
|
import { transform } from '../../../src/model/operation/transform';
|
|
|
+import { transformSets } from '@ckeditor/ckeditor5-engine/src/model/operation/transform';
|
|
|
|
|
|
import Model from '../../../src/model/model';
|
|
|
import RootElement from '../../../src/model/rootelement';
|
|
|
@@ -2607,3 +2608,69 @@ describe( 'transform', () => {
|
|
|
} );
|
|
|
} );
|
|
|
} );
|
|
|
+
|
|
|
+describe( 'transformSets', () => {
|
|
|
+ let model, doc, root, node;
|
|
|
+
|
|
|
+ beforeEach( () => {
|
|
|
+ model = new Model();
|
|
|
+ doc = model.document;
|
|
|
+ root = doc.createRoot();
|
|
|
+
|
|
|
+ node = new Node();
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'originalOperations should correctly link transformed operations with original operations #1', () => {
|
|
|
+ const position = new Position( root, [ 0 ] );
|
|
|
+
|
|
|
+ const a = new InsertOperation( position, [ node ], 0 );
|
|
|
+
|
|
|
+ const { operationsA, originalOperations } = transformSets( [ a ], [], {
|
|
|
+ document: doc,
|
|
|
+ useRelations: false,
|
|
|
+ padWithNoOps: false
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( originalOperations.get( operationsA[ 0 ] ) ).to.equal( a );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'originalOperations should correctly link transformed operations with original operations #2', () => {
|
|
|
+ const position = new Position( root, [ 0 ] );
|
|
|
+
|
|
|
+ const b = new InsertOperation( position, [ node ], 0 );
|
|
|
+
|
|
|
+ const { operationsB, originalOperations } = transformSets( [], [ b ], {
|
|
|
+ document: doc,
|
|
|
+ useRelations: false,
|
|
|
+ padWithNoOps: false
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( originalOperations.get( operationsB[ 0 ] ) ).to.equal( b );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'originalOperations should correctly link transformed operations with original operations #3', () => {
|
|
|
+ const position = new Position( root, [ 4 ] );
|
|
|
+
|
|
|
+ const a = new InsertOperation( position, [ node ], 0 );
|
|
|
+ const b = new AttributeOperation(
|
|
|
+ new Range(
|
|
|
+ new Position( root, [ 2 ] ),
|
|
|
+ new Position( root, [ 11 ] )
|
|
|
+ ),
|
|
|
+ 'foo',
|
|
|
+ 'bar',
|
|
|
+ 'xyz',
|
|
|
+ 0
|
|
|
+ );
|
|
|
+
|
|
|
+ const { operationsA, operationsB, originalOperations } = transformSets( [ a ], [ b ], {
|
|
|
+ document: doc,
|
|
|
+ useRelations: false,
|
|
|
+ padWithNoOps: false
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( originalOperations.get( operationsA[ 0 ] ) ).to.equal( a );
|
|
|
+ expect( originalOperations.get( operationsB[ 0 ] ) ).to.equal( b );
|
|
|
+ expect( originalOperations.get( operationsB[ 1 ] ) ).to.equal( b );
|
|
|
+ } );
|
|
|
+} );
|