浏览代码

document package renamed to treeModel.

Szymon Cofalik 10 年之前
父节点
当前提交
9251546a91
共有 56 个文件被更改,包括 771 次插入569 次删除
  1. 3 3
      packages/ckeditor5-engine/src/treemodel/attribute.js
  2. 7 7
      packages/ckeditor5-engine/src/treemodel/batch.js
  3. 3 3
      packages/ckeditor5-engine/src/treemodel/character.js
  4. 15 15
      packages/ckeditor5-engine/src/treemodel/delta/attributedelta.js
  5. 7 7
      packages/ckeditor5-engine/src/treemodel/delta/batch-base.js
  6. 7 7
      packages/ckeditor5-engine/src/treemodel/delta/delta.js
  7. 9 9
      packages/ckeditor5-engine/src/treemodel/delta/insertdelta.js
  8. 10 10
      packages/ckeditor5-engine/src/treemodel/delta/mergedelta.js
  9. 1 1
      packages/ckeditor5-engine/src/treemodel/delta/register.js
  10. 7 7
      packages/ckeditor5-engine/src/treemodel/delta/removedelta.js
  11. 10 10
      packages/ckeditor5-engine/src/treemodel/delta/splitdelta.js
  12. 22 22
      packages/ckeditor5-engine/src/treemodel/document.js
  13. 14 14
      packages/ckeditor5-engine/src/treemodel/element.js
  14. 13 13
      packages/ckeditor5-engine/src/treemodel/node.js
  15. 10 10
      packages/ckeditor5-engine/src/treemodel/nodelist.js
  16. 15 15
      packages/ckeditor5-engine/src/treemodel/operation/attributeoperation.js
  17. 12 12
      packages/ckeditor5-engine/src/treemodel/operation/insertoperation.js
  18. 8 8
      packages/ckeditor5-engine/src/treemodel/operation/moveoperation.js
  19. 3 3
      packages/ckeditor5-engine/src/treemodel/operation/nooperation.js
  20. 12 12
      packages/ckeditor5-engine/src/treemodel/operation/operation.js
  21. 6 6
      packages/ckeditor5-engine/src/treemodel/operation/reinsertoperation.js
  22. 7 7
      packages/ckeditor5-engine/src/treemodel/operation/removeoperation.js
  23. 16 16
      packages/ckeditor5-engine/src/treemodel/operation/transform.js
  24. 34 34
      packages/ckeditor5-engine/src/treemodel/position.js
  25. 11 11
      packages/ckeditor5-engine/src/treemodel/positioniterator.js
  26. 46 46
      packages/ckeditor5-engine/src/treemodel/range.js
  27. 5 5
      packages/ckeditor5-engine/src/treemodel/rootelement.js
  28. 82 0
      packages/ckeditor5-engine/src/treemodel/smartrange.js
  29. 6 6
      packages/ckeditor5-engine/src/treemodel/text.js
  30. 2 2
      packages/ckeditor5-engine/tests/treemodel/attribute.js
  31. 4 4
      packages/ckeditor5-engine/tests/treemodel/batch.js
  32. 8 8
      packages/ckeditor5-engine/tests/treemodel/character.js
  33. 16 16
      packages/ckeditor5-engine/tests/treemodel/deltas/attributedelta.js
  34. 2 2
      packages/ckeditor5-engine/tests/treemodel/deltas/delta.js
  35. 4 4
      packages/ckeditor5-engine/tests/treemodel/deltas/insertdelta.js
  36. 8 8
      packages/ckeditor5-engine/tests/treemodel/deltas/mergedelta.js
  37. 4 4
      packages/ckeditor5-engine/tests/treemodel/deltas/removedelta.js
  38. 8 8
      packages/ckeditor5-engine/tests/treemodel/deltas/splitdelta.js
  39. 120 0
      packages/ckeditor5-engine/tests/treemodel/document.js
  40. 34 34
      packages/ckeditor5-engine/tests/treemodel/document/change-event.js
  41. 8 8
      packages/ckeditor5-engine/tests/treemodel/document/document.js
  42. 8 8
      packages/ckeditor5-engine/tests/treemodel/element.js
  43. 8 8
      packages/ckeditor5-engine/tests/treemodel/node.js
  44. 8 8
      packages/ckeditor5-engine/tests/treemodel/nodelist.js
  45. 16 16
      packages/ckeditor5-engine/tests/treemodel/operation/attributeoperation.js
  46. 15 15
      packages/ckeditor5-engine/tests/treemodel/operation/insertoperation.js
  47. 10 10
      packages/ckeditor5-engine/tests/treemodel/operation/moveoperation.js
  48. 4 4
      packages/ckeditor5-engine/tests/treemodel/operation/nooperation.js
  49. 10 10
      packages/ckeditor5-engine/tests/treemodel/operation/reinsertoperation.js
  50. 10 10
      packages/ckeditor5-engine/tests/treemodel/operation/removeoperation.js
  51. 21 21
      packages/ckeditor5-engine/tests/treemodel/operation/transform.js
  52. 10 10
      packages/ckeditor5-engine/tests/treemodel/position.js
  53. 12 12
      packages/ckeditor5-engine/tests/treemodel/positioniterator.js
  54. 10 10
      packages/ckeditor5-engine/tests/treemodel/range.js
  55. 6 6
      packages/ckeditor5-engine/tests/treemodel/rootelement.js
  56. 4 4
      packages/ckeditor5-engine/tests/treemodel/text.js

+ 3 - 3
packages/ckeditor5-engine/src/document/attribute.js → packages/ckeditor5-engine/src/treemodel/attribute.js

