8
0
Quellcode durchsuchen

Merge branch 'master' into t/92

Piotrek Koszuliński vor 10 Jahren
Ursprung
Commit
b188e77d4f
51 geänderte Dateien mit 15 neuen und 5431 gelöschten Zeilen
  1. 0 125
      packages/ckeditor5-utils/src/document/attribute.js
  2. 0 36
      packages/ckeditor5-utils/src/document/character.js
  3. 0 155
      packages/ckeditor5-utils/src/document/delta/changedelta.js
  4. 0 58
      packages/ckeditor5-utils/src/document/delta/delta.js
  5. 0 44
      packages/ckeditor5-utils/src/document/delta/insertdelta.js
  6. 0 78
      packages/ckeditor5-utils/src/document/delta/mergedelta.js
  7. 0 14
      packages/ckeditor5-utils/src/document/delta/register.js
  8. 0 47
      packages/ckeditor5-utils/src/document/delta/removedelta.js
  9. 0 71
      packages/ckeditor5-utils/src/document/delta/splitdelta.js
  10. 0 124
      packages/ckeditor5-utils/src/document/delta/transaction-base.js
  11. 0 159
      packages/ckeditor5-utils/src/document/document.js
  12. 0 123
      packages/ckeditor5-utils/src/document/element.js
  13. 0 247
      packages/ckeditor5-utils/src/document/node.js
  14. 0 156
      packages/ckeditor5-utils/src/document/nodelist.js
  15. 0 130
      packages/ckeditor5-utils/src/document/operation/changeoperation.js
  16. 0 61
      packages/ckeditor5-utils/src/document/operation/insertoperation.js
  17. 0 128
      packages/ckeditor5-utils/src/document/operation/moveoperation.js
  18. 0 87
      packages/ckeditor5-utils/src/document/operation/operation.js
  19. 0 33
      packages/ckeditor5-utils/src/document/operation/reinsertoperation.js
  20. 0 45
      packages/ckeditor5-utils/src/document/operation/removeoperation.js
  21. 0 177
      packages/ckeditor5-utils/src/document/position.js
  22. 0 178
      packages/ckeditor5-utils/src/document/positioniterator.js
  23. 0 85
      packages/ckeditor5-utils/src/document/range.js
  24. 0 35
      packages/ckeditor5-utils/src/document/rootelement.js
  25. 0 42
      packages/ckeditor5-utils/src/document/text.js
  26. 0 21
      packages/ckeditor5-utils/src/document/transaction.js
  27. 13 17
      packages/ckeditor5-utils/src/utils.js
  28. 0 81
      packages/ckeditor5-utils/tests/document/attribute.js
  29. 0 56
      packages/ckeditor5-utils/tests/document/character.js
  30. 0 275
      packages/ckeditor5-utils/tests/document/deltas/changedelta.js
  31. 0 67
      packages/ckeditor5-utils/tests/document/deltas/delta.js
  32. 0 46
      packages/ckeditor5-utils/tests/document/deltas/insertdelta.js
  33. 0 80
      packages/ckeditor5-utils/tests/document/deltas/mergedelta.js
  34. 0 61
      packages/ckeditor5-utils/tests/document/deltas/removedelta.js
  35. 0 101
      packages/ckeditor5-utils/tests/document/deltas/splitdelta.js
  36. 0 120
      packages/ckeditor5-utils/tests/document/document.js
  37. 0 128
      packages/ckeditor5-utils/tests/document/element.js
  38. 0 276
      packages/ckeditor5-utils/tests/document/node.js
  39. 0 115
      packages/ckeditor5-utils/tests/document/nodelist.js
  40. 0 319
      packages/ckeditor5-utils/tests/document/operation/changeoperation.js
  41. 0 160
      packages/ckeditor5-utils/tests/document/operation/insertoperation.js
  42. 0 245
      packages/ckeditor5-utils/tests/document/operation/moveoperation.js
  43. 0 81
      packages/ckeditor5-utils/tests/document/operation/reinsertoperation.js
  44. 0 103
      packages/ckeditor5-utils/tests/document/operation/removeoperation.js
  45. 0 229
      packages/ckeditor5-utils/tests/document/position.js
  46. 0 137
      packages/ckeditor5-utils/tests/document/positioniterator.js
  47. 0 118
      packages/ckeditor5-utils/tests/document/range.js
  48. 0 42
      packages/ckeditor5-utils/tests/document/rootelement.js
  49. 0 31
      packages/ckeditor5-utils/tests/document/text.js
  50. 0 82
      packages/ckeditor5-utils/tests/document/transaction.js
  51. 2 2
      packages/ckeditor5-utils/tests/utils/utils.js

+ 0 - 125
packages/ckeditor5-utils/src/document/attribute.js

@@ -1,125 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [ 'utils' ], ( utils ) => {
-	/**
-	 * Attributes can store any additional information for nodes in the data model.
-	 *
-	 * @class document.Attribute
-	 */
-	class Attribute {
-		/**
-		 * Creates a new instance of the `Attribute` class. Once attribute is created it is immutable.
-		 *
-		 * @param {String} key Attribute key.
-		 * @param {Mixed} value Attribute value.
-		 * @constructor
-		 */
-		constructor( key, value ) {
-			/**
-			 * Attribute key.
-			 *
-			 * @readonly
-			 * @property {String} key
-			 */
-			this.key = key;
-
-			/**
-			 * Attribute value. Note that value may be any type, including objects.
-			 *
-			 * @readonly
-			 * @property {Mixed} value
-			 */
-			this.value = value;
-
-			/**
-			 * Attribute hash. Used to compare attributes. Two attributes with the same key and value will have the same hash.
-			 *
-			 * @readonly
-			 * @private
-			 * @property {String} _hash
-			 */
-			this._hash = this.key + ': ' + JSON.stringify( this.value, sort );
-
-			// If attribute is already registered the registered one should be returned.
-			if ( Attribute._register[ this._hash ] ) {
-				return Attribute._register[ this._hash ];
-			}
-
-			// We do not care about the order, so collections with the same elements should return the same hash.
-			function sort( key, value ) {
-				if ( !utils.isArray( value ) && utils.isObject( value ) ) {
-					const sorted = {};
-
-					// Sort keys and fill up the sorted object.
-					Object.keys( value ).sort().forEach( ( key ) => {
-						sorted[ key ] = value[ key ];
-					} );
-
-					return sorted;
-				} else {
-					return value;
-				}
-			}
-		}
-
-		/**
-		 * Compares two attributes. Returns `true` if two attributes have the same key and value even if the order of keys
-		 * in the value object is different.
-		 *
-		 *		let attr1 = new Attribute( 'foo', { a: 1, b: 2 } );
-		 *		let attr2 = new Attribute( 'foo', { b: 2, a: 1 } );
-		 *		attr1.isEqual( attr2 ); // true
-		 *
-		 * @param {document.Attribute} otherAttr Attribute to compare with.
-		 * @returns {Boolean} True if attributes are equal to each other.
-		 */
-		isEqual( otherAttr ) {
-			return this._hash === otherAttr._hash;
-		}
-
-		/**
-		 * To save memory, commonly used attributes may be registered. If an attribute is registered the constructor will
-		 * always return the same instance of this attribute.
-		 *
-		 * Note that attributes are registered globally.
-		 *
-		 *		let attr1 = Attribute.register( 'bold', true );
-		 *		let attr2 = Attribute.register( 'bold', true );
-		 *		let attr3 = new Attribute( 'bold', true );
-		 *		attr1 === attr2 // true
-		 *		attr1 === attr3 // true
-		 *
-		 * @static
-		 * @param {String} key Attribute key.
-		 * @param {Mixed} value Attribute value.
-		 * @returns {document.Attribute} Registered attribute.
-		 */
-		static register( key, value ) {
-			const attr = new Attribute( key, value );
-
-			if ( this._register[ attr._hash ] ) {
-				return this._register[ attr._hash ];
-			} else {
-				this._register[ attr._hash ] = attr;
-
-				return attr;
-			}
-		}
-	}
-
-	/**
-	 * Register of attributes in which all registered attributes are stored.
-	 *
-	 * @static
-	 * @private
-	 * @property {String} _hash
-	 */
-	Attribute._register = {};
-
-	return Attribute;
-} );

+ 0 - 36
packages/ckeditor5-utils/src/document/character.js

@@ -1,36 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [ 'document/node' ], ( Node ) => {
-	/**
-	 * Data structure for character stored in the tree data model.
-	 *
-	 * @class Character
-	 */
-	class Character extends Node {
-		/**
-		 * Creates character linear item.
-		 *
-		 * @param {String} character Described character.
-		 * @param {Iterable} attrs Iterable collection of {@link document.Attribute attributes}.
-		 * @constructor
-		 */
-		constructor( character, attrs ) {
-			super( attrs );
-
-			/**
-			 * Described character.
-			 *
-			 * @readonly
-			 * @property {String} character
-			 */
-			this.character = character;
-		}
-	}
-
-	return Character;
-} );

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

@@ -1,155 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [
-	'document/delta/delta',
-	'document/delta/register',
-	'document/operation/changeoperation',
-	'document/position',
-	'document/range',
-	'document/attribute',
-	'document/element'
-], ( Delta, register, ChangeOperation, Position, Range, Attribute, Element ) => {
-	/**
-	 * To provide specific OT behavior and better collisions solving, change methods ({@link document.Transaction#setAttr}
-	 * and {@link document.Transaction#removeAttr}) use `ChangeDelta` class which inherits from the `Delta` class and may
-	 * overwrite some methods.
-	 *
-	 * @class document.delta.ChangeDelta
-	 */
-	class ChangeDelta extends Delta {}
-
-	/**
-	 * Sets the value of the attribute of the node or on the range.
-	 *
-	 * @chainable
-	 * @method setAttr
-	 * @memberOf document.Transaction
-	 * @param {String} key Attribute key.
-	 * @param {Mixed} value Attribute new value.
-	 * @param {document.Node|document.Range} nodeOrRange Node or range on which the attribute will be set.
-	 */
-	register( 'setAttr', function( key, value, nodeOrRange ) {
-		change( this, key, value, nodeOrRange );
-
-		return this;
-	} );
-
-	/**
-	 * Removes an attribute from the range.
-	 *
-	 * @chainable
-	 * @method removeAttr
-	 * @memberOf document.Transaction
-	 * @param {String} key Attribute key.
-	 * @param {document.Node|document.Range} nodeOrRange Node or range on which the attribute will be removed.
-	 */
-	register( 'removeAttr', function( key, nodeOrRange ) {
-		change( this, key, null, nodeOrRange );
-
-		return this;
-	} );
-
-	function change( transaction, key, value, nodeOrRange ) {
-		const delta = new ChangeDelta();
-
-		if ( nodeOrRange instanceof Range ) {
-			changeRange( transaction.doc, delta, key, value, nodeOrRange );
-		} else {
-			changeNode( transaction.doc, delta, key, value, nodeOrRange );
-		}
-
-		transaction.addDelta( delta );
-	}
-
-	function changeNode( doc, delta, key, value, node ) {
-		const previousValue = node.getAttr( key );
-		let range;
-
-		if ( previousValue != value ) {
-			if ( node instanceof Element ) {
-				// If we change the attribute of the element, we do not want to change attributes of its children, so
-				// the end on the range can not be put after the closing tag, it should be inside that element with the
-				// offset 0, so the range will contains only the opening tag...
-				range = new Range( Position.createBefore( node ), Position.createFromParentAndOffset( node, 0 ) );
-			} else {
-				// ...but for characters we can not put the range inside it, so we end the range after that character.
-				range = new Range( Position.createBefore( node ), Position.createAfter( node ) );
-			}
-
-			const operation = new ChangeOperation(
-					range,
-					previousValue ? new Attribute( key, previousValue ) : null,
-					value ? new Attribute( key, value ) : null,
-					doc.version
-				);
-
-			doc.applyOperation( operation );
-			delta.addOperation( operation );
-		}
-	}
-
-	// Because change operation needs to have the same attribute value on the whole range, this function split the range
-	// into smaller parts.
-	function changeRange( doc, delta, key, value, range ) {
-		// Position of the last split, the beginning of the new range.
-		let lastSplitPosition = range.start;
-
-		// Currently position in the scanning range. Because we need value after the position, it is not a current
-		// position of the iterator but the previous one (we need to iterate one more time to get the value after).
-		let position;
-		// Value before the currently position.
-		let valueBefore;
-		// Value after the currently position.
-		let valueAfter;
-
-		// Because we need not only a node, but also a position, we can not use ( value of range ).
-		const iterator = range[ Symbol.iterator ]();
-		// Iterator state.
-		let next = iterator.next();
-
-		while ( !next.done ) {
-			valueAfter = next.value.node.getAttr( key );
-
-			// At the first run of the iterator the position in undefined. We also do not have a valueBefore, but
-			// because valueAfter may be null, valueBefore may be equal valueAfter ( undefined == null ).
-			if ( position && valueBefore != valueAfter ) {
-				// if valueBefore == value there is nothing to change, so we add operation only if these values are different.
-				if ( valueBefore != value ) {
-					addOperation();
-				}
-
-				lastSplitPosition = position;
-			}
-
-			position = iterator.position;
-			valueBefore = valueAfter;
-
-			next = iterator.next();
-		}
-
-		// Because position in the loop is not the iterator position (see let position comment), the last position in
-		// the while loop will be last but one position in the range. We need to check the last position manually.
-		if ( position != lastSplitPosition && valueBefore != value ) {
-			addOperation();
-		}
-
-		function addOperation() {
-			const operation = new ChangeOperation(
-					new Range( lastSplitPosition, position ),
-					valueBefore ? new Attribute( key, valueBefore ) : null,
-					value ? new Attribute( key, value ) : null,
-					doc.version
-				);
-
-			doc.applyOperation( operation );
-			delta.addOperation( operation );
-		}
-	}
-
-	return ChangeDelta;
-} );

+ 0 - 58
packages/ckeditor5-utils/src/document/delta/delta.js

@@ -1,58 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [], () => {
-	/**
-	 * Base class for all deltas.
-	 *
-	 * Delta is a single, from the user action point of view, change in the editable document, like insert, split or
-	 * rename element. Delta is composed of operations, which are unit changes needed to be done to execute user action.
-	 *
-	 * Multiple deltas are grouped into a single {@link document.Transaction}.
-	 *
-	 * @class document.delta.Delta
-	 */
-	class Delta {
-		/**
-		 * Creates a delta instance.
-		 *
-		 * @constructor
-		 */
-		constructor() {
-			/**
-			 * {@link document.Transaction} which delta is a part of. This property is null by default and set by the
-			 * {@link Document.Transaction#addDelta} method.
-			 *
-			 * @readonly
-			 * @type {document.Transaction}
-			 */
-			this.transaction = null;
-
-			/**
-			 * Array of operations which compose delta.
-			 *
-			 * @readonly
-			 * @type {document.operation.Operation[]}
-			 */
-			this.operations = [];
-		}
-
-		/**
-		 * Add operation to the delta.
-		 *
-		 * @param {document.operation.Operation} operation Operation instance.
-		 */
-		addOperation( operation ) {
-			operation.delta = this;
-			this.operations.push( operation );
-
-			return operation;
-		}
-	}
-
-	return Delta;
-} );

+ 0 - 44
packages/ckeditor5-utils/src/document/delta/insertdelta.js

@@ -1,44 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [
-	'document/delta/delta',
-	'document/delta/register',
-	'document/operation/insertoperation'
-], ( Delta, register, InsertOperation ) => {
-	/**
-	 * To provide specific OT behavior and better collisions solving, the {@link document.Transaction#insert} method
-	 * uses the `InsertDelta` class which inherits from the `Delta` class and may overwrite some methods.
-	 *
-	 * @class document.delta.InsertDelta
-	 */
-	class InsertDelta extends Delta {}
-
-	/**
-	 * Inserts a node or nodes at the given position.
-	 *
-	 * @chainable
-	 * @memberOf document.Transaction
-	 * @method insert
-	 * @param {document.Position} position Position of insertion.
-	 * @param {document.Node|document.Text|document.NodeList|String|Iterable} nodes The list of nodes to be inserted.
-	 * List of nodes can be of any type accepted by the {@link document.NodeList} constructor.
-	 */
-	register( 'insert', function( position, nodes ) {
-		const delta = new InsertDelta();
-
-		const operation = new InsertOperation( position, nodes, this.doc.version );
-		this.doc.applyOperation( operation );
-		delta.addOperation( operation );
-
-		this.addDelta( delta );
-
-		return this;
-	} );
-
-	return InsertDelta;
-} );

+ 0 - 78
packages/ckeditor5-utils/src/document/delta/mergedelta.js

@@ -1,78 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [
-	'document/delta/delta',
-	'document/delta/register',
-	'document/position',
-	'document/element',
-	'document/operation/removeoperation',
-	'document/operation/moveoperation',
-	'ckeditorerror'
-], ( Delta, register, Position, Element, RemoveOperation, MoveOperation, CKEditorError ) => {
-	/**
-	 * To provide specific OT behavior and better collisions solving, {@link document.Transaction#merge} method
-	 * uses the `MergeDelta` class which inherits from the `Delta` class and may overwrite some methods.
-	 *
-	 * @class document.delta.MergeDelta
-	 */
-	class MergeDelta extends Delta {}
-
-	/**
-	 * Merges two siblings at the given position.
-	 *
-	 * Node before and after the position have to be an element. Otherwise `transaction-merge-no-element-before` or
-	 * `transaction-merge-no-element-after` error will be thrown.
-	 *
-	 * @chainable
-	 * @method merge
-	 * @memberOf document.Transaction
-	 * @param {document.Position} position Position of merge.
-	 */
-	register( 'merge', function( position ) {
-		const delta = new MergeDelta();
-		const nodeBefore = position.nodeBefore;
-		const nodeAfter = position.nodeAfter;
-
-		if ( !( nodeBefore instanceof Element ) ) {
-			/**
-			 * Node before merge position must be an element.
-			 *
-			 * @error transaction-merge-no-element-before
-			 */
-			throw new CKEditorError(
-				'transaction-merge-no-element-before: Node before merge position must be an element.' );
-		}
-
-		if ( !( nodeAfter instanceof Element ) ) {
-			/**
-			 * Node after merge position must be an element.
-			 *
-			 * @error transaction-merge-no-element-after
-			 */
-			throw new CKEditorError(
-				'transaction-merge-no-element-after: Node after merge position must be an element.' );
-		}
-
-		const positionAfter = Position.createFromParentAndOffset( nodeAfter, 0 );
-		const positionBefore = Position.createFromParentAndOffset( nodeBefore, nodeBefore.getChildCount() );
-
-		const move = new MoveOperation( positionAfter, positionBefore, nodeAfter.getChildCount(), this.doc.version );
-		this.doc.applyOperation( move );
-		delta.addOperation( move );
-
-		const remove = new RemoveOperation( position, 1, this.doc.version );
-		this.doc.applyOperation( remove );
-		delta.addOperation( remove );
-
-		this.addDelta( delta );
-
-		return this;
-	} );
-
-	return MergeDelta;
-} );

+ 0 - 14
packages/ckeditor5-utils/src/document/delta/register.js

@@ -1,14 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-// Register method exposed for deltas, which needs only this method, to make code simpler, more beautiful and, first of
-// all, to solve circular dependencies.
-CKEDITOR.define( [
-	'document/delta/transaction-base'
-], ( Transaction ) => {
-	return Transaction.register;
-} );

+ 0 - 47
packages/ckeditor5-utils/src/document/delta/removedelta.js

@@ -1,47 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [
-	'document/delta/delta',
-	'document/delta/register',
-	'document/operation/removeoperation'
-], ( Delta, register, RemoveOperation ) => {
-	/**
-	 * To provide specific OT behavior and better collisions solving, {@link document.Transaction#remove} method
-	 * uses the `RemoveDelta` class which inherits from the `Delta` class and may overwrite some methods.
-	 *
-	 * @class document.delta.RemoveDelta
-	 */
-	class RemoveDelta extends Delta {}
-
-	/**
-	 * Removes nodes starting from the given position.
-	 *
-	 * @chainable
-	 * @method remove
-	 * @memberOf document.Transaction
-	 * @param {document.Position} position Position before the first node to remove.
-	 * @param {Number} howMany How many nodes to remove.
-	 */
-	register( 'remove', function( position, howMany ) {
-		if ( typeof howMany !== 'number' ) {
-			howMany = 1;
-		}
-
-		const delta = new RemoveDelta();
-
-		const operation = new RemoveOperation( position, howMany, this.doc.version );
-		this.doc.applyOperation( operation );
-		delta.addOperation( operation );
-
-		this.addDelta( delta );
-
-		return this;
-	} );
-
-	return RemoveDelta;
-} );

+ 0 - 71
packages/ckeditor5-utils/src/document/delta/splitdelta.js

@@ -1,71 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [
-	'document/delta/delta',
-	'document/delta/register',
-	'document/position',
-	'document/element',
-	'document/operation/insertoperation',
-	'document/operation/moveoperation',
-	'ckeditorerror'
-], ( Delta, register, Position, Element, InsertOperation, MoveOperation, CKEditorError ) => {
-	/**
-	 * To provide specific OT behavior and better collisions solving, the {@link document.Transaction#split} method
-	 * uses `SplitDelta` class which inherits from the `Delta` class and may overwrite some methods.
-	 *
-	 * @class document.delta.SplitDelta
-	 */
-	class SplitDelta extends Delta {}
-
-	/**
-	 * Splits a node at the given position.
-	 *
-	 * This cannot be a position inside the root element. The `transaction-split-root` error will be thrown if
-	 * you try to split the root element.
-	 *
-	 * @chainable
-	 * @method split
-	 * @memberOf document.Transaction
-	 * @param {document.Position} position Position of split.
-	 */
-	register( 'split', function( position ) {
-		const delta = new SplitDelta();
-		const splitElement = position.parent;
-
-		if ( !splitElement.parent ) {
-			/**
-			 * Root element can not be split.
-			 *
-			 * @error transaction-split-root
-			 */
-			throw new CKEditorError( 'transaction-split-root: Root element can not be split.' );
-		}
-
-		const copy = new Element( splitElement.name, splitElement.getAttrs() );
-		const insert = new InsertOperation( Position.createAfter( splitElement ), copy, this.doc.version );
-
-		this.doc.applyOperation( insert );
-		delta.addOperation( insert );
-
-		const move = new MoveOperation(
-			position,
-			Position.createFromParentAndOffset( copy, 0 ),
-			splitElement.getChildCount() - position.offset,
-			this.doc.version
-		);
-
-		this.doc.applyOperation( move );
-		delta.addOperation( move );
-
-		this.addDelta( delta );
-
-		return this;
-	} );
-
-	return SplitDelta;
-} );

+ 0 - 124
packages/ckeditor5-utils/src/document/delta/transaction-base.js

