浏览代码

ChangeOperation and ChangeDelta renamed to AttributeOperation and AttributeDelta.

Szymon Cofalik 10 年之前
父节点
当前提交
b72ad40595

+ 1 - 1
packages/ckeditor5-utils/src/document/batch.js

@@ -13,7 +13,7 @@ CKEDITOR.define( [
 	'document/delta/batch-base',
 	'document/delta/batch-base',
 	'document/delta/insertdelta',
 	'document/delta/insertdelta',
 	'document/delta/removedelta',
 	'document/delta/removedelta',
-	'document/delta/changedelta',
+	'document/delta/attributedelta',
 	'document/delta/splitdelta',
 	'document/delta/splitdelta',
 	'document/delta/mergedelta'
 	'document/delta/mergedelta'
 ], ( Batch ) => {
 ], ( Batch ) => {

+ 13 - 13
packages/ckeditor5-utils/src/document/delta/changedelta.js

@@ -8,20 +8,20 @@
 CKEDITOR.define( [
 CKEDITOR.define( [
 	'document/delta/delta',
 	'document/delta/delta',
 	'document/delta/register',
 	'document/delta/register',
-	'document/operation/changeoperation',
+	'document/operation/attributeoperation',
 	'document/position',
 	'document/position',
 	'document/range',
 	'document/range',
 	'document/attribute',
 	'document/attribute',
 	'document/element'
 	'document/element'
-], ( Delta, register, ChangeOperation, Position, Range, Attribute, Element ) => {
+], ( Delta, register, AttributeOperation, Position, Range, Attribute, Element ) => {
 	/**
 	/**
 	 * To provide specific OT behavior and better collisions solving, change methods ({@link document.Batch#setAttr}
 	 * To provide specific OT behavior and better collisions solving, change methods ({@link document.Batch#setAttr}
-	 * and {@link document.Batch#removeAttr}) use `ChangeDelta` class which inherits from the `Delta` class and may
+	 * and {@link document.Batch#removeAttr}) use `AttributeDelta` class which inherits from the `Delta` class and may
 	 * overwrite some methods.
 	 * overwrite some methods.
 	 *
 	 *
-	 * @class document.delta.ChangeDelta
+	 * @class document.delta.AttributeDelta
 	 */
 	 */
-	class ChangeDelta extends Delta {}
+	class AttributeDelta extends Delta {}
 
 
 	/**
 	/**
 	 * Sets the value of the attribute of the node or on the range.
 	 * Sets the value of the attribute of the node or on the range.
@@ -34,7 +34,7 @@ CKEDITOR.define( [
 	 * @param {document.Node|document.Range} nodeOrRange Node or range on which the attribute will be set.
 	 * @param {document.Node|document.Range} nodeOrRange Node or range on which the attribute will be set.
 	 */
 	 */
 	register( 'setAttr', function( key, value, nodeOrRange ) {
 	register( 'setAttr', function( key, value, nodeOrRange ) {
-		change( this, key, value, nodeOrRange );
+		attribute( this, key, value, nodeOrRange );
 
 
 		return this;
 		return this;
 	} );
 	} );
@@ -49,13 +49,13 @@ CKEDITOR.define( [
 	 * @param {document.Node|document.Range} nodeOrRange Node or range on which the attribute will be removed.
 	 * @param {document.Node|document.Range} nodeOrRange Node or range on which the attribute will be removed.
 	 */
 	 */
 	register( 'removeAttr', function( key, nodeOrRange ) {
 	register( 'removeAttr', function( key, nodeOrRange ) {
-		change( this, key, null, nodeOrRange );
+		attribute( this, key, null, nodeOrRange );
 
 
 		return this;
 		return this;
 	} );
 	} );
 
 
-	function change( batch, key, value, nodeOrRange ) {
-		const delta = new ChangeDelta();
+	function attribute( batch, key, value, nodeOrRange ) {
+		const delta = new AttributeDelta();
 
 
 		if ( nodeOrRange instanceof Range ) {
 		if ( nodeOrRange instanceof Range ) {
 			changeRange( batch.doc, delta, key, value, nodeOrRange );
 			changeRange( batch.doc, delta, key, value, nodeOrRange );
@@ -81,7 +81,7 @@ CKEDITOR.define( [
 				range = new Range( Position.createBefore( node ), Position.createAfter( node ) );
 				range = new Range( Position.createBefore( node ), Position.createAfter( node ) );
 			}
 			}
 
 
-			const operation = new ChangeOperation(
+			const operation = new AttributeOperation(
 					range,
 					range,
 					previousValue ? new Attribute( key, previousValue ) : null,
 					previousValue ? new Attribute( key, previousValue ) : null,
 					value ? new Attribute( key, value ) : null,
 					value ? new Attribute( key, value ) : null,
@@ -93,7 +93,7 @@ CKEDITOR.define( [
 		}
 		}
 	}
 	}
 
 
-	// Because change operation needs to have the same attribute value on the whole range, this function split the range
+	// Because attribute operation needs to have the same attribute value on the whole range, this function split the range
 	// into smaller parts.
 	// into smaller parts.
 	function changeRange( doc, delta, key, value, range ) {
 	function changeRange( doc, delta, key, value, range ) {
 		// Position of the last split, the beginning of the new range.
 		// Position of the last split, the beginning of the new range.
@@ -139,7 +139,7 @@ CKEDITOR.define( [
 		}
 		}
 
 
 		function addOperation() {
 		function addOperation() {
-			const operation = new ChangeOperation(
+			const operation = new AttributeOperation(
 					new Range( lastSplitPosition, position ),
 					new Range( lastSplitPosition, position ),
 					valueBefore ? new Attribute( key, valueBefore ) : null,
 					valueBefore ? new Attribute( key, valueBefore ) : null,
 					value ? new Attribute( key, value ) : null,
 					value ? new Attribute( key, value ) : null,
@@ -151,5 +151,5 @@ CKEDITOR.define( [
 		}
 		}
 	}
 	}
 
 
-	return ChangeDelta;
+	return AttributeDelta;
 } );
 } );

+ 1 - 1
packages/ckeditor5-utils/src/document/node.js

@@ -33,7 +33,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], ( Attribute
 			/**
 			/**
 			 * Attributes set.
 			 * Attributes set.
 			 *
 			 *
-			 * Attributes of nodes attached to the document can be changed only be the {@link document.operation.ChangeOperation}.
+			 * Attributes of nodes attached to the document can be changed only be the {@link document.operation.AttributeOperation}.
 			 *
 			 *
 			 * @private
 			 * @private
 			 * @property {Set} _attrs
 			 * @property {Set} _attrs

+ 12 - 12
packages/ckeditor5-utils/src/document/operation/changeoperation.js

@@ -12,11 +12,11 @@ CKEDITOR.define( [
 	/**
 	/**
 	 * Operation to change nodes' attribute. Using this class you can add, remove or change value of the attribute.
 	 * Operation to change nodes' attribute. Using this class you can add, remove or change value of the attribute.
 	 *
 	 *
-	 * @class document.operation.ChangeOperation
+	 * @class document.operation.AttributeOperation
 	 */
 	 */
-	class ChangeOperation extends Operation {
+	class AttributeOperation extends Operation {
 		/**
 		/**
-		 * Creates a change operation.
+		 * Creates an operation that changes, removes or adds attributes.
 		 *
 		 *
 		 * If only the new attribute is set, then it will be inserted. Note that in all nodes in ranges there must be
 		 * If only the new attribute is set, then it will be inserted. Note that in all nodes in ranges there must be
 		 * no attributes with the same key as the new attribute.
 		 * no attributes with the same key as the new attribute.
@@ -66,11 +66,11 @@ CKEDITOR.define( [
 		}
 		}
 
 
 		clone() {
 		clone() {
-			return new ChangeOperation( this.range.clone(), this.oldAttr, this.newAttr, this.baseVersion );
+			return new AttributeOperation( this.range.clone(), this.oldAttr, this.newAttr, this.baseVersion );
 		}
 		}
 
 
 		getReversed() {
 		getReversed() {
-			return new ChangeOperation( this.range, this.newAttr, this.oldAttr, this.baseVersion + 1 );
+			return new AttributeOperation( this.range, this.newAttr, this.oldAttr, this.baseVersion + 1 );
 		}
 		}
 
 
 		_execute() {
 		_execute() {
@@ -82,12 +82,12 @@ CKEDITOR.define( [
 				/**
 				/**
 				 * Old and new attributes should have the same keys.
 				 * Old and new attributes should have the same keys.
 				 *
 				 *
-				 * @error operation-change-different-keys
+				 * @error operation-attribute-different-keys
 				 * @param {document.Attribute} oldAttr
 				 * @param {document.Attribute} oldAttr
 				 * @param {document.Attribute} newAttr
 				 * @param {document.Attribute} newAttr
 				 */
 				 */
 				throw new CKEditorError(
 				throw new CKEditorError(
-					'operation-change-different-keys: Old and new attributes should have the same keys.',
+					'operation-attribute-different-keys: Old and new attributes should have the same keys.',
 					{ oldAttr: oldAttr, newAttr: newAttr } );
 					{ oldAttr: oldAttr, newAttr: newAttr } );
 			}
 			}
 
 
@@ -98,12 +98,12 @@ CKEDITOR.define( [
 						/**
 						/**
 						 * The attribute which should be removed does not exists for the given node.
 						 * The attribute which should be removed does not exists for the given node.
 						 *
 						 *
-						 * @error operation-change-no-attr-to-remove
+						 * @error operation-attribute-no-attr-to-remove
 						 * @param {document.Node} node
 						 * @param {document.Node} node
 						 * @param {document.Attribute} attr
 						 * @param {document.Attribute} attr
 						 */
 						 */
 						throw new CKEditorError(
 						throw new CKEditorError(
-							'operation-change-no-attr-to-remove: The attribute which should be removed does not exists for given node.',
+							'operation-attribute-no-attr-to-remove: The attribute which should be removed does not exists for given node.',
 							{ node: value.node, attr: oldAttr } );
 							{ node: value.node, attr: oldAttr } );
 					}
 					}
 
 
@@ -122,12 +122,12 @@ CKEDITOR.define( [
 						/**
 						/**
 						 * The attribute with given key already exists for the given node.
 						 * The attribute with given key already exists for the given node.
 						 *
 						 *
-						 * @error operation-change-attr-exists
+						 * @error operation-attribute-attr-exists
 						 * @param {document.Node} node
 						 * @param {document.Node} node
 						 * @param {document.Attribute} attr
 						 * @param {document.Attribute} attr
 						 */
 						 */
 						throw new CKEditorError(
 						throw new CKEditorError(
-							'operation-change-attr-exists: The attribute with given key already exists.',
+							'operation-attribute-attr-exists: The attribute with given key already exists.',
 							{ node: value.node, attr: newAttr } );
 							{ node: value.node, attr: newAttr } );
 					}
 					}
 
 
@@ -139,5 +139,5 @@ CKEDITOR.define( [
 		}
 		}
 	}
 	}
 
 
-	return ChangeOperation;
+	return AttributeOperation;
 } );
 } );

+ 20 - 20
packages/ckeditor5-utils/src/document/operation/transform.js

@@ -45,12 +45,12 @@
 
 
 CKEDITOR.define( [
 CKEDITOR.define( [
 	'document/operation/insertoperation',
 	'document/operation/insertoperation',
-	'document/operation/changeoperation',
+	'document/operation/attributeoperation',
 	'document/operation/moveoperation',
 	'document/operation/moveoperation',
 	'document/operation/nooperation',
 	'document/operation/nooperation',
 	'document/range',
 	'document/range',
 	'utils'
 	'utils'
-], ( InsertOperation, ChangeOperation, MoveOperation, NoOperation, Range, utils ) => {
+], ( InsertOperation, AttributeOperation, MoveOperation, NoOperation, Range, utils ) => {
 	const ot = {
 	const ot = {
 		InsertOperation: {
 		InsertOperation: {
 			// Transforms InsertOperation `a` by InsertOperation `b`. Accepts a flag stating whether `a` is more important
 			// Transforms InsertOperation `a` by InsertOperation `b`. Accepts a flag stating whether `a` is more important
@@ -65,7 +65,7 @@ CKEDITOR.define( [
 				return [ transformed ];
 				return [ transformed ];
 			},
 			},
 
 
-			ChangeOperation: doNotUpdate,
+			AttributeOperation: doNotUpdate,
 
 
 			// Transforms InsertOperation `a` by MoveOperation `b`. Accepts a flag stating whether `a` is more important
 			// Transforms InsertOperation `a` by MoveOperation `b`. Accepts a flag stating whether `a` is more important
 			// than `b` when it comes to resolving conflicts. Returns results as an array of operations.
 			// than `b` when it comes to resolving conflicts. Returns results as an array of operations.
@@ -79,15 +79,15 @@ CKEDITOR.define( [
 			}
 			}
 		},
 		},
 
 
-		ChangeOperation: {
-			// Transforms ChangeOperation `a` by InsertOperation `b`. Returns results as an array of operations.
+		AttributeOperation: {
+			// Transforms AttributeOperation `a` by InsertOperation `b`. Returns results as an array of operations.
 			InsertOperation( a, b ) {
 			InsertOperation( a, b ) {
 				// Transform this operation's range.
 				// Transform this operation's range.
 				const ranges = a.range.getTransformedByInsertion( b.position, b.nodeList.length );
 				const ranges = a.range.getTransformedByInsertion( b.position, b.nodeList.length );
 
 
 				// Map transformed range(s) to operations and return them.
 				// Map transformed range(s) to operations and return them.
 				return ranges.reverse().map( ( range ) => {
 				return ranges.reverse().map( ( range ) => {
-					return new ChangeOperation(
+					return new AttributeOperation(
 						range,
 						range,
 						a.oldAttr,
 						a.oldAttr,
 						a.newAttr,
 						a.newAttr,
@@ -96,9 +96,9 @@ CKEDITOR.define( [
 				} );
 				} );
 			},
 			},
 
 
-			// Transforms ChangeOperation `a` by ChangeOperation `b`. Accepts a flag stating whether `a` is more important
+			// Transforms AttributeOperation `a` by AttributeOperation `b`. Accepts a flag stating whether `a` is more important
 			// than `b` when it comes to resolving conflicts. Returns results as an array of operations.
 			// than `b` when it comes to resolving conflicts. Returns results as an array of operations.
-			ChangeOperation( a, b, isStrong ) {
+			AttributeOperation( a, b, isStrong ) {
 				if ( haveConflictingAttributes( a, b ) ) {
 				if ( haveConflictingAttributes( a, b ) ) {
 					// If operations attributes are in conflict, check if their ranges intersect and manage them properly.
 					// If operations attributes are in conflict, check if their ranges intersect and manage them properly.
 					let operations = [];
 					let operations = [];
@@ -106,7 +106,7 @@ CKEDITOR.define( [
 					// First, we want to apply change to the part of a range that has not been changed by the other operation.
 					// First, we want to apply change to the part of a range that has not been changed by the other operation.
 					operations = operations.concat(
 					operations = operations.concat(
 						a.range.getDifference( b.range ).map( ( range ) => {
 						a.range.getDifference( b.range ).map( ( range ) => {
-							return new ChangeOperation( range, a.oldAttr, a.newAttr, a.baseVersion );
+							return new AttributeOperation( range, a.oldAttr, a.newAttr, a.baseVersion );
 						} )
 						} )
 					);
 					);
 
 
@@ -117,7 +117,7 @@ CKEDITOR.define( [
 						const common = a.range.getIntersection( b.range );
 						const common = a.range.getIntersection( b.range );
 
 
 						if ( common !== null ) {
 						if ( common !== null ) {
-							operations.push( new ChangeOperation( common, b.oldAttr, a.newAttr, a.baseVersion ) );
+							operations.push( new AttributeOperation( common, b.oldAttr, a.newAttr, a.baseVersion ) );
 						}
 						}
 					}
 					}
 
 
@@ -134,7 +134,7 @@ CKEDITOR.define( [
 				}
 				}
 			},
 			},
 
 
-			// Transforms ChangeOperation `a` by MoveOperation `b`. Returns results as an array of operations.
+			// Transforms AttributeOperation `a` by MoveOperation `b`. Returns results as an array of operations.
 			MoveOperation( a, b ) {
 			MoveOperation( a, b ) {
 				// Convert MoveOperation properties into a range.
 				// Convert MoveOperation properties into a range.
 				const rangeB = Range.createFromPositionAndOffset( b.sourcePosition, b.howMany );
 				const rangeB = Range.createFromPositionAndOffset( b.sourcePosition, b.howMany );
@@ -145,7 +145,7 @@ CKEDITOR.define( [
 				// This will aggregate transformed ranges.
 				// This will aggregate transformed ranges.
 				let ranges = [];
 				let ranges = [];
 
 
-				// Difference is a part of changed range that is modified by ChangeOperation but are not affected
+				// Difference is a part of changed range that is modified by AttributeOperation but are not affected
 				// by MoveOperation. This can be zero, one or two ranges (if moved range is inside changed range).
 				// by MoveOperation. This can be zero, one or two ranges (if moved range is inside changed range).
 				// If two ranges were returned it means that rangeB was inside rangeA. We will cover rangeB later.
 				// If two ranges were returned it means that rangeB was inside rangeA. We will cover rangeB later.
 				// Right now we will make a simplification and join difference ranges and transform them as one.
 				// Right now we will make a simplification and join difference ranges and transform them as one.
@@ -157,7 +157,7 @@ CKEDITOR.define( [
 				if ( difference !== null ) {
 				if ( difference !== null ) {
 					// MoveOperation removes nodes from their original position. We acknowledge this by proper transformation.
 					// MoveOperation removes nodes from their original position. We acknowledge this by proper transformation.
 					// Take the start and the end of the range and transform them by deletion of moved nodes.
 					// Take the start and the end of the range and transform them by deletion of moved nodes.
-					// Note that if rangeB was inside ChangeOperation range, only difference.end will be transformed.
+					// Note that if rangeB was inside AttributeOperation range, only difference.end will be transformed.
 					// This nicely covers the joining simplification we did in the previous step.
 					// This nicely covers the joining simplification we did in the previous step.
 					difference.start = difference.start.getTransformedByDeletion( b.sourcePosition, b.howMany );
 					difference.start = difference.start.getTransformedByDeletion( b.sourcePosition, b.howMany );
 					difference.end = difference.end.getTransformedByDeletion( b.sourcePosition, b.howMany );
 					difference.end = difference.end.getTransformedByDeletion( b.sourcePosition, b.howMany );
@@ -182,7 +182,7 @@ CKEDITOR.define( [
 
 
 				// Map transformed range(s) to operations and return them.
 				// Map transformed range(s) to operations and return them.
 				return ranges.map( ( range ) => {
 				return ranges.map( ( range ) => {
-					return new ChangeOperation(
+					return new AttributeOperation(
 						range,
 						range,
 						a.oldAttr,
 						a.oldAttr,
 						a.newAttr,
 						a.newAttr,
@@ -214,7 +214,7 @@ CKEDITOR.define( [
 				} );
 				} );
 			},
 			},
 
 
-			ChangeOperation: doNotUpdate,
+			AttributeOperation: doNotUpdate,
 
 
 			// Transforms MoveOperation `a` by MoveOperation `b`. Accepts a flag stating whether `a` is more important
 			// Transforms MoveOperation `a` by MoveOperation `b`. Accepts a flag stating whether `a` is more important
 			// than `b` when it comes to resolving conflicts. Returns results as an array of operations.
 			// than `b` when it comes to resolving conflicts. Returns results as an array of operations.
@@ -333,8 +333,8 @@ CKEDITOR.define( [
 
 
 		if ( a instanceof InsertOperation ) {
 		if ( a instanceof InsertOperation ) {
 			group = ot.InsertOperation;
 			group = ot.InsertOperation;
-		} else if ( a instanceof ChangeOperation ) {
-			group = ot.ChangeOperation;
+		} else if ( a instanceof AttributeOperation ) {
+			group = ot.AttributeOperation;
 		} else if ( a instanceof MoveOperation ) {
 		} else if ( a instanceof MoveOperation ) {
 			group = ot.MoveOperation;
 			group = ot.MoveOperation;
 		} else {
 		} else {
@@ -344,8 +344,8 @@ CKEDITOR.define( [
 		if ( group ) {
 		if ( group ) {
 			if ( b instanceof InsertOperation ) {
 			if ( b instanceof InsertOperation ) {
 				algorithm = group.InsertOperation;
 				algorithm = group.InsertOperation;
-			} else if ( b instanceof ChangeOperation ) {
-				algorithm = group.ChangeOperation;
+			} else if ( b instanceof AttributeOperation ) {
+				algorithm = group.AttributeOperation;
 			} else if ( b instanceof MoveOperation ) {
 			} else if ( b instanceof MoveOperation ) {
 				algorithm = group.MoveOperation;
 				algorithm = group.MoveOperation;
 			} else {
 			} else {
@@ -379,7 +379,7 @@ CKEDITOR.define( [
 		return a.targetPosition.getTransformedByDeletion( b.sourcePosition, b.howMany ) === null;
 		return a.targetPosition.getTransformedByDeletion( b.sourcePosition, b.howMany ) === null;
 	}
 	}
 
 
-	// Takes two ChangeOperations and checks whether their attributes are in conflict.
+	// Takes two AttributeOperations and checks whether their attributes are in conflict.
 	// This happens when both operations changes an attribute with the same key and they either set different
 	// This happens when both operations changes an attribute with the same key and they either set different
 	// values for this attribute or one of them removes it while the other one sets it.
 	// values for this attribute or one of them removes it while the other one sets it.
 	// Returns true if attributes are in conflict.
 	// Returns true if attributes are in conflict.

packages/ckeditor5-utils/tests/document/deltas/changedelta.js → packages/ckeditor5-utils/tests/document/deltas/attributedelta.js


+ 26 - 26
packages/ckeditor5-utils/tests/document/operation/changeoperation.js

@@ -14,7 +14,7 @@ const getIteratorCount = bender.tools.core.getIteratorCount;
 
 
 const modules = bender.amd.require(
 const modules = bender.amd.require(
 	'document/document',
 	'document/document',
-	'document/operation/changeoperation',
+	'document/operation/attributeoperation',
 	'document/position',
 	'document/position',
 	'document/range',
 	'document/range',
 	'document/character',
 	'document/character',
@@ -23,12 +23,12 @@ const modules = bender.amd.require(
 	'ckeditorerror'
 	'ckeditorerror'
 );
 );
 
 
-describe( 'ChangeOperation', () => {
-	let Document, ChangeOperation, Position, Range, Character, Attribute, Text, CKEditorError;
+describe( 'AttributeOperation', () => {
+	let Document, AttributeOperation, Position, Range, Character, Attribute, Text, CKEditorError;
 
 
 	before( () => {
 	before( () => {
 		Document = modules[ 'document/document' ];
 		Document = modules[ 'document/document' ];
-		ChangeOperation = modules[ 'document/operation/changeoperation' ];
+		AttributeOperation = modules[ 'document/operation/attributeoperation' ];
 		Position = modules[ 'document/position' ];
 		Position = modules[ 'document/position' ];
 		Range = modules[ 'document/range' ];
 		Range = modules[ 'document/range' ];
 		Character = modules[ 'document/character' ];
 		Character = modules[ 'document/character' ];
@@ -45,14 +45,14 @@ describe( 'ChangeOperation', () => {
 	} );
 	} );
 
 
 	it( 'should have proper type', () => {
 	it( 'should have proper type', () => {
-		const opp = new ChangeOperation(
+		const op = new AttributeOperation(
 			new Range( new Position( root, [ 0 ] ), new Position( root, [ 2 ] ) ),
 			new Range( new Position( root, [ 0 ] ), new Position( root, [ 2 ] ) ),
 			null,
 			null,
 			new Attribute( 'isNew', true ),
 			new Attribute( 'isNew', true ),
 			doc.version
 			doc.version
 		);
 		);
 
 
-		expect( opp.type ).to.equal( 'attr' );
+		expect( op.type ).to.equal( 'attr' );
 	} );
 	} );
 
 
 	it( 'should insert attribute to the set of nodes', () => {
 	it( 'should insert attribute to the set of nodes', () => {
@@ -61,7 +61,7 @@ describe( 'ChangeOperation', () => {
 		root.insertChildren( 0, 'bar' );
 		root.insertChildren( 0, 'bar' );
 
 
 		doc.applyOperation(
 		doc.applyOperation(
-			new ChangeOperation(
+			new AttributeOperation(
 				new Range( new Position( root, [ 0 ] ), new Position( root, [ 2 ] ) ),
 				new Range( new Position( root, [ 0 ] ), new Position( root, [ 2 ] ) ),
 				null,
 				null,
 				newAttr,
 				newAttr,
@@ -84,7 +84,7 @@ describe( 'ChangeOperation', () => {
 		root.insertChildren( 0, new Character( 'x', [ fooAttr, barAttr ] ) );
 		root.insertChildren( 0, new Character( 'x', [ fooAttr, barAttr ] ) );
 
 
 		doc.applyOperation(
 		doc.applyOperation(
-			new ChangeOperation(
+			new AttributeOperation(
 				new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) ),
 				new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) ),
 				null,
 				null,
 				newAttr,
 				newAttr,
@@ -107,7 +107,7 @@ describe( 'ChangeOperation', () => {
 		root.insertChildren( 0, new Text( 'bar', [ oldAttr ] ) );
 		root.insertChildren( 0, new Text( 'bar', [ oldAttr ] ) );
 
 
 		doc.applyOperation(
 		doc.applyOperation(
-			new ChangeOperation(
+			new AttributeOperation(
 				new Range( new Position( root, [ 0 ] ), new Position( root, [ 2 ] ) ),
 				new Range( new Position( root, [ 0 ] ), new Position( root, [ 2 ] ) ),
 				oldAttr,
 				oldAttr,
 				newAttr,
 				newAttr,
@@ -134,7 +134,7 @@ describe( 'ChangeOperation', () => {
 		root.insertChildren( 0, new Character( 'x', [ fooAttr, x1Attr, barAttr ] ) );
 		root.insertChildren( 0, new Character( 'x', [ fooAttr, x1Attr, barAttr ] ) );
 
 
 		doc.applyOperation(
 		doc.applyOperation(
-			new ChangeOperation(
+			new AttributeOperation(
 				new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) ),
 				new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) ),
 				x1Attr,
 				x1Attr,
 				x2Attr,
 				x2Attr,
@@ -158,7 +158,7 @@ describe( 'ChangeOperation', () => {
 		root.insertChildren( 0, new Character( 'x', [ fooAttr, xAttr, barAttr ] ) );
 		root.insertChildren( 0, new Character( 'x', [ fooAttr, xAttr, barAttr ] ) );
 
 
 		doc.applyOperation(
 		doc.applyOperation(
-			new ChangeOperation(
+			new AttributeOperation(
 				new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) ),
 				new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) ),
 				xAttr,
 				xAttr,
 				null,
 				null,
@@ -173,14 +173,14 @@ describe( 'ChangeOperation', () => {
 		expect( root.getChild( 0 ).hasAttr( barAttr ) ).to.be.true;
 		expect( root.getChild( 0 ).hasAttr( barAttr ) ).to.be.true;
 	} );
 	} );
 
 
-	it( 'should create a change operation as a reverse', () => {
+	it( 'should create an AttributeOperation as a reverse', () => {
 		let oldAttr = new Attribute( 'x', 'old' );
 		let oldAttr = new Attribute( 'x', 'old' );
 		let newAttr = new Attribute( 'x', 'new' );
 		let newAttr = new Attribute( 'x', 'new' );
 		let range = new Range( new Position( root, [ 0 ] ), new Position( root, [ 3 ] ) );
 		let range = new Range( new Position( root, [ 0 ] ), new Position( root, [ 3 ] ) );
-		let operation = new ChangeOperation( range, oldAttr, newAttr, doc.version );
+		let operation = new AttributeOperation( range, oldAttr, newAttr, doc.version );
 		let reverse = operation.getReversed();
 		let reverse = operation.getReversed();
 
 
-		expect( reverse ).to.be.an.instanceof( ChangeOperation );
+		expect( reverse ).to.be.an.instanceof( AttributeOperation );
 		expect( reverse.baseVersion ).to.equal( 1 );
 		expect( reverse.baseVersion ).to.equal( 1 );
 		expect( reverse.range ).to.equal( range );
 		expect( reverse.range ).to.equal( range );
 		expect( reverse.oldAttr ).to.equal( newAttr );
 		expect( reverse.oldAttr ).to.equal( newAttr );
@@ -192,7 +192,7 @@ describe( 'ChangeOperation', () => {
 
 
 		root.insertChildren( 0, 'bar' );
 		root.insertChildren( 0, 'bar' );
 
 
-		let operation = new ChangeOperation(
+		let operation = new AttributeOperation(
 			new Range( new Position( root, [ 0 ] ), new Position( root, [ 3 ] ) ),
 			new Range( new Position( root, [ 0 ] ), new Position( root, [ 3 ] ) ),
 			null,
 			null,
 			newAttr,
 			newAttr,
@@ -217,7 +217,7 @@ describe( 'ChangeOperation', () => {
 
 
 		root.insertChildren( 0, new Text( 'bar', [ oldAttr ] ) );
 		root.insertChildren( 0, new Text( 'bar', [ oldAttr ] ) );
 
 
-		let operation = new ChangeOperation(
+		let operation = new AttributeOperation(
 			new Range( new Position( root, [ 0 ] ), new Position( root, [ 3 ] ) ),
 			new Range( new Position( root, [ 0 ] ), new Position( root, [ 3 ] ) ),
 			oldAttr,
 			oldAttr,
 			newAttr,
 			newAttr,
@@ -245,7 +245,7 @@ describe( 'ChangeOperation', () => {
 
 
 		root.insertChildren( 0, new Text( 'bar', [ fooAttr ] ) );
 		root.insertChildren( 0, new Text( 'bar', [ fooAttr ] ) );
 
 
-		let operation = new ChangeOperation(
+		let operation = new AttributeOperation(
 			new Range( new Position( root, [ 0 ] ), new Position( root, [ 3 ] ) ),
 			new Range( new Position( root, [ 0 ] ), new Position( root, [ 3 ] ) ),
 			fooAttr,
 			fooAttr,
 			null,
 			null,
@@ -275,14 +275,14 @@ describe( 'ChangeOperation', () => {
 
 
 		expect( () => {
 		expect( () => {
 			doc.applyOperation(
 			doc.applyOperation(
-				new ChangeOperation(
+				new AttributeOperation(
 					new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) ),
 					new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) ),
 					fooAttr,
 					fooAttr,
 					null,
 					null,
 					doc.version
 					doc.version
 				)
 				)
 			);
 			);
-		} ).to.throw( CKEditorError, /operation-change-no-attr-to-remove/ );
+		} ).to.throw( CKEditorError, /operation-attribute-no-attr-to-remove/ );
 	} );
 	} );
 
 
 	it( 'should throw an error when one try to insert and the attribute already exists', () => {
 	it( 'should throw an error when one try to insert and the attribute already exists', () => {
@@ -293,14 +293,14 @@ describe( 'ChangeOperation', () => {
 
 
 		expect( () => {
 		expect( () => {
 			doc.applyOperation(
 			doc.applyOperation(
-				new ChangeOperation(
+				new AttributeOperation(
 					new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) ),
 					new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) ),
 					null,
 					null,
 					x2Attr,
 					x2Attr,
 					doc.version
 					doc.version
 				)
 				)
 			);
 			);
-		} ).to.throw( CKEditorError, /operation-change-attr-exists/ );
+		} ).to.throw( CKEditorError, /operation-attribute-attr-exists/ );
 	} );
 	} );
 
 
 	it( 'should throw an error when one try to change and the new and old attributes have different keys', () => {
 	it( 'should throw an error when one try to change and the new and old attributes have different keys', () => {
@@ -311,30 +311,30 @@ describe( 'ChangeOperation', () => {
 
 
 		expect( () => {
 		expect( () => {
 			doc.applyOperation(
 			doc.applyOperation(
-				new ChangeOperation(
+				new AttributeOperation(
 					new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) ),
 					new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) ),
 					fooAttr,
 					fooAttr,
 					barAttr,
 					barAttr,
 					doc.version
 					doc.version
 				)
 				)
 			);
 			);
-		} ).to.throw( CKEditorError, /operation-change-different-keys/ );
+		} ).to.throw( CKEditorError, /operation-attribute-different-keys/ );
 	} );
 	} );
 
 
-	it( 'should create operation with the same parameters when cloned', () => {
+	it( 'should create an AttributeOperation with the same parameters when cloned', () => {
 		let range = new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) );
 		let range = new Range( new Position( root, [ 0 ] ), new Position( root, [ 1 ] ) );
 		let oldAttr = new Attribute( 'foo', 'old' );
 		let oldAttr = new Attribute( 'foo', 'old' );
 		let newAttr = new Attribute( 'foo', 'bar' );
 		let newAttr = new Attribute( 'foo', 'bar' );
 		let baseVersion = doc.version;
 		let baseVersion = doc.version;
 
 
-		let op = new ChangeOperation( range, oldAttr, newAttr, baseVersion );
+		let op = new AttributeOperation( range, oldAttr, newAttr, baseVersion );
 
 
 		let clone = op.clone();
 		let clone = op.clone();
 
 
 		// New instance rather than a pointer to the old instance.
 		// New instance rather than a pointer to the old instance.
 		expect( clone ).not.to.be.equal( op );
 		expect( clone ).not.to.be.equal( op );
 
 
-		expect( clone ).to.be.instanceof( ChangeOperation );
+		expect( clone ).to.be.instanceof( AttributeOperation );
 		expect( clone.range.isEqual( range ) ).to.be.true;
 		expect( clone.range.isEqual( range ) ).to.be.true;
 		expect( clone.oldAttr.isEqual( oldAttr ) ).to.be.true;
 		expect( clone.oldAttr.isEqual( oldAttr ) ).to.be.true;
 		expect( clone.newAttr.isEqual( newAttr ) ).to.be.true;
 		expect( clone.newAttr.isEqual( newAttr ) ).to.be.true;

+ 28 - 28
packages/ckeditor5-utils/tests/document/operation/transform.js

@@ -18,13 +18,13 @@ const modules = bender.amd.require(
 	'document/attribute',
 	'document/attribute',
 	'document/operation/transform',
 	'document/operation/transform',
 	'document/operation/insertoperation',
 	'document/operation/insertoperation',
-	'document/operation/changeoperation',
+	'document/operation/attributeoperation',
 	'document/operation/moveoperation',
 	'document/operation/moveoperation',
 	'document/operation/nooperation'
 	'document/operation/nooperation'
 );
 );
 
 
 describe( 'transform', () => {
 describe( 'transform', () => {
-	let RootElement, Node, Position, Range, Attribute, InsertOperation, ChangeOperation, MoveOperation, NoOperation;
+	let RootElement, Node, Position, Range, Attribute, InsertOperation, AttributeOperation, MoveOperation, NoOperation;
 	let transform;
 	let transform;
 
 
 	before( () => {
 	before( () => {
@@ -34,7 +34,7 @@ describe( 'transform', () => {
 		Range = modules[ 'document/range' ];
 		Range = modules[ 'document/range' ];
 		Attribute = modules[ 'document/attribute' ];
 		Attribute = modules[ 'document/attribute' ];
 		InsertOperation = modules[ 'document/operation/insertoperation' ];
 		InsertOperation = modules[ 'document/operation/insertoperation' ];
-		ChangeOperation = modules[ 'document/operation/changeoperation' ];
+		AttributeOperation = modules[ 'document/operation/attributeoperation' ];
 		MoveOperation = modules[ 'document/operation/moveoperation' ];
 		MoveOperation = modules[ 'document/operation/moveoperation' ];
 		NoOperation = modules[ 'document/operation/nooperation' ];
 		NoOperation = modules[ 'document/operation/nooperation' ];
 
 
@@ -187,13 +187,13 @@ describe( 'transform', () => {
 			} );
 			} );
 		} );
 		} );
 
 
-		describe( 'by ChangeOperation', () => {
+		describe( 'by AttributeOperation', () => {
 			it( 'no position update', () => {
 			it( 'no position update', () => {
 				let rangeStart = position.clone();
 				let rangeStart = position.clone();
 				let rangeEnd = position.clone();
 				let rangeEnd = position.clone();
 				rangeEnd.offset += 2;
 				rangeEnd.offset += 2;
 
 
-				let transformBy = new ChangeOperation(
+				let transformBy = new AttributeOperation(
 					new Range( rangeStart, rangeEnd ),
 					new Range( rangeStart, rangeEnd ),
 					null,
 					null,
 					new Attribute( 'foo', 'bar' ),
 					new Attribute( 'foo', 'bar' ),
@@ -410,7 +410,7 @@ describe( 'transform', () => {
 		} );
 		} );
 	} );
 	} );
 
 
-	describe( 'ChangeOperation', () => {
+	describe( 'AttributeOperation', () => {
 		let start, end, range, oldAttr, newAttr, anotherOldAttr, anotherNewAttr;
 		let start, end, range, oldAttr, newAttr, anotherOldAttr, anotherNewAttr;
 
 
 		beforeEach( () => {
 		beforeEach( () => {
@@ -421,7 +421,7 @@ describe( 'transform', () => {
 			anotherNewAttr = new Attribute( oldAttr.key, 'anothernew' );
 			anotherNewAttr = new Attribute( oldAttr.key, 'anothernew' );
 
 
 			expected = {
 			expected = {
-				type: ChangeOperation,
+				type: AttributeOperation,
 				oldAttr: oldAttr,
 				oldAttr: oldAttr,
 				newAttr: newAttr,
 				newAttr: newAttr,
 				baseVersion: baseVersion + 1
 				baseVersion: baseVersion + 1
@@ -435,7 +435,7 @@ describe( 'transform', () => {
 
 
 				range = new Range( start, end );
 				range = new Range( start, end );
 
 
-				op = new ChangeOperation( range, oldAttr, newAttr, baseVersion );
+				op = new AttributeOperation( range, oldAttr, newAttr, baseVersion );
 
 
 				expected.range = new Range( start.clone(), end.clone() );
 				expected.range = new Range( start.clone(), end.clone() );
 			} );
 			} );
@@ -549,9 +549,9 @@ describe( 'transform', () => {
 				} );
 				} );
 			} );
 			} );
 
 
-			describe( 'by ChangeOperation', () => {
+			describe( 'by AttributeOperation', () => {
 				it( 'attributes have different key: no operation update', () => {
 				it( 'attributes have different key: no operation update', () => {
-					let transformBy = new ChangeOperation(
+					let transformBy = new AttributeOperation(
 						range.clone(),
 						range.clone(),
 						new Attribute( 'abc', true ),
 						new Attribute( 'abc', true ),
 						new Attribute( 'abc', false ),
 						new Attribute( 'abc', false ),
@@ -565,7 +565,7 @@ describe( 'transform', () => {
 				} );
 				} );
 
 
 				it( 'attributes set same value: no operation update', () => {
 				it( 'attributes set same value: no operation update', () => {
-					let transformBy = new ChangeOperation(
+					let transformBy = new AttributeOperation(
 						range.clone(),
 						range.clone(),
 						oldAttr,
 						oldAttr,
 						newAttr,
 						newAttr,
@@ -581,7 +581,7 @@ describe( 'transform', () => {
 				it( 'both operations removes attribute: no operation update', () => {
 				it( 'both operations removes attribute: no operation update', () => {
 					op.newAttr = null;
 					op.newAttr = null;
 
 
-					let transformBy = new ChangeOperation(
+					let transformBy = new AttributeOperation(
 						new Range( new Position( root, [ 1, 1, 4 ] ), new Position( root, [ 3 ] ) ),
 						new Range( new Position( root, [ 1, 1, 4 ] ), new Position( root, [ 3 ] ) ),
 						anotherOldAttr,
 						anotherOldAttr,
 						null,
 						null,
@@ -598,7 +598,7 @@ describe( 'transform', () => {
 
 
 				describe( 'that is less important and', () => {
 				describe( 'that is less important and', () => {
 					it( 'range does not intersect original range: no operation update', () => {
 					it( 'range does not intersect original range: no operation update', () => {
-						let transformBy = new ChangeOperation(
+						let transformBy = new AttributeOperation(
 							new Range( new Position( root, [ 3, 0 ] ), new Position( root, [ 4 ] ) ),
 							new Range( new Position( root, [ 3, 0 ] ), new Position( root, [ 4 ] ) ),
 							anotherOldAttr,
 							anotherOldAttr,
 							null,
 							null,
@@ -612,7 +612,7 @@ describe( 'transform', () => {
 					} );
 					} );
 
 
 					it( 'range contains original range: update oldAttr', () => {
 					it( 'range contains original range: update oldAttr', () => {
-						let transformBy = new ChangeOperation(
+						let transformBy = new AttributeOperation(
 							new Range( new Position( root, [ 1, 1, 4 ] ), new Position( root, [ 3 ] ) ),
 							new Range( new Position( root, [ 1, 1, 4 ] ), new Position( root, [ 3 ] ) ),
 							anotherOldAttr,
 							anotherOldAttr,
 							null,
 							null,
@@ -632,7 +632,7 @@ describe( 'transform', () => {
 						// Get more test cases and better code coverage
 						// Get more test cases and better code coverage
 						op.newAttr = null;
 						op.newAttr = null;
 
 
-						let transformBy = new ChangeOperation(
+						let transformBy = new AttributeOperation(
 							new Range( new Position( root, [ 1, 4, 2 ] ), new Position( root, [ 3 ] ) ),
 							new Range( new Position( root, [ 1, 4, 2 ] ), new Position( root, [ 3 ] ) ),
 							anotherOldAttr,
 							anotherOldAttr,
 							// Get more test cases and better code coverage
 							// Get more test cases and better code coverage
@@ -660,7 +660,7 @@ describe( 'transform', () => {
 
 
 					// [  range transformed by  <   ]  original range  >
 					// [  range transformed by  <   ]  original range  >
 					it( 'range intersects on right: split into two operations, update oldAttr', () => {
 					it( 'range intersects on right: split into two operations, update oldAttr', () => {
-						let transformBy = new ChangeOperation(
+						let transformBy = new AttributeOperation(
 							new Range( new Position( root, [ 1 ] ), new Position( root, [ 2, 1 ] ) ),
 							new Range( new Position( root, [ 1 ] ), new Position( root, [ 2, 1 ] ) ),
 							anotherOldAttr,
 							anotherOldAttr,
 							null,
 							null,
@@ -684,7 +684,7 @@ describe( 'transform', () => {
 					} );
 					} );
 
 
 					it( 'range is inside original range: split into three operations, update oldAttr', () => {
 					it( 'range is inside original range: split into three operations, update oldAttr', () => {
-						let transformBy = new ChangeOperation(
+						let transformBy = new AttributeOperation(
 							new Range( new Position( root, [ 1, 4, 1 ] ), new Position( root, [ 2, 1 ] ) ),
 							new Range( new Position( root, [ 1, 4, 1 ] ), new Position( root, [ 2, 1 ] ) ),
 							anotherOldAttr,
 							anotherOldAttr,
 							null,
 							null,
@@ -716,7 +716,7 @@ describe( 'transform', () => {
 
 
 				describe( 'that is more important and', () => {
 				describe( 'that is more important and', () => {
 					it( 'range does not intersect original range: no operation update', () => {
 					it( 'range does not intersect original range: no operation update', () => {
-						let transformBy = new ChangeOperation(
+						let transformBy = new AttributeOperation(
 							new Range( new Position( root, [ 3, 0 ] ), new Position( root, [ 4 ] ) ),
 							new Range( new Position( root, [ 3, 0 ] ), new Position( root, [ 4 ] ) ),
 							oldAttr,
 							oldAttr,
 							null,
 							null,
@@ -730,7 +730,7 @@ describe( 'transform', () => {
 					} );
 					} );
 
 
 					it( 'range contains original range: convert to NoOperation', () => {
 					it( 'range contains original range: convert to NoOperation', () => {
-						let transformBy = new ChangeOperation(
+						let transformBy = new AttributeOperation(
 							new Range( new Position( root, [ 1, 1, 4 ] ), new Position( root, [ 3 ] ) ),
 							new Range( new Position( root, [ 1, 1, 4 ] ), new Position( root, [ 3 ] ) ),
 							oldAttr,
 							oldAttr,
 							null,
 							null,
@@ -748,7 +748,7 @@ describe( 'transform', () => {
 
 
 					// [ original range   <   ]   range transformed by >
 					// [ original range   <   ]   range transformed by >
 					it( 'range intersects on left: shrink original range', () => {
 					it( 'range intersects on left: shrink original range', () => {
-						let transformBy = new ChangeOperation(
+						let transformBy = new AttributeOperation(
 							new Range( new Position( root, [ 1, 4, 2 ] ), new Position( root, [ 3 ] ) ),
 							new Range( new Position( root, [ 1, 4, 2 ] ), new Position( root, [ 3 ] ) ),
 							oldAttr,
 							oldAttr,
 							null,
 							null,
@@ -765,7 +765,7 @@ describe( 'transform', () => {
 
 
 					// [  range transformed by  <   ]  original range  >
 					// [  range transformed by  <   ]  original range  >
 					it( 'range intersects on right: shrink original range', () => {
 					it( 'range intersects on right: shrink original range', () => {
-						let transformBy = new ChangeOperation(
+						let transformBy = new AttributeOperation(
 							new Range( new Position( root, [ 1 ] ), new Position( root, [ 2, 1 ] ) ),
 							new Range( new Position( root, [ 1 ] ), new Position( root, [ 2, 1 ] ) ),
 							oldAttr,
 							oldAttr,
 							null,
 							null,
@@ -781,7 +781,7 @@ describe( 'transform', () => {
 					} );
 					} );
 
 
 					it( 'range is inside original range: split into two operations', () => {
 					it( 'range is inside original range: split into two operations', () => {
-						let transformBy = new ChangeOperation(
+						let transformBy = new AttributeOperation(
 							new Range( new Position( root, [ 1, 4, 1 ] ), new Position( root, [ 2, 1 ] ) ),
 							new Range( new Position( root, [ 1, 4, 1 ] ), new Position( root, [ 2, 1 ] ) ),
 							oldAttr,
 							oldAttr,
 							null,
 							null,
@@ -1063,7 +1063,7 @@ describe( 'transform', () => {
 			} );
 			} );
 		} );
 		} );
 
 
-		// Some extra cases for a ChangeOperation that operates on single tree level range.
+		// Some extra cases for a AttributeOperation that operates on single tree level range.
 		// This means that the change range start and end differs only on offset value.
 		// This means that the change range start and end differs only on offset value.
 		// This test suite also have some modifications to the original operation
 		// This test suite also have some modifications to the original operation
 		// to get more test cases covered and better code coverage.
 		// to get more test cases covered and better code coverage.
@@ -1074,7 +1074,7 @@ describe( 'transform', () => {
 
 
 				range = new Range( start, end );
 				range = new Range( start, end );
 
 
-				op = new ChangeOperation( range, oldAttr, newAttr, baseVersion );
+				op = new AttributeOperation( range, oldAttr, newAttr, baseVersion );
 
 
 				expected.range = new Range( start.clone(), end.clone() );
 				expected.range = new Range( start.clone(), end.clone() );
 			} );
 			} );
@@ -1537,9 +1537,9 @@ describe( 'transform', () => {
 			} );
 			} );
 		} );
 		} );
 
 
-		describe( 'by ChangeOperation', () => {
+		describe( 'by AttributeOperation', () => {
 			it( 'no operation update', () => {
 			it( 'no operation update', () => {
-				let transformBy = new ChangeOperation(
+				let transformBy = new AttributeOperation(
 					new Range( sourcePosition, rangeEnd ),
 					new Range( sourcePosition, rangeEnd ),
 					new Attribute( 'abc', true ),
 					new Attribute( 'abc', true ),
 					new Attribute( 'abc', false ),
 					new Attribute( 'abc', false ),
@@ -2333,9 +2333,9 @@ describe( 'transform', () => {
 			} );
 			} );
 		} );
 		} );
 
 
-		describe( 'by ChangeOperation', () => {
+		describe( 'by AttributeOperation', () => {
 			it( 'no operation update', () => {
 			it( 'no operation update', () => {
-				let transformBy = new ChangeOperation(
+				let transformBy = new AttributeOperation(
 					new Range(
 					new Range(
 						new Position( root, [ 0 ] ),
 						new Position( root, [ 0 ] ),
 						new Position( root, [ 1 ] )
 						new Position( root, [ 1 ] )