|
|
@@ -11,7 +11,9 @@ import UnwrapOperation from './unwrapoperation';
|
|
|
import NoOperation from './nooperation';
|
|
|
import Range from '../range';
|
|
|
import Position from '../position';
|
|
|
+
|
|
|
import compareArrays from '@ckeditor/ckeditor5-utils/src/comparearrays';
|
|
|
+import log from '@ckeditor/ckeditor5-utils/src/log';
|
|
|
|
|
|
const transformations = new Map();
|
|
|
|
|
|
@@ -51,7 +53,20 @@ function updateBaseVersions( operations, baseVersion ) {
|
|
|
function transform( a, b, context = {} ) {
|
|
|
const transformationFunction = getTransformation( a, b );
|
|
|
|
|
|
- return transformationFunction( a.clone(), b, context );
|
|
|
+ try {
|
|
|
+ return transformationFunction( a.clone(), b, context );
|
|
|
+ } catch ( e ) {
|
|
|
+ log.error( 'Error during operation transformation!' );
|
|
|
+ log.error( 'Transformed operation', a );
|
|
|
+ log.error( 'Operation transformed by', b );
|
|
|
+ log.error( 'context.aIsStrong', context.aIsStrong );
|
|
|
+ log.error( 'context.wasUndone( a )', context.wasUndone( a ) );
|
|
|
+ log.error( 'context.wasUndone( b )', context.wasUndone( b ) );
|
|
|
+ log.error( 'context.getRelation( a, b )', context.getRelation( a, b ) );
|
|
|
+ log.error( 'context.getRelation( b, a )', context.getRelation( b, a ) );
|
|
|
+
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function transformSets( operationsA, operationsB, options ) {
|
|
|
@@ -115,6 +130,8 @@ function transformSets( operationsA, operationsB, options ) {
|
|
|
if ( options.useContext ) {
|
|
|
updateOriginalOperation( context, opA, newOpA );
|
|
|
updateOriginalOperation( context, opB, newOpB );
|
|
|
+
|
|
|
+ updateRelations( context, opA, opB );
|
|
|
}
|
|
|
|
|
|
opsA.splice( k, 1, ...newOpA );
|
|
|
@@ -996,7 +1013,7 @@ setTransformation( MoveOperation, MoveOperation, ( a, b, context ) => {
|
|
|
|
|
|
// Assign `context.aIsStrong` to a different variable, because the value may change during execution of
|
|
|
// this algorithm and we do not want to override original `context.aIsStrong` that will be used in later transformations.
|
|
|
- let aIsStrong = context.aIsStrong;
|
|
|
+ let aIsStrong = context.aIsStrong || context.getRelation( a, b ) == 'insertBefore';
|
|
|
|
|
|
if ( context.abRelation == 'insertBefore' ) {
|
|
|
aIsStrong = true;
|