@@ -1,124 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [ 'ckeditorerror' ], ( CKEditorError ) => {
-	/**
-	 * The transaction class groups document changes (deltas). All deltas grouped in a single transactions can be
-	 * reverted together, so you can think about the transaction as a single undo step. If you want to extend one
-	 * undo step you can call another method on the same transaction object. If you want to create a separate undo step
-	 * you can create a new transaction.
-	 *
-	 * For example to create two separate undo steps you can call:
-	 *
-	 *		doc.createTransaction().insert( firstPosition, 'foo' );
-	 *		doc.createTransaction().insert( secondPosition, 'bar' );
-	 *
-	 * To create a single undo step:
-	 *
-	 *		const transaction = doc.createTransaction()
-	 *		transaction.insert( firstPosition, 'foo' );
-	 *		transaction.insert( secontPosition, 'bar' );
-	 *
-	 * Note that all document modification methods (insert, remove, split, etc.) are chainable so you can shorten code to:
-	 *
-	 *		doc.createTransaction().insert( firstPosition, 'foo' ).insert( secontPosition, 'bar' );
-	 *
-	 * @class document.Transaction
-	 */
-	class Transaction {
-		/**
-		 * Creates transaction instance. Not recommended to use directly, use {@link document.Document#createTransaction}
-		 * instead.
-		 *
-		 * @constructor
-		 * @param {document.Document} doc Document which this transaction changes.
-		 */
-		constructor( doc ) {
-			/**
-			 * Document which this transaction changes.
-			 *
-			 * @readonly
-			 * @type {document.Document}
-			 */
-			this.doc = doc;
-
-			/**
-			 * Array of deltas which compose transaction.
-			 *
-			 * @readonly
-			 * @type {document.delta.Delta[]}
-			 */
-			this.deltas = [];
-		}
-
-		/**
-		 * Adds delta to the transaction instance. All modification methods (insert, remove, split, etc.) use this method
-		 * to add created deltas.
-		 *
-		 * @param {document.delta.Delta} delta Delta to add.
-		 * @return {document.delta.Delta} Added delta.
-		 */
-		addDelta( delta ) {
-			delta.transaction = this;
-			this.deltas.push( delta );
-
-			return delta;
-		}
-
-		/**
-		 * Static method to register transaction methods. To make code scalable transaction do not have modification
-		 * methods built in. They can be registered using this method.
-		 *
-		 * This method checks if there is no naming collision and throw `transaction-register-taken` if the method name
-		 * is already taken.
-		 *
-		 * Beside that no magic happens here, the method is added to the `Transaction` class prototype.
-		 *
-		 * For example:
-		 *
-		 *		Transaction.register( 'insert', function( position, nodes ) {
-		 *			// You can use a class inherit from Delta if that class should handle OT in the special way.
-		 *			const delta = new Delta();
-		 *
-		 * 			// Create operations which should be components of this delta.
-		 *			const operation = new InsertOperation( position, nodes, this.doc.version );
-		 *
-		 *			// Remember to apply every operation, no magic, you need to do it manually.
-		 *			this.doc.applyOperation( operation );
-		 *
-		 *			// Add operation to the delta.
-		 *			delta.addOperation( operation );
-		 *
-		 *			// Add delta to the transaction instance.
-		 *			this.addDelta( delta );
-		 *
-		 * 			// Make this method chainable.
-		 * 			return this;
-		 *		} );
-		 *
-		 * @param {String} name Method name.
-		 * @param {Fuction} creator Method body.
-		 */
-		static register( name, creator ) {
-			if ( Transaction.prototype[ name ] ) {
-				/**
-				 * This transaction method is already taken.
-				 *
-				 * @error transaction-register-taken
-				 * @param {String} name
-				 */
-				throw new CKEditorError(
-					'transaction-register-taken: This transaction method is already taken.',
-					{ name: name } );
-			}
-
-			Transaction.prototype[ name ] = creator;
-		}
-	}
-
-	return Transaction;
-} );

+ 0 - 159
packages/ckeditor5-utils/src/document/document.js

@@ -1,159 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [
-	'document/element',
-	'document/rootelement',
-	'document/transaction',
-	'emittermixin',
-	'utils',
-	'ckeditorerror'
-], ( Element, RootElement, Tranaction, EmitterMixin, utils, CKEditorError ) => {
-	const graveyardSymbol = Symbol( 'graveyard' );
-
-	/**
-	 * Document tree model describes all editable data in the editor. It may contain multiple {@link #roots root elements},
-	 * for example if the editor have multiple editable areas, each area will be represented by the separate root.
-	 *
-	 * All changes in the document are done by {@link document.operation.Operation operations}. To create operations in
-	 * the simple way use use the {@link document.Transaction transaction} API, for example:
-	 *
-	 *		document.createTransaction().insert( position, nodes ).split( otherPosition );
-	 *
-	 * @see #createTransaction
-	 *
-	 * @class document.Document
-	 */
-	class Document {
-		/**
-		 * Creates an empty document instance with no {@link #roots}.
-		 *
-		 * @constructor
-		 */
-		constructor() {
-			/**
-			 * List of roots that are owned and managed by this document.
-			 *
-			 * @readonly
-			 * @property {Map} roots
-			 */
-			this.roots = new Map();
-
-			// Graveyard tree root. Document always have a graveyard root, which stores removed nodes.
-			this.createRoot( graveyardSymbol );
-
-			/**
-			 * Document version. It starts from `0` and every operation increases the version number. It is used to ensure that
-			 * operations are applied on the proper document version. If the {@link document.operation.Operation#baseVersion} will
-			 * not match document version the {@link document-applyOperation-wrong-version} error is thrown.
-			 *
-			 * @readonly
-			 * @property {Number} version
-			 */
-			this.version = 0;
-		}
-
-		/**
-		 * This is the entry point for all document changes. All changes on the document are done using
-		 * {@link document.operation.Operation operations}. To create operations in the simple way use the
-		 * {@link document.Transaction} API available via {@link #createTransaction} method.
-		 *
-		 * @param {document.operation.Operation} operation Operation to be applied.
-		 */
-		applyOperation( operation ) {
-			if ( operation.baseVersion !== this.version ) {
-				/**
-				 * Only operations with matching versions can be applied.
-				 *
-				 * @error document-applyOperation-wrong-version
-				 * @param {document.operation.Operation} operation
-				 */
-				throw new CKEditorError(
-					'document-applyOperation-wrong-version: Only operations with matching versions can be applied.',
-					{ operation: operation } );
-			}
-
-			operation._execute();
-			this.version++;
-			this.fire( 'operationApplied', operation );
-		}
-
-		/**
-		 * Creates a new top-level root.
-		 *
-		 * @param {String|Symbol} name Unique root name.
-		 * @returns {document.RootElement} Created root.
-		 */
-		createRoot( name ) {
-			if ( this.roots.has( name ) ) {
-				/**
-				 * Root with specified name already exists.
-				 *
-				 * @error document-createRoot-name-exists
-				 * @param {document.Document} doc
-				 * @param {String} name
-				 */
-				throw new CKEditorError(
-					'document-createRoot-name-exists: Root with specified name already exists.',
-					{ name: name }
-				);
-			}
-
-			const root = new RootElement( this );
-			this.roots.set( name, root );
-
-			return root;
-		}
-
-		/**
-		 * Returns top-level root by it's name.
-		 *
-		 * @param {String|Symbol} name Name of the root to get.
-		 * @returns (document.RootElement} Root registered under given name.
-		 */
-		getRoot( name ) {
-			if ( !this.roots.has( name ) ) {
-				/**
-				 * Root with specified name does not exist.
-				 *
-				 * @error document-createRoot-root-not-exist
-				 * @param {String} name
-				 */
-				throw new CKEditorError(
-					'document-createRoot-root-not-exist: Root with specified name does not exist.',
-					{ name: name }
-				);
-			}
-
-			return this.roots.get( name );
-		}
-
-		/**
-		 * Graveyard tree root. Document always have a graveyard root, which stores removed nodes.
-		 *
-		 * @protected
-		 * @readonly
-		 * @property {document.RootElement} _graveyard
-		 */
-		get _graveyard() {
-			return this.getRoot( graveyardSymbol );
-		}
-
-		/**
-		 * Creates a {@link document.Transaction} instance which allows to change the document.
-		 *
-		 * @returns {document.Transaction} Transaction instance.
-		 */
-		createTransaction() {
-			return new Tranaction( this );
-		}
-	}
-
-	utils.extend( Document.prototype, EmitterMixin );
-
-	return Document;
-} );

+ 0 - 123
packages/ckeditor5-utils/src/document/element.js

@@ -1,123 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [
-	'document/node',
-	'document/nodelist',
-	'document/range',
-	'document/position'
-], ( Node, NodeList ) => {
-	/**
-	 * Tree data model element.
-	 *
-	 * @class document.Element
-	 */
-	class Element extends Node {
-		/**
-		 * Creates a tree data model element.
-		 *
-		 * This constructor should be used only internally by the document.
-		 *
-		 * @param {String} name Node name.
-		 * @param {Iterable} attrs Iterable collection of {@link document.Attribute attributes}.
-		 * @param {document.Node|document.Text|document.NodeList|String|Iterable} children List of nodes to be inserted
-		 * into created element. List of nodes can be of any type accepted by the {@link document.NodeList} constructor.
-		 * @constructor
-		 */
-		constructor( name, attrs, children ) {
-			super( attrs );
-
-			/**
-			 * Element name.
-			 *
-			 * @readonly
-			 * @property {String} name
-			 */
-			this.name = name;
-
-			/**
-			 * List of children nodes.
-			 *
-			 * @protected
-			 * @property {document.NodeList} _children
-			 */
-			this._children = new NodeList();
-
-			if ( children ) {
-				this.insertChildren( 0, children );
-			}
-		}
-
-		/**
-		 * Inserts a list of child nodes on the given index and sets the parent of these nodes to this element.
-		 *
-		 * Note that the list of children can be modified only in elements not yet attached to the document.
-		 * All attached nodes should be modified using the {@link document.operation.InsertOperation}.
-		 *
-		 * @param {Number} index Position where nodes should be inserted.
-		 * @param {document.Node|document.Text|document.NodeList|String|Iterable} nodes The list of nodes to be inserted.
-		 * The list of nodes can be of any type accepted by the {@link document.NodeList} constructor.
-		 */
-		insertChildren( index, nodes ) {
-			this._children.insert( index, new NodeList( nodes ) );
-
-			for ( let node of this._children ) {
-				node.parent = this;
-			}
-		}
-
-		/**
-		 * Removes number of child nodes starting at the given index and set the parent of these nodes to `null`.
-		 *
-		 * Note that the list of children can be modified only in elements not yet attached to the document.
-		 * All attached nodes should be modified using the {@link document.operation.RemoveOperation}.
-		 *
-		 * @param {Number} index Position of the first node to remove.
-		 * @param {Number} number Number of nodes to remove.
-		 * @returns {document.NodeList} The list of removed nodes.
-		 */
-
-		removeChildren( index, number ) {
-			for ( let i = index; i < index + number; i++ ) {
-				this._children.get( i ).parent = null;
-			}
-
-			return this._children.remove( index, number );
-		}
-
-		/**
-		 * Gets child at the given index.
-		 *
-		 * @param {Number} index Index of child.
-		 * @returns {document.Node} Child node.
-		 */
-		getChild( index ) {
-			return this._children.get( index );
-		}
-
-		/**
-		 * Gets index of the given child node.
-		 *
-		 * @param {document.Node} node Child node.
-		 * @returns {Number} Index of the child node.
-		 */
-		getChildIndex( node ) {
-			return this._children.indexOf( node );
-		}
-
-		/**
-		 * Gets the number of element's children.
-		 *
-		 * @returns {Number} The number of element's children.
-		 */
-		getChildCount() {
-			return this._children.length;
-		}
-	}
-
-	return Element;
-} );

+ 0 - 247
packages/ckeditor5-utils/src/document/node.js

@@ -1,247 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], ( Attribute, utils, CKEditorError ) => {
-	/**
-	 * Abstract document tree node class.
-	 *
-	 * @abstract
-	 * @class document.Node
-	 */
-	class Node {
-		/**
-		 * Creates a tree node.
-		 *
-		 * This is an abstract class, so this constructor should not be used directly.
-		 *
-		 * @param {Iterable} attrs Iterable collection of {@link document.Attribute attributes}.
-		 * @constructor
-		 */
-		constructor( attrs ) {
-			/**
-			 * Parent element. Null by default. Set by {@link document.Element#insertChildren}.
-			 *
-			 * @readonly
-			 * @property {document.Element|null} parent
-			 */
-			this.parent = null;
-
-			/**
-			 * Attributes set.
-			 *
-			 * Attributes of nodes attached to the document can be changed only be the {@link document.operation.ChangeOperation}.
-			 *
-			 * @private
-			 * @property {Set} _attrs
-			 */
-			this._attrs = new Set( attrs );
-		}
-
-		/**
-		 * Index of the node in the parent element or null if the node has no parent.
-		 *
-		 * Throws error if the parent element does not contain this node.
-		 *
-		 * @returns {Number|Null} Index of the node in the parent element or null if the node has not parent.
-		 */
-		getIndex() {
-			let pos;
-
-			if ( !this.parent ) {
-				return null;
-			}
-
-			// No parent or child doesn't exist in parent's children.
-			if ( ( pos = this.parent.getChildIndex( this ) ) == -1 ) {
-				/**
-				 * The node's parent does not contain this node. It means that the document tree is corrupted.
-				 *
-				 * @error node-not-found-in-parent
-				 */
-				throw new CKEditorError( 'node-not-found-in-parent: The node\'s parent does not contain this node.' );
-			}
-
-			return pos;
-		}
-
-		/**
-		 * Depth of the node, which equals to total number of its parents.
-		 *
-		 * @readonly
-		 * @property {Number} depth
-		 */
-		get depth() {
-			let depth = 0;
-			let parent = this.parent;
-
-			while ( parent ) {
-				depth++;
-
-				parent = parent.parent;
-			}
-
-			return depth;
-		}
-
-		/**
-		 * The top parent for the node. If node has no parent it is the root itself.
-		 *
-		 * @readonly
-		 * @property {Number} depth
-		 */
-		get root() {
-			let root = this; // jscs:ignore safeContextKeyword
-
-			while ( root.parent ) {
-				root = root.parent;
-			}
-
-			return root;
-		}
-
-		/**
-		 * Nodes next sibling or `null` if it is the last child.
-		 *
-		 * @readonly
-		 * @property {document.Node|null} nextSibling
-		 */
-		get nextSibling() {
-			const index = this.getIndex();
-
-			return ( index !== null && this.parent.getChild( index + 1 ) ) || null;
-		}
-
-		/**
-		 * Nodes previous sibling or null if it is the last child.
-		 *
-		 * @readonly
-		 * @property {document.Node|null} previousSibling
-		 */
-		get previousSibling() {
-			const index = this.getIndex();
-
-			return ( index !== null && this.parent.getChild( index - 1 ) ) || null;
-		}
-
-		/**
-		 * Returns `true` if the node contains an attribute with the same key and value as given or the same key if the
-		 * given parameter is a string.
-		 *
-		 * @param {document.Attribute|String} attr An attribute or a key to compare.
-		 * @returns {Boolean} True if node contains given attribute or an attribute with the given key.
-		 */
-		hasAttr( key ) {
-			let attr;
-
-			// Attribute.
-			if ( key instanceof Attribute ) {
-				for ( attr of this._attrs ) {
-					if ( attr.isEqual( key ) ) {
-						return true;
-					}
-				}
-			}
-			// Key.
-			else {
-				for ( attr of this._attrs ) {
-					if ( attr.key == key ) {
-						return true;
-					}
-				}
-			}
-
-			return false;
-		}
-
-		/**
-		 * Finds an attribute by a key.
-		 *
-		 * @param {String} attr The attribute key.
-		 * @returns {document.Attribute} The found attribute.
-		 */
-		getAttr( key ) {
-			for ( let attr of this._attrs ) {
-				if ( attr.key == key ) {
-					return attr.value;
-				}
-			}
-
-			return null;
-		}
-
-		/**
-		 * Removes attribute from the list of attributes.
-		 *
-		 * @param {String} key The attribute key.
-		 */
-		removeAttr( key ) {
-			for ( let attr of this._attrs ) {
-				if ( attr.key == key ) {
-					this._attrs.delete( attr );
-
-					return;
-				}
-			}
-		}
-
-		/**
-		 * Sets a given attribute. If the attribute with the same key already exists it will be removed.
-		 *
-		 * @param {document.Attribute} attr Attribute to set.
-		 */
-		setAttr( attr ) {
-			this.removeAttr( attr.key );
-
-			this._attrs.add( attr );
-		}
-
-		/**
-		 * Gets path to the node. For example if the node is the second child of the first child of the root then the path
-		 * will be `[ 1, 2 ]`. This path can be used as a parameter of {@link document.Position}.
-		 *
-		 * @returns {Number[]} The path.
-		 */
-		getPath() {
-			const path = [];
-			let node = this; // jscs:ignore safeContextKeyword
-
-			while ( node.parent ) {
-				path.unshift( node.getIndex() );
-				node = node.parent;
-			}
-
-			return path;
-		}
-
-		/**
-		 * Custom toJSON method to solve child-parent circular dependencies.
-		 *
-		 * @returns {Object} Clone of this object with the parent property replaced with its name.
-		 */
-		toJSON() {
-			const json = utils.clone( this );
-
-			// Due to circular references we need to remove parent reference.
-			json.parent = this.parent ? this.parent.name : null;
-
-			return json;
-		}
-
-		/**
-		 * Returns attribute iterator. It can be use to create a new element with the same attributes:
-		 *
-		 *		const copy = new Element( element.name, element.getAttrs() );
-		 *
-		 * @returns {Iterable.<document.Attribute>} Attribute iterator.
-		 */
-		getAttrs() {
-			return this._attrs[ Symbol.iterator ]();
-		}
-	}
-
-	return Node;
-} );

+ 0 - 156
packages/ckeditor5-utils/src/document/nodelist.js

@@ -1,156 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [
-	'document/character',
-	'document/text',
-	'document/node',
-	'utils'
-], ( Character, Text, Node, utils ) => {
-	/**
-	 * List of nodes. It is used to represent multiple nodes with a given order, for example children of
-	 * {@link document.Element} object or nodes inserted using {@link document.operation.InsertOperation}.
-	 *
-	 * Thanks to the constructor, which accepts various arguments, this class lets you easily create desired list of nodes.
-	 *
-	 * It also may internally compress nodes.
-	 *
-	 * @class document.NodeList
-	 */
-	class NodeList {
-		/**
-		 * Constructor let you create a list of nodes in many ways. See examples:
-		 *
-		 *		let nodeList = new NodeList( [ new Element( p1 ), new Element( p1 ) ] );
-		 *		nodeList.length; // 2
-		 *
-		 *		let nodeList = new NodeList( new Element( p ) );
-		 *		nodeList.length; // 1
-		 *
-		 *		let nodeList = new NodeList( [ 'foo', new Element( p ), 'bar' ] );
-		 *		nodeList.length; // 7
-		 *
-		 *		let nodeList = new NodeList( 'foo' );
-		 *		nodeList.length; // 3
-		 *
-		 *		let nodeList = new NodeList( new Text( 'foo', [ new Attribute( 'bar', 'bom' ) ] ) );
-		 *		nodeList.length; // 3
-		 *		nodeList.get( 0 ).getAttr( 'bar' ); // 'bom'
-		 *		nodeList.get( 1 ).getAttr( 'bar' ); // 'bom'
-		 *		nodeList.get( 2 ).getAttr( 'bar' ); // 'bom'
-		 *
-		 *		let nodeListA = new NodeList( 'foo' );
-		 *		let nodeListB = new NodeList( nodeListA );
-		 *		nodeListA === nodeListB // true
-		 *		nodeListB.length // 3
-		 *
-		 * @param {document.Node|document.Text|document.NodeList|String|Iterable} nodes List of nodes.
-		 * @constructor
-		 */
-		constructor( nodes ) {
-			if ( nodes instanceof NodeList ) {
-				// We do not clone anything.
-				return nodes;
-			}
-
-			/**
-			 * Internal array to store nodes.
-			 *
-			 * @private
-			 * @property {Array}
-			 */
-			this._nodes = [];
-
-			if ( nodes ) {
-				let node, character;
-
-				if ( !utils.isIterable( nodes ) ) {
-					nodes = [ nodes ];
-				}
-
-				for ( node of nodes ) {
-					// Node.
-					if ( node instanceof Node ) {
-						this._nodes.push( node );
-					}
-					// Text.
-					else if ( node instanceof Text ) {
-						for ( character of node.text ) {
-							this._nodes.push( new Character( character, node.attrs ) );
-						}
-					}
-					// String.
-					else {
-						for ( character of node ) {
-							this._nodes.push( new Character( character ) );
-						}
-					}
-				}
-			}
-		}
-
-		/**
-		 * Returns node at the given index.
-		 *
-		 * @param {Number} index Node index.
-		 * @returns {document.Node} Node at given index.
-		 */
-		get( index ) {
-			return this._nodes[ index ];
-		}
-
-		/**
-		 * Inserts nodes from the given node list into this node list at the given index.
-		 *
-		 * @param {Number} index Position where nodes should be inserted.
-		 * @param {document.NodeList} nodeList List of nodes to insert.
-		 */
-		insert( index, nodeList ) {
-			this._nodes.splice.apply( this._nodes, [ index, 0 ].concat( nodeList._nodes ) );
-		}
-
-		/**
-		 * Removes number of nodes starting at the given index.
-		 *
-		 * @param {Number} index Position of the first node to remove.
-		 * @param {Number} number Number of nodes to remove.
-		 * @returns {document.NodeList} List of removed nodes.
-		 */
-		remove( index, number ) {
-			return new NodeList( this._nodes.splice( index, number ) );
-		}
-
-		/**
-		 * Search for the node in the node list.
-		 *
-		 * @param {document.Node} node Node to find.
-		 * @returns {Number} Position of the node in the list.
-		 */
-		indexOf( node ) {
-			return this._nodes.indexOf( node );
-		}
-
-		/**
-		 * Number of nodes in the node list.
-		 *
-		 * @readonly
-		 * @property {Number} length
-		 */
-		get length() {
-			return this._nodes.length;
-		}
-
-		/**
-		 * Node list iterator.
-		 */
-		[ Symbol.iterator ]() {
-			return this._nodes[ Symbol.iterator ]();
-		}
-	}
-
-	return NodeList;
-} );

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