@@ -9,7 +9,7 @@ CKEDITOR.define( [ 'utils' ], ( utils ) => {
 	/**
 	 * Attributes can store any additional information for nodes in the data model.
 	 *
-	 * @class document.Attribute
+	 * @class treeModel.Attribute
 	 */
 	class Attribute {
 		/**
@@ -75,7 +75,7 @@ CKEDITOR.define( [ 'utils' ], ( utils ) => {
 		 *		let attr2 = new Attribute( 'foo', { b: 2, a: 1 } );
 		 *		attr1.isEqual( attr2 ); // true
 		 *
-		 * @param {document.Attribute} otherAttr Attribute to compare with.
+		 * @param {treeModel.Attribute} otherAttr Attribute to compare with.
 		 * @returns {Boolean} True if attributes are equal to each other.
 		 */
 		isEqual( otherAttr ) {
@@ -97,7 +97,7 @@ CKEDITOR.define( [ 'utils' ], ( utils ) => {
 		 * @static
 		 * @param {String} key Attribute key.
 		 * @param {Mixed} value Attribute value.
-		 * @returns {document.Attribute} Registered attribute.
+		 * @returns {treeModel.Attribute} Registered attribute.
 		 */
 		static register( key, value ) {
 			const attr = new Attribute( key, value );

+ 7 - 7
packages/ckeditor5-engine/src/document/batch.js → packages/ckeditor5-engine/src/treemodel/batch.js

@@ -8,14 +8,14 @@
 // All deltas need to be loaded so they can register themselves as Batch methods.
 //
 // To solve circular dependencies (deltas need to require Batch class), Batch class body is moved
-// to document/delta/batch-base.
+// to treemodel/delta/batch-base.
 CKEDITOR.define( [
-	'document/delta/batch-base',
-	'document/delta/insertdelta',
-	'document/delta/removedelta',
-	'document/delta/attributedelta',
-	'document/delta/splitdelta',
-	'document/delta/mergedelta'
+	'treemodel/delta/batch-base',
+	'treemodel/delta/insertdelta',
+	'treemodel/delta/removedelta',
+	'treemodel/delta/attributedelta',
+	'treemodel/delta/splitdelta',
+	'treemodel/delta/mergedelta'
 ], ( Batch ) => {
 	return Batch;
 } );

+ 3 - 3
packages/ckeditor5-engine/src/document/character.js → packages/ckeditor5-engine/src/treemodel/character.js

@@ -5,18 +5,18 @@
 
 'use strict';
 
-CKEDITOR.define( [ 'document/node' ], ( Node ) => {
+CKEDITOR.define( [ 'treemodel/node' ], ( Node ) => {
 	/**
 	 * Data structure for character stored in the tree data model.
 	 *
-	 * @class document.Character
+	 * @class treeModel.Character
 	 */
 	class Character extends Node {
 		/**
 		 * Creates character linear item.
 		 *
 		 * @param {String} character Described character.
-		 * @param {Iterable} attrs Iterable collection of {@link document.Attribute attributes}.
+		 * @param {Iterable} attrs Iterable collection of {@link treeModel.Attribute attributes}.
 		 * @constructor
 		 */
 		constructor( character, attrs ) {

+ 15 - 15
packages/ckeditor5-engine/src/document/delta/attributedelta.js → packages/ckeditor5-engine/src/treemodel/delta/attributedelta.js

@@ -6,21 +6,21 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/delta/delta',
-	'document/delta/register',
-	'document/operation/attributeoperation',
-	'document/position',
-	'document/range',
-	'document/positioniterator',
-	'document/attribute',
-	'document/element'
+	'treemodel/delta/delta',
+	'treemodel/delta/register',
+	'treemodel/operation/attributeoperation',
+	'treemodel/position',
+	'treemodel/range',
+	'treemodel/positioniterator',
+	'treemodel/attribute',
+	'treemodel/element'
 ], ( Delta, register, AttributeOperation, Position, Range, PositionIterator, Attribute, Element ) => {
 	/**
-	 * To provide specific OT behavior and better collisions solving, change methods ({@link document.Batch#setAttr}
-	 * and {@link document.Batch#removeAttr}) use `AttributeDelta` class which inherits from the `Delta` class and may
+	 * To provide specific OT behavior and better collisions solving, change methods ({@link treeModel.Batch#setAttr}
+	 * and {@link treeModel.Batch#removeAttr}) use `AttributeDelta` class which inherits from the `Delta` class and may
 	 * overwrite some methods.
 	 *
-	 * @class document.delta.AttributeDelta
+	 * @class treeModel.delta.AttributeDelta
 	 */
 	class AttributeDelta extends Delta {}
 
@@ -29,10 +29,10 @@ CKEDITOR.define( [
 	 *
 	 * @chainable
 	 * @method setAttr
-	 * @memberOf document.Batch
+	 * @memberOf treeModel.Batch
 	 * @param {String} key Attribute key.
 	 * @param {*} value Attribute new value.
-	 * @param {document.Node|document.Range} nodeOrRange Node or range on which the attribute will be set.
+	 * @param {treeModel.Node|treeModel.Range} nodeOrRange Node or range on which the attribute will be set.
 	 */
 	register( 'setAttr', function( key, value, nodeOrRange ) {
 		attribute( this, key, value, nodeOrRange );
@@ -45,9 +45,9 @@ CKEDITOR.define( [
 	 *
 	 * @chainable
 	 * @method removeAttr
-	 * @memberOf document.Batch
+	 * @memberOf treeModel.Batch
 	 * @param {String} key Attribute key.
-	 * @param {document.Node|document.Range} nodeOrRange Node or range on which the attribute will be removed.
+	 * @param {treeModel.Node|treeModel.Range} nodeOrRange Node or range on which the attribute will be removed.
 	 */
 	register( 'removeAttr', function( key, nodeOrRange ) {
 		attribute( this, key, null, nodeOrRange );

+ 7 - 7
packages/ckeditor5-engine/src/document/delta/batch-base.js → packages/ckeditor5-engine/src/treemodel/delta/batch-base.js

@@ -27,21 +27,21 @@ CKEDITOR.define( [ 'ckeditorerror' ], ( CKEditorError ) => {
 	 *
 	 *		doc.batch().insert( firstPosition, 'foo' ).insert( secondPosition, 'bar' );
 	 *
-	 * @class document.Batch
+	 * @class treeModel.Batch
 	 */
 	class Batch {
 		/**
-		 * Creates Batch instance. Not recommended to use directly, use {@link document.Document#batch} instead.
+		 * Creates Batch instance. Not recommended to use directly, use {@link treeModel.Document#batch} instead.
 		 *
 		 * @constructor
-		 * @param {document.Document} doc Document which this Batch changes.
+		 * @param {treeModel.Document} doc Document which this Batch changes.
 		 */
 		constructor( doc ) {
 			/**
 			 * Document which this Batch changes.
 			 *
 			 * @readonly
-			 * @type {document.Document}
+			 * @type {treeModel.Document}
 			 */
 			this.doc = doc;
 
@@ -49,7 +49,7 @@ CKEDITOR.define( [ 'ckeditorerror' ], ( CKEditorError ) => {
 			 * Array of deltas which compose Batch.
 			 *
 			 * @readonly
-			 * @type {Array.<document.delta.Delta>}
+			 * @type {Array.<treeModel.delta.Delta>}
 			 */
 			this.deltas = [];
 		}
@@ -58,8 +58,8 @@ CKEDITOR.define( [ 'ckeditorerror' ], ( CKEditorError ) => {
 		 * Adds delta to the Batch 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.
+		 * @param {treeModel.delta.Delta} delta Delta to add.
+		 * @return {treeModel.delta.Delta} Added delta.
 		 */
 		addDelta( delta ) {
 			delta.batch = this;

+ 7 - 7
packages/ckeditor5-engine/src/document/delta/delta.js → packages/ckeditor5-engine/src/treemodel/delta/delta.js

@@ -12,9 +12,9 @@ CKEDITOR.define( [], () => {
 	 * 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.Batch}.
+	 * Multiple deltas are grouped into a single {@link treeModel.Batch}.
 	 *
-	 * @class document.delta.Delta
+	 * @class treeModel.delta.Delta
 	 */
 	class Delta {
 		/**
@@ -24,11 +24,11 @@ CKEDITOR.define( [], () => {
 		 */
 		constructor() {
 			/**
-			 * {@link document.Batch} which delta is a part of. This property is null by default and set by the
-			 * {@link Document.Batch#addDelta} method.
+			 * {@link treeModel.Batch} which delta is a part of. This property is null by default and set by the
+			 * {@link treeModel.Batch#addDelta} method.
 			 *
 			 * @readonly
-			 * @type {document.Batch}
+			 * @type {treeModel.Batch}
 			 */
 			this.batch = null;
 
@@ -36,7 +36,7 @@ CKEDITOR.define( [], () => {
 			 * Array of operations which compose delta.
 			 *
 			 * @readonly
-			 * @type {document.operation.Operation[]}
+			 * @type {treeModel.operation.Operation[]}
 			 */
 			this.operations = [];
 		}
@@ -44,7 +44,7 @@ CKEDITOR.define( [], () => {
 		/**
 		 * Add operation to the delta.
 		 *
-		 * @param {document.operation.Operation} operation Operation instance.
+		 * @param {treeModel.operation.Operation} operation Operation instance.
 		 */
 		addOperation( operation ) {
 			operation.delta = this;

+ 9 - 9
packages/ckeditor5-engine/src/document/delta/insertdelta.js → packages/ckeditor5-engine/src/treemodel/delta/insertdelta.js

@@ -6,15 +6,15 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/delta/delta',
-	'document/delta/register',
-	'document/operation/insertoperation'
+	'treemodel/delta/delta',
+	'treemodel/delta/register',
+	'treemodel/operation/insertoperation'
 ], ( Delta, register, InsertOperation ) => {
 	/**
-	 * To provide specific OT behavior and better collisions solving, the {@link document.Batch#insert} method
+	 * To provide specific OT behavior and better collisions solving, the {@link treeModel.Batch#insert} method
 	 * uses the `InsertDelta` class which inherits from the `Delta` class and may overwrite some methods.
 	 *
-	 * @class document.delta.InsertDelta
+	 * @class treeModel.delta.InsertDelta
 	 */
 	class InsertDelta extends Delta {}
 
@@ -22,11 +22,11 @@ CKEDITOR.define( [
 	 * Inserts a node or nodes at the given position.
 	 *
 	 * @chainable
-	 * @memberOf document.Batch
+	 * @memberOf treeModel.Batch
 	 * @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.
+	 * @param {treeModel.Position} position Position of insertion.
+	 * @param {treeModel.Node|treeModel.Text|treeModel.NodeList|String|Iterable} nodes The list of nodes to be inserted.
+	 * List of nodes can be of any type accepted by the {@link treeModel.NodeList} constructor.
 	 */
 	register( 'insert', function( position, nodes ) {
 		const delta = new InsertDelta();

+ 10 - 10
packages/ckeditor5-engine/src/document/delta/mergedelta.js → packages/ckeditor5-engine/src/treemodel/delta/mergedelta.js

@@ -6,19 +6,19 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/delta/delta',
-	'document/delta/register',
-	'document/position',
-	'document/element',
-	'document/operation/removeoperation',
-	'document/operation/moveoperation',
+	'treemodel/delta/delta',
+	'treemodel/delta/register',
+	'treemodel/position',
+	'treemodel/element',
+	'treemodel/operation/removeoperation',
+	'treemodel/operation/moveoperation',
 	'ckeditorerror'
 ], ( Delta, register, Position, Element, RemoveOperation, MoveOperation, CKEditorError ) => {
 	/**
-	 * To provide specific OT behavior and better collisions solving, {@link document.Batch#merge} method
+	 * To provide specific OT behavior and better collisions solving, {@link treeModel.Batch#merge} method
 	 * uses the `MergeDelta` class which inherits from the `Delta` class and may overwrite some methods.
 	 *
-	 * @class document.delta.MergeDelta
+	 * @class treeModel.delta.MergeDelta
 	 */
 	class MergeDelta extends Delta {}
 
@@ -30,8 +30,8 @@ CKEDITOR.define( [
 	 *
 	 * @chainable
 	 * @method merge
-	 * @memberOf document.Batch
-	 * @param {document.Position} position Position of merge.
+	 * @memberOf treeModel.Batch
+	 * @param {treeModel.Position} position Position of merge.
 	 */
 	register( 'merge', function( position ) {
 		const delta = new MergeDelta();

+ 1 - 1
packages/ckeditor5-engine/src/document/delta/register.js → packages/ckeditor5-engine/src/treemodel/delta/register.js

@@ -8,7 +8,7 @@
 // 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/batch-base'
+	'treemodel/delta/batch-base'
 ], ( Batch ) => {
 	return Batch.register;
 } );

+ 7 - 7
packages/ckeditor5-engine/src/document/delta/removedelta.js → packages/ckeditor5-engine/src/treemodel/delta/removedelta.js

@@ -6,15 +6,15 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/delta/delta',
-	'document/delta/register',
-	'document/operation/removeoperation'
+	'treemodel/delta/delta',
+	'treemodel/delta/register',
+	'treemodel/operation/removeoperation'
 ], ( Delta, register, RemoveOperation ) => {
 	/**
-	 * To provide specific OT behavior and better collisions solving, {@link document.Batch#remove} method
+	 * To provide specific OT behavior and better collisions solving, {@link treeModel.Batch#remove} method
 	 * uses the `RemoveDelta` class which inherits from the `Delta` class and may overwrite some methods.
 	 *
-	 * @class document.delta.RemoveDelta
+	 * @class treeModel.delta.RemoveDelta
 	 */
 	class RemoveDelta extends Delta {}
 
@@ -23,8 +23,8 @@ CKEDITOR.define( [
 	 *
 	 * @chainable
 	 * @method remove
-	 * @memberOf document.Batch
-	 * @param {document.Position} position Position before the first node to remove.
+	 * @memberOf treeModel.Batch
+	 * @param {treeModel.Position} position Position before the first node to remove.
 	 * @param {Number} howMany How many nodes to remove.
 	 */
 	register( 'remove', function( position, howMany ) {

+ 10 - 10
packages/ckeditor5-engine/src/document/delta/splitdelta.js → packages/ckeditor5-engine/src/treemodel/delta/splitdelta.js

@@ -6,19 +6,19 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/delta/delta',
-	'document/delta/register',
-	'document/position',
-	'document/element',
-	'document/operation/insertoperation',
-	'document/operation/moveoperation',
+	'treemodel/delta/delta',
+	'treemodel/delta/register',
+	'treemodel/position',
+	'treemodel/element',
+	'treemodel/operation/insertoperation',
+	'treemodel/operation/moveoperation',
 	'ckeditorerror'
 ], ( Delta, register, Position, Element, InsertOperation, MoveOperation, CKEditorError ) => {
 	/**
-	 * To provide specific OT behavior and better collisions solving, the {@link document.Batch#split} method
+	 * To provide specific OT behavior and better collisions solving, the {@link treeModel.Batch#split} method
 	 * uses `SplitDelta` class which inherits from the `Delta` class and may overwrite some methods.
 	 *
-	 * @class document.delta.SplitDelta
+	 * @class treeModel.delta.SplitDelta
 	 */
 	class SplitDelta extends Delta {}
 
@@ -30,8 +30,8 @@ CKEDITOR.define( [
 	 *
 	 * @chainable
 	 * @method split
-	 * @memberOf document.Batch
-	 * @param {document.Position} position Position of split.
+	 * @memberOf treeModel.Batch
+	 * @param {treeModel.Position} position Position of split.
 	 */
 	register( 'split', function( position ) {
 		const delta = new SplitDelta();

+ 22 - 22
packages/ckeditor5-engine/src/document/document.js → packages/ckeditor5-engine/src/treemodel/document.js

@@ -6,9 +6,9 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/element',
-	'document/rootelement',
-	'document/batch',
+	'treemodel/element',
+	'treemodel/rootelement',
+	'treemodel/batch',
 	'emittermixin',
 	'utils',
 	'ckeditorerror'
@@ -19,14 +19,14 @@ CKEDITOR.define( [
 	 * 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.Batch} API, for example:
+	 * All changes in the document are done by {@link treeModel.operation.Operation operations}. To create operations in
+	 * the simple way use use the {@link treeModel.Batch} API, for example:
 	 *
-	 *		document.batch().insert( position, nodes ).split( otherPosition );
+	 *		treeModel.batch().insert( position, nodes ).split( otherPosition );
 	 *
 	 * @see #batch
 	 *
-	 * @class document.Document
+	 * @class treeModel.Document
 	 */
 	class Document {
 		/**
@@ -48,7 +48,7 @@ CKEDITOR.define( [
 
 			/**
 			 * 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
+			 * operations are applied on the proper document version. If the {@link treeModel.operation.Operation#baseVersion} will
 			 * not match document version the {@link document-applyOperation-wrong-version} error is thrown.
 			 *
 			 * @readonly
@@ -62,7 +62,7 @@ CKEDITOR.define( [
 		 *
 		 * @protected
 		 * @readonly
-		 * @property {document.RootElement} _graveyard
+		 * @property {treeModel.RootElement} graveyard
 		 */
 		get _graveyard() {
 			return this.getRoot( graveyardSymbol );
@@ -70,10 +70,10 @@ CKEDITOR.define( [
 
 		/**
 		 * 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.Batch} API available via {@link #batch} method.
+		 * {@link treeModel.operation.Operation operations}. To create operations in the simple way use the
+		 * {@link treeModel.Batch} API available via {@link #batch} method.
 		 *
-		 * @param {document.operation.Operation} operation Operation to be applied.
+		 * @param {treeModel.operation.Operation} operation Operation to be applied.
 		 */
 		applyOperation( operation ) {
 			if ( operation.baseVersion !== this.version ) {
@@ -81,7 +81,7 @@ CKEDITOR.define( [
 				 * Only operations with matching versions can be applied.
 				 *
 				 * @error document-applyOperation-wrong-version
-				 * @param {document.operation.Operation} operation
+				 * @param {treeModel.operation.Operation} operation
 				 */
 				throw new CKEditorError(
 					'document-applyOperation-wrong-version: Only operations with matching versions can be applied.',
@@ -96,9 +96,9 @@ CKEDITOR.define( [
 		}
 
 		/**
-		 * Creates a {@link document.Batch} instance which allows to change the document.
+		 * Creates a {@link treeModel.Batch} instance which allows to change the document.
 		 *
-		 * @returns {document.Batch} Batch instance.
+		 * @returns {treeModel.Batch} Batch instance.
 		 */
 		batch() {
 			return new Batch( this );
@@ -108,7 +108,7 @@ CKEDITOR.define( [
 		 * Creates a new top-level root.
 		 *
 		 * @param {String|Symbol} name Unique root name.
-		 * @returns {document.RootElement} Created root.
+		 * @returns {treeModel.RootElement} Created root.
 		 */
 		createRoot( name ) {
 			if ( this.roots.has( name ) ) {
@@ -116,7 +116,7 @@ CKEDITOR.define( [
 				 * Root with specified name already exists.
 				 *
 				 * @error document-createRoot-name-exists
-				 * @param {document.Document} doc
+				 * @param {treeModel.Document} doc
 				 * @param {String} name
 				 */
 				throw new CKEditorError(
@@ -135,7 +135,7 @@ CKEDITOR.define( [
 		 * 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.
+		 * @returns (treeModel.RootElement} Root registered under given name.
 		 */
 		getRoot( name ) {
 			if ( !this.roots.has( name ) ) {
@@ -171,13 +171,13 @@ CKEDITOR.define( [
 		 * @event change
 		 * @param {String} type Change type, possible option: 'insert', 'remove', 'reinsert', 'move', 'attr'.
 		 * @param {Object} changeInfo Additional information about the change.
-		 * @param {document.Range} changeInfo.range Range containing changed nodes. Note that for 'remove' the range will be in the
+		 * @param {treeModel.Range} changeInfo.range Range containing changed nodes. Note that for 'remove' the range will be in the
 		 * {@link #_graveyard graveyard root}.
-		 * @param {document.Position} [changeInfo.sourcePosition] Change source position. Exists for 'remove', 'reinsert' and 'move'.
 		 * Note that for 'reinsert' the source position will be in the {@link #_graveyard graveyard root}.
-		 * @param {document.Attribute} [changeInfo.oldAttr] Only for 'attr' type. If the type is 'attr' and `oldAttr`
+		 * @param {treeModel.Position} [changeInfo.sourcePosition] Change source position. Exists for 'remove', 'reinsert' and 'move'.
+		 * @param {treeModel.Attribute} [changeInfo.oldAttr] Only for 'attr' type. If the type is 'attr' and `oldAttr`
 		 * is `undefined` it means that new attribute was inserted. Otherwise it contains changed or removed attribute.
-		 * @param {document.Attribute} [changeInfo.newAttr] Only for 'attr' type. If the type is 'attr' and `newAttr`
+		 * @param {treeModel.Attribute} [changeInfo.newAttr] Only for 'attr' type. If the type is 'attr' and `newAttr`
 		 * is `undefined` it means that attribute was removed. Otherwise it contains changed or inserted attribute.
 		 */
 	}

+ 14 - 14
packages/ckeditor5-engine/src/document/element.js → packages/ckeditor5-engine/src/treemodel/element.js

@@ -6,13 +6,13 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/node',
-	'document/nodelist'
+	'treemodel/node',
+	'treemodel/nodelist'
 ], ( Node, NodeList ) => {
 	/**
 	 * Tree data model element.
 	 *
-	 * @class document.Element
+	 * @class treeModel.Element
 	 */
 	class Element extends Node {
 		/**
@@ -21,9 +21,9 @@ CKEDITOR.define( [
 		 * 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.
+		 * @param {Iterable} attrs Iterable collection of {@link treeModel.Attribute attributes}.
+		 * @param {treeModel.Node|treeModel.Text|treeModel.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 treeModel.NodeList} constructor.
 		 * @constructor
 		 */
 		constructor( name, attrs, children ) {
@@ -41,7 +41,7 @@ CKEDITOR.define( [
 			 * List of children nodes.
 			 *
 			 * @protected
-			 * @property {document.NodeList} _children
+			 * @property {treeModel.NodeList} _children
 			 */
 			this._children = new NodeList();
 
@@ -54,7 +54,7 @@ CKEDITOR.define( [
 		 * Gets child at the given index.
 		 *
 		 * @param {Number} index Index of child.
-		 * @returns {document.Node} Child node.
+		 * @returns {treeModel.Node} Child node.
 		 */
 		getChild( index ) {
 			return this._children.get( index );
@@ -72,7 +72,7 @@ CKEDITOR.define( [
 		/**
 		 * Gets index of the given child node.
 		 *
-		 * @param {document.Node} node Child node.
+		 * @param {treeModel.Node} node Child node.
 		 * @returns {Number} Index of the child node.
 		 */
 		getChildIndex( node ) {
@@ -83,11 +83,11 @@ CKEDITOR.define( [
 		 * 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}.
+		 * All attached nodes should be modified using the {@link treeModel.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.
+		 * @param {treeModel.Node|treeModel.Text|treeModel.NodeList|String|Iterable} nodes The list of nodes to be inserted.
+		 * The list of nodes can be of any type accepted by the {@link treeModel.NodeList} constructor.
 		 */
 		insertChildren( index, nodes ) {
 			this._children.insert( index, new NodeList( nodes ) );
@@ -101,11 +101,11 @@ CKEDITOR.define( [
 		 * 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}.
+		 * All attached nodes should be modified using the {@link treeModel.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.
+		 * @returns {treeModel.NodeList} The list of removed nodes.
 		 */
 
 		removeChildren( index, number ) {

+ 13 - 13
packages/ckeditor5-engine/src/document/node.js → packages/ckeditor5-engine/src/treemodel/node.js

@@ -5,12 +5,12 @@
 
 'use strict';
 
-CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], ( Attribute, utils, CKEditorError ) => {
+CKEDITOR.define( [ 'treemodel/attribute', 'utils', 'ckeditorerror' ], ( Attribute, utils, CKEditorError ) => {
 	/**
 	 * Abstract document tree node class.
 	 *
 	 * @abstract
-	 * @class document.Node
+	 * @class treeModel.Node
 	 */
 	class Node {
 		/**
@@ -18,22 +18,22 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], ( Attribute
 		 *
 		 * This is an abstract class, so this constructor should not be used directly.
 		 *
-		 * @param {Iterable} attrs Iterable collection of {@link document.Attribute attributes}.
+		 * @param {Iterable} attrs Iterable collection of {@link treeModel.Attribute attributes}.
 		 * @constructor
 		 */
 		constructor( attrs ) {
 			/**
-			 * Parent element. Null by default. Set by {@link document.Element#insertChildren}.
+			 * Parent element. Null by default. Set by {@link treeModel.Element#insertChildren}.
 			 *
 			 * @readonly
-			 * @property {document.Element|null} parent
+			 * @property {treeModel.Element|null} parent
 			 */
 			this.parent = null;
 
 			/**
 			 * Attributes set.
 			 *
-			 * Attributes of nodes attached to the document can be changed only be the {@link document.operation.AttributeOperation}.
+			 * Attributes of nodes attached to the document can be changed only be the {@link treeModel.operation.AttributeOperation}.
 			 *
 			 * @private
 			 * @property {Set} _attrs
@@ -64,7 +64,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], ( Attribute
 		 * Nodes next sibling or `null` if it is the last child.
 		 *
 		 * @readonly
-		 * @property {document.Node|null} nextSibling
+		 * @property {treeModel.Node|null} nextSibling
 		 */
 		get nextSibling() {
 			const index = this.getIndex();
@@ -76,7 +76,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], ( Attribute
 		 * Nodes previous sibling or null if it is the last child.
 		 *
 		 * @readonly
-		 * @property {document.Node|null} previousSibling
+		 * @property {treeModel.Node|null} previousSibling
 		 */
 		get previousSibling() {
 			const index = this.getIndex();
@@ -104,7 +104,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], ( Attribute
 		 * Finds an attribute by a key.
 		 *
 		 * @param {String} attr The attribute key.
-		 * @returns {document.Attribute} The found attribute.
+		 * @returns {treeModel.Attribute} The found attribute.
 		 */
 		getAttr( key ) {
 			for ( let attr of this._attrs ) {
@@ -121,7 +121,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], ( Attribute
 		 *
 		 *		const copy = new Element( element.name, element.getAttrs() );
 		 *
-		 * @returns {Iterable.<document.Attribute>} Attribute iterator.
+		 * @returns {Iterable.<treeModel.Attribute>} Attribute iterator.
 		 */
 		getAttrs() {
 			return this._attrs[ Symbol.iterator ]();
@@ -156,7 +156,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], ( Attribute
 
 		/**
 		 * 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}.
+		 * will be `[ 1, 2 ]`. This path can be used as a parameter of {@link treeModel.Position}.
 		 *
 		 * @returns {Number[]} The path.
 		 */
@@ -176,7 +176,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], ( Attribute
 		 * 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} key An attribute or a key to compare.
+		 * @param {treeModel.Attribute|String} key An attribute or a key to compare.
 		 * @returns {Boolean} True if node contains given attribute or an attribute with the given key.
 		 */
 		hasAttr( key ) {
@@ -220,7 +220,7 @@ CKEDITOR.define( [ 'document/attribute', 'utils', 'ckeditorerror' ], ( Attribute
 		/**
 		 * Sets a given attribute. If the attribute with the same key already exists it will be removed.
 		 *
-		 * @param {document.Attribute} attr Attribute to set.
+		 * @param {treeModel.Attribute} attr Attribute to set.
 		 */
 		setAttr( attr ) {
 			this.removeAttr( attr.key );

+ 10 - 10
packages/ckeditor5-engine/src/document/nodelist.js → packages/ckeditor5-engine/src/treemodel/nodelist.js

@@ -6,20 +6,20 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/character',
-	'document/text',
-	'document/node',
+	'treemodel/character',
+	'treemodel/text',
+	'treemodel/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}.
+	 * {@link treeModel.Element} object or nodes inserted using {@link treeModel.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 treeModel.NodeList
 	 */
 	class NodeList {
 		/**
@@ -48,7 +48,7 @@ CKEDITOR.define( [
 		 *		nodeListA === nodeListB // true
 		 *		nodeListB.length // 3
 		 *
-		 * @param {document.Node|document.Text|document.NodeList|String|Iterable} nodes List of nodes.
+		 * @param {treeModel.Node|treeModel.Text|treeModel.NodeList|String|Iterable} nodes List of nodes.
 		 * @constructor
 		 */
 		constructor( nodes ) {
@@ -114,7 +114,7 @@ CKEDITOR.define( [
 		 * Returns node at the given index.
 		 *
 		 * @param {Number} index Node index.
-		 * @returns {document.Node} Node at given index.
+		 * @returns {treeModel.Node} Node at given index.
 		 */
 		get( index ) {
 			return this._nodes[ index ];
@@ -123,7 +123,7 @@ CKEDITOR.define( [
 		/**
 		 * Search for the node in the node list.
 		 *
-		 * @param {document.Node} node Node to find.
+		 * @param {treeModel.Node} node Node to find.
 		 * @returns {Number} Position of the node in the list.
 		 */
 		indexOf( node ) {
@@ -134,7 +134,7 @@ CKEDITOR.define( [
 		 * 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.
+		 * @param {treeModel.NodeList} nodeList List of nodes to insert.
 		 */
 		insert( index, nodeList ) {
 			this._nodes.splice.apply( this._nodes, [ index, 0 ].concat( nodeList._nodes ) );
@@ -145,7 +145,7 @@ CKEDITOR.define( [
 		 *
 		 * @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.
+		 * @returns {treeModel.NodeList} List of removed nodes.
 		 */
 		remove( index, number ) {
 			return new NodeList( this._nodes.splice( index, number ) );

+ 15 - 15
packages/ckeditor5-engine/src/document/operation/attributeoperation.js → packages/ckeditor5-engine/src/treemodel/operation/attributeoperation.js

@@ -6,13 +6,13 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/operation/operation',
+	'treemodel/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.AttributeOperation
+	 * @class treeModel.operation.AttributeOperation
 	 */
 	class AttributeOperation extends Operation {
 		/**
@@ -27,10 +27,10 @@ CKEDITOR.define( [
 		 * 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.
+		 * @param {treeModel.Range} range Range on which the operation should be applied.
+		 * @param {treeModel.Attribute|null} oldAttr Attribute to be removed. If `null`, then the operation just inserts a new attribute.
+		 * @param {treeModel.Attribute|null} newAttr Attribute to be added. If `null`, then the operation just removes the attribute.
+		 * @param {Number} baseVersion {@link treeModel.Document#version} on which the operation can be applied.
 		 * @constructor
 		 */
 		constructor( range, oldAttr, newAttr, baseVersion ) {
@@ -40,7 +40,7 @@ CKEDITOR.define( [
 			 * Range on which operation should be applied.
 			 *
 			 * @readonly
-			 * @type {document.Range}
+			 * @type {treeModel.Range}
 			 */
 			this.range = range;
 
@@ -48,7 +48,7 @@ CKEDITOR.define( [
 			 * Old attribute to change. Set to `null` if operation inserts a new attribute.
 			 *
 			 * @readonly
-			 * @type {document.Attribute|null}
+			 * @type {treeModel.Attribute|null}
 			 */
 			this.oldAttr = oldAttr;
 
@@ -56,7 +56,7 @@ CKEDITOR.define( [
 			 * New attribute. Set to `null` if operation removes the attribute.
 			 *
 			 * @readonly
-			 * @type {document.Attribute|null}
+			 * @type {treeModel.Attribute|null}
 			 */
 			this.newAttr = newAttr;
 		}
@@ -82,8 +82,8 @@ CKEDITOR.define( [
 				 * Old and new attributes should have the same keys.
 				 *
 				 * @error operation-attribute-different-keys
-				 * @param {document.Attribute} oldAttr
-				 * @param {document.Attribute} newAttr
+				 * @param {treeModel.Attribute} oldAttr
+				 * @param {treeModel.Attribute} newAttr
 				 */
 				throw new CKEditorError(
 					'operation-attribute-different-keys: Old and new attributes should have the same keys.',
@@ -98,8 +98,8 @@ CKEDITOR.define( [
 						 * The attribute which should be removed does not exists for the given node.
 						 *
 						 * @error operation-attribute-no-attr-to-remove
-						 * @param {document.Node} node
-						 * @param {document.Attribute} attr
+						 * @param {treeModel.Node} node
+						 * @param {treeModel.Attribute} attr
 						 */
 						throw new CKEditorError(
 							'operation-attribute-no-attr-to-remove: The attribute which should be removed does not exists for given node.',
@@ -122,8 +122,8 @@ CKEDITOR.define( [
 						 * The attribute with given key already exists for the given node.
 						 *
 						 * @error operation-attribute-attr-exists
-						 * @param {document.Node} node
-						 * @param {document.Attribute} attr
+						 * @param {treeModel.Node} node
+						 * @param {treeModel.Attribute} attr
 						 */
 						throw new CKEditorError(
 							'operation-attribute-attr-exists: The attribute with given key already exists.',

+ 12 - 12
packages/ckeditor5-engine/src/document/operation/insertoperation.js → packages/ckeditor5-engine/src/treemodel/operation/insertoperation.js

@@ -6,24 +6,24 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/operation/operation',
-	'document/nodelist',
-	'document/range',
-	'document/operation/removeoperation'
+	'treemodel/operation/operation',
+	'treemodel/nodelist',
+	'treemodel/operation/removeoperation',
+	'treemodel/range'
 ], ( Operation, NodeList, Range ) => {
 	/**
 	 * Operation to insert list of nodes on the given position in the tree data model.
 	 *
-	 * @class document.operation.InsertOperation
+	 * @class treeModel.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.
+		 * @param {treeModel.Position} position Position of insertion.
+		 * @param {treeModel.Node|treeModel.Text|treeModel.NodeList|String|Iterable} nodes The list of nodes to be inserted.
+		 * List of nodes can be any type accepted by the {@link treeModel.NodeList} constructor.
+		 * @param {Number} baseVersion {@link treeModel.Document#version} on which operation can be applied.
 		 * @constructor
 		 */
 		constructor( position, nodes, baseVersion ) {
@@ -33,7 +33,7 @@ CKEDITOR.define( [
 			 * Position of insertion.
 			 *
 			 * @readonly
-			 * @type {document.Position}
+			 * @type {treeModel.Position}
 			 */
 			this.position = position;
 
@@ -41,7 +41,7 @@ CKEDITOR.define( [
 			 * List of nodes to insert.
 			 *
 			 * @readonly
-			 * @type {document.NodeList}
+			 * @type {treeModel.NodeList}
 			 */
 			this.nodeList = new NodeList( nodes );
 		}
@@ -56,7 +56,7 @@ CKEDITOR.define( [
 
 		getReversed() {
 			// Because of circular dependencies we need to re-require remove operation here.
-			const RemoveOperation = CKEDITOR.require( 'document/operation/removeoperation' );
+			const RemoveOperation = CKEDITOR.require( 'treemodel/operation/removeoperation' );
 
 			return new RemoveOperation( this.position, this.nodeList.length, this.baseVersion + 1 );
 		}

+ 8 - 8
packages/ckeditor5-engine/src/document/operation/moveoperation.js → packages/ckeditor5-engine/src/treemodel/operation/moveoperation.js

@@ -6,24 +6,24 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/operation/operation',
-	'document/range',
+	'treemodel/operation/operation',
+	'treemodel/range',
 	'ckeditorerror',
 	'utils'
 ], ( Operation, Range, CKEditorError, utils ) => {
 	/**
 	 * Operation to move list of subsequent nodes from one position in the document to another.
 	 *
-	 * @class document.operation.MoveOperation
+	 * @class treeModel.operation.MoveOperation
 	 */
 	class MoveOperation extends Operation {
 		/**
 		 * Creates a move operation.
 		 *
-		 * @param {document.Position} sourcePosition Position before the first element to move.
+		 * @param {treeModel.Position} sourcePosition Position before the first element to move.
 		 * @param {Number} howMany How many consecutive nodes to move, starting from `sourcePosition`.
-		 * @param {document.Position} targetPosition Position where moved elements will be inserted.
-		 * @param {Number} baseVersion {@link document.Document#version} on which operation can be applied.
+		 * @param {treeModel.Position} targetPosition Position where moved elements will be inserted.
+		 * @param {Number} baseVersion {@link treeModel.Document#version} on which operation can be applied.
 		 * @constructor
 		 */
 		constructor( sourcePosition, howMany, targetPosition, baseVersion ) {
@@ -32,7 +32,7 @@ CKEDITOR.define( [
 			/**
 			 * Source move position.
 			 *
-			 * @type {document.Position}
+			 * @type {treeModel.Position}
 			 */
 			this.sourcePosition = sourcePosition;
 
@@ -46,7 +46,7 @@ CKEDITOR.define( [
 			/**
 			 * Target move position.
 			 *
-			 * @type {document.Position}
+			 * @type {treeModel.Position}
 			 */
 			this.targetPosition = targetPosition;
 		}

+ 3 - 3
packages/ckeditor5-engine/src/document/operation/nooperation.js → packages/ckeditor5-engine/src/treemodel/operation/nooperation.js

@@ -6,7 +6,7 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/operation/operation'
+	'treemodel/operation/operation'
 ], ( Operation ) => {
 	/**
 	 * Operation which is doing nothing ("empty operation", "do-nothing operation", "noop").
@@ -14,10 +14,10 @@ CKEDITOR.define( [
 	 * It still has some parameters defined for transformation purposes.
 	 *
 	 * In most cases this operation is a result of transforming operations. When transformation returns
-	 * {@link document.operation.NoOperation} it means that changes done by the transformed operation
+	 * {@link treeModel.operation.NoOperation} it means that changes done by the transformed operation
 	 * have already been applied.
 	 *
-	 * @class document.operation.NoOperation
+	 * @class treeModel.operation.NoOperation
 	 */
 	class NoOperation extends Operation {
 		clone() {

+ 12 - 12
packages/ckeditor5-engine/src/document/operation/operation.js → packages/ckeditor5-engine/src/treemodel/operation/operation.js

@@ -10,20 +10,20 @@ CKEDITOR.define( [], () => {
 	 * Abstract base operation class.
 	 *
 	 * @abstract
-	 * @class document.operation.Operation
+	 * @class treeModel.operation.Operation
 	 */
 	class Operation {
 		/**
 		 * Base operation constructor.
 		 *
-		 * @param {Number} baseVersion {@link document.Document#version} on which the operation can be applied.
+		 * @param {Number} baseVersion {@link treeModel.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}
+			 * {@link treeModel.Document#version} on which operation can be applied. If you try to
+			 * {@link treeModel.Document#applyOperation apply} operation with different base version than the
+			 * {@link treeModel.Document#version document version} the {@link document-applyOperation-wrong-version}
 			 * error is thrown.
 			 *
 			 * @property {Number}
@@ -37,18 +37,18 @@ CKEDITOR.define( [], () => {
 			 */
 
 			/**
-			 * {@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.
+			 * {@link treeModel.Delta Delta} which the operation is a part of. This property is set by the
+			 * {@link treeModel.Delta delta} when the operations is added to it by the
+			 * {@link treeModel.Delta#addOperation} method.
 			 *
-			 * @property {Document.Delta} delta
+			 * @property {treeModel.Delta} delta
 			 */
 
 			/**
 			 * Creates and returns an operation that has the same parameters as this operation.
 			 *
 			 * @method clone
-			 * @returns {document.operation.Operation} Clone of this operation.
+			 * @returns {treeModel.operation.Operation} Clone of this operation.
 			 */
 
 			/**
@@ -58,10 +58,10 @@ CKEDITOR.define( [], () => {
 			 *
 			 * 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 document.operation.transform} it by all operations that were executed after the original operation.
+			 * {@link treeModel.operation.transform} it by all operations that were executed after the original operation.
 			 *
 			 * @method getReversed
-			 * @returns {document.operation.Operation} Reversed operation.
+			 * @returns {treeModel.operation.Operation} Reversed operation.
 			 */
 
 			/**

+ 6 - 6
packages/ckeditor5-engine/src/document/operation/reinsertoperation.js → packages/ckeditor5-engine/src/treemodel/operation/reinsertoperation.js

@@ -6,24 +6,24 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/operation/moveoperation',
-	'document/operation/removeoperation'
+	'treemodel/operation/moveoperation',
+	'treemodel/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.
+	 * This is basically {@link treeModel.operation.MoveOperation} but it returns
+	 * {@link treeModel.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 treeModel.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' );
+			const RemoveOperation = CKEDITOR.require( 'treemodel/operation/removeoperation' );
 
 			return new RemoveOperation( this.targetPosition, this.howMany, this.baseVersion + 1 );
 		}

+ 7 - 7
packages/ckeditor5-engine/src/document/operation/removeoperation.js → packages/ckeditor5-engine/src/treemodel/operation/removeoperation.js

@@ -6,22 +6,22 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/operation/moveoperation',
-	'document/position',
-	'document/operation/reinsertoperation'
+	'treemodel/operation/moveoperation',
+	'treemodel/position',
+	'treemodel/operation/reinsertoperation'
 ], ( MoveOperation, Position ) => {
 	/**
 	 * Operation to remove a range of nodes.
 	 *
-	 * @class document.operation.RemoveOperation
+	 * @class treeModel.operation.RemoveOperation
 	 */
 	class RemoveOperation extends MoveOperation {
 		/**
 		 * Creates a remove operation.
 		 *
-		 * @param {document.Position} position Position before the first node to remove.
+		 * @param {treeModel.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.
+		 * @param {Number} baseVersion {@link treeModel.Document#version} on which operation can be applied.
 		 * @constructor
 		 */
 		constructor( position, howMany, baseVersion ) {
@@ -39,7 +39,7 @@ CKEDITOR.define( [
 
 		getReversed() {
 			// Because of circular dependencies we need to re-require reinsert operation here.
-			const ReinsertOperation = CKEDITOR.require( 'document/operation/reinsertoperation' );
+			const ReinsertOperation = CKEDITOR.require( 'treemodel/operation/reinsertoperation' );
 
 			return new ReinsertOperation( this.targetPosition, this.howMany, this.sourcePosition, this.baseVersion + 1 );
 		}

+ 16 - 16
packages/ckeditor5-engine/src/document/operation/transform.js → packages/ckeditor5-engine/src/treemodel/operation/transform.js

@@ -6,19 +6,19 @@
 'use strict';
 
 /**
- * Transforms given {document.operation.Operation} by another {document.operation.Operation} and returns the result of
- * that transformation as an array containing one or more {document.operation.Operation} elements.
+ * Transforms given {treeModel.operation.Operation} by another {treeModel.operation.Operation} and returns the result of
+ * that transformation as an array containing one or more {treeModel.operation.Operation} elements.
  *
- * Operations work on specified positions, passed to them when they are created. Whenever {@link document.Document document}
+ * Operations work on specified positions, passed to them when they are created. Whenever {@link treeModel.Document document}
  * changes, we have to reflect those modifications by updating or "transforming" operations which are not yet applied.
  * When an operation is transformed, its parameters may change based on the operation by which it is transformed.
  * If the transform-by operation applied any modifications to the Tree Data Model which affect positions or nodes
  * connected with transformed operation, those changes will be reflected in the parameters of the returned operation(s).
  *
- * Whenever the {@link document.Document document} has different {@link document.Document#baseVersion}
- * than the operation you want to {@link document.Document#applyOperation apply}, you need to transform that
- * operation by all operations which were already applied to the {@link document.Document document} and have greater
- * {@link document.Document#baseVersion} than the operation being applied. Transform them in the same order as those
+ * Whenever the {@link treeModel.Document document} has different {@link treeModel.Document#baseVersion}
+ * than the operation you want to {@link treeModel.Document#applyOperation apply}, you need to transform that
+ * operation by all operations which were already applied to the {@link treeModel.Document document} and have greater
+ * {@link treeModel.Document#baseVersion} than the operation being applied. Transform them in the same order as those
  * operations which were applied. This way all modifications done to the Tree Data Model will be reflected
  * in the operation parameters and the operation will "operate" on "up-to-date" version of the Tree Data Model.
  * This is mostly the case with Operational Transformations but it might be needed in particular features as well.
@@ -35,20 +35,20 @@
  * `a` by `b` and also `b` by `a`. In both transformations the same operation has to be the important one. If we assume
  * that first or the second passed operation is always more important we won't be able to solve this case.
  *
- * @function document.operation.transform
- * @param {document.operation.Operation} a Operation that will be transformed.
- * @param {document.operation.Operation} b Operation to transform by.
+ * @function treeModel.operation.transform
+ * @param {treeModel.operation.Operation} a Operation that will be transformed.
+ * @param {treeModel.operation.Operation} b Operation to transform by.
  * @param {Boolean} isAMoreImportantThanB Flag indicating whether the operation which will be transformed (`a`) should be treated
  * as more important when resolving conflicts.
- * @returns {Array.<document.operation.Operation>} Result of the transformation.
+ * @returns {Array.<treeModel.operation.Operation>} Result of the transformation.
  */
 
 CKEDITOR.define( [
-	'document/operation/insertoperation',
-	'document/operation/attributeoperation',
-	'document/operation/moveoperation',
-	'document/operation/nooperation',
-	'document/range',
+	'treemodel/operation/insertoperation',
+	'treemodel/operation/attributeoperation',
+	'treemodel/operation/moveoperation',
+	'treemodel/operation/nooperation',
+	'treemodel/range',
 	'utils'
 ], ( InsertOperation, AttributeOperation, MoveOperation, NoOperation, Range, utils ) => {
 	const ot = {

+ 34 - 34
packages/ckeditor5-engine/src/document/position.js → packages/ckeditor5-engine/src/treemodel/position.js

@@ -5,7 +5,7 @@
 
 'use strict';
 
-CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootElement, utils, CKEditorError ) => {
+CKEDITOR.define( [ 'treemodel/rootelement', 'utils', 'ckeditorerror' ], ( RootElement, utils, CKEditorError ) => {
 	const SAME = 0;
 	const AFTER = 1;
 	const BEFORE = 2;
@@ -15,13 +15,13 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 	 * Position in the tree. Position is always located before or after a node.
 	 * See {@link #path} property for more information.
 	 *
-	 * @class document.Position
+	 * @class treeModel.Position
 	 */
 	class Position {
 		/**
 		 * Creates a position.
 		 *
-		 * @param {document.RootElement} root Root element for the path. Note that this element can not have a parent.
+		 * @param {treeModel.RootElement} root Root element for the path. Note that this element can not have a parent.
 		 * @param {Array.<Number>} path Position path. Must contain at least one item. See {@link #path} property for more information.
 		 * @constructor
 		 */
@@ -39,7 +39,7 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 			/**
 			 * Root element for the path. Note that this element can not have a parent.
 			 *
-			 * @type {document.RootElement}
+			 * @type {treeModel.RootElement}
 			 */
 			this.root = root;
 
@@ -77,7 +77,7 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		 * Node directly after the position.
 		 *
 		 * @readonly
-		 * @property {document.Node}
+		 * @property {treeModel.Node}
 		 */
 		get nodeAfter() {
 			return this.parent.getChild( this.offset ) || null;
@@ -87,7 +87,7 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		 * Node directly before the position.
 		 *
 		 * @readonly
-		 * @type {document.Node}
+		 * @type {treeModel.Node}
 		 */
 		get nodeBefore() {
 			return this.parent.getChild( this.offset - 1 ) || null;
@@ -114,7 +114,7 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		 * Parent element of the position. The position is located at {@link #offset} in this element.
 		 *
 		 * @readonly
-		 * @property {document.Element} parent
+		 * @property {treeModel.Element} parent
 		 */
 		get parent() {
 			let parent = this.root;
@@ -129,10 +129,10 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		}
 
 		/**
-		 * Creates and returns a new instance of {@link document.Position}
-		 * which is equal to this {@link document.Position position}.
+		 * Creates and returns a new instance of {@link treeModel.Position}
+		 * which is equal to this {@link treeModel.Position position}.
 		 *
-		 * @returns {document.Position} Cloned {@link document.Position position}.
+		 * @returns {treeModel.Position} Cloned {@link treeModel.Position position}.
 		 */
 		clone() {
 			return new Position( this.root, this.path.slice() );
@@ -141,7 +141,7 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		/**
 		 * Checks whether this position is before or after given position.
 		 *
-		 * @param {document.Position} otherPosition Position to compare with.
+		 * @param {treeModel.Position} otherPosition Position to compare with.
 		 * @returns {Number} A flag indicating whether this position is {@link #BEFORE} or
 		 * {@link #AFTER} or {@link #SAME} as given position. If positions are in different roots,
 		 * {@link #DIFFERENT} flag is returned.
@@ -173,7 +173,7 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		}
 
 		/**
-		 * Returns the path to the parent, which is the {@link document.Position#path} without the last element.
+		 * Returns the path to the parent, which is the {@link treeModel.Position#path} without the last element.
 		 *
 		 * This method returns the parent path even if the parent does not exists.
 		 *
@@ -187,9 +187,9 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		 * Returns this position after being updated by removing `howMany` nodes starting from `deletePosition`.
 		 * It may happen that this position is in a removed node. If that is the case, `null` is returned instead.
 		 *
-		 * @param {document.Position} deletePosition Position before the first removed node.
+		 * @param {treeModel.Position} deletePosition Position before the first removed node.
 		 * @param {Number} howMany How many nodes are removed.
-		 * @returns {document.Position|null} Transformed position or `null`.
+		 * @returns {treeModel.Position|null} Transformed position or `null`.
 		 */
 		getTransformedByDeletion( deletePosition, howMany ) {
 			let transformed = this.clone();
@@ -233,12 +233,12 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		/**
 		 * Returns this position after being updated by inserting `howMany` nodes at `insertPosition`.
 		 *
-		 * @param {document.Position} insertPosition Position where nodes are inserted.
+		 * @param {treeModel.Position} insertPosition Position where nodes are inserted.
 		 * @param {Number} howMany How many nodes are inserted.
 		 * @param {Boolean} insertBefore Flag indicating whether nodes are inserted before or after `insertPosition`.
 		 * This is important only when `insertPosition` and this position are same. If that is the case and the flag is
 		 * set to `true`, this position will get transformed. If the flag is set to `false`, it won't.
-		 * @returns {document.Position} Transformed position.
+		 * @returns {treeModel.Position} Transformed position.
 		 */
 		getTransformedByInsertion( insertPosition, howMany, insertBefore ) {
 			let transformed = this.clone();
@@ -272,13 +272,13 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		/**
 		 * Returns this position after being updated by moving `howMany` attributes from `sourcePosition` to `targetPosition`.
 		 *
-		 * @param {document.Position} sourcePosition Position before the first element to move.
-		 * @param {document.Position} targetPosition Position where moved elements will be inserted.
+		 * @param {treeModel.Position} sourcePosition Position before the first element to move.
+		 * @param {treeModel.Position} targetPosition Position where moved elements will be inserted.
 		 * @param {Number} howMany How many consecutive nodes to move, starting from `sourcePosition`.
 		 * @param {Boolean} insertBefore Flag indicating whether moved nodes are pasted before or after `insertPosition`.
 		 * This is important only when `targetPosition` and this position are same. If that is the case and the flag is
 		 * set to `true`, this position will get transformed by range insertion. If the flag is set to `false`, it won't.
-		 * @returns {document.Position} Transformed position.
+		 * @returns {treeModel.Position} Transformed position.
 		 */
 		getTransformedByMove( sourcePosition, targetPosition, howMany, insertBefore ) {
 			// Moving a range removes nodes from their original position. We acknowledge this by proper transformation.
@@ -300,9 +300,9 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		/**
 		 * Checks whether this position is after given position.
 		 *
-		 * **Note:** see {document.Position#isBefore}.
+		 * **Note:** see {treeModel.Position#isBefore}.
 		 *
-		 * @param {document.Position} otherPosition Position to compare with.
+		 * @param {treeModel.Position} otherPosition Position to compare with.
 		 * @returns {Boolean} True if this position is after given position.
 		 */
 		isAfter( otherPosition ) {
@@ -337,7 +337,7 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		 *    // do A.
 		 *  }
 		 *
-		 * @param {document.Position} otherPosition Position to compare with.
+		 * @param {treeModel.Position} otherPosition Position to compare with.
 		 * @returns {Boolean} True if this position is before given position.
 		 */
 		isBefore( otherPosition ) {
@@ -347,7 +347,7 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		/**
 		 * Checks whether this position equals given position.
 		 *
-		 * @param {document.Position} otherPosition Position to compare with.
+		 * @param {treeModel.Position} otherPosition Position to compare with.
 		 * @returns {Boolean} True if positions are same.
 		 */
 		isEqual( otherPosition ) {
@@ -357,8 +357,8 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		/**
 		 * Creates a new position after given node.
 		 *
-		 * @param {document.Node} node Node the position should be directly after.
-		 * @returns {document.Position}
+		 * @param {treeModel.Node} node Node the position should be directly after.
+		 * @returns {treeModel.Position}
 		 */
 		static createAfter( node ) {
 			if ( !node.parent ) {
@@ -366,7 +366,7 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 				 * You can not make position after root.
 				 *
 				 * @error position-after-root
-				 * @param {document.Node} root
+				 * @param {treeModel.Node} root
 				 */
 				throw new CKEditorError( 'position-after-root: You can not make position after root.', { root: node } );
 			}
@@ -377,8 +377,8 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		/**
 		 * Creates a new position before the given node.
 		 *
-		 * @param {document.node} node Node the position should be directly before.
-		 * @returns {document.Position}
+		 * @param {treeModel.node} node Node the position should be directly before.
+		 * @returns {treeModel.Position}
 		 */
 		static createBefore( node ) {
 			if ( !node.parent ) {
@@ -386,7 +386,7 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 				 * You can not make position before root.
 				 *
 				 * @error position-before-root
-				 * @param {document.Node} root
+				 * @param {treeModel.Node} root
 				 */
 				throw new CKEditorError( 'position-before-root: You can not make position before root.', { root: node } );
 			}
@@ -397,9 +397,9 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		/**
 		 * Creates a new position from the parent element and the offset in that element.
 		 *
-		 * @param {document.Element} parent Position parent element.
+		 * @param {treeModel.Element} parent Position parent element.
 		 * @param {Number} offset Position offset.
-		 * @returns {document.Position}
+		 * @returns {treeModel.Position}
 		 */
 		static createFromParentAndOffset( parent, offset ) {
 			const path = parent.getPath();
@@ -435,9 +435,9 @@ CKEDITOR.define( [ 'document/rootelement', 'utils', 'ckeditorerror' ], ( RootEle
 		 * Finally, the transformed position will point to `[ 1, 1, 4, 1 ]`.
 		 *
 		 * @protected
-		 * @param {document.Position} source Beginning of the moved range.
-		 * @param {document.Position} target Position where the range is moved.
-		 * @returns {document.Position} Combined position.
+		 * @param {treeModel.Position} source Beginning of the moved range.
+		 * @param {treeModel.Position} target Position where the range is moved.
+		 * @returns {treeModel.Position} Combined position.
 		 */
 		_getCombined( source, target ) {
 			const i = source.path.length - 1;

+ 11 - 11
packages/ckeditor5-engine/src/document/positioniterator.js → packages/ckeditor5-engine/src/treemodel/positioniterator.js

@@ -6,9 +6,9 @@
 'use strict';
 
 CKEDITOR.define( [
-	'document/character',
-	'document/element',
-	'document/position'
+	'treemodel/character',
+	'treemodel/element',
+	'treemodel/position'
 ], ( Character, Element, Position ) => {
 	const ELEMENT_ENTER = 0;
 	const ELEMENT_LEAVE = 1;
@@ -17,14 +17,14 @@ CKEDITOR.define( [
 	/**
 	 * Position iterator class. It allows to iterate forward and backward over the tree document.
 	 *
-	 * @class document.PositionIterator
+	 * @class treeModel.PositionIterator
 	 */
 	class PositionIterator {
 		/**
 		 * Creates a range iterator.
 		 *
-		 * @param {document.Range} [boundaries] Range to define boundaries of the iterator.
-		 * @param {document.Position} [iteratorPosition] Starting position.
+		 * @param {treeModel.Range} [boundaries] Range to define boundaries of the iterator.
+		 * @param {treeModel.Position} [iteratorPosition] Starting position.
 		 * @constructor
 		 */
 		constructor( boundaries, iteratorPosition ) {
@@ -38,7 +38,7 @@ CKEDITOR.define( [
 			/**
 			 * Iterator position.
 			 *
-			 * @property {document.Position} position
+			 * @property {treeModel.Position} position
 			 */
 
 			/**
@@ -49,7 +49,7 @@ CKEDITOR.define( [
 			 *
 			 * If boundaries are not defined they are set before first and after last child of the root node.
 			 *
-			 * @property {document.Range} boundaries
+			 * @property {treeModel.Range} boundaries
 			 */
 		}
 
@@ -61,14 +61,14 @@ CKEDITOR.define( [
 		 * @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.
+		 * @returns {treeModel.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' );
+			Element = CKEDITOR.require( 'treemodel/element' );
 
 			// We are at the end of the root.
 			if ( parent.parent === null && position.offset === parent.getChildCount() ) {
@@ -104,7 +104,7 @@ CKEDITOR.define( [
 		 * @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.
+		 * @returns {treeModel.Node} return.value.node Scanned node.
 		 */
 		previous() {
 			const position = this.position;

+ 46 - 46
packages/ckeditor5-engine/src/document/range.js → packages/ckeditor5-engine/src/treemodel/range.js

@@ -5,32 +5,32 @@
 
 'use strict';
 
-CKEDITOR.define( [ 'document/position', 'document/positioniterator', 'utils' ], ( Position, PositionIterator, utils ) => {
+CKEDITOR.define( [ 'treemodel/position', 'treemodel/positioniterator', 'utils' ], ( Position, PositionIterator, utils ) => {
 	/**
 	 * Range class. Range is iterable.
 	 *
-	 * @class document.Range
+	 * @class treeModel.Range
 	 */
 	class Range {
 		/**
 		 * Creates a range.
 		 *
-		 * @param {document.Position} start Start position.
-		 * @param {document.Position} end End position.
+		 * @param {treeModel.Position} start Start position.
+		 * @param {treeModel.Position} end End position.
 		 * @constructor
 		 */
 		constructor( start, end ) {
 			/**
 			 * Start position.
 			 *
-			 * @property {document.Position}
+			 * @property {treeModel.Position}
 			 */
 			this.start = start;
 
 			/**
 			 * End position.
 			 *
-			 * @property {document.Position}
+			 * @property {treeModel.Position}
 			 */
 			this.end = end;
 		}
@@ -38,45 +38,45 @@ CKEDITOR.define( [ 'document/position', 'document/positioniterator', 'utils' ],
 		/**
 		 * Range iterator.
 		 *
-		 * @see document.PositionIterator
+		 * @see treeModel.PositionIterator
 		 */
 		[ Symbol.iterator ]() {
 			return new PositionIterator( this );
 		}
 
 		/**
-		 * Creates and returns a new instance of {@link document.Range}
-		 * which is equal to this {@link document.Range range}.
+		 * Creates and returns a new instance of {@link treeModel.Range}
+		 * which is equal to this {@link treeModel.Range range}.
 		 *
-		 * @returns {document.Position} Cloned {@link document.Range range}.
+		 * @returns {treeModel.Position} Cloned {@link treeModel.Range range}.
 		 */
 		clone() {
 			return new Range( this.start.clone(), this.end.clone() );
 		}
 
 		/**
-		 * Checks whether this contains given {@link document.Position position}.
+		 * Checks whether this contains given {@link treeModel.Position position}.
 		 *
-		 * @param {document.Position} position Position to check.
-		 * @returns {Boolean} True if given {@link document.Position position} is contained.
+		 * @param {treeModel.Position} position Position to check.
+		 * @returns {Boolean} True if given {@link treeModel.Position position} is contained.
 		 */
 		containsPosition( position ) {
 			return position.isAfter( this.start ) && position.isBefore( this.end );
 		}
 
 		/**
-		 * Checks whether this range contains given {@link document.Range range}.
+		 * Checks whether this range contains given {@link treeModel.Range range}.
 		 *
-		 * @param {document.Range} otherRange Range to check.
-		 * @returns {Boolean} True if given {@link document.Range range} boundaries are contained by this range.
+		 * @param {treeModel.Range} otherRange Range to check.
+		 * @returns {Boolean} True if given {@link treeModel.Range range} boundaries are contained by this range.
 		 */
 		containsRange( otherRange ) {
 			return this.containsPosition( otherRange.start ) && this.containsPosition( otherRange.end );
 		}
 
 		/**
-		 * Gets a part of this {@link document.Range range} which is not a part of given {@link document.Range range}. Returned
-		 * array contains zero, one or two {@link document.Range ranges}.
+		 * Gets a part of this {@link treeModel.Range range} which is not a part of given {@link treeModel.Range range}. Returned
+		 * array contains zero, one or two {@link treeModel.Range ranges}.
 		 *
 		 * Examples:
 		 *
@@ -93,8 +93,8 @@ CKEDITOR.define( [ 'document/position', 'document/positioniterator', 'utils' ],
 		 * 	transformed = range.getDifference( otherRange );
 		 * 	// transformed array has two ranges: from [ 2, 7 ] to [ 3 ] and from [ 4 ] to [ 4, 0, 1 ]
 		 *
-		 * @param {document.Range} otherRange Range to differentiate against.
-		 * @returns {Array.<document.Range>} The difference between ranges.
+		 * @param {treeModel.Range} otherRange Range to differentiate against.
+		 * @returns {Array.<treeModel.Range>} The difference between ranges.
 		 */
 		getDifference( otherRange ) {
 			const ranges = [];
@@ -132,7 +132,7 @@ CKEDITOR.define( [ 'document/position', 'document/positioniterator', 'utils' ],
 		}
 
 		/**
-		 * Returns an intersection of this {@link document.Range range} and given {@link document.Range range}. Intersection
+		 * Returns an intersection of this {@link treeModel.Range range} and given {@link treeModel.Range range}. Intersection
 		 * is a common part of both of those ranges. If ranges has no common part, returns `null`.
 		 *
 		 * Examples:
@@ -144,8 +144,8 @@ CKEDITOR.define( [ 'document/position', 'document/positioniterator', 'utils' ],
 		 * 	otherRange = new Range( new Position( root, [ 3 ] ), new Position( root, [ 5 ] ) );
 		 * 	transformed = range.getIntersection( otherRange ); // range from [ 3 ] to [ 4, 0, 1 ]
 		 *
-		 * @param {document.Range} otherRange Range to check for intersection.
-		 * @returns {document.Range|null} A common part of given ranges or null if ranges have no common part.
+		 * @param {treeModel.Range} otherRange Range to check for intersection.
+		 * @returns {treeModel.Range|null} A common part of given ranges or null if ranges have no common part.
 		 */
 		getIntersection( otherRange ) {
 			if ( this.start.isBefore( otherRange.end ) && this.end.isAfter( otherRange.start ) ) {
@@ -174,16 +174,16 @@ CKEDITOR.define( [ 'document/position', 'document/positioniterator', 'utils' ],
 		}
 
 		/**
-		 * Returns an iterator that iterates over all {@link document.Node nodes} that are in this range and returns them.
-		 * A node is in the range when it is after a {@link document.Position position} contained in this range.
-		 * In other words, this iterates over all {@link document.Character}s that are inside the range and
-		 * all the {@link document.Element}s we enter into when iterating over this range.
+		 * Returns an iterator that iterates over all {@link treeModel.Node nodes} that are in this range and returns them.
+		 * A node is in the range when it is after a {@link treeModel.Position position} contained in this range.
+		 * In other words, this iterates over all {@link treeModel.Character}s that are inside the range and
+		 * all the {@link treeModel.Element}s we enter into when iterating over this range.
 		 *
-		 * Note, that this method will not return a parent node of start position. This is in contrary to {@link document.PositionIterator}
-		 * which will return that node with {@link document.PositionIterator#ELEMENT_LEAVE} type.
+		 * Note, that this method will not return a parent node of start position. This is in contrary to {@link treeModel.PositionIterator}
+		 * which will return that node with {@link treeModel.PositionIterator#ELEMENT_LEAVE} type.
 		 *
-		 * @see {document.PositionIterator}
-		 * @returns {document.Node}
+		 * @see {treeModel.PositionIterator}
+		 * @returns {treeModel.Node}
 		 */
 		*getNodes() {
 			for ( let value of this ) {
@@ -194,9 +194,9 @@ CKEDITOR.define( [ 'document/position', 'document/positioniterator', 'utils' ],
 		}
 
 		/**
-		 * Returns an array containing one or two {document.Range ranges} that are a result of transforming this
-		 * {@link document.Range range} by inserting `howMany` nodes at `insertPosition`. Two {@link document.Range ranges} are
-		 * returned if the insertion was inside this {@link document.Range range}.
+		 * Returns an array containing one or two {treeModel.Range ranges} that are a result of transforming this
+		 * {@link treeModel.Range range} by inserting `howMany` nodes at `insertPosition`. Two {@link treeModel.Range ranges} are
+		 * returned if the insertion was inside this {@link treeModel.Range range}.
 		 *
 		 * Examples:
 		 *
@@ -210,11 +210,11 @@ CKEDITOR.define( [ 'document/position', 'document/positioniterator', 'utils' ],
 		 * 	transformed = range.getTransformedByInsertion( new Position( root, [ 3, 2 ] ), 4, true );
 		 * 	// transformed array has one range which is equal to `range`. This is because of spreadOnlyOnSameLevel flag.
 		 *
-		 * @param {document.Position} insertPosition Position where nodes are inserted.
+		 * @param {treeModel.Position} insertPosition Position where nodes are inserted.
 		 * @param {Number} howMany How many nodes are inserted.
-		 * @param {Boolean} spreadOnlyOnSameLevel Flag indicating whether this {document.Range range} should be spread
-		 * if insertion was inside a node from this {document.Range range} but not in the range itself.
-		 * @returns {Array.<document.Range>} Result of the transformation.
+		 * @param {Boolean} spreadOnlyOnSameLevel Flag indicating whether this {treeModel.Range range} should be spread
+		 * if insertion was inside a node from this {treeModel.Range range} but not in the range itself.
+		 * @returns {Array.<treeModel.Range>} Result of the transformation.
 		 */
 		getTransformedByInsertion( insertPosition, howMany, spreadOnlyOnSameLevel ) {
 			// Flag indicating whether this whole range and given insertPosition is on the same tree level.
@@ -252,7 +252,7 @@ CKEDITOR.define( [ 'document/position', 'document/positioniterator', 'utils' ],
 		/**
 		 * Two ranges equal if their start and end positions equal.
 		 *
-		 * @param {document.Range} otherRange Range to compare with.
+		 * @param {treeModel.Range} otherRange Range to compare with.
 		 * @returns {Boolean} True if ranges equal.
 		 */
 		isEqual( otherRange ) {
@@ -262,8 +262,8 @@ CKEDITOR.define( [ 'document/position', 'document/positioniterator', 'utils' ],
 		/**
 		 * 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.
+		 * @param {treeModel.Element} element Element which is a parent for the range.
+		 * @returns {treeModel.Range} Created range.
 		 */
 		static createFromElement( element ) {
 			return Range.createFromParentsAndOffsets( element, 0, element, element.getChildCount() );
@@ -272,9 +272,9 @@ CKEDITOR.define( [ 'document/position', 'document/positioniterator', 'utils' ],
 		/**
 		 * Creates a new range spreading from specified position to the same position moved by given offset.
 		 *
-		 * @param {document.Position} position Beginning of the range.
+		 * @param {treeModel.Position} position Beginning of the range.
 		 * @param {Number} offset How long the range should be.
-		 * @returns {document.Range}
+		 * @returns {treeModel.Range}
 		 */
 		static createFromPositionAndOffset( position, offset ) {
 			let endPosition = position.clone();
@@ -286,11 +286,11 @@ CKEDITOR.define( [ 'document/position', 'document/positioniterator', 'utils' ],
 		/**
 		 * Creates a range from given parents and offsets.
 		 *
-		 * @param {document.Element} startElement Start position parent element.
+		 * @param {treeModel.Element} startElement Start position parent element.
 		 * @param {Number} startOffset Start position offset.
-		 * @param {document.Element} endElement End position parent element.
+		 * @param {treeModel.Element} endElement End position parent element.
 		 * @param {Number} endOffset End position offset.
-		 * @returns {document.Range} Created range.
+		 * @returns {treeModel.Range} Created range.
 		 */
 		static createFromParentsAndOffsets( startElement, startOffset, endElement, endOffset ) {
 			return new Range(

+ 5 - 5
packages/ckeditor5-engine/src/document/rootelement.js → packages/ckeditor5-engine/src/treemodel/rootelement.js

@@ -5,27 +5,27 @@
 
 'use strict';
 
-CKEDITOR.define( [ 'document/element' ], ( Element ) => {
+CKEDITOR.define( [ 'treemodel/element' ], ( Element ) => {
 	/**
 	 * Class for nodes that are roots of trees in tree data model.
 	 *
-	 * @class document.RootElement
+	 * @class treeModel.RootElement
 	 */
 	class RootElement extends Element {
 		/**
 		 * Creates tree root node.
 		 *
-		 * @param {document.Document} doc {@link document.Document} that is an owner of the root.
+		 * @param {treeModel.Document} doc {@link treeModel.Document} that is an owner of the root.
 		 * @constructor
 		 */
 		constructor( doc ) {
 			super( 'root' );
 
 			/**
-			 * {@link document.Document} that is an owner of this root.
+			 * {@link treeModel.Document} that is an owner of this root.
 			 *
 			 * @readonly
-			 * @property {document.Document}
+			 * @property {treeModel.Document}
 			 */
 			this.document = doc;
 		}

+ 82 - 0
packages/ckeditor5-engine/src/treemodel/smartrange.js

@@ -0,0 +1,82 @@
+/**
+ * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+CKEDITOR.define( [ 'treemodel/range', 'emittermixin', 'utils' ], ( Range, EmitterMixin, utils ) => {
+	/**
+	 * SmartRange is a Range in the Tree Model that updates itself as the tree changes. It may be used as a bookmark.
+	 * SmartRange object may fire 'update' event whenever it gets changed by internal mechanisms.
+	 *
+	 * @class treeModel.SmartRange
+	 */
+	class SmartRange extends Range {
+		/**
+		 * Creates a smart range.
+		 *
+		 * @see {treeModel.Range}
+		 * @constructor
+		 */
+		constructor( start, end ) {
+			super( start, end );
+
+			this.listenTo( this.root.document, 'update', transform, this );
+		}
+	}
+
+	/**
+	 * Updates this position accordingly to the updates applied to the Tree Model. Bases on change events.
+	 *
+	 * @method transform
+	 * @param {String} type Type of changes applied to the Tree Model.
+	 * @param {treeModel.Range} range Range containing the result of applied change.
+	 * @param {treeModel.Position} [position] Additional position parameter provided by some change events.
+	 * @private
+	 */
+	function transform( type, range, position ) {
+		/*jshint validthis: true */
+
+		let howMany = range.end.offset - range.start.offset;
+		let newStart, newEnd;
+
+		switch ( type ) {
+			case 'insert':
+				newStart = this.start.getTransformedByInsertion( range.start, howMany, true );
+				newEnd = this.end.getTransformedByInsertion( range.start, howMany, false );
+				break;
+
+			case 'move':
+			case 'remove':
+			case 'reinsert':
+				let differenceSet = this.getDifference( Range.createFromPositionAndOffset( position, howMany ) );
+
+				if ( differenceSet.length > 0 ) {
+					let diff = differenceSet[ 0 ];
+
+					if ( differenceSet.length > 1 ) {
+						diff.end = differenceSet[ 1 ].end.clone();
+					}
+
+					newStart = diff.start.getTransformedByDeletion( position, howMany ).getTransformedByInsertion( range.start, howMany );
+					newEnd = diff.end.getTransformedByDeletion( position, howMany ).getTransformedByInsertion( range.start, howMany );
+				} else {
+					newStart = this.start._getCombined( position, range.start );
+					newEnd = this.end._getCombined( position, range.start );
+				}
+
+				break;
+		}
+
+		if ( !newStart.isEqual( this.start ) || !newEnd.isEqual( this.end ) ) {
+			this.start = newStart;
+			this.end = newEnd;
+			this.fire( 'update' );
+		}
+	}
+
+	utils.extend( SmartRange.prototype, EmitterMixin );
+
+	return SmartRange;
+} );

+ 6 - 6
packages/ckeditor5-engine/src/document/text.js → packages/ckeditor5-engine/src/treemodel/text.js

@@ -7,17 +7,17 @@
 
 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}.
+	 * Data structure for text with attributes. Note that the `Text` is not a {@link treeModel.Node},
+	 * because it will never be part of the document tree. {@link treeModel.Character is a node}.
 	 *
-	 * @class document.Text
+	 * @class treeModel.Text
 	 */
 	class Text {
 		/**
 		 * Creates a text with attributes.
 		 *
 		 * @param {String} text Described text.
-		 * @param {Iterable} attrs Iterable collection of {@link document.Attribute attributes}.
+		 * @param {Iterable} attrs Iterable collection of {@link treeModel.Attribute attributes}.
 		 * @constructor
 		 */
 		constructor( text, attrs ) {
@@ -30,7 +30,7 @@ CKEDITOR.define( [], () => {
 			this.text = text;
 
 			/**
-			 * Iterable collection of {@link document.Attribute attributes}.
+			 * Iterable collection of {@link treeModel.Attribute attributes}.
 			 *
 			 * @property {Iterable}
 			 */
@@ -39,4 +39,4 @@ CKEDITOR.define( [], () => {
 	}
 
 	return Text;
-} );
+} );

+ 2 - 2
packages/ckeditor5-engine/tests/document/attribute.js → packages/ckeditor5-engine/tests/treemodel/attribute.js

@@ -7,13 +7,13 @@
 
 'use strict';
 
-const modules = bender.amd.require( 'document/attribute' );
+const modules = bender.amd.require( 'treemodel/attribute' );
 
 describe( 'Attribute', () => {
 	let Attribute;
 
 	before( () => {
-		Attribute = modules[ 'document/attribute' ];
+		Attribute = modules[ 'treemodel/attribute' ];
 	} );
 
 	beforeEach( () => {

+ 4 - 4
packages/ckeditor5-engine/tests/document/batch.js → packages/ckeditor5-engine/tests/treemodel/batch.js

@@ -8,8 +8,8 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/batch',
-	'document/delta/delta',
+	'treemodel/batch',
+	'treemodel/delta/delta',
 	'ckeditorerror'
 );
 
@@ -17,8 +17,8 @@ describe( 'Batch', () => {
 	let Batch, Delta, CKEditorError;
 
 	before( () => {
-		Batch = modules[ 'document/batch' ];
-		Delta = modules[ 'document/delta/delta' ];
+		Batch = modules[ 'treemodel/batch' ];
+		Delta = modules[ 'treemodel/delta/delta' ];
 		CKEditorError = modules.ckeditorerror;
 	} );
 

+ 8 - 8
packages/ckeditor5-engine/tests/document/character.js → packages/ckeditor5-engine/tests/treemodel/character.js

@@ -14,20 +14,20 @@
 const getIteratorCount = bender.tools.core.getIteratorCount;
 
 const modules = bender.amd.require(
-	'document/character',
-	'document/node',
-	'document/element',
-	'document/attribute'
+	'treemodel/character',
+	'treemodel/node',
+	'treemodel/element',
+	'treemodel/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' ];
+		Element = modules[ 'treemodel/element' ];
+		Character = modules[ 'treemodel/character' ];
+		Node = modules[ 'treemodel/node' ];
+		Attribute = modules[ 'treemodel/attribute' ];
 	} );
 
 	describe( 'constructor', () => {

+ 16 - 16
packages/ckeditor5-engine/tests/document/deltas/attributedelta.js → packages/ckeditor5-engine/tests/treemodel/deltas/attributedelta.js

@@ -12,14 +12,14 @@
 const getIteratorCount = bender.tools.core.getIteratorCount;
 
 const modules = bender.amd.require(
-	'document/batch',
-	'document/document',
-	'document/text',
-	'document/attribute',
-	'document/range',
-	'document/position',
-	'document/element',
-	'document/character' );
+	'treemodel/batch',
+	'treemodel/document',
+	'treemodel/text',
+	'treemodel/attribute',
+	'treemodel/range',
+	'treemodel/position',
+	'treemodel/element',
+	'treemodel/character' );
 
 describe( 'Batch', () => {
 	let Batch, Document, Text, Attribute, Range, Position, Element, Character;
@@ -27,14 +27,14 @@ describe( 'Batch', () => {
 	let doc, root, batch;
 
 	before( () => {
-		Batch = modules[ 'document/batch' ];
-		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' ];
+		Batch = modules[ 'treemodel/batch' ];
+		Document = modules[ 'treemodel/document' ];
+		Text = modules[ 'treemodel/text' ];
+		Attribute = modules[ 'treemodel/attribute' ];
+		Range = modules[ 'treemodel/range' ];
+		Position = modules[ 'treemodel/position' ];
+		Element = modules[ 'treemodel/element' ];
+		Character = modules[ 'treemodel/character' ];
 	} );
 
 	beforeEach( () => {

+ 2 - 2
packages/ckeditor5-engine/tests/document/deltas/delta.js → packages/ckeditor5-engine/tests/treemodel/deltas/delta.js

@@ -12,13 +12,13 @@
 const getIteratorCount = bender.tools.core.getIteratorCount;
 
 const modules = bender.amd.require(
-	'document/delta/delta' );
+	'treemodel/delta/delta' );
 
 describe( 'Delta', () => {
 	let Delta;
 
 	before( () => {
-		Delta = modules[ 'document/delta/delta' ];
+		Delta = modules[ 'treemodel/delta/delta' ];
 	} );
 
 	describe( 'constructor', () => {

+ 4 - 4
packages/ckeditor5-engine/tests/document/deltas/insertdelta.js → packages/ckeditor5-engine/tests/treemodel/deltas/insertdelta.js

@@ -8,8 +8,8 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/position' );
+	'treemodel/document',
+	'treemodel/position' );
 
 describe( 'Batch', () => {
 	let Document, Position;
@@ -17,8 +17,8 @@ describe( 'Batch', () => {
 	let doc, root;
 
 	before( () => {
-		Document = modules[ 'document/document' ];
-		Position = modules[ 'document/position' ];
+		Document = modules[ 'treemodel/document' ];
+		Position = modules[ 'treemodel/position' ];
 	} );
 
 	beforeEach( () => {

+ 8 - 8
packages/ckeditor5-engine/tests/document/deltas/mergedelta.js → packages/ckeditor5-engine/tests/treemodel/deltas/mergedelta.js

@@ -12,10 +12,10 @@
 const getIteratorCount = bender.tools.core.getIteratorCount;
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/position',
-	'document/element',
-	'document/attribute',
+	'treemodel/document',
+	'treemodel/position',
+	'treemodel/element',
+	'treemodel/attribute',
 	'ckeditorerror' );
 
 describe( 'Batch', () => {
@@ -24,10 +24,10 @@ describe( 'Batch', () => {
 	let doc, root, p1, p2;
 
 	before( () => {
-		Document = modules[ 'document/document' ];
-		Position = modules[ 'document/position' ];
-		Element = modules[ 'document/element' ];
-		Attribute = modules[ 'document/attribute' ];
+		Document = modules[ 'treemodel/document' ];
+		Position = modules[ 'treemodel/position' ];
+		Element = modules[ 'treemodel/element' ];
+		Attribute = modules[ 'treemodel/attribute' ];
 		CKEditorError = modules.ckeditorerror;
 	} );
 

+ 4 - 4
packages/ckeditor5-engine/tests/document/deltas/removedelta.js → packages/ckeditor5-engine/tests/treemodel/deltas/removedelta.js

@@ -8,8 +8,8 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/position' );
+	'treemodel/document',
+	'treemodel/position' );
 
 describe( 'Batch', () => {
 	let Document, Position;
@@ -17,8 +17,8 @@ describe( 'Batch', () => {
 	let doc, root;
 
 	before( () => {
-		Document = modules[ 'document/document' ];
-		Position = modules[ 'document/position' ];
+		Document = modules[ 'treemodel/document' ];
+		Position = modules[ 'treemodel/position' ];
 	} );
 
 	beforeEach( () => {

+ 8 - 8
packages/ckeditor5-engine/tests/document/deltas/splitdelta.js → packages/ckeditor5-engine/tests/treemodel/deltas/splitdelta.js

@@ -12,10 +12,10 @@
 const getIteratorCount = bender.tools.core.getIteratorCount;
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/position',
-	'document/element',
-	'document/attribute',
+	'treemodel/document',
+	'treemodel/position',
+	'treemodel/element',
+	'treemodel/attribute',
 	'ckeditorerror' );
 
 describe( 'Batch', () => {
@@ -24,10 +24,10 @@ describe( 'Batch', () => {
 	let doc, root, p;
 
 	before( () => {
-		Document = modules[ 'document/document' ];
-		Position = modules[ 'document/position' ];
-		Element = modules[ 'document/element' ];
-		Attribute = modules[ 'document/attribute' ];
+		Document = modules[ 'treemodel/document' ];
+		Position = modules[ 'treemodel/position' ];
+		Element = modules[ 'treemodel/element' ];
+		Attribute = modules[ 'treemodel/attribute' ];
 		CKEditorError = modules.ckeditorerror;
 	} );
 

+ 120 - 0
packages/ckeditor5-engine/tests/treemodel/document.js

@@ -0,0 +1,120 @@
+/**
+ * @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(
+	'treemodel/document',
+	'treemodel/rootelement',
+	'treemodel/batch',
+	'ckeditorerror'
+);
+
+describe( 'Document', () => {
+	let Document, RootElement, Batch, CKEditorError;
+
+	before( () => {
+		Document = modules[ 'treemodel/document' ];
+		RootElement = modules[ 'treemodel/rootelement' ];
+		Batch = modules[ 'treemodel/batch' ];
+		CKEditorError = modules.ckeditorerror;
+	} );
+
+	let document;
+
+	beforeEach( () => {
+		document = new Document();
+	} );
+
+	describe( 'constructor', () => {
+		it( 'should create Document with no data and empty graveyard', () => {
+			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( 'batch', () => {
+		it( 'should create a new batch with the document property', () => {
+			const batch = document.batch();
+
+			expect( batch ).to.be.instanceof( Batch );
+			expect( batch ).to.have.property( 'doc' ).that.equals( document );
+		} );
+	} );
+} );

+ 34 - 34
packages/ckeditor5-engine/tests/document/document/change-event.js → packages/ckeditor5-engine/tests/treemodel/document/change-event.js

@@ -8,36 +8,36 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/element',
-	'document/rootelement',
-	'document/attribute',
-	'document/position',
-	'document/range',
-	'document/operation/changeoperation',
-	'document/operation/insertoperation',
-	'document/operation/moveoperation',
-	'document/operation/reinsertoperation',
-	'document/operation/removeoperation'
+	'treemodel/document',
+	'treemodel/element',
+	'treemodel/rootelement',
+	'treemodel/attribute',
+	'treemodel/position',
+	'treemodel/range',
+	'treemodel/operation/attributeoperation',
+	'treemodel/operation/insertoperation',
+	'treemodel/operation/moveoperation',
+	'treemodel/operation/reinsertoperation',
+	'treemodel/operation/removeoperation'
 );
 
 describe( 'Document change event', () => {
 	let Document, RootElement, Element, Range, Position;
-	let ChangeOperation, InsertOperation, MoveOperation, ReinsertOperation, RemoveOperation, Attribute;
+	let AttributeOperation, InsertOperation, MoveOperation, ReinsertOperation, RemoveOperation, Attribute;
 
 	before( () => {
-		Document = modules[ 'document/document' ];
-		Element = modules[ 'document/element' ];
-		RootElement = modules[ 'document/rootelement' ];
-		Attribute = modules[ 'document/attribute' ];
-		Position = modules[ 'document/position' ];
-		Range = modules[ 'document/range' ];
-
-		InsertOperation = modules[ 'document/operation/insertoperation' ];
-		ChangeOperation = modules[ 'document/operation/changeoperation' ];
-		MoveOperation = modules[ 'document/operation/moveoperation' ];
-		ReinsertOperation = modules[ 'document/operation/reinsertoperation' ];
-		RemoveOperation = modules[ 'document/operation/removeoperation' ];
+		Document = modules[ 'treemodel/document' ];
+		Element = modules[ 'treemodel/element' ];
+		RootElement = modules[ 'treemodel/rootelement' ];
+		Attribute = modules[ 'treemodel/attribute' ];
+		Position = modules[ 'treemodel/position' ];
+		Range = modules[ 'treemodel/range' ];
+
+		InsertOperation = modules[ 'treemodel/operation/insertoperation' ];
+		AttributeOperation = modules[ 'treemodel/operation/attributeoperation' ];
+		MoveOperation = modules[ 'treemodel/operation/moveoperation' ];
+		ReinsertOperation = modules[ 'treemodel/operation/reinsertoperation' ];
+		RemoveOperation = modules[ 'treemodel/operation/removeoperation' ];
 	} );
 
 	let doc, root, graveyard, types, changes;
@@ -45,7 +45,7 @@ describe( 'Document change event', () => {
 	beforeEach( () => {
 		doc = new Document();
 		root = doc.createRoot( 'root' );
-		graveyard = doc._graveyard;
+		graveyard = doc.graveyard;
 
 		types = [];
 		changes = [];
@@ -57,7 +57,7 @@ describe( 'Document change event', () => {
 	} );
 
 	it( 'should be fired when text is inserted', () => {
-		doc.applyOperation( new InsertOperation( new Position( [ 0 ], root ), 'foo', doc.version ) );
+		doc.applyOperation( new InsertOperation( new Position( root, [ 0 ] ), 'foo', doc.version ) );
 
 		expect( changes ).to.have.length( 1 );
 		expect( types[ 0 ] ).to.equal( 'insert' );
@@ -66,7 +66,7 @@ describe( 'Document change event', () => {
 
 	it( 'should be fired when element is inserted', () => {
 		const element = new Element( 'p' );
-		doc.applyOperation( new InsertOperation( new Position( [ 0 ], root ), element, doc.version ) );
+		doc.applyOperation( new InsertOperation( new Position( root, [ 0 ] ), element, doc.version ) );
 
 		expect( changes ).to.have.length( 1 );
 		expect( types[ 0 ] ).to.equal( 'insert' );
@@ -75,7 +75,7 @@ describe( 'Document change event', () => {
 
 	it( 'should be fired when nodes are inserted', () => {
 		const element = new Element( 'p' );
-		doc.applyOperation( new InsertOperation( new Position( [ 0 ], root ), [ element, 'foo' ], doc.version ) );
+		doc.applyOperation( new InsertOperation( new Position( root, [ 0 ] ), [ element, 'foo' ], doc.version ) );
 
 		expect( changes ).to.have.length( 1 );
 		expect( types[ 0 ] ).to.equal( 'insert' );
@@ -92,9 +92,9 @@ describe( 'Document change event', () => {
 
 		doc.applyOperation(
 			new MoveOperation(
-				new Position( [ 0, 0 ], root ),
-				new Position( [ 1, 0 ], root ),
+				new Position( root, [ 0, 0 ] ),
 				3,
+				new Position( root, [ 1, 0 ] ),
 				doc.version
 			)
 		);
@@ -108,7 +108,7 @@ describe( 'Document change event', () => {
 	it( 'should be fired when multiple nodes are removed and reinserted', () => {
 		root.insertChildren( 0, 'foo' );
 
-		const removeOperation = new RemoveOperation( new Position( [ 0 ], root ), 3, doc.version );
+		const removeOperation = new RemoveOperation( new Position( root, [ 0 ] ), 3, doc.version );
 		doc.applyOperation( removeOperation );
 
 		const reinsertOperation = removeOperation.getReversed();
@@ -129,7 +129,7 @@ describe( 'Document change event', () => {
 		root.insertChildren( 0, 'foo' );
 
 		doc.applyOperation(
-			new ChangeOperation(
+			new AttributeOperation(
 				Range.createFromParentsAndOffsets( root, 0, root, 3 ),
 				null,
 				new Attribute( 'key', 'new' ),
@@ -149,7 +149,7 @@ describe( 'Document change event', () => {
 		root.insertChildren( 0, elem );
 
 		doc.applyOperation(
-			new ChangeOperation(
+			new AttributeOperation(
 				Range.createFromParentsAndOffsets( root, 0, elem, 0 ),
 				new Attribute( 'key', 'old' ),
 				null,
@@ -169,7 +169,7 @@ describe( 'Document change event', () => {
 		root.insertChildren( 0, elem );
 
 		doc.applyOperation(
-			new ChangeOperation(
+			new AttributeOperation(
 				Range.createFromParentsAndOffsets( root, 0, elem, 0 ),
 				new Attribute( 'key', 'old' ),
 				new Attribute( 'key', 'new' ),

+ 8 - 8
packages/ckeditor5-engine/tests/document/document/document.js → packages/ckeditor5-engine/tests/treemodel/document/document.js

@@ -8,9 +8,9 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/rootelement',
-	'document/batch',
+	'treemodel/document',
+	'treemodel/rootelement',
+	'treemodel/batch',
 	'ckeditorerror'
 );
 
@@ -18,9 +18,9 @@ describe( 'Document', () => {
 	let Document, RootElement, Batch, CKEditorError;
 
 	before( () => {
-		Document = modules[ 'document/document' ];
-		RootElement = modules[ 'document/rootelement' ];
-		Batch = modules[ 'document/batch' ];
+		Document = modules[ 'treemodel/document' ];
+		RootElement = modules[ 'treemodel/rootelement' ];
+		Batch = modules[ 'treemodel/batch' ];
 		CKEditorError = modules.ckeditorerror;
 	} );
 
@@ -34,8 +34,8 @@ describe( 'Document', () => {
 		it( 'should create Document with no data and empty graveyard', () => {
 			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 );
+			expect( document.graveyard ).to.be.instanceof( RootElement );
+			expect( document.graveyard.getChildCount() ).to.equal( 0 );
 		} );
 	} );
 

+ 8 - 8
packages/ckeditor5-engine/tests/document/element.js → packages/ckeditor5-engine/tests/treemodel/element.js

@@ -14,20 +14,20 @@
 const getIteratorCount = bender.tools.core.getIteratorCount;
 
 const modules = bender.amd.require(
-	'document/node',
-	'document/nodelist',
-	'document/element',
-	'document/attribute'
+	'treemodel/node',
+	'treemodel/nodelist',
+	'treemodel/element',
+	'treemodel/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' ];
+		Element = modules[ 'treemodel/element' ];
+		Node = modules[ 'treemodel/node' ];
+		NodeList = modules[ 'treemodel/nodelist' ];
+		Attribute = modules[ 'treemodel/attribute' ];
 	} );
 
 	describe( 'constructor', () => {

+ 8 - 8
packages/ckeditor5-engine/tests/document/node.js → packages/ckeditor5-engine/tests/treemodel/node.js

@@ -12,10 +12,10 @@
 const getIteratorCount = bender.tools.core.getIteratorCount;
 
 const modules = bender.amd.require(
-	'document/element',
-	'document/character',
-	'document/attribute',
-	'document/nodelist',
+	'treemodel/element',
+	'treemodel/character',
+	'treemodel/attribute',
+	'treemodel/nodelist',
 	'ckeditorerror'
 );
 
@@ -27,10 +27,10 @@ describe( 'Node', () => {
 	let charB, charA, charR, img;
 
 	before( () => {
-		Element = modules[ 'document/element' ];
-		Character = modules[ 'document/character' ];
-		Attribute = modules[ 'document/attribute' ];
-		NodeList = modules[ 'document/nodelist' ];
+		Element = modules[ 'treemodel/element' ];
+		Character = modules[ 'treemodel/character' ];
+		Attribute = modules[ 'treemodel/attribute' ];
+		NodeList = modules[ 'treemodel/nodelist' ];
 		CKEditorError = modules.ckeditorerror;
 
 		charB = new Character( 'b' );

+ 8 - 8
packages/ckeditor5-engine/tests/document/nodelist.js → packages/ckeditor5-engine/tests/treemodel/nodelist.js

@@ -8,20 +8,20 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/nodelist',
-	'document/character',
-	'document/text',
-	'document/attribute'
+	'treemodel/nodelist',
+	'treemodel/character',
+	'treemodel/text',
+	'treemodel/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' ];
+		NodeList = modules[ 'treemodel/nodelist' ];
+		Character = modules[ 'treemodel/character' ];
+		Text = modules[ 'treemodel/text' ];
+		Attribute = modules[ 'treemodel/attribute' ];
 	} );
 
 	describe( 'constructor', () => {

+ 16 - 16
packages/ckeditor5-engine/tests/document/operation/attributeoperation.js → packages/ckeditor5-engine/tests/treemodel/operation/attributeoperation.js

@@ -13,14 +13,14 @@
 const getIteratorCount = bender.tools.core.getIteratorCount;
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/element',
-	'document/operation/attributeoperation',
-	'document/position',
-	'document/range',
-	'document/character',
-	'document/attribute',
-	'document/text',
+	'treemodel/document',
+	'treemodel/element',
+	'treemodel/operation/attributeoperation',
+	'treemodel/position',
+	'treemodel/range',
+	'treemodel/character',
+	'treemodel/attribute',
+	'treemodel/text',
 	'ckeditorerror'
 );
 
@@ -28,14 +28,14 @@ describe( 'AttributeOperation', () => {
 	let Document, Element, AttributeOperation, Position, Range, Character, Attribute, Text, CKEditorError;
 
 	before( () => {
-		Document = modules[ 'document/document' ];
-		Element = modules[ 'document/element' ];
-		AttributeOperation = modules[ 'document/operation/attributeoperation' ];
-		Position = modules[ 'document/position' ];
-		Range = modules[ 'document/range' ];
-		Character = modules[ 'document/character' ];
-		Attribute = modules[ 'document/attribute' ];
-		Text = modules[ 'document/text' ];
+		Document = modules[ 'treemodel/document' ];
+		Element = modules[ 'treemodel/element' ];
+		AttributeOperation = modules[ 'treemodel/operation/attributeoperation' ];
+		Position = modules[ 'treemodel/position' ];
+		Range = modules[ 'treemodel/range' ];
+		Character = modules[ 'treemodel/character' ];
+		Attribute = modules[ 'treemodel/attribute' ];
+		Text = modules[ 'treemodel/text' ];
 		CKEditorError = modules.ckeditorerror;
 	} );
 

+ 15 - 15
packages/ckeditor5-engine/tests/document/operation/insertoperation.js → packages/ckeditor5-engine/tests/treemodel/operation/insertoperation.js

@@ -9,27 +9,27 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/node',
-	'document/nodelist',
-	'document/operation/insertoperation',
-	'document/operation/removeoperation',
-	'document/position',
-	'document/character',
-	'document/nodelist'
+	'treemodel/document',
+	'treemodel/node',
+	'treemodel/nodelist',
+	'treemodel/operation/insertoperation',
+	'treemodel/operation/removeoperation',
+	'treemodel/position',
+	'treemodel/character',
+	'treemodel/nodelist'
 );
 
 describe( 'InsertOperation', () => {
 	let Document, Node, NodeList, InsertOperation, RemoveOperation, Position, Character;
 
 	before( () => {
-		Document = modules[ 'document/document' ];
-		Node = modules[ 'document/node' ];
-		NodeList = modules[ 'document/nodelist' ];
-		InsertOperation = modules[ 'document/operation/insertoperation' ];
-		RemoveOperation = modules[ 'document/operation/removeoperation' ];
-		Position = modules[ 'document/position' ];
-		Character = modules[ 'document/character' ];
+		Document = modules[ 'treemodel/document' ];
+		Node = modules[ 'treemodel/node' ];
+		NodeList = modules[ 'treemodel/nodelist' ];
+		InsertOperation = modules[ 'treemodel/operation/insertoperation' ];
+		RemoveOperation = modules[ 'treemodel/operation/removeoperation' ];
+		Position = modules[ 'treemodel/position' ];
+		Character = modules[ 'treemodel/character' ];
 	} );
 
 	let doc, root;

+ 10 - 10
packages/ckeditor5-engine/tests/document/operation/moveoperation.js → packages/ckeditor5-engine/tests/treemodel/operation/moveoperation.js

@@ -9,11 +9,11 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/operation/moveoperation',
-	'document/position',
-	'document/element',
-	'document/nodelist',
+	'treemodel/document',
+	'treemodel/operation/moveoperation',
+	'treemodel/position',
+	'treemodel/element',
+	'treemodel/nodelist',
 	'ckeditorerror'
 );
 
@@ -21,11 +21,11 @@ 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' ];
+		Document = modules[ 'treemodel/document' ];
+		MoveOperation = modules[ 'treemodel/operation/moveoperation' ];
+		Position = modules[ 'treemodel/position' ];
+		Element = modules[ 'treemodel/element' ];
+		NodeList = modules[ 'treemodel/nodelist' ];
 		CKEditorError = modules.ckeditorerror;
 	} );
 

+ 4 - 4
packages/ckeditor5-engine/tests/document/operation/nooperation.js → packages/ckeditor5-engine/tests/treemodel/operation/nooperation.js

@@ -8,16 +8,16 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/operation/nooperation'
+	'treemodel/document',
+	'treemodel/operation/nooperation'
 );
 
 describe( 'NoOperation', () => {
 	let Document, NoOperation;
 
 	before( function() {
-		Document = modules[ 'document/document' ];
-		NoOperation = modules[ 'document/operation/nooperation' ];
+		Document = modules[ 'treemodel/document' ];
+		NoOperation = modules[ 'treemodel/operation/nooperation' ];
 	} );
 
 	let noop, doc, root;

+ 10 - 10
packages/ckeditor5-engine/tests/document/operation/reinsertoperation.js → packages/ckeditor5-engine/tests/treemodel/operation/reinsertoperation.js

@@ -8,22 +8,22 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/operation/reinsertoperation',
-	'document/operation/removeoperation',
-	'document/operation/moveoperation',
-	'document/position'
+	'treemodel/document',
+	'treemodel/operation/reinsertoperation',
+	'treemodel/operation/removeoperation',
+	'treemodel/operation/moveoperation',
+	'treemodel/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' ];
+		Document = modules[ 'treemodel/document' ];
+		ReinsertOperation = modules[ 'treemodel/operation/reinsertoperation' ];
+		RemoveOperation = modules[ 'treemodel/operation/removeoperation' ];
+		MoveOperation = modules[ 'treemodel/operation/moveoperation' ];
+		Position = modules[ 'treemodel/position' ];
 	} );
 
 	let doc, root, graveyard, operation, graveyardPosition, rootPosition;

+ 10 - 10
packages/ckeditor5-engine/tests/document/operation/removeoperation.js → packages/ckeditor5-engine/tests/treemodel/operation/removeoperation.js

@@ -8,22 +8,22 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/operation/reinsertoperation',
-	'document/operation/removeoperation',
-	'document/operation/moveoperation',
-	'document/position'
+	'treemodel/document',
+	'treemodel/operation/reinsertoperation',
+	'treemodel/operation/removeoperation',
+	'treemodel/operation/moveoperation',
+	'treemodel/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' ];
+		Document = modules[ 'treemodel/document' ];
+		ReinsertOperation = modules[ 'treemodel/operation/reinsertoperation' ];
+		RemoveOperation = modules[ 'treemodel/operation/removeoperation' ];
+		MoveOperation = modules[ 'treemodel/operation/removeoperation' ];
+		Position = modules[ 'treemodel/position' ];
 	} );
 
 	let doc, root, graveyard;

+ 21 - 21
packages/ckeditor5-engine/tests/document/operation/transform.js → packages/ckeditor5-engine/tests/treemodel/operation/transform.js

@@ -11,16 +11,16 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/rootelement',
-	'document/node',
-	'document/position',
-	'document/range',
-	'document/attribute',
-	'document/operation/transform',
-	'document/operation/insertoperation',
-	'document/operation/attributeoperation',
-	'document/operation/moveoperation',
-	'document/operation/nooperation'
+	'treemodel/rootelement',
+	'treemodel/node',
+	'treemodel/position',
+	'treemodel/range',
+	'treemodel/attribute',
+	'treemodel/operation/transform',
+	'treemodel/operation/insertoperation',
+	'treemodel/operation/attributeoperation',
+	'treemodel/operation/moveoperation',
+	'treemodel/operation/nooperation'
 );
 
 describe( 'transform', () => {
@@ -28,17 +28,17 @@ describe( 'transform', () => {
 	let transform;
 
 	before( () => {
-		RootElement = modules[ 'document/rootelement' ];
-		Node = modules[ 'document/node' ];
-		Position = modules[ 'document/position' ];
-		Range = modules[ 'document/range' ];
-		Attribute = modules[ 'document/attribute' ];
-		InsertOperation = modules[ 'document/operation/insertoperation' ];
-		AttributeOperation = modules[ 'document/operation/attributeoperation' ];
-		MoveOperation = modules[ 'document/operation/moveoperation' ];
-		NoOperation = modules[ 'document/operation/nooperation' ];
-
-		transform = modules[ 'document/operation/transform' ];
+		RootElement = modules[ 'treemodel/rootelement' ];
+		Node = modules[ 'treemodel/node' ];
+		Position = modules[ 'treemodel/position' ];
+		Range = modules[ 'treemodel/range' ];
+		Attribute = modules[ 'treemodel/attribute' ];
+		InsertOperation = modules[ 'treemodel/operation/insertoperation' ];
+		AttributeOperation = modules[ 'treemodel/operation/attributeoperation' ];
+		MoveOperation = modules[ 'treemodel/operation/moveoperation' ];
+		NoOperation = modules[ 'treemodel/operation/nooperation' ];
+
+		transform = modules[ 'treemodel/operation/transform' ];
 	} );
 
 	let root, op, nodeA, nodeB, expected, baseVersion;

+ 10 - 10
packages/ckeditor5-engine/tests/document/position.js → packages/ckeditor5-engine/tests/treemodel/position.js

@@ -8,12 +8,12 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/element',
-	'document/character',
-	'document/position',
-	'document/document',
+	'treemodel/element',
+	'treemodel/character',
+	'treemodel/position',
+	'treemodel/document',
 	'ckeditorerror',
-	'document/nodelist'
+	'treemodel/nodelist'
 );
 
 describe( 'position', () => {
@@ -33,11 +33,11 @@ describe( 'position', () => {
 	//        |- 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' ];
+		Element = modules[ 'treemodel/element' ];
+		Character = modules[ 'treemodel/character' ];
+		Document = modules[ 'treemodel/document' ];
+		NodeList = modules[ 'treemodel/nodelist' ];
+		Position = modules[ 'treemodel/position' ];
 		CKEditorError = modules.ckeditorerror;
 
 		doc = new Document();

+ 12 - 12
packages/ckeditor5-engine/tests/document/positioniterator.js → packages/ckeditor5-engine/tests/treemodel/positioniterator.js

@@ -8,12 +8,12 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/element',
-	'document/character',
-	'document/positioniterator',
-	'document/position',
-	'document/range'
+	'treemodel/document',
+	'treemodel/element',
+	'treemodel/character',
+	'treemodel/positioniterator',
+	'treemodel/position',
+	'treemodel/range'
 );
 
 describe( 'range iterator', () => {
@@ -23,12 +23,12 @@ describe( 'range iterator', () => {
 	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' ];
+		Document = modules[ 'treemodel/document' ];
+		Element = modules[ 'treemodel/element' ];
+		Character = modules[ 'treemodel/character' ];
+		PositionIterator = modules[ 'treemodel/positioniterator' ];
+		Position = modules[ 'treemodel/position' ];
+		Range = modules[ 'treemodel/range' ];
 
 		ELEMENT_ENTER = PositionIterator.ELEMENT_ENTER;
 		ELEMENT_LEAVE = PositionIterator.ELEMENT_LEAVE;

+ 10 - 10
packages/ckeditor5-engine/tests/document/range.js → packages/ckeditor5-engine/tests/treemodel/range.js

@@ -8,22 +8,22 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/range',
-	'document/position',
-	'document/element',
-	'document/character',
-	'document/document'
+	'treemodel/range',
+	'treemodel/position',
+	'treemodel/element',
+	'treemodel/character',
+	'treemodel/document'
 );
 
 describe( 'Range', () => {
 	let Range, Position, Element, Character, Document;
 
 	before( () => {
-		Position = modules[ 'document/position' ];
-		Range = modules[ 'document/range' ];
-		Element = modules[ 'document/element' ];
-		Character = modules[ 'document/character' ];
-		Document = modules[ 'document/document' ];
+		Position = modules[ 'treemodel/position' ];
+		Range = modules[ 'treemodel/range' ];
+		Element = modules[ 'treemodel/element' ];
+		Character = modules[ 'treemodel/character' ];
+		Document = modules[ 'treemodel/document' ];
 	} );
 
 	let range, start, end, root;

+ 6 - 6
packages/ckeditor5-engine/tests/document/rootelement.js → packages/ckeditor5-engine/tests/treemodel/rootelement.js

@@ -14,18 +14,18 @@
 const getIteratorCount = bender.tools.core.getIteratorCount;
 
 const modules = bender.amd.require(
-	'document/document',
-	'document/element',
-	'document/rootelement'
+	'treemodel/document',
+	'treemodel/element',
+	'treemodel/rootelement'
 );
 
 describe( 'Element', () => {
 	let Document, Element, RootElement;
 
 	before( () => {
-		Document = modules[ 'document/document' ];
-		Element = modules[ 'document/element' ];
-		RootElement = modules[ 'document/rootelement' ];
+		Document = modules[ 'treemodel/document' ];
+		Element = modules[ 'treemodel/element' ];
+		RootElement = modules[ 'treemodel/rootelement' ];
 	} );
 
 	describe( 'constructor', () => {

+ 4 - 4
packages/ckeditor5-engine/tests/document/text.js → packages/ckeditor5-engine/tests/treemodel/text.js

@@ -10,15 +10,15 @@
 'use strict';
 
 const modules = bender.amd.require(
-	'document/text',
-	'document/attribute'
+	'treemodel/text',
+	'treemodel/attribute'
 );
 
 describe( 'Text', () => {
 	describe( 'constructor', () => {
 		it( 'should create character without attributes', () => {
-			const Text = modules[ 'document/text' ];
-			const Attribute = modules[ 'document/attribute' ];
+			const Text = modules[ 'treemodel/text' ];
+			const Attribute = modules[ 'treemodel/attribute' ];
 
 			let attrs = [ new Attribute( 'bold', true ) ];
 			let text = new Text( 'bar', attrs );