@@ -1,130 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [ 'document/operation/operation', 'ckeditorerror' ], ( Operation, CKEditorError ) => {
-	/**
-	 * Operation to change nodes' attribute. Using this class you can add, remove or change value of the attribute.
-	 *
-	 * @class document.operation.ChangeOperation
-	 */
-	class ChangeOperation extends Operation {
-		/**
-		 * Creates a change operation.
-		 *
-		 * 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.
-		 *
-		 * If only the old attribute is set, then it will be removed. Note that this attribute must be present in all nodes in
-		 * ranges.
-		 *
-		 * If both new and old attributes are set, then the operation will change the attribute value. Note that both new and
-		 * old attributes have to have the same key and the old attribute must be present in all nodes in ranges.
-		 *
-		 * @param {document.Range} range Range on which the operation should be applied.
-		 * @param {document.Attribute|null} oldAttr Attribute to be removed. If `null`, then the operation just inserts a new attribute.
-		 * @param {document.Attribute|null} newAttr Attribute to be added. If `null`, then the operation just removes the attribute.
-		 * @param {Number} baseVersion {@link document.Document#version} on which the operation can be applied.
-		 * @constructor
-		 */
-		constructor( range, oldAttr, newAttr, baseVersion ) {
-			super( baseVersion );
-
-			/**
-			 * Range on which operation should be applied.
-			 *
-			 * @readonly
-			 * @type {document.Range}
-			 */
-			this.range = range;
-
-			/**
-			 * Old attribute to change. Set to `null` if operation inserts a new attribute.
-			 *
-			 * @readonly
-			 * @type {document.Attribute|null}
-			 */
-			this.oldAttr = oldAttr;
-
-			/**
-			 * New attribute. Set to `null` if operation removes the attribute.
-			 *
-			 * @readonly
-			 * @type {document.Attribute|null}
-			 */
-			this.newAttr = newAttr;
-		}
-
-		_execute() {
-			const oldAttr = this.oldAttr;
-			const newAttr = this.newAttr;
-			let value;
-
-			if ( oldAttr !== null && newAttr !== null && oldAttr.key != newAttr.key ) {
-				/**
-				 * Old and new attributes should have the same keys.
-				 *
-				 * @error operation-change-different-keys
-				 * @param {document.Attribute} oldAttr
-				 * @param {document.Attribute} newAttr
-				 */
-				throw new CKEditorError(
-					'operation-change-different-keys: Old and new attributes should have the same keys.',
-					{ oldAttr: oldAttr, newAttr: newAttr } );
-			}
-
-			// Remove or change.
-			if ( oldAttr !== null ) {
-				for ( value of this.range ) {
-					if ( !value.node.hasAttr( oldAttr ) ) {
-						/**
-						 * The attribute which should be removed does not exists for the given node.
-						 *
-						 * @error operation-change-no-attr-to-remove
-						 * @param {document.Node} node
-						 * @param {document.Attribute} attr
-						 */
-						throw new CKEditorError(
-							'operation-change-no-attr-to-remove: The attribute which should be removed does not exists for given node.',
-							{ node: value.node, attr: oldAttr } );
-					}
-
-					// There is no use in removing attribute if we will overwrite it later.
-					// Still it is profitable to run through the loop to check if all nodes in the range has old attribute.
-					if ( newAttr === null ) {
-						value.node.removeAttr( oldAttr.key );
-					}
-				}
-			}
-
-			// Insert or change.
-			if ( newAttr !== null ) {
-				for ( value of this.range ) {
-					if ( oldAttr === null && value.node.hasAttr( newAttr.key ) ) {
-						/**
-						 * The attribute with given key already exists for the given node.
-						 *
-						 * @error operation-change-attr-exists
-						 * @param {document.Node} node
-						 * @param {document.Attribute} attr
-						 */
-						throw new CKEditorError(
-							'operation-change-attr-exists: The attribute with given key already exists.',
-							{ node: value.node, attr: newAttr } );
-					}
-
-					value.node.setAttr( newAttr );
-				}
-			}
-		}
-
-		getReversed() {
-			return new ChangeOperation( this.range, this.newAttr, this.oldAttr, this.baseVersion + 1 );
-		}
-	}
-
-	return ChangeOperation;
-} );

+ 0 - 61
packages/ckeditor5-utils/src/document/operation/insertoperation.js

@@ -1,61 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [
-	'document/operation/operation',
-	'document/nodelist',
-	'document/operation/removeoperation'
-], ( Operation, NodeList ) => {
-	/**
-	 * Operation to insert list of nodes on the given position in the tree data model.
-	 *
-	 * @class document.operation.InsertOperation
-	 */
-	class InsertOperation extends Operation {
-		/**
-		 * Creates an insert operation.
-		 *
-		 * @param {document.Position} position Position of insertion.
-		 * @param {document.Node|document.Text|document.NodeList|String|Iterable} nodes The list of nodes to be inserted.
-		 * List of nodes can be any type accepted by the {@link document.NodeList} constructor.
-		 * @param {Number} baseVersion {@link document.Document#version} on which operation can be applied.
-		 * @constructor
-		 */
-		constructor( position, nodes, baseVersion ) {
-			super( baseVersion );
-
-			/**
-			 * Position of insertion.
-			 *
-			 * @readonly
-			 * @type {document.Position}
-			 */
-			this.position = position;
-
-			/**
-			 * List of nodes to insert.
-			 *
-			 * @readonly
-			 * @type {document.NodeList}
-			 */
-			this.nodeList = new NodeList( nodes );
-		}
-
-		_execute() {
-			this.position.parent.insertChildren( this.position.offset, this.nodeList );
-		}
-
-		getReversed() {
-			// Because of circular dependencies we need to re-require remove operation here.
-			const RemoveOperation = CKEDITOR.require( 'document/operation/removeoperation' );
-
-			return new RemoveOperation( this.position, this.nodeList.length, this.baseVersion + 1 );
-		}
-	}
-
-	return InsertOperation;
-} );

+ 0 - 128
packages/ckeditor5-utils/src/document/operation/moveoperation.js

@@ -1,128 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [
-	'document/operation/operation',
-	'document/nodelist',
-	'ckeditorerror',
-	'utils'
-], ( Operation, NodeList, CKEditorError, utils ) => {
-	/**
-	 * Operation to move list of subsequent nodes from one position in the document to another.
-	 *
-	 * @class document.operation.MoveOperation
-	 */
-	class MoveOperation extends Operation {
-		/**
-		 * Creates a move operation.
-		 *
-		 * @param {document.Position} sourcePosition Position before the first element to move.
-		 * @param {document.Position} targetPosition Position where moved elements will be inserted.
-		 * @param {Number} howMany How many consecutive nodes to move, starting from `sourcePosition`.
-		 * @param {Number} baseVersion {@link document.Document#version} on which operation can be applied.
-		 * @constructor
-		 */
-		constructor( sourcePosition, targetPosition, howMany, baseVersion ) {
-			super( baseVersion );
-
-			/**
-			 * Source move position.
-			 *
-			 * @type {document.Position}
-			 */
-			this.sourcePosition = sourcePosition;
-
-			/**
-			 * Target move position.
-			 *
-			 * @type {document.Position}
-			 */
-			this.targetPosition = targetPosition;
-
-			/**
-			 * How many nodes to move.
-			 *
-			 * @type {Number}
-			 */
-			this.howMany = howMany;
-		}
-
-		_execute() {
-			let sourceElement = this.sourcePosition.parent;
-			let targetElement = this.targetPosition.parent;
-			let sourceOffset = this.sourcePosition.offset;
-			let targetOffset = this.targetPosition.offset;
-
-			// Validate whether move operation has correct parameters.
-			// Validation is pretty complex but move operation is one of the core ways to manipulate the document state.
-			// We expect that many errors might be connected with one of scenarios described below.
-			if ( !sourceElement || !targetElement ) {
-				/**
-				 * Source position or target position is invalid.
-				 *
-				 * @error operation-move-position-invalid
-				 */
-				throw new CKEditorError(
-					'operation-move-position-invalid: Source position or target position is invalid.'
-				);
-			} else if ( sourceOffset + this.howMany > sourceElement.getChildCount() ) {
-				/**
-				 * The nodes which should be moved do not exist.
-				 *
-				 * @error operation-move-nodes-do-not-exist
-				 */
-				throw new CKEditorError(
-					'operation-move-nodes-do-not-exist: The nodes which should be moved do not exist.'
-				);
-			} else if ( sourceElement === targetElement && sourceOffset <= targetOffset && targetOffset < sourceOffset + this.howMany ) {
-				/**
-				 * Trying to move a range of nodes into the middle of that range.
-				 *
-				 * @error operation-move-range-into-itself
-				 */
-				throw new CKEditorError(
-					'operation-move-range-into-itself: Trying to move a range of nodes to the inside of that range.'
-				);
-			} else {
-				const sourcePath = this.sourcePosition.getParentPath();
-				const targetPath = this.targetPosition.getParentPath();
-
-				if ( utils.compareArrays( sourcePath, targetPath ) == utils.compareArrays.PREFIX ) {
-					let i = sourcePath.length;
-
-					if ( this.targetPosition.path[ i ] >= sourceOffset && this.targetPosition.path[ i ] < sourceOffset + this.howMany ) {
-						/**
-						 * Trying to move a range of nodes into one of nodes from that range.
-						 *
-						 * @error operation-move-node-into-itself
-						 */
-						throw new CKEditorError(
-							'operation-move-node-into-itself: Trying to move a range of nodes into one of nodes from that range.'
-						);
-					}
-				}
-			}
-			// End of validation.
-
-			// If we move children in the same element and we remove elements on the position before the target we
-			// need to update a target offset.
-			if ( sourceElement === targetElement && sourceOffset < targetOffset ) {
-				targetOffset -= this.howMany;
-			}
-
-			const removedNodes = sourceElement.removeChildren( sourceOffset, this.howMany );
-
-			targetElement.insertChildren( targetOffset, removedNodes );
-		}
-
-		getReversed() {
-			return new MoveOperation( this.targetPosition, this.sourcePosition, this.howMany, this.baseVersion + 1 );
-		}
-	}
-
-	return MoveOperation;
-} );

+ 0 - 87
packages/ckeditor5-utils/src/document/operation/operation.js

@@ -1,87 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [], () => {
-	/**
-	 * Abstract base operation class.
-	 *
-	 * @abstract
-	 * @class document.operation.Operation
-	 */
-	class Operation {
-		/**
-		 * Base operation constructor.
-		 *
-		 * @param {Number} baseVersion {@link document.Document#version} on which the operation can be applied.
-		 * @constructor
-		 */
-		constructor( baseVersion ) {
-			/**
-			 * {@link document.Document#version} on which operation can be applied. If you try to
-			 * {@link document.Document#applyOperation apply} operation with different base version than the
-			 * {@link document.Document#version document version} the {@link document-applyOperation-wrong-version}
-			 * error is thrown.
-			 *
-			 * @property {Number}
-			 */
-			this.baseVersion = baseVersion;
-
-			/**
-			 * {@link Document.Delta Delta} which the operation is a part of. This property is set by the
-			 * {@link Document.Delta delta} when the operations is added to it by the
-			 * {@link Document.Delta#addOperation} method.
-			 *
-			 * @property {Document.Delta} delta
-			 */
-
-			/**
-			 * Executes the operation - modifications described by the operation attributes
-			 * will be applied to the tree model.
-			 *
-			 * @method _execute
-			 * @protected
-			 */
-
-			/**
-			 * Creates and returns a reverse operation. Reverse operation when executed right after
-			 * the original operation will bring back tree model state to the point before the original
-			 * operation execution. In other words, it reverses changes done by the original operation.
-			 *
-			 * Keep in mind that tree model state may change since executing the original operation,
-			 * so reverse operation will be "outdated". In that case you will need to
-			 * {@link #getTransformedBy transform} it by all operations that were executed after the original operation.
-			 *
-			 * @method getReversed
-			 * @returns {document.operation.Operation} Reversed operation.
-			 */
-
-			/**
-			 * Creates and returns a clone of this operation which is transformed by the given operation.
-			 * When operation is transformed its parameters may change accordingly to the operation which it is
-			 * transformed by. If the given operation applied to the tree model any modifications which are
-			 * affecting ranges/positions/nodes connected with this operation, those changes will be reflected
-			 * in the parameters of the returned operation.
-			 *
-			 * Whenever the {@link document.Document document} has different {@link document.Document#baseVersion}
-			 * than an operation you want to {@link document.Document#applyOperation apply}, you need to transform
-			 * all the operations that were executed on the {@link document.Document document} since it has
-			 * {@link document.Document#baseVersion} same as the operation (transform in the same order as those
-			 * operations were executed). This way all modifications done to the tree model will be reflected
-			 * in the operation parameters and the operation will "work" on "up-to-date" version of the tree model.
-			 *
-			 * **TODO**: So far we think that transforming one operation by another one may result in more than one
-			 * operation. This needs to be clarified in this documentation.
-			 *
-			 * @method getTransformedBy
-			 * @param {document.operation.Operation} operation Operation by which this operation will be transformed.
-			 * @returns {document.operation.Operation[]} A result of transformation of this operation by the given operation.
-			 */
-		}
-	}
-
-	return Operation;
-} );

+ 0 - 33
packages/ckeditor5-utils/src/document/operation/reinsertoperation.js

@@ -1,33 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [
-	'document/operation/moveoperation',
-	'document/operation/removeoperation'
-], ( MoveOperation ) => {
-	/**
-	 * Operation to reinsert previously removed nodes back to the non-graveyard root.
-	 * This is basically {@link document.operation.MoveOperation} but it returns
-	 * {@link document.operation.RemoveOperation} when reversed.
-	 *
-	 * With this class, we achieve two goals: by having separate classes it's easier to distinguish whether move
-	 * operation is actually a remove/reinsert operation and fire proper events. Also it
-	 * will be easier to expand if we need to change operation's behavior if it is remove/reinsert.
-	 *
-	 * @class document.operation.ReinsertOperation
-	 */
-	class ReinsertOperation extends MoveOperation {
-		getReversed() {
-			// Because of circular dependencies we need to re-require reinsert operation here.
-			const RemoveOperation = CKEDITOR.require( 'document/operation/removeoperation' );
-
-			return new RemoveOperation( this.targetPosition, this.howMany, this.baseVersion + 1 );
-		}
-	}
-
-	return ReinsertOperation;
-} );

+ 0 - 45
packages/ckeditor5-utils/src/document/operation/removeoperation.js

@@ -1,45 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [
-	'document/operation/moveoperation',
-	'document/position',
-	'document/operation/reinsertoperation'
-], ( MoveOperation, Position ) => {
-	/**
-	 * Operation to remove a range of nodes.
-	 *
-	 * @class document.operation.RemoveOperation
-	 */
-	class RemoveOperation extends MoveOperation {
-		/**
-		 * Creates a remove operation.
-		 *
-		 * @param {document.Position} position Position before the first node to remove.
-		 * @param {Number} howMany How many nodes to remove.
-		 * @param {Number} baseVersion {@link document.Document#version} on which operation can be applied.
-		 * @constructor
-		 */
-		constructor( position, howMany, baseVersion ) {
-			const graveyard = position.root.document._graveyard;
-
-			// Position in a graveyard where nodes were moved.
-			const graveyardPosition = Position.createFromParentAndOffset( graveyard, 0 );
-
-			super( position, graveyardPosition, howMany, baseVersion );
-		}
-
-		getReversed() {
-			// Because of circular dependencies we need to re-require reinsert operation here.
-			const ReinsertOperation = CKEDITOR.require( 'document/operation/reinsertoperation' );
-
-			return new ReinsertOperation( this.targetPosition, this.sourcePosition, this.howMany, this.baseVersion + 1 );
-		}
-	}
-
-	return RemoveOperation;
-} );

+ 0 - 177
packages/ckeditor5-utils/src/document/position.js

@@ -1,177 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [ 'utils', 'ckeditorerror' ], ( utils, CKEditorError ) => {
-	/**
-	 * Position in the tree. Position is always located before or after a node.
-	 * See {@link #path} property for more information.
-	 *
-	 * @class document.Position
-	 */
-	class Position {
-		/**
-		 * Creates a position.
-		 *
-		 * @param {Array} path Position path. See {@link #path} property for more information.
-		 * @param {document.Element} root Root element for the path. Note that this element can not have a parent.
-		 * @constructor
-		 */
-		constructor( path, root ) {
-			/**
-			 * Position of the node it the tree. For example:
-			 *
-			 * root
-			 *  |- p         Before: [ 0 ]       After: [ 1 ]
-			 *  |- ul        Before: [ 1 ]       After: [ 2 ]
-			 *     |- li     Before: [ 1, 0 ]    After: [ 1, 1 ]
-			 *     |  |- f   Before: [ 1, 0, 0 ] After: [ 1, 0, 1 ]
-			 *     |  |- o   Before: [ 1, 0, 1 ] After: [ 1, 0, 2 ]
-			 *     |  |- o   Before: [ 1, 0, 2 ] After: [ 1, 0, 3 ]
-			 *     |- li     Before: [ 1, 1 ]    After: [ 1, 2 ]
-			 *        |- b   Before: [ 1, 1, 0 ] After: [ 1, 1, 1 ]
-			 *        |- a   Before: [ 1, 1, 1 ] After: [ 1, 1, 2 ]
-			 *        |- r   Before: [ 1, 1, 2 ] After: [ 1, 1, 3 ]
-			 *
-			 * @type {Number[]}
-			 */
-			this.path = path;
-
-			/**
-			 * Root element for the path. Note that this element can not have a parent.
-			 *
-			 * @type {document.Element}
-			 */
-			this.root = root;
-		}
-
-		/**
-		 * Parent element of the position. The position is located at {@link #offset} in this element.
-		 *
-		 * @readonly
-		 * @property {document.Element} parent
-		 */
-		get parent() {
-			let parent = this.root;
-
-			let i, len;
-
-			for ( i = 0, len = this.path.length - 1; i < len; i++ ) {
-				parent = parent.getChild( this.path[ i ] );
-			}
-
-			return parent;
-		}
-
-		/**
-		 * Offset at which the position is located in the {@link #parent}.
-		 *
-		 * @readonly
-		 * @property {Number} offset
-		 */
-		get offset() {
-			return utils.last( this.path );
-		}
-
-		/**
-		 * Node directly before the position.
-		 *
-		 * @readonly
-		 * @type {document.Node}
-		 */
-		get nodeBefore() {
-			return this.parent.getChild( this.offset - 1 ) || null;
-		}
-
-		/**
-		 * Node directly after the position.
-		 *
-		 * @readonly
-		 * @property {document.Node}
-		 */
-		get nodeAfter() {
-			return this.parent.getChild( this.offset ) || null;
-		}
-
-		/**
-		 * Two positions equal if paths are equal.
-		 *
-		 * @param {document.Position} otherPosition Position to compare.
-		 * @returns {Boolean} True if positions equal.
-		 */
-		isEqual( otherPosition ) {
-			return utils.isEqual( this.path, otherPosition.path );
-		}
-
-		/**
-		 * Returns the path to the parent, which is the {@link document.Position#path} without the last element.
-		 *
-		 * This method returns the parent path even if the parent does not exists.
-		 *
-		 * @returns {Number[]} Path to the parent.
-		 */
-		getParentPath() {
-			return this.path.slice( 0, -1 );
-		}
-
-		/**
-		 * Creates a new position from the parent element and the offset in that element.
-		 *
-		 * @param {document.Element} parent Position parent element.
-		 * @param {Number} offset Position offset.
-		 * @returns {document.Position}
-		 */
-		static createFromParentAndOffset( parent, offset ) {
-			const path = parent.getPath();
-
-			path.push( offset );
-
-			return new Position( path, parent.root );
-		}
-
-		/**
-		 * Creates a new position before the given node.
-		 *
-		 * @param {document.node} node Node the position should be directly before.
-		 * @returns {document.Position}
-		 */
-		static createBefore( node ) {
-			if ( !node.parent ) {
-				/**
-				 * You can not make position before root.
-				 *
-				 * @error position-before-root
-				 * @param {document.Node} root
-				 */
-				throw new CKEditorError( 'position-before-root: You can not make position before root.', { root: node } );
-			}
-
-			return Position.createFromParentAndOffset( node.parent, node.getIndex() );
-		}
-
-		/**
-		 * Creates a new position after given node.
-		 *
-		 * @param {document.Node} node Node the position should be directly after.
-		 * @returns {document.Position}
-		 */
-		static createAfter( node ) {
-			if ( !node.parent ) {
-				/**
-				 * You can not make position after root.
-				 *
-				 * @error position-after-root
-				 * @param {document.Node} root
-				 */
-				throw new CKEditorError( 'position-after-root: You can not make position after root.', { root: node } );
-			}
-
-			return Position.createFromParentAndOffset( node.parent, node.getIndex() + 1 );
-		}
-	}
-
-	return Position;
-} );

+ 0 - 178
packages/ckeditor5-utils/src/document/positioniterator.js

@@ -1,178 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [
-	'document/character',
-	'document/element',
-	'document/position'
-], ( Character, Element, Position ) => {
-	const ELEMENT_ENTER = 0;
-	const ELEMENT_LEAVE = 1;
-	const CHARACTER = 2;
-
-	/**
-	 * Position iterator class. It allows to iterate forward and backward over the tree document.
-	 *
-	 * @class document.PositionIterator
-	 */
-	class PositionIterator {
-		/**
-		 * Creates a range iterator.
-		 *
-		 * @param {document.Range} [boundaries] Range to define boundaries of the iterator.
-		 * @param {document.Position} [iteratorPosition] Starting position.
-		 * @constructor
-		 */
-		constructor( boundaries, iteratorPosition ) {
-			if ( boundaries instanceof Position ) {
-				this.position = boundaries;
-			} else {
-				this.boundaries =  boundaries;
-				this.position = iteratorPosition || boundaries.start;
-			}
-
-			/**
-			 * Iterator position.
-			 *
-			 * @property {document.Position} position
-			 */
-
-			/**
-			 * Iterator boundaries.
-			 *
-			 * When the {@link #next} method is called on the end boundary or the {@link #previous} method
-			 * on the start boundary, then `{ done: true }` is returned.
-			 *
-			 * If boundaries are not defined they are set before first and after last child of the root node.
-			 *
-			 * @property {document.Range} boundaries
-			 */
-		}
-
-		/**
-		 * Moves the {@link #position} to the next position and returns the enctountered value.
-		 *
-		 * @returns {Object} Value between the previous and the new {@link #position}.
-		 * @returns {Boolean} return.done True if iterator is done.
-		 * @returns {Object} return.value
-		 * @returns {Number} return.value.type Encountered value type, possible options: {@link PositionIterator#ELEMENT_ENTER},
-		 * {@link PositionIterator#ELEMENT_LEAVE} or {@link PositionIterator#CHARACTER}.
-		 * @returns {document.Node} return.value.node Encountered node.
-		 */
-		next() {
-			const position = this.position;
-			const parent = position.parent;
-
-			// Ugh... added here because of circular deps in AMD ;<.
-			Element = CKEDITOR.require( 'document/element' );
-
-			// We are at the end of the root.
-			if ( parent.parent === null && position.offset === parent.getChildCount() ) {
-				return { done: true };
-			}
-
-			if ( this.boundaries && position.isEqual( this.boundaries.end ) ) {
-				return { done: true };
-			}
-
-			const nodeAfter = position.nodeAfter;
-
-			if ( nodeAfter instanceof Element ) {
-				this.position = Position.createFromParentAndOffset( nodeAfter, 0 );
-
-				return formatReturnValue( ELEMENT_ENTER, nodeAfter );
-			} else if ( nodeAfter instanceof Character ) {
-				this.position = Position.createFromParentAndOffset( parent, position.offset + 1 );
-
-				return formatReturnValue( CHARACTER, nodeAfter );
-			} else {
-				this.position = Position.createFromParentAndOffset( parent.parent, parent.getIndex() + 1 );
-
-				return formatReturnValue( ELEMENT_LEAVE, this.position.nodeBefore );
-			}
-		}
-
-		/**
-		 * Moves the {@link #position} to the previous position and returns the encountered value.
-		 *
-		 * @returns {Object} Value between the previous and the new {@link #position}.
-		 * @returns {Boolean} return.done True if iterator is done.
-		 * @returns {Object} return.value
-		 * @returns {Number} return.value.type Encountered value type, possible options: {@link PositionIterator#ELEMENT_ENTER},
-		 * {@link PositionIterator#ELEMENT_LEAVE} or {@link PositionIterator#CHARACTER}.
-		 * @returns {document.Node} return.value.node Scanned node.
-		 */
-		previous() {
-			const position = this.position;
-			const parent = position.parent;
-
-			// We are at the beginning of the root.
-			if ( parent.parent === null && position.offset === 0 ) {
-				return { done: true };
-			}
-
-			if ( this.boundaries && position.isEqual( this.boundaries.start ) ) {
-				return { done: true };
-			}
-
-			const nodeBefore = position.nodeBefore;
-
-			if ( nodeBefore instanceof Element ) {
-				this.position = Position.createFromParentAndOffset( nodeBefore, nodeBefore.getChildCount() );
-
-				return formatReturnValue( ELEMENT_LEAVE, nodeBefore );
-			} else if ( nodeBefore instanceof Character ) {
-				this.position = Position.createFromParentAndOffset( parent, position.offset - 1 );
-
-				return formatReturnValue( CHARACTER, nodeBefore );
-			} else {
-				this.position = Position.createFromParentAndOffset( parent.parent, parent.getIndex() );
-
-				return formatReturnValue( ELEMENT_ENTER, this.position.nodeAfter );
-			}
-		}
-	}
-
-	function formatReturnValue( type, node ) {
-		return {
-			done: false,
-			value: {
-				type: type,
-				node: node
-			}
-		};
-	}
-
-	/**
-	 * Flag for entering element.
-	 *
-	 * @static
-	 * @readonly
-	 * @property {Number}
-	 */
-	PositionIterator.ELEMENT_ENTER = ELEMENT_ENTER;
-
-	/**
-	 * Flag for leaving element.
-	 *
-	 * @static
-	 * @readonly
-	 * @property {Number}
-	 */
-	PositionIterator.ELEMENT_LEAVE = ELEMENT_LEAVE;
-
-	/**
-	 * Flag for character.
-	 *
-	 * @static
-	 * @readonly
-	 * @property {Number}
-	 */
-	PositionIterator.CHARACTER = CHARACTER;
-
-	return PositionIterator;
-} );

+ 0 - 85
packages/ckeditor5-utils/src/document/range.js

@@ -1,85 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [ 'document/positioniterator', 'document/position' ], ( PositionIterator, Position ) => {
-	/**
-	 * Range class. Range is iterable.
-	 *
-	 * @class document.Range
-	 */
-	class Range {
-		/**
-		 * Creates a range.
-		 *
-		 * @param {document.Position} start Start position.
-		 * @param {document.Position} end End position.
-		 * @constructor
-		 */
-		constructor( start, end ) {
-			/**
-			 * Start position.
-			 *
-			 * @property {document.Position}
-			 */
-			this.start = start;
-
-			/**
-			 * End position.
-			 *
-			 * @property {document.Position}
-			 */
-			this.end = end;
-		}
-
-		/**
-		 * Creates a range inside an element which starts before the first child and ends after the last child.
-		 *
-		 * @param {document.Element} element Element which is a parent for the range.
-		 * @returns {document.Range} Created range.
-		 */
-		static createFromElement( element ) {
-			return Range.createFromParentsAndOffsets( element, 0, element, element.getChildCount() );
-		}
-
-		/**
-		 * Creates a range from given parents and offsets.
-		 *
-		 * @param {document.Element} startElement Start position parent element.
-		 * @param {Number} startOffset Start position offset.
-		 * @param {document.Element} endElement End position parent element.
-		 * @param {Number} endOffset End position offset.
-		 * @returns {document.Range} Created range.
-		 */
-		static createFromParentsAndOffsets( startElement, startOffset, endElement, endOffset ) {
-			return new Range(
-					Position.createFromParentAndOffset( startElement, startOffset ),
-					Position.createFromParentAndOffset( endElement, endOffset )
-				);
-		}
-
-		/**
-		 * Two ranges equal if their start and end positions equal.
-		 *
-		 * @param {document.Range} otherRange Range to compare with.
-		 * @returns {Boolean} True if ranges equal.
-		 */
-		isEqual( otherRange ) {
-			return this.start.isEqual( otherRange.start ) && this.end.isEqual( otherRange.end );
-		}
-
-		/**
-		 * Range iterator.
-		 *
-		 * @see document.PositionIterator
-		 */
-		[ Symbol.iterator ]() {
-			return new PositionIterator( this );
-		}
-	}
-
-	return Range;
-} );

+ 0 - 35
packages/ckeditor5-utils/src/document/rootelement.js

@@ -1,35 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [ 'document/element' ], ( Element ) => {
-	/**
-	 * Class for nodes that are roots of trees in tree data model.
-	 *
-	 * @class document.RootElement
-	 */
-	class RootElement extends Element {
-		/**
-		 * Creates tree root node.
-		 *
-		 * @param {document.Document} doc {@link document.Document} that is an owner of the root.
-		 * @constructor
-		 */
-		constructor( doc ) {
-			super( 'root' );
-
-			/**
-			 * {@link document.Document} that is an owner of this root.
-			 *
-			 * @readonly
-			 * @property {document.Document}
-			 */
-			this.document = doc;
-		}
-	}
-
-	return RootElement;
-} );

+ 0 - 42
packages/ckeditor5-utils/src/document/text.js

@@ -1,42 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-CKEDITOR.define( [], () => {
-	/**
-	 * Data structure for text with attributes. Note that the `Text` is not a {@link document.Node},
-	 * because it will never be part of the document tree. {@link document.Character is a node}.
-	 *
-	 * @class document.Text
-	 */
-	class Text {
-		/**
-		 * Creates a text with attributes.
-		 *
-		 * @param {String} text Described text.
-		 * @param {Iterable} attrs Iterable collection of {@link document.Attribute attributes}.
-		 * @constructor
-		 */
-		constructor( text, attrs ) {
-			/**
-			 * Text.
-			 *
-			 * @readonly
-			 * @property {String}
-			 */
-			this.text = text;
-
-			/**
-			 * Iterable collection of {@link document.Attribute attributes}.
-			 *
-			 * @property {Iterable}
-			 */
-			this.attrs = attrs;
-		}
-	}
-
-	return Text;
-} );

+ 0 - 21
packages/ckeditor5-utils/src/document/transaction.js

@@ -1,21 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-// All deltas need to be loaded so they can register themselves as transaction methods.
-//
-// To solve circular dependencies (deltas need to require transaction class), transaction class body is moved
-// to document/delta/transaction-base.
-CKEDITOR.define( [
-	'document/delta/transaction-base',
-	'document/delta/insertdelta',
-	'document/delta/removedelta',
-	'document/delta/changedelta',
-	'document/delta/splitdelta',
-	'document/delta/mergedelta'
-], ( Transaction ) => {
-	return Transaction;
-} );

+ 13 - 17
packages/ckeditor5-utils/src/utils.js

@@ -55,18 +55,21 @@ CKEDITOR.define( [ 'utils-lodash', 'lib/lodash/lodash-ckeditor' ], ( lodashInclu
 
 		/**
 		 * Compares how given arrays relate to each other. One array can be: same as another array, prefix of another array
-		 * or completely different.
+		 * or completely different. If arrays are different, first index at which they differ is returned. Otherwise,
+		 * a flag specifying the relation is returned. Flags are negative numbers, so whenever a number >= 0 is returned
+		 * it means that arrays differ.
 		 *
 		 *   compareArrays( [ 0, 2 ], [ 0, 2 ] ); // SAME
 		 *   compareArrays( [ 0, 2 ], [ 0, 2, 1 ] ); // PREFIX
 		 *   compareArrays( [ 0, 2 ], [ 0 ] ); // EXTENSION
-		 *   compareArrays( [ 0, 2 ], [ 1, 2 ] ); // DIFFERENT
+		 *   compareArrays( [ 0, 2 ], [ 1, 2 ] ); // 0
+		 *   compareArrays( [ 0, 2 ], [ 0, 1 ] ); // 1
 		 *
 		 * @param {Array} a Array that is compared.
 		 * @param {Array} b Array to compare with.
-		 * @returns {Number} How array `a` is related to array `b`. Represented by one of flags:
-		 * `a` is {@link utils.compareArrays#SAME same}, `a` is a {@link utils.compareArrays#PREFIX prefix),
-		 * `a` is a {@link utils.compareArrays#EXTENSION extension}, or `a` is {@link utils.compareArrays#DIFFERENT different}.
+		 * @returns {Number} An index at which arrays differ, or if they do not differ, how array `a` is related to array `b`.
+		 * This is represented by one of flags: `a` is {@link utils.compareArrays#SAME same}, `a` is
+		 * a {@link utils.compareArrays#PREFIX prefix) or `a` is an {@link utils.compareArrays#EXTENSION extension}.
 		 */
 		compareArrays( a, b ) {
 			const minLen = Math.min( a.length, b.length );
@@ -74,7 +77,7 @@ CKEDITOR.define( [ 'utils-lodash', 'lib/lodash/lodash-ckeditor' ], ( lodashInclu
 			for ( let i = 0; i < minLen; i++ ) {
 				if ( a[ i ] != b[ i ] ) {
 					// The arrays are different.
-					return utils.compareArrays.DIFFERENT;
+					return i;
 				}
 			}
 
@@ -86,7 +89,7 @@ CKEDITOR.define( [ 'utils-lodash', 'lib/lodash/lodash-ckeditor' ], ( lodashInclu
 				// Compared array is shorter so it is a prefix of the other array.
 				return utils.compareArrays.PREFIX;
 			} else {
-				// Compared array is longer so it is a suffix of the other array.
+				// Compared array is longer so it is an extension of the other array.
 				return utils.compareArrays.EXTENSION;
 			}
 		},
@@ -115,28 +118,21 @@ CKEDITOR.define( [ 'utils-lodash', 'lib/lodash/lodash-ckeditor' ], ( lodashInclu
 	 *
 	 * @type {Number}
 	 */
-	utils.compareArrays.SAME = 0;
+	utils.compareArrays.SAME = -1;
 
 	/**
 	 * Flag for "is a prefix of" relation between arrays.
 	 *
 	 * @type {Number}
 	 */
-	utils.compareArrays.PREFIX = 1;
+	utils.compareArrays.PREFIX = -2;
 
 	/**
 	 * Flag for "is a suffix of" relation between arrays.
 	 *
 	 * @type {number}
 	 */
-	utils.compareArrays.EXTENSION = 2;
-
-	/**
-	 * Flag for "is different than" relation between arrays.
-	 *
-	 * @type {Number}
-	 */
-	utils.compareArrays.DIFFERENT = 3;
+	utils.compareArrays.EXTENSION = -3;
 
 	// Extend "utils" with Lo-Dash methods.
 	for ( let i = 0; i < lodashIncludes.length; i++ ) {

+ 0 - 81
packages/ckeditor5-utils/tests/document/attribute.js

@@ -1,81 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document */
-
-'use strict';
-
-const modules = bender.amd.require( 'document/attribute' );
-
-describe( 'Attribute', () => {
-	let Attribute;
-
-	before( () => {
-		Attribute = modules[ 'document/attribute' ];
-	} );
-
-	beforeEach( () => {
-		Attribute._register = {};
-	} );
-
-	describe( 'constructor', () => {
-		it( 'should create attribute', () => {
-			let attr = new Attribute( 'foo', 'bar' );
-
-			expect( attr ).to.have.property( 'key' ).that.equals( 'foo' );
-			expect( attr ).to.have.property( 'value' ).that.equals( 'bar' );
-		} );
-
-		it( 'should create equal instance even if object has different order', () => {
-			let attr1 = new Attribute( 'foo', { a: 1, b: 2 } );
-			let attr2 = new Attribute( 'foo', { b: 2, a: 1 } );
-
-			expect( attr1.isEqual( attr2 ) ).to.be.true;
-		} );
-
-		it( 'should return the same object for registered objects', () => {
-			Attribute.register( 'register', true );
-
-			let attr1 = new Attribute( 'register', true );
-			let attr2 = new Attribute( 'register', true );
-
-			expect( attr1 ).to.equal( attr2 );
-			expect( attr1.isEqual( attr2 ) ).to.be.true;
-		} );
-
-		it( 'should return different objects for different values', () => {
-			Attribute.register( 'register', true );
-
-			let attr1 = new Attribute( 'register', true );
-			let attr2 = new Attribute( 'register', false );
-
-			expect( attr1 ).to.not.be.equals( attr2 );
-			expect( attr1.isEqual( attr2 ) ).to.not.be.true;
-		} );
-
-		it( 'should return different objects for not registered objects', () => {
-			Attribute.register( 'register', true );
-
-			let attr1 = new Attribute( 'register', false );
-			let attr2 = new Attribute( 'register', false );
-
-			expect( attr1 ).to.not.be.equals( attr2 );
-			expect( attr1.isEqual( attr2 ) ).to.be.true;
-		} );
-	} );
-
-	describe( 'register', () => {
-		it( 'Attribute.register should return registered attribute', () => {
-			let attr1 = new Attribute( 'register', true );
-			let attr2 = Attribute.register( 'register', true );
-			let attr3 = Attribute.register( 'register', true );
-			let attr4 = new Attribute( 'register', true );
-
-			expect( attr1 ).to.not.be.equals( attr2 );
-			expect( attr2 ).to.equal( attr3 );
-			expect( attr3 ).to.equal( attr4 );
-		} );
-	} );
-} );

+ 0 - 56
packages/ckeditor5-utils/tests/document/character.js

@@ -1,56 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* jshint expr: true */
-
-/* bender-tags: document */
-
-/* bender-include: ../_tools/tools.js */
-
-'use strict';
-
-const getIteratorCount = bender.tools.core.getIteratorCount;
-
-const modules = bender.amd.require(
-	'document/character',
-	'document/node',
-	'document/element',
-	'document/attribute'
-);
-
-describe( 'Character', () => {
-	let Element, Character, Node, Attribute;
-
-	before( () => {
-		Element = modules[ 'document/element' ];
-		Character = modules[ 'document/character' ];
-		Node = modules[ 'document/node' ];
-		Attribute = modules[ 'document/attribute' ];
-	} );
-
-	describe( 'constructor', () => {
-		it( 'should create character without attributes', () => {
-			let character = new Character( 'f' );
-			let parent = new Element( 'parent', [], character );
-
-			expect( character ).to.be.an.instanceof( Node );
-			expect( character ).to.have.property( 'character' ).that.equals( 'f' );
-			expect( character ).to.have.property( 'parent' ).that.equals( parent );
-			expect( getIteratorCount( character.getAttrs() ) ).to.equal( 0 );
-		} );
-
-		it( 'should create character with attributes', () => {
-			let attr = new Attribute( 'foo', 'bar' );
-			let character = new Character( 'f', [ attr ] );
-			let parent = new Element( 'parent', [], character );
-
-			expect( character ).to.be.an.instanceof( Node );
-			expect( character ).to.have.property( 'character' ).that.equals( 'f' );
-			expect( character ).to.have.property( 'parent' ).that.equals( parent );
-			expect( getIteratorCount( character.getAttrs() ) ).to.equal( 1 );
-			expect( character.getAttr( attr.key ) ).to.equal( attr.value );
-		} );
-	} );
-} );

+ 0 - 275
packages/ckeditor5-utils/tests/document/deltas/changedelta.js

@@ -1,275 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document, delta */
-
-/* bender-include: ../../_tools/tools.js */
-
-'use strict';
-
-const getIteratorCount = bender.tools.core.getIteratorCount;
-
-const modules = bender.amd.require(
-	'document/transaction',
-	'document/document',
-	'document/text',
-	'document/attribute',
-	'document/range',
-	'document/position',
-	'document/element',
-	'document/character' );
-
-describe( 'Transaction', () => {
-	let Transaction, Document, Text, Attribute, Range, Position, Element, Character;
-
-	let doc, root, transaction;
-
-	before( () => {
-		Transaction = modules[ 'document/transaction' ];
-		Document = modules[ 'document/document' ];
-		Text = modules[ 'document/text' ];
-		Attribute = modules[ 'document/attribute' ];
-		Range = modules[ 'document/range' ];
-		Position = modules[ 'document/position' ];
-		Element = modules[ 'document/element' ];
-		Character = modules[ 'document/character' ];
-	} );
-
-	beforeEach( () => {
-		doc = new Document();
-		root = doc.createRoot( 'root' );
-		transaction = doc.createTransaction();
-	} );
-
-	function getOperationsCount() {
-		let count = 0;
-
-		for ( let delta of transaction.deltas ) {
-			count += getIteratorCount( delta.operations );
-		}
-
-		return count;
-	}
-
-	describe( 'change attribute on node', () => {
-		let node, character;
-
-		beforeEach( () => {
-			node = new Element( 'p', [ new Attribute( 'a', 1 ) ] );
-			character = new Character( 'c', [ new Attribute( 'a', 1 ) ] );
-			root.insertChildren( 0, [ node, character ] );
-		} );
-
-		describe( 'setAttr', () => {
-			it( 'should create the attribute on element', () => {
-				transaction.setAttr( 'b', 2, node );
-				expect( getOperationsCount() ).to.equal( 1 );
-				expect( node.getAttr( 'b' ) ).to.equal( 2 );
-			} );
-
-			it( 'should change the attribute of element', () => {
-				transaction.setAttr( 'a', 2, node );
-				expect( getOperationsCount() ).to.equal( 1 );
-				expect( node.getAttr( 'a' ) ).to.equal( 2 );
-			} );
-
-			it( 'should create the attribute on character', () => {
-				transaction.setAttr( 'b', 2, character );
-				expect( getOperationsCount() ).to.equal( 1 );
-				expect( character.getAttr( 'b' ) ).to.equal( 2 );
-			} );
-
-			it( 'should change the attribute of character', () => {
-				transaction.setAttr( 'a', 2, character );
-				expect( getOperationsCount() ).to.equal( 1 );
-				expect( character.getAttr( 'a' ) ).to.equal( 2 );
-			} );
-
-			it( 'should do nothing if the attribute value is the same', () => {
-				transaction.setAttr( 'a', 1, node );
-				expect( getOperationsCount() ).to.equal( 0 );
-				expect( node.getAttr( 'a' ) ).to.equal( 1 );
-			} );
-
-			it( 'should be chainable', () => {
-				const chain = transaction.setAttr( 'b', 2, node );
-				expect( chain ).to.equal( transaction );
-			} );
-		} );
-
-		describe( 'removeAttr', () => {
-			it( 'should remove the attribute from element', () => {
-				transaction.removeAttr( 'a', node );
-				expect( getOperationsCount() ).to.equal( 1 );
-				expect( node.getAttr( 'a' ) ).to.be.null;
-			} );
-
-			it( 'should remove the attribute from character', () => {
-				transaction.removeAttr( 'a', character );
-				expect( getOperationsCount() ).to.equal( 1 );
-				expect( character.getAttr( 'a' ) ).to.be.null;
-			} );
-
-			it( 'should do nothing if the attribute is not set', () => {
-				transaction.removeAttr( 'b', node );
-				expect( getOperationsCount() ).to.equal( 0 );
-			} );
-
-			it( 'should be chainable', () => {
-				const chain = transaction.removeAttr( 'a', node );
-				expect( chain ).to.equal( transaction );
-			} );
-		} );
-	} );
-
-	describe( 'change attribute on range', () => {
-		beforeEach( () => {
-			root.insertChildren( 0, [
-				new Text( 'xxx', [ new Attribute( 'a', 1 ) ] ),
-				'xxx',
-				new Text( 'xxx', [ new Attribute( 'a', 1 ) ] ),
-				new Text( 'xxx', [ new Attribute( 'a', 2 ) ] ),
-				'xxx',
-				new Text( 'xxx', [ new Attribute( 'a', 1 ) ] )
-			] );
-		} );
-
-		function getRange( startIndex, endIndex ) {
-			return new Range(
-					Position.createFromParentAndOffset( root, startIndex ),
-					Position.createFromParentAndOffset( root, endIndex )
-				);
-		}
-
-		function getChangesAttrsCount() {
-			let count = 0;
-
-			for ( let delta of transaction.deltas ) {
-				for ( let operation of delta.operations ) {
-					count += getIteratorCount( operation.range );
-				}
-			}
-
-			return count;
-		}
-
-		function getCompressedAttrs() {
-			// default: 111---111222---111
-			const range = Range.createFromElement( root );
-
-			return Array.from( range ).map( value => value.node.getAttr( 'a' ) || '-' ).join( '' );
-		}
-
-		describe( 'setAttr', () => {
-			it( 'should set the attribute on the range', () => {
-				transaction.setAttr( 'a', 3, getRange( 3, 6 ) );
-				expect( getOperationsCount() ).to.equal( 1 );
-				expect( getChangesAttrsCount() ).to.equal( 3 );
-				expect( getCompressedAttrs() ).to.equal( '111333111222---111' );
-			} );
-
-			it( 'should split the operations if parts of the range have different attributes', () => {
-				transaction.setAttr( 'a', 3, getRange( 4, 14 ) );
-				expect( getOperationsCount() ).to.equal( 4 );
-				expect( getChangesAttrsCount() ).to.equal( 10 );
-				expect( getCompressedAttrs() ).to.equal( '111-3333333333-111' );
-			} );
-
-			it( 'should split the operations if parts of the part of the range have the attribute', () => {
-				transaction.setAttr( 'a', 2, getRange( 4, 14 ) );
-				expect( getOperationsCount() ).to.equal( 3 );
-				expect( getChangesAttrsCount() ).to.equal( 7 );
-				expect( getCompressedAttrs() ).to.equal( '111-2222222222-111' );
-			} );
-
-			it( 'should strip the range if the beginning have the attribute', () => {
-				transaction.setAttr( 'a', 1, getRange( 1, 5 ) );
-				expect( getOperationsCount() ).to.equal( 1 );
-				expect( getChangesAttrsCount() ).to.equal( 2 );
-				expect( getCompressedAttrs() ).to.equal( '11111-111222---111' );
-			} );
-
-			it( 'should strip the range if the ending have the attribute', () => {
-				transaction.setAttr( 'a', 1, getRange( 13, 17 ) );
-				expect( getOperationsCount() ).to.equal( 1 );
-				expect( getChangesAttrsCount() ).to.equal( 2 );
-				expect( getCompressedAttrs() ).to.equal( '111---111222-11111' );
-			} );
-
-			it( 'should do nothing if the range has attribute', () => {
-				transaction.setAttr( 'a', 1, getRange( 0, 3 ) );
-				expect( getOperationsCount() ).to.equal( 0 );
-				expect( getCompressedAttrs() ).to.equal( '111---111222---111' );
-			} );
-
-			it( 'should create a proper operations for the mixed range', () => {
-				transaction.setAttr( 'a', 1, getRange( 0, 18 ) );
-				expect( getOperationsCount() ).to.equal( 3 );
-				expect( getChangesAttrsCount() ).to.equal( 9 );
-				expect( getCompressedAttrs() ).to.equal( '111111111111111111' );
-			} );
-
-			it( 'should be chainable', () => {
-				const chain = transaction.setAttr( 'a', 3, getRange( 3, 6 ) );
-				expect( chain ).to.equal( transaction );
-			} );
-		} );
-
-		describe( 'removeAttr', () => {
-			it( 'should remove the attribute on the range', () => {
-				transaction.removeAttr( 'a', getRange( 0, 2 ) );
-				expect( getOperationsCount() ).to.equal( 1 );
-				expect( getChangesAttrsCount() ).to.equal( 2 );
-				expect( getCompressedAttrs() ).to.equal( '--1---111222---111' );
-			} );
-
-			it( 'should split the operations if parts of the range have different attributes', () => {
-				transaction.removeAttr( 'a', getRange( 7, 11 ) );
-				expect( getOperationsCount() ).to.equal( 2 );
-				expect( getChangesAttrsCount() ).to.equal( 4 );
-				expect( getCompressedAttrs() ).to.equal( '111---1----2---111' );
-			} );
-
-			it( 'should split the operations if parts of the part of the range have no attribute', () => {
-				transaction.removeAttr( 'a', getRange( 1, 7 ) );
-				expect( getOperationsCount() ).to.equal( 2 );
-				expect( getChangesAttrsCount() ).to.equal( 3 );
-				expect( getCompressedAttrs() ).to.equal( '1------11222---111' );
-			} );
-
-			it( 'should strip the range if the beginning have no attribute', () => {
-				transaction.removeAttr( 'a', getRange( 4, 12 ) );
-				expect( getOperationsCount() ).to.equal( 2 );
-				expect( getChangesAttrsCount() ).to.equal( 6 );
-				expect( getCompressedAttrs() ).to.equal( '111------------111' );
-			} );
-
-			it( 'should strip the range if the ending have no attribute', () => {
-				transaction.removeAttr( 'a', getRange( 7, 15 ) );
-				expect( getOperationsCount() ).to.equal( 2 );
-				expect( getChangesAttrsCount() ).to.equal( 5 );
-				expect( getCompressedAttrs() ).to.equal( '111---1--------111' );
-			} );
-
-			it( 'should do nothing if the range has no attribute', () => {
-				transaction.removeAttr( 'a', getRange( 4, 5 ) );
-				expect( getOperationsCount() ).to.equal( 0 );
-				expect( getCompressedAttrs() ).to.equal( '111---111222---111' );
-			} );
-
-			it( 'should create a proper operations for the mixed range', () => {
-				transaction.removeAttr( 'a', getRange( 3, 15 ) );
-				expect( getOperationsCount() ).to.equal( 2 );
-				expect( getChangesAttrsCount() ).to.equal( 6 );
-				expect( getCompressedAttrs() ).to.equal( '111------------111' );
-			} );
-
-			it( 'should be chainable', () => {
-				const chain = transaction.removeAttr( 'a', getRange( 0, 2 ) );
-				expect( chain ).to.equal( transaction );
-			} );
-		} );
-	} );
-} );

+ 0 - 67
packages/ckeditor5-utils/tests/document/deltas/delta.js

@@ -1,67 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document, delta */
-
-/* bender-include: ../../_tools/tools.js */
-
-'use strict';
-
-const getIteratorCount = bender.tools.core.getIteratorCount;
-
-const modules = bender.amd.require(
-	'document/delta/delta' );
-
-describe( 'Delta', () => {
-	let Delta;
-
-	before( () => {
-		Delta = modules[ 'document/delta/delta' ];
-	} );
-
-	describe( 'constructor', () => {
-		it( 'should create an delta with empty properties', () => {
-			const delta = new Delta();
-
-			expect( delta ).to.have.property( 'transaction' ).that.is.null;
-			expect( delta ).to.have.property( 'operations' ).that.a( 'array' ).and.have.length( 0 );
-		} );
-	} );
-
-	describe( 'addOperation', () => {
-		it( 'should add operation to the delta', () => {
-			const delta = new Delta();
-			const operation = {};
-
-			delta.addOperation( operation );
-
-			expect( delta.operations ).to.have.length( 1 );
-			expect( delta.operations[ 0 ] ).to.equal( operation );
-		} );
-
-		it( 'should add delta property to the operation', () => {
-			const delta = new Delta();
-			const operation = {};
-
-			delta.addOperation( operation );
-
-			expect( operation.delta ).to.equal( delta );
-		} );
-	} );
-
-	describe( 'iterator', () => {
-		it( 'should iterate over delta operations', () => {
-			const delta = new Delta();
-
-			delta.addOperation( {} );
-			delta.addOperation( {} );
-			delta.addOperation( {} );
-
-			const count = getIteratorCount( delta.operations );
-
-			expect( count ).to.equal( 3 );
-		} );
-	} );
-} );

+ 0 - 46
packages/ckeditor5-utils/tests/document/deltas/insertdelta.js

@@ -1,46 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document, delta */
-
-'use strict';
-
-const modules = bender.amd.require(
-	'document/document',
-	'document/position' );
-
-describe( 'Transaction', () => {
-	let Document, Position;
-
-	let doc, root;
-
-	before( () => {
-		Document = modules[ 'document/document' ];
-		Position = modules[ 'document/position' ];
-	} );
-
-	beforeEach( () => {
-		doc = new Document();
-		root = doc.createRoot( 'root' );
-	} );
-
-	it( 'should insert text', () => {
-		const position = new Position( [ 0 ], root );
-		doc.createTransaction().insert( position, 'foo' );
-
-		expect( root.getChildCount() ).to.equal( 3 );
-		expect( root.getChild( 0 ).character ).to.equal( 'f' );
-		expect( root.getChild( 1 ).character ).to.equal( 'o' );
-		expect( root.getChild( 2 ).character ).to.equal( 'o' );
-	} );
-
-	it( 'should be chainable', () => {
-		const position = new Position( [ 0 ], root );
-		const transaction = doc.createTransaction();
-
-		const chain = transaction.insert( position, 'foo' );
-		expect( chain ).to.equal( transaction );
-	} );
-} );

+ 0 - 80
packages/ckeditor5-utils/tests/document/deltas/mergedelta.js

@@ -1,80 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document, delta */
-
-/* bender-include: ../../_tools/tools.js */
-
-'use strict';
-
-const getIteratorCount = bender.tools.core.getIteratorCount;
-
-const modules = bender.amd.require(
-	'document/document',
-	'document/position',
-	'document/element',
-	'document/attribute',
-	'ckeditorerror' );
-
-describe( 'Transaction', () => {
-	let Document, Position, Element, Attribute, CKEditorError;
-
-	let doc, root, p1, p2;
-
-	before( () => {
-		Document = modules[ 'document/document' ];
-		Position = modules[ 'document/position' ];
-		Element = modules[ 'document/element' ];
-		Attribute = modules[ 'document/attribute' ];
-		CKEditorError = modules.ckeditorerror;
-	} );
-
-	beforeEach( () => {
-		doc = new Document();
-		root = doc.createRoot( 'root' );
-
-		p1 = new Element( 'p', [ new Attribute( 'key1', 'value1' ) ], 'foo' );
-		p2 = new Element( 'p', [ new Attribute( 'key2', 'value2' ) ], 'bar' );
-
-		root.insertChildren( 0, [ p1, p2 ] );
-	} );
-
-	describe( 'merge', () => {
-		it( 'should merge foo and bar into foobar', () => {
-			doc.createTransaction().merge( new Position( [ 1 ], root ) );
-
-			expect( root.getChildCount() ).to.equal( 1 );
-			expect( root.getChild( 0 ).name ).to.equal( 'p' );
-			expect( root.getChild( 0 ).getChildCount() ).to.equal( 6 );
-			expect( getIteratorCount( root.getChild( 0 ).getAttrs() ) ).to.equal( 1 );
-			expect( root.getChild( 0 ).getAttr( 'key1' ) ).to.equal( 'value1' );
-			expect( root.getChild( 0 ).getChild( 0 ).character ).to.equal( 'f' );
-			expect( root.getChild( 0 ).getChild( 1 ).character ).to.equal( 'o' );
-			expect( root.getChild( 0 ).getChild( 2 ).character ).to.equal( 'o' );
-			expect( root.getChild( 0 ).getChild( 3 ).character ).to.equal( 'b' );
-			expect( root.getChild( 0 ).getChild( 4 ).character ).to.equal( 'a' );
-			expect( root.getChild( 0 ).getChild( 5 ).character ).to.equal( 'r' );
-		} );
-
-		it( 'should throw if there is no element after', () => {
-			expect( () => {
-				doc.createTransaction().merge( new Position( [ 2 ], root ) );
-			} ).to.throw( CKEditorError, /^transaction-merge-no-element-after/ );
-		} );
-
-		it( 'should throw if there is no element before', () => {
-			expect( () => {
-				doc.createTransaction().merge( new Position( [ 0, 2 ], root ) );
-			} ).to.throw( CKEditorError, /^transaction-merge-no-element-before/ );
-		} );
-
-		it( 'should be chainable', () => {
-			const transaction = doc.createTransaction();
-
-			const chain = transaction.merge( new Position( [ 1 ], root ) );
-			expect( chain ).to.equal( transaction );
-		} );
-	} );
-} );

+ 0 - 61
packages/ckeditor5-utils/tests/document/deltas/removedelta.js

@@ -1,61 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document, delta */
-
-'use strict';
-
-const modules = bender.amd.require(
-	'document/document',
-	'document/position' );
-
-describe( 'Transaction', () => {
-	let Document, Position;
-
-	let doc, root;
-
-	before( () => {
-		Document = modules[ 'document/document' ];
-		Position = modules[ 'document/position' ];
-	} );
-
-	beforeEach( () => {
-		doc = new Document();
-		root = doc.createRoot( 'root' );
-		root.insertChildren( 0, 'foobar' );
-	} );
-
-	describe( 'remove', () => {
-		it( 'should remove one element', () => {
-			const position = new Position( [ 1 ], root );
-			doc.createTransaction().remove( position );
-
-			expect( root.getChildCount() ).to.equal( 5 );
-			expect( root.getChild( 0 ).character ).to.equal( 'f' );
-			expect( root.getChild( 1 ).character ).to.equal( 'o' );
-			expect( root.getChild( 2 ).character ).to.equal( 'b' );
-			expect( root.getChild( 3 ).character ).to.equal( 'a' );
-			expect( root.getChild( 4 ).character ).to.equal( 'r' );
-		} );
-
-		it( 'should remove 3 elements', () => {
-			const position = new Position( [ 1 ], root );
-			doc.createTransaction().remove( position, 3 );
-
-			expect( root.getChildCount() ).to.equal( 3 );
-			expect( root.getChild( 0 ).character ).to.equal( 'f' );
-			expect( root.getChild( 1 ).character ).to.equal( 'a' );
-			expect( root.getChild( 2 ).character ).to.equal( 'r' );
-		} );
-
-		it( 'should be chainable', () => {
-			const position = new Position( [ 1 ], root );
-			const transaction = doc.createTransaction();
-
-			const chain = transaction.remove( position );
-			expect( chain ).to.equal( transaction );
-		} );
-	} );
-} );

+ 0 - 101
packages/ckeditor5-utils/tests/document/deltas/splitdelta.js

@@ -1,101 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document, delta */
-
-/* bender-include: ../../_tools/tools.js */
-
-'use strict';
-
-const getIteratorCount = bender.tools.core.getIteratorCount;
-
-const modules = bender.amd.require(
-	'document/document',
-	'document/position',
-	'document/element',
-	'document/attribute',
-	'ckeditorerror' );
-
-describe( 'Transaction', () => {
-	let Document, Position, Element, Attribute, CKEditorError;
-
-	let doc, root, p;
-
-	before( () => {
-		Document = modules[ 'document/document' ];
-		Position = modules[ 'document/position' ];
-		Element = modules[ 'document/element' ];
-		Attribute = modules[ 'document/attribute' ];
-		CKEditorError = modules.ckeditorerror;
-	} );
-
-	beforeEach( () => {
-		doc = new Document();
-		root = doc.createRoot( 'root' );
-
-		p = new Element( 'p', [ new Attribute( 'key', 'value' ) ], 'foobar' );
-
-		root.insertChildren( 0, p );
-	} );
-
-	describe( 'split', () => {
-		it( 'should split foobar to foo and bar', () => {
-			doc.createTransaction().split( new Position( [ 0, 3 ], root ) );
-
-			expect( root.getChildCount() ).to.equal( 2 );
-
-			expect( root.getChild( 0 ).name ).to.equal( 'p' );
-			expect( root.getChild( 0 ).getChildCount() ).to.equal( 3 );
-			expect( getIteratorCount( root.getChild( 0 ).getAttrs() ) ).to.equal( 1 );
-			expect( root.getChild( 0 ).getAttr( 'key' ) ).to.equal( 'value' );
-			expect( root.getChild( 0 ).getChild( 0 ).character ).to.equal( 'f' );
-			expect( root.getChild( 0 ).getChild( 1 ).character ).to.equal( 'o' );
-			expect( root.getChild( 0 ).getChild( 2 ).character ).to.equal( 'o' );
-
-			expect( root.getChild( 1 ).name ).to.equal( 'p' );
-			expect( root.getChild( 1 ).getChildCount() ).to.equal( 3 );
-			expect( getIteratorCount( root.getChild( 1 ).getAttrs() ) ).to.equal( 1 );
-			expect( root.getChild( 1 ).getAttr( 'key' ) ).to.equal( 'value' );
-			expect( root.getChild( 1 ).getChild( 0 ).character ).to.equal( 'b' );
-			expect( root.getChild( 1 ).getChild( 1 ).character ).to.equal( 'a' );
-			expect( root.getChild( 1 ).getChild( 2 ).character ).to.equal( 'r' );
-		} );
-
-		it( 'should create an empty paragraph if we split at the end', () => {
-			doc.createTransaction().split( new Position( [ 0, 6 ], root ) );
-
-			expect( root.getChildCount() ).to.equal( 2 );
-
-			expect( root.getChild( 0 ).name ).to.equal( 'p' );
-			expect( root.getChild( 0 ).getChildCount() ).to.equal( 6 );
-			expect( getIteratorCount( root.getChild( 0 ).getAttrs() ) ).to.equal( 1 );
-			expect( root.getChild( 0 ).getAttr( 'key' ) ).to.equal( 'value' );
-			expect( root.getChild( 0 ).getChild( 0 ).character ).to.equal( 'f' );
-			expect( root.getChild( 0 ).getChild( 1 ).character ).to.equal( 'o' );
-			expect( root.getChild( 0 ).getChild( 2 ).character ).to.equal( 'o' );
-			expect( root.getChild( 0 ).getChild( 3 ).character ).to.equal( 'b' );
-			expect( root.getChild( 0 ).getChild( 4 ).character ).to.equal( 'a' );
-			expect( root.getChild( 0 ).getChild( 5 ).character ).to.equal( 'r' );
-
-			expect( root.getChild( 1 ).name ).to.equal( 'p' );
-			expect( root.getChild( 1 ).getChildCount() ).to.equal( 0 );
-			expect( getIteratorCount( root.getChild( 1 ).getAttrs() ) ).to.equal( 1 );
-			expect( root.getChild( 1 ).getAttr( 'key' ) ).to.equal( 'value' );
-		} );
-
-		it( 'should throw if we try to split a root', () => {
-			expect( () => {
-				doc.createTransaction().split( new Position( [ 0 ], root ) );
-			} ).to.throw( CKEditorError, /^transaction-split-root/ );
-		} );
-
-		it( 'should be chainable', () => {
-			const transaction = doc.createTransaction();
-
-			const chain = transaction.split( new Position( [ 0, 3 ], root ) );
-			expect( chain ).to.equal( transaction );
-		} );
-	} );
-} );

+ 0 - 120
packages/ckeditor5-utils/tests/document/document.js

@@ -1,120 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document */
-
-'use strict';
-
-const modules = bender.amd.require(
-	'document/document',
-	'document/rootelement',
-	'document/transaction',
-	'ckeditorerror'
-);
-
-describe( 'Document', () => {
-	let Document, RootElement, Transaction, CKEditorError;
-
-	before( () => {
-		Document = modules[ 'document/document' ];
-		RootElement = modules[ 'document/rootelement' ];
-		Transaction = modules[ 'document/transaction' ];
-		CKEditorError = modules.ckeditorerror;
-	} );
-
-	let document;
-
-	beforeEach( () => {
-		document = new Document();
-	} );
-
-	describe( 'constructor', () => {
-		it( 'should create Document with no data', () => {
-			expect( document ).to.have.property( 'roots' ).that.is.instanceof( Map );
-			expect( document.roots.size ).to.equal( 1 );
-			expect( document._graveyard ).to.be.instanceof( RootElement );
-			expect( document._graveyard.getChildCount() ).to.equal( 0 );
-		} );
-	} );
-
-	describe( 'createRoot', () => {
-		it( 'should create a new RootElement, add it to roots map and return it', () => {
-			let root = document.createRoot( 'root' );
-
-			expect( document.roots.size ).to.equal( 2 );
-			expect( root ).to.be.instanceof( RootElement );
-			expect( root.getChildCount() ).to.equal( 0 );
-		} );
-
-		it( 'should throw an error when trying to create a second root with the same name', () => {
-			document.createRoot( 'root' );
-
-			expect(
-				() => {
-					document.createRoot( 'root' );
-				}
-			).to.throw( CKEditorError, /document-createRoot-name-exists/ );
-		} );
-	} );
-
-	describe( 'getRoot', () => {
-		it( 'should return a RootElement previously created with given name', () => {
-			let newRoot = document.createRoot( 'root' );
-			let getRoot = document.getRoot( 'root' );
-
-			expect( getRoot ).to.equal( newRoot );
-		} );
-
-		it( 'should throw an error when trying to get non-existent root', () => {
-			expect(
-				() => {
-					document.getRoot( 'root' );
-				}
-			).to.throw( CKEditorError, /document-createRoot-root-not-exist/ );
-		} );
-	} );
-
-	describe( 'applyOperation', () => {
-		it( 'should increase document version, execute operation and fire operationApplied', () => {
-			let operationApplied = sinon.spy();
-			let operation = {
-				baseVersion: 0,
-				_execute: sinon.spy()
-			};
-
-			document.on( 'operationApplied', operationApplied );
-
-			document.applyOperation( operation );
-
-			expect( document.version ).to.equal( 1 );
-			sinon.assert.calledOnce( operationApplied );
-			sinon.assert.calledOnce( operation._execute );
-		} );
-
-		it( 'should throw an error on the operation base version and the document version is different', () => {
-			let operationApplied = sinon.spy();
-			let operation = {
-				baseVersion: 1
-			};
-
-			document.on( 'operationApplied', operationApplied );
-
-			expect(
-				() => {
-					document.applyOperation( operation );
-				}
-			).to.throw( CKEditorError, /document-applyOperation-wrong-version/ );
-		} );
-	} );
-
-	describe( 'createTransaction', () => {
-		it( 'should create a new transaction with the document property', () => {
-			const transaction = document.createTransaction();
-
-			expect( transaction ).to.be.instanceof( Transaction );
-			expect( transaction ).to.have.property( 'doc' ).that.equals( document );
-		} );
-	} );
-} );

+ 0 - 128
packages/ckeditor5-utils/tests/document/element.js

@@ -1,128 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* jshint expr: true */
-
-/* bender-tags: document */
-
-/* bender-include: ../_tools/tools.js */
-
-'use strict';
-
-const getIteratorCount = bender.tools.core.getIteratorCount;
-
-const modules = bender.amd.require(
-	'document/node',
-	'document/nodelist',
-	'document/element',
-	'document/attribute'
-);
-
-describe( 'Element', () => {
-	let Element, Node, NodeList, Attribute;
-
-	before( () => {
-		Element = modules[ 'document/element' ];
-		Node = modules[ 'document/node' ];
-		NodeList = modules[ 'document/nodelist' ];
-		Attribute = modules[ 'document/attribute' ];
-	} );
-
-	describe( 'constructor', () => {
-		it( 'should create element without attributes', () => {
-			let element = new Element( 'elem' );
-			let parent = new Element( 'parent', [], [ element ] );
-
-			expect( element ).to.be.an.instanceof( Node );
-			expect( element ).to.have.property( 'name' ).that.equals( 'elem' );
-			expect( element ).to.have.property( 'parent' ).that.equals( parent );
-			expect( getIteratorCount( element.getAttrs() ) ).to.equal( 0 );
-		} );
-
-		it( 'should create element with attributes', () => {
-			let attr = new Attribute( 'foo', 'bar' );
-
-			let element = new Element( 'elem', [ attr ] );
-			let parent = new Element( 'parent', [], [ element ] );
-
-			expect( element ).to.be.an.instanceof( Node );
-			expect( element ).to.have.property( 'name' ).that.equals( 'elem' );
-			expect( element ).to.have.property( 'parent' ).that.equals( parent );
-			expect( getIteratorCount( element.getAttrs() ) ).to.equal( 1 );
-			expect( element.getAttr( attr.key ) ).to.equal( attr.value );
-		} );
-
-		it( 'should create element with children', () => {
-			let element = new Element( 'elem', [], 'foo' );
-
-			expect( element ).to.have.property( 'name' ).that.equals( 'elem' );
-			expect( element.getChildCount() ).to.equal( 3 );
-			expect( element.getChild( 0 ) ).to.have.property( 'character' ).that.equals( 'f' );
-			expect( element.getChild( 1 ) ).to.have.property( 'character' ).that.equals( 'o' );
-			expect( element.getChild( 2 ) ).to.have.property( 'character' ).that.equals( 'o' );
-		} );
-	} );
-
-	describe( 'insertChildren', () => {
-		it( 'should add children to the element', () => {
-			let element = new Element( 'elem', [], [ 'xy' ] );
-			element.insertChildren( 1, 'foo' );
-
-			expect( element ).to.have.property( 'name' ).that.equals( 'elem' );
-			expect( element.getChildCount() ).to.equal( 5 );
-			expect( element.getChild( 0 ) ).to.have.property( 'character' ).that.equals( 'x' );
-			expect( element.getChild( 1 ) ).to.have.property( 'character' ).that.equals( 'f' );
-			expect( element.getChild( 2 ) ).to.have.property( 'character' ).that.equals( 'o' );
-			expect( element.getChild( 3 ) ).to.have.property( 'character' ).that.equals( 'o' );
-			expect( element.getChild( 4 ) ).to.have.property( 'character' ).that.equals( 'y' );
-		} );
-	} );
-
-	describe( 'removeChildren', () => {
-		it( 'should remove children from the element and return them as a NodeList', () => {
-			let element = new Element( 'elem', [], [ 'foobar' ] );
-			let o = element.getChild( 2 );
-			let b = element.getChild( 3 );
-			let a = element.getChild( 4 );
-			let removed = element.removeChildren( 2, 3 );
-
-			expect( element.getChildCount() ).to.equal( 3 );
-			expect( element.getChild( 0 ) ).to.have.property( 'character' ).that.equals( 'f' );
-			expect( element.getChild( 1 ) ).to.have.property( 'character' ).that.equals( 'o' );
-			expect( element.getChild( 2 ) ).to.have.property( 'character' ).that.equals( 'r' );
-
-			expect( o ).to.have.property( 'parent' ).that.is.null;
-			expect( b ).to.have.property( 'parent' ).that.is.null;
-			expect( a ).to.have.property( 'parent' ).that.is.null;
-
-			expect( removed ).to.be.instanceof( NodeList );
-			expect( removed.length ).to.equal( 3 );
-			expect( removed.get( 0 ) ).to.equal( o );
-			expect( removed.get( 1 ) ).to.equal( b );
-			expect( removed.get( 2 ) ).to.equal( a );
-		} );
-	} );
-
-	describe( 'getChildIndex', () => {
-		it( 'should return child index', () => {
-			let element = new Element( 'elem', [], [ 'bar' ] );
-			let b = element.getChild( 0 );
-			let a = element.getChild( 1 );
-			let r = element.getChild( 2 );
-
-			expect( element.getChildIndex( b ) ).to.equal( 0 );
-			expect( element.getChildIndex( a ) ).to.equal( 1 );
-			expect( element.getChildIndex( r ) ).to.equal( 2 );
-		} );
-	} );
-
-	describe( 'getChildCount', () => {
-		it( 'should return number of children', () => {
-			let element = new Element( 'elem', [], [ 'bar' ] );
-
-			expect( element.getChildCount() ).to.equal( 3 );
-		} );
-	} );
-} );

+ 0 - 276
packages/ckeditor5-utils/tests/document/node.js

@@ -1,276 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document */
-
-/* bender-include: ../_tools/tools.js */
-
-'use strict';
-
-const getIteratorCount = bender.tools.core.getIteratorCount;
-
-const modules = bender.amd.require(
-	'document/element',
-	'document/character',
-	'document/attribute',
-	'document/nodelist',
-	'ckeditorerror'
-);
-
-describe( 'Node', () => {
-	let Element, Character, Attribute, NodeList, CKEditorError;
-
-	let root;
-	let one, two, three;
-	let charB, charA, charR, img;
-
-	before( () => {
-		Element = modules[ 'document/element' ];
-		Character = modules[ 'document/character' ];
-		Attribute = modules[ 'document/attribute' ];
-		NodeList = modules[ 'document/nodelist' ];
-		CKEditorError = modules.ckeditorerror;
-
-		charB = new Character( 'b' );
-		charA = new Character( 'a' );
-		img = new Element( 'img' );
-		charR = new Character( 'r' );
-
-		one = new Element( 'one' );
-		two = new Element( 'two', null, [ charB, charA, img, charR ] );
-		three = new Element( 'three' );
-
-		root = new Element( null, null, [ one, two, three ] );
-	} );
-
-	describe( 'should have a correct property', () => {
-		it( 'depth', () => {
-			expect( root ).to.have.property( 'depth' ).that.equals( 0 );
-
-			expect( one ).to.have.property( 'depth' ).that.equals( 1 );
-			expect( two ).to.have.property( 'depth' ).that.equals( 1 );
-			expect( three ).to.have.property( 'depth' ).that.equals( 1 );
-
-			expect( charB ).to.have.property( 'depth' ).that.equals( 2 );
-			expect( charA ).to.have.property( 'depth' ).that.equals( 2 );
-			expect( img ).to.have.property( 'depth' ).that.equals( 2 );
-			expect( charR ).to.have.property( 'depth' ).that.equals( 2 );
-		} );
-
-		it( 'root', () => {
-			expect( root ).to.have.property( 'root' ).that.equals( root );
-
-			expect( one ).to.have.property( 'root' ).that.equals( root );
-			expect( two ).to.have.property( 'root' ).that.equals( root );
-			expect( three ).to.have.property( 'root' ).that.equals( root );
-
-			expect( charB ).to.have.property( 'root' ).that.equals( root );
-			expect( charA ).to.have.property( 'root' ).that.equals( root );
-			expect( img ).to.have.property( 'root' ).that.equals( root );
-			expect( charR ).to.have.property( 'root' ).that.equals( root );
-		} );
-
-		it( 'nextSibling', () => {
-			expect( root ).to.have.property( 'nextSibling' ).that.is.null;
-
-			expect( one ).to.have.property( 'nextSibling' ).that.equals( two );
-			expect( two ).to.have.property( 'nextSibling' ).that.equals( three );
-			expect( three ).to.have.property( 'nextSibling' ).that.is.null;
-
-			expect( charB ).to.have.property( 'nextSibling' ).that.equals( charA );
-			expect( charA ).to.have.property( 'nextSibling' ).that.equals( img );
-			expect( img ).to.have.property( 'nextSibling' ).that.equals( charR );
-			expect( charR ).to.have.property( 'nextSibling' ).that.is.null;
-		} );
-
-		it( 'previousSibling', () => {
-			expect( root ).to.have.property( 'previousSibling' ).that.is.expect;
-
-			expect( one ).to.have.property( 'previousSibling' ).that.is.null;
-			expect( two ).to.have.property( 'previousSibling' ).that.equals( one );
-			expect( three ).to.have.property( 'previousSibling' ).that.equals( two );
-
-			expect( charB ).to.have.property( 'previousSibling' ).that.is.null;
-			expect( charA ).to.have.property( 'previousSibling' ).that.equals( charB );
-			expect( img ).to.have.property( 'previousSibling' ).that.equals( charA );
-			expect( charR ).to.have.property( 'previousSibling' ).that.equals( img );
-		} );
-	} );
-
-	describe( 'constructor', () => {
-		it( 'should copy attributes, not pass by reference', () => {
-			let attrs = [ new Attribute( 'attr', true ) ];
-			let foo = new Element( 'foo', attrs );
-			let bar = new Element( 'bar', attrs );
-
-			foo.removeAttr( 'attr' );
-
-			expect( getIteratorCount( foo.getAttrs() ) ).to.equal( 0 );
-			expect( getIteratorCount( bar.getAttrs() ) ).to.equal( 1 );
-		} );
-	} );
-
-	describe( 'getAttr', () => {
-		let fooAttr, element;
-
-		beforeEach( () => {
-			fooAttr = new Attribute( 'foo', true );
-			element = new Element( 'foo', [ fooAttr ] );
-		} );
-
-		it( 'should be possible to get attribute by key', () => {
-			expect( element.getAttr( 'foo' ) ).to.equal( fooAttr.value );
-		} );
-
-		it( 'should return null if attribute was not found by key', () => {
-			expect( element.getAttr( 'bar' ) ).to.be.null;
-		} );
-	} );
-
-	describe( 'setAttr', () => {
-		it( 'should insert an attribute', () => {
-			let element = new Element( 'elem' );
-			let attr = new Attribute( 'foo', 'bar' );
-
-			element.setAttr( attr );
-
-			expect( getIteratorCount( element.getAttrs() ) ).to.equal( 1 );
-			expect( element.getAttr( attr.key ) ).to.equal( attr.value );
-		} );
-
-		it( 'should overwrite attribute with the same key', () => {
-			let oldAttr = new Attribute( 'foo', 'bar' );
-			let newAttr = new Attribute( 'foo', 'bar' );
-			let element = new Element( 'elem', [ oldAttr ] );
-
-			element.setAttr( newAttr );
-
-			expect( getIteratorCount( element.getAttrs() ) ).to.equal( 1 );
-			expect( element.getAttr( newAttr.key ) ).to.equal( newAttr.value );
-		} );
-	} );
-
-	describe( 'removeAttr', () => {
-		it( 'should remove an attribute', () => {
-			let attrA = new Attribute( 'a', 'A' );
-			let attrB = new Attribute( 'b', 'b' );
-			let attrC = new Attribute( 'c', 'C' );
-			let element = new Element( 'elem', [ attrA, attrB, attrC ] );
-
-			element.removeAttr( attrB.key );
-
-			expect( getIteratorCount( element.getAttrs() ) ).to.equal( 2 );
-			expect( element.getAttr( attrA.key ) ).to.equal( attrA.value );
-			expect( element.getAttr( attrC.key ) ).to.equal( attrC.value );
-			expect( element.getAttr( attrB.key ) ).to.be.null;
-		} );
-	} );
-
-	describe( 'hasAttr', () => {
-		it( 'should check attribute by key', () => {
-			let fooAttr = new Attribute( 'foo', true );
-			let element = new Element( 'foo', [ fooAttr ] );
-
-			expect( element.hasAttr( 'foo' ) ).to.be.true;
-		} );
-
-		it( 'should return false if attribute was not found by key', () => {
-			let fooAttr = new Attribute( 'foo', true );
-			let element = new Element( 'foo', [ fooAttr ] );
-
-			expect( element.hasAttr( 'bar' ) ).to.be.false;
-		} );
-
-		it( 'should check attribute by object', () => {
-			let fooAttr = new Attribute( 'foo', true );
-			let foo2Attr = new Attribute( 'foo', true );
-			let element = new Element( 'foo', [ fooAttr ] );
-
-			expect( element.hasAttr( foo2Attr ) ).to.be.true;
-		} );
-
-		it( 'should return false if attribute was not found by object', () => {
-			let fooAttr = new Attribute( 'foo', true );
-			let element = new Element( 'foo' );
-
-			expect( element.hasAttr( fooAttr ) ).to.be.false;
-		} );
-
-		it( 'should create proper JSON string using toJSON method', () => {
-			let b = new Character( 'b' );
-			let foo = new Element( 'foo', [], [ b ] );
-
-			let parsedFoo = JSON.parse( JSON.stringify( foo ) );
-			let parsedBar = JSON.parse( JSON.stringify( b ) );
-
-			expect( parsedFoo.parent ).to.equal( null );
-			expect( parsedBar.parent ).to.equal( 'foo' );
-		} );
-	} );
-
-	describe( 'getAttrs', () => {
-		it( 'should allows to get attribute count', () => {
-			let element = new Element( 'foo', [
-				new Attribute( 1, true ),
-				new Attribute( 2, true ),
-				new Attribute( 3, true )
-			] );
-
-			expect( getIteratorCount( element.getAttrs() ) ).to.equal( 3 );
-		} );
-
-		it( 'should allows to copy attributes', () => {
-			let element = new Element( 'foo', [ new Attribute( 'x', true ) ] );
-			let copy = new Element( 'bar', element.getAttrs() );
-
-			expect( copy.getAttr( 'x' ) ).to.be.true;
-		} );
-	} );
-
-	describe( 'getIndex', () => {
-		it( 'should return null if the parent is null', () => {
-			expect( root.getIndex() ).to.be.null;
-		} );
-
-		it( 'should return index in the parent', () => {
-			expect( one.getIndex() ).to.equal( 0 );
-			expect( two.getIndex() ).to.equal( 1 );
-			expect( three.getIndex() ).to.equal( 2 );
-
-			expect( charB.getIndex() ).to.equal( 0 );
-			expect( charA.getIndex() ).to.equal( 1 );
-			expect( img.getIndex() ).to.equal( 2 );
-			expect( charR.getIndex() ).to.equal( 3 );
-		} );
-
-		it( 'should throw an error if parent does not contains element', () => {
-			let f = new Character( 'f' );
-			let bar = new Element( 'bar', [], [] );
-
-			f.parent = bar;
-
-			expect(
-				() => {
-					f.getIndex();
-				}
-			).to.throw( CKEditorError, /node-not-found-in-parent/ );
-		} );
-	} );
-
-	describe( 'getPath', () => {
-		it( 'should return proper path', () => {
-			expect( root.getPath() ).to.deep.equal( [] );
-
-			expect( one.getPath() ).to.deep.equal( [ 0 ] );
-			expect( two.getPath() ).to.deep.equal( [ 1 ] );
-			expect( three.getPath() ).to.deep.equal( [ 2 ] );
-
-			expect( charB.getPath() ).to.deep.equal( [ 1, 0 ] );
-			expect( charA.getPath() ).to.deep.equal( [ 1, 1 ] );
-			expect( img.getPath() ).to.deep.equal( [ 1, 2 ] );
-			expect( charR.getPath() ).to.deep.equal( [ 1, 3 ] );
-		} );
-	} );
-} );

+ 0 - 115
packages/ckeditor5-utils/tests/document/nodelist.js

@@ -1,115 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document */
-
-'use strict';
-
-const modules = bender.amd.require(
-	'document/nodelist',
-	'document/character',
-	'document/text',
-	'document/attribute'
-);
-
-describe( 'NodeList', () => {
-	let NodeList, Character, Text, Attribute;
-
-	before( () => {
-		NodeList = modules[ 'document/nodelist' ];
-		Character = modules[ 'document/character' ];
-		Text = modules[ 'document/text' ];
-		Attribute = modules[ 'document/attribute' ];
-	} );
-
-	describe( 'constructor', () => {
-		it( 'should change array of strings into a set of nodes', () => {
-			let nodeList = new NodeList( [ 'foo', new Character( 'x' ), 'bar' ] );
-
-			expect( nodeList.length ).to.equal( 7 );
-			expect( nodeList.get( 0 ).character ).to.equal( 'f' );
-			expect( nodeList.get( 1 ).character ).to.equal( 'o' );
-			expect( nodeList.get( 2 ).character ).to.equal( 'o' );
-			expect( nodeList.get( 3 ).character ).to.equal( 'x' );
-			expect( nodeList.get( 4 ).character ).to.equal( 'b' );
-			expect( nodeList.get( 5 ).character ).to.equal( 'a' );
-			expect( nodeList.get( 6 ).character ).to.equal( 'r' );
-		} );
-
-		it( 'should change string into a set of nodes', () => {
-			let nodeList = new NodeList( 'foo' );
-
-			expect( nodeList.length ).to.equal( 3 );
-			expect( nodeList.get( 0 ).character ).to.equal( 'f' );
-			expect( nodeList.get( 1 ).character ).to.equal( 'o' );
-			expect( nodeList.get( 2 ).character ).to.equal( 'o' );
-		} );
-
-		it( 'should change node into a set of nodes', () => {
-			let nodeList = new NodeList( new Character( 'x' ) );
-
-			expect( nodeList.length ).to.equal( 1 );
-			expect( nodeList.get( 0 ).character ).to.equal( 'x' );
-		} );
-
-		it( 'should change text with attribute into a set of nodes', () => {
-			let attr = new Attribute( 'bold', true );
-			let nodeList = new NodeList( new Text( 'foo', [ attr ] ) );
-
-			expect( nodeList.length ).to.equal( 3 );
-			expect( nodeList.get( 0 ).character ).to.equal( 'f' );
-			expect( nodeList.get( 0 ).getAttr( attr.key ) ).to.equal( attr.value );
-			expect( nodeList.get( 1 ).character ).to.equal( 'o' );
-			expect( nodeList.get( 1 ).getAttr( attr.key ) ).to.equal( attr.value );
-			expect( nodeList.get( 2 ).character ).to.equal( 'o' );
-			expect( nodeList.get( 2 ).getAttr( attr.key ) ).to.equal( attr.value );
-		} );
-	} );
-
-	describe( 'insert', () => {
-		it( 'should insert one nodelist into another', () => {
-			let outerList = new NodeList( 'foo' );
-			let innerList = new NodeList( 'xxx' );
-
-			outerList.insert( 2, innerList );
-
-			expect( outerList.length ).to.equal( 6 );
-			expect( outerList.get( 0 ).character ).to.equal( 'f' );
-			expect( outerList.get( 1 ).character ).to.equal( 'o' );
-			expect( outerList.get( 2 ).character ).to.equal( 'x' );
-			expect( outerList.get( 3 ).character ).to.equal( 'x' );
-			expect( outerList.get( 4 ).character ).to.equal( 'x' );
-			expect( outerList.get( 5 ).character ).to.equal( 'o' );
-		} );
-	} );
-
-	describe( 'remove', () => {
-		it( 'should remove part of the nodelist', () => {
-			let nodeList = new NodeList( 'foobar' );
-
-			nodeList.remove( 2, 3 );
-
-			expect( nodeList.length ).to.equal( 3 );
-			expect( nodeList.get( 0 ).character ).to.equal( 'f' );
-			expect( nodeList.get( 1 ).character ).to.equal( 'o' );
-			expect( nodeList.get( 2 ).character ).to.equal( 'r' );
-		} );
-	} );
-
-	describe( 'iterator', () => {
-		it( 'should iterate over all elements in the collection', () => {
-			let characters = 'foo';
-			let nodeList = new NodeList( characters );
-			let i = 0;
-
-			for ( let node of nodeList ) {
-				expect( node.character ).to.equal( characters[ i ] );
-				i++;
-			}
-
-			expect( i ).to.equal( 3 );
-		} );
-	} );
-} );

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

@@ -1,319 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document */
-
-/* bender-include: ../../_tools/tools.js */
-
-'use strict';
-
-const getIteratorCount = bender.tools.core.getIteratorCount;
-
-const modules = bender.amd.require(
-	'document/document',
-	'document/operation/changeoperation',
-	'document/position',
-	'document/range',
-	'document/character',
-	'document/attribute',
-	'document/nodelist',
-	'document/text',
-	'ckeditorerror'
-);
-
-describe( 'ChangeOperation', () => {
-	let Document, ChangeOperation, Position, Range, Character, Attribute, NodeList, Text, CKEditorError;
-
-	before( () => {
-		Document = modules[ 'document/document' ];
-		ChangeOperation = modules[ 'document/operation/changeoperation' ];
-		Position = modules[ 'document/position' ];
-		Range = modules[ 'document/range' ];
-		Character = modules[ 'document/character' ];
-		Attribute = modules[ 'document/attribute' ];
-		NodeList = modules[ 'document/nodelist' ];
-		Text = modules[ 'document/text' ];
-		CKEditorError = modules.ckeditorerror;
-	} );
-
-	let doc, root;
-
-	beforeEach( () => {
-		doc = new Document();
-		root = doc.createRoot( 'root' );
-	} );
-
-	it( 'should insert attribute to the set of nodes', () => {
-		let newAttr = new Attribute( 'isNew', true );
-
-		root.insertChildren( 0, 'bar' );
-
-		doc.applyOperation(
-			new ChangeOperation(
-				new Range( new Position( [ 0 ], root ), new Position( [ 2 ], root ) ),
-				null,
-				newAttr,
-				doc.version
-			)
-		);
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 3 );
-		expect( root.getChild( 0 ).hasAttr( newAttr ) ).to.be.true;
-		expect( root.getChild( 1 ).hasAttr( newAttr ) ).to.be.true;
-		expect( getIteratorCount( root.getChild( 2 ).getAttrs() ) ).to.equal( 0 );
-	} );
-
-	it( 'should add attribute to the existing attributes', () => {
-		let newAttr = new Attribute( 'isNew', true );
-		let fooAttr = new Attribute( 'foo', true );
-		let barAttr = new Attribute( 'bar', true );
-
-		root.insertChildren( 0, new Character( 'x', [ fooAttr, barAttr ] ) );
-
-		doc.applyOperation(
-			new ChangeOperation(
-				new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
-				null,
-				newAttr,
-				doc.version
-			)
-		);
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 1 );
-		expect( getIteratorCount( root.getChild( 0 ).getAttrs() ) ).to.equal( 3 );
-		expect( root.getChild( 0 ).hasAttr( newAttr ) ).to.be.true;
-		expect( root.getChild( 0 ).hasAttr( fooAttr ) ).to.be.true;
-		expect( root.getChild( 0 ).hasAttr( barAttr ) ).to.be.true;
-	} );
-
-	it( 'should change attribute to the set of nodes', () => {
-		let oldAttr = new Attribute( 'isNew', false );
-		let newAttr = new Attribute( 'isNew', true );
-
-		root.insertChildren( 0, new Text( 'bar', [ oldAttr ] ) );
-
-		doc.applyOperation(
-			new ChangeOperation(
-				new Range( new Position( [ 0 ], root ), new Position( [ 2 ], root ) ),
-				oldAttr,
-				newAttr,
-				doc.version
-			)
-		);
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 3 );
-		expect( getIteratorCount( root.getChild( 0 ).getAttrs() ) ).to.equal( 1 );
-		expect( root.getChild( 0 ).hasAttr( newAttr ) ).to.be.true;
-		expect( getIteratorCount( root.getChild( 1 ).getAttrs() ) ).to.equal( 1 );
-		expect( root.getChild( 1 ).hasAttr( newAttr ) ).to.be.true;
-		expect( getIteratorCount( root.getChild( 2 ).getAttrs() ) ).to.equal( 1 );
-		expect( root.getChild( 2 ).hasAttr( oldAttr ) ).to.be.true;
-	} );
-
-	it( 'should change attribute in the middle of existing attributes', () => {
-		let fooAttr = new Attribute( 'foo', true );
-		let x1Attr = new Attribute( 'x', 1 );
-		let x2Attr = new Attribute( 'x', 2 );
-		let barAttr = new Attribute( 'bar', true );
-
-		root.insertChildren( 0, new Character( 'x', [ fooAttr, x1Attr, barAttr ] ) );
-
-		doc.applyOperation(
-			new ChangeOperation(
-				new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
-				x1Attr,
-				x2Attr,
-				doc.version
-			)
-		);
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 1 );
-		expect( getIteratorCount( root.getChild( 0 ).getAttrs() ) ).to.equal( 3 );
-		expect( root.getChild( 0 ).hasAttr( fooAttr ) ).to.be.true;
-		expect( root.getChild( 0 ).hasAttr( x2Attr ) ).to.be.true;
-		expect( root.getChild( 0 ).hasAttr( barAttr ) ).to.be.true;
-	} );
-
-	it( 'should remove attribute', () => {
-		let fooAttr = new Attribute( 'foo', true );
-		let xAttr = new Attribute( 'x', true );
-		let barAttr = new Attribute( 'bar', true );
-
-		root.insertChildren( 0, new Character( 'x', [ fooAttr, xAttr, barAttr ] ) );
-
-		doc.applyOperation(
-			new ChangeOperation(
-				new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
-				xAttr,
-				null,
-				doc.version
-			)
-		);
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 1 );
-		expect( getIteratorCount( root.getChild( 0 ).getAttrs() ) ).to.equal( 2 );
-		expect( root.getChild( 0 ).hasAttr( fooAttr ) ).to.be.true;
-		expect( root.getChild( 0 ).hasAttr( barAttr ) ).to.be.true;
-	} );
-
-	it( 'should create a change operation as a reverse', () => {
-		let oldAttr = new Attribute( 'x', 'old' );
-		let newAttr = new Attribute( 'x', 'new' );
-		let range = new Range( new Position( [ 0 ], root ), new Position( [ 3 ], root ) );
-		let operation = new ChangeOperation( range, oldAttr, newAttr, doc.version );
-		let reverse = operation.getReversed();
-
-		expect( reverse ).to.be.an.instanceof( ChangeOperation );
-		expect( reverse.baseVersion ).to.equal( 1 );
-		expect( reverse.range ).to.equal( range );
-		expect( reverse.oldAttr ).to.equal( newAttr );
-		expect( reverse.newAttr ).to.equal( oldAttr );
-	} );
-
-	it( 'should undo adding attribute by applying reverse operation', () => {
-		let newAttr = new Attribute( 'isNew', true );
-
-		root.insertChildren( 0, 'bar' );
-
-		let operation = new ChangeOperation(
-			new Range( new Position( [ 0 ], root ), new Position( [ 3 ], root ) ),
-			null,
-			newAttr,
-			doc.version
-		);
-
-		let reverse = operation.getReversed();
-
-		doc.applyOperation( operation );
-		doc.applyOperation( reverse );
-
-		expect( doc.version ).to.equal( 2 );
-		expect( root.getChildCount() ).to.equal( 3 );
-		expect( getIteratorCount( root.getChild( 0 ).getAttrs() ) ).to.equal( 0 );
-		expect( getIteratorCount( root.getChild( 1 ).getAttrs() ) ).to.equal( 0 );
-		expect( getIteratorCount( root.getChild( 2 ).getAttrs() ) ).to.equal( 0 );
-	} );
-
-	it( 'should undo changing attribute by applying reverse operation', () => {
-		let oldAttr = new Attribute( 'isNew', false );
-		let newAttr = new Attribute( 'isNew', true );
-
-		root.insertChildren( 0, new Text( 'bar', [ oldAttr ] ) );
-
-		let operation = new ChangeOperation(
-			new Range( new Position( [ 0 ], root ), new Position( [ 3 ], root ) ),
-			oldAttr,
-			newAttr,
-			doc.version
-		);
-
-		let reverse = operation.getReversed();
-
-		doc.applyOperation( operation );
-
-		doc.applyOperation( reverse );
-
-		expect( doc.version ).to.equal( 2 );
-		expect( root.getChildCount() ).to.equal( 3 );
-		expect( getIteratorCount( root.getChild( 0 ).getAttrs() ) ).to.equal( 1 );
-		expect( root.getChild( 0 ).hasAttr( oldAttr ) ).to.be.true;
-		expect( getIteratorCount( root.getChild( 1 ).getAttrs() ) ).to.equal( 1 );
-		expect( root.getChild( 1 ).hasAttr( oldAttr ) ).to.be.true;
-		expect( getIteratorCount( root.getChild( 2 ).getAttrs() ) ).to.equal( 1 );
-		expect( root.getChild( 2 ).hasAttr( oldAttr ) ).to.be.true;
-	} );
-
-	it( 'should undo remove attribute by applying reverse operation', () => {
-		let fooAttr = new Attribute( 'foo', false );
-
-		root.insertChildren( 0, new Text( 'bar', [ fooAttr ] ) );
-
-		let operation = new ChangeOperation(
-			new Range( new Position( [ 0 ], root ), new Position( [ 3 ], root ) ),
-			fooAttr,
-			null,
-			doc.version
-		);
-
-		let reverse = operation.getReversed();
-
-		doc.applyOperation( operation );
-
-		doc.applyOperation( reverse );
-
-		expect( doc.version ).to.equal( 2 );
-		expect( root.getChildCount() ).to.equal( 3 );
-		expect( getIteratorCount( root.getChild( 0 ).getAttrs() ) ).to.equal( 1 );
-		expect( root.getChild( 0 ).hasAttr( fooAttr ) ).to.be.true;
-		expect( getIteratorCount( root.getChild( 1 ).getAttrs() ) ).to.equal( 1 );
-		expect( root.getChild( 1 ).hasAttr( fooAttr ) ).to.be.true;
-		expect( getIteratorCount( root.getChild( 2 ).getAttrs() ) ).to.equal( 1 );
-		expect( root.getChild( 2 ).hasAttr( fooAttr ) ).to.be.true;
-	} );
-
-	it( 'should throw an error when one try to remove and the attribute does not exists', () => {
-		let fooAttr = new Attribute( 'foo', true );
-
-		root.insertChildren( 0, 'x' );
-
-		expect(
-			() => {
-				doc.applyOperation(
-					new ChangeOperation(
-						new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
-						fooAttr,
-						null,
-						doc.version
-					)
-				);
-			}
-		).to.throw( CKEditorError, /operation-change-no-attr-to-remove/ );
-	} );
-
-	it( 'should throw an error when one try to insert and the attribute already exists', () => {
-		let x1Attr = new Attribute( 'x', 1 );
-		let x2Attr = new Attribute( 'x', 2 );
-
-		root.insertChildren( 0, new Character( 'x', [ x1Attr ] ) );
-
-		expect(
-			() => {
-				doc.applyOperation(
-					new ChangeOperation(
-						new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
-						null,
-						x2Attr,
-						doc.version
-					)
-				);
-			}
-		).to.throw( CKEditorError, /operation-change-attr-exists/ );
-	} );
-
-	it( 'should throw an error when one try to change and the new and old attributes have different keys', () => {
-		let fooAttr = new Attribute( 'foo', true );
-		let barAttr = new Attribute( 'bar', true );
-
-		root.insertChildren( 0, 'x' );
-
-		expect(
-			() => {
-				doc.applyOperation(
-					new ChangeOperation(
-						new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
-						fooAttr,
-						barAttr,
-						doc.version
-					)
-				);
-			}
-		).to.throw( CKEditorError, /operation-change-different-keys/ );
-	} );
-} );

+ 0 - 160
packages/ckeditor5-utils/tests/document/operation/insertoperation.js

@@ -1,160 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document */
-
-'use strict';
-
-const modules = bender.amd.require(
-	'document/document',
-	'document/operation/insertoperation',
-	'document/operation/removeoperation',
-	'document/position',
-	'document/character',
-	'document/nodelist'
-);
-
-describe( 'InsertOperation', () => {
-	let Document, InsertOperation, RemoveOperation, Position, Character;
-
-	before( () => {
-		Document = modules[ 'document/document' ];
-		InsertOperation = modules[ 'document/operation/insertoperation' ];
-		RemoveOperation = modules[ 'document/operation/removeoperation' ];
-		Position = modules[ 'document/position' ];
-		Character = modules[ 'document/character' ];
-	} );
-
-	let doc, root;
-
-	beforeEach( () => {
-		doc = new Document();
-		root = doc.createRoot( 'root' );
-	} );
-
-	it( 'should insert node', () => {
-		doc.applyOperation(
-			new InsertOperation(
-				new Position( [ 0 ], root ),
-				new Character( 'x' ),
-				doc.version
-			)
-		);
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 1 );
-		expect( root.getChild( 0 ).character ).to.equal( 'x' );
-	} );
-
-	it( 'should insert set of nodes', () => {
-		doc.applyOperation(
-			new InsertOperation(
-				new Position( [ 0 ], root ),
-				'bar',
-				doc.version
-			)
-		);
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 3 );
-		expect( root.getChild( 0 ).character ).to.equal( 'b' );
-		expect( root.getChild( 1 ).character ).to.equal( 'a' );
-		expect( root.getChild( 2 ).character ).to.equal( 'r' );
-	} );
-
-	it( 'should insert between existing nodes', () => {
-		root.insertChildren( 0, 'xy' );
-
-		doc.applyOperation(
-			new InsertOperation(
-				new Position( [ 1 ], root ),
-				'bar',
-				doc.version
-			)
-		);
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 5 );
-		expect( root.getChild( 0 ).character ).to.equal( 'x' );
-		expect( root.getChild( 1 ).character ).to.equal( 'b' );
-		expect( root.getChild( 2 ).character ).to.equal( 'a' );
-		expect( root.getChild( 3 ).character ).to.equal( 'r' );
-		expect( root.getChild( 4 ).character ).to.equal( 'y' );
-	} );
-
-	it( 'should insert text', () => {
-		doc.applyOperation(
-			new InsertOperation(
-				new Position( [ 0 ], root ),
-				[ 'foo', new Character( 'x' ), 'bar' ],
-				doc.version
-			)
-		);
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 7 );
-		expect( root.getChild( 0 ).character ).to.equal( 'f' );
-		expect( root.getChild( 1 ).character ).to.equal( 'o' );
-		expect( root.getChild( 2 ).character ).to.equal( 'o' );
-		expect( root.getChild( 3 ).character ).to.equal( 'x' );
-		expect( root.getChild( 4 ).character ).to.equal( 'b' );
-		expect( root.getChild( 5 ).character ).to.equal( 'a' );
-		expect( root.getChild( 6 ).character ).to.equal( 'r' );
-	} );
-
-	it( 'should create a remove operation as a reverse', () => {
-		let position = new Position( [ 0 ], root );
-		let operation = new InsertOperation(
-			position,
-			[ 'foo', new Character( 'x' ), 'bar' ],
-			0
-		);
-
-		let reverse = operation.getReversed();
-
-		expect( reverse ).to.be.an.instanceof( RemoveOperation );
-		expect( reverse.baseVersion ).to.equal( 1 );
-		expect( reverse.sourcePosition ).to.equal( position );
-		expect( reverse.howMany ).to.equal( 7 );
-	} );
-
-	it( 'should undo insert node by applying reverse operation', () => {
-		let operation = new InsertOperation(
-			new Position( [ 0 ], root ),
-			new Character( 'x' ),
-			doc.version
-		);
-
-		let reverse = operation.getReversed();
-
-		doc.applyOperation( operation );
-
-		expect( doc.version ).to.equal( 1 );
-
-		doc.applyOperation( reverse );
-
-		expect( doc.version ).to.equal( 2 );
-		expect( root.getChildCount() ).to.equal( 0 );
-	} );
-
-	it( 'should undo insert set of nodes by applying reverse operation', () => {
-		let operation = new InsertOperation(
-			new Position( [ 0 ], root ),
-			'bar',
-			doc.version
-		);
-
-		let reverse = operation.getReversed();
-
-		doc.applyOperation( operation );
-
-		expect( doc.version ).to.equal( 1 );
-
-		doc.applyOperation( reverse );
-
-		expect( doc.version ).to.equal( 2 );
-		expect( root.getChildCount() ).to.equal( 0 );
-	} );
-} );

+ 0 - 245
packages/ckeditor5-utils/tests/document/operation/moveoperation.js

@@ -1,245 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document */
-
-'use strict';
-
-const modules = bender.amd.require(
-	'document/document',
-	'document/operation/moveoperation',
-	'document/position',
-	'document/element',
-	'document/nodelist',
-	'ckeditorerror'
-);
-
-describe( 'MoveOperation', () => {
-	let Document, MoveOperation, Position, Element, NodeList, CKEditorError;
-
-	before( () => {
-		Document = modules[ 'document/document' ];
-		MoveOperation = modules[ 'document/operation/moveoperation' ];
-		Position = modules[ 'document/position' ];
-		Element = modules[ 'document/element' ];
-		NodeList = modules[ 'document/nodelist' ];
-		CKEditorError = modules.ckeditorerror;
-	} );
-
-	let doc, root;
-
-	beforeEach( () => {
-		doc = new Document();
-		root = doc.createRoot( 'root' );
-	} );
-
-	it( 'should move from one node to another', () => {
-		let p1 = new Element( 'p1', [], new Element( 'x' ) );
-		let p2 = new Element( 'p2' );
-
-		root.insertChildren( 0, [ p1, p2 ] );
-
-		doc.applyOperation(
-			new MoveOperation(
-				new Position( [ 0, 0 ], root ),
-				new Position( [ 1, 0 ], root ),
-				1,
-				doc.version
-			)
-		);
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 2 );
-		expect( root.getChild( 0 ).name ).to.equal( 'p1' );
-		expect( root.getChild( 1 ).name ).to.equal( 'p2' );
-		expect( p1.getChildCount() ).to.equal( 0 );
-		expect( p2.getChildCount() ).to.equal( 1 );
-		expect( p2.getChild( 0 ).name ).to.equal( 'x' );
-	} );
-
-	it( 'should move position of children in one node backward', () => {
-		root.insertChildren( 0, 'xbarx' );
-
-		doc.applyOperation(
-			new MoveOperation(
-				new Position( [ 2 ], root ),
-				new Position( [ 1 ], root ),
-				2,
-				doc.version
-			)
-		);
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 5 );
-		expect( root.getChild( 0 ).character ).to.equal( 'x' );
-		expect( root.getChild( 1 ).character ).to.equal( 'a' );
-		expect( root.getChild( 2 ).character ).to.equal( 'r' );
-		expect( root.getChild( 3 ).character ).to.equal( 'b' );
-		expect( root.getChild( 4 ).character ).to.equal( 'x' );
-	} );
-
-	it( 'should move position of children in one node forward', () => {
-		root.insertChildren( 0, 'xbarx' );
-
-		doc.applyOperation(
-			new MoveOperation(
-				new Position( [ 1 ], root ),
-				new Position( [ 4 ], root ),
-				2,
-				doc.version
-			)
-		);
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 5 );
-		expect( root.getChild( 0 ).character ).to.equal( 'x' );
-		expect( root.getChild( 1 ).character ).to.equal( 'r' );
-		expect( root.getChild( 2 ).character ).to.equal( 'b' );
-		expect( root.getChild( 3 ).character ).to.equal( 'a' );
-		expect( root.getChild( 4 ).character ).to.equal( 'x' );
-	} );
-
-	it( 'should create a move operation as a reverse', () => {
-		let nodeList = new NodeList( 'bar' );
-
-		let sourcePosition = new Position( [ 0 ], root );
-		let targetPosition = new Position( [ 4 ], root );
-
-		let operation = new MoveOperation( sourcePosition, targetPosition, nodeList.length, doc.version );
-
-		let reverse = operation.getReversed();
-
-		expect( reverse ).to.be.an.instanceof( MoveOperation );
-		expect( reverse.baseVersion ).to.equal( 1 );
-		expect( reverse.howMany ).to.equal( nodeList.length );
-		expect( reverse.sourcePosition ).to.equal( targetPosition );
-		expect( reverse.targetPosition ).to.equal( sourcePosition );
-	} );
-
-	it( 'should undo move node by applying reverse operation', () => {
-		let p1 = new Element( 'p1', [], new Element( 'x' ) );
-		let p2 = new Element( 'p2' );
-
-		root.insertChildren( 0, [ p1, p2 ] );
-
-		let operation = new MoveOperation(
-			new Position( [ 0, 0 ], root ),
-			new Position( [ 1, 0 ], root ),
-			1,
-			doc.version
-		);
-
-		doc.applyOperation( operation );
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 2 );
-		expect( p1.getChildCount() ).to.equal( 0 );
-		expect( p2.getChildCount() ).to.equal( 1 );
-		expect( p2.getChild( 0 ).name ).to.equal( 'x' );
-
-		doc.applyOperation( operation.getReversed() );
-
-		expect( doc.version ).to.equal( 2 );
-		expect( root.getChildCount() ).to.equal( 2 );
-		expect( p1.getChildCount() ).to.equal( 1 );
-		expect( p1.getChild( 0 ).name ).to.equal( 'x' );
-		expect( p2.getChildCount() ).to.equal( 0 );
-	} );
-
-	it( 'should throw an error if number of nodes to move exceeds the number of existing nodes in given element', () => {
-		root.insertChildren( 0, 'xbarx' );
-
-		expect(
-			() => {
-				doc.applyOperation(
-					new MoveOperation(
-						new Position( [ 3 ], root ),
-						new Position( [ 1 ], root ),
-						3,
-						doc.version
-					)
-				);
-			}
-		).to.throw( CKEditorError, /operation-move-nodes-do-not-exist/ );
-	} );
-
-	it( 'should throw an error if target or source parent-element specified by position does not exist', () => {
-		let p = new Element( 'p' );
-		p.insertChildren( 0, 'foo' );
-		root.insertChildren( 0, [ 'ab', p ] );
-
-		let operation = new MoveOperation(
-			new Position( [ 2, 0 ], root ),
-			new Position( [ 1 ], root ),
-			3,
-			doc.version
-		);
-
-		root.removeChildren( 2, 1 );
-
-		expect(
-			() => {
-				doc.applyOperation( operation );
-			}
-		).to.throw( CKEditorError, /operation-move-position-invalid/ );
-	} );
-
-	it( 'should throw an error if operation tries to move a range between the beginning and the end of that range', () => {
-		root.insertChildren( 0, 'xbarx' );
-
-		let operation = new MoveOperation(
-			new Position( [ 1 ], root ),
-			new Position( [ 2 ], root ),
-			3,
-			doc.version
-		);
-
-		expect(
-			() => {
-				doc.applyOperation( operation );
-			}
-		).to.throw( CKEditorError, /operation-move-range-into-itself/ );
-	} );
-
-	it( 'should throw an error if operation tries to move a range into a sub-tree of a node that is in that range', () => {
-		let p = new Element( 'p', [], [ new Element( 'p' ) ] );
-		root.insertChildren( 0, [ 'ab', p, 'xy' ] );
-
-		let operation = new MoveOperation(
-			new Position( [ 1 ], root ),
-			new Position( [ 2, 0, 0 ], root ),
-			3,
-			doc.version
-		);
-
-		expect(
-			() => {
-				doc.applyOperation( operation );
-			}
-		).to.throw( CKEditorError, /operation-move-node-into-itself/ );
-	} );
-
-	it( 'should not throw an error if operation move a range into a sibling', () => {
-		let p = new Element( 'p' );
-		root.insertChildren( 0, [ 'ab', p, 'xy' ] );
-
-		let operation = new MoveOperation(
-			new Position( [ 1 ], root ),
-			new Position( [ 2, 0 ], root ),
-			1,
-			doc.version
-		);
-
-		expect(
-			() => {
-				doc.applyOperation( operation );
-			}
-		).not.to.throw();
-
-		expect( root.getChildCount() ).to.equal( 4 );
-		expect( p.getChildCount() ).to.equal( 1 );
-		expect( p.getChild( 0 ).character ).to.equal( 'b' );
-	} );
-} );

+ 0 - 81
packages/ckeditor5-utils/tests/document/operation/reinsertoperation.js

@@ -1,81 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document */
-
-'use strict';
-
-const modules = bender.amd.require(
-	'document/document',
-	'document/operation/reinsertoperation',
-	'document/operation/removeoperation',
-	'document/operation/moveoperation',
-	'document/position'
-);
-
-describe( 'ReinsertOperation', () => {
-	let Document, ReinsertOperation, RemoveOperation, MoveOperation, Position;
-
-	before( () => {
-		Document = modules[ 'document/document' ];
-		ReinsertOperation = modules[ 'document/operation/reinsertoperation' ];
-		RemoveOperation = modules[ 'document/operation/removeoperation' ];
-		MoveOperation = modules[ 'document/operation/moveoperation' ];
-		Position = modules[ 'document/position' ];
-	} );
-
-	let doc, root, graveyard, operation, graveyardPosition, rootPosition;
-
-	beforeEach( () => {
-		doc = new Document();
-		root = doc.createRoot( 'root' );
-		graveyard = doc._graveyard;
-
-		graveyardPosition = new Position( [ 0 ], graveyard );
-		rootPosition = new Position( [ 0 ], root );
-
-		operation = new ReinsertOperation(
-			graveyardPosition,
-			rootPosition,
-			2,
-			doc.version
-		);
-	} );
-
-	it( 'should extend MoveOperation class', () => {
-		expect( operation ).to.be.instanceof( MoveOperation );
-	} );
-
-	it( 'should create a remove operation as a reverse', () => {
-		let reverse = operation.getReversed();
-
-		expect( reverse ).to.be.an.instanceof( RemoveOperation );
-		expect( reverse.baseVersion ).to.equal( 1 );
-		expect( reverse.howMany ).to.equal( 2 );
-		expect( reverse.sourcePosition.isEqual( rootPosition ) ).to.be.true;
-		expect( reverse.targetPosition.isEqual( graveyardPosition ) ).to.be.true;
-	} );
-
-	it( 'should undo reinsert set of nodes by applying reverse operation', () => {
-		let reverse = operation.getReversed();
-
-		graveyard.insertChildren( 0, 'bar' );
-
-		doc.applyOperation( operation );
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 2 );
-
-		doc.applyOperation( reverse );
-
-		expect( doc.version ).to.equal( 2 );
-		expect( root.getChildCount() ).to.equal( 0 );
-		expect( graveyard.getChildCount() ).to.equal( 3 );
-
-		expect( graveyard.getChild( 0 ).character ).to.equal( 'b' );
-		expect( graveyard.getChild( 1 ).character ).to.equal( 'a' );
-		expect( graveyard.getChild( 2 ).character ).to.equal( 'r' );
-	} );
-} );

+ 0 - 103
packages/ckeditor5-utils/tests/document/operation/removeoperation.js

@@ -1,103 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document */
-
-'use strict';
-
-const modules = bender.amd.require(
-	'document/document',
-	'document/operation/reinsertoperation',
-	'document/operation/removeoperation',
-	'document/operation/moveoperation',
-	'document/position'
-);
-
-describe( 'RemoveOperation', () => {
-	let Document, ReinsertOperation, RemoveOperation, MoveOperation, Position;
-
-	before( () => {
-		Document = modules[ 'document/document' ];
-		ReinsertOperation = modules[ 'document/operation/reinsertoperation' ];
-		RemoveOperation = modules[ 'document/operation/removeoperation' ];
-		MoveOperation = modules[ 'document/operation/removeoperation' ];
-		Position = modules[ 'document/position' ];
-	} );
-
-	let doc, root, graveyard;
-
-	beforeEach( () => {
-		doc = new Document();
-		root = doc.createRoot( 'root' );
-		graveyard = doc._graveyard;
-	} );
-
-	it( 'should extend MoveOperation class', () => {
-		let operation = new RemoveOperation(
-			new Position( [ 2 ], root ),
-			2,
-			doc.version
-		);
-
-		expect( operation ).to.be.instanceof( MoveOperation );
-	} );
-
-	it( 'should remove set of nodes and append them to graveyard root', () => {
-		root.insertChildren( 0, 'fozbar' );
-
-		let z = root.getChild( 2 );
-		let b = root.getChild( 3 );
-		let a = root.getChild( 4 );
-
-		doc.applyOperation(
-			new RemoveOperation(
-				new Position( [ 2 ], root ),
-				2,
-				doc.version
-			)
-		);
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 4 );
-		expect( root.getChild( 2 ) ).to.equal( a );
-
-		expect( graveyard.getChildCount() ).to.equal( 2 );
-		expect( graveyard.getChild( 0 ) ).to.equal( z );
-		expect( graveyard.getChild( 1 ) ).to.equal( b );
-	} );
-
-	it( 'should create a reinsert operation as a reverse', () => {
-		let position = new Position( [ 0 ], root );
-		let operation = new RemoveOperation( position, 2, 0 );
-		let reverse = operation.getReversed();
-
-		expect( reverse ).to.be.an.instanceof( ReinsertOperation );
-		expect( reverse.baseVersion ).to.equal( 1 );
-		expect( reverse.howMany ).to.equal( 2 );
-		expect( reverse.sourcePosition ).to.equal( operation.targetPosition );
-		expect( reverse.targetPosition ).to.equal( position );
-	} );
-
-	it( 'should undo remove set of nodes by applying reverse operation', () => {
-		let position = new Position( [ 0 ], root );
-		let operation = new RemoveOperation( position, 3, 0 );
-		let reverse = operation.getReversed();
-
-		root.insertChildren( 0, 'bar' );
-
-		doc.applyOperation( operation );
-
-		expect( doc.version ).to.equal( 1 );
-		expect( root.getChildCount() ).to.equal( 0 );
-
-		doc.applyOperation( reverse );
-
-		expect( doc.version ).to.equal( 2 );
-		expect( root.getChildCount() ).to.equal( 3 );
-		expect( root.getChild( 0 ).character ).to.equal( 'b' );
-		expect( root.getChild( 1 ).character ).to.equal( 'a' );
-		expect( root.getChild( 2 ).character ).to.equal( 'r' );
-	} );
-} );

+ 0 - 229
packages/ckeditor5-utils/tests/document/position.js

@@ -1,229 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document */
-
-'use strict';
-
-const modules = bender.amd.require(
-	'document/element',
-	'document/character',
-	'document/position',
-	'document/document',
-	'ckeditorerror',
-	'document/nodelist'
-);
-
-describe( 'position', () => {
-	let Element, Character, Document, NodeList, Position, CKEditorError;
-
-	let doc, root, p, ul, li1, li2, f, o, z, b, a, r;
-
-	// root
-	//  |- p         Before: [ 0 ]       After: [ 1 ]
-	//  |- ul        Before: [ 1 ]       After: [ 2 ]
-	//     |- li     Before: [ 1, 0 ]    After: [ 1, 1 ]
-	//     |  |- f   Before: [ 1, 0, 0 ] After: [ 1, 0, 1 ]
-	//     |  |- o   Before: [ 1, 0, 1 ] After: [ 1, 0, 2 ]
-	//     |  |- z   Before: [ 1, 0, 2 ] After: [ 1, 0, 3 ]
-	//     |- li     Before: [ 1, 1 ]    After: [ 1, 2 ]
-	//        |- b   Before: [ 1, 1, 0 ] After: [ 1, 1, 1 ]
-	//        |- a   Before: [ 1, 1, 1 ] After: [ 1, 1, 2 ]
-	//        |- r   Before: [ 1, 1, 2 ] After: [ 1, 1, 3 ]
-	before( () => {
-		Element = modules[ 'document/element' ];
-		Character = modules[ 'document/character' ];
-		Document = modules[ 'document/document' ];
-		NodeList = modules[ 'document/nodelist' ];
-		Position = modules[ 'document/position' ];
-		CKEditorError = modules.ckeditorerror;
-
-		doc = new Document();
-
-		root = doc.createRoot( 'root' );
-
-		f = new Character( 'f' );
-		o = new Character( 'o' );
-		z = new Character( 'z' );
-
-		li1 = new Element( 'li', [], [ f, o, z ] );
-
-		b = new Character( 'b' );
-		a = new Character( 'a' );
-		r = new Character( 'r' );
-
-		li2 = new Element( 'li', [], [ b, a, r ] );
-
-		ul = new Element( 'ul', [], [ li1, li2 ] );
-
-		p = new Element( 'p' );
-
-		root.insertChildren( 0, [ p, ul ] );
-	} );
-
-	it( 'should create a position with path and document', () => {
-		let position = new Position( [ 0 ], root );
-
-		expect( position ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
-		expect( position ).to.have.property( 'root' ).that.equals( root );
-	} );
-
-	it( 'should make positions form node and offset', () => {
-		expect( Position.createFromParentAndOffset( root, 0 ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
-		expect( Position.createFromParentAndOffset( root, 1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
-		expect( Position.createFromParentAndOffset( root, 2 ) ).to.have.property( 'path' ).that.deep.equals( [ 2 ] );
-
-		expect( Position.createFromParentAndOffset( p, 0 ) ).to.have.property( 'path' ).that.deep.equals( [ 0, 0 ] );
-
-		expect( Position.createFromParentAndOffset( ul, 0 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0 ] );
-		expect( Position.createFromParentAndOffset( ul, 1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
-		expect( Position.createFromParentAndOffset( ul, 2 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 2 ] );
-
-		expect( Position.createFromParentAndOffset( li1, 0 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 0 ] );
-		expect( Position.createFromParentAndOffset( li1, 1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
-		expect( Position.createFromParentAndOffset( li1, 2 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
-		expect( Position.createFromParentAndOffset( li1, 3 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 3 ] );
-	} );
-
-	it( 'should make positions before elements', () => {
-		expect( Position.createBefore( p ) ).to.have.property( 'path' ).that.deep.equals( [ 0 ] );
-
-		expect( Position.createBefore( ul ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
-
-		expect( Position.createBefore( li1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0 ] );
-
-		expect( Position.createBefore( f ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 0 ] );
-		expect( Position.createBefore( o ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
-		expect( Position.createBefore( z ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
-
-		expect( Position.createBefore( li2 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
-
-		expect( Position.createBefore( b ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 0 ] );
-		expect( Position.createBefore( a ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
-		expect( Position.createBefore( r ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
-	} );
-
-	it( 'should throw error if one try to make positions before root', () => {
-		expect(
-			() => {
-				Position.createBefore( root );
-			}
-		).to.throw( CKEditorError, /position-before-root/ );
-	} );
-
-	it( 'should make positions after elements', () => {
-		expect( Position.createAfter( p ) ).to.have.property( 'path' ).that.deep.equals( [ 1 ] );
-
-		expect( Position.createAfter( ul ) ).to.have.property( 'path' ).that.deep.equals( [ 2 ] );
-
-		expect( Position.createAfter( li1 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1 ] );
-
-		expect( Position.createAfter( f ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 1 ] );
-		expect( Position.createAfter( o ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 2 ] );
-		expect( Position.createAfter( z ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 0, 3 ] );
-
-		expect( Position.createAfter( li2 ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 2 ] );
-
-		expect( Position.createAfter( b ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 1 ] );
-		expect( Position.createAfter( a ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 2 ] );
-		expect( Position.createAfter( r ) ).to.have.property( 'path' ).that.deep.equals( [ 1, 1, 3 ] );
-	} );
-
-	it( 'should throw error if one try to make positions after root', () => {
-		expect(
-			() => {
-				Position.createAfter( root );
-			}
-		).to.throw( CKEditorError, /position-after-root/ );
-	} );
-
-	it( 'should have parent', () => {
-		expect( new Position( [ 0 ], root ) ).to.have.property( 'parent' ).that.equals( root );
-		expect( new Position( [ 1 ], root ) ).to.have.property( 'parent' ).that.equals( root );
-		expect( new Position( [ 2 ], root ) ).to.have.property( 'parent' ).that.equals( root );
-
-		expect( new Position( [ 0, 0 ], root ) ).to.have.property( 'parent' ).that.equals( p );
-
-		expect( new Position( [ 1, 0 ], root ) ).to.have.property( 'parent' ).that.equals( ul );
-		expect( new Position( [ 1, 1 ], root ) ).to.have.property( 'parent' ).that.equals( ul );
-		expect( new Position( [ 1, 2 ], root ) ).to.have.property( 'parent' ).that.equals( ul );
-
-		expect( new Position( [ 1, 0, 0 ], root ) ).to.have.property( 'parent' ).that.equals( li1 );
-		expect( new Position( [ 1, 0, 1 ], root ) ).to.have.property( 'parent' ).that.equals( li1 );
-		expect( new Position( [ 1, 0, 2 ], root ) ).to.have.property( 'parent' ).that.equals( li1 );
-		expect( new Position( [ 1, 0, 3 ], root ) ).to.have.property( 'parent' ).that.equals( li1 );
-	} );
-
-	it( 'should have offset', () => {
-		expect( new Position( [ 0 ], root ) ).to.have.property( 'offset' ).that.equals( 0 );
-		expect( new Position( [ 1 ], root ) ).to.have.property( 'offset' ).that.equals( 1 );
-		expect( new Position( [ 2 ], root ) ).to.have.property( 'offset' ).that.equals( 2 );
-
-		expect( new Position( [ 0, 0 ], root ) ).to.have.property( 'offset' ).that.equals( 0 );
-
-		expect( new Position( [ 1, 0 ], root ) ).to.have.property( 'offset' ).that.equals( 0 );
-		expect( new Position( [ 1, 1 ], root ) ).to.have.property( 'offset' ).that.equals( 1 );
-		expect( new Position( [ 1, 2 ], root ) ).to.have.property( 'offset' ).that.equals( 2 );
-
-		expect( new Position( [ 1, 0, 0 ], root ) ).to.have.property( 'offset' ).that.equals( 0 );
-		expect( new Position( [ 1, 0, 1 ], root ) ).to.have.property( 'offset' ).that.equals( 1 );
-		expect( new Position( [ 1, 0, 2 ], root ) ).to.have.property( 'offset' ).that.equals( 2 );
-		expect( new Position( [ 1, 0, 3 ], root ) ).to.have.property( 'offset' ).that.equals( 3 );
-	} );
-
-	it( 'should have nodeBefore', () => {
-		expect( new Position( [ 0 ], root ) ).to.have.property( 'nodeBefore' ).that.is.null;
-		expect( new Position( [ 1 ], root ) ).to.have.property( 'nodeBefore' ).that.equals( p );
-		expect( new Position( [ 2 ], root ) ).to.have.property( 'nodeBefore' ).that.equals( ul );
-
-		expect( new Position( [ 0, 0 ], root ) ).to.have.property( 'nodeBefore' ).that.is.null;
-
-		expect( new Position( [ 1, 0 ], root ) ).to.have.property( 'nodeBefore' ).that.is.null;
-		expect( new Position( [ 1, 1 ], root ) ).to.have.property( 'nodeBefore' ).that.equals( li1 );
-		expect( new Position( [ 1, 2 ], root ) ).to.have.property( 'nodeBefore' ).that.equals( li2 );
-
-		expect( new Position( [ 1, 0, 0 ], root ) ).to.have.property( 'nodeBefore' ).that.is.null;
-		expect( new Position( [ 1, 0, 1 ], root ) ).to.have.property( 'nodeBefore' ).that.equals( f );
-		expect( new Position( [ 1, 0, 2 ], root ) ).to.have.property( 'nodeBefore' ).that.equals( o );
-		expect( new Position( [ 1, 0, 3 ], root ) ).to.have.property( 'nodeBefore' ).that.equals( z );
-	} );
-
-	it( 'should have nodeAfter', () => {
-		expect( new Position( [ 0 ], root ) ).to.have.property( 'nodeAfter' ).that.equals( p );
-		expect( new Position( [ 1 ], root ) ).to.have.property( 'nodeAfter' ).that.equals( ul );
-		expect( new Position( [ 2 ], root ) ).to.have.property( 'nodeAfter' ).that.is.null;
-
-		expect( new Position( [ 0, 0 ], root ) ).to.have.property( 'nodeAfter' ).that.is.null;
-
-		expect( new Position( [ 1, 0 ], root ) ).to.have.property( 'nodeAfter' ).that.equals( li1 );
-		expect( new Position( [ 1, 1 ], root ) ).to.have.property( 'nodeAfter' ).that.equals( li2 );
-		expect( new Position( [ 1, 2 ], root ) ).to.have.property( 'nodeAfter' ).that.is.null;
-
-		expect( new Position( [ 1, 0, 0 ], root ) ).to.have.property( 'nodeAfter' ).that.equals( f );
-		expect( new Position( [ 1, 0, 1 ], root ) ).to.have.property( 'nodeAfter' ).that.equals( o );
-		expect( new Position( [ 1, 0, 2 ], root ) ).to.have.property( 'nodeAfter' ).that.equals( z );
-		expect( new Position( [ 1, 0, 3 ], root ) ).to.have.property( 'nodeAfter' ).that.is.null;
-	} );
-
-	it( 'should equals another position with the same path', () => {
-		let position = new Position( [ 1, 1, 2 ], root );
-		let samePosition = new Position( [ 1, 1, 2 ], root );
-
-		expect( position.isEqual( samePosition ) ).to.be.true;
-	} );
-
-	it( 'should not equals another position with the different path', () => {
-		let position = new Position( [ 1, 1, 1 ], root );
-		let differentNode = new Position( [ 1, 2, 2 ], root );
-
-		expect( position.isEqual( differentNode ) ).to.be.false;
-	} );
-
-	it( 'should have proper parent path', () => {
-		let position = new Position( [ 1, 2, 3 ], root );
-
-		expect( position.getParentPath() ).to.deep.equal( [ 1, 2 ] );
-	} );
-} );

+ 0 - 137
packages/ckeditor5-utils/tests/document/positioniterator.js

@@ -1,137 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document */
-
-'use strict';
-
-const modules = bender.amd.require(
-	'document/document',
-	'document/element',
-	'document/character',
-	'document/positioniterator',
-	'document/position',
-	'document/range'
-);
-
-describe( 'range iterator', () => {
-	let Document, Element, Character, PositionIterator, Position, Range;
-	let ELEMENT_ENTER, ELEMENT_LEAVE, CHARACTER;
-
-	let doc, expectedItems, root, img1, paragraph, b, a, r, img2, x;
-
-	before( () => {
-		Document = modules[ 'document/document' ];
-		Element = modules[ 'document/element' ];
-		Character = modules[ 'document/character' ];
-		PositionIterator = modules[ 'document/positioniterator' ];
-		Position = modules[ 'document/position' ];
-		Range = modules[ 'document/range' ];
-
-		ELEMENT_ENTER = PositionIterator.ELEMENT_ENTER;
-		ELEMENT_LEAVE = PositionIterator.ELEMENT_LEAVE;
-		CHARACTER = PositionIterator.CHARACTER;
-
-		doc = new Document();
-		root = doc.createRoot( 'root' );
-
-		// root
-		//  |- img1
-		//  |- p
-		//     |- B
-		//     |- A
-		//     |- R
-		//     |
-		//     |- img2
-		//     |
-		//     |- X
-
-		b = new Character( 'b' );
-		a = new Character( 'a' );
-		r = new Character( 'r' );
-		img2 = new Element( 'img2' );
-		x = new Character( 'x' );
-
-		paragraph = new Element( 'p', [], [ b, a, r, img2, x ] );
-		img1 = new Element( 'img1' );
-
-		root.insertChildren( 0, [ img1, paragraph ] );
-
-		expectedItems = [
-			{ type: ELEMENT_ENTER, node: img1 },
-			{ type: ELEMENT_LEAVE, node: img1 },
-			{ type: ELEMENT_ENTER, node: paragraph },
-			{ type: CHARACTER, node: b },
-			{ type: CHARACTER, node: a },
-			{ type: CHARACTER, node: r },
-			{ type: ELEMENT_ENTER, node: img2 },
-			{ type: ELEMENT_LEAVE, node: img2 },
-			{ type: CHARACTER, node: x },
-			{ type: ELEMENT_LEAVE, node: paragraph }
-		];
-	} );
-
-	it( 'should return next position', () => {
-		let iterator = new PositionIterator( new Position( [ 0 ], root ) ); // beginning of root
-		let i, len;
-
-		for ( i = 0, len = expectedItems.length; i < len; i++ ) {
-			expect( iterator.next() ).to.deep.equal( { done: false, value: expectedItems[ i ] } );
-		}
-		expect( iterator.next() ).to.have.property( 'done' ).that.is.true;
-	} );
-
-	it( 'should return previous position', () => {
-		let iterator = new PositionIterator( new Position( [ 2 ], root ) ); // ending of root
-
-		for ( let i = expectedItems.length - 1; i >= 0; i-- ) {
-			expect( iterator.previous() ).to.deep.equal( { done: false, value: expectedItems[ i ] } );
-		}
-		expect( iterator.previous() ).to.have.property( 'done' ).that.is.true;
-	} );
-
-	it( 'should return next position in the boundaries', () => {
-		let start = new Position( [ 1, 0 ], root ); // p, 0
-		let end = new Position( [ 1, 3, 0 ], root ); // img, 0
-
-		let iterator = new PositionIterator( new Range( start, end ) );
-
-		let i, len;
-
-		for ( i = 3, len = expectedItems.length; i < 7; i++ ) {
-			expect( iterator.next() ).to.deep.equal( { done: false, value: expectedItems[ i ] } );
-		}
-		expect( iterator.next() ).to.have.property( 'done' ).that.is.true;
-	} );
-
-	it( 'should return previous position in the boundaries', () => {
-		let start = new Position( [ 1, 0 ], root ); // p, 0
-		let end = new Position( [ 1, 3, 0 ], root ); // img, 0
-
-		let iterator = new PositionIterator( new Range( start, end ), end );
-
-		let i, len;
-
-		for ( i = 6, len = expectedItems.length; i > 2; i-- ) {
-			expect( iterator.previous() ).to.deep.equal( { done: false, value: expectedItems[ i ] } );
-		}
-		expect( iterator.previous() ).to.have.property( 'done' ).that.is.true;
-	} );
-
-	it( 'should return iterate over the range', () => {
-		let start = new Position( [ 0 ], root ); // begging of root
-		let end = new Position( [ 2 ], root ); // ending of root
-		let range = new Range( start, end );
-
-		let i = 0;
-		let value;
-
-		for ( value of range ) {
-			expect( value ).to.deep.equal( expectedItems[ i ] );
-			i++;
-		}
-		expect( i ).to.equal( expectedItems.length );
-	} );
-} );

+ 0 - 118
packages/ckeditor5-utils/tests/document/range.js

@@ -1,118 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document */
-
-'use strict';
-
-const modules = bender.amd.require(
-	'document/range',
-	'document/position',
-	'document/element',
-	'document/character',
-	'document/document'
-);
-
-describe( 'Range', () => {
-	let Range, Position, Element, Character, Document;
-
-	let start, end;
-
-	before( () => {
-		Position = modules[ 'document/position' ];
-		Range = modules[ 'document/range' ];
-		Element = modules[ 'document/element' ];
-		Character = modules[ 'document/character' ];
-		Document = modules[ 'document/document' ];
-
-		start = new Position( [ 0 ] );
-		end = new Position( [ 1 ] );
-	} );
-
-	let range;
-
-	beforeEach( () => {
-		range = new Range( start, end );
-	} );
-
-	describe( 'constructor', () => {
-		it( 'should create a range with given positions', () => {
-			expect( range ).to.have.property( 'start' ).that.equal( start );
-			expect( range ).to.have.property( 'end' ).that.equal( end );
-		} );
-	} );
-
-	describe( 'isEqual', () => {
-		it( 'should return true if the ranges are the same', () => {
-			let sameStart = new Position( [ 0 ] );
-			let sameEnd = new Position( [ 1 ] );
-
-			let sameRange = new Range( sameStart, sameEnd );
-
-			expect( range.isEqual( sameRange ) ).to.be.true;
-		} );
-
-		it( 'should return false if the start position is different', () => {
-			let range = new Range( start, end );
-
-			let diffStart = new Position( [ 1 ] );
-			let sameEnd = new Position( [ 1 ] );
-
-			let diffRange = new Range( diffStart, sameEnd );
-
-			expect( range.isEqual( diffRange ) ).to.not.be.true;
-		} );
-
-		it( 'should return false if the end position is different', () => {
-			let sameStart = new Position( [ 0 ] );
-			let diffEnd = new Position( [ 0 ] );
-
-			let diffRange = new Range( sameStart, diffEnd );
-
-			expect( range.isEqual( diffRange ) ).to.not.be.true;
-		} );
-	} );
-
-	describe( 'static constructors', () => {
-		let doc, root, p, f, o, z;
-
-		// root
-		//  |- p
-		//     |- f
-		//     |- o
-		//     |- z
-		before( () => {
-			doc = new Document();
-
-			root = doc.createRoot( 'root' );
-
-			f = new Character( 'f' );
-			o = new Character( 'o' );
-			z = new Character( 'z' );
-
-			p = new Element( 'p', [], [ f, o, z ] );
-
-			root.insertChildren( 0, [ p ] );
-		} );
-
-		describe( 'createFromElement', () => {
-			it( 'should return range', () => {
-				const range = Range.createFromElement( p );
-
-				expect( range.start.path ).to.deep.equal( [ 0, 0 ] );
-				expect( range.end.path ).to.deep.equal( [ 0, 3 ] );
-			} );
-		} );
-
-		describe( 'createFromParentsAndOffsets', () => {
-			it( 'should return range', () => {
-				const range = Range.createFromParentsAndOffsets( root, 0, p, 2 );
-
-				expect( range.start.path ).to.deep.equal( [ 0 ] );
-				expect( range.end.path ).to.deep.equal( [ 0, 2 ] );
-			} );
-		} );
-	} );
-} );

+ 0 - 42
packages/ckeditor5-utils/tests/document/rootelement.js

@@ -1,42 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* jshint expr: true */
-
-/* bender-tags: document */
-
-/* bender-include: ../_tools/tools.js */
-
-'use strict';
-
-const getIteratorCount = bender.tools.core.getIteratorCount;
-
-const modules = bender.amd.require(
-	'document/document',
-	'document/element',
-	'document/rootelement'
-);
-
-describe( 'Element', () => {
-	let Document, Element, RootElement;
-
-	before( () => {
-		Document = modules[ 'document/document' ];
-		Element = modules[ 'document/element' ];
-		RootElement = modules[ 'document/rootelement' ];
-	} );
-
-	describe( 'constructor', () => {
-		it( 'should create root element without attributes', () => {
-			let doc = new Document();
-			let root = new RootElement( doc );
-
-			expect( root ).to.be.an.instanceof( Element );
-			expect( root ).to.have.property( 'document' ).that.equals( doc );
-			expect( getIteratorCount( root.getAttrs() ) ).to.equal( 0 );
-			expect( root.getChildCount() ).to.equal( 0 );
-		} );
-	} );
-} );

+ 0 - 31
packages/ckeditor5-utils/tests/document/text.js

@@ -1,31 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* jshint expr: true */
-
-/* bender-tags: document */
-
-'use strict';
-
-const modules = bender.amd.require(
-	'document/text',
-	'document/attribute'
-);
-
-describe( 'Text', () => {
-	describe( 'constructor', () => {
-		it( 'should create character without attributes', () => {
-			const Text = modules[ 'document/text' ];
-			const Attribute = modules[ 'document/attribute' ];
-
-			let attrs = [ new Attribute( 'bold', true ) ];
-			let text = new Text( 'bar', attrs );
-
-			expect( text ).to.have.property( 'text' ).that.equals( 'bar' );
-			expect( text ).to.have.property( 'attrs' ).that.is.an( 'array' );
-			expect( text.attrs ).to.be.deep.equals( attrs );
-		} );
-	} );
-} );

+ 0 - 82
packages/ckeditor5-utils/tests/document/transaction.js

@@ -1,82 +0,0 @@
-/**
- * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/* bender-tags: document, delta */
-
-'use strict';
-
-const modules = bender.amd.require(
-	'document/transaction',
-	'document/delta/delta',
-	'ckeditorerror' );
-
-describe( 'Transaction', () => {
-	let Transaction, Delta, CKEditorError;
-
-	before( () => {
-		Transaction = modules[ 'document/transaction' ];
-		Delta = modules[ 'document/delta/delta' ];
-		CKEditorError = modules.ckeditorerror;
-	} );
-
-	it( 'should have registered basic methods', () => {
-		const transaction = new Transaction();
-
-		expect( transaction.setAttr ).to.be.a( 'function' );
-		expect( transaction.removeAttr ).to.be.a( 'function' );
-	} );
-
-	describe( 'Transaction.register', () => {
-		let TestDelta;
-
-		before( () => {
-			TestDelta = class extends Delta {
-				constructor( transaction ) {
-					super( transaction, [] );
-				}
-			};
-		} );
-
-		afterEach( () => {
-			delete Transaction.prototype.foo;
-		} );
-
-		it( 'should register function which return an delta', () => {
-			Transaction.register( 'foo', function() {
-				this.addDelta( new TestDelta() );
-			} );
-
-			const transaction = new Transaction();
-
-			transaction.foo();
-
-			expect( transaction.deltas.length ).to.equal( 1 );
-			expect( transaction.deltas[ 0 ] ).to.be.instanceof( TestDelta );
-		} );
-
-		it( 'should register function which return an multiple deltas', () => {
-			Transaction.register( 'foo', function() {
-				this.addDelta( new TestDelta() );
-				this.addDelta( new TestDelta() );
-			} );
-
-			const transaction = new Transaction();
-
-			transaction.foo();
-
-			expect( transaction.deltas.length ).to.equal( 2 );
-			expect( transaction.deltas[ 0 ] ).to.be.instanceof( TestDelta );
-			expect( transaction.deltas[ 1 ] ).to.be.instanceof( TestDelta );
-		} );
-
-		it( 'should throw if one try to register the same transaction twice', () => {
-			Transaction.register( 'foo', () => {} );
-
-			expect( () => {
-				Transaction.register( 'foo', () => {} );
-			} ).to.throw( CKEditorError, /^transaction-register-taken/ );
-		} );
-	} );
-} );

+ 2 - 2
packages/ckeditor5-utils/tests/utils/utils.js

@@ -140,13 +140,13 @@ describe( 'utils', () => {
 			expect( result ).to.equal( utils.compareArrays.EXTENSION );
 		} );
 
-		it( 'should return DIFFERENT flag, when arrays are not same', () => {
+		it( 'should return index on which arrays differ, when arrays are not the same', () => {
 			let a = [ 'abc', 0, 3 ];
 			let b = [ 'abc', 1, 3 ];
 
 			let result = utils.compareArrays( a, b );
 
-			expect( result ).to.equal( utils.compareArrays.DIFFERENT );
+			expect( result ).to.equal( 1 );
 		} );
 	} );