Procházet zdrojové kódy

Merge branch 'master' into t/344

Oskar Wrobel před 9 roky
rodič
revize
c7e1c3d01f
100 změnil soubory, kde provedl 2529 přidání a 1999 odebrání
  1. 33 33
      packages/ckeditor5-engine/src/treecontroller/mapper.js
  2. 28 28
      packages/ckeditor5-engine/src/treecontroller/model-converter-builder.js
  3. 30 30
      packages/ckeditor5-engine/src/treecontroller/model-selection-to-view-converters.js
  4. 49 49
      packages/ckeditor5-engine/src/treecontroller/model-to-view-converters.js
  5. 20 20
      packages/ckeditor5-engine/src/treecontroller/modelconsumable.js
  6. 88 88
      packages/ckeditor5-engine/src/treecontroller/modelconversiondispatcher.js
  7. 1 1
      packages/ckeditor5-engine/src/treecontroller/treecontroller.jsdoc
  8. 32 32
      packages/ckeditor5-engine/src/treecontroller/view-converter-builder.js
  9. 17 17
      packages/ckeditor5-engine/src/treecontroller/view-to-model-converters.js
  10. 45 45
      packages/ckeditor5-engine/src/treecontroller/viewconsumable.js
  11. 61 61
      packages/ckeditor5-engine/src/treecontroller/viewconversiondispatcher.js
  12. 0 0
      packages/ckeditor5-engine/src/datacontroller.js
  13. 1 1
      packages/ckeditor5-engine/src/treecontroller/editingcontroller.js
  14. 9 9
      packages/ckeditor5-engine/src/treemodel/batch.js
  15. 10 10
      packages/ckeditor5-engine/src/treemodel/characterproxy.js
  16. 23 23
      packages/ckeditor5-engine/src/treemodel/composer/composer.js
  17. 3 3
      packages/ckeditor5-engine/src/treemodel/composer/deletecontents.js
  18. 2 2
      packages/ckeditor5-engine/src/treemodel/composer/modifyselection.js
  19. 33 14
      packages/ckeditor5-engine/src/treemodel/delta/attributedelta.js
  20. 0 0
      packages/ckeditor5-engine/src/model/delta/basic-deltas.js
  21. 0 0
      packages/ckeditor5-engine/src/model/delta/basic-transformations.js
  22. 44 12
      packages/ckeditor5-engine/src/treemodel/delta/delta.js
  23. 1 1
      packages/ckeditor5-engine/src/treemodel/delta.jsdoc
  24. 65 0
      packages/ckeditor5-engine/src/model/delta/deltafactory.js
  25. 18 8
      packages/ckeditor5-engine/src/treemodel/delta/insertdelta.js
  26. 19 9
      packages/ckeditor5-engine/src/treemodel/delta/mergedelta.js
  27. 22 12
      packages/ckeditor5-engine/src/treemodel/delta/movedelta.js
  28. 15 5
      packages/ckeditor5-engine/src/treemodel/delta/removedelta.js
  29. 14 4
      packages/ckeditor5-engine/src/treemodel/delta/renamedelta.js
  30. 18 8
      packages/ckeditor5-engine/src/treemodel/delta/splitdelta.js
  31. 24 24
      packages/ckeditor5-engine/src/treemodel/delta/transform.js
  32. 16 6
      packages/ckeditor5-engine/src/treemodel/delta/unwrapdelta.js
  33. 22 12
      packages/ckeditor5-engine/src/treemodel/delta/weakinsertdelta.js
  34. 16 9
      packages/ckeditor5-engine/src/treemodel/delta/wrapdelta.js
  35. 59 49
      packages/ckeditor5-engine/src/treemodel/document.js
  36. 12 12
      packages/ckeditor5-engine/src/treemodel/documentfragment.js
  37. 49 15
      packages/ckeditor5-engine/src/treemodel/element.js
  38. 14 14
      packages/ckeditor5-engine/src/treemodel/history.js
  39. 10 0
      packages/ckeditor5-engine/src/model/item.jsdoc
  40. 32 32
      packages/ckeditor5-engine/src/treemodel/liveposition.js
  41. 25 25
      packages/ckeditor5-engine/src/treemodel/liverange.js
  42. 1 1
      packages/ckeditor5-engine/src/treeview/treeview.jsdoc
  43. 13 13
      packages/ckeditor5-engine/src/treemodel/node.js
  44. 74 43
      packages/ckeditor5-engine/src/treemodel/nodelist.js
  45. 30 12
      packages/ckeditor5-engine/src/treemodel/operation/attributeoperation.js
  46. 28 10
      packages/ckeditor5-engine/src/treemodel/operation/insertoperation.js
  47. 37 16
      packages/ckeditor5-engine/src/treemodel/operation/moveoperation.js
  48. 12 5
      packages/ckeditor5-engine/src/treemodel/operation/nooperation.js
  49. 113 0
      packages/ckeditor5-engine/src/model/operation/operation.js
  50. 2 1
      packages/ckeditor5-engine/src/treeview/observer.jsdoc
  51. 44 0
      packages/ckeditor5-engine/src/model/operation/operationfactory.js
  52. 14 6
      packages/ckeditor5-engine/src/treemodel/operation/reinsertoperation.js
  53. 13 6
      packages/ckeditor5-engine/src/treemodel/operation/removeoperation.js
  54. 47 16
      packages/ckeditor5-engine/src/treemodel/operation/rootattributeoperation.js
  55. 13 13
      packages/ckeditor5-engine/src/treemodel/operation/transform.js
  56. 76 48
      packages/ckeditor5-engine/src/treemodel/position.js
  57. 82 71
      packages/ckeditor5-engine/src/treemodel/range.js
  58. 53 0
      packages/ckeditor5-engine/src/model/rootelement.js
  59. 26 26
      packages/ckeditor5-engine/src/treemodel/schema.js
  60. 51 51
      packages/ckeditor5-engine/src/treemodel/selection.js
  61. 23 6
      packages/ckeditor5-engine/src/treemodel/text.js
  62. 18 18
      packages/ckeditor5-engine/src/treemodel/textproxy.js
  63. 35 34
      packages/ckeditor5-engine/src/treemodel/treewalker.js
  64. 0 10
      packages/ckeditor5-engine/src/treemodel/item.jsdoc
  65. 0 9
      packages/ckeditor5-engine/src/treemodel/operation.jsdoc
  66. 0 91
      packages/ckeditor5-engine/src/treemodel/operation/operation.js
  67. 0 34
      packages/ckeditor5-engine/src/treemodel/rootelement.js
  68. 12 12
      packages/ckeditor5-engine/src/treeview/attributeelement.js
  69. 12 12
      packages/ckeditor5-engine/src/treeview/containerelement.js
  70. 29 29
      packages/ckeditor5-engine/src/treeview/document.js
  71. 13 13
      packages/ckeditor5-engine/src/treeview/documentfragment.js
  72. 66 66
      packages/ckeditor5-engine/src/treeview/domconverter.js
  73. 31 31
      packages/ckeditor5-engine/src/treeview/element.js
  74. 20 20
      packages/ckeditor5-engine/src/treeview/filler.js
  75. 20 20
      packages/ckeditor5-engine/src/treeview/matcher.js
  76. 26 26
      packages/ckeditor5-engine/src/treeview/node.js
  77. 7 7
      packages/ckeditor5-engine/src/treeview/observer/domeventdata.js
  78. 15 15
      packages/ckeditor5-engine/src/treeview/observer/domeventobserver.js
  79. 7 7
      packages/ckeditor5-engine/src/treeview/observer/focusobserver.js
  80. 9 9
      packages/ckeditor5-engine/src/treeview/observer/keyobserver.js
  81. 30 30
      packages/ckeditor5-engine/src/treeview/observer/mutationobserver.js
  82. 12 12
      packages/ckeditor5-engine/src/treeview/observer/observer.js
  83. 8 0
      packages/ckeditor5-engine/src/view/observer/observer.jsdoc
  84. 21 21
      packages/ckeditor5-engine/src/treeview/observer/selectionobserver.js
  85. 25 25
      packages/ckeditor5-engine/src/treeview/position.js
  86. 15 15
      packages/ckeditor5-engine/src/treeview/range.js
  87. 30 30
      packages/ckeditor5-engine/src/treeview/renderer.js
  88. 49 49
      packages/ckeditor5-engine/src/treeview/selection.js
  89. 7 7
      packages/ckeditor5-engine/src/treeview/text.js
  90. 1 1
      packages/ckeditor5-engine/src/treemodel/treemodel.jsdoc
  91. 107 107
      packages/ckeditor5-engine/src/treeview/writer.js
  92. 6 6
      packages/ckeditor5-engine/tests/_utils-tests/model.js
  93. 9 9
      packages/ckeditor5-engine/tests/_utils-tests/view.js
  94. 21 21
      packages/ckeditor5-engine/tests/_utils/model.js
  95. 72 72
      packages/ckeditor5-engine/tests/_utils/view.js
  96. 23 23
      packages/ckeditor5-engine/tests/treecontroller/advanced-converters.js
  97. 11 11
      packages/ckeditor5-engine/tests/treecontroller/mapper.js
  98. 17 17
      packages/ckeditor5-engine/tests/treecontroller/model-converter-builder.js
  99. 13 13
      packages/ckeditor5-engine/tests/treecontroller/model-selection-to-view-converters.js
  100. 0 0
      packages/ckeditor5-engine/tests/treecontroller/model-to-view-converters.js

+ 33 - 33
packages/ckeditor5-engine/src/treecontroller/mapper.js

@@ -5,19 +5,19 @@
 
 'use strict';
 
-import ModelPosition from '../treemodel/position.js';
-import ViewPosition from '../treeview/position.js';
-import ModelRange from '../treemodel/range.js';
-import ViewRange from '../treeview/range.js';
-import ViewText from '../treeview/text.js';
+import ModelPosition from '../model/position.js';
+import ViewPosition from '../view/position.js';
+import ModelRange from '../model/range.js';
+import ViewRange from '../view/range.js';
+import ViewText from '../view/text.js';
 
 /**
- * Maps elements and positions between {@link engine.treeView.Document TreeView} and {@link engine.treeModel TreeModel}.
+ * Maps elements and positions between {@link engine.view.Document view} and {@link engine.model model}.
  *
  * Mapper use binded elements to find corresponding elements and positions, so, to get proper results,
- * all Tree Model elements should be {@link engine.treeController.Mapper#bindElements binded}.
+ * all Tree Model elements should be {@link engine.conversion.Mapper#bindElements binded}.
  *
- * @memberOf engine.treeController
+ * @memberOf engine.conversion
  */
 export default class Mapper {
 	/**
@@ -28,7 +28,7 @@ export default class Mapper {
 		 * Model element to View element mapping.
 		 *
 		 * @private
-		 * @member {WeakMap} engine.treeController.Mapper#_modelToViewMapping
+		 * @member {WeakMap} engine.conversion.Mapper#_modelToViewMapping
 		 */
 		this._modelToViewMapping = new WeakMap();
 
@@ -36,19 +36,19 @@ export default class Mapper {
 		 * View element to Model element mapping.
 		 *
 		 * @private
-		 * @member {WeakMap} engine.treeController.Mapper#_viewToModelMapping
+		 * @member {WeakMap} engine.conversion.Mapper#_viewToModelMapping
 		 */
 		this._viewToModelMapping = new WeakMap();
 	}
 
 	/**
 	 * Marks model and view elements as corresponding. Corresponding elements can be retrieved by using
-	 * the {@link engine.treeController.Mapper#toModelElement toModelElement} and
-	 * {@link engine.treeController.Mapper#toViewElement toViewElement} methods.
+	 * the {@link engine.conversion.Mapper#toModelElement toModelElement} and
+	 * {@link engine.conversion.Mapper#toViewElement toViewElement} methods.
 	 * The information that elements are bound is also used to translate positions.
 	 *
-	 * @param {engine.treeModel.Element} modelElement Model element.
-	 * @param {engine.treeView.Element} viewElement View element.
+	 * @param {engine.model.Element} modelElement Model element.
+	 * @param {engine.view.Element} viewElement View element.
 	 */
 	bindElements( modelElement, viewElement ) {
 		this._modelToViewMapping.set( modelElement, viewElement );
@@ -58,8 +58,8 @@ export default class Mapper {
 	/**
 	 * Gets the corresponding model element.
 	 *
-	 * @param {engine.treeView.Element} viewElement View element.
-	 * @returns {engine.treeModel.Element|null} Corresponding model element or `null` if not found.
+	 * @param {engine.view.Element} viewElement View element.
+	 * @returns {engine.model.Element|null} Corresponding model element or `null` if not found.
 	 */
 	toModelElement( viewElement ) {
 		return this._viewToModelMapping.get( viewElement );
@@ -68,8 +68,8 @@ export default class Mapper {
 	/**
 	 * Gets the corresponding view element.
 	 *
-	 * @param {engine.treeModel.Element} modelElement Model element.
-	 * @returns {engine.treeView.Element|null} Corresponding view element or `null` if not found.
+	 * @param {engine.model.Element} modelElement Model element.
+	 * @returns {engine.view.Element|null} Corresponding view element or `null` if not found.
 	 */
 	toViewElement( modelElement ) {
 		return this._modelToViewMapping.get( modelElement );
@@ -78,8 +78,8 @@ export default class Mapper {
 	/**
 	 * Gets the corresponding model range.
 	 *
-	 * @param {engine.treeView.Range} viewRange View range.
-	 * @returns {engine.treeModel.Range} Corresponding model range.
+	 * @param {engine.view.Range} viewRange View range.
+	 * @returns {engine.model.Range} Corresponding model range.
 	 */
 	toModelRange( viewRange ) {
 		return new ModelRange( this.toModelPosition( viewRange.start ), this.toModelPosition( viewRange.end ) );
@@ -88,8 +88,8 @@ export default class Mapper {
 	/**
 	 * Gets the corresponding view range.
 	 *
-	 * @param {engine.treeModel.Range} modelRange Model range.
-	 * @returns {engine.treeView.Range} Corresponding view range.
+	 * @param {engine.model.Range} modelRange Model range.
+	 * @returns {engine.view.Range} Corresponding view range.
 	 */
 	toViewRange( modelRange ) {
 		return new ViewRange( this.toViewPosition( modelRange.start ), this.toViewPosition( modelRange.end ) );
@@ -98,8 +98,8 @@ export default class Mapper {
 	/**
 	 * Gets the corresponding model position.
 	 *
-	 * @param {engine.treeView.Position} viewPosition View position.
-	 * @returns {engine.treeModel.Position} Corresponding model position.
+	 * @param {engine.view.Position} viewPosition View position.
+	 * @returns {engine.model.Position} Corresponding model position.
 	 */
 	toModelPosition( viewPosition ) {
 		let viewBlock = viewPosition.parent;
@@ -118,8 +118,8 @@ export default class Mapper {
 	/**
 	 * Gets the corresponding view position.
 	 *
-	 * @param {engine.treeModel.Position} modelPosition Model position.
-	 * @returns {engine.treeView.Position} Corresponding view position.
+	 * @param {engine.model.Position} modelPosition Model position.
+	 * @returns {engine.view.Position} Corresponding view position.
 	 */
 	toViewPosition( modelPosition ) {
 		let viewContainer = this._modelToViewMapping.get( modelPosition.parent );
@@ -140,9 +140,9 @@ export default class Mapper {
 	 *		<p>foo<b>ba|r</b></p> // _toModelOffset( b, 2, b ) -> 2
 	 *
 	 * @private
-	 * @param {engine.treeView.Element} viewParent Position parent.
+	 * @param {engine.view.Element} viewParent Position parent.
 	 * @param {Number} viewOffset Position offset.
-	 * @param {engine.treeView.Element} viewBlock Block used as a base to calculate offset.
+	 * @param {engine.view.Element} viewBlock Block used as a base to calculate offset.
 	 * @returns {Number} Offset in the model.
 	 */
 	_toModelOffset( viewParent, viewOffset, viewBlock ) {
@@ -181,7 +181,7 @@ export default class Mapper {
 	 *		<p>foo</p>   -> 1 // Length the element which has corresponding model element is always 1.
 	 *
 	 * @private
-	 * @param {engine.treeView.Element} viewNode View node.
+	 * @param {engine.view.Element} viewNode View node.
 	 * @returns {Number} Length of the node in the tree model.
 	 */
 	_getModelLength( viewNode ) {
@@ -224,9 +224,9 @@ export default class Mapper {
 	 *		<p>fo<b>ba|r</b>bom</p> -> expected offset: 2, actual offset: 2 -> position found
 	 *
 	 * @private
-	 * @param {engine.treeView.Element} viewParent Tree view element in which we are looking for the position.
+	 * @param {engine.view.Element} viewParent Tree view element in which we are looking for the position.
 	 * @param {Number} expectedOffset Expected offset.
-	 * @returns {engine.treeView.Position} Found position.
+	 * @returns {engine.view.Position} Found position.
 	 */
 	_findPositionIn( viewParent, expectedOffset ) {
 		// Last scanned view node.
@@ -273,8 +273,8 @@ export default class Mapper {
 	 *		<p><b>[]foo</b></p> -> <p><b>{}foo</b></p> // move to text node
 	 *
 	 * @private
-	 * @param {engine.treeView.Position} viewPosition Position potentially next to text node.
-	 * @returns {engine.treeView.Position} Position in text node if possible.
+	 * @param {engine.view.Position} viewPosition Position potentially next to text node.
+	 * @returns {engine.view.Position} Position in text node if possible.
 	 */
 	_moveViewPositionToTextNode( viewPosition ) {
 		// If the position is just after text node, put it at the end of that text node.

+ 28 - 28
packages/ckeditor5-engine/src/treecontroller/model-converter-builder.js

@@ -15,17 +15,17 @@ import {
 
 import { convertSelectionAttribute } from './model-selection-to-view-converters.js';
 
-import ViewAttributeElement from '../treeview/attributeelement.js';
-import ViewContainerElement from '../treeview/containerelement.js';
+import ViewAttributeElement from '../view/attributeelement.js';
+import ViewContainerElement from '../view/containerelement.js';
 
 /**
  * Provides chainable, high-level API to easily build basic model-to-view converters that are appended to given
  * dispatchers. In many cases, this is the API that should be used to specify how abstract model elements and
  * attributes should be represented in the view (and then later in DOM). Instances of this class are created by
- * {@link engine.treeController.BuildModelConverterFor}.
+ * {@link engine.conversion.BuildModelConverterFor}.
  *
- * If you need more complex converters, see {@link engine.treeController.ModelConversionDispatcher},
- * {@link engine.treeController.modelToView}, {@link engine.treeController.ModelConsumable}, {@link engine.treeController.Mapper}.
+ * If you need more complex converters, see {@link engine.conversion.ModelConversionDispatcher},
+ * {@link engine.conversion.modelToView}, {@link engine.conversion.ModelConsumable}, {@link engine.conversion.Mapper}.
  *
  * Using this API it is possible to create three kinds of converters:
  *
@@ -48,33 +48,33 @@ import ViewContainerElement from '../treeview/containerelement.js';
  *
  *		BuildModelConverterFor( dispatcher ).fromAttribute( 'bold' ).toElement( 'strong' );
  *
- * It is possible to provide various different parameters for {@link engine.treeController.ModelConverterBuilder#toElement}
- * and {@link engine.treeController.ModelConverterBuilder#toAttribute} methods. See their descriptions to learn more.
+ * It is possible to provide various different parameters for {@link engine.conversion.ModelConverterBuilder#toElement}
+ * and {@link engine.conversion.ModelConverterBuilder#toAttribute} methods. See their descriptions to learn more.
  *
- * It is also possible to {@link engine.treeController.ModelConverterBuilder#withPriority change default priority}
+ * It is also possible to {@link engine.conversion.ModelConverterBuilder#withPriority change default priority}
  * of created converters to decide which converter should be fired earlier and which later. This is useful if you provide
  * a general converter but want to provide different converter for a specific-case (i.e. given model element is converted
  * always to given view element, but if it has given attribute it is converter to other view element). For this,
- * use {@link engine.treeController.ModelConverterBuilder#withPriority withPriority} right after `from...` method.
+ * use {@link engine.conversion.ModelConverterBuilder#withPriority withPriority} right after `from...` method.
  *
  * Note that `to...` methods are "terminators", which means that should be the last one used in building converter.
  *
- * You can use {@link engine.treeController.ViewConverterBuilder} to create "opposite" converters - from view to model.
+ * You can use {@link engine.conversion.ViewConverterBuilder} to create "opposite" converters - from view to model.
  *
- * @memberOf engine.treeController
+ * @memberOf engine.conversion
  */
 class ModelConverterBuilder {
 	/**
 	 * Creates `ModelConverterBuilder` with given `dispatchers` registered to it.
 	 *
-	 * @param {Array.<engine.treeController.ModelConversionDispatcher>} dispatchers Dispatchers to which converters will
+	 * @param {Array.<engine.conversion.ModelConversionDispatcher>} dispatchers Dispatchers to which converters will
 	 * be attached.
 	 */
 	constructor( dispatchers ) {
 		/**
 		 * Dispatchers to which converters will be attached.
 		 *
-		 * @type {Array.<engine.treeController.ModelConversionDispatcher>}
+		 * @type {Array.<engine.conversion.ModelConversionDispatcher>}
 		 * @private
 		 */
 		this._dispatchers = dispatchers;
@@ -93,7 +93,7 @@ class ModelConverterBuilder {
 	 *
 	 * @chainable
 	 * @param {String} elementName Name of element to convert.
-	 * @returns {engine.treeController.ModelConverterBuilder}
+	 * @returns {engine.conversion.ModelConverterBuilder}
 	 */
 	fromElement( elementName ) {
 		this._from = {
@@ -110,7 +110,7 @@ class ModelConverterBuilder {
 	 *
 	 * @chainable
 	 * @param {String} key Key of attribute to convert.
-	 * @returns {engine.treeController.ModelConverterBuilder}
+	 * @returns {engine.conversion.ModelConverterBuilder}
 	 */
 	fromAttribute( key ) {
 		this._from = {
@@ -127,7 +127,7 @@ class ModelConverterBuilder {
 	 * Default priority is `10`.
 	 *
 	 * **Note:** Keep in mind that event priority, that is set by this modifier, is used for attribute priority
-	 * when {@link engine.treeView.Writer} is used. This changes how model attributes converter to view elements are
+	 * when {@link engine.view.Writer} is used. This changes how model attributes converter to view elements are
 	 * ordered, i.e.: `<strong><em>foo</em></strong>` vs `<em><strong>foo</strong></em>`. Using priority you can also
 	 * prevent node merging, i.e.: `<span class="bold"><span class="theme">foo</span><span>` vs `<span class="bold theme">foo</span>`.
 	 * If you want to prevent merging, just set different priority for both converters.
@@ -137,7 +137,7 @@ class ModelConverterBuilder {
 	 *
 	 * @chainable
 	 * @param {Number} priority Converter priority.
-	 * @returns {engine.treeController.ModelConverterBuilder}
+	 * @returns {engine.conversion.ModelConverterBuilder}
 	 */
 	withPriority( priority ) {
 		this._from.priority = priority;
@@ -151,8 +151,8 @@ class ModelConverterBuilder {
 	 * Method accepts various ways of providing how the view element will be created. You can pass view element name as
 	 * `string`, view element instance which will be cloned and used, or creator function which returns view element that
 	 * will be used. Keep in mind that when you view element instance or creator function, it has to be/return a
-	 * proper type of view element: {@link engine.treeView.ViewContainerElement ViewContainerElement} if you convert
-	 * from element or {@link engine.treeView.ViewAttributeElement ViewAttributeElement} if you convert from attribute.
+	 * proper type of view element: {@link engine.view.ViewContainerElement ViewContainerElement} if you convert
+	 * from element or {@link engine.view.ViewAttributeElement ViewAttributeElement} if you convert from attribute.
 	 *
 	 *		BuildModelConverterFor( dispatcher ).fromElement( 'paragraph' ).toElement( 'p' );
 	 *
@@ -166,16 +166,16 @@ class ModelConverterBuilder {
 	 *
 	 * Creator function will be passed different values depending whether conversion is from element or from attribute:
 	 *
-	 * * from element: dispatcher's {@link engine.treeController.ModelConversionDispatcher#event:insert insert event} parameters
+	 * * from element: dispatcher's {@link engine.conversion.ModelConversionDispatcher#event:insert insert event} parameters
 	 * will be passed,
 	 * * from attribute: there is one parameter and it is attribute value.
 	 *
 	 * This method also registers model selection to view selection converter, if conversion is from attribute.
 	 *
 	 * This method creates the converter and adds it as a callback to a proper
-	 * {@link engine.treeController.ModelConversionDispatcher conversion dispatcher} event.
+	 * {@link engine.conversion.ModelConversionDispatcher conversion dispatcher} event.
 	 *
-	 * @param {String|engine.treeView.ViewElement|Function} element Element created by converter.
+	 * @param {String|engine.view.ViewElement|Function} element Element created by converter.
 	 */
 	toElement( element ) {
 		const priority = this._from.priority === null ? 10 : this._from.priority;
@@ -210,7 +210,7 @@ class ModelConverterBuilder {
 	 * * if you pass two `string`s, first one will be used as new attribute key and second one as new attribute value,
 	 * * if you pass a function, it is expected to return an object with `key` and `value` properties representing attribute key and value.
 	 * This function will be passed model attribute value and model attribute key as first two parameters and then
-	 * all dispatcher's {engine.treeController.ModelConversionDispatcher#event:changeAttribute changeAttribute event} parameters.
+	 * all dispatcher's {engine.conversion.ModelConversionDispatcher#event:changeAttribute changeAttribute event} parameters.
 	 *
 	 *		BuildModelConverterFor( dispatcher ).fromAttribute( 'class' ).toAttribute( '' );
 	 *
@@ -223,7 +223,7 @@ class ModelConverterBuilder {
 	 *			.toAttribute( ( value ) => ( { key: 'class', value: value + '-theme' } ) );
 	 *
 	 * This method creates the converter and adds it as a callback to a proper
-	 * {@link engine.treeController.ModelConversionDispatcher conversion dispatcher} event.
+	 * {@link engine.conversion.ModelConversionDispatcher conversion dispatcher} event.
 	 *
 	 * @param {String|Function} [keyOrCreator] Attribute key or a creator function.
 	 * @param {*} [value] Attribute value.
@@ -270,11 +270,11 @@ class ModelConverterBuilder {
 /**
  * Entry point for model-to-view converters builder. This chainable API makes it easy to create basic, most common
  * model-to-view converters and attach them to provided dispatchers. The method returns an instance of
- * {@link engine.treeController.ModelConverterBuilder}.
+ * {@link engine.conversion.ModelConverterBuilder}.
  *
- * @external engine.treeController.BuildModelConverterFor
- * @memberOf engine.treeController
- * @param {...engine.treeController.ModelConversionDispatcher} dispatchers One or more dispatchers which
+ * @external engine.conversion.BuildModelConverterFor
+ * @memberOf engine.conversion
+ * @param {...engine.conversion.ModelConversionDispatcher} dispatchers One or more dispatchers which
  * the built converter will be attached to.
  */
 export default function BuildModelConverterFor( ...dispatchers ) {

+ 30 - 30
packages/ckeditor5-engine/src/treecontroller/model-selection-to-view-converters.js

@@ -5,25 +5,25 @@
 
 'use strict';
 
-import ViewElement from '../treeview/element.js';
-import ViewRange from '../treeview/range.js';
+import ViewElement from '../view/element.js';
+import ViewRange from '../view/range.js';
 
 /**
- * Contains {@link engine.treeModel.Selection model selection} to {@link engine.treeView.Selection view selection} converters for
- * {@link engine.treeController.ModelConversionDispatcher}.
+ * Contains {@link engine.model.Selection model selection} to {@link engine.view.Selection view selection} converters for
+ * {@link engine.conversion.ModelConversionDispatcher}.
  *
- * @namespace engine.treeController.modelSelectionToView
+ * @namespace engine.conversion.modelSelectionToView
  */
 
 /**
- * Function factory, creates a converter that converts non-collapsed {@link engine.treeModel.Selection model selection} to
- * {@link engine.treeView.Selection view selection}. The converter consumes appropriate value from `consumable` object
+ * Function factory, creates a converter that converts non-collapsed {@link engine.model.Selection model selection} to
+ * {@link engine.view.Selection view selection}. The converter consumes appropriate value from `consumable` object
  * and maps model positions from selection to view positions.
  *
  *		modelDispatcher.on( 'selection', convertRangeSelection() );
  *
- * @external engine.treeController.modelSelectionToView
- * @function engine.treeController.modelSelectionToView.convertRangeSelection
+ * @external engine.conversion.modelSelectionToView
+ * @function engine.conversion.modelSelectionToView.convertRangeSelection
  * @returns {Function} Selection converter.
  */
 export function convertRangeSelection() {
@@ -48,9 +48,9 @@ export function convertRangeSelection() {
 }
 
 /**
- * Function factory, creates a converter that converts collapsed {@link engine.treeModel.Selection model selection} to
- * {@link engine.treeView.Selection view selection}. The converter consumes appropriate value from `consumable` object,
- * maps model selection position to view position and breaks {@link engine.treeView.AttributeElement attribute elements}
+ * Function factory, creates a converter that converts collapsed {@link engine.model.Selection model selection} to
+ * {@link engine.view.Selection view selection}. The converter consumes appropriate value from `consumable` object,
+ * maps model selection position to view position and breaks {@link engine.view.AttributeElement attribute elements}
  * at the selection position.
  *
  *		modelDispatcher.on( 'selection', convertCollapsedSelection() );
@@ -61,14 +61,14 @@ export function convertRangeSelection() {
  *		-> <p><strong>f</strong>^<strong>oo</strong>bar</p>
  *
  * By breaking attribute elements like `<strong>` selection is in correct elements. See also complementary
- * {@link engine.treeController.modelSelectionToView.convertSelectionAttribute attribute converter} for selection attributes,
+ * {@link engine.conversion.modelSelectionToView.convertSelectionAttribute attribute converter} for selection attributes,
  * which wraps collapsed selection into view elements. Those converters together ensure, that selection ends up in
  * appropriate elements.
  *
- * See also {@link engine.treeController.modelSelectionToView.clearAttributes} which do the clean-up by merging attributes.
+ * See also {@link engine.conversion.modelSelectionToView.clearAttributes} which do the clean-up by merging attributes.
  *
- * @external engine.treeController.modelSelectionToView
- * @function engine.treeController.modelSelectionToView.convertCollapsedSelection
+ * @external engine.conversion.modelSelectionToView
+ * @function engine.conversion.modelSelectionToView.convertCollapsedSelection
  * @returns {Function} Selection converter.
  */
 export function convertCollapsedSelection() {
@@ -93,15 +93,15 @@ export function convertCollapsedSelection() {
 }
 
 /**
- * Function factory, creates a converter that converts {@link engine.treeModel.Selection model selection} attributes to
- * {@link engine.treeView.AttributeElement view attribute elements}. The converter works only for collapsed selection.
+ * Function factory, creates a converter that converts {@link engine.model.Selection model selection} attributes to
+ * {@link engine.view.AttributeElement view attribute elements}. The converter works only for collapsed selection.
  * The converter consumes appropriate value from `consumable` object, maps model selection position to view position and
  * wraps that position into a view attribute element.
  *
- * The wrapping node depends on passed parameter. If {@link engine.treeView.Element} was passed, it will be cloned and
+ * The wrapping node depends on passed parameter. If {@link engine.view.Element} was passed, it will be cloned and
  * the copy will become the wrapping element. If `Function` is provided, it is passed all the parameters of the
- * {@link engine.treeController.ModelConversionDispatcher#event:selectionAttribute selectionAttribute event}. It's expected that
- * the function returns a {@link engine.treeView.AttributeElement}. The result of the function will be the wrapping element.
+ * {@link engine.conversion.ModelConversionDispatcher#event:selectionAttribute selectionAttribute event}. It's expected that
+ * the function returns a {@link engine.view.AttributeElement}. The result of the function will be the wrapping element.
  *
  *		modelDispatcher.on( 'selectionAttribute:italic', convertSelectionAttribute( new ViewAttributeElement( 'em' ) ) );
  *
@@ -114,7 +114,7 @@ export function convertCollapsedSelection() {
  *		}
  *		modelDispatcher.on( 'selectionAttribute:style', convertSelectionAttribute( styleCreator ) );
  *
- * **Note:** You can use the same `elementCreator` function for this converter factory and {@link engine.treeController.modelToView.wrap}
+ * **Note:** You can use the same `elementCreator` function for this converter factory and {@link engine.conversion.modelToView.wrap}
  * model to view converter, as long as the `elementCreator` function uses only the first parameter (attribute value).
  *
  * Example of view state after converting collapsed selection. The scenario is: selection is inside bold text (`<strong>` element)
@@ -138,9 +138,9 @@ export function convertCollapsedSelection() {
  * but then it got wrapped-back by `convertSelectionAttribute()` converter. In second example, notice how `<strong>` element
  * is broken to prevent putting selection in it, since selection has no `bold` attribute.
  *
- * @external engine.treeController.modelSelectionToView
- * @function engine.treeController.modelSelectionToView.convertCollapsedSelection
- * @param {engine.treeView.AttributeElement|Function} elementCreator View element, or function returning a view element, which will
+ * @external engine.conversion.modelSelectionToView
+ * @function engine.conversion.modelSelectionToView.convertCollapsedSelection
+ * @param {engine.view.AttributeElement|Function} elementCreator View element, or function returning a view element, which will
  * be used for wrapping.
  * @returns {Function} Selection converter.
  */
@@ -171,8 +171,8 @@ export function convertSelectionAttribute( elementCreator ) {
 
 /**
  * Function factory, creates a converter that clears artifacts after the previous
- * {@link engine.treeModel.Selection model selection} conversion. It removes all empty
- * {@link engine.treeView.AttributeElement view attribute elements} and merge sibling attributes at all start and end
+ * {@link engine.model.Selection model selection} conversion. It removes all empty
+ * {@link engine.view.AttributeElement view attribute elements} and merge sibling attributes at all start and end
  * positions of all ranges.
  *
  *		<p><strong>^</strong></p>
@@ -188,11 +188,11 @@ export function convertSelectionAttribute( elementCreator ) {
  *
  *		modelDispatcher.on( 'selection', clearAttributes() );
  *
- * See {@link engine.treeController.modelSelectionToView.convertCollapsedSelection} which do the opposite by breaking
+ * See {@link engine.conversion.modelSelectionToView.convertCollapsedSelection} which do the opposite by breaking
  * attributes in the selection position.
  *
- * @external engine.treeController.modelSelectionToView
- * @function engine.treeController.modelSelectionToView.clearAttributes
+ * @external engine.conversion.modelSelectionToView
+ * @function engine.conversion.modelSelectionToView.clearAttributes
  * @returns {Function} Selection converter.
  */
 export function clearAttributes() {

+ 49 - 49
packages/ckeditor5-engine/src/treecontroller/model-to-view-converters.js

@@ -5,28 +5,28 @@
 
 'use strict';
 
-import ModelTreeWalker from '../treemodel/treewalker.js';
-import ModelRange from '../treemodel/range.js';
+import ModelTreeWalker from '../model/treewalker.js';
+import ModelRange from '../model/range.js';
 
-import ViewElement from '../treeview/element.js';
-import ViewText from '../treeview/text.js';
+import ViewElement from '../view/element.js';
+import ViewText from '../view/text.js';
 
 /**
- * Contains {@link engine.treeModel model} to {@link engine.treeView view} converters for
- * {@link engine.treeController.ModelConversionDispatcher}.
+ * Contains {@link engine.model model} to {@link engine.view view} converters for
+ * {@link engine.conversion.ModelConversionDispatcher}.
  *
- * @namespace engine.treeController.modelToView
+ * @namespace engine.conversion.modelToView
  */
 
 /**
  * Function factory, creates a converter that converts node insertion changes from the model to the view.
- * The view element that will be added to the view depends on passed parameter. If {@link engine.treeView.Element} was passed,
+ * The view element that will be added to the view depends on passed parameter. If {@link engine.view.Element} was passed,
  * it will be cloned and the copy will be inserted. If `Function` is provided, it is passed all the parameters of the
- * dispatcher's {@link engine.treeController.ModelConversionDispatcher#event:insert insert event}. It's expected that the
- * function returns a {@link engine.treeView.Element}. The result of the function will be inserted to the view.
+ * dispatcher's {@link engine.conversion.ModelConversionDispatcher#event:insert insert event}. It's expected that the
+ * function returns a {@link engine.view.Element}. The result of the function will be inserted to the view.
  *
  * The converter automatically consumes corresponding value from consumables list, stops the event (see
- * {@link engine.treeController.ModelConversionDispatcher}) and bind model and view elements.
+ * {@link engine.conversion.ModelConversionDispatcher}) and bind model and view elements.
  *
  *		modelDispatcher.on( 'insert:paragraph', insertElement( new ViewElement( 'p' ) ) );
  *
@@ -41,9 +41,9 @@ import ViewText from '../treeview/text.js';
  *			}
  *		) );
  *
- * @external engine.treeController.modelToView
- * @function engine.treeController.modelToView.insertElement
- * @param {engine.treeView.Element|Function} elementCreator View element, or function returning a view element, which
+ * @external engine.conversion.modelToView
+ * @function engine.conversion.modelToView.insertElement
+ * @param {engine.view.Element|Function} elementCreator View element, or function returning a view element, which
  * will be inserted.
  * @returns {Function} Insert element event converter.
  */
@@ -67,12 +67,12 @@ export function insertElement( elementCreator ) {
  * Function factory, creates a default model-to-view converter for text insertion changes.
  *
  * The converter automatically consumes corresponding value from consumables list and stops the event (see
- * {@link engine.treeController.ModelConversionDispatcher}).
+ * {@link engine.conversion.ModelConversionDispatcher}).
  *
  *		modelDispatcher.on( 'insert:$text', insertText() );
  *
- * @external engine.treeController.modelToView
- * @function engine.treeController.modelToView.insertText
+ * @external engine.conversion.modelToView
+ * @function engine.conversion.modelToView.insertText
  * @returns {Function} Insert text event converter.
  */
 export function insertText() {
@@ -97,7 +97,7 @@ export function insertText() {
  * **Note:** Provided attribute creator should always return the same `key` for given attribute from the model.
  *
  * The converter automatically consumes corresponding value from consumables list and stops the event (see
- * {@link engine.treeController.ModelConversionDispatcher}).
+ * {@link engine.conversion.ModelConversionDispatcher}).
  *
  *		modelDispatcher.on( 'addAttribute:customAttr:myElem', setAttribute( ( data ) => {
  *			// Change attribute key from `customAttr` to `class` in view.
@@ -113,12 +113,12 @@ export function insertText() {
  *			return { key, value };
  *		} ) );
  *
- * @external engine.treeController.modelToView
- * @function engine.treeController.modelToView.setAttribute
+ * @external engine.conversion.modelToView
+ * @function engine.conversion.modelToView.setAttribute
  * @param {Function} [attributeCreator] Function returning an object with two properties: `key` and `value`, which
- * represents attribute key and attribute value to be set on a {@link engine.treeView.Element view element}. The function
- * is passed all the parameters of the {@link engine.treeController.ModelConversionDispatcher.addAttribute}
- * or {@link engine.treeController.ModelConversionDispatcher.changeAttribute} event.
+ * represents attribute key and attribute value to be set on a {@link engine.view.Element view element}. The function
+ * is passed all the parameters of the {@link engine.conversion.ModelConversionDispatcher.addAttribute}
+ * or {@link engine.conversion.ModelConversionDispatcher.changeAttribute} event.
  * @returns {Function} Set/change attribute converter.
  */
 export function setAttribute( attributeCreator ) {
@@ -141,10 +141,10 @@ export function setAttribute( attributeCreator ) {
  *
  * **Note:** Provided attribute creator should always return the same `key` for given attribute from the model.
  *
- * **Note:** You can use the same attribute creator as in {@link engine.treeController.modelToView.setAttribute}.
+ * **Note:** You can use the same attribute creator as in {@link engine.conversion.modelToView.setAttribute}.
  *
  * The converter automatically consumes corresponding value from consumables list and stops the event (see
- * {@link engine.treeController.ModelConversionDispatcher}).
+ * {@link engine.conversion.ModelConversionDispatcher}).
  *
  *		modelDispatcher.on( 'removeAttribute:customAttr:myElem', removeAttribute( ( data ) => {
  *			// Change attribute key from `customAttr` to `class` in view.
@@ -160,12 +160,12 @@ export function setAttribute( attributeCreator ) {
  *			return { key, value };
  *		} ) );
  *
- * @external engine.treeController.modelToView
- * @function engine.treeController.modelToView.removeAttribute
+ * @external engine.conversion.modelToView
+ * @function engine.conversion.modelToView.removeAttribute
  * @param {Function} [attributeCreator] Function returning an object with two properties: `key` and `value`, which
- * represents attribute key and attribute value to be removed from {@link engine.treeView.Element view element}. The function
- * is passed all the parameters of the {@link engine.treeController.ModelConversionDispatcher#event:addAttribute addAttribute event}
- * or {@link engine.treeController.ModelConversionDispatcher#event:changeAttribute changeAttribute event}.
+ * represents attribute key and attribute value to be removed from {@link engine.view.Element view element}. The function
+ * is passed all the parameters of the {@link engine.conversion.ModelConversionDispatcher#event:addAttribute addAttribute event}
+ * or {@link engine.conversion.ModelConversionDispatcher#event:changeAttribute changeAttribute event}.
  * @returns {Function} Remove attribute converter.
  */
 export function removeAttribute( attributeCreator ) {
@@ -192,19 +192,19 @@ export function removeAttribute( attributeCreator ) {
  *			|- b {bold: true}                             |   |- ab
  *			|- c                                          |- c
  *
- * The wrapping node depends on passed parameter. If {@link engine.treeView.Element} was passed, it will be cloned and
+ * The wrapping node depends on passed parameter. If {@link engine.view.Element} was passed, it will be cloned and
  * the copy will become the wrapping element. If `Function` is provided, it is passed all the parameters of the
- * {@link engine.treeController.ModelConversionDispatcher#event:setAttribute setAttribute event}. It's expected that the
- * function returns a {@link engine.treeView.Element}. The result of the function will be the wrapping element.
+ * {@link engine.conversion.ModelConversionDispatcher#event:setAttribute setAttribute event}. It's expected that the
+ * function returns a {@link engine.view.Element}. The result of the function will be the wrapping element.
  *
  * The converter automatically consumes corresponding value from consumables list, stops the event (see
- * {@link engine.treeController.ModelConversionDispatcher}).
+ * {@link engine.conversion.ModelConversionDispatcher}).
  *
  *		modelDispatcher.on( 'addAttribute:bold', wrap( new ViewElement( 'strong' ) ) );
  *
- * @external engine.treeController.modelToView
- * @function engine.treeController.modelToView.wrap
- * @param {engine.treeView.Element|Function} elementCreator View element, or function returning a view element, which will
+ * @external engine.conversion.modelToView
+ * @function engine.conversion.modelToView.wrap
+ * @param {engine.view.Element|Function} elementCreator View element, or function returning a view element, which will
  * be used for wrapping.
  * @returns {Function} Set/change attribute converter.
  */
@@ -238,21 +238,21 @@ export function wrap( elementCreator ) {
  * view element if given attribute was removed.
  *
  * The view element type that will be unwrapped depends on passed parameter.
- * If {@link engine.treeView.Element} was passed, it will be used to look for similar element in the view for unwrapping. If `Function`
+ * If {@link engine.view.Element} was passed, it will be used to look for similar element in the view for unwrapping. If `Function`
  * is provided, it is passed all the parameters of the
- * {@link engine.treeController.ModelConversionDispatcher#event:setAttribute setAttribute event}. It's expected that the
- * function returns a {@link engine.treeView.Element}. The result of the function will be used to look for similar element
+ * {@link engine.conversion.ModelConversionDispatcher#event:setAttribute setAttribute event}. It's expected that the
+ * function returns a {@link engine.view.Element}. The result of the function will be used to look for similar element
  * in the view for unwrapping.
  *
  * The converter automatically consumes corresponding value from consumables list, stops the event (see
- * {@link engine.treeController.ModelConversionDispatcher}) and bind model and view elements.
+ * {@link engine.conversion.ModelConversionDispatcher}) and bind model and view elements.
  *
  *		modelDispatcher.on( 'removeAttribute:bold', unwrap( new ViewElement( 'strong' ) ) );
  *
- * @see engine.treeController.modelToView.wrap
- * @external engine.treeController.modelToView
- * @function engine.treeController.modelToView.unwrap
- * @param {engine.treeView.Element|Function} elementCreator View element, or function returning a view element, which will
+ * @see engine.conversion.modelToView.wrap
+ * @external engine.conversion.modelToView
+ * @function engine.conversion.modelToView.unwrap
+ * @param {engine.view.Element|Function} elementCreator View element, or function returning a view element, which will
  * be used for unwrapping.
  * @returns {Function} Remove attribute converter.
  */
@@ -276,8 +276,8 @@ export function unwrap( elementCreator ) {
  *
  *		modelDispatcher.on( 'move', move() );
  *
- * @external engine.treeController.modelToView
- * @function engine.treeController.modelToView.move
+ * @external engine.conversion.modelToView
+ * @function engine.conversion.modelToView.move
  * @returns {Function} Move event converter.
  */
 export function move() {
@@ -304,8 +304,8 @@ export function move() {
  *
  *		modelDispatcher.on( 'remove', remove() );
  *
- * @external engine.treeController.modelToView
- * @function engine.treeController.modelToView.remove
+ * @external engine.conversion.modelToView
+ * @function engine.conversion.modelToView.remove
  * @returns {Function} Remove event converter.
  */
 export function remove() {

+ 20 - 20
packages/ckeditor5-engine/src/treecontroller/modelconsumable.js

@@ -5,16 +5,16 @@
 
 'use strict';
 
-import TextProxy from '../treemodel/textproxy.js';
+import TextProxy from '../model/textproxy.js';
 
 /**
- * Manages a list of consumable values for {@link engine.treeModel.Item model items}.
+ * Manages a list of consumable values for {@link engine.model.Item model items}.
  *
  * Consumables are various aspects of the model. A model item can be broken down into singular properties that might be
  * taken into consideration when converting that item.
  *
- * `ModelConsumable` is used by {@link engine.treeController.ModelConversionDispatcher} while analyzing changed
- * parts of {@link engine.treeModel.Document the document}. The added / changed / removed model items are broken down
+ * `ModelConsumable` is used by {@link engine.conversion.ModelConversionDispatcher} while analyzing changed
+ * parts of {@link engine.model.Document the document}. The added / changed / removed model items are broken down
  * into singular properties (the item itself and it's attributes). All those parts are saved in `ModelConsumable`. Then,
  * during conversion, when given part of model item is converted (i.e. the view element has been inserted into the view,
  * but without attributes), consumable value is removed from `ModelConsumable`.
@@ -22,10 +22,10 @@ import TextProxy from '../treemodel/textproxy.js';
  * For model items, `ModelConsumable` stores consumable values of one of following types: `insert`, `addAttribute:<attributeKey>`,
  * `changeAttribute:<attributeKey>`, `removeAttribute:<attributeKey>`.
  *
- * In most cases, it is enough to let {@link engine.treeController.ModelConversionDispatcher} gather consumable values, so
- * there is no need to use {@link engine.treeController.ModelConsumable#add add method} directly. However, it is important to
- * understand how consumable values can be {@link engine.treeController.ModelConsumable#consume consumed}. See
- * {@link engine.treeController.modelToView default model to view converters} for more information.
+ * In most cases, it is enough to let {@link engine.conversion.ModelConversionDispatcher} gather consumable values, so
+ * there is no need to use {@link engine.conversion.ModelConsumable#add add method} directly. However, it is important to
+ * understand how consumable values can be {@link engine.conversion.ModelConsumable#consume consumed}. See
+ * {@link engine.conversion.modelToView default model to view converters} for more information.
  *
  * Keep in mind, that one conversion event may have multiple callbacks (converters) attached to it. Each of those is
  * able to convert one or more parts of the model. However, when one of those callbacks actually converts
@@ -84,7 +84,7 @@ import TextProxy from '../treemodel/textproxy.js';
  *			evt.stop();
  *		} );
  *
- * @memberOf engine.treeController
+ * @memberOf engine.conversion
  */
 export default class ModelConsumable {
 	/**
@@ -95,12 +95,12 @@ export default class ModelConsumable {
 		 * Contains list of consumable values.
 		 *
 		 * @private
-		 * @member {Map} engine.treeController.ModelConsumable#_consumable
+		 * @member {Map} engine.conversion.ModelConsumable#_consumable
 		 */
 		this._consumable = new Map();
 
 		/**
-		 * For each {@link engine.treeModel.TextProxy} added to `ModelConsumable`, this registry holds parent
+		 * For each {@link engine.model.TextProxy} added to `ModelConsumable`, this registry holds parent
 		 * of that `TextProxy` and start and end indices of that `TextProxy`. This allows identification of `TextProxy`
 		 * instances that points to the same part of the model but are different instances. Each distinct `TextProxy`
 		 * is given unique `Symbol` which is then registered as consumable. This process is transparent for `ModelConsumable`
@@ -108,7 +108,7 @@ export default class ModelConsumable {
 		 * `ModelConsumable` translates `TextProxy` to that unique `Symbol`.
 		 *
 		 * @private
-		 * @member {Map} engine.treeController.ModelConsumable#_textProxyRegistry
+		 * @member {Map} engine.conversion.ModelConsumable#_textProxyRegistry
 		 */
 		this._textProxyRegistry = new Map();
 	}
@@ -122,7 +122,7 @@ export default class ModelConsumable {
 	 *		modelConsumable.add( modelSelection, 'selection' ); // Add `modelSelection` to consumable values.
 	 *		modelConsumable.add( modelSelection, 'selectionAttribute:bold' ); // Add `bold` attribute on `modelSelection` to consumables.
 	 *
-	 * @param {engine.treeModel.Item|engine.treeModel.Selection} item Model item or selection that has the consumable.
+	 * @param {engine.model.Item|engine.model.Selection} item Model item or selection that has the consumable.
 	 * @param {String} type Consumable type.
 	 */
 	add( item, type ) {
@@ -146,7 +146,7 @@ export default class ModelConsumable {
 	 *		modelConsumable.consume( modelSelection, 'selection' ); // Remove `modelSelection` from consumable values.
 	 *		modelConsumable.consume( modelSelection, 'selectionAttribute:bold' ); // Remove `bold` on `modelSelection` from consumables.
 	 *
-	 * @param {engine.treeModel.Item|engine.treeModel.Selection} item Model item or selection from which consumable will be consumed.
+	 * @param {engine.model.Item|engine.model.Selection} item Model item or selection from which consumable will be consumed.
 	 * @param {String} type Consumable type.
 	 * @returns {Boolean} `true` if consumable value was available and was consumed, `false` otherwise.
 	 */
@@ -173,7 +173,7 @@ export default class ModelConsumable {
 	 *		modelConsumable.test( modelSelection, 'selection' ); // Check if `modelSelection` is consumable.
 	 *		modelConsumable.test( modelSelection, 'selectionAttribute:bold' ); // Check if `bold` on `modelSelection` is consumable.
 	 *
-	 * @param {engine.treeModel.Item|engine.treeModel.Selection} item Model item or selection that will be tested.
+	 * @param {engine.model.Item|engine.model.Selection} item Model item or selection that will be tested.
 	 * @param {String} type Consumable type.
 	 * @returns {null|Boolean} `null` if such consumable was never added, `false` if the consumable values was
 	 * already consumed or `true` if it was added and not consumed yet.
@@ -207,7 +207,7 @@ export default class ModelConsumable {
 	 *		modelConsumable.revert( modelSelection, 'selection' ); // Revert consuming `modelSelection`.
 	 *		modelConsumable.revert( modelSelection, 'selectionAttribute:bold' ); // Revert consuming `bold` from `modelSelection`.
 	 *
-	 * @param {engine.treeModel.Item|engine.treeModel.Selection} item Model item or selection that will be reverted.
+	 * @param {engine.model.Item|engine.model.Selection} item Model item or selection that will be reverted.
 	 * @param {String} type Consumable type.
 	 * @returns {null|Boolean} `true` if consumable has been reversed, `false` otherwise. `null` if the consumable has
 	 * never been added.
@@ -231,13 +231,13 @@ export default class ModelConsumable {
 	}
 
 	/**
-	 * Gets a unique symbol for passed {@link engine.treeModel.TextProxy} instance. All `TextProxy` instances that
+	 * Gets a unique symbol for passed {@link engine.model.TextProxy} instance. All `TextProxy` instances that
 	 * have same parent, same start index and same end index will get the same symbol.
 	 *
 	 * Used internally to correctly consume `TextProxy` instances.
 	 *
 	 * @private
-	 * @param {engine.treeModel.TextProxy} textProxy `TextProxy` instance to get a symbol for.
+	 * @param {engine.model.TextProxy} textProxy `TextProxy` instance to get a symbol for.
 	 * @returns {Symbol} Symbol representing all equal instances of `TextProxy`.
 	 */
 	_getSymbolForTextProxy( textProxy ) {
@@ -265,14 +265,14 @@ export default class ModelConsumable {
 	}
 
 	/**
-	 * Adds a symbol for given properties that characterizes a {@link engine.treeModel.TextProxy} instance.
+	 * Adds a symbol for given properties that characterizes a {@link engine.model.TextProxy} instance.
 	 *
 	 * Used internally to correctly consume `TextProxy` instances.
 	 *
 	 * @private
 	 * @param {Number} startIndex Text proxy start index in it's parent.
 	 * @param {Number} endIndex Text proxy end index in it's parent.
-	 * @param {engine.treeModel.Element} parent Text proxy parent.
+	 * @param {engine.model.Element} parent Text proxy parent.
 	 * @returns {Symbol} Symbol generated for given properties.
 	 */
 	_addSymbolForTextProxy( startIndex, endIndex, parent ) {

+ 88 - 88
packages/ckeditor5-engine/src/treecontroller/modelconversiondispatcher.js

@@ -6,16 +6,16 @@
 'use strict';
 
 import Consumable from './modelconsumable.js';
-import Range from '../treemodel/range.js';
-import TextProxy from '../treemodel/textproxy.js';
+import Range from '../model/range.js';
+import TextProxy from '../model/textproxy.js';
 import EmitterMixin from '../../utils/emittermixin.js';
 import mix from '../../utils/mix.js';
 import extend from '../../utils/lib/lodash/extend.js';
 
 /**
- * `ModelConversionDispatcher` is a central point of {@link engine.treeModel model} conversion, which is
+ * `ModelConversionDispatcher` is a central point of {@link engine.model model} conversion, which is
  * a process of reacting to changes in the model and reflecting them by listeners that listen to those changes.
- * In default application, {@link engine.treeModel model} is converted to {@link engine.treeView view}. This means
+ * In default application, {@link engine.model model} is converted to {@link engine.view view}. This means
  * that changes in the model are reflected by changing the view (i.e. adding view nodes or changing attributes on view elements).
  *
  * During conversion process, `ModelConversionDispatcher` fires data-manipulation events, basing on state of the model and prepares
@@ -23,24 +23,24 @@ import extend from '../../utils/lib/lodash/extend.js';
  * or "removing" so one might say that we are converting "changes". This is in contrary to view to model conversion,
  * where we convert view nodes (the structure, not "changes" to the view). Note, that because changes are converted
  * and not the structure itself, there is a need to have a mapping between model and the structure on which changes are
- * reflected. To map elements during model to view conversion use {@link engine.treeController.Mapper}.
+ * reflected. To map elements during model to view conversion use {@link engine.conversion.Mapper}.
  *
- * The main use for this class is to listen to {@link engine.treeModel.Document.change Document change event}, process it
+ * The main use for this class is to listen to {@link engine.model.Document.change Document change event}, process it
  * and then fire specific events telling what exactly has changed. For those events, `ModelConversionDispatcher`
- * creates {@link engine.treeController.ModelConsumable list of consumable values} that should be handled by event
+ * creates {@link engine.conversion.ModelConsumable list of consumable values} that should be handled by event
  * callbacks. Those events are listened to by model-to-view converters which convert changes done in the
- * {@link engine.treeModel model} to changes in the {@link engine.treeView view}. `ModelConversionController` also checks
+ * {@link engine.model model} to changes in the {@link engine.view view}. `ModelConversionController` also checks
  * the current state of consumables, so it won't fire events for parts of model that were already consumed. This is
- * especially important in callbacks that consume multiple values. See {@link engine.treeController.ModelConsumable}
+ * especially important in callbacks that consume multiple values. See {@link engine.conversion.ModelConsumable}
  * for an example of such callback.
  *
  * Although the primary usage for this class is the model-to-view conversion, `ModelConversionDispatcher` can be used
  * to build custom data processing pipelines that converts model to anything that is needed. Existing model structure can
- * be used to generate events (listening to {@link engine.treeModel.Document.change Document change event} is not required)
+ * be used to generate events (listening to {@link engine.model.Document.change Document change event} is not required)
  * and custom callbacks can be added to the events (these does not have to be limited to changes in the view).
  *
  * When providing your own event listeners for `ModelConversionDispatcher` keep in mind that any callback that had
- * {@link engine.treeController.ModelConsumable#consume consumed} a value from consumable (and did some changes, i.e. to
+ * {@link engine.conversion.ModelConsumable#consume consumed} a value from consumable (and did some changes, i.e. to
  * the view) should also stop the event. This is because whenever a callback is fired it is assumed that there is something
  * to be consumed. Thanks to that approach, you do not have to test whether there is anything to consume at the beginning
  * of your listener callback.
@@ -91,7 +91,7 @@ import extend from '../../utils/lib/lodash/extend.js';
  *			viewSourceBtn.addClass( 'source' );
  *
  *			// Insert the button using writer API.
- *			// If `addAttribute` event is fired by `engine.treeController.ModelConversionDispatcher#convertInsert` it is fired
+ *			// If `addAttribute` event is fired by `engine.conversion.ModelConversionDispatcher#convertInsert` it is fired
  *			// after `data.item` insert conversion was done. If the event is fired due to attribute insertion coming from
  *			// different source, `data.item` already existed. This means we are safe to get `viewQuote` from mapper.
  *			const viewQuote = conversionApi.mapper.toViewElement( data.item );
@@ -101,7 +101,7 @@ import extend from '../../utils/lib/lodash/extend.js';
  *			evt.stop();
  *		}, 1 );
  *
- * @memberOf engine.treeController
+ * @memberOf engine.conversion
  */
 export default class ModelConversionDispatcher {
 	/**
@@ -113,7 +113,7 @@ export default class ModelConversionDispatcher {
 		/**
 		 * Interface passed by dispatcher to the events callbacks.
 		 *
-		 * @member {Object} engine.treeController.ModelConversionDispatcher#conversionApi
+		 * @member {Object} engine.conversion.ModelConversionDispatcher#conversionApi
 		 */
 		this.conversionApi = extend( {}, conversionApi );
 	}
@@ -121,15 +121,15 @@ export default class ModelConversionDispatcher {
 	/**
 	 * Prepares data and fires a proper event.
 	 *
-	 * The method is crafted to take use of parameters passed in {@link engine.treeModel.Document.change Document change event}.
+	 * The method is crafted to take use of parameters passed in {@link engine.model.Document.change Document change event}.
 	 *
-	 * @see engine.treeModel.Document.change
-	 * @fires engine.treeController.ModelConversionDispatcher#insert
-	 * @fires engine.treeController.ModelConversionDispatcher#move
-	 * @fires engine.treeController.ModelConversionDispatcher#remove
-	 * @fires engine.treeController.ModelConversionDispatcher#addAttribute
-	 * @fires engine.treeController.ModelConversionDispatcher#removeAttribute
-	 * @fires engine.treeController.ModelConversionDispatcher#changeAttribute
+	 * @see engine.model.Document.change
+	 * @fires engine.conversion.ModelConversionDispatcher#insert
+	 * @fires engine.conversion.ModelConversionDispatcher#move
+	 * @fires engine.conversion.ModelConversionDispatcher#remove
+	 * @fires engine.conversion.ModelConversionDispatcher#addAttribute
+	 * @fires engine.conversion.ModelConversionDispatcher#removeAttribute
+	 * @fires engine.conversion.ModelConversionDispatcher#changeAttribute
 	 * @param {String} type Change type.
 	 * @param {Object} data Additional information about the change.
 	 */
@@ -151,9 +151,9 @@ export default class ModelConversionDispatcher {
 	 * **Note**: This method will fire separate events for node insertion and attributes insertion. All
 	 * attributes that are set on inserted nodes are treated like they were added just after node insertion.
 	 *
-	 * @fires engine.treeController.ModelConversionDispatcher#insert
-	 * @fires engine.treeController.ModelConversionDispatcher#addAttribute
-	 * @param {engine.treeModel.Range} range Inserted range.
+	 * @fires engine.conversion.ModelConversionDispatcher#insert
+	 * @fires engine.conversion.ModelConversionDispatcher#addAttribute
+	 * @param {engine.model.Range} range Inserted range.
 	 */
 	convertInsert( range ) {
 		// Create a list of things that can be consumed, consisting of nodes and their attributes.
@@ -186,9 +186,9 @@ export default class ModelConversionDispatcher {
 	/**
 	 * Fires move event with data based on passed values.
 	 *
-	 * @fires engine.treeController.ModelConversionDispatcher#move
-	 * @param {engine.treeModel.Position} sourcePosition Position from where the range has been moved.
-	 * @param {engine.treeModel.Range} range Moved range (after move).
+	 * @fires engine.conversion.ModelConversionDispatcher#move
+	 * @param {engine.model.Position} sourcePosition Position from where the range has been moved.
+	 * @param {engine.model.Range} range Moved range (after move).
 	 */
 	convertMove( sourcePosition, range ) {
 		const data = {
@@ -202,9 +202,9 @@ export default class ModelConversionDispatcher {
 	/**
 	 * Fires remove event with data based on passed values.
 	 *
-	 * @fires engine.treeController.ModelConversionDispatcher#remove
-	 * @param {engine.treeModel.Position} sourcePosition Position from where the range has been removed.
-	 * @param {engine.treeModel.Range} range Removed range (after remove, in {@link engine.treeModel.Document#graveyard graveyard root}).
+	 * @fires engine.conversion.ModelConversionDispatcher#remove
+	 * @param {engine.model.Position} sourcePosition Position from where the range has been removed.
+	 * @param {engine.model.Range} range Removed range (after remove, in {@link engine.model.Document#graveyard graveyard root}).
 	 */
 	convertRemove( sourcePosition, range ) {
 		const data = {
@@ -218,11 +218,11 @@ export default class ModelConversionDispatcher {
 	/**
 	 * Analyzes given attribute change and fires attributes-connected events with data based on passed values.
 	 *
-	 * @fires engine.treeController.ModelConversionDispatcher#addAttribute
-	 * @fires engine.treeController.ModelConversionDispatcher#removeAttribute
-	 * @fires engine.treeController.ModelConversionDispatcher#changeAttribute
+	 * @fires engine.conversion.ModelConversionDispatcher#addAttribute
+	 * @fires engine.conversion.ModelConversionDispatcher#removeAttribute
+	 * @fires engine.conversion.ModelConversionDispatcher#changeAttribute
 	 * @param {String} type Change type. Possible values: `addAttribute`, `removeAttribute`, `changeAttribute`.
-	 * @param {engine.treeModel.Range} range Changed range.
+	 * @param {engine.model.Range} range Changed range.
 	 * @param {String} key Attribute key.
 	 * @param {*} oldValue Attribute value before the change or `null` if attribute has not been set.
 	 * @param {*} newValue New attribute value or `null` if attribute has been removed.
@@ -248,11 +248,11 @@ export default class ModelConversionDispatcher {
 	}
 
 	/**
-	 * Fires events for given {@link engine.treeModel.Selection selection} to start selection conversion.
+	 * Fires events for given {@link engine.model.Selection selection} to start selection conversion.
 	 *
-	 * @fires engine.treeController.ModelConversionDispatcher#selection
-	 * @fires engine.treeController.ModelConversionDispatcher#selectionAttribute
-	 * @param {engine.treeModel.Selection} selection Selection to convert.
+	 * @fires engine.conversion.ModelConversionDispatcher#selection
+	 * @fires engine.conversion.ModelConversionDispatcher#selectionAttribute
+	 * @param {engine.model.Selection} selection Selection to convert.
 	 */
 	convertSelection( selection ) {
 		const consumable = this._createSelectionConsumable( selection );
@@ -274,12 +274,12 @@ export default class ModelConversionDispatcher {
 	}
 
 	/**
-	 * Creates {@link engine.treeController.ModelConsumable} with values to consume from given range, assuming that
+	 * Creates {@link engine.conversion.ModelConsumable} with values to consume from given range, assuming that
 	 * given range has just been inserted to the model.
 	 *
 	 * @private
-	 * @param {engine.treeModel.Range} range Inserted range.
-	 * @returns {engine.treeController.ModelConsumable} Values to consume.
+	 * @param {engine.model.Range} range Inserted range.
+	 * @returns {engine.conversion.ModelConsumable} Values to consume.
 	 */
 	_createInsertConsumable( range ) {
 		const consumable = new Consumable();
@@ -298,14 +298,14 @@ export default class ModelConversionDispatcher {
 	}
 
 	/**
-	 * Creates {@link engine.treeController.ModelConsumable} with values to consume from given range, assuming that
+	 * Creates {@link engine.conversion.ModelConsumable} with values to consume from given range, assuming that
 	 * given range has just had it's attributes changed.
 	 *
 	 * @private
 	 * @param {String} type Change type. Possible values: `addAttribute`, `removeAttribute`, `changeAttribute`.
-	 * @param {engine.treeController.Range} range Changed range.
+	 * @param {engine.conversion.Range} range Changed range.
 	 * @param {String} key Attribute key.
-	 * @returns {engine.treeController.ModelConsumable} Values to consume.
+	 * @returns {engine.conversion.ModelConsumable} Values to consume.
 	 */
 	_createAttributeConsumable( type, range, key ) {
 		const consumable = new Consumable();
@@ -320,11 +320,11 @@ export default class ModelConversionDispatcher {
 	}
 
 	/**
-	 * Creates {@link engine.treeController.ModelConsumable} with selection consumable values.
+	 * Creates {@link engine.conversion.ModelConsumable} with selection consumable values.
 	 *
 	 * @private
-	 * @param {engine.treeModel.Selection} selection Selection to create consumable from.
-	 * @returns {engine.treeController.ModelConsumable} Values to consume.
+	 * @param {engine.model.Selection} selection Selection to create consumable from.
+	 * @returns {engine.conversion.ModelConsumable} Values to consume.
 	 */
 	_createSelectionConsumable( selection ) {
 		const consumable = new Consumable();
@@ -342,13 +342,13 @@ export default class ModelConversionDispatcher {
 	 * Tests passed `consumable` to check whether given event can be fired and if so, fires it.
 	 *
 	 * @private
-	 * @fires engine.treeController.ModelConversionDispatcher#insert
-	 * @fires engine.treeController.ModelConversionDispatcher#addAttribute
-	 * @fires engine.treeController.ModelConversionDispatcher#removeAttribute
-	 * @fires engine.treeController.ModelConversionDispatcher#changeAttribute
+	 * @fires engine.conversion.ModelConversionDispatcher#insert
+	 * @fires engine.conversion.ModelConversionDispatcher#addAttribute
+	 * @fires engine.conversion.ModelConversionDispatcher#removeAttribute
+	 * @fires engine.conversion.ModelConversionDispatcher#changeAttribute
 	 * @param {String} type Event type.
 	 * @param {Object} data Event data.
-	 * @param {engine.treeController.ModelConsumable} consumable Values to consume.
+	 * @param {engine.conversion.ModelConsumable} consumable Values to consume.
 	 */
 	_testAndFire( type, data, consumable ) {
 		if ( !consumable.test( data.item, type ) ) {
@@ -378,36 +378,36 @@ export default class ModelConversionDispatcher {
 	 *
 	 * `insert` is a namespace for a class of events. Names of actually called events follow this pattern:
 	 * `insert:<type>:<elementName>`. `type` is either `text` when one or more characters has been inserted or `element`
-	 * when {@link engine.treeModel.Element} has been inserted. If `type` is `element`, `elementName` is added and is
-	 * equal to the {@link engine.treeModel.Element#name name} of inserted element. This way listeners can either
+	 * when {@link engine.model.Element} has been inserted. If `type` is `element`, `elementName` is added and is
+	 * equal to the {@link engine.model.Element#name name} of inserted element. This way listeners can either
 	 * listen to very general `insert` event or, i.e., very specific `insert:paragraph` event, which is fired only for
 	 * model elements with name `paragraph`.
 	 *
-	 * @event engine.treeController.ModelConversionDispatcher.insert
+	 * @event engine.conversion.ModelConversionDispatcher.insert
 	 * @param {Object} data Additional information about the change.
-	 * @param {engine.treeModel.Item} data.item Inserted item.
-	 * @param {engine.treeModel.Range} data.range Range spanning over inserted item.
-	 * @param {engine.treeController.ModelConsumable} consumable Values to consume.
+	 * @param {engine.model.Item} data.item Inserted item.
+	 * @param {engine.model.Range} data.range Range spanning over inserted item.
+	 * @param {engine.conversion.ModelConsumable} consumable Values to consume.
 	 * @param {Object} conversionApi Conversion interface to be used by callback, passed in `ModelConversionDispatcher` constructor.
 	 */
 
 	/**
 	 * Fired for moved nodes.
 	 *
-	 * @event engine.treeController.ModelConversionDispatcher.move
+	 * @event engine.conversion.ModelConversionDispatcher.move
 	 * @param {Object} data Additional information about the change.
-	 * @param {engine.treeModel.Position} data.sourcePosition Position from where the range has been moved.
-	 * @param {engine.treeModel.Range} data.range Moved range (after move).
+	 * @param {engine.model.Position} data.sourcePosition Position from where the range has been moved.
+	 * @param {engine.model.Range} data.range Moved range (after move).
 	 * @param {Object} conversionApi Conversion interface to be used by callback, passed in `ModelConversionDispatcher` constructor.
 	 */
 
 	/**
 	 * Fired for removed nodes.
 	 *
-	 * @event engine.treeController.ModelConversionDispatcher.remove
+	 * @event engine.conversion.ModelConversionDispatcher.remove
 	 * @param {Object} data Additional information about the change.
-	 * @param {engine.treeModel.Position} data.sourcePosition Position from where the range has been removed.
-	 * @param {engine.treeModel.Range} data.range Removed range (in {@link engine.treeModel.Document#graveyard graveyard root}).
+	 * @param {engine.model.Position} data.sourcePosition Position from where the range has been removed.
+	 * @param {engine.model.Range} data.range Removed range (in {@link engine.model.Document#graveyard graveyard root}).
 	 * @param {Object} conversionApi Conversion interface to be used by callback, passed in `ModelConversionDispatcher` constructor.
 	 */
 
@@ -416,17 +416,17 @@ export default class ModelConversionDispatcher {
 	 *
 	 * `addAttribute` is a namespace for a class of events. Names of actually called events follow this pattern:
 	 * `addAttribute:<attributeKey>:<elementName>`. `attributeKey` is the key of added attribute. `elementName` is
-	 * equal to the {@link engine.treeModel.Element#name name} of the element which got the attribute. This way listeners
+	 * equal to the {@link engine.model.Element#name name} of the element which got the attribute. This way listeners
 	 * can either listen to adding certain attribute, i.e. `addAttribute:bold`, or be more specific, i.e. `addAttribute:link:img`.
 	 *
-	 * @event engine.treeController.ModelConversionDispatcher.addAttribute
+	 * @event engine.conversion.ModelConversionDispatcher.addAttribute
 	 * @param {Object} data Additional information about the change.
-	 * @param {engine.treeModel.Item} data.item Changed item.
-	 * @param {engine.treeModel.Range} data.range Range spanning over changed item.
+	 * @param {engine.model.Item} data.item Changed item.
+	 * @param {engine.model.Range} data.range Range spanning over changed item.
 	 * @param {String} data.attributeKey Attribute key.
 	 * @param {null} data.attributeOldValue Attribute value before the change - always `null`. Kept for the sake of unifying events.
 	 * @param {*} data.attributeNewValue New attribute value.
-	 * @param {engine.treeController.ModelConsumable} consumable Values to consume.
+	 * @param {engine.conversion.ModelConsumable} consumable Values to consume.
 	 * @param {Object} conversionApi Conversion interface to be used by callback, passed in `ModelConversionDispatcher` constructor.
 	 */
 
@@ -435,17 +435,17 @@ export default class ModelConversionDispatcher {
 	 *
 	 * `removeAttribute` is a namespace for a class of events. Names of actually called events follow this pattern:
 	 * `removeAttribute:<attributeKey>:<elementName>`. `attributeKey` is the key of removed attribute. `elementName` is
-	 * equal to the {@link engine.treeModel.Element#name name} of the element which got the attribute removed. This way listeners
+	 * equal to the {@link engine.model.Element#name name} of the element which got the attribute removed. This way listeners
 	 * can either listen to removing certain attribute, i.e. `removeAttribute:bold`, or be more specific, i.e. `removeAttribute:link:img`.
 	 *
-	 * @event engine.treeController.ModelConversionDispatcher.removeAttribute
+	 * @event engine.conversion.ModelConversionDispatcher.removeAttribute
 	 * @param {Object} data Additional information about the change.
-	 * @param {engine.treeModel.Item} data.item Changed item.
-	 * @param {engine.treeModel.Range} data.range Range spanning over changed item.
+	 * @param {engine.model.Item} data.item Changed item.
+	 * @param {engine.model.Range} data.range Range spanning over changed item.
 	 * @param {String} data.attributeKey Attribute key.
 	 * @param {*} data.attributeOldValue Attribute value before it was removed.
 	 * @param {null} data.attributeNewValue New attribute value - always `null`. Kept for the sake of unifying events.
-	 * @param {engine.treeController.ModelConsumable} consumable Values to consume.
+	 * @param {engine.conversion.ModelConsumable} consumable Values to consume.
 	 * @param {Object} conversionApi Conversion interface to be used by callback, passed in `ModelConversionDispatcher` constructor.
 	 */
 
@@ -454,42 +454,42 @@ export default class ModelConversionDispatcher {
 	 *
 	 * `changeAttribute` is a namespace for a class of events. Names of actually called events follow this pattern:
 	 * `changeAttribute:<attributeKey>:<elementName>`. `attributeKey` is the key of changed attribute. `elementName` is
-	 * equal to the {@link engine.treeModel.Element#name name} of the element which got the attribute changed. This way listeners
+	 * equal to the {@link engine.model.Element#name name} of the element which got the attribute changed. This way listeners
 	 * can either listen to changing certain attribute, i.e. `changeAttribute:link`, or be more specific, i.e. `changeAttribute:link:img`.
 	 *
-	 * @event engine.treeController.ModelConversionDispatcher.changeAttribute
+	 * @event engine.conversion.ModelConversionDispatcher.changeAttribute
 	 * @param {Object} data Additional information about the change.
-	 * @param {engine.treeModel.Item} data.item Changed item.
-	 * @param {engine.treeModel.Range} data.range Range spanning over changed item.
+	 * @param {engine.model.Item} data.item Changed item.
+	 * @param {engine.model.Range} data.range Range spanning over changed item.
 	 * @param {String} data.attributeKey Attribute key.
 	 * @param {*} data.attributeOldValue Attribute value before the change.
 	 * @param {*} data.attributeNewValue New attribute value.
-	 * @param {engine.treeController.ModelConsumable} consumable Values to consume.
+	 * @param {engine.conversion.ModelConsumable} consumable Values to consume.
 	 * @param {Object} conversionApi Conversion interface to be used by callback, passed in `ModelConversionDispatcher` constructor.
 	 */
 
 	/**
-	 * Fired for {@link engine.treeModel.Selection selection} changes.
+	 * Fired for {@link engine.model.Selection selection} changes.
 	 *
-	 * @event engine.treeController.ModelConversionDispatcher.selection
-	 * @param {engine.treeModel.Selection} selection `Selection` instance that is converted.
-	 * @param {engine.treeController.ModelConsumable} consumable Values to consume.
+	 * @event engine.conversion.ModelConversionDispatcher.selection
+	 * @param {engine.model.Selection} selection `Selection` instance that is converted.
+	 * @param {engine.conversion.ModelConsumable} consumable Values to consume.
 	 * @param {Object} conversionApi Conversion interface to be used by callback, passed in `ModelConversionDispatcher` constructor.
 	 */
 
 	/**
-	 * Fired for {@link engine.treeModel.Selection selection} attributes changes.
+	 * Fired for {@link engine.model.Selection selection} attributes changes.
 	 *
 	 * `selectionAttribute` is a namespace for a class of events. Names of actually called events follow this pattern:
 	 * `selectionAttribute:<attributeKey>`. `attributeKey` is the key of selection attribute. This way listen can listen to
 	 * certain attribute, i.e. `addAttribute:bold`.
 	 *
-	 * @event engine.treeController.ModelConversionDispatcher.selectionAttribute
+	 * @event engine.conversion.ModelConversionDispatcher.selectionAttribute
 	 * @param {Object} data Additional information about the change.
-	 * @param {engine.treeModel.Selection} data.selection Selection that is converted.
+	 * @param {engine.model.Selection} data.selection Selection that is converted.
 	 * @param {String} data.attributeKey Key of changed attribute.
 	 * @param {*} data.attributeValue Value of changed attribute.
-	 * @param {engine.treeController.ModelConsumable} consumable Values to consume.
+	 * @param {engine.conversion.ModelConsumable} consumable Values to consume.
 	 * @param {Object} conversionApi Conversion interface to be used by callback, passed in `ModelConversionDispatcher` constructor.
 	 */
 }

+ 1 - 1
packages/ckeditor5-engine/src/treecontroller/treecontroller.jsdoc

@@ -4,5 +4,5 @@
  */
 
 /**
- * @namespace engine.treeController
+ * @namespace engine.conversion
  */

+ 32 - 32
packages/ckeditor5-engine/src/treecontroller/view-converter-builder.js

@@ -5,8 +5,8 @@
 
 'use strict';
 
-import Matcher from '../treeview/matcher.js';
-import ModelElement from '../treemodel/element.js';
+import Matcher from '../view/matcher.js';
+import ModelElement from '../model/element.js';
 import isIterable from '../../utils/isiterable.js';
 
 /**
@@ -15,10 +15,10 @@ import isIterable from '../../utils/isiterable.js';
  * HTML content to the editor. Then, converters are used to translate this structure, possibly removing unknown/incorrect
  * nodes, and add it to the model. Also multiple, different elements might be translated into the same thing in the
  * model, i.e. `<b>` and `<strong>` elements might be converted to `bold` attribute (even though `bold` attribute will
- * be then converted only to `<strong>` tag). Instances of this class are created by {@link engine.treeController.BuildViewConverterFor}.
+ * be then converted only to `<strong>` tag). Instances of this class are created by {@link engine.conversion.BuildViewConverterFor}.
  *
- * If you need more complex converters, see {@link engine.treeController.ViewConversionDispatcher},
- * {@link engine.treeController.viewToModel}, {@link engine.treeController.ViewConsumable}.
+ * If you need more complex converters, see {@link engine.conversion.ViewConversionDispatcher},
+ * {@link engine.conversion.viewToModel}, {@link engine.conversion.ViewConsumable}.
  *
  * Using this API it is possible to create various kind of converters:
  *
@@ -43,7 +43,7 @@ import isIterable from '../../utils/isiterable.js';
  *			.fromElement( 'b' ).fromElement( 'strong' ).fromAttribute( 'style', { 'font-weight': 'bold' } )
  *			.toAttributes( { bold: true } );
  *
- * 5. View {@link engine.treeView.Matcher view element matcher instance} or {@link engine.treeView.Matcher#add matcher pattern}
+ * 5. View {@link engine.view.Matcher view element matcher instance} or {@link engine.view.Matcher#add matcher pattern}
  * to model element or attribute:
  *
  *		const matcher = new ViewMatcher();
@@ -52,43 +52,43 @@ import isIterable from '../../utils/isiterable.js';
  *
  *		BuildViewConverterFor( dispatcher ).from( { name: 'span', class: 'bold' } ).toAttributes( { bold: true } );
  *
- * Note, that converters built using `ViewConverterBuilder` automatically check {@link engine.treeModel.Schema schema}
+ * Note, that converters built using `ViewConverterBuilder` automatically check {@link engine.model.Schema schema}
  * if created model structure is valid. If given conversion would be invalid according to schema, it is ignored.
  *
- * It is possible to provide creator functions as parameters for {@link engine.treeController.ViewConverterBuilder#toElement}
- * and {@link engine.treeController.ViewConverterBuilder#toAttributes} methods. See their descriptions to learn more.
+ * It is possible to provide creator functions as parameters for {@link engine.conversion.ViewConverterBuilder#toElement}
+ * and {@link engine.conversion.ViewConverterBuilder#toAttributes} methods. See their descriptions to learn more.
  *
- * By default, converter will {@link engine.treeController.ViewConsumable#consume consume} every value specified in
+ * By default, converter will {@link engine.conversion.ViewConsumable#consume consume} every value specified in
  * given `from...` query, i.e. `.from( { name: 'span', class: 'bold' } )` will make converter consume both `span` name
- * and `bold` class. It is possible to change this behavior using {@link engine.treeController.ViewConverterBuilder#consuming consuming}
+ * and `bold` class. It is possible to change this behavior using {@link engine.conversion.ViewConverterBuilder#consuming consuming}
  * modifier. The modifier alters the last `fromXXX` query used before it. To learn more about consuming values,
- * see {@link engine.treeController.ViewConsumable}.
+ * see {@link engine.conversion.ViewConsumable}.
  *
- * It is also possible to {@link engine.treeController.ViewConverterBuilder#withPriority change default priority}
+ * It is also possible to {@link engine.conversion.ViewConverterBuilder#withPriority change default priority}
  * of created converters to decide which converter should be fired earlier and which later. This is useful if you provide
  * a general converter but want to provide different converter for a specific-case (i.e. given view element is converted
  * always to given model element, but if it has given class it is converter to other model element). For this,
- * use {@link engine.treeController.ViewConverterBuilder#withPriority withPriority} modifier. The modifier alters
+ * use {@link engine.conversion.ViewConverterBuilder#withPriority withPriority} modifier. The modifier alters
  * the last `from...` query used before it.
  *
  * Note that `to...` methods are "terminators", which means that should be the last one used in building converter.
  *
- * You can use {@link engine.treeController.ModelConverterBuilder} to create "opposite" converters - from model to view.
+ * You can use {@link engine.conversion.ModelConverterBuilder} to create "opposite" converters - from model to view.
  *
- * @memberOf engine.treeController
+ * @memberOf engine.conversion
  */
 class ViewConverterBuilder {
 	/**
 	 * Creates `ViewConverterBuilder` with given `dispatchers` registered to it.
 	 *
-	 * @param {Array.<engine.treeController.ViewConversionDispatcher>} dispatchers Dispatchers to which converters will
+	 * @param {Array.<engine.conversion.ViewConversionDispatcher>} dispatchers Dispatchers to which converters will
 	 * be attached.
 	 */
 	constructor( dispatchers ) {
 		/**
 		 * Dispatchers to which converters will be attached.
 		 *
-		 * @type {Array.<engine.treeController.ViewConversionDispatcher>}
+		 * @type {Array.<engine.conversion.ViewConversionDispatcher>}
 		 * @private
 		 */
 		this._dispatchers = dispatchers;
@@ -109,7 +109,7 @@ class ViewConverterBuilder {
 	 *
 	 * @chainable
 	 * @param {String} elementName View element name.
-	 * @returns {engine.treeController.ViewConverterBuilder}
+	 * @returns {engine.conversion.ViewConverterBuilder}
 	 */
 	fromElement( elementName ) {
 		return this.from( { name: elementName } );
@@ -123,7 +123,7 @@ class ViewConverterBuilder {
 	 * @chainable
 	 * @param {String|RegExp} key View attribute key.
 	 * @param {String|RegExp} [value] View attribute value.
-	 * @returns {engine.treeController.ViewConverterBuilder}
+	 * @returns {engine.conversion.ViewConverterBuilder}
 	 */
 	fromAttribute( key, value = /.*/ ) {
 		let pattern = {};
@@ -133,7 +133,7 @@ class ViewConverterBuilder {
 	}
 
 	/**
-	 * Registers what view pattern should be converted. The method accepts either {@link engine.treeView.Matcher view matcher}
+	 * Registers what view pattern should be converted. The method accepts either {@link engine.view.Matcher view matcher}
 	 * or view matcher pattern.
 	 *
 	 *		const matcher = new ViewMatcher();
@@ -143,8 +143,8 @@ class ViewConverterBuilder {
 	 *		BuildViewConverterFor( dispatcher ).from( { name: 'span', class: 'bold' } ).toAttributes( { bold: true } );
 	 *
 	 * @chainable
-	 * @param {Object|engine.treeView.Matcher} matcher View matcher or view matcher pattern.
-	 * @returns {engine.treeController.ViewConverterBuilder}
+	 * @param {Object|engine.view.Matcher} matcher View matcher or view matcher pattern.
+	 * @returns {engine.conversion.ViewConverterBuilder}
 	 */
 	from( matcher ) {
 		if ( !( matcher instanceof Matcher ) ) {
@@ -161,7 +161,7 @@ class ViewConverterBuilder {
 	}
 
 	/**
-	 * Modifies which consumable values will be {@link engine.treeController.ViewConsumable#consume consumed} by built converter.
+	 * Modifies which consumable values will be {@link engine.conversion.ViewConsumable#consume consumed} by built converter.
 	 * It modifies the last `from...` query. Can be used after each `from...` query in given chain. Useful for providing
 	 * more specific matches.
 	 *
@@ -183,10 +183,10 @@ class ViewConverterBuilder {
 	 * conversion conditions (like in second example). So, the view element, to be converter, has to match query of
 	 * `from...` method and then have to have enough consumable values to consume.
 	 *
-	 * @see engine.treeController.ViewConsumable
+	 * @see engine.conversion.ViewConsumable
 	 * @chainable
 	 * @param {Object} consume Values to consume.
-	 * @returns {engine.treeController.ViewConverterBuilder}
+	 * @returns {engine.conversion.ViewConverterBuilder}
 	 */
 	consuming( consume ) {
 		let lastFrom = this._from[ this._from.length - 1 ];
@@ -214,7 +214,7 @@ class ViewConverterBuilder {
 	 *
 	 * @chainable
 	 * @param {Number} priority Converter priority.
-	 * @returns {engine.treeController.ViewConverterBuilder}
+	 * @returns {engine.conversion.ViewConverterBuilder}
 	 */
 	withPriority( priority ) {
 		let lastFrom = this._from[ this._from.length - 1 ];
@@ -370,7 +370,7 @@ class ViewConverterBuilder {
 	}
 }
 
-// Helper function that sets given attributes on given `engine.treeModel.Item` or `engine.treeModel.DocumentFragment`.
+// Helper function that sets given attributes on given `engine.model.Item` or `engine.model.DocumentFragment`.
 function setAttributeOn( toChange, attribute, data, conversionApi ) {
 	if ( isIterable( toChange ) ) {
 		for ( let node of toChange ) {
@@ -397,11 +397,11 @@ function setAttributeOn( toChange, attribute, data, conversionApi ) {
 /**
  * Entry point for view-to-model converters builder. This chainable API makes it easy to create basic, most common
  * view-to-model converters and attach them to provided dispatchers. The method returns an instance of
- * {@link engine.treeController.ViewConverterBuilder}.
+ * {@link engine.conversion.ViewConverterBuilder}.
  *
- * @external engine.treeController.BuildViewConverterFor
- * @memberOf engine.treeController
- * @param {...engine.treeController.ViewConversionDispatcher} dispatchers One or more dispatchers to which
+ * @external engine.conversion.BuildViewConverterFor
+ * @memberOf engine.conversion
+ * @param {...engine.conversion.ViewConversionDispatcher} dispatchers One or more dispatchers to which
  * the built converter will be attached.
  */
 export default function BuildViewConverterFor( ...dispatchers ) {

+ 17 - 17
packages/ckeditor5-engine/src/treecontroller/view-to-model-converters.js

@@ -5,30 +5,30 @@
 
 'use strict';
 
-import ModelDocumentFragment from '../treemodel/documentfragment.js';
-import ModelText from '../treemodel/text.js';
+import ModelDocumentFragment from '../model/documentfragment.js';
+import ModelText from '../model/text.js';
 
 /**
- * Contains {@link engine.treeView view} to {@link engine.treeModel model} converters for
- * {@link engine.treeController.ViewConversionDispatcher}.
+ * Contains {@link engine.view view} to {@link engine.model model} converters for
+ * {@link engine.conversion.ViewConversionDispatcher}.
  *
- * @namespace engine.treeController.viewToModel
+ * @namespace engine.conversion.viewToModel
  */
 
 /**
- * Function factory, creates a converter that converts {@link engine.treeView.DocumentFragment view document fragment} or
- * all children of {@link engine.treeView.Element} into {@link engine.treeModel.DocumentFragment model document fragment}.
+ * Function factory, creates a converter that converts {@link engine.view.DocumentFragment view document fragment} or
+ * all children of {@link engine.view.Element} into {@link engine.model.DocumentFragment model document fragment}.
  * This is the "entry-point" converter for view to model conversion. This converter starts the conversion of all "children"
- * of passed view document fragment. Those "children" {@link engine.treeView.Node view nodes} are then handled by other converters.
+ * of passed view document fragment. Those "children" {@link engine.view.Node view nodes} are then handled by other converters.
  *
  * This also a "default", last resort converter for all view elements that has not been converted by other converters.
  * When a view element is converted to the model and it does not have it's converter specified, all of that elements
- * children will be converted to {@link engine.treeModel.DocumentFragment} and returned.
+ * children will be converted to {@link engine.model.DocumentFragment} and returned.
  *
- * @external engine.treeController.viewToModel
- * @function engine.treeController.viewToModel.convertToModelFragment
- * @returns {Function} Universal converter for view {@link engine.treeView.DocumentFragment fragments} and
- * {@link engine.treeView.Element elements} that returns {@link engine.treeModel.DocumentFragment model fragment} with
+ * @external engine.conversion.viewToModel
+ * @function engine.conversion.viewToModel.convertToModelFragment
+ * @returns {Function} Universal converter for view {@link engine.view.DocumentFragment fragments} and
+ * {@link engine.view.Element elements} that returns {@link engine.model.DocumentFragment model fragment} with
  * children of converted view item.
  */
 export function convertToModelFragment() {
@@ -43,11 +43,11 @@ export function convertToModelFragment() {
 }
 
 /**
- * Function factory, creates a converter that converts {@link engine.treeView.Text} to {@link engine.treeModel.Text}.
+ * Function factory, creates a converter that converts {@link engine.view.Text} to {@link engine.model.Text}.
  *
- * @external engine.treeController.viewToModel
- * @function engine.treeController.viewToModel.convertText
- * @returns {Function} {@link engine.treeView.Text View text} converter.
+ * @external engine.conversion.viewToModel
+ * @function engine.conversion.viewToModel.convertText
+ * @returns {Function} {@link engine.view.Text View text} converter.
  */
 export function convertText() {
 	return ( evt, data, consumable, conversionApi ) => {

+ 45 - 45
packages/ckeditor5-engine/src/treecontroller/viewconsumable.js

@@ -7,16 +7,16 @@
 
 import isArray from '../../utils/lib/lodash/isArray.js';
 import CKEditorError from '../../utils/ckeditorerror.js';
-import ViewElement from '../treeview/element.js';
-import ViewText from '../treeview/text.js';
-import ViewDocumentFragment from '../treeview/documentfragment.js';
+import ViewElement from '../view/element.js';
+import ViewText from '../view/text.js';
+import ViewDocumentFragment from '../view/documentfragment.js';
 
 /**
- * This is a private helper-class for {@link engine.treeController.ViewConsumable}.
- * It represents and manipulates consumable parts of a single {@link engine.treeView.Element}.
+ * This is a private helper-class for {@link engine.conversion.ViewConsumable}.
+ * It represents and manipulates consumable parts of a single {@link engine.view.Element}.
  *
  * @private
- * @memberOf engine.treeController
+ * @memberOf engine.conversion
  */
 class ViewElementConsumables {
 
@@ -28,7 +28,7 @@ class ViewElementConsumables {
 		 * Flag indicating if name of the element can be consumed.
 		 *
 		 * @private
-		 * @member {Boolean} engine.treeController.ViewElementConsumables#_canConsumeName
+		 * @member {Boolean} engine.conversion.ViewElementConsumables#_canConsumeName
 		 */
 		this._canConsumeName = null;
 
@@ -36,7 +36,7 @@ class ViewElementConsumables {
 		 * Contains maps of element's consumables: attributes, classes and styles.
 		 *
 		 * @private
-		 * @member {Object} engine.treeController.ViewElementConsumables#_consumables
+		 * @member {Object} engine.conversion.ViewElementConsumables#_consumables
 		 */
 		this._consumables = {
 			attribute: new Map(),
@@ -46,7 +46,7 @@ class ViewElementConsumables {
 	}
 
 	/**
-	 * Adds consumable parts of the {@link engine.treeView.Element view element}.
+	 * Adds consumable parts of the {@link engine.view.Element view element}.
 	 * Element's name itself can be marked to be consumed (when element's name is consumed its attributes, classes and
 	 * styles still could be consumed):
 	 *
@@ -79,7 +79,7 @@ class ViewElementConsumables {
 	}
 
 	/**
-	 * Tests if parts of the {@link engine.treeView.Element view element} can be consumed.
+	 * Tests if parts of the {@link engine.view.Element view element} can be consumed.
 	 *
 	 * Element's name can be tested:
 	 *
@@ -119,7 +119,7 @@ class ViewElementConsumables {
 	}
 
 	/**
-	 * Consumes parts of {@link engine.treeView.Element view element}. This function does not check if consumable item
+	 * Consumes parts of {@link engine.view.Element view element}. This function does not check if consumable item
 	 * is already consumed - it consumes all consumable items provided.
 	 * Element's name can be consumed:
 	 *
@@ -149,7 +149,7 @@ class ViewElementConsumables {
 	}
 
 	/**
-	 * Revert already consumed parts of {@link engine.treeView.Element view Element}, so they can be consumed once again.
+	 * Revert already consumed parts of {@link engine.view.Element view Element}, so they can be consumed once again.
 	 * Element's name can be reverted:
 	 *
 	 *		consumables.revert( { name: true } );
@@ -290,14 +290,14 @@ class ViewElementConsumables {
 }
 
 /**
- * Class used for handling consumption of view {@link engine.treeView.Element elements},
- * {@link engine.treeView.Text text nodes} and {@link engine.treeView.DocumentFragment document fragments}.
+ * Class used for handling consumption of view {@link engine.view.Element elements},
+ * {@link engine.view.Text text nodes} and {@link engine.view.DocumentFragment document fragments}.
  * Element's name and its parts (attributes, classes and styles) can be consumed separately. Consuming an element's name
  * does not consume its attributes, classes and styles.
- * To add items for consumption use {@link engine.treeController.ViewConsumable#add add method}.
- * To test items use {@link engine.treeController.ViewConsumable#test test method}.
- * To consume items use {@link engine.treeController.ViewConsumable#consume consume method}.
- * To revert already consumed items use {@link engine.treeController.ViewConsumable#revert revert method}.
+ * To add items for consumption use {@link engine.conversion.ViewConsumable#add add method}.
+ * To test items use {@link engine.conversion.ViewConsumable#test test method}.
+ * To consume items use {@link engine.conversion.ViewConsumable#consume consume method}.
+ * To revert already consumed items use {@link engine.conversion.ViewConsumable#revert revert method}.
  *
  *		viewConsumable.add( element, { name: true } ); // Adds element's name as ready to be consumed.
  *		viewConsumable.add( textNode ); // Adds text node for consumption.
@@ -312,7 +312,7 @@ class ViewElementConsumables {
  *		viewConsumable.revert( textNode ); // Revert already consumed text node.
  *		viewConsumable.revert( docFragment ); // Revert already consumed document fragment.
  *
- * @memberOf engine.treeController
+ * @memberOf engine.conversion
  */
 export default class ViewConsumable {
 
@@ -321,20 +321,20 @@ export default class ViewConsumable {
 	 */
 	constructor() {
 		/**
-		 * Map of consumable elements. If {@link engine.treeView.Element element} is used as a key,
-		 * {@link engine.treeController.ViewElementConsumables ViewElementConsumables} instance is stored as value.
-		 * For {@link engine.treeView.Text text nodes} and {@link engine.treeView.DocumentFragment document fragments}
+		 * Map of consumable elements. If {@link engine.view.Element element} is used as a key,
+		 * {@link engine.conversion.ViewElementConsumables ViewElementConsumables} instance is stored as value.
+		 * For {@link engine.view.Text text nodes} and {@link engine.view.DocumentFragment document fragments}
 		 * boolean value is stored as value.
 		 *
 		 * @protected
-		 * @member {Map.<engine.treeController.ViewElementConsumables|Boolean>} engine.treeController.ViewConsumable#_consumables
+		 * @member {Map.<engine.conversion.ViewElementConsumables|Boolean>} engine.conversion.ViewConsumable#_consumables
 		*/
 		this._consumables = new Map();
 	}
 
 	/**
-	 * Adds {@link engine.treeView.Element view element}, {@link engine.treeView.Text text node} or
-	 * {@link engine.treeView.DocumentFragment document fragment} as ready to be consumed.
+	 * Adds {@link engine.view.Element view element}, {@link engine.view.Text text node} or
+	 * {@link engine.view.DocumentFragment document fragment} as ready to be consumed.
 	 *
 	 *		viewConsumable.add( p, { name: true } ); // Adds element's name to consume.
 	 *		viewConsumable.add( p, { attribute: 'name' } ); // Adds element's attribute.
@@ -351,8 +351,8 @@ export default class ViewConsumable {
 	 *		viewConsumable.add( p, { attribute: 'style' } ); // This call will throw an exception.
 	 *		viewConsumable.add( p, { style: 'color' } ); // This is properly handled style.
 	 *
-	 * @param {engine.treeView.Element|engine.treeView.Text|engine.treeView.DocumentFragment} element
-	 * @param {Object} [consumables] Used only if first parameter is {@link engine.treeView.Element view element} instance.
+	 * @param {engine.view.Element|engine.view.Text|engine.view.DocumentFragment} element
+	 * @param {Object} [consumables] Used only if first parameter is {@link engine.view.Element view element} instance.
 	 * @param {Boolean} consumables.name If set to true element's name will be included.
 	 * @param {String|Array.<String>} consumables.attribute Attribute name or array of attribute names.
 	 * @param {String|Array.<String>} consumables.class Class name or array of class names.
@@ -380,8 +380,8 @@ export default class ViewConsumable {
 	}
 
 	/**
-	 * Tests if {@link engine.treeView.Element view element}, {@link engine.treeView.Text text node} or
-	 * {@link engine.treeView.DocumentFragment document fragment} can be consumed.
+	 * Tests if {@link engine.view.Element view element}, {@link engine.view.Text text node} or
+	 * {@link engine.view.DocumentFragment document fragment} can be consumed.
 	 * It returns `true` when all items included in method's call can be consumed. Returns `false` when
 	 * first already consumed item is found and `null` when first non-consumable item is found.
 	 *
@@ -399,8 +399,8 @@ export default class ViewConsumable {
 	 *		viewConsumable.test( p, { attribute: 'class' } ); // Tests if all added classes can be consumed.
 	 *		viewConsumable.test( p, { attribute: 'style' } ); // Tests if all added styles can be consumed.
 	 *
-	 * @param {engine.treeView.Element|engine.treeView.Text|engine.treeView.DocumentFragment} element
-	 * @param {Object} [consumables] Used only if first parameter is {@link engine.treeView.Element view element} instance.
+	 * @param {engine.view.Element|engine.view.Text|engine.view.DocumentFragment} element
+	 * @param {Object} [consumables] Used only if first parameter is {@link engine.view.Element view element} instance.
 	 * @param {Boolean} consumables.name If set to true element's name will be included.
 	 * @param {String|Array.<String>} consumables.attribute Attribute name or array of attribute names.
 	 * @param {String|Array.<String>} consumables.class Class name or array of class names.
@@ -425,8 +425,8 @@ export default class ViewConsumable {
 	}
 
 	/**
-	 * Consumes {@link engine.treeView.Element view element}, {@link engine.treeView.Text text node} or
-	 * {@link engine.treeView.DocumentFragment document fragment}.
+	 * Consumes {@link engine.view.Element view element}, {@link engine.view.Text text node} or
+	 * {@link engine.view.DocumentFragment document fragment}.
 	 * It returns `true` when all items included in method's call can be consumed, otherwise returns `false`.
 	 *
 	 *		viewConsumable.consume( p, { name: true } ); // Consumes element's name.
@@ -443,8 +443,8 @@ export default class ViewConsumable {
 	 *		viewConsumable.consume( p, { attribute: 'class' } ); // Consume only if all added classes can be consumed.
 	 *		viewConsumable.consume( p, { attribute: 'style' } ); // Consume only if all added styles can be consumed.
 	 *
-	 * @param {engine.treeView.Element|engine.treeView.Text|engine.treeView.DocumentFragment} element
-	 * @param {Object} [consumables] Used only if first parameter is {@link engine.treeView.Element view element} instance.
+	 * @param {engine.view.Element|engine.view.Text|engine.view.DocumentFragment} element
+	 * @param {Object} [consumables] Used only if first parameter is {@link engine.view.Element view element} instance.
 	 * @param {Boolean} consumables.name If set to true element's name will be included.
 	 * @param {String|Array.<String>} consumables.attribute Attribute name or array of attribute names.
 	 * @param {String|Array.<String>} consumables.class Class name or array of class names.
@@ -469,8 +469,8 @@ export default class ViewConsumable {
 	}
 
 	/**
-	 * Reverts {@link engine.treeView.Element view element}, {@link engine.treeView.Text text node} or
-	 * {@link engine.treeView.DocumentFragment document fragment} so they can be consumed once again.
+	 * Reverts {@link engine.view.Element view element}, {@link engine.view.Text text node} or
+	 * {@link engine.view.DocumentFragment document fragment} so they can be consumed once again.
 	 * Method does not revert items that were never previously added for consumption, even if they are included in
 	 * method's call.
 	 *
@@ -489,8 +489,8 @@ export default class ViewConsumable {
 	 *		viewConsumable.revert( p, { attribute: 'class' } ); // Reverts all classes added for consumption.
 	 *		viewConsumable.revert( p, { attribute: 'style' } ); // Reverts all styles added for consumption.
 	 *
-	 * @param {engine.treeView.Element|engine.treeView.Text|engine.treeView.DocumentFragment} element
-	 * @param {Object} [consumables] Used only if first parameter is {@link engine.treeView.Element view element} instance.
+	 * @param {engine.view.Element|engine.view.Text|engine.view.DocumentFragment} element
+	 * @param {Object} [consumables] Used only if first parameter is {@link engine.view.Element view element} instance.
 	 * @param {Boolean} consumables.name If set to true element's name will be included.
 	 * @param {String|Array.<String>} consumables.attribute Attribute name or array of attribute names.
 	 * @param {String|Array.<String>} consumables.class Class name or array of class names.
@@ -511,11 +511,11 @@ export default class ViewConsumable {
 	}
 
 	/**
-	 * Creates consumable object from {@link engine.treeView.Element view element}. Consumable object will include
+	 * Creates consumable object from {@link engine.view.Element view element}. Consumable object will include
 	 * element's name and all its attributes, classes and styles.
 	 *
 	 * @static
-	 * @param {engine.treeView.Element} element
+	 * @param {engine.view.Element} element
 	 * @returns {Object} consumables
 	 */
 	static consumablesFromElement( element ) {
@@ -553,14 +553,14 @@ export default class ViewConsumable {
 	}
 
 	/**
-	 * Creates {@link engine.treeController.ViewConsumable ViewConsumable} instance from
-	 * {@link engine.treeView.Element element} or {@link engine.treeView.DocumentFragment document fragment}.
+	 * Creates {@link engine.conversion.ViewConsumable ViewConsumable} instance from
+	 * {@link engine.view.Element element} or {@link engine.view.DocumentFragment document fragment}.
 	 * Instance will contain all elements, child nodes, attributes, styles and classes added for consumption.
 	 *
 	 * @static
-	 * @param {engine.treeView.Element|engine.treeView.DocumentFragment} from View element or document fragment
+	 * @param {engine.view.Element|engine.view.DocumentFragment} from View element or document fragment
 	 * from which `ViewConsumable` will be created.
-	 * @param {engine.treeController.ViewConsumable} [instance] If provided, given `ViewConsumable` instance will be used
+	 * @param {engine.conversion.ViewConsumable} [instance] If provided, given `ViewConsumable` instance will be used
 	 * to add all consumables. It will be returned instead of a new instance.
 	 */
 	static createFrom( from, instance ) {

+ 61 - 61
packages/ckeditor5-engine/src/treecontroller/viewconversiondispatcher.js

@@ -6,35 +6,35 @@
 'use strict';
 
 import ViewConsumable from './viewconsumable.js';
-import ViewElement from '../treeview/element.js';
-import ViewText from '../treeview/text.js';
+import ViewElement from '../view/element.js';
+import ViewText from '../view/text.js';
 import EmitterMixin from '../../utils/emittermixin.js';
 import mix from '../../utils/mix.js';
 import extend from '../../utils/lib/lodash/extend.js';
 
 /**
- * `ViewConversionDispatcher` is a central point of {@link engine.treeView view} conversion, which is a process of
- * converting given {@link engine.treeView.DocumentFragment view document fragment} or {@link engine.treeView.Element}
- * into another structure. In default application, {@link engine.treeView view} is converted to {@link engine.treeModel}.
+ * `ViewConversionDispatcher` is a central point of {@link engine.view view} conversion, which is a process of
+ * converting given {@link engine.view.DocumentFragment view document fragment} or {@link engine.view.Element}
+ * into another structure. In default application, {@link engine.view view} is converted to {@link engine.model}.
  *
- * During conversion process, for all {@link engine.treeView.Node view nodes} from the converted view document fragment,
+ * During conversion process, for all {@link engine.view.Node view nodes} from the converted view document fragment,
  * `ViewConversionDispatcher` fires corresponding events. Special callbacks called "converters" should listen to
  * `ViewConversionDispatcher` for those events.
  *
  * Each callback, as a first argument, is passed a special object `data` that has `input` and `output` properties.
- * `input` property contains {@link engine.treeView.Node view node} or {@link engine.treeView.DocumentFragment view document fragment}
+ * `input` property contains {@link engine.view.Node view node} or {@link engine.view.DocumentFragment view document fragment}
  * that is converted at the moment and might be handled by the callback. `output` property should be used to save the result
  * of conversion. Keep in mind that the `data` parameter is customizable and may contain other values - see
- * {@link engine.treeController.ViewConversionDispatcher#convert}. It is also shared by reference by all callbacks
+ * {@link engine.conversion.ViewConversionDispatcher#convert}. It is also shared by reference by all callbacks
  * listening to given event. **Note**: in view to model conversion - `data` contains `context` property that is an array
- * of {@link engine.treeModel.Element model elements}. These are model elements that will be the parent of currently
+ * of {@link engine.model.Element model elements}. These are model elements that will be the parent of currently
  * converted view item. `context` property is used in examples below.
  *
- * The second parameter passed to a callback is an instance of {@link engine.treeController.ViewConsumable}. It stores
+ * The second parameter passed to a callback is an instance of {@link engine.conversion.ViewConsumable}. It stores
  * information about what parts of processed view item are still waiting to be handled. After a piece of view item
- * was converted, appropriate consumable value should be {@link engine.treeController.ViewConsumable#consume consumed}.
+ * was converted, appropriate consumable value should be {@link engine.conversion.ViewConsumable#consume consumed}.
  *
- * The third parameter passed to a callback is an instance of {@link engine.treeController.ViewConversionDispatcher}
+ * The third parameter passed to a callback is an instance of {@link engine.conversion.ViewConversionDispatcher}
  * which provides additional tools for converters.
  *
  * Examples of providing callbacks for `ViewConversionDispatcher`:
@@ -85,22 +85,22 @@ import extend from '../../utils/lib/lodash/extend.js';
  *		// is going to be appended directly to a '$root' element, use that in `context`.
  *		viewDispatcher.convert( viewDocumentFragment, { context: [ '$root' ] } );
  *
- * Before each conversion process, `ViewConversionDispatcher` fires {@link engine.treeController.ViewConversionDispatcher.viewCleanup}
+ * Before each conversion process, `ViewConversionDispatcher` fires {@link engine.conversion.ViewConversionDispatcher.viewCleanup}
  * event which can be used to prepare tree view for conversion.
  *
  * @mixes utils.EmitterMixin
- * @fires engine.treeController.ViewConversionDispatcher.viewCleanup
- * @fires engine.treeController.ViewConversionDispatcher.element
- * @fires engine.treeController.ViewConversionDispatcher.text
- * @fires engine.treeController.ViewConversionDispatcher.documentFragment
+ * @fires engine.conversion.ViewConversionDispatcher.viewCleanup
+ * @fires engine.conversion.ViewConversionDispatcher.element
+ * @fires engine.conversion.ViewConversionDispatcher.text
+ * @fires engine.conversion.ViewConversionDispatcher.documentFragment
  *
- * @memberOf engine.treeController
+ * @memberOf engine.conversion
  */
 export default class ViewConversionDispatcher {
 	/**
 	 * Creates a `ViewConversionDispatcher` that operates using passed API.
 	 *
-	 * @see engine.treeController.ViewConversionApi
+	 * @see engine.conversion.ViewConversionApi
 	 * @param {Object} [conversionApi] Additional properties for interface that will be passed to events fired
 	 * by `ViewConversionDispatcher`.
 	 */
@@ -108,7 +108,7 @@ export default class ViewConversionDispatcher {
 		/**
 		 * Interface passed by dispatcher to the events callbacks.
 		 *
-		 * @member {engine.treeController.ViewConversionApi} engine.treeController.ViewConversionDispatcher#conversionApi
+		 * @member {engine.conversion.ViewConversionApi} engine.conversion.ViewConversionDispatcher#conversionApi
 		 */
 		this.conversionApi = extend( {}, conversionApi );
 
@@ -121,13 +121,13 @@ export default class ViewConversionDispatcher {
 	/**
 	 * Starts the conversion process. The entry point for the conversion.
 	 *
-	 * @fires engine.treeController.ViewConversionDispatcher.element
-	 * @fires engine.treeController.ViewConversionDispatcher.text
-	 * @fires engine.treeController.ViewConversionDispatcher.documentFragment
-	 * @param {engine.treeView.DocumentFragment|engine.treeView.Element} viewItem Part of the view to be converted.
+	 * @fires engine.conversion.ViewConversionDispatcher.element
+	 * @fires engine.conversion.ViewConversionDispatcher.text
+	 * @fires engine.conversion.ViewConversionDispatcher.documentFragment
+	 * @param {engine.view.DocumentFragment|engine.view.Element} viewItem Part of the view to be converted.
 	 * @param {Object} [additionalData] Additional data to be passed in `data` argument when firing `ViewConversionDispatcher`
-	 * events. See also {@link engine.treeController.ViewConversionDispatcher.element element event}.
-	 * @returns {engine.treeModel.DocumentFragment} Model document fragment that is a result of the conversion process.
+	 * events. See also {@link engine.conversion.ViewConversionDispatcher.element element event}.
+	 * @returns {engine.model.DocumentFragment} Model document fragment that is a result of the conversion process.
 	 */
 	convert( viewItem, additionalData = {} ) {
 		this.fire( 'viewCleanup', viewItem );
@@ -139,7 +139,7 @@ export default class ViewConversionDispatcher {
 
 	/**
 	 * @private
-	 * @see engine.treeController.ViewConversionApi#convertItem
+	 * @see engine.conversion.ViewConversionApi#convertItem
 	 */
 	_convertItem( input, consumable, additionalData = {} ) {
 		const data = extend( {}, additionalData, {
@@ -160,7 +160,7 @@ export default class ViewConversionDispatcher {
 
 	/**
 	 * @private
-	 * @see engine.treeController.ViewConversionApi#convertChildren
+	 * @see engine.conversion.ViewConversionApi#convertChildren
 	 */
 	_convertChildren( input, consumable, additionalData = {} ) {
 		const viewChildren = Array.from( input.getChildren() );
@@ -173,58 +173,58 @@ export default class ViewConversionDispatcher {
 	/**
 	 * Fired before the first conversion event, at the beginning of view to model conversion process.
 	 *
-	 * @event engine.treeController.ViewConversionDispatcher.viewCleanup
-	 * @param {engine.treeView.DocumentFragment|engine.treeView.Element} viewItem Part of the view to be converted.
+	 * @event engine.conversion.ViewConversionDispatcher.viewCleanup
+	 * @param {engine.view.DocumentFragment|engine.view.Element} viewItem Part of the view to be converted.
 	 */
 
 	/**
-	 * Fired when {@link engine.treeView.Element} is converted.
+	 * Fired when {@link engine.view.Element} is converted.
 	 *
 	 * `element` is a namespace event for a class of events. Names of actually called events follow this pattern:
 	 * `element:<elementName>` where `elementName` is the name of converted element. This way listeners may listen to
 	 * all elements conversion or to conversion of specific elements.
 	 *
-	 * @event engine.treeController.ViewConversionDispatcher.element
+	 * @event engine.conversion.ViewConversionDispatcher.element
 	 * @param {Object} data Object containing conversion input and a placeholder for conversion output and possibly other
-	 * values (see {@link engine.treeController.ViewConversionDispatcher#convert}). Keep in mind that this object is shared
+	 * values (see {@link engine.conversion.ViewConversionDispatcher#convert}). Keep in mind that this object is shared
 	 * by reference between all callbacks that will be called. This means that callbacks can add their own values if needed,
 	 * and those values will be available in other callbacks.
-	 * @param {engine.treeView.Element} data.input Converted element.
+	 * @param {engine.view.Element} data.input Converted element.
 	 * @param {*} data.output The current state of conversion result. Every change to converted element should
 	 * be reflected by setting or modifying this property.
-	 * @param {engine.treeController.ViewConsumable} consumable Values to consume.
+	 * @param {engine.conversion.ViewConsumable} consumable Values to consume.
 	 * @param {Object} conversionApi Conversion interface to be used by callback, passed in `ViewConversionDispatcher` constructor.
 	 * Besides of properties passed in constructor, it also has `convertItem` and `convertChildren` methods which are references
-	 * to {@link engine.treeController.ViewConversionDispatcher#_convertItem} and
-	 * {@link engine.treeController.ViewConversionDispatcher#_convertChildren}. Those methods are needed to convert
+	 * to {@link engine.conversion.ViewConversionDispatcher#_convertItem} and
+	 * {@link engine.conversion.ViewConversionDispatcher#_convertChildren}. Those methods are needed to convert
 	 * the whole view-tree they were exposed in `conversionApi` for callbacks.
 	 */
 
 	/**
-	 * Fired when {@link engine.treeView.Text} is converted.
+	 * Fired when {@link engine.view.Text} is converted.
 	 *
-	 * @event engine.treeController.ViewConversionDispatcher.text
-	 * @see engine.treeController.ViewConversionDispatcher.element
+	 * @event engine.conversion.ViewConversionDispatcher.text
+	 * @see engine.conversion.ViewConversionDispatcher.element
 	 */
 
 	/**
-	 * Fired when {@link engine.treeView.DocumentFragment} is converted.
+	 * Fired when {@link engine.view.DocumentFragment} is converted.
 	 *
-	 * @event engine.treeController.ViewConversionDispatcher.documentFragment
-	 * @see engine.treeController.ViewConversionDispatcher.element
+	 * @event engine.conversion.ViewConversionDispatcher.documentFragment
+	 * @see engine.conversion.ViewConversionDispatcher.element
 	 */
 }
 
 mix( ViewConversionDispatcher, EmitterMixin );
 
 /**
- * Conversion interface that is registered for given {@link engine.treeController.ViewConversionDispatcher} and is
- * passed as one of parameters when {@link engine.treeController.ViewConversionDispatcher dispatcher} fires it's events.
+ * Conversion interface that is registered for given {@link engine.conversion.ViewConversionDispatcher} and is
+ * passed as one of parameters when {@link engine.conversion.ViewConversionDispatcher dispatcher} fires it's events.
  *
- * `ViewConversionApi` object is built by {@link engine.treeController.ViewConversionDispatcher} constructor. The exact
+ * `ViewConversionApi` object is built by {@link engine.conversion.ViewConversionDispatcher} constructor. The exact
  * list of properties of this object is determined by the object passed to the constructor.
  *
- * @interface engine.treeController.ViewConversionApi
+ * @interface engine.conversion.ViewConversionApi
  */
 
 /**
@@ -233,29 +233,29 @@ mix( ViewConversionDispatcher, EmitterMixin );
  * Every fired event is passed (as first parameter) an object with `output` property. Every event may set and/or
  * modify that property. When all callbacks are done, the final value of `output` property is returned by this method.
  *
- * @memberOf engine.treeController.ViewConversionApi
+ * @memberOf engine.conversion.ViewConversionApi
  * @function covertItem
- * @fires engine.treeController.ViewConversionDispatcher.element
- * @fires engine.treeController.ViewConversionDispatcher.text
- * @fires engine.treeController.ViewConversionDispatcher.documentFragment
- * @param {engine.treeView.DocumentFragment|engine.treeView.Element|engine.treeView.Text} input Item to convert.
- * @param {engine.treeController.ViewConsumable} consumable Values to consume.
+ * @fires engine.conversion.ViewConversionDispatcher.element
+ * @fires engine.conversion.ViewConversionDispatcher.text
+ * @fires engine.conversion.ViewConversionDispatcher.documentFragment
+ * @param {engine.view.DocumentFragment|engine.view.Element|engine.view.Text} input Item to convert.
+ * @param {engine.conversion.ViewConsumable} consumable Values to consume.
  * @param {Object} [additionalData] Additional data to be passed in `data` argument when firing `ViewConversionDispatcher`
- * events. See also {@link engine.treeController.ViewConversionDispatcher.element element event}.
+ * events. See also {@link engine.conversion.ViewConversionDispatcher.element element event}.
  * @returns {*} The result of item conversion, created and modified by callbacks attached to fired event.
  */
 
 /**
  * Starts conversion of all children of given item by firing appropriate events for all those children.
  *
- * @memberOf engine.treeController.ViewConversionApi
+ * @memberOf engine.conversion.ViewConversionApi
  * @function convertChildren
- * @fires engine.treeController.ViewConversionDispatcher.element
- * @fires engine.treeController.ViewConversionDispatcher.text
- * @fires engine.treeController.ViewConversionDispatcher.documentFragment
- * @param {engine.treeView.DocumentFragment|engine.treeView.Element} input Item which children will be converted.
- * @param {engine.treeController.ViewConsumable} consumable Values to consume.
+ * @fires engine.conversion.ViewConversionDispatcher.element
+ * @fires engine.conversion.ViewConversionDispatcher.text
+ * @fires engine.conversion.ViewConversionDispatcher.documentFragment
+ * @param {engine.view.DocumentFragment|engine.view.Element} input Item which children will be converted.
+ * @param {engine.conversion.ViewConsumable} consumable Values to consume.
  * @param {Object} [additionalData] Additional data to be passed in `data` argument when firing `ViewConversionDispatcher`
- * events. See also {@link engine.treeController.ViewConversionDispatcher.element element event}.
+ * events. See also {@link engine.conversion.ViewConversionDispatcher.element element event}.
  * @returns {Array.<*>} Array containing results of conversion of all children of given item.
  */

packages/ckeditor5-engine/src/treecontroller/datacontroller.js → packages/ckeditor5-engine/src/datacontroller.js


+ 1 - 1
packages/ckeditor5-engine/src/treecontroller/editingcontroller.js

@@ -5,7 +5,7 @@
 
 'use strict';
 
-import ViewDocument from '../treeview/document.js';
+import ViewDocument from './view/document.js';
 
 export default class EditingController {
 	constructor( modelDocument ) {

+ 9 - 9
packages/ckeditor5-engine/src/treemodel/batch.js

@@ -28,19 +28,19 @@ import CKEditorError from '../../utils/ckeditorerror.js';
  *
  *		doc.batch().insert( firstPosition, 'foo' ).insert( secondPosition, 'bar' );
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class Batch {
 	/**
-	 * Creates Batch instance. Not recommended to use directly, use {@link engine.treeModel.Document#batch} instead.
+	 * Creates Batch instance. Not recommended to use directly, use {@link engine.model.Document#batch} instead.
 	 *
-	 * @param {engine.treeModel.Document} doc Document which this Batch changes.
+	 * @param {engine.model.Document} doc Document which this Batch changes.
 	 */
 	constructor( doc ) {
 		/**
 		 * Document which this Batch changes.
 		 *
-		 * @member {engine.treeModel.Document} engine.treeModel.Batch#doc
+		 * @member {engine.model.Document} engine.model.Batch#doc
 		 * @readonly
 		 */
 		this.doc = doc;
@@ -48,7 +48,7 @@ export default class Batch {
 		/**
 		 * Array of deltas which compose Batch.
 		 *
-		 * @member {Array.<engine.treeModel.delta.Delta>} engine.treeModel.Batch#deltas
+		 * @member {Array.<engine.model.delta.Delta>} engine.model.Batch#deltas
 		 * @readonly
 		 */
 		this.deltas = [];
@@ -58,8 +58,8 @@ export default class Batch {
 	 * Adds delta to the Batch instance. All modification methods (insert, remove, split, etc.) use this method
 	 * to add created deltas.
 	 *
-	 * @param {engine.treeModel.delta.Delta} delta Delta to add.
-	 * @return {engine.treeModel.delta.Delta} Added delta.
+	 * @param {engine.model.delta.Delta} delta Delta to add.
+	 * @return {engine.model.delta.Delta} Added delta.
 	 */
 	addDelta( delta ) {
 		delta.batch = this;
@@ -71,7 +71,7 @@ export default class Batch {
 	/**
 	 * Gets an iterable collection of operations.
 	 *
-	 * @returns {Iterable.<engine.treeModel.operation.Operation}
+	 * @returns {Iterable.<engine.model.operation.Operation}
 	 */
 	*getOperations() {
 		for ( let delta of this.deltas ) {
@@ -111,7 +111,7 @@ export default class Batch {
  *			return this;
  *		} );
  *
- * @method engine.treeModel.Batch.register
+ * @method engine.model.Batch.register
  * @param {String} name Method name.
  * @param {Function} creator Method body.
  */

+ 10 - 10
packages/ckeditor5-engine/src/treemodel/characterproxy.js

@@ -14,25 +14,25 @@ import toMap from '../../utils/tomap.js';
  * the actual nodes in tree model.
  *
  * Keep in mind that CharacterProxy is static, meaning that it won't change when tree model changes. For example, if you
- * have a {engine.treeModel.Element element} `myEl` containing text `foobar` and then assign `let b = myEl.getChild( 3 )`
+ * have a {engine.model.Element element} `myEl` containing text `foobar` and then assign `let b = myEl.getChild( 3 )`
  * and then remove all nodes from `myEl`, `b` will still have character `b`, parent `myEl` and offset `3`.
  *
  * CharacterProxy is created on the fly basing on tree model. It is not an explicit node in a tree model but
  * rather represents it. Because of this, it is not advised to store or compare instances of CharacterProxy class.
- * If you want to keep live reference to a point in a text, you should use {@link engine.treeModel.LivePosition}.
+ * If you want to keep live reference to a point in a text, you should use {@link engine.model.LivePosition}.
  *
  * You should never create an instance of this class by your own. When passing parameters to constructors,
- * use string literals or {@link engine.treeModel.Text} instead.
+ * use string literals or {@link engine.model.Text} instead.
  *
- * @memberOf engine.treeModel
- * @extends engine.treeModel.Node
+ * @memberOf engine.model
+ * @extends engine.model.Node
  */
 export default class CharacterProxy extends Node {
 	/**
 	 * Creates character node proxy.
 	 *
 	 * @protected
-	 * @param {engine.treeModel.NodeListText} nodeListText Reference to a text object in a node list containing this character.
+	 * @param {engine.model.NodeListText} nodeListText Reference to a text object in a node list containing this character.
 	 * @param {Number} index Index of the character in `nodeListText`.
 	 */
 	constructor( nodeListText, index ) {
@@ -42,7 +42,7 @@ export default class CharacterProxy extends Node {
 		 * Character represented by this proxy.
 		 *
 		 * @readonly
-		 * @member {String} engine.treeModel.CharacterProxy#character
+		 * @member {String} engine.model.CharacterProxy#character
 		 */
 		this.character = nodeListText.text.substr( index, 1 );
 
@@ -56,7 +56,7 @@ export default class CharacterProxy extends Node {
 		 *
 		 * @protected
 		 * @readonly
-		 * @member {engine.treeModel.NodeListText} engine.treeModel.CharacterProxy#_nodeListText
+		 * @member {engine.model.NodeListText} engine.model.CharacterProxy#_nodeListText
 		 */
 		this._nodeListText = nodeListText;
 
@@ -65,7 +65,7 @@ export default class CharacterProxy extends Node {
 		 *
 		 * @protected
 		 * @readonly
-		 * @member {Number} engine.treeModel.CharacterProxy#_index
+		 * @member {Number} engine.model.CharacterProxy#_index
 		 */
 		this._index = index;
 	}
@@ -94,7 +94,7 @@ export default class CharacterProxy extends Node {
 	 * It is highly unrecommended to store references to `CharacterProxy` instances.
 	 *
 	 * @param {Iterable|Object} attrs Iterable object containing attributes to be set. See
-	 * {@link engine.treeModel.CharacterProxy#getAttributes}.
+	 * {@link engine.model.CharacterProxy#getAttributes}.
 	 */
 	setAttributesTo( attrs ) {
 		let attrsMap = toMap( attrs );

+ 23 - 23
packages/ckeditor5-engine/src/treemodel/composer/composer.js

@@ -12,14 +12,14 @@ import modifySelection from './modifyselection.js';
 
 /**
  * Set of frequently used tools to work with a document.
- * The instance of composer is available in {@link engine.treeModel.Document#composer}.
+ * The instance of composer is available in {@link engine.model.Document#composer}.
  *
  * By default this class implements only a very basic version of those algorithms. However, all its methods can be extended
  * by features by listening to related events. The default action of those events are implemented
- * by functions available in the {@link engine.treeModel.composer} namespace, so they can be reused
+ * by functions available in the {@link engine.model.composer} namespace, so they can be reused
  * in the algorithms implemented by features.
  *
- * @member engine.treeModel.composer
+ * @member engine.model.composer
  * @mixes utils.EmitterMixin
  */
 export default class Composer {
@@ -32,7 +32,7 @@ export default class Composer {
 	}
 
 	/**
-	 * See {@link engine.treeModel.composer.deleteContents}.
+	 * See {@link engine.model.composer.deleteContents}.
 	 *
 	 * Note: For the sake of predictability, the resulting selection should always be collapsed.
 	 * In cases where a feature wants to modify deleting behavior so selection isn't collapsed
@@ -42,21 +42,21 @@ export default class Composer {
 	 * the selection inside the last selected cell" or "delete the row and collapse selection somewhere near".
 	 * That needs to be done in order to ensure that other features which use `deleteContents()` will work well with tables.
 	 *
-	 * @fires engine.treeModel.composer.Composer#deleteContents
-	 * @param {engine.treeModel.Batch} batch Batch to which deltas will be added.
-	 * @param {engine.treeModel.Selection} selection Selection of which the content should be deleted.
-	 * @param {Object} options See {@link engine.treeModel.composer.deleteContents}'s options.
+	 * @fires engine.model.composer.Composer#deleteContents
+	 * @param {engine.model.Batch} batch Batch to which deltas will be added.
+	 * @param {engine.model.Selection} selection Selection of which the content should be deleted.
+	 * @param {Object} options See {@link engine.model.composer.deleteContents}'s options.
 	 */
 	deleteContents( batch, selection, options ) {
 		this.fire( 'deleteContents', { batch, selection, options } );
 	}
 
 	/**
-	 * See {@link engine.treeModel.composer.modifySelection}.
+	 * See {@link engine.model.composer.modifySelection}.
 	 *
-	 * @fires engine.treeModel.composer.Composer#modifySelection
-	 * @param {engine.treeModel.Selection} The selection to modify.
-	 * @param {Object} options See {@link engine.treeModel.composer.modifySelection}'s options.
+	 * @fires engine.model.composer.Composer#modifySelection
+	 * @param {engine.model.Selection} The selection to modify.
+	 * @param {Object} options See {@link engine.model.composer.modifySelection}'s options.
 	 */
 	modifySelection( selection, options ) {
 		this.fire( 'modifySelection', { selection, options } );
@@ -66,24 +66,24 @@ export default class Composer {
 mix( Composer, EmitterMixin );
 
 /**
- * Event fired when {@link engine.treeModel.composer.Composer#deleteContents} method is called.
- * The {@link engine.treeModel.composer.deleteContents default action of the composer} is implemented as a
+ * Event fired when {@link engine.model.composer.Composer#deleteContents} method is called.
+ * The {@link engine.model.composer.deleteContents default action of the composer} is implemented as a
  * listener to that event so it can be fully customized by the features.
  *
- * @event engine.treeModel.composer.Composer#deleteContents
+ * @event engine.model.composer.Composer#deleteContents
  * @param {Object} data
- * @param {engine.treeModel.Batch} data.batch
- * @param {engine.treeModel.Selection} data.selection
- * @param {Object} data.options See {@link engine.treeModel.composer.deleteContents}'s options.
+ * @param {engine.model.Batch} data.batch
+ * @param {engine.model.Selection} data.selection
+ * @param {Object} data.options See {@link engine.model.composer.deleteContents}'s options.
  */
 
 /**
- * Event fired when {@link engine.treeModel.composer.Composer#modifySelection} method is called.
- * The {@link engine.treeModel.composer.modifySelection default action of the composer} is implemented as a
+ * Event fired when {@link engine.model.composer.Composer#modifySelection} method is called.
+ * The {@link engine.model.composer.modifySelection default action of the composer} is implemented as a
  * listener to that event so it can be fully customized by the features.
  *
- * @event engine.treeModel.composer.Composer#modifySelection
+ * @event engine.model.composer.Composer#modifySelection
  * @param {Object} data
- * @param {engine.treeModel.Selection} data.selection
- * @param {Object} data.options See {@link engine.treeModel.composer.modifySelection}'s options.
+ * @param {engine.model.Selection} data.selection
+ * @param {Object} data.options See {@link engine.model.composer.modifySelection}'s options.
  */

+ 3 - 3
packages/ckeditor5-engine/src/treemodel/composer/deletecontents.js

@@ -12,9 +12,9 @@ import compareArrays from '../../../utils/comparearrays.js';
 /**
  * Delete contents of the selection and merge siblings. The resulting selection is always collapsed.
  *
- * @method engine.treeModel.composer.deleteContents
- * @param {engine.treeModel.Batch} batch Batch to which the deltas will be added.
- * @param {engine.treeModel.Selection} selection Selection of which the content should be deleted.
+ * @method engine.model.composer.deleteContents
+ * @param {engine.model.Batch} batch Batch to which the deltas will be added.
+ * @param {engine.model.Selection} selection Selection of which the content should be deleted.
  * @param {Object} [options]
  * @param {Boolean} [options.merge=false] Merge elements after removing the contents of the selection.
  * For example, `<h>x[x</h><p>y]y</p>` will become: `<h>x^y</h>` with the option enabled

+ 2 - 2
packages/ckeditor5-engine/src/treemodel/composer/modifyselection.js

@@ -16,8 +16,8 @@ import Range from '../range.js';
  * (defaults to `'CHARACTER'`, other values are not not yet supported).
  * Note: if you extend a forward selection in a backward direction you will in fact shrink it.
  *
- * @method engine.treeModel.composer.modifySelection
- * @param {engine.treeModel.Selection} The selection to modify.
+ * @method engine.model.composer.modifySelection
+ * @param {engine.model.Selection} The selection to modify.
  * @param {Object} [options]
  * @param {'FORWARD'|'BACKWARD'} [options.direction='FORWARD'] The direction in which the selection should be modified.
  */

+ 33 - 14
packages/ckeditor5-engine/src/treemodel/delta/attributedelta.js

@@ -6,6 +6,7 @@
 'use strict';
 
 import Delta from './delta.js';
+import DeltaFactory from './deltafactory.js';
 import { register } from '../batch.js';
 import AttributeOperation from '../operation/attributeoperation.js';
 import RootAttributeOperation from '../operation/rootattributeoperation.js';
@@ -15,12 +16,12 @@ import RootElement from '../rootelement.js';
 import Element from '../element.js';
 
 /**
- * To provide specific OT behavior and better collisions solving, change methods ({@link engine.treeModel.Batch#setAttr}
- * and {@link engine.treeModel.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 engine.model.Batch#setAttr}
+ * and {@link engine.model.Batch#removeAttr}) use `AttributeDelta` class which inherits from the `Delta` class and may
  * overwrite some methods.
  *
- * @memberOf engine.treeModel.delta
- * @extends engine.treeModel.delta.Delta
+ * @memberOf engine.model.delta
+ * @extends engine.model.delta.Delta
  */
 export default class AttributeDelta extends Delta {
 	/**
@@ -44,7 +45,7 @@ export default class AttributeDelta extends Delta {
 	/**
 	 * The range on which delta operates or `null` if the delta has no operations.
 	 *
-	 * @type {engine.treeModel.Range|null}
+	 * @type {engine.model.Range|null}
 	 */
 	get range() {
 		// Check if it is cached.
@@ -69,29 +70,43 @@ export default class AttributeDelta extends Delta {
 		return AttributeDelta;
 	}
 
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.delta.AttributeDelta';
+	}
+
 	static get _priority() {
 		return 20;
 	}
 }
 
 /**
- * To provide specific OT behavior and better collisions solving, change methods ({@link engine.treeModel.Batch#setAttr}
- * and {@link engine.treeModel.Batch#removeAttr}) use `RootAttributeDelta` class which inherits from the `Delta` class and may
+ * To provide specific OT behavior and better collisions solving, change methods ({@link engine.model.Batch#setAttr}
+ * and {@link engine.model.Batch#removeAttr}) use `RootAttributeDelta` class which inherits from the `Delta` class and may
  * overwrite some methods.
  *
- * @memberOf engine.treeModel.delta
- * @extends engine.treeModel.delta.Delta
+ * @memberOf engine.model.delta
+ * @extends engine.model.delta.Delta
  */
-export class RootAttributeDelta extends Delta {}
+export class RootAttributeDelta extends Delta {
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.delta.RootAttributeDelta';
+	}
+}
 
 /**
  * Sets the value of the attribute of the node or on the range.
  *
  * @chainable
- * @method engine.treeModel.Batch#setAttr
+ * @method engine.model.Batch#setAttr
  * @param {String} key Attribute key.
  * @param {*} value Attribute new value.
- * @param {engine.treeModel.Node|engine.treeModel.Range} nodeOrRange Node or range on which the attribute will be set.
+ * @param {engine.model.Node|engine.model.Range} nodeOrRange Node or range on which the attribute will be set.
  */
 register( 'setAttr', function( key, value, nodeOrRange ) {
 	attribute( this, key, value, nodeOrRange );
@@ -103,9 +118,9 @@ register( 'setAttr', function( key, value, nodeOrRange ) {
  * Removes an attribute from the range.
  *
  * @chainable
- * @method engine.treeModel.Batch#removeAttr
+ * @method engine.model.Batch#removeAttr
  * @param {String} key Attribute key.
- * @param {engine.treeModel.Node|engine.treeModel.Range} nodeOrRange Node or range on which the attribute will be removed.
+ * @param {engine.model.Node|engine.model.Range} nodeOrRange Node or range on which the attribute will be removed.
  */
 register( 'removeAttr', function( key, nodeOrRange ) {
 	attribute( this, key, null, nodeOrRange );
@@ -200,3 +215,7 @@ function changeRange( batch, doc, attributeKey, attributeValue, range ) {
 		doc.applyOperation( operation );
 	}
 }
+
+DeltaFactory.register( AttributeDelta );
+
+DeltaFactory.register( RootAttributeDelta );

packages/ckeditor5-engine/src/treemodel/delta/basic-deltas.js → packages/ckeditor5-engine/src/model/delta/basic-deltas.js


packages/ckeditor5-engine/src/treemodel/delta/basic-transformations.js → packages/ckeditor5-engine/src/model/delta/basic-transformations.js


+ 44 - 12
packages/ckeditor5-engine/src/treemodel/delta/delta.js

@@ -5,15 +5,18 @@
 
 'use strict';
 
+import clone from '../../../utils/lib/lodash/clone.js';
+import DeltaFactory from './deltafactory.js';
+
 /**
  * Base class for all deltas.
  *
  * Delta is a single, from the user action point of view, change in the editable document, like insert, split or
  * rename element. Delta is composed of operations, which are unit changes needed to be done to execute user action.
  *
- * Multiple deltas are grouped into a single {@link engine.treeModel.Batch}.
+ * Multiple deltas are grouped into a single {@link engine.model.Batch}.
  *
- * @memberOf engine.treeModel.delta
+ * @memberOf engine.model.delta
  */
 export default class Delta {
 	/**
@@ -21,11 +24,11 @@ export default class Delta {
 	 */
 	constructor() {
 		/**
-		 * {@link engine.treeModel.Batch} which delta is a part of. This property is null by default and set by the
-		 * {@link engine.treeModel.Batch#addDelta} method.
+		 * {@link engine.model.Batch} which delta is a part of. This property is null by default and set by the
+		 * {@link engine.model.Batch#addDelta} method.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.Batch} engine.treeModel.delta.Delta#batch
+		 * @member {engine.model.Batch} engine.model.delta.Delta#batch
 		 */
 		this.batch = null;
 
@@ -33,7 +36,7 @@ export default class Delta {
 		 * Array of operations which compose delta.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.operation.Operation[]} engine.treeModel.delta.Delta#operations
+		 * @member {engine.model.operation.Operation[]} engine.model.delta.Delta#operations
 		 */
 		this.operations = [];
 	}
@@ -42,7 +45,7 @@ export default class Delta {
 	 * Returns delta base version which is equal to the base version of the first operation in delta. If there
 	 * are no operations in delta, returns `null`.
 	 *
-	 * @see engine.treeModel.Document
+	 * @see engine.model.Document
 	 * @type {Number|null}
 	 */
 	get baseVersion() {
@@ -66,7 +69,7 @@ export default class Delta {
 	/**
 	 * Add operation to the delta.
 	 *
-	 * @param {engine.treeModel.operation.Operation} operation Operation instance.
+	 * @param {engine.model.operation.Operation} operation Operation instance.
 	 */
 	addOperation( operation ) {
 		operation.delta = this;
@@ -78,7 +81,7 @@ export default class Delta {
 	/**
 	 * Creates and returns a delta that has the same parameters as this delta.
 	 *
-	 * @returns {engine.treeModel.delta.Delta} Clone of this delta.
+	 * @returns {engine.model.delta.Delta} Clone of this delta.
 	 */
 	clone() {
 		let delta = new this.constructor();
@@ -96,10 +99,10 @@ export default class Delta {
 	 * by the original delta.
 	 *
 	 * Keep in mind that tree model state may change since executing the original delta, so reverse delta may be "outdated".
-	 * In that case you will need to {@link engine.treeModel.delta.transform} it by all deltas that were executed after
+	 * In that case you will need to {@link engine.model.delta.transform} it by all deltas that were executed after
 	 * the original delta.
 	 *
-	 * @returns {engine.treeModel.delta.Delta} Reversed delta.
+	 * @returns {engine.model.delta.Delta} Reversed delta.
 	 */
 	getReversed() {
 		let delta = new this._reverseDeltaClass();
@@ -118,7 +121,34 @@ export default class Delta {
 	}
 
 	/**
-	 * Delta priority. Used in {@link engine.treeModel.delta.transform delta transformations}. Delta with the higher
+	 * Custom toJSON method to make deltas serializable.
+	 *
+	 * @returns {Object} Clone of this delta with added class name.
+	 */
+	toJSON() {
+		let json = clone( this );
+
+		json.__className = this.constructor.className;
+
+		// Remove parent batch to avoid circular dependencies.
+		delete json.batch;
+
+		return json;
+	}
+
+	/**
+	 * Delta class name. Used by {@link engine.model.delta.Delta#toJSON} method for serialization and
+	 * {@link engine.model.delta.DeltaFactory.fromJSON} during deserialization.
+	 *
+	 * @type {String}
+	 * @readonly
+	 */
+	static get className() {
+		return 'engine.model.delta.Delta';
+	}
+
+	/**
+	 * Delta priority. Used in {@link engine.model.delta.transform delta transformations}. Delta with the higher
 	 * priority will be treated as more important when resolving transformation conflicts. If deltas have same
 	 * priority, other factors will be used to determine which delta is more important.
 	 *
@@ -129,3 +159,5 @@ export default class Delta {
 		return 0;
 	}
 }
+
+DeltaFactory.register( Delta );

+ 1 - 1
packages/ckeditor5-engine/src/treemodel/delta.jsdoc

@@ -4,5 +4,5 @@
  */
 
 /**
- * @namespace engine.treeModel.delta
+ * @namespace engine.model.delta
  */

+ 65 - 0
packages/ckeditor5-engine/src/model/delta/deltafactory.js

@@ -0,0 +1,65 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+import CKEditorError from '../../../utils/ckeditorerror.js';
+
+import OperationFactory from '../operation/operationfactory.js';
+
+const deserializers = new Map();
+
+/**
+ * A factory class for creating operations.
+ *
+ * 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 engine.model.Batch}.
+ *
+ * @memberOf engine.model.delta
+ */
+export default class DeltaFactory {
+	/**
+	 * Creates InsertDelta from deserialized object, i.e. from parsed JSON string.
+	 *
+	 * @param {Object} json
+	 * @param {engine.model.Document} doc Document on which this delta will be applied.
+	 * @returns {engine.model.delta.InsertDelta}
+	 */
+	static fromJSON( json, doc ) {
+		if ( !deserializers.has( json.__className ) ) {
+			/**
+			 * This delta has no defined deserializer.
+			 *
+			 * @error delta-fromjson-no-deserializer
+			 * @param {String} name
+			 */
+			throw new CKEditorError(
+				'delta-fromjson-no-deserializer: This delta has no defined deserializer',
+				{ name: json.__className }
+			);
+		}
+
+		let Delta = deserializers.get( json.__className );
+
+		let delta = new Delta();
+
+		for ( let operation of json.operations ) {
+			delta.addOperation( OperationFactory.fromJSON( operation, doc ) );
+		}
+
+		return delta;
+	}
+
+	/**
+	 * Registers a class for delta factory.
+	 *
+	 * @param {Function} Delta A delta class to register.
+	 */
+	static register( Delta ) {
+		deserializers.set( Delta.className, Delta );
+	}
+}

+ 18 - 8
packages/ckeditor5-engine/src/treemodel/delta/insertdelta.js

@@ -6,22 +6,23 @@
 'use strict';
 
 import Delta from './delta.js';
+import DeltaFactory from './deltafactory.js';
 import RemoveDelta from './removedelta.js';
 import { register } from '../batch.js';
 import InsertOperation from '../operation/insertoperation.js';
 
 /**
  * @classdesc
- * To provide specific OT behavior and better collisions solving, the {@link engine.treeModel.Batch#insert Batch#insert} method
+ * To provide specific OT behavior and better collisions solving, the {@link engine.model.Batch#insert Batch#insert} method
  * uses the `InsertDelta` class which inherits from the `Delta` class and may overwrite some methods.
  *
- * @memberOf engine.treeModel.delta
+ * @memberOf engine.model.delta
  */
 export default class InsertDelta extends Delta {
 	/**
 	 * Position where the delta inserts nodes or `null` if there are no operations in the delta.
 	 *
-	 * @type {engine.treeModel.Position|null}
+	 * @type {engine.model.Position|null}
 	 */
 	get position() {
 		return this._insertOperation ? this._insertOperation.position : null;
@@ -30,7 +31,7 @@ export default class InsertDelta extends Delta {
 	/**
 	 * Node list containing all the nodes inserted by the delta or `null` if there are no operations in the delta.
 	 *
-	 * @type {engine.treeModel.NodeList|null}
+	 * @type {engine.model.NodeList|null}
 	 */
 	get nodeList() {
 		return this._insertOperation ? this._insertOperation.nodeList : null;
@@ -40,7 +41,7 @@ export default class InsertDelta extends Delta {
 	 * Insert operation that is saved in this delta or `null` if there are no operations in the delta.
 	 *
 	 * @protected
-	 * @type {engine.treeModel.operation.InsertOperation|null}
+	 * @type {engine.model.operation.InsertOperation|null}
 	 */
 	get _insertOperation() {
 		return this.operations[ 0 ] || null;
@@ -50,6 +51,13 @@ export default class InsertDelta extends Delta {
 		return RemoveDelta;
 	}
 
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.delta.InsertDelta';
+	}
+
 	static get _priority() {
 		return 20;
 	}
@@ -59,9 +67,9 @@ export default class InsertDelta extends Delta {
  * Inserts a node or nodes at the given position.
  *
  * @chainable
- * @method engine.treeModel.Batch#insert
- * @param {engine.treeModel.Position} position Position of insertion.
- * @param {engine.treeModel.NodeSet} nodes The list of nodes to be inserted.
+ * @method engine.model.Batch#insert
+ * @param {engine.model.Position} position Position of insertion.
+ * @param {engine.model.NodeSet} nodes The list of nodes to be inserted.
  */
 register( 'insert', function( position, nodes ) {
 	const delta = new InsertDelta();
@@ -73,3 +81,5 @@ register( 'insert', function( position, nodes ) {
 
 	return this;
 } );
+
+DeltaFactory.register( InsertDelta );

+ 19 - 9
packages/ckeditor5-engine/src/treemodel/delta/mergedelta.js

@@ -6,6 +6,7 @@
 'use strict';
 
 import Delta from './delta.js';
+import DeltaFactory from './deltafactory.js';
 import SplitDelta from './splitdelta.js';
 import { register } from '../batch.js';
 import Position from '../position.js';
@@ -16,16 +17,16 @@ import CKEditorError from '../../../utils/ckeditorerror.js';
 
 /**
  * @classdesc
- * To provide specific OT behavior and better collisions solving, {@link engine.treeModel.Batch#merge} method
+ * To provide specific OT behavior and better collisions solving, {@link engine.model.Batch#merge} method
  * uses the `MergeDelta` class which inherits from the `Delta` class and may overwrite some methods.
  *
- * @memberOf engine.treeModel.delta
+ * @memberOf engine.model.delta
  */
 export default class MergeDelta extends Delta {
 	/**
 	 * Position between to merged nodes or `null` if the delta has no operations.
 	 *
-	 * @type {engine.treeModel.Position|null}
+	 * @type {engine.model.Position|null}
 	 */
 	get position() {
 		return this._removeOperation ? this._removeOperation.sourcePosition : null;
@@ -33,12 +34,12 @@ export default class MergeDelta extends Delta {
 
 	/**
 	 * Operation in this delta that removes the node after merge position (which will be empty at that point) or
-	 * `null` if the delta has no operations. Note, that after {@link engine.treeModel.delta.transform transformation}
-	 * this might be an instance of {@link engine.treeModel.operation.MoveOperation} instead of
-	 * {@link engine.treeModel.operation.RemoveOperation}.
+	 * `null` if the delta has no operations. Note, that after {@link engine.model.delta.transform transformation}
+	 * this might be an instance of {@link engine.model.operation.MoveOperation} instead of
+	 * {@link engine.model.operation.RemoveOperation}.
 	 *
 	 * @protected
-	 * @type {engine.treeModel.operation.MoveOperation|null}
+	 * @type {engine.model.operation.MoveOperation|null}
 	 */
 	get _removeOperation() {
 		return this.operations[ 1 ] || null;
@@ -47,6 +48,13 @@ export default class MergeDelta extends Delta {
 	get _reverseDeltaClass() {
 		return SplitDelta;
 	}
+
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.delta.MergeDelta';
+	}
 }
 
 /**
@@ -56,8 +64,8 @@ export default class MergeDelta extends Delta {
  * `batch-merge-no-element-after` error will be thrown.
  *
  * @chainable
- * @method engine.treeModel.Batch#merge
- * @param {engine.treeModel.Position} position Position of merge.
+ * @method engine.model.Batch#merge
+ * @param {engine.model.Position} position Position of merge.
  */
 register( 'merge', function( position ) {
 	const delta = new MergeDelta();
@@ -100,3 +108,5 @@ register( 'merge', function( position ) {
 
 	return this;
 } );
+
+DeltaFactory.register( MergeDelta );

+ 22 - 12
packages/ckeditor5-engine/src/treemodel/delta/movedelta.js

@@ -6,6 +6,7 @@
 'use strict';
 
 import Delta from './delta.js';
+import DeltaFactory from './deltafactory.js';
 import { register } from '../batch.js';
 import MoveOperation from '../operation/moveoperation.js';
 import Position from '../position.js';
@@ -14,10 +15,10 @@ import CKEditorError from '../../../utils/ckeditorerror.js';
 
 /**
  * @classdesc
- * To provide specific OT behavior and better collisions solving, {@link engine.treeModel.Batch#move} method
+ * To provide specific OT behavior and better collisions solving, {@link engine.model.Batch#move} method
  * uses the `MoveDelta` class which inherits from the `Delta` class and may overwrite some methods.
  *
- * @memberOf engine.treeModel.delta
+ * @memberOf engine.model.delta
  */
 export default class MoveDelta extends Delta {
 	/**
@@ -30,22 +31,22 @@ export default class MoveDelta extends Delta {
 	}
 
 	/**
-	 * {@link engine.treeModel.delta.MoveDelta#_moveOperation Move operation}
-	 * {@link engine.treeModel.operation.MoveOperation#sourcePosition source position} or `null` if there are
+	 * {@link engine.model.delta.MoveDelta#_moveOperation Move operation}
+	 * {@link engine.model.operation.MoveOperation#sourcePosition source position} or `null` if there are
 	 * no operations in the delta.
 	 *
-	 * @type {engine.treeModel.Position|null}
+	 * @type {engine.model.Position|null}
 	 */
 	get sourcePosition() {
 		return this._moveOperation ? this._moveOperation.sourcePosition : null;
 	}
 
 	/**
-	 * {@link engine.treeModel.delta.MoveDelta#_moveOperation Move operation}
-	 * {@link engine.treeModel.operation.MoveOperation#targetPosition target position} or `null` if there are
+	 * {@link engine.model.delta.MoveDelta#_moveOperation Move operation}
+	 * {@link engine.model.operation.MoveOperation#targetPosition target position} or `null` if there are
 	 * no operations in the delta.
 	 *
-	 * @type {engine.treeModel.Position|null}
+	 * @type {engine.model.Position|null}
 	 */
 	get targetPosition() {
 		return this._moveOperation ? this._moveOperation.targetPosition : null;
@@ -55,7 +56,7 @@ export default class MoveDelta extends Delta {
 	 * Move operation that is saved in this delta or `null` if there are no operations in the delta.
 	 *
 	 * @protected
-	 * @type {engine.treeModel.operation.MoveOperation|null}
+	 * @type {engine.model.operation.MoveOperation|null}
 	 */
 	get _moveOperation() {
 		return this.operations[ 0 ] || null;
@@ -65,6 +66,13 @@ export default class MoveDelta extends Delta {
 		return MoveDelta;
 	}
 
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.delta.MoveDelta';
+	}
+
 	static get _priority() {
 		return 20;
 	}
@@ -80,9 +88,9 @@ function addMoveOperation( batch, delta, sourcePosition, howMany, targetPosition
  * Moves given node or given range of nodes to target position.
  *
  * @chainable
- * @method engine.treeModel.Batch#move
- * @param {engine.treeModel.Node|engine.treeModel.Range} nodeOrRange Node or range of nodes to move.
- * @param {engine.treeModel.Position} targetPosition Position where moved nodes will be inserted.
+ * @method engine.model.Batch#move
+ * @param {engine.model.Node|engine.model.Range} nodeOrRange Node or range of nodes to move.
+ * @param {engine.model.Position} targetPosition Position where moved nodes will be inserted.
  */
 register( 'move', function( nodeOrRange, targetPosition ) {
 	const delta = new MoveDelta();
@@ -105,3 +113,5 @@ register( 'move', function( nodeOrRange, targetPosition ) {
 
 	return this;
 } );
+
+DeltaFactory.register( MoveDelta );

+ 15 - 5
packages/ckeditor5-engine/src/treemodel/delta/removedelta.js

@@ -7,18 +7,26 @@
 
 import MoveDelta from './movedelta.js';
 import { register } from '../batch.js';
+import DeltaFactory from './deltafactory.js';
 import RemoveOperation from '../operation/removeoperation.js';
 import Position from '../position.js';
 import Range from '../range.js';
 
 /**
  * @classdesc
- * To provide specific OT behavior and better collisions solving, {@link engine.treeModel.Batch#remove} method
+ * To provide specific OT behavior and better collisions solving, {@link engine.model.Batch#remove} method
  * uses the `RemoveDelta` class which inherits from the `Delta` class and may overwrite some methods.
  *
- * @memberOf engine.treeModel.delta
+ * @memberOf engine.model.delta
  */
-export default class RemoveDelta extends MoveDelta {}
+export default class RemoveDelta extends MoveDelta {
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.delta.RemoveDelta';
+	}
+}
 
 function addRemoveOperation( batch, delta, position, howMany ) {
 	const operation = new RemoveOperation( position, howMany, batch.doc.version );
@@ -30,8 +38,8 @@ function addRemoveOperation( batch, delta, position, howMany ) {
  * Removes given node or range of nodes.
  *
  * @chainable
- * @method engine.treeModel.Batch#remove
- * @param {engine.treeModel.Node|engine.treeModel.Range} nodeOrRange Node or range of nodes to remove.
+ * @method engine.model.Batch#remove
+ * @param {engine.model.Node|engine.model.Range} nodeOrRange Node or range of nodes to remove.
  */
 register( 'remove', function( nodeOrRange ) {
 	const delta = new RemoveDelta();
@@ -50,3 +58,5 @@ register( 'remove', function( nodeOrRange ) {
 
 	return this;
 } );
+
+DeltaFactory.register( RemoveDelta );

+ 14 - 4
packages/ckeditor5-engine/src/treemodel/delta/renamedelta.js

@@ -6,6 +6,7 @@
 'use strict';
 
 import Delta from './delta.js';
+import DeltaFactory from './deltafactory.js';
 import { register } from '../batch.js';
 import InsertOperation from '../operation/insertoperation.js';
 import RemoveOperation from '../operation/removeoperation.js';
@@ -14,15 +15,22 @@ import Element from '../element.js';
 import Position from '../position.js';
 
 /**
- * To provide specific OT behavior and better collisions solving, the {@link engine.treeModel.Batch#rename Batch#rename} method
+ * To provide specific OT behavior and better collisions solving, the {@link engine.model.Batch#rename Batch#rename} method
  * uses the `RenameDelta` class which inherits from the `Delta` class and may overwrite some methods.
  *
- * @memberOf engine.treeModel.delta
+ * @memberOf engine.model.delta
  */
 export default class RenameDelta extends Delta {
 	get _reverseDeltaClass() {
 		return RenameDelta;
 	}
+
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.delta.RenameDelta';
+	}
 }
 
 function apply( batch, delta, operation ) {
@@ -35,9 +43,9 @@ function apply( batch, delta, operation ) {
  * Renames the given element.
  *
  * @chainable
- * @method engine.treeModel.Batch#rename
+ * @method engine.model.Batch#rename
  * @param {String} newName New element name.
- * @param {engine.treeModel.Element} element The element to rename.
+ * @param {engine.model.Element} element The element to rename.
  */
 register( 'rename', function( newName, element ) {
 	const delta = new RenameDelta();
@@ -60,3 +68,5 @@ register( 'rename', function( newName, element ) {
 
 	return this;
 } );
+
+DeltaFactory.register( RenameDelta );

+ 18 - 8
packages/ckeditor5-engine/src/treemodel/delta/splitdelta.js

@@ -6,6 +6,7 @@
 'use strict';
 
 import Delta from './delta.js';
+import DeltaFactory from './deltafactory.js';
 import { register } from '../batch.js';
 import Position from '../position.js';
 import Element from '../element.js';
@@ -16,16 +17,16 @@ import MergeDelta from '../delta/mergedelta.js';
 
 /**
  * @classdesc
- * To provide specific OT behavior and better collisions solving, the {@link engine.treeModel.Batch#split} method
+ * To provide specific OT behavior and better collisions solving, the {@link engine.model.Batch#split} method
  * uses `SplitDelta` class which inherits from the `Delta` class and may overwrite some methods.
  *
- * @memberOf engine.treeModel.delta
+ * @memberOf engine.model.delta
  */
 export default class SplitDelta extends Delta {
 	/**
 	 * Position of split or `null` if there are no operations in the delta.
 	 *
-	 * @type {engine.treeModel.Position|null}
+	 * @type {engine.model.Position|null}
 	 */
 	get position() {
 		return this._moveOperation ? this._moveOperation.sourcePosition : null;
@@ -36,11 +37,11 @@ export default class SplitDelta extends Delta {
 	 * there are no operations in the delta.
 	 *
 	 * Most commonly this will be insert operation, as `SplitDelta` has to create a new node. If `SplitDelta` was created
-	 * through {@link engine.treeModel.delta.MergeDelta MergeDelta} {@link engine.treeModel.delta.Delta#getReversed reversing},
+	 * through {@link engine.model.delta.MergeDelta MergeDelta} {@link engine.model.delta.Delta#getReversed reversing},
 	 * this will be a reinsert operation, as we will want to "insert-back" the node that was removed by `MergeDelta`.
 	 *
 	 * @protected
-	 * @type {engine.treeModel.operation.InsertOpertaion|engine.treeModel.operation.ReinsertOperation|null}
+	 * @type {engine.model.operation.InsertOpertaion|engine.model.operation.ReinsertOperation|null}
 	 */
 	get _cloneOperation() {
 		return this.operations[ 0 ] || null;
@@ -51,7 +52,7 @@ export default class SplitDelta extends Delta {
 	 * or `null` if there are no operations in the delta.
 	 *
 	 * @protected
-	 * @type {engine.treeModel.operation.MoveOperation|null}
+	 * @type {engine.model.operation.MoveOperation|null}
 	 */
 	get _moveOperation() {
 		return this.operations[ 1 ] || null;
@@ -61,6 +62,13 @@ export default class SplitDelta extends Delta {
 		return MergeDelta;
 	}
 
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.delta.SplitDelta';
+	}
+
 	static get _priority() {
 		return 5;
 	}
@@ -73,8 +81,8 @@ export default class SplitDelta extends Delta {
  * you try to split the root element.
  *
  * @chainable
- * @method engine.treeModel.Batch#split
- * @param {engine.treeModel.Position} position Position of split.
+ * @method engine.model.Batch#split
+ * @param {engine.model.Position} position Position of split.
  */
 register( 'split', function( position ) {
 	const delta = new SplitDelta();
@@ -111,3 +119,5 @@ register( 'split', function( position ) {
 
 	return this;
 } );
+
+DeltaFactory.register( SplitDelta );

+ 24 - 24
packages/ckeditor5-engine/src/treemodel/delta/transform.js

@@ -11,11 +11,11 @@ import arrayUtils from '../../../utils/lib/lodash/array.js';
 const specialCases = new Map();
 
 /**
- * Transforms given {@link engine.treeModel.delta.Delta delta} by another {@link engine.treeModel.delta.Delta delta} and
- * returns the result of that transformation as an array containing one or more {@link engine.treeModel.delta.Delta delta}
+ * Transforms given {@link engine.model.delta.Delta delta} by another {@link engine.model.delta.Delta delta} and
+ * returns the result of that transformation as an array containing one or more {@link engine.model.delta.Delta delta}
  * instances.
  *
- * Delta transformations heavily base on {@link engine.treeModel.operation.transform operational transformations}. Since
+ * Delta transformations heavily base on {@link engine.model.operation.transform operational transformations}. Since
  * delta is a list of operations most situations can be handled thanks to operational transformation. Unfortunately,
  * deltas are more complicated than operations and have they semantic meaning, as they represent user's editing intentions.
  *
@@ -24,20 +24,20 @@ const specialCases = new Map();
  * we need to handle transformations in special cases in a custom way.
  *
  * The function itself looks whether two given delta types have a special case function registered. If so, the deltas are
- * transformed using that function. If not, {@link engine.treeModel.delta.defaultTransform default transformation algorithm}
+ * transformed using that function. If not, {@link engine.model.delta.defaultTransform default transformation algorithm}
  * is used.
  *
- * @see engine.treeModel.operation.transform
+ * @see engine.model.operation.transform
  *
- * @external engine.treeModel.delta.transform
- * @function engine.treeModel.delta.transform.transform
- * @param {engine.treeModel.delta.Delta} a Delta that will be transformed.
- * @param {engine.treeModel.delta.Delta} b Delta to transform by.
+ * @external engine.model.delta.transform
+ * @function engine.model.delta.transform.transform
+ * @param {engine.model.delta.Delta} a Delta that will be transformed.
+ * @param {engine.model.delta.Delta} b Delta to transform by.
  * @param {Boolean} isAMoreImportantThanB Flag indicating whether the delta which will be transformed (`a`) should be treated
  * as more important when resolving conflicts. Note that this flag is used only if provided deltas have same
- * {@link engine.treeModel.delta.priorities priority}. If deltas have different priorities, their importance is resolved
+ * {@link engine.model.delta.priorities priority}. If deltas have different priorities, their importance is resolved
  * automatically and overwrites this flag.
- * @returns {Array.<engine.treeModel.delta.Delta>} Result of the transformation.
+ * @returns {Array.<engine.model.delta.Delta>} Result of the transformation.
  */
 export default function transform( a, b, isAMoreImportantThanB ) {
 	const transformAlgorithm = getTransformationCase( a, b ) || defaultTransform;
@@ -65,15 +65,15 @@ function updateBaseVersion( baseVersion, deltas ) {
  * This algorithm is similar to popular `dOPT` algorithm used in operational transformation, as we are in fact
  * transforming two sets of operations by each other.
  *
- * @external engine.treeModel.delta.transform
- * @function engine.treeModel.delta.transform.defaultTransform
- * @param {engine.treeModel.delta.Delta} a Delta that will be transformed.
- * @param {engine.treeModel.delta.Delta} b Delta to transform by.
+ * @external engine.model.delta.transform
+ * @function engine.model.delta.transform.defaultTransform
+ * @param {engine.model.delta.Delta} a Delta that will be transformed.
+ * @param {engine.model.delta.Delta} b Delta to transform by.
  * @param {Boolean} isAMoreImportantThanB Flag indicating whether the delta which will be transformed (`a`) should be treated
  * as more important when resolving conflicts. Note that this flag is used only if provided deltas have same
- * {@link engine.treeModel.delta.priorities priority}. If deltas have different priorities, their importance is resolved
+ * {@link engine.model.delta.priorities priority}. If deltas have different priorities, their importance is resolved
  * automatically and overwrites this flag.
- * @returns {Array.<engine.treeModel.delta.Delta>} Result of the transformation, that is an array with single delta instance.
+ * @returns {Array.<engine.model.delta.Delta>} Result of the transformation, that is an array with single delta instance.
  */
 export function defaultTransform( a, b, isAMoreImportantThanB ) {
 	// First, resolve the flag real value.
@@ -163,8 +163,8 @@ export function defaultTransform( a, b, isAMoreImportantThanB ) {
 /**
  * Adds a special case callback for given delta classes.
  *
- * @external engine.treeModel.delta.transform
- * @function engine.treeModel.delta.transform.addTransformationCase
+ * @external engine.model.delta.transform
+ * @function engine.model.delta.transform.addTransformationCase
  * @param {Function} A Delta constructor which instance will get transformed.
  * @param {Function} B Delta constructor which instance will be transformed by.
  * @param {Function} resolver A callback that will handle custom special case transformation for instances of given delta classes.
@@ -181,12 +181,12 @@ export function addTransformationCase( A, B, resolver ) {
 }
 
 /**
- * Gets a special case callback which was previously {@link engine.treeModel.delta.transform.addTransformationCase added}.
+ * Gets a special case callback which was previously {@link engine.model.delta.transform.addTransformationCase added}.
  *
- * @external engine.treeModel.delta.transform
- * @function engine.treeModel.delta.transform.getTransformationCase
- * @param {engine.treeModel.delta.Delta} a Delta to transform.
- * @param {engine.treeModel.delta.Delta} b Delta to be transformed by.
+ * @external engine.model.delta.transform
+ * @function engine.model.delta.transform.getTransformationCase
+ * @param {engine.model.delta.Delta} a Delta to transform.
+ * @param {engine.model.delta.Delta} b Delta to be transformed by.
  */
 export function getTransformationCase( a, b ) {
 	let casesA = specialCases.get( a.constructor );

+ 16 - 6
packages/ckeditor5-engine/src/treemodel/delta/unwrapdelta.js

@@ -6,6 +6,7 @@
 'use strict';
 
 import Delta from './delta.js';
+import DeltaFactory from './deltafactory.js';
 import WrapDelta from './wrapdelta.js';
 import { register } from '../batch.js';
 import Position from '../position.js';
@@ -15,16 +16,16 @@ import CKEditorError from '../../../utils/ckeditorerror.js';
 
 /**
  * @classdesc
- * To provide specific OT behavior and better collisions solving, {@link engine.treeModel.Batch#merge} method
+ * To provide specific OT behavior and better collisions solving, {@link engine.model.Batch#merge} method
  * uses the `UnwrapDelta` class which inherits from the `Delta` class and may overwrite some methods.
  *
- * @memberOf engine.treeModel.delta
+ * @memberOf engine.model.delta
  */
 export default class UnwrapDelta extends Delta {
 	/**
 	 * Position before unwrapped element or `null` if there are no operations in the delta.
 	 *
-	 * @type {engine.treeModel.Position|null}
+	 * @type {engine.model.Position|null}
 	 */
 	get position() {
 		return this._moveOperation ? this._moveOperation.targetPosition : null;
@@ -34,7 +35,7 @@ export default class UnwrapDelta extends Delta {
 	 * Operation in the delta that moves unwrapped nodes to their new parent or `null` if there are no operations in the delta.
 	 *
 	 * @protected
-	 * @type {engine.treeModel.operation.MoveOperation|null}
+	 * @type {engine.model.operation.MoveOperation|null}
 	 */
 	get _moveOperation() {
 		return this.operations[ 0 ] || null;
@@ -44,6 +45,13 @@ export default class UnwrapDelta extends Delta {
 		return WrapDelta;
 	}
 
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.delta.UnwrapDelta';
+	}
+
 	static get _priority() {
 		return 10;
 	}
@@ -54,8 +62,8 @@ export default class UnwrapDelta extends Delta {
  * error if you try to unwrap an element that does not have a parent.
  *
  * @chainable
- * @method engine.treeModel.Batch#unwrap
- * @param {engine.treeModel.Element} position Element to unwrap.
+ * @method engine.model.Batch#unwrap
+ * @param {engine.model.Element} position Element to unwrap.
  */
 register( 'unwrap', function( element ) {
 	if ( element.parent === null ) {
@@ -85,3 +93,5 @@ register( 'unwrap', function( element ) {
 
 	return this;
 } );
+
+DeltaFactory.register( UnwrapDelta );

+ 22 - 12
packages/ckeditor5-engine/src/treemodel/delta/weakinsertdelta.js

@@ -7,36 +7,44 @@
 
 import InsertDelta from './insertdelta.js';
 import { register } from '../batch.js';
+import DeltaFactory from './deltafactory.js';
 import InsertOperation from '../operation/insertoperation.js';
 import NodeList from '../nodelist.js';
 
 /**
  * @classdesc
- * To provide specific OT behavior and better collisions solving, the {@link engine.treeModel.Batch#insert} method
+ * To provide specific OT behavior and better collisions solving, the {@link engine.model.Batch#insert} method
  * uses the `WeakInsertDelta` class which inherits from the `Delta` class and may overwrite some methods.
  *
- * @memberOf engine.treeModel.delta
+ * @memberOf engine.model.delta
  */
-export default class WeakInsertDelta extends InsertDelta {}
+export default class WeakInsertDelta extends InsertDelta {
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.delta.WeakInsertDelta';
+	}
+}
 
 /**
- * Inserts a node or nodes at the given position. {@link engine.treeModel.Batch#weakInsert weakInsert} is commonly used for actions
+ * Inserts a node or nodes at the given position. {@link engine.model.Batch#weakInsert weakInsert} is commonly used for actions
  * like typing or plain-text paste (without formatting). There are two differences between
- * {@link engine.treeModel.Batch#insert insert} and {@link engine.treeModel.Batch#weakInsert weakInsert}:
+ * {@link engine.model.Batch#insert insert} and {@link engine.model.Batch#weakInsert weakInsert}:
  *
  * * When using `weakInsert`, inserted nodes will have same attributes as the current attributes of
- * {@link engine.treeModel.Document#selection document selection}.
+ * {@link engine.model.Document#selection document selection}.
  * * Normal behavior is that inserting inside range changed by
- * {@link engine.treeModel.operation.AttributeOperation AttributeOperation} splits
+ * {@link engine.model.operation.AttributeOperation AttributeOperation} splits
  * the operation into two operations, which "omit" the inserted nodes. The correct behavior for `WeakInsertDelta` is that
- * {@link engine.treeModel.operation.AttributeOperation AttributeOperation} does not "break" and also
+ * {@link engine.model.operation.AttributeOperation AttributeOperation} does not "break" and also
  * applies attributes for inserted nodes.
- * The above has to be reflected during {@link engine.treeModel.operation.transform operational transformation}.
+ * The above has to be reflected during {@link engine.model.operation.transform operational transformation}.
  *
  * @chainable
- * @method engine.treeModel.Batch#weakInsert
- * @param {engine.treeModel.Position} position Position of insertion.
- * @param {engine.treeModel.NodeSet} nodes The list of nodes to be inserted.
+ * @method engine.model.Batch#weakInsert
+ * @param {engine.model.Position} position Position of insertion.
+ * @param {engine.model.NodeSet} nodes The list of nodes to be inserted.
  */
 register( 'weakInsert', function( position, nodes ) {
 	const delta = new WeakInsertDelta();
@@ -54,3 +62,5 @@ register( 'weakInsert', function( position, nodes ) {
 
 	return this;
 } );
+
+DeltaFactory.register( WeakInsertDelta );

+ 16 - 9
packages/ckeditor5-engine/src/treemodel/delta/wrapdelta.js

@@ -6,6 +6,7 @@
 'use strict';
 
 import Delta from './delta.js';
+import DeltaFactory from './deltafactory.js';
 import UnwrapDelta from './unwrapdelta.js';
 import { register } from '../batch.js';
 import Position from '../position.js';
@@ -17,16 +18,16 @@ import CKEditorError from '../../../utils/ckeditorerror.js';
 
 /**
  * @classdesc
- * To provide specific OT behavior and better collisions solving, {@link engine.treeModel.Batch#merge} method
+ * To provide specific OT behavior and better collisions solving, {@link engine.model.Batch#merge} method
  * uses the `WrapDelta` class which inherits from the `Delta` class and may overwrite some methods.
  *
- * @memberOf engine.treeModel.delta
+ * @memberOf engine.model.delta
  */
 export default class WrapDelta extends Delta {
 	/**
 	 * Range to wrap or `null` if there are no operations in the delta.
 	 *
-	 * @type {engine.treeModel.Range|null}
+	 * @type {engine.model.Range|null}
 	 */
 	get range() {
 		let moveOp = this._moveOperation;
@@ -49,7 +50,7 @@ export default class WrapDelta extends Delta {
 	 * Operation that inserts wrapping element or `null` if there are no operations in the delta.
 	 *
 	 * @protected
-	 * @type {engine.treeModel.operation.InsertOperation|engine.treeModel.operation.ReinsertOperation}
+	 * @type {engine.model.operation.InsertOperation|engine.model.operation.ReinsertOperation}
 	 */
 	get _insertOperation() {
 		return this.operations[ 0 ] || null;
@@ -59,7 +60,7 @@ export default class WrapDelta extends Delta {
 	 * Operation that moves wrapped nodes to their new parent or `null` if there are no operations in the delta.
 	 *
 	 * @protected
-	 * @type {engine.treeModel.operation.MoveOperation|null}
+	 * @type {engine.model.operation.MoveOperation|null}
 	 */
 	get _moveOperation() {
 		return this.operations[ 1 ] || null;
@@ -69,6 +70,10 @@ export default class WrapDelta extends Delta {
 		return UnwrapDelta;
 	}
 
+	static get className() {
+		return 'engine.model.delta.WrapDelta';
+	}
+
 	static get _priority() {
 		return 10;
 	}
@@ -76,12 +81,12 @@ export default class WrapDelta extends Delta {
 
 /**
  * Wraps given range with given element or with a new element of specified name if string has been passed.
- * **Note:** given range should be a "flat range" (see {@link engine.treeModel.Range#isFlat}). If not, error will be thrown.
+ * **Note:** given range should be a "flat range" (see {@link engine.model.Range#isFlat}). If not, error will be thrown.
  *
  * @chainable
- * @method engine.treeModel.Batch#wrap
- * @param {engine.treeModel.Range} range Range to wrap.
- * @param {engine.treeModel.Element|String} elementOrString Element or name of element to wrap the range with.
+ * @method engine.model.Batch#wrap
+ * @param {engine.model.Range} range Range to wrap.
+ * @param {engine.model.Element|String} elementOrString Element or name of element to wrap the range with.
  */
 register( 'wrap', function( range, elementOrString ) {
 	if ( !range.isFlat ) {
@@ -127,3 +132,5 @@ register( 'wrap', function( range, elementOrString ) {
 
 	return this;
 } );
+
+DeltaFactory.register( WrapDelta );

+ 59 - 49
packages/ckeditor5-engine/src/treemodel/document.js

@@ -20,34 +20,34 @@ import Schema from './schema.js';
 import Composer from './composer/composer.js';
 import clone from '../../utils/lib/lodash/clone.js';
 
-const graveyardSymbol = Symbol( 'graveyard' );
+const graveyardName = '$graveyard';
 
 /**
  * Document tree model describes all editable data in the editor. It may contain multiple
- * {@link engine.treeModel.Document#roots root elements}, for example if the editor have multiple editable areas, each area will be
+ * {@link engine.model.Document#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 engine.treeModel.operation.Operation operations}. To create operations in
- * the simple way use use the {@link engine.treeModel.Batch} API, for example:
+ * All changes in the document are done by {@link engine.model.operation.Operation operations}. To create operations in
+ * the simple way use use the {@link engine.model.Batch} API, for example:
  *
  *		doc.batch().insert( position, nodes ).split( otherPosition );
  *
- * @see engine.treeModel.Document#batch
+ * @see engine.model.Document#batch
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class Document {
 	/**
-	 * Creates an empty document instance with no {@link engine.treeModel.Document#roots} (other than graveyard).
+	 * Creates an empty document instance with no {@link engine.model.Document#roots} (other than graveyard).
 	 */
 	constructor() {
 		/**
 		 * 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 engine.treeModel.operation.Operation#baseVersion} will
+		 * operations are applied on the proper document version. If the {@link engine.model.operation.Operation#baseVersion} will
 		 * not match document version the {@link document-applyOperation-wrong-version} error is thrown.
 		 *
 		 * @readonly
-		 * @member {Number} engine.treeModel.Document#version
+		 * @member {Number} engine.model.Document#version
 		 */
 		this.version = 0;
 
@@ -55,14 +55,14 @@ export default class Document {
 		 * Selection done on this document.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.Selection} engine.treeModel.Document#selection
+		 * @member {engine.model.Selection} engine.model.Document#selection
 		 */
 		this.selection = new Selection( this );
 
 		/**
 		 * Schema for this document.
 		 *
-		 * @member {engine.treeModel.Schema} engine.treeModel.Document#schema
+		 * @member {engine.model.Schema} engine.model.Document#schema
 		 */
 		this.schema = new Schema();
 
@@ -71,25 +71,25 @@ export default class Document {
 		 *
 		 * The features can tune up these tools to better work on their specific cases.
 		 *
-		 * @member {engine.treeModel.composer.Composer} engine.treeModel.Document#composer
+		 * @member {engine.model.composer.Composer} engine.model.Document#composer
 		 */
 		this.composer = new Composer();
 
 		/**
-		 * Array of pending changes. See: {@link engine.treeModel.Document#enqueueChanges}.
+		 * Array of pending changes. See: {@link engine.model.Document#enqueueChanges}.
 		 *
 		 * @private
-		 * @member {Array.<Function>} engine.treeModel.Document#_pendingChanges
+		 * @member {Array.<Function>} engine.model.Document#_pendingChanges
 		 */
 		this._pendingChanges = [];
 
 		/**
-		 * List of roots that are owned and managed by this document. Use {@link engine.treeModel.document#createRoot} and
-		 * {@link engine.treeModel.document#getRoot} to manipulate it.
+		 * List of roots that are owned and managed by this document. Use {@link engine.model.document#createRoot} and
+		 * {@link engine.model.document#getRoot} to manipulate it.
 		 *
 		 * @readonly
 		 * @protected
-		 * @member {Map} engine.treeModel.Document#roots
+		 * @member {Map} engine.model.Document#roots
 		 */
 		this._roots = new Map();
 
@@ -103,13 +103,13 @@ export default class Document {
 		} );
 
 		// Graveyard tree root. Document always have a graveyard root, which stores removed nodes.
-		this.createRoot( graveyardSymbol );
+		this.createRoot( graveyardName );
 
 		/**
 		 * Document's history.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.History} engine.treeModel.Document#history
+		 * @member {engine.model.History} engine.model.Document#history
 		 */
 		this.history = new History();
 	}
@@ -118,29 +118,29 @@ export default class Document {
 	 * Graveyard tree root. Document always have a graveyard root, which stores removed nodes.
 	 *
 	 * @readonly
-	 * @type {engine.treeModel.RootElement}
+	 * @type {engine.model.RootElement}
 	 */
 	get graveyard() {
-		return this.getRoot( graveyardSymbol );
+		return this.getRoot( graveyardName );
 	}
 
 	/**
-	 * Gets names of all roots (without the {@link engine.treeModel.Document#graveyard}).
+	 * Gets names of all roots (without the {@link engine.model.Document#graveyard}).
 	 *
 	 * @readonly
 	 * @type {Iterable.<String>}
 	 */
 	get rootNames() {
-		return Array.from( this._roots.keys() ).filter( ( name ) => name != graveyardSymbol );
+		return Array.from( this._roots.keys() ).filter( ( name ) => name != graveyardName );
 	}
 
 	/**
 	 * This is the entry point for all document changes. All changes on the document are done using
-	 * {@link engine.treeModel.operation.Operation operations}. To create operations in the simple way use the
-	 * {@link engine.treeModel.Batch} API available via {@link engine.treeModel.Document#batch} method.
+	 * {@link engine.model.operation.Operation operations}. To create operations in the simple way use the
+	 * {@link engine.model.Batch} API available via {@link engine.model.Document#batch} method.
 	 *
-	 * @fires @link engine.treeModel.Document#change
-	 * @param {engine.treeModel.operation.Operation} operation Operation to be applied.
+	 * @fires @link engine.model.Document#change
+	 * @param {engine.model.operation.Operation} operation Operation to be applied.
 	 */
 	applyOperation( operation ) {
 		if ( operation.baseVersion !== this.version ) {
@@ -148,7 +148,7 @@ export default class Document {
 			 * Only operations with matching versions can be applied.
 			 *
 			 * @error document-applyOperation-wrong-version
-			 * @param {engine.treeModel.operation.Operation} operation
+			 * @param {engine.model.operation.Operation} operation
 			 */
 			throw new CKEditorError(
 				'document-applyOperation-wrong-version: Only operations with matching versions can be applied.',
@@ -170,9 +170,9 @@ export default class Document {
 	}
 
 	/**
-	 * Creates a {@link engine.treeModel.Batch} instance which allows to change the document.
+	 * Creates a {@link engine.model.Batch} instance which allows to change the document.
 	 *
-	 * @returns {engine.treeModel.Batch} Batch instance.
+	 * @returns {engine.model.Batch} Batch instance.
 	 */
 	batch() {
 		return new Batch( this );
@@ -185,7 +185,7 @@ export default class Document {
 	 * @param {String} [elementName='$root'] Element name. Defaults to `'$root'` which also have
 	 * some basic schema defined (`$block`s are allowed inside the `$root`). Make sure to define a proper
 	 * schema if you use a different name.
-	 * @returns {engine.treeModel.RootElement} Created root.
+	 * @returns {engine.model.RootElement} Created root.
 	 */
 	createRoot( rootName, elementName = '$root' ) {
 		if ( this._roots.has( rootName ) ) {
@@ -193,7 +193,7 @@ export default class Document {
 			 * Root with specified name already exists.
 			 *
 			 * @error document-createRoot-name-exists
-			 * @param {engine.treeModel.Document} doc
+			 * @param {engine.model.Document} doc
 			 * @param {String} name
 			 */
 			throw new CKEditorError(
@@ -202,7 +202,7 @@ export default class Document {
 			);
 		}
 
-		const root = new RootElement( this, elementName );
+		const root = new RootElement( this, elementName, rootName );
 		this._roots.set( rootName, root );
 
 		return root;
@@ -217,14 +217,14 @@ export default class Document {
 	}
 
 	/**
-	 * Enqueues document changes. Any changes to be done on document (mostly using {@link engine.treeModel.Document#batch}
+	 * Enqueues document changes. Any changes to be done on document (mostly using {@link engine.model.Document#batch}
 	 * should be placed in the queued callback. If no other plugin is changing document at the moment, the callback will be
 	 * called immediately. Otherwise it will wait for all previously queued changes to finish happening. This way
 	 * queued callback will not interrupt other callbacks.
 	 *
-	 * When all queued changes are done {@link engine.treeModel.Document#changesDone} event is fired.
+	 * When all queued changes are done {@link engine.model.Document#changesDone} event is fired.
 	 *
-	 * @fires @link engine.treeModel.Document#changesDone
+	 * @fires @link engine.model.Document#changesDone
 	 * @param {Function} callback Callback to enqueue.
 	 */
 	enqueueChanges( callback ) {
@@ -244,7 +244,7 @@ export default class Document {
 	 * Returns top-level root by its name.
 	 *
 	 * @param {String|Symbol} name Unique root name.
-	 * @returns {engine.treeModel.RootElement} Root registered under given name.
+	 * @returns {engine.model.RootElement} Root registered under given name.
 	 */
 	getRoot( name ) {
 		if ( !this._roots.has( name ) ) {
@@ -264,6 +264,16 @@ export default class Document {
 	}
 
 	/**
+	 * Checks if root with given name is defined.
+	 *
+	 * @param {String} name Name of root to check.
+	 * @returns {Boolean}
+	 */
+	hasRoot( name ) {
+		return this._roots.has( name );
+	}
+
+	/**
 	 * Custom toJSON method to solve child-parent circular dependencies.
 	 *
 	 * @returns {Object} Clone of this object with the document property changed to string.
@@ -272,18 +282,18 @@ export default class Document {
 		const json = clone( this );
 
 		// Due to circular references we need to remove parent reference.
-		json.selection = '[engine.treeModel.Selection]';
+		json.selection = '[engine.model.Selection]';
 
 		return {};
 	}
 
 	/**
 	 * Returns default root for this document which is either the first root that was added to the the document using
-	 * {@link engine.treeModel.Document#createRoot} or the {@link engine.treeModel.Document#graveyard graveyard root} if
+	 * {@link engine.model.Document#createRoot} or the {@link engine.model.Document#graveyard graveyard root} if
 	 * no other roots were created.
 	 *
 	 * @protected
-	 * @returns {engine.treeModel.RootElement} The default root for this document.
+	 * @returns {engine.model.RootElement} The default root for this document.
 	 */
 	_getDefaultRoot() {
 		for ( let root of this._roots.values() ) {
@@ -311,29 +321,29 @@ export default class Document {
 	 * * 'removeRootAttribute' when attribute for root is removed,
 	 * * 'changeRootAttribute' when attribute for root changes.
 	 *
-	 * @event engine.treeModel.Document.change
+	 * @event engine.model.Document.change
 	 * @param {String} type Change type, possible option: 'insert', 'remove', 'reinsert', 'move', 'attribute'.
 	 * @param {Object} data Additional information about the change.
-	 * @param {engine.treeModel.Range} data.range Range in model containing changed nodes. Note that the range state is
-	 * after changes has been done, i.e. for 'remove' the range will be in the {@link engine.treeModel.Document#graveyard graveyard root}.
+	 * @param {engine.model.Range} data.range Range in model containing changed nodes. Note that the range state is
+	 * after changes has been done, i.e. for 'remove' the range will be in the {@link engine.model.Document#graveyard graveyard root}.
 	 * This is `undefined` for "...root..." types.
-	 * @param {engine.treeModel.Position} [data.sourcePosition] Change source position. Exists for 'remove', 'reinsert' and 'move'.
+	 * @param {engine.model.Position} [data.sourcePosition] Change source position. Exists for 'remove', 'reinsert' and 'move'.
 	 * Note that this position state is before changes has been done, i.e. for 'reinsert' the source position will be in the
-	 * {@link engine.treeModel.Document#graveyard graveyard root}.
+	 * {@link engine.model.Document#graveyard graveyard root}.
 	 * @param {String} [data.key] Only for attribute types. Key of changed / inserted / removed attribute.
 	 * @param {*} [data.oldValue] Only for 'removeAttribute', 'removeRootAttribute', 'changeAttribute' or
 	 * 'changeRootAttribute' type.
 	 * @param {*} [data.newValue] Only for 'addAttribute', 'addRootAttribute', 'changeAttribute' or
 	 * 'changeRootAttribute' type.
-	 * @param {engine.treeModel.RootElement} [changeInfo.root] Root element which attributes got changed. This is defined
+	 * @param {engine.model.RootElement} [changeInfo.root] Root element which attributes got changed. This is defined
 	 * only for root types.
-	 * @param {engine.treeModel.Batch} batch A {@link engine.treeModel.Batch batch} of changes which this change is a part of.
+	 * @param {engine.model.Batch} batch A {@link engine.model.Batch batch} of changes which this change is a part of.
 	 */
 
 	/**
-	 * Fired when all queued document changes are done. See {@link engine.treeModel.Document#enqueueChanges}.
+	 * Fired when all queued document changes are done. See {@link engine.model.Document#enqueueChanges}.
 	 *
-	 * @event engine.treeModel.Document#changesDone
+	 * @event engine.model.Document#changesDone
 	 */
 }
 

+ 12 - 12
packages/ckeditor5-engine/src/treemodel/documentfragment.js

@@ -11,20 +11,20 @@ import NodeList from './nodelist.js';
  * DocumentFragment represents a part of Tree Model which does not have a common root but it's top level nodes
  * can be seen as siblings.
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class DocumentFragment {
 	/**
 	 * Creates empty DocumentFragment.
 	 *
-	 * @param {engine.treeModel.NodeSet} children List of nodes contained inside the DocumentFragment.
+	 * @param {engine.model.NodeSet} children List of nodes contained inside the DocumentFragment.
 	 */
 	constructor( children ) {
 		/**
 		 * List of nodes contained inside the DocumentFragment.
 		 *
 		 * @protected
-		 * @member {engine.treeModel.NodeSet} engine.treeModel.DocumentFragment#_children
+		 * @member {engine.model.NodeSet} engine.model.DocumentFragment#_children
 		 */
 		this._children = new NodeList();
 
@@ -34,17 +34,17 @@ export default class DocumentFragment {
 	}
 
 	/**
-	 * `DocumentFragment` iterator. Returns {@link engine.treeModel.Node nodes} that are added to the `DocumentFragment`.
+	 * `DocumentFragment` iterator. Returns {@link engine.model.Node nodes} that are added to the `DocumentFragment`.
 	 */
 	[ Symbol.iterator ]() {
 		return this._children[ Symbol.iterator ]();
 	}
 
 	/**
-	 * The root of `DocumentFragment`. Returns itself. Added for compatibility reasons with {@link engine.treeModel.Element}.
+	 * The root of `DocumentFragment`. Returns itself. Added for compatibility reasons with {@link engine.model.Element}.
 	 *
 	 * @readonly
-	 * @type {engine.treeModel.DocumentFragment}
+	 * @type {engine.model.DocumentFragment}
 	 */
 	get root() {
 		return this;
@@ -52,7 +52,7 @@ export default class DocumentFragment {
 
 	/**
 	 * Returns path to the `DocumentFragment` This is always equal to empty array and is added for compatibility reasons
-	 * with {@link engine.treeModel.Element}.
+	 * with {@link engine.model.Element}.
 	 *
 	 * @returns {Array} The path.
 	 */
@@ -64,7 +64,7 @@ export default class DocumentFragment {
 	 * Gets child at the given index.
 	 *
 	 * @param {Number} index Index of child.
-	 * @returns {engine.treeModel.Node} Child node.
+	 * @returns {engine.model.Node} Child node.
 	 */
 	getChild( index ) {
 		return this._children.get( index );
@@ -82,7 +82,7 @@ export default class DocumentFragment {
 	/**
 	 * Gets index of the given child node.
 	 *
-	 * @param {engine.treeModel.Node} node Child node.
+	 * @param {engine.model.Node} node Child node.
 	 * @returns {Number} Index of the child node.
 	 */
 	getChildIndex( node ) {
@@ -92,7 +92,7 @@ export default class DocumentFragment {
 	/**
 	 * Inserts a child node or a list of child nodes at the end of this DocumentFragment.
 	 *
-	 * @param {engine.treeModel.NodeSet} nodes The list of nodes to be inserted.
+	 * @param {engine.model.NodeSet} nodes The list of nodes to be inserted.
 	 */
 	appendChildren( nodes ) {
 		this.insertChildren( this.getChildCount(), nodes );
@@ -102,7 +102,7 @@ export default class DocumentFragment {
 	 * Inserts a list of child nodes on the given index and sets the parent of these nodes to this DocumentFragment.
 	 *
 	 * @param {Number} index Position where nodes should be inserted.
-	 * @param {engine.treeModel.NodeSet} nodes The list of nodes to be inserted.
+	 * @param {engine.model.NodeSet} nodes The list of nodes to be inserted.
 	 */
 	insertChildren( index, nodes ) {
 		let nodeList = new NodeList( nodes );
@@ -124,7 +124,7 @@ export default class DocumentFragment {
 	 *
 	 * @param {Number} index Position of the first node to remove.
 	 * @param {Number} [howMany=1] Number of nodes to remove.
-	 * @returns {engine.treeModel.NodeList} The list of removed nodes.
+	 * @returns {engine.model.NodeList} The list of removed nodes.
 	 */
 	removeChildren( index, howMany = 1 ) {
 		let nodeList = this._children.remove( index, howMany );

+ 49 - 15
packages/ckeditor5-engine/src/treemodel/element.js

@@ -14,7 +14,7 @@ import toMap from '../../utils/tomap.js';
 /**
  * Tree data model element.
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class Element extends Node {
 	/**
@@ -22,8 +22,8 @@ export default class Element extends Node {
 	 *
 	 * @param {String} name Node name.
 	 * @param {Iterable} [attrs] Iterable collection of attributes.
-	 * @param {engine.treeModel.NodeSet} [children] List of nodes to be inserted.
-	 * into created element. List of nodes can be of any type accepted by the {@link engine.treeModel.NodeList} constructor.
+	 * @param {engine.model.NodeSet} [children] List of nodes to be inserted.
+	 * into created element. List of nodes can be of any type accepted by the {@link engine.model.NodeList} constructor.
 	 */
 	constructor( name, attrs, children ) {
 		super( attrs );
@@ -32,7 +32,7 @@ export default class Element extends Node {
 		 * Element name.
 		 *
 		 * @readonly
-		 * @member {String} engine.treeModel.Element#name
+		 * @member {String} engine.model.Element#name
 		 */
 		this.name = name;
 
@@ -40,7 +40,7 @@ export default class Element extends Node {
 		 * List of children nodes.
 		 *
 		 * @protected
-		 * @member {engine.treeModel.NodeList} engine.treeModel.Element#_children
+		 * @member {engine.model.NodeList} engine.model.Element#_children
 		 */
 		this._children = new NodeList();
 
@@ -53,7 +53,7 @@ export default class Element extends Node {
 	 * Gets child at the given index.
 	 *
 	 * @param {Number} index Index of child.
-	 * @returns {engine.treeModel.Node} Child node.
+	 * @returns {engine.model.Node} Child node.
 	 */
 	getChild( index ) {
 		return this._children.get( index );
@@ -71,7 +71,7 @@ export default class Element extends Node {
 	/**
 	 * Gets index of the given child node.
 	 *
-	 * @param {engine.treeModel.Node} node Child node.
+	 * @param {engine.model.Node} node Child node.
 	 * @returns {Number} Index of the child node.
 	 */
 	getChildIndex( node ) {
@@ -79,13 +79,13 @@ export default class Element extends Node {
 	}
 
 	/**
-	 * {@link engine.treeModel.Element#insert Inserts} a child node or a list of child nodes at the end of this node and sets
+	 * {@link engine.model.Element#insert Inserts} a child node or a list of child nodes at the end of this node 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 engine.treeModel.operation.InsertOperation}.
+	 * All attached nodes should be modified using the {@link engine.model.operation.InsertOperation}.
 	 *
-	 * @param {engine.treeModel.NodeSet} nodes The list of nodes to be inserted.
+	 * @param {engine.model.NodeSet} nodes The list of nodes to be inserted.
 	 */
 	appendChildren( nodes ) {
 		this.insertChildren( this.getChildCount(), nodes );
@@ -95,10 +95,10 @@ export default class Element extends Node {
 	 * 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 engine.treeModel.operation.InsertOperation}.
+	 * All attached nodes should be modified using the {@link engine.model.operation.InsertOperation}.
 	 *
 	 * @param {Number} index Position where nodes should be inserted.
-	 * @param {engine.treeModel.NodeSet} nodes The list of nodes to be inserted.
+	 * @param {engine.model.NodeSet} nodes The list of nodes to be inserted.
 	 */
 	insertChildren( index, nodes ) {
 		let nodeList = new NodeList( nodes );
@@ -119,11 +119,11 @@ export default class Element extends Node {
 	 * 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 engine.treeModel.operation.RemoveOperation}.
+	 * All attached nodes should be modified using the {@link engine.model.operation.RemoveOperation}.
 	 *
 	 * @param {Number} index Position of the first node to remove.
 	 * @param {Number} [howMany=1] Number of nodes to remove.
-	 * @returns {engine.treeModel.NodeList} The list of removed nodes.
+	 * @returns {engine.model.NodeList} The list of removed nodes.
 	 */
 	removeChildren( index, howMany = 1 ) {
 		let nodeList = this._children.remove( index, howMany );
@@ -148,7 +148,7 @@ export default class Element extends Node {
 	/**
 	 * Removes all attributes from the element and sets given attributes.
 	 *
-	 * @param {Iterable|Object} attrs Iterable object containing attributes to be set. See {@link engine.treeModel.Node#getAttributes}.
+	 * @param {Iterable|Object} attrs Iterable object containing attributes to be set. See {@link engine.model.Node#getAttributes}.
 	 */
 	setAttributesTo( attrs ) {
 		this._attrs = toMap( attrs );
@@ -197,4 +197,38 @@ export default class Element extends Node {
 
 		return text;
 	}
+
+	/**
+	 * Custom toJSON method to solve child-parent circular dependencies.
+	 *
+	 * @returns {Object} Clone of this object with the parent property replaced with its name.
+	 */
+	toJSON() {
+		let json = super.toJSON();
+
+		if ( this._children.length ) {
+			json.children = this._children.toJSON();
+		}
+
+		json.name = this.name;
+
+		return json;
+	}
+
+	/**
+	 * Creates Element object from deserilized object, ie. from parsed JSON string.
+	 *
+	 *		let deserialized = JSON.parse( JSON.stringify( someElementObject ) );
+	 *		let element = NodeList.fromJSON( deserialized );
+	 *
+	 * @param {Object} json
+	 * @returns {engine.model.Element}
+	 */
+	static fromJSON( json ) {
+		if ( json.children ) {
+			return new Element( json.name, json.attributes, NodeList.fromJSON( json.children ) );
+		}
+
+		return new Element( json.name, json.attributes );
+	}
 }

+ 14 - 14
packages/ckeditor5-engine/src/treemodel/history.js

@@ -13,11 +13,11 @@ import transform from './delta/transform.js';
 import CKEditorError from '../../utils/ckeditorerror.js';
 
 /**
- * History keeps the track of all the deltas applied to the {@link engine.treeModel.Document document} and provides
+ * History keeps the track of all the deltas applied to the {@link engine.model.Document document} and provides
  * utility tools to operate on the history. Most of times history is needed to transform a delta that has wrong
- * {@link engine.treeModel.delta.Delta#baseVersion} to a state where it can be applied to the document.
+ * {@link engine.model.delta.Delta#baseVersion} to a state where it can be applied to the document.
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class History {
 	/**
@@ -28,16 +28,16 @@ export default class History {
 		 * Deltas added to the history.
 		 *
 		 * @private
-		 * @member {Array.<engine.treeModel.delta.Delta>} engine.treeModel.History#_deltas
+		 * @member {Array.<engine.model.delta.Delta>} engine.model.History#_deltas
 		 */
 		this._deltas = [];
 
 		/**
-		 * Helper structure that maps added delta's base version to the index in {@link engine.treeModel.History#_deltas}
+		 * Helper structure that maps added delta's base version to the index in {@link engine.model.History#_deltas}
 		 * at which the delta was added.
 		 *
 		 * @private
-		 * @member {Map} engine.treeModel.History#_historyPoints
+		 * @member {Map} engine.model.History#_historyPoints
 		 */
 		this._historyPoints = new Map();
 	}
@@ -57,7 +57,7 @@ export default class History {
 	/**
 	 * Adds an operation to the history.
 	 *
-	 * @param {engine.treeModel.operation.Operation} operation Operation to add.
+	 * @param {engine.model.operation.Operation} operation Operation to add.
 	 */
 	addOperation( operation ) {
 		const delta = operation.delta;
@@ -78,10 +78,10 @@ export default class History {
 	/**
 	 * Transforms out-dated delta by all deltas that were added to the history since the given delta's base version. In other
 	 * words, it makes the delta up-to-date with the history. The transformed delta(s) is (are) ready to be applied
-	 * to the {@link engine.treeModel.Document document}.
+	 * to the {@link engine.model.Document document}.
 	 *
-	 * @param {engine.treeModel.delta.Delta} delta Delta to update.
-	 * @returns {Array.<engine.treeModel.delta.Delta>} Result of transformation which is an array containing one or more deltas.
+	 * @param {engine.model.delta.Delta} delta Delta to update.
+	 * @returns {Array.<engine.model.delta.Delta>} Result of transformation which is an array containing one or more deltas.
 	 */
 	getTransformedDelta( delta ) {
 		if ( delta.baseVersion === this._nextHistoryPoint ) {
@@ -108,7 +108,7 @@ export default class History {
 	 * Returns all deltas from history, starting from given history point (if passed).
 	 *
 	 * @param {Number} from History point.
-	 * @returns {Iterator.<engine.treeModel.delta.Delta>} Deltas from given history point to the end of history.
+	 * @returns {Iterator.<engine.model.delta.Delta>} Deltas from given history point to the end of history.
 	 */
 	*getDeltas( from = 0 ) {
 		let i = this._historyPoints.get( from );
@@ -126,9 +126,9 @@ export default class History {
 	 * Transforms given delta by another given delta. Exposed for testing purposes.
 	 *
 	 * @protected
-	 * @param {engine.treeModel.delta.Delta} toTransform Delta to be transformed.
-	 * @param {engine.treeModel.delta.Delta} transformBy Delta to transform by.
-	 * @returns {Array.<engine.treeModel.delta.Delta>} Result of the transformation.
+	 * @param {engine.model.delta.Delta} toTransform Delta to be transformed.
+	 * @param {engine.model.delta.Delta} transformBy Delta to transform by.
+	 * @returns {Array.<engine.model.delta.Delta>} Result of the transformation.
 	 */
 	static _transform( toTransform, transformBy ) {
 		return transform( toTransform, transformBy, false );

+ 10 - 0
packages/ckeditor5-engine/src/model/item.jsdoc

@@ -0,0 +1,10 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/**
+ * Item is a {@link engine.model.Node Node} or {engine.model.TextProxy TextProxy}.
+ *
+ * @typedef {engine.model.Node|engine.model.TextProxy} engine.model.Item
+ */

+ 32 - 32
packages/ckeditor5-engine/src/treemodel/liveposition.js

@@ -13,25 +13,25 @@ import mix from '../../utils/mix.js';
 import CKEditorError from '../../utils/ckeditorerror.js';
 
 /**
- * LivePosition is a position in {@link engine.treeModel.Document Document} that updates itself as Document is changed
+ * LivePosition is a position in {@link engine.model.Document Document} that updates itself as Document is changed
  * through operations. It may be used as a bookmark in the Document.
- * **Note:** Contrary to {@link engine.treeModel.Position}, LivePosition works only in roots that are
- * {@link engine.treeModel.RootElement}. If {@link engine.treeModel.DocumentFragment} is passed, error will be thrown.
+ * **Note:** Contrary to {@link engine.model.Position}, LivePosition works only in roots that are
+ * {@link engine.model.RootElement}. If {@link engine.model.DocumentFragment} is passed, error will be thrown.
  * **Note:** Be very careful when dealing with LivePosition. Each LivePosition instance bind events that might
- * have to be unbound. Use {@link engine.treeModel.LivePosition#detach} whenever you don't need LivePosition anymore.
+ * have to be unbound. Use {@link engine.model.LivePosition#detach} whenever you don't need LivePosition anymore.
  *
- * @memberOf engine.treeModel
- * @extends engine.treeModel.Position
+ * @memberOf engine.model
+ * @extends engine.model.Position
  */
 export default class LivePosition extends Position {
 	/**
 	 * Creates a live position.
 	 *
-	 * @see engine.treeModel.Position
-	 * @param {engine.treeModel.RootElement} root
+	 * @see engine.model.Position
+	 * @param {engine.model.RootElement} root
 	 * @param {Array.<Number>} path
-	 * @param {engine.treeModel.PositionStickiness} [stickiness] Defaults to `'STICKS_TO_NEXT'`.
-	 * See {@link engine.treeModel.LivePosition#stickiness}.
+	 * @param {engine.model.PositionStickiness} [stickiness] Defaults to `'STICKS_TO_NEXT'`.
+	 * See {@link engine.model.LivePosition#stickiness}.
 	 */
 	constructor( root, path, stickiness ) {
 		if ( !( root instanceof RootElement ) ) {
@@ -63,7 +63,7 @@ export default class LivePosition extends Position {
 		 *		- | sticks to previous node: `<p>f|[oo]</p><p>b^ar</p>` => `<p>f|</p><p>booar</p>`
 		 *		- | sticks to next node: `<p>f|[oo]</p><p>b^ar</p>` => `<p>f</p><p>b|ooar</p>`
 		 *
-		 * @member {engine.treeModel.PositionStickiness} engine.treeModel.LivePosition#stickiness
+		 * @member {engine.model.PositionStickiness} engine.model.LivePosition#stickiness
 		 */
 		this.stickiness = stickiness || 'STICKS_TO_NEXT';
 
@@ -81,44 +81,44 @@ export default class LivePosition extends Position {
 
 	/**
 	 * @static
-	 * @method engine.treeModel.LivePosition.createAfter
-	 * @see engine.treeModel.Position.createAfter
-	 * @param {engine.treeModel.Node} node
-	 * @returns {engine.treeModel.LivePosition}
+	 * @method engine.model.LivePosition.createAfter
+	 * @see engine.model.Position.createAfter
+	 * @param {engine.model.Node} node
+	 * @returns {engine.model.LivePosition}
 	 */
 
 	/**
 	 * @static
-	 * @method engine.treeModel.LivePosition.createBefore
-	 * @see engine.treeModel.Position.createBefore
-	 * @param {engine.treeModel.Node} node
-	 * @returns {engine.treeModel.LivePosition}
+	 * @method engine.model.LivePosition.createBefore
+	 * @see engine.model.Position.createBefore
+	 * @param {engine.model.Node} node
+	 * @returns {engine.model.LivePosition}
 	 */
 
 	/**
 	 * @static
-	 * @method engine.treeModel.LivePosition.createFromParentAndOffset
-	 * @see engine.treeModel.Position.createFromParentAndOffset
-	 * @param {engine.treeModel.Element} parent
+	 * @method engine.model.LivePosition.createFromParentAndOffset
+	 * @see engine.model.Position.createFromParentAndOffset
+	 * @param {engine.model.Element} parent
 	 * @param {Number} offset
-	 * @returns {engine.treeModel.LivePosition}
+	 * @returns {engine.model.LivePosition}
 	 */
 
 	/**
 	 * @static
-	 * @method engine.treeModel.LivePosition.createFromPosition
-	 * @see engine.treeModel.Position.createFromPosition
-	 * @param {engine.treeModel.Position} position
-	 * @returns {engine.treeModel.LivePosition}
+	 * @method engine.model.LivePosition.createFromPosition
+	 * @see engine.model.Position.createFromPosition
+	 * @param {engine.model.Position} position
+	 * @returns {engine.model.LivePosition}
 	 */
 }
 
 /**
- * Binds this LivePosition to the {@link engine.treeModel.Document} that owns this position {@link engine.treeModel.RootElement root}.
+ * Binds this LivePosition to the {@link engine.model.Document} that owns this position {@link engine.model.RootElement root}.
  *
  * @ignore
  * @private
- * @method engine.treeModel.LivePosition.bindWithDocument
+ * @method engine.model.LivePosition.bindWithDocument
  */
 function bindWithDocument() {
 	/*jshint validthis: true */
@@ -140,8 +140,8 @@ function bindWithDocument() {
  * @private
  * @method transform
  * @param {String} type Type of changes applied to the Tree Model.
- * @param {engine.treeModel.Range} range Range containing the result of applied change.
- * @param {engine.treeModel.Position} [position] Additional position parameter provided by some change events.
+ * @param {engine.model.Range} range Range containing the result of applied change.
+ * @param {engine.model.Position} [position] Additional position parameter provided by some change events.
  */
 function transform( type, range, position ) {
 	/*jshint validthis: true */
@@ -186,6 +186,6 @@ mix( LivePosition, EmitterMixin );
  * Enum representing how position is "sticking" with their neighbour nodes.
  * Possible values: `'STICKS_TO_NEXT'`, `'STICKS_TO_PREVIOUS'`.
  *
- * @typedef {String} engine.treeModel.PositionStickiness
+ * @typedef {String} engine.model.PositionStickiness
  */
 

+ 25 - 25
packages/ckeditor5-engine/src/treemodel/liverange.js

@@ -13,15 +13,15 @@ import mix from '../../utils/mix.js';
  * LiveRange is a Range in the Tree Model that updates itself as the tree changes. It may be used as a bookmark.
  *
  * **Note:** Be very careful when dealing with `LiveRange`. Each `LiveRange` instance bind events that might
- * have to be unbound. Use {@link engine.treeModel.LiveRange#detach detach} whenever you don't need `LiveRange` anymore.
+ * have to be unbound. Use {@link engine.model.LiveRange#detach detach} whenever you don't need `LiveRange` anymore.
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class LiveRange extends Range {
 	/**
 	 * Creates a live range.
 	 *
-	 * @see engine.treeModel.Range
+	 * @see engine.model.Range
 	 */
 	constructor( start, end ) {
 		super( start, end );
@@ -39,48 +39,48 @@ export default class LiveRange extends Range {
 	}
 
 	/**
-	 * @see engine.treeModel.Range.createFromElement
+	 * @see engine.model.Range.createFromElement
 	 * @static
-	 * @method engine.treeModel.LiveRange.createFromElement
-	 * @param {engine.treeModel.Element} element
-	 * @returns {engine.treeModel.LiveRange}
+	 * @method engine.model.LiveRange.createFromElement
+	 * @param {engine.model.Element} element
+	 * @returns {engine.model.LiveRange}
 	 */
 
 	/**
-	 * @see engine.treeModel.Range.createFromPositionAndShift
+	 * @see engine.model.Range.createFromPositionAndShift
 	 * @static
-	 * @method engine.treeModel.LiveRange.createFromPositionAndShift
-	 * @param {engine.treeModel.Position} position
+	 * @method engine.model.LiveRange.createFromPositionAndShift
+	 * @param {engine.model.Position} position
 	 * @param {Number} shift
-	 * @returns {engine.treeModel.LiveRange}
+	 * @returns {engine.model.LiveRange}
 	 */
 
 	/**
-	 * @see engine.treeModel.Range.createFromParentsAndOffsets
+	 * @see engine.model.Range.createFromParentsAndOffsets
 	 * @static
-	 * @method engine.treeModel.LiveRange.createFromParentsAndOffsets
-	 * @param {engine.treeModel.Element} startElement
+	 * @method engine.model.LiveRange.createFromParentsAndOffsets
+	 * @param {engine.model.Element} startElement
 	 * @param {Number} startOffset
-	 * @param {engine.treeModel.Element} endElement
+	 * @param {engine.model.Element} endElement
 	 * @param {Number} endOffset
-	 * @returns {engine.treeModel.LiveRange}
+	 * @returns {engine.model.LiveRange}
 	 */
 
 	/**
-	 * @see engine.treeModel.Range.createFromRange
+	 * @see engine.model.Range.createFromRange
 	 * @static
-	 * @method engine.treeModel.LiveRange.createFromRange
-	 * @param {engine.treeModel.Range} range
-	 * @returns {engine.treeModel.LiveRange}
+	 * @method engine.model.LiveRange.createFromRange
+	 * @param {engine.model.Range} range
+	 * @returns {engine.model.LiveRange}
 	 */
 }
 
 /**
- * Binds this LiveRange to the {@link engine.treeModel.Document} that owns this range.
+ * Binds this LiveRange to the {@link engine.model.Document} that owns this range.
  *
  * @ignore
  * @private
- * @method engine.treeModel.LiveRange#bindWithDocument
+ * @method engine.model.LiveRange#bindWithDocument
  */
 function bindWithDocument() {
 	/*jshint validthis: true */
@@ -96,7 +96,7 @@ function bindWithDocument() {
 }
 
 /**
- * LiveRange boundaries are instances of {@link engine.treeModel.LivePosition}, so it is updated thanks to them. This method
+ * LiveRange boundaries are instances of {@link engine.model.LivePosition}, so it is updated thanks to them. This method
  * additionally fixes the results of updating live positions taking into account that those live positions
  * are boundaries of a range. An example case for fixing live positions is end boundary is moved before start boundary.
  *
@@ -104,8 +104,8 @@ function bindWithDocument() {
  * @private
  * @method fixBoundaries
  * @param {String} type Type of changes applied to the Tree Model.
- * @param {engine.treeModel.Range} range Range containing the result of applied change.
- * @param {engine.treeModel.Position} [position] Additional position parameter provided by some change events.
+ * @param {engine.model.Range} range Range containing the result of applied change.
+ * @param {engine.model.Position} [position] Additional position parameter provided by some change events.
  */
 function fixBoundaries( type, range, position ) {
 	/* jshint validthis: true */

+ 1 - 1
packages/ckeditor5-engine/src/treeview/treeview.jsdoc

@@ -4,5 +4,5 @@
  */
 
 /**
- * @namespace engine.treeView
+ * @namespace engine.model
  */

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

@@ -5,14 +5,13 @@
 
 'use strict';
 
-import clone from '../../utils/lib/lodash/clone.js';
 import toMap from '../../utils/tomap.js';
 import CKEditorError from '../../utils/ckeditorerror.js';
 
 /**
  * Tree model node. This is an abstract class for other classes representing different nodes in Tree Model.
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class Node {
 	/**
@@ -28,7 +27,7 @@ export default class Node {
 		 * Element or DocumentFragment that is a parent of this node.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.Element|engine.treeModel.DocumentFragment|null} engine.treeModel.Node#parent
+		 * @member {engine.model.Element|engine.model.DocumentFragment|null} engine.model.Node#parent
 		 */
 		this.parent = null;
 
@@ -36,11 +35,11 @@ export default class Node {
 		 * List of attributes set on this node.
 		 *
 		 * **Note:** It is **important** that attributes of nodes already attached to the document must be changed
-		 * only by an {@link engine.treeModel.operation.AttributeOperation}. Do not set attributes of such nodes
-		 * using {@link engine.treeModel.Node} methods.
+		 * only by an {@link engine.model.operation.AttributeOperation}. Do not set attributes of such nodes
+		 * using {@link engine.model.Node} methods.
 		 *
 		 * @protected
-		 * @member {Map} engine.treeModel.Node#_attrs
+		 * @member {Map} engine.model.Node#_attrs
 		 */
 		this._attrs = toMap( attrs );
 	}
@@ -68,7 +67,7 @@ export default class Node {
 	 * Nodes next sibling or `null` if it is the last child.
 	 *
 	 * @readonly
-	 * @type {engine.treeModel.Node|null}
+	 * @type {engine.model.Node|null}
 	 */
 	get nextSibling() {
 		const index = this.getIndex();
@@ -80,7 +79,7 @@ export default class Node {
 	 * Nodes previous sibling or null if it is the last child.
 	 *
 	 * @readonly
-	 * @type {engine.treeModel.Node|null}
+	 * @type {engine.model.Node|null}
 	 */
 	get previousSibling() {
 		const index = this.getIndex();
@@ -92,7 +91,7 @@ export default class Node {
 	 * The top parent for the node. If node has no parent it is the root itself.
 	 *
 	 * @readonly
-	 * @type {engine.treeModel.Element}
+	 * @type {engine.model.Element}
 	 */
 	get root() {
 		let root = this;
@@ -132,7 +131,7 @@ export default class Node {
 
 	/**
 	 * 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 engine.treeModel.Position}.
+	 * will be `[ 1, 2 ]`. This path can be used as a parameter of {@link engine.model.Position}.
 	 *
 	 * @returns {Number[]} The path.
 	 */
@@ -183,10 +182,11 @@ export default class Node {
 	 * @returns {Object} Clone of this object with the parent property replaced with its name.
 	 */
 	toJSON() {
-		const json = clone( this );
+		let json = {};
 
-		// Due to circular references we need to remove parent reference.
-		json.parent = this.parent ? this.parent.name : null;
+		if ( this._attrs.size ) {
+			json.attributes = [ ...this._attrs ];
+		}
 
 		return json;
 	}

+ 74 - 43
packages/ckeditor5-engine/src/treemodel/nodelist.js

@@ -7,22 +7,22 @@
 
 import CharacterProxy from './characterproxy.js';
 import Text from './text.js';
+import Element from './element.js';
 import DocumentFragment from './documentfragment.js';
 import mapsEqual from '../../utils/mapsequal.js';
 import isIterable from '../../utils/isiterable.js';
-import clone from '../../utils/lib/lodash/clone.js';
 import CKEditorError from '../../utils/ckeditorerror.js';
 
 /**
- * This is a private helper-class for {@link engine.treeModel.NodeList} text compression utility.
+ * This is a private helper-class for {@link engine.model.NodeList} text compression utility.
  *
  * @protected
- * @memberOf engine.treeModel
- * @extends engine.treeModel.Text
+ * @memberOf engine.model
+ * @extends engine.model.Text
  */
 class NodeListText extends Text {
 	/**
-	 * @see engine.treeModel.Text#constructor
+	 * @see engine.model.Text#constructor
 	 * @protected
 	 * @constructor
 	 */
@@ -32,47 +32,34 @@ class NodeListText extends Text {
 		/**
 		 * Element that contains character nodes represented by this NodeListText.
 		 *
-		 * @type {engine.treeModel.Element|engine.treeModel.DocumentFragment|null}
+		 * @type {engine.model.Element|engine.model.DocumentFragment|null}
 		 */
 		this.parent = null;
 	}
 
 	/**
-	 * Gets a character at given index and creates a {@link engine.treeModel.CharacterProxy} out of it.
+	 * Gets a character at given index and creates a {@link engine.model.CharacterProxy} out of it.
 	 *
 	 * @param {Number} index Character index.
-	 * @returns {engine.treeModel.CharacterProxy}
+	 * @returns {engine.model.CharacterProxy}
 	 */
 	getCharAt( index ) {
 		index = index && index >= 0 ? index : 0;
 
 		return new CharacterProxy( this, index );
 	}
-
-	/**
-	 * Custom toJSON method to solve child-parent circular dependencies.
-	 *
-	 * @returns {Object} Clone of this object with the parent property replaced with its name.
-	 */
-	toJSON() {
-		const json = clone( this );
-
-		json.parent = json.parent ? this.parent.name : null;
-
-		return json;
-	}
 }
 
 /**
  * List of nodes. It is used to represent multiple nodes with a given order, for example children of
- * {@link engine.treeModel.Element} object or nodes inserted using {@link engine.treeModel.operation.InsertOperation}.
+ * {@link engine.model.Element} object or nodes inserted using {@link engine.model.operation.InsertOperation}.
  *
  * Thanks to the constructor, which accepts various arguments, this class lets you easily create desired list of nodes.
  *
- * Parameters passed to constructor are converted and internally kept as an array of {@link engine.treeModel.Node}
- * and {@link engine.treeModel.Text} instances.
+ * Parameters passed to constructor are converted and internally kept as an array of {@link engine.model.Node}
+ * and {@link engine.model.Text} instances.
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class NodeList {
 	/**
@@ -101,9 +88,9 @@ export default class NodeList {
 	 *		nodeListA === nodeListB // true
 	 *		nodeListB.length // 3
 	 *
-	 * @see engine.treeModel.NodeSet
+	 * @see engine.model.NodeSet
 	 *
-	 * @param {engine.treeModel.NodeSet} nodes List of nodes.
+	 * @param {engine.model.NodeSet} nodes List of nodes.
 	 * @constructor
 	 */
 	constructor( nodes ) {
@@ -118,7 +105,7 @@ export default class NodeList {
 		 * Internal array to store nodes.
 		 *
 		 * @protected
-		 * @member {Array} engine.treeModel.NodeList#_nodes
+		 * @member {Array} engine.model.NodeList#_nodes
 		 */
 		this._nodes = [];
 
@@ -128,7 +115,7 @@ export default class NodeList {
 		 * which occupy multiple slots in `_indexMap`.
 		 *
 		 * @private
-		 * @member {Array} engine.treeModel.NodeList#_indexMap
+		 * @member {Array} engine.model.NodeList#_indexMap
 		 */
 		this._indexMap = [];
 
@@ -200,7 +187,7 @@ export default class NodeList {
 	 * Returns node at the given index.
 	 *
 	 * @param {Number} index Node index.
-	 * @returns {engine.treeModel.Node} Node at given index.
+	 * @returns {engine.model.Node} Node at given index.
 	 */
 	get( index ) {
 		let realIndex = this._indexMap[ index ];
@@ -216,7 +203,7 @@ export default class NodeList {
 	/**
 	 * Search for the element in the node list.
 	 *
-	 * @param {engine.treeModel.Node} node Node to find.
+	 * @param {engine.model.Node} node Node to find.
 	 * @returns {Number} Position of the element in the list or -1 if not found.
 	 */
 	indexOf( node ) {
@@ -235,7 +222,7 @@ export default class NodeList {
 	 * 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 {engine.treeModel.NodeList} nodeList List of nodes to insert.
+	 * @param {engine.model.NodeList} nodeList List of nodes to insert.
 	 */
 	insert( index, nodeList ) {
 		if ( this._nodes.length === 0 ) {
@@ -275,7 +262,7 @@ export default class NodeList {
 	 *
 	 * @param {Number} index Position of the first node to remove.
 	 * @param {Number} number Number of nodes to remove.
-	 * @returns {engine.treeModel.NodeList} List of removed nodes.
+	 * @returns {engine.model.NodeList} List of removed nodes.
 	 */
 	remove( index, number ) {
 		if ( this._nodes.length === 0 ) {
@@ -293,7 +280,7 @@ export default class NodeList {
 
 		this._indexMap.splice( index, number );
 
-		for ( let i = index; i < this._indexMap.length ; i++ ) {
+		for ( let i = index; i < this._indexMap.length; i++ ) {
 			this._indexMap[ i ] -= removed.length;
 		}
 
@@ -354,6 +341,50 @@ export default class NodeList {
 	}
 
 	/**
+	 * Custom toJSON method to solve child-parent circular dependencies.
+	 *
+	 * @returns {Object} Clone of this object with the parent property replaced with its name.
+	 */
+	toJSON() {
+		if ( !this._nodes.length ) {
+			return {};
+		}
+
+		let json = { nodes: [] };
+
+		for ( let node of this._nodes ) {
+			json.nodes.push( node.toJSON() );
+		}
+
+		return json;
+	}
+
+	/**
+	 * Creates NodeList object from deserilized object, ie. from parsed JSON string.
+	 *
+	 *		let deserialized = JSON.parse( JSON.stringify( someNodeList ) );
+	 *		let nodeList = NodeList.fromJSON( deserialized );
+	 *
+	 * @param {Object} json Deserialized JSON object.
+	 * @returns {engine.model.NodeList}
+	 */
+	static fromJSON( json ) {
+		let nodes = [];
+
+		if ( json.nodes ) {
+			for ( let node of json.nodes ) {
+				if ( node.text ) {
+					nodes.push( new Text( node.text, node.attributes ) );
+				} else {
+					nodes.push( Element.fromJSON( node ) );
+				}
+			}
+		}
+
+		return new NodeList( nodes );
+	}
+
+	/**
 	 * Checks whether given index is inside a text and if so, splits that text node. This method should be used
 	 * to split text objects whenever there are some changes made on a part of text object (i.e. removing part of text,
 	 * inserting between text object, changing attributes of part of a text object).
@@ -425,7 +456,7 @@ export default class NodeList {
 			// Remove text node after index.
 			this._nodes.splice( realIndexAfter, 1 );
 
-			for ( let i = index; i < this._indexMap.length ; i++ ) {
+			for ( let i = index; i < this._indexMap.length; i++ ) {
 				this._indexMap[ i ]--;
 			}
 		}
@@ -445,19 +476,19 @@ export default class NodeList {
 }
 
 /**
- * Value that is convertible to an item kept in {@link engine.treeModel.NodeList} or an iterable collection of such items.
- * In other words, this is anything that {@link engine.treeModel.NodeList#constructor} is able to take and convert to node:
- * * {@link engine.treeModel.Node} will be left as is
- * * {@link engine.treeModel.Text} and {String} will be converted to a set of {@link engine.treeModel.CharacterProxy}
- * * {@link engine.treeModel.NodeList} will clone a node list (but not the nodes inside, so the new and passed list will
+ * Value that is convertible to an item kept in {@link engine.model.NodeList} or an iterable collection of such items.
+ * In other words, this is anything that {@link engine.model.NodeList#constructor} is able to take and convert to node:
+ * * {@link engine.model.Node} will be left as is
+ * * {@link engine.model.Text} and {String} will be converted to a set of {@link engine.model.CharacterProxy}
+ * * {@link engine.model.NodeList} will clone a node list (but not the nodes inside, so the new and passed list will
  * point to the same nodes.
  * * Iterable collection of above items will be iterated over and all items will be added to the node list.
  *
- * @typedef {engine.treeModel.Node|engine.treeModel.Text|String|engine.treeModel.NodeList|engine.treeModel.DocumentFragment|Iterable}
- * engine.treeModel.NodeSet
+ * @typedef {engine.model.Node|engine.model.Text|String|engine.model.NodeList|engine.model.DocumentFragment|Iterable}
+ * engine.model.NodeSet
  */
 
-// Helper function that "flattens" `engine.treeModel.DocumentFragment`.
+// Helper function that "flattens" `engine.model.DocumentFragment`.
 function* getNodes( nodes ) {
 	for ( let node of nodes ) {
 		if ( node instanceof DocumentFragment ) {

+ 30 - 12
packages/ckeditor5-engine/src/treemodel/operation/attributeoperation.js

@@ -12,8 +12,8 @@ import CKEditorError from '../../../utils/ckeditorerror.js';
 /**
  * Operation to change nodes' attribute. Using this class you can add, remove or change value of the attribute.
  *
- * @memberOf engine.treeModel.operation
- * @extends engine.treeModel.operation.Operation
+ * @memberOf engine.model.operation
+ * @extends engine.model.operation.Operation
  */
 export default class AttributeOperation extends Operation {
 	/**
@@ -28,11 +28,11 @@ export default class AttributeOperation extends Operation {
 	 * 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 {engine.treeModel.Range} range Range on which the operation should be applied.
+	 * @param {engine.model.Range} range Range on which the operation should be applied.
 	 * @param {String} key Key of an attribute to change or remove.
 	 * @param {*} oldValue Old value of the attribute with given key or `null` if adding a new attribute.
 	 * @param {*} newValue New value to set for the attribute. If `null`, then the operation just removes the attribute.
-	 * @param {Number} baseVersion {@link engine.treeModel.Document#version} on which the operation can be applied.
+	 * @param {Number} baseVersion {@link engine.model.Document#version} on which the operation can be applied.
 	 */
 	constructor( range, key, oldValue, newValue, baseVersion ) {
 		super( baseVersion );
@@ -41,7 +41,7 @@ export default class AttributeOperation extends Operation {
 		 * Range on which operation should be applied.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.Range} engine.treeModel.operation.AttributeOperation#range
+		 * @member {engine.model.Range} engine.model.operation.AttributeOperation#range
 		 */
 		this.range = Range.createFromRange( range );
 
@@ -49,7 +49,7 @@ export default class AttributeOperation extends Operation {
 		 * Key of an attribute to change or remove.
 		 *
 		 * @readonly
-		 * @member {String} engine.treeModel.operation.AttributeOperation#key
+		 * @member {String} engine.model.operation.AttributeOperation#key
 		 */
 		this.key = key;
 
@@ -57,7 +57,7 @@ export default class AttributeOperation extends Operation {
 		 * Old value of the attribute with given key or `null` if adding a new attribute.
 		 *
 		 * @readonly
-		 * @member {*} engine.treeModel.operation.AttributeOperation#oldValue
+		 * @member {*} engine.model.operation.AttributeOperation#oldValue
 		 */
 		this.oldValue = oldValue;
 
@@ -65,7 +65,7 @@ export default class AttributeOperation extends Operation {
 		 * New value to set for the attribute. If `null`, then the operation just removes the attribute.
 		 *
 		 * @readonly
-		 * @member {*} engine.treeModel.operation.AttributeOperation#newValue
+		 * @member {*} engine.model.operation.AttributeOperation#newValue
 		 */
 		this.newValue = newValue;
 	}
@@ -81,14 +81,14 @@ export default class AttributeOperation extends Operation {
 	}
 
 	/**
-	 * @returns {engine.treeModel.operation.AttributeOperation}
+	 * @returns {engine.model.operation.AttributeOperation}
 	 */
 	clone() {
 		return new AttributeOperation( this.range, this.key, this.oldValue, this.newValue, this.baseVersion );
 	}
 
 	/**
-	 * @returns {engine.treeModel.operation.AttributeOperation}
+	 * @returns {engine.model.operation.AttributeOperation}
 	 */
 	getReversed() {
 		return new AttributeOperation( this.range, this.key, this.newValue, this.oldValue, this.baseVersion + 1 );
@@ -101,7 +101,7 @@ export default class AttributeOperation extends Operation {
 				 * The attribute which should be removed does not exists for the given node.
 				 *
 				 * @error operation-attribute-no-attr-to-remove
-				 * @param {engine.treeModel.Item} item
+				 * @param {engine.model.Item} item
 				 * @param {String} key
 				 * @param {*} value
 				 */
@@ -116,7 +116,7 @@ export default class AttributeOperation extends Operation {
 				 * The attribute with given key already exists for the given node.
 				 *
 				 * @error operation-attribute-attr-exists
-				 * @param {engine.treeModel.Node} node
+				 * @param {engine.model.Node} node
 				 * @param {String} key
 				 */
 				throw new CKEditorError(
@@ -134,4 +134,22 @@ export default class AttributeOperation extends Operation {
 
 		return { range: this.range, key: this.key, oldValue: this.oldValue, newValue: this.newValue };
 	}
+
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.operation.AttributeOperation';
+	}
+
+	/**
+	 * Creates AttributeOperation object from deserilized object, i.e. from parsed JSON string.
+	 *
+	 * @param {Object} json Deserialized JSON object.
+	 * @param {engine.model.Document} document Document on which this operation will be applied.
+	 * @returns {engine.model.operation.AttributeOperation}
+	 */
+	static fromJSON( json, document ) {
+		return new AttributeOperation( Range.fromJSON( json.range, document ), json.key, json.oldValue, json.newValue, json.baseVersion );
+	}
 }

+ 28 - 10
packages/ckeditor5-engine/src/treemodel/operation/insertoperation.js

@@ -14,17 +14,17 @@ import RemoveOperation from './removeoperation.js';
 /**
  * Operation to insert list of nodes on the given position in the tree data model.
  *
- * @memberOf engine.treeModel.operation
- * @extends engine.treeModel.operation.Operation
+ * @memberOf engine.model.operation
+ * @extends engine.model.operation.Operation
  */
 export default class InsertOperation extends Operation {
 	/**
 	 * Creates an insert operation.
 	 *
-	 * @param {engine.treeModel.Position} position Position of insertion.
-	 * @param {engine.treeModel.NodeSet} nodes The list of nodes to be inserted.
-	 * List of nodes can be any type accepted by the {@link engine.treeModel.NodeList} constructor.
-	 * @param {Number} baseVersion {@link engine.treeModel.Document#version} on which operation can be applied.
+	 * @param {engine.model.Position} position Position of insertion.
+	 * @param {engine.model.NodeSet} nodes The list of nodes to be inserted.
+	 * List of nodes can be any type accepted by the {@link engine.model.NodeList} constructor.
+	 * @param {Number} baseVersion {@link engine.model.Document#version} on which operation can be applied.
 	 */
 	constructor( position, nodes, baseVersion ) {
 		super( baseVersion );
@@ -33,7 +33,7 @@ export default class InsertOperation extends Operation {
 		 * Position of insertion.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.Position} engine.treeModel.operation.InsertOperation#position
+		 * @member {engine.model.Position} engine.model.operation.InsertOperation#position
 		 */
 		this.position = Position.createFromPosition( position );
 
@@ -41,7 +41,7 @@ export default class InsertOperation extends Operation {
 		 * List of nodes to insert.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.NodeList} engine.treeModel.operation.InsertOperation#nodeList
+		 * @member {engine.model.NodeList} engine.model.operation.InsertOperation#nodeList
 		 */
 		this.nodeList = new NodeList( nodes );
 	}
@@ -51,14 +51,14 @@ export default class InsertOperation extends Operation {
 	}
 
 	/**
-	 * @returns {engine.treeModel.operation.InsertOperation}
+	 * @returns {engine.model.operation.InsertOperation}
 	 */
 	clone() {
 		return new InsertOperation( this.position, this.nodeList, this.baseVersion );
 	}
 
 	/**
-	 * @returns {engine.treeModel.operation.RemoveOperation}
+	 * @returns {engine.model.operation.RemoveOperation}
 	 */
 	getReversed() {
 		return new RemoveOperation( this.position, this.nodeList.length, this.baseVersion + 1 );
@@ -71,4 +71,22 @@ export default class InsertOperation extends Operation {
 			range: Range.createFromPositionAndShift( this.position, this.nodeList.length )
 		};
 	}
+
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.operation.InsertOperation';
+	}
+
+	/**
+	 * Creates InsertOperation object from deserilized object, i.e. from parsed JSON string.
+	 *
+	 * @param {Object} json Deserialized JSON object.
+	 * @param {engine.model.Document} document Document on which this operation will be applied.
+	 * @returns {engine.model.operation.InsertOperation}
+	 */
+	static fromJSON( json, document ) {
+		return new InsertOperation( Position.fromJSON( json.position, document ), NodeList.fromJSON( json.nodeList ), json.baseVersion );
+	}
 }

+ 37 - 16
packages/ckeditor5-engine/src/treemodel/operation/moveoperation.js

@@ -14,17 +14,17 @@ import compareArrays from '../../../utils/comparearrays.js';
 /**
  * Operation to move list of subsequent nodes from one position in the document to another.
  *
- * @memberOf engine.treeModel.operation
- * @extends engine.treeModel.operation.Operation
+ * @memberOf engine.model.operation
+ * @extends engine.model.operation.Operation
  */
 export default class MoveOperation extends Operation {
 	/**
 	 * Creates a move operation.
 	 *
-	 * @param {engine.treeModel.Position} sourcePosition Position before the first node to move.
+	 * @param {engine.model.Position} sourcePosition Position before the first node to move.
 	 * @param {Number} howMany How many consecutive nodes to move, starting from `sourcePosition`.
-	 * @param {engine.treeModel.Position} targetPosition Position where moved nodes will be inserted.
-	 * @param {Number} baseVersion {@link engine.treeModel.Document#version} on which operation can be applied.
+	 * @param {engine.model.Position} targetPosition Position where moved nodes will be inserted.
+	 * @param {Number} baseVersion {@link engine.model.Document#version} on which operation can be applied.
 	 */
 	constructor( sourcePosition, howMany, targetPosition, baseVersion ) {
 		super( baseVersion );
@@ -32,29 +32,29 @@ export default class MoveOperation extends Operation {
 		/**
 		 * Source move position.
 		 *
-		 * @member {engine.treeModel.Position} engine.treeModel.operation.MoveOperation#sourcePosition
+		 * @member {engine.model.Position} engine.model.operation.MoveOperation#sourcePosition
 		 */
 		this.sourcePosition = Position.createFromPosition( sourcePosition );
 
 		/**
 		 * How many nodes to move.
 		 *
-		 * @member {Number} engine.treeModel.operation.MoveOperation#howMany
+		 * @member {Number} engine.model.operation.MoveOperation#howMany
 		 */
 		this.howMany = howMany;
 
 		/**
 		 * Target move position.
 		 *
-		 * @member {engine.treeModel.Position} engine.treeModel.operation.MoveOperation#targetPosition
+		 * @member {engine.model.Position} engine.model.operation.MoveOperation#targetPosition
 		 */
 		this.targetPosition = Position.createFromPosition( targetPosition );
 
 		/**
 		 * Position of the start of the moved range after it got moved. This may be different than
-		 * {@link engine.treeModel.operation.MoveOperation#targetPosition} in some cases, i.e. when a range is moved
-		 * inside the same parent but {@link engine.treeModel.operation.MoveOperation#targetPosition targetPosition}
-		 * is after {@link engine.treeModel.operation.MoveOperation#sourcePosition sourcePosition}.
+		 * {@link engine.model.operation.MoveOperation#targetPosition} in some cases, i.e. when a range is moved
+		 * inside the same parent but {@link engine.model.operation.MoveOperation#targetPosition targetPosition}
+		 * is after {@link engine.model.operation.MoveOperation#sourcePosition sourcePosition}.
 		 *
 		 *		 vv              vv
 		 *		abcdefg ===> adefbcg
@@ -62,17 +62,17 @@ export default class MoveOperation extends Operation {
 		 *		     targetPos	movedRangeStart
 		 *		     offset 6	offset 4
 		 *
-		 * @member {engine.treeModel.Position} engine.treeModel.operation.MoveOperation#movedRangeStart
+		 * @member {engine.model.Position} engine.model.operation.MoveOperation#movedRangeStart
 		 */
 		this.movedRangeStart = this.targetPosition.getTransformedByDeletion( this.sourcePosition, this.howMany );
 
 		/**
 		 * Defines whether `MoveOperation` is sticky. If `MoveOperation` is sticky, during
-		 * {@link engine.treeModel.operation.transform operational transformation} if there will be an operation that
+		 * {@link engine.model.operation.transform operational transformation} if there will be an operation that
 		 * inserts some nodes at the position equal to the boundary of this `MoveOperation`, that operation will
 		 * get their insertion path updated to the position where this `MoveOperation` moves the range.
 		 *
-		 * @member {Boolean} engine.treeModel.operation.MoveOperation#isSticky
+		 * @member {Boolean} engine.model.operation.MoveOperation#isSticky
 		 */
 		this.isSticky = false;
 	}
@@ -82,7 +82,7 @@ export default class MoveOperation extends Operation {
 	}
 
 	/**
-	 * @returns {engine.treeModel.operation.MoveOperation}
+	 * @returns {engine.model.operation.MoveOperation}
 	 */
 	clone() {
 		const op = new this.constructor( this.sourcePosition, this.howMany, this.targetPosition, this.baseVersion );
@@ -92,7 +92,7 @@ export default class MoveOperation extends Operation {
 	}
 
 	/**
-	 * @returns {engine.treeModel.operation.MoveOperation}
+	 * @returns {engine.model.operation.MoveOperation}
 	 */
 	getReversed() {
 		let newTargetPosition = this.sourcePosition.getTransformedByInsertion( this.targetPosition, this.howMany );
@@ -172,4 +172,25 @@ export default class MoveOperation extends Operation {
 			range: Range.createFromPositionAndShift( this.movedRangeStart, this.howMany )
 		};
 	}
+
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.operation.MoveOperation';
+	}
+
+	/**
+	 * Creates MoveOperation object from deserilized object, i.e. from parsed JSON string.
+	 *
+	 * @param {Object} json Deserialized JSON object.
+	 * @param {engine.model.Document} document Document on which this operation will be applied.
+	 * @returns {engine.model.operation.MoveOperation}
+	 */
+	static fromJSON( json, document ) {
+		let sourcePosition = Position.fromJSON( json.sourcePosition, document );
+		let targetPosition = Position.fromJSON( json.targetPosition, document );
+
+		return new MoveOperation( sourcePosition, json.howMany, targetPosition, json.baseVersion );
+	}
 }

+ 12 - 5
packages/ckeditor5-engine/src/treemodel/operation/nooperation.js

@@ -13,22 +13,22 @@ import Operation from './operation.js';
  * It still has some parameters defined for transformation purposes.
  *
  * In most cases this operation is a result of transforming operations. When transformation returns
- * {@link engine.treeModel.operation.NoOperation} it means that changes done by the transformed operation
+ * {@link engine.model.operation.NoOperation} it means that changes done by the transformed operation
  * have already been applied.
  *
- * @memberOf engine.treeModel.operation
- * @extends engine.treeModel.operation.Operation
+ * @memberOf engine.model.operation
+ * @extends engine.model.operation.Operation
  */
 export default class NoOperation extends Operation {
 	/**
-	 * @returns {engine.treeModel.operation.NoOperation}
+	 * @returns {engine.model.operation.NoOperation}
 	 */
 	clone() {
 		return new NoOperation( this.baseVersion );
 	}
 
 	/**
-	 * @returns {engine.treeModel.operation.NoOperation}
+	 * @returns {engine.model.operation.NoOperation}
 	 */
 	getReversed() {
 		return new NoOperation( this.baseVersion + 1 );
@@ -37,4 +37,11 @@ export default class NoOperation extends Operation {
 	_execute() {
 		// Do nothing.
 	}
+
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.operation.NoOperation';
+	}
 }

+ 113 - 0
packages/ckeditor5-engine/src/model/operation/operation.js

@@ -0,0 +1,113 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+import clone from '../../../utils/lib/lodash/clone.js';
+
+/**
+ * Abstract base operation class.
+ *
+ * @abstract
+ * @memberOf engine.model.operation
+ */
+export default class Operation {
+	/**
+	 * Base operation constructor.
+	 * @param {Number} baseVersion {@link engine.model.Document#version} on which the operation can be applied.
+	 */
+	constructor( baseVersion ) {
+		/**
+		 * {@link engine.model.Document#version} on which operation can be applied. If you try to
+		 * {@link engine.model.Document#applyOperation apply} operation with different base version than the
+		 * {@link engine.model.Document#version document version} the {@link document-applyOperation-wrong-version}
+		 * error is thrown.
+		 *
+		 * @member {Number} engine.model.operation.Operation#baseVersion
+		 */
+		this.baseVersion = baseVersion;
+
+		/**
+		 * Operation type.
+		 *
+		 * @member {String} engine.model.operation.Operation#type
+		 */
+
+		/**
+		 * {@link engine.model.Delta Delta} which the operation is a part of. This property is set by the
+		 * {@link engine.model.Delta delta} when the operations is added to it by the
+		 * {@link engine.model.Delta#addOperation} method.
+		 *
+		 * @member {engine.model.Delta} engine.model.operation.Operation#delta
+		 */
+
+		/**
+		 * Creates and returns an operation that has the same parameters as this operation.
+		 *
+		 * @method engine.model.operation.Operation#clone
+		 * @returns {engine.model.operation.Operation} Clone of this operation.
+		 */
+
+		/**
+		 * Creates and returns a reverse operation. Reverse operation when executed right after
+		 * the original operation will bring back tree model state to the point before the original
+		 * operation execution. In other words, it reverses changes done by the original operation.
+		 *
+		 * Keep in mind that tree model state may change since executing the original operation,
+		 * so reverse operation will be "outdated". In that case you will need to
+		 * {@link engine.model.operation.transform} it by all operations that were executed after the original operation.
+		 *
+		 * @method engine.model.operation.Operation#getReversed
+		 * @returns {engine.model.operation.Operation} Reversed operation.
+		 */
+
+		/**
+		 * Executes the operation - modifications described by the operation attributes
+		 * will be applied to the tree model.
+		 *
+		 * @protected
+		 * @method engine.model.operation.Operation#_execute
+		 * @returns {Object} Object with additional information about the applied changes. Always has `range`
+		 * property containing changed nodes. May have additional properties depending on the operation type.
+		 */
+	}
+
+	/**
+	 * Custom toJSON method to solve child-parent circular dependencies.
+	 *
+	 * @method engine.model.operation.Operation#toJSON
+	 * @returns {Object} Clone of this object with the delta property replaced with string.
+	 */
+	toJSON() {
+		const json = clone( this, true );
+
+		json.__className = this.constructor.className;
+
+		// Remove parent delta to avoid circular dependencies.
+		delete json.delta;
+
+		return json;
+	}
+
+	/**
+	 * Name of the operation class used for serialization.
+	 *
+	 * @type {String}
+	 */
+	static get className() {
+		return 'engine.model.operation.Operation';
+	}
+
+	/**
+	 * Creates Operation object from deserilized object, i.e. from parsed JSON string.
+	 *
+	 * @param {Object} json Deserialized JSON object.
+	 * @param {engine.model.Document} doc Document on which this operation will be applied.
+	 * @returns {engine.model.operation.Operation}
+	 */
+	static fromJSON( json ) {
+		return new Operation( json.baseVersion );
+	}
+}

+ 2 - 1
packages/ckeditor5-engine/src/treeview/observer.jsdoc

@@ -4,5 +4,6 @@
  */
 
 /**
- * @namespace engine.treeView.observer
+ * Core &rarr; model &rarr; Operation namespace (`engine.model.operation`).
+ * @namespace engine.model.operation
  */

+ 44 - 0
packages/ckeditor5-engine/src/model/operation/operationfactory.js

@@ -0,0 +1,44 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+import AttributeOperation from '../operation/attributeoperation.js';
+import InsertOperation from '../operation/insertoperation.js';
+import MoveOperation from '../operation/moveoperation.js';
+import NoOperation from '../operation/nooperation.js';
+import Operation from '../operation/operation.js';
+import ReinsertOperation from '../operation/reinsertoperation.js';
+import RemoveOperation from '../operation/removeoperation.js';
+import RootAttributeOperation from '../operation/rootattributeoperation.js';
+
+const operations = {};
+operations[ AttributeOperation.className ] = AttributeOperation;
+operations[ InsertOperation.className ] = InsertOperation;
+operations[ MoveOperation.className ] = MoveOperation;
+operations[ NoOperation.className ] = NoOperation;
+operations[ Operation.className ] = Operation;
+operations[ ReinsertOperation.className ] = ReinsertOperation;
+operations[ RemoveOperation.className ] = RemoveOperation;
+operations[ RootAttributeOperation.className ] = RootAttributeOperation;
+
+/**
+ * A factory class for creating operations.
+ *
+ * @abstract
+ * @memberOf engine.model.operation
+ */
+export default class OperationFactory {
+	/**
+	 * Creates concrete Operation object from deserilized object, i.e. from parsed JSON string.
+	 *
+	 * @param {Object} json Deserialized JSON object.
+	 * @param {engine.model.Document} document Document on which this operation will be applied.
+	 * @returns {engine.model.operation.Operation}
+	 */
+	static fromJSON( json, document ) {
+		return operations[ json.__className ].fromJSON( json, document );
+	}
+}

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

@@ -10,21 +10,21 @@ import RemoveOperation from './removeoperation.js';
 
 /**
  * Operation to reinsert previously removed nodes back to the non-graveyard root.
- * This is basically {@link engine.treeModel.operation.MoveOperation} but it returns
- * {@link engine.treeModel.operation.RemoveOperation} when reversed.
+ * This is basically {@link engine.model.operation.MoveOperation} but it returns
+ * {@link engine.model.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.
  *
- * @memberOf engine.treeModel.operation
- * @extends engine.treeModel.operation.Operation
+ * @memberOf engine.model.operation
+ * @extends engine.model.operation.Operation
  */
 export default class ReinsertOperation extends MoveOperation {
 	/**
 	 * Position where re-inserted node will be inserted.
 	 *
-	 * @type {engine.treeModel.Position}
+	 * @type {engine.model.Position}
 	 */
 	get position() {
 		return this.targetPosition;
@@ -39,9 +39,17 @@ export default class ReinsertOperation extends MoveOperation {
 	}
 
 	/**
-	 * @returns {engine.treeModel.operation.RemoveOperation}
+	 * @returns {engine.model.operation.RemoveOperation}
 	 */
 	getReversed() {
 		return new RemoveOperation( this.targetPosition, this.howMany, this.baseVersion + 1 );
 	}
+
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.operation.ReinsertOperation';
+	}
+
 }

+ 13 - 6
packages/ckeditor5-engine/src/treemodel/operation/removeoperation.js

@@ -12,17 +12,17 @@ import ReinsertOperation from './reinsertoperation.js';
 /**
  * Operation to remove a range of nodes.
  *
- * @memberOf engine.treeModel.operation
- * @extends engine.treeModel.operation.Operation
+ * @memberOf engine.model.operation
+ * @extends engine.model.operation.Operation
  */
 export default class RemoveOperation extends MoveOperation {
 	/**
 	 *
 	 * Creates a remove operation.
 	 *
-	 * @param {engine.treeModel.Position} position Position before the first node to remove.
+	 * @param {engine.model.Position} position Position before the first node to remove.
 	 * @param {Number} howMany How many nodes to remove.
-	 * @param {Number} baseVersion {@link engine.treeModel.Document#version} on which operation can be applied.
+	 * @param {Number} baseVersion {@link engine.model.Document#version} on which operation can be applied.
 	 */
 	constructor( position, howMany, baseVersion ) {
 		// Position in a graveyard where nodes were moved.
@@ -36,16 +36,23 @@ export default class RemoveOperation extends MoveOperation {
 	}
 
 	/**
-	 * @returns {engine.treeModel.operation.ReinsertOperation}
+	 * @returns {engine.model.operation.ReinsertOperation}
 	 */
 	getReversed() {
 		return new ReinsertOperation( this.targetPosition, this.howMany, this.sourcePosition, this.baseVersion + 1 );
 	}
 
 	/**
-	 * @returns {engine.treeModel.operation.RemoveOperation}
+	 * @returns {engine.model.operation.RemoveOperation}
 	 */
 	clone() {
 		return new RemoveOperation( this.sourcePosition, this.howMany, this.baseVersion );
 	}
+
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.operation.RemoveOperation';
+	}
 }

+ 47 - 16
packages/ckeditor5-engine/src/treemodel/operation/rootattributeoperation.js

@@ -11,24 +11,24 @@ import CKEditorError from '../../../utils/ckeditorerror.js';
 /**
  * Operation to change root element's attribute. Using this class you can add, remove or change value of the attribute.
  *
- * This operation is needed, because root elements can't be changed through {@link engine.treeModel.operation.AttributeOperation}.
- * It is because {@link engine.treeModel.operation.AttributeOperation} requires a range to change and root element can't
- * be a part of range because every {@link engine.treeModel.Position} has to be inside a root. {@link engine.treeModel.Position}
+ * This operation is needed, because root elements can't be changed through {@link engine.model.operation.AttributeOperation}.
+ * It is because {@link engine.model.operation.AttributeOperation} requires a range to change and root element can't
+ * be a part of range because every {@link engine.model.Position} has to be inside a root. {@link engine.model.Position}
  * can't be created before a root element.
  *
- * @memberOf engine.treeModel.operation
- * @extends engine.treeModel.operation.Operation
+ * @memberOf engine.model.operation
+ * @extends engine.model.operation.Operation
  */
 export default class RootAttributeOperation extends Operation {
 	/**
 	 * Creates an operation that changes, removes or adds attributes on root element.
 	 *
-	 * @see engine.treeModel.operation.AttributeOperation
-	 * @param {engine.treeModel.RootElement} root Root element to change.
+	 * @see engine.model.operation.AttributeOperation
+	 * @param {engine.model.RootElement} root Root element to change.
 	 * @param {String} key Key of an attribute to change or remove.
 	 * @param {*} oldValue Old value of the attribute with given key or `null` if adding a new attribute.
 	 * @param {*} newValue New value to set for the attribute. If `null`, then the operation just removes the attribute.
-	 * @param {Number} baseVersion {@link engine.treeModel.Document#version} on which the operation can be applied.
+	 * @param {Number} baseVersion {@link engine.model.Document#version} on which the operation can be applied.
 	 */
 	constructor( root, key, oldValue, newValue, baseVersion ) {
 		super( baseVersion );
@@ -37,7 +37,7 @@ export default class RootAttributeOperation extends Operation {
 		 * Root element to change.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.RootElement} engine.treeModel.operation.RootAttributeOperation#root
+		 * @member {engine.model.RootElement} engine.model.operation.RootAttributeOperation#root
 		 */
 		this.root = root;
 
@@ -45,7 +45,7 @@ export default class RootAttributeOperation extends Operation {
 		 * Key of an attribute to change or remove.
 		 *
 		 * @readonly
-		 * @member {String} engine.treeModel.operation.RootAttributeOperation#key
+		 * @member {String} engine.model.operation.RootAttributeOperation#key
 		 */
 		this.key = key;
 
@@ -53,7 +53,7 @@ export default class RootAttributeOperation extends Operation {
 		 * Old value of the attribute with given key or `null` if adding a new attribute.
 		 *
 		 * @readonly
-		 * @member {*} engine.treeModel.operation.RootAttributeOperation#oldValue
+		 * @member {*} engine.model.operation.RootAttributeOperation#oldValue
 		 */
 		this.oldValue = oldValue;
 
@@ -61,7 +61,7 @@ export default class RootAttributeOperation extends Operation {
 		 * New value to set for the attribute. If `null`, then the operation just removes the attribute.
 		 *
 		 * @readonly
-		 * @member {*} engine.treeModel.operation.RootAttributeOperation#newValue
+		 * @member {*} engine.model.operation.RootAttributeOperation#newValue
 		 */
 		this.newValue = newValue;
 	}
@@ -77,14 +77,14 @@ export default class RootAttributeOperation extends Operation {
 	}
 
 	/**
-	 * @returns {engine.treeModel.operation.RootAttributeOperation}
+	 * @returns {engine.model.operation.RootAttributeOperation}
 	 */
 	clone() {
 		return new RootAttributeOperation( this.root, this.key, this.oldValue, this.newValue, this.baseVersion );
 	}
 
 	/**
-	 * @returns {engine.treeModel.operation.RootAttributeOperation}
+	 * @returns {engine.model.operation.RootAttributeOperation}
 	 */
 	getReversed() {
 		return new RootAttributeOperation( this.root, this.key, this.newValue, this.oldValue, this.baseVersion + 1 );
@@ -96,7 +96,7 @@ export default class RootAttributeOperation extends Operation {
 			 * The attribute which should be removed does not exists for the given node.
 			 *
 			 * @error operation-rootattribute-no-attr-to-remove
-			 * @param {engine.treeModel.RootElement} root
+			 * @param {engine.model.RootElement} root
 			 * @param {String} key
 			 * @param {*} value
 			 */
@@ -111,7 +111,7 @@ export default class RootAttributeOperation extends Operation {
 			 * The attribute with given key already exists for the given node.
 			 *
 			 * @error operation-rootattribute-attr-exists
-			 * @param {engine.treeModel.RootElement} root
+			 * @param {engine.model.RootElement} root
 			 * @param {String} key
 			 */
 			throw new CKEditorError(
@@ -128,4 +128,35 @@ export default class RootAttributeOperation extends Operation {
 
 		return { root: this.root, key: this.key, oldValue: this.oldValue, newValue: this.newValue };
 	}
+
+	/**
+	 * @inheritDoc
+	 */
+	static get className() {
+		return 'engine.model.operation.RootAttributeOperation';
+	}
+
+	/**
+	 * Creates RootAttributeOperation object from deserilized object, i.e. from parsed JSON string.
+	 *
+	 * @param {Object} json Deserialized JSON object.
+	 * @param {engine.model.Document} document Document on which this operation will be applied.
+	 * @returns {engine.model.operation.RootAttributeOperation}
+	 */
+	static fromJSON( json, document ) {
+		if ( !document.hasRoot( json.root ) ) {
+			/**
+			 * Cannot create RootAttributeOperation for document. Root with specified name does not exist.
+			 *
+			 * @error rootattributeoperation-fromjson-no-root
+			 * @param {String} rootName
+			 */
+			throw new CKEditorError(
+				'rootattributeoperation-fromjson-no-root: Cannot create RootAttributeOperation. Root with specified name does not exist.',
+				{ rootName: json }
+			);
+		}
+
+		return new RootAttributeOperation( document.getRoot( json.root ), json.key, json.oldValue, json.newValue, json.baseVersion );
+	}
 }

+ 13 - 13
packages/ckeditor5-engine/src/treemodel/operation/transform.js

@@ -16,21 +16,21 @@ import isEqual from '../../../utils/lib/lodash/isEqual.js';
 import compareArrays from '../../../utils/comparearrays.js';
 
 /**
- * Transforms given {@link engine.treeModel.operation.Operation operation} by another
- * {@link engine.treeModel.operation.Operation operation} and
+ * Transforms given {@link engine.model.operation.Operation operation} by another
+ * {@link engine.model.operation.Operation operation} and
  * returns the result of that transformation as an array containing one or more
- * {@link engine.treeModel.operation.Operation operation} elements.
+ * {@link engine.model.operation.Operation operation} elements.
  *
- * Operations work on specified positions, passed to them when they are created. Whenever {@link engine.treeModel.Document document}
+ * Operations work on specified positions, passed to them when they are created. Whenever {@link engine.model.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 engine.treeModel.Document document} has different {@link engine.treeModel.Document#baseVersion}
- * than the operation you want to {@link engine.treeModel.Document#applyOperation apply}, you need to transform that
- * operation by all operations which were already applied to the {@link engine.treeModel.Document document} and have greater
- * {@link engine.treeModel.Document#baseVersion} than the operation being applied. Transform them in the same order as those
+ * Whenever the {@link engine.model.Document document} has different {@link engine.model.Document#baseVersion}
+ * than the operation you want to {@link engine.model.Document#applyOperation apply}, you need to transform that
+ * operation by all operations which were already applied to the {@link engine.model.Document document} and have greater
+ * {@link engine.model.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.
@@ -47,13 +47,13 @@ import compareArrays from '../../../utils/comparearrays.js';
  * `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.
  *
- * @external engine.treeModel.operation
- * @function engine.treeModel.operation.transform
- * @param {engine.treeModel.operation.Operation} a Operation that will be transformed.
- * @param {engine.treeModel.operation.Operation} b Operation to transform by.
+ * @external engine.model.operation
+ * @function engine.model.operation.transform
+ * @param {engine.model.operation.Operation} a Operation that will be transformed.
+ * @param {engine.model.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.<engine.treeModel.operation.Operation>} Result of the transformation.
+ * @returns {Array.<engine.model.operation.Operation>} Result of the transformation.
  */
 
 export default transform;

+ 76 - 48
packages/ckeditor5-engine/src/treemodel/position.js

@@ -15,15 +15,15 @@ import CKEditorError from '../../utils/ckeditorerror.js';
  * Position in the tree. Position is always located before or after a node.
  * See {@link #path} property for more information.
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class Position {
 	/**
 	 * Creates a position.
 	 *
-	 * @param {engine.treeModel.Element|engine.treeModel.DocumentFragment} root
-	 * Root of the position path. Element (most often a {@link engine.treeModel.RootElement}) or a document fragment.
-	 * @param {Array.<Number>} path Position path. See {@link engine.treeModel.Position#path} property for more information.
+	 * @param {engine.model.Element|engine.model.DocumentFragment} root
+	 * Root of the position path. Element (most often a {@link engine.model.RootElement}) or a document fragment.
+	 * @param {Array.<Number>} path Position path. See {@link engine.model.Position#path} property for more information.
 	 */
 	constructor( root, path ) {
 		if ( !( root instanceof Element ) && !( root instanceof DocumentFragment ) ) {
@@ -53,7 +53,7 @@ export default class Position {
 		 * Root of the position path.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.Element|engine.treeModel.DocumentFragment} engine.treeModel.Position#root
+		 * @member {engine.model.Element|engine.model.DocumentFragment} engine.model.Position#root
 		 */
 		this.root = root;
 
@@ -72,7 +72,7 @@ export default class Position {
 		 *		        |- a   Before: [ 1, 1, 1 ] After: [ 1, 1, 2 ]
 		 *		        |- r   Before: [ 1, 1, 2 ] After: [ 1, 1, 3 ]
 		 *
-		 * @member {Array.<Number>} engine.treeModel.Position#path
+		 * @member {Array.<Number>} engine.model.Position#path
 		 */
 		this.path = path;
 	}
@@ -81,7 +81,7 @@ export default class Position {
 	 * Node directly after the position.
 	 *
 	 * @readonly
-	 * @type {engine.treeModel.Node}
+	 * @type {engine.model.Node}
 	 */
 	get nodeAfter() {
 		return this.parent.getChild( this.offset ) || null;
@@ -120,7 +120,7 @@ export default class Position {
 	 * Parent element of the position. The position is located at {@link #offset} in this element.
 	 *
 	 * @readonly
-	 * @type {engine.treeModel.Element}
+	 * @type {engine.model.Element}
 	 */
 	get parent() {
 		let parent = this.root;
@@ -137,8 +137,8 @@ export default class Position {
 	/**
 	 * Checks whether this position is before or after given position.
 	 *
-	 * @param {engine.treeModel.Position} otherPosition Position to compare with.
-	 * @returns {engine.treeModel.PositionRelation}
+	 * @param {engine.model.Position} otherPosition Position to compare with.
+	 * @returns {engine.model.PositionRelation}
 	 */
 	compareWith( otherPosition ) {
 		if ( this.root != otherPosition.root ) {
@@ -167,7 +167,7 @@ export default class Position {
 	}
 
 	/**
-	 * Returns the path to the parent, which is the {@link engine.treeModel.Position#path} without the last element.
+	 * Returns the path to the parent, which is the {@link engine.model.Position#path} without the last element.
 	 *
 	 * This method returns the parent path even if the parent does not exists.
 	 *
@@ -181,7 +181,7 @@ export default class Position {
 	 * Returns a new instance of Position with offset incremented by `shift` value.
 	 *
 	 * @param {Number} shift How position offset should get changed. Accepts negative values.
-	 * @returns {engine.treeModel.Position} Shifted position.
+	 * @returns {engine.model.Position} Shifted position.
 	 */
 	getShiftedBy( shift ) {
 		let shifted = Position.createFromPosition( this );
@@ -197,9 +197,9 @@ export default class Position {
 	 * It may happen that this position is in a removed node. If that is the case, `null` is returned instead.
 	 *
 	 * @protected
-	 * @param {engine.treeModel.Position} deletePosition Position before the first removed node.
+	 * @param {engine.model.Position} deletePosition Position before the first removed node.
 	 * @param {Number} howMany How many nodes are removed.
-	 * @returns {engine.treeModel.Position|null} Transformed position or `null`.
+	 * @returns {engine.model.Position|null} Transformed position or `null`.
 	 */
 	getTransformedByDeletion( deletePosition, howMany ) {
 		let transformed = Position.createFromPosition( this );
@@ -245,12 +245,12 @@ export default class Position {
 	 * Returns this position after being updated by inserting `howMany` nodes at `insertPosition`.
 	 *
 	 * @protected
-	 * @param {engine.treeModel.Position} insertPosition Position where nodes are inserted.
+	 * @param {engine.model.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 {engine.treeModel.Position} Transformed position.
+	 * @returns {engine.model.Position} Transformed position.
 	 */
 	getTransformedByInsertion( insertPosition, howMany, insertBefore ) {
 		let transformed = Position.createFromPosition( this );
@@ -285,15 +285,15 @@ export default class Position {
 	 * Returns this position after being updated by moving `howMany` nodes from `sourcePosition` to `targetPosition`.
 	 *
 	 * @protected
-	 * @param {engine.treeModel.Position} sourcePosition Position before the first element to move.
-	 * @param {engine.treeModel.Position} targetPosition Position where moved elements will be inserted.
+	 * @param {engine.model.Position} sourcePosition Position before the first element to move.
+	 * @param {engine.model.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.
 	 * @param {Boolean} [sticky] Flag indicating whether this position "sticks" to range, that is if it should be moved
 	 * with the moved range if it is equal to one of range's boundaries.
-	 * @returns {engine.treeModel.Position} Transformed position.
+	 * @returns {engine.model.Position} Transformed position.
 	 */
 	getTransformedByMove( sourcePosition, targetPosition, howMany, insertBefore, sticky ) {
 		// Moving a range removes nodes from their original position. We acknowledge this by proper transformation.
@@ -318,9 +318,9 @@ export default class Position {
 	/**
 	 * Checks whether this position is after given position.
 	 *
-	 * @see engine.treeModel.Position#isBefore
+	 * @see engine.model.Position#isBefore
 	 *
-	 * @param {engine.treeModel.Position} otherPosition Position to compare with.
+	 * @param {engine.model.Position} otherPosition Position to compare with.
 	 * @returns {Boolean} True if this position is after given position.
 	 */
 	isAfter( otherPosition ) {
@@ -355,7 +355,7 @@ export default class Position {
 	 *			// do A.
 	 *		}
 	 *
-	 * @param {engine.treeModel.Position} otherPosition Position to compare with.
+	 * @param {engine.model.Position} otherPosition Position to compare with.
 	 * @returns {Boolean} True if this position is before given position.
 	 */
 	isBefore( otherPosition ) {
@@ -365,7 +365,7 @@ export default class Position {
 	/**
 	 * Checks whether this position equals given position.
 	 *
-	 * @param {engine.treeModel.Position} otherPosition Position to compare with.
+	 * @param {engine.model.Position} otherPosition Position to compare with.
 	 * @returns {Boolean} True if positions are same.
 	 */
 	isEqual( otherPosition ) {
@@ -377,7 +377,7 @@ export default class Position {
 	 * or empty nodes in a range between them. Technically, those positions are not equal but in many cases
 	 * they are very similar or even indistinguishable when they touch.
 	 *
-	 * @param {engine.treeModel.Position} otherPosition Position to compare with.
+	 * @param {engine.model.Position} otherPosition Position to compare with.
 	 * @returns {Boolean} True if positions touch.
 	 */
 	isTouching( otherPosition ) {
@@ -426,7 +426,7 @@ export default class Position {
 	}
 
 	/**
-	 * Whether position is at the beginning of its {@link engine.treeModel.Position#parent}.
+	 * Whether position is at the beginning of its {@link engine.model.Position#parent}.
 	 *
 	 * @returns {Boolean}
 	 */
@@ -435,7 +435,7 @@ export default class Position {
 	}
 
 	/**
-	 * Whether position is at the end of its {@link engine.treeModel.Position#parent}.
+	 * Whether position is at the end of its {@link engine.model.Position#parent}.
 	 *
 	 * @returns {Boolean}
 	 */
@@ -446,19 +446,19 @@ export default class Position {
 	/**
 	 * Creates position at the given location. The location can be specified as:
 	 *
-	 * * a {@link engine.treeModel.Position position},
+	 * * a {@link engine.model.Position position},
 	 * * parent element and offset (offset defaults to `0`),
 	 * * parent element and `'END'` (sets selection at the end of that element),
 	 * * node and `'BEFORE'` or `'AFTER'` (sets selection before or after the given node).
 	 *
 	 * This method is a shortcut to other constructors such as:
 	 *
-	 * * {@link engine.treeModel.Position.createBefore},
-	 * * {@link engine.treeModel.Position.createAfter},
-	 * * {@link engine.treeModel.Position.createFromParentAndOffset},
-	 * * {@link engine.treeModel.Position.createFromPosition}.
+	 * * {@link engine.model.Position.createBefore},
+	 * * {@link engine.model.Position.createAfter},
+	 * * {@link engine.model.Position.createFromParentAndOffset},
+	 * * {@link engine.model.Position.createFromPosition}.
 	 *
-	 * @param {engine.treeModel.Node|engine.treeModel.Position} nodeOrPosition
+	 * @param {engine.model.Node|engine.model.Position} nodeOrPosition
 	 * @param {Number|'END'|'BEFORE'|'AFTER'} [offset=0] Offset or one of the flags. Used only when
 	 * first parameter is a node.
 	 */
@@ -487,10 +487,10 @@ export default class Position {
 	/**
 	 * Creates a new position after given node.
 	 *
-	 * @see {@link engine.treeModel.TreeWalkerValue}
+	 * @see {@link engine.model.TreeWalkerValue}
 	 *
-	 * @param {engine.treeModel.Node} node Node the position should be directly after.
-	 * @returns {engine.treeModel.Position}
+	 * @param {engine.model.Node} node Node the position should be directly after.
+	 * @returns {engine.model.Position}
 	 */
 	static createAfter( node ) {
 		if ( !node.parent ) {
@@ -498,7 +498,7 @@ export default class Position {
 			 * You can not make position after root.
 			 *
 			 * @error position-after-root
-			 * @param {engine.treeModel.Node} root
+			 * @param {engine.model.Node} root
 			 */
 			throw new CKEditorError( 'position-after-root: You can not make position after root.', { root: node } );
 		}
@@ -509,10 +509,10 @@ export default class Position {
 	/**
 	 * Creates a new position before the given node.
 	 *
-	 * @see {@link engine.treeModel.TreeWalkerValue}
+	 * @see {@link engine.model.TreeWalkerValue}
 	 *
-	 * @param {engine.treeModel.node} node Node the position should be directly before.
-	 * @returns {engine.treeModel.Position}
+	 * @param {engine.model.node} node Node the position should be directly before.
+	 * @returns {engine.model.Position}
 	 */
 	static createBefore( node ) {
 		if ( !node.parent ) {
@@ -520,7 +520,7 @@ export default class Position {
 			 * You can not make position before root.
 			 *
 			 * @error position-before-root
-			 * @param {engine.treeModel.Node} root
+			 * @param {engine.model.Node} root
 			 */
 			throw new CKEditorError( 'position-before-root: You can not make position before root.', { root: node } );
 		}
@@ -531,10 +531,10 @@ export default class Position {
 	/**
 	 * Creates a new position from the parent element and the offset in that element.
 	 *
-	 * @param {engine.treeModel.Element|engine.treeModel.DocumentFragment} parent Position's parent element or
+	 * @param {engine.model.Element|engine.model.DocumentFragment} parent Position's parent element or
 	 * document fragment.
 	 * @param {Number} offset Position's offset.
-	 * @returns {engine.treeModel.Position}
+	 * @returns {engine.model.Position}
 	 */
 	static createFromParentAndOffset( parent, offset ) {
 		if ( !( parent instanceof Element || parent instanceof DocumentFragment ) ) {
@@ -556,14 +556,42 @@ export default class Position {
 	/**
 	 * Creates and returns a new instance of Position, which is equal to passed position.
 	 *
-	 * @param {engine.treeModel.Position} position Position to be cloned.
-	 * @returns {engine.treeModel.Position}
+	 * @param {engine.model.Position} position Position to be cloned.
+	 * @returns {engine.model.Position}
 	 */
 	static createFromPosition( position ) {
 		return new this( position.root, position.path.slice() );
 	}
 
 	/**
+	 * Creates Element object from deserilized object, ie. from parsed JSON string.
+	 *
+	 * @param {Object} json Deserialized JSON object.
+	 * @param {engine.model.Document} doc Document on which this operation will be applied.
+	 * @returns {engine.model.Position}
+	 */
+	static fromJSON( json, doc ) {
+		if ( json.root === '$graveyard' ) {
+			return new Position( doc.graveyard, json.path );
+		}
+
+		if ( !doc.hasRoot( json.root ) ) {
+			/**
+			 * Cannot create position for document. Root with specified name does not exist.
+			 *
+			 * @error position-fromjson-no-root
+			 * @param {String} rootName
+			 */
+			throw new CKEditorError(
+				'position-fromjson-no-root: Cannot create position for document. Root with specified name does not exist.',
+				{ rootName: json.root }
+			);
+		}
+
+		return new Position( doc.getRoot( json.root ), json.path );
+	}
+
+	/**
 	 * Returns a new position that is a combination of this position and given positions. The combined
 	 * position is this position transformed by moving a range starting at `from` to `to` position.
 	 * It is expected that this position is inside the moved range.
@@ -589,9 +617,9 @@ export default class Position {
 	 * Finally, the transformed position will point to `[ 1, 1, 4, 1 ]`.
 	 *
 	 * @protected
-	 * @param {engine.treeModel.Position} source Beginning of the moved range.
-	 * @param {engine.treeModel.Position} target Position where the range is moved.
-	 * @returns {engine.treeModel.Position} Combined position.
+	 * @param {engine.model.Position} source Beginning of the moved range.
+	 * @param {engine.model.Position} target Position where the range is moved.
+	 * @returns {engine.model.Position} Combined position.
 	 */
 	_getCombined( source, target ) {
 		const i = source.path.length - 1;
@@ -616,5 +644,5 @@ export default class Position {
  * A flag indicating whether this position is `'BEFORE'` or `'AFTER'` or `'SAME'` as given position.
  * If positions are in different roots `'DIFFERENT'` flag is returned.
  *
- * @typedef {String} engine.treeModel.PositionRelation
+ * @typedef {String} engine.model.PositionRelation
  */

+ 82 - 71
packages/ckeditor5-engine/src/treemodel/range.js

@@ -12,22 +12,22 @@ import compareArrays from '../../utils/comparearrays.js';
 /**
  * Range class. Range is iterable.
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class Range {
 	/**
 	 * Creates a range spanning from `start` position to `end` position.
-	 * **Note:** Constructor creates it's own {@link engine.treeModel.Position} instances basing on passed values.
+	 * **Note:** Constructor creates it's own {@link engine.model.Position} instances basing on passed values.
 	 *
-	 * @param {engine.treeModel.Position} start Start position.
-	 * @param {engine.treeModel.Position} end End position.
+	 * @param {engine.model.Position} start Start position.
+	 * @param {engine.model.Position} end End position.
 	 */
 	constructor( start, end ) {
 		/**
 		 * Start position.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.Position} engine.treeModel.Range#start
+		 * @member {engine.model.Position} engine.model.Range#start
 		 */
 		this.start = Position.createFromPosition( start );
 
@@ -35,7 +35,7 @@ export default class Range {
 		 * End position.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.Position} engine.treeModel.Range#end
+		 * @member {engine.model.Position} engine.model.Range#end
 		 */
 		this.end = Position.createFromPosition( end );
 	}
@@ -63,35 +63,35 @@ export default class Range {
 	 *
 	 * Equals to the root of start position (which should be same as root of end position).
 	 *
-	 * @type {engine.treeModel.RootElement|engine.treeModel.DocumentFragment}
+	 * @type {engine.model.RootElement|engine.model.DocumentFragment}
 	 */
 	get root() {
 		return this.start.root;
 	}
 
 	/**
-	 * Checks whether this contains given {@link engine.treeModel.Position position}.
+	 * Checks whether this contains given {@link engine.model.Position position}.
 	 *
-	 * @param {engine.treeModel.Position} position Position to check.
-	 * @returns {Boolean} True if given {@link engine.treeModel.Position position} is contained.
+	 * @param {engine.model.Position} position Position to check.
+	 * @returns {Boolean} True if given {@link engine.model.Position position} is contained.
 	 */
 	containsPosition( position ) {
 		return position.isAfter( this.start ) && position.isBefore( this.end );
 	}
 
 	/**
-	 * Checks whether this range contains given {@link engine.treeModel.Range range}.
+	 * Checks whether this range contains given {@link engine.model.Range range}.
 	 *
-	 * @param {engine.treeModel.Range} otherRange Range to check.
-	 * @returns {Boolean} True if given {@link engine.treeModel.Range range} boundaries are contained by this range.
+	 * @param {engine.model.Range} otherRange Range to check.
+	 * @returns {Boolean} True if given {@link engine.model.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 engine.treeModel.Range range} which is not a part of given {@link engine.treeModel.Range range}. Returned
-	 * array contains zero, one or two {@link engine.treeModel.Range ranges}.
+	 * Gets a part of this {@link engine.model.Range range} which is not a part of given {@link engine.model.Range range}. Returned
+	 * array contains zero, one or two {@link engine.model.Range ranges}.
 	 *
 	 * Examples:
 	 *
@@ -108,8 +108,8 @@ export default class Range {
 	 *		transformed = range.getDifference( otherRange );
 	 *		// transformed array has two ranges: from [ 2, 7 ] to [ 3 ] and from [ 4 ] to [ 4, 0, 1 ]
 	 *
-	 * @param {engine.treeModel.Range} otherRange Range to differentiate against.
-	 * @returns {Array.<engine.treeModel.Range>} The difference between ranges.
+	 * @param {engine.model.Range} otherRange Range to differentiate against.
+	 * @returns {Array.<engine.model.Range>} The difference between ranges.
 	 */
 	getDifference( otherRange ) {
 		const ranges = [];
@@ -137,7 +137,7 @@ export default class Range {
 	}
 
 	/**
-	 * Returns an intersection of this {@link engine.treeModel.Range range} and given {@link engine.treeModel.Range range}. Intersection
+	 * Returns an intersection of this {@link engine.model.Range range} and given {@link engine.model.Range range}. Intersection
 	 * is a common part of both of those ranges. If ranges has no common part, returns `null`.
 	 *
 	 * Examples:
@@ -149,8 +149,8 @@ export default class Range {
 	 *		otherRange = new Range( new Position( root, [ 3 ] ), new Position( root, [ 5 ] ) );
 	 *		transformed = range.getIntersection( otherRange ); // range from [ 3 ] to [ 4, 0, 1 ]
 	 *
-	 * @param {engine.treeModel.Range} otherRange Range to check for intersection.
-	 * @returns {engine.treeModel.Range|null} A common part of given ranges or null if ranges have no common part.
+	 * @param {engine.model.Range} otherRange Range to check for intersection.
+	 * @returns {engine.model.Range|null} A common part of given ranges or null if ranges have no common part.
 	 */
 	getIntersection( otherRange ) {
 		if ( this.isIntersecting( otherRange ) ) {
@@ -211,7 +211,7 @@ export default class Range {
 	 * **Note:** this method is not returning flat ranges that contain no nodes. It may also happen that not-collapsed
 	 * range will return an empty array of flat ranges.
 	 *
-	 * @returns {Array.<engine.treeModel.Range>} Array of flat ranges.
+	 * @returns {Array.<engine.model.Range>} Array of flat ranges.
 	 */
 	getMinimalFlatRanges() {
 		let ranges = [];
@@ -254,33 +254,33 @@ export default class Range {
 	}
 
 	/**
-	 * Returns an iterator that iterates over all {@link engine.treeModel.Item items} that are in this range and returns
-	 * them together with additional information like length or {@link engine.treeModel.Position positions},
-	 * grouped as {@link engine.treeModel.TreeWalkerValue}. It iterates over all {@link engine.treeModel.TextProxy texts}
-	 * that are inside the range and all the {@link engine.treeModel.Element}s we enter into when iterating over this
+	 * Returns an iterator that iterates over all {@link engine.model.Item items} that are in this range and returns
+	 * them together with additional information like length or {@link engine.model.Position positions},
+	 * grouped as {@link engine.model.TreeWalkerValue}. It iterates over all {@link engine.model.TextProxy texts}
+	 * that are inside the range and all the {@link engine.model.Element}s we enter into when iterating over this
 	 * range.
 	 *
 	 * **Note:** iterator will not return a parent node of start position. This is in contrary to
-	 * {@link engine.treeModel.TreeWalker} which will return that node with `'ELEMENT_END'` type. Iterator also
-	 * returns each {@link engine.treeModel.Element} once, while simply used {@link engine.treeModel.TreeWalker} might
+	 * {@link engine.model.TreeWalker} which will return that node with `'ELEMENT_END'` type. Iterator also
+	 * returns each {@link engine.model.Element} once, while simply used {@link engine.model.TreeWalker} might
 	 * return it twice: for `'ELEMENT_START'` and `'ELEMENT_END'`.
 	 *
-	 * **Note:** because iterator does not return {@link engine.treeModel.TreeWalkerValue values} with the type of
-	 * `'ELEMENT_END'`, you can use {@link engine.treeModel.TreeWalkerValue.previousPosition} as a position before the
+	 * **Note:** because iterator does not return {@link engine.model.TreeWalkerValue values} with the type of
+	 * `'ELEMENT_END'`, you can use {@link engine.model.TreeWalkerValue.previousPosition} as a position before the
 	 * item.
 	 *
-	 * @see engine.treeModel.TreeWalker
-	 * @returns {Iterable.<engine.treeModel.TreeWalkerValue>}
+	 * @see engine.model.TreeWalker
+	 * @returns {Iterable.<engine.model.TreeWalkerValue>}
 	 */
 	*[ Symbol.iterator ]() {
 		yield* new TreeWalker( { boundaries: this, ignoreElementEnd: true } );
 	}
 
 	/**
-	 * Creates a {@link engine.treeModel.TreeWalker} instance with this range as a boundary.
+	 * Creates a {@link engine.model.TreeWalker} instance with this range as a boundary.
 	 *
-	 * @param {Object} options Object with configuration options. See {@link engine.treeModel.TreeWalker}.
-	 * @param {engine.treeModel.Position} [options.startPosition]
+	 * @param {Object} options Object with configuration options. See {@link engine.model.TreeWalker}.
+	 * @param {engine.model.Position} [options.startPosition]
 	 * @param {Boolean} [options.singleCharacters=false]
 	 * @param {Boolean} [options.shallow=false]
 	 * @param {Boolean} [options.ignoreElementEnd=false]
@@ -292,17 +292,17 @@ export default class Range {
 	}
 
 	/**
-	 * Returns an iterator that iterates over all {@link engine.treeModel.Item items} that are in this range and returns
-	 * them. It iterates over all {@link engine.treeModel.CharacterProxy characters} or
-	 * {@link engine.treeModel.TextProxy texts} that are inside the range and all the {@link engine.treeModel.Element}s
-	 * we enter into when iterating over this range. Note that it use {@link engine.treeModel.TreeWalker} with the
-	 * {@link engine.treeModel.TreeWalker#ignoreElementEnd ignoreElementEnd} option set to true.
-	 *
-	 * @param {Object} options Object with configuration options. See {@link engine.treeModel.TreeWalker}.
-	 * @param {engine.treeModel.Position} [options.startPosition]
+	 * Returns an iterator that iterates over all {@link engine.model.Item items} that are in this range and returns
+	 * them. It iterates over all {@link engine.model.CharacterProxy characters} or
+	 * {@link engine.model.TextProxy texts} that are inside the range and all the {@link engine.model.Element}s
+	 * we enter into when iterating over this range. Note that it use {@link engine.model.TreeWalker} with the
+	 * {@link engine.model.TreeWalker#ignoreElementEnd ignoreElementEnd} option set to true.
+	 *
+	 * @param {Object} options Object with configuration options. See {@link engine.model.TreeWalker}.
+	 * @param {engine.model.Position} [options.startPosition]
 	 * @param {Boolean} [options.singleCharacters=false]
 	 * @param {Boolean} [options.shallow=false]
-	 * @returns {Iterable.<engine.treeModel.Item>}
+	 * @returns {Iterable.<engine.model.Item>}
 	 */
 	*getItems( options = {} ) {
 		options.boundaries = this;
@@ -316,13 +316,13 @@ export default class Range {
 	}
 
 	/**
-	 * Returns an iterator that iterates over all {@link engine.treeModel.Position positions} that are boundaries or
+	 * Returns an iterator that iterates over all {@link engine.model.Position positions} that are boundaries or
 	 * contained in this range.
 	 *
-	 * @param {Object} options Object with configuration options. See {@link engine.treeModel.TreeWalker}.
+	 * @param {Object} options Object with configuration options. See {@link engine.model.TreeWalker}.
 	 * @param {Boolean} [options.singleCharacters=false]
 	 * @param {Boolean} [options.shallow=false]
-	 * @returns {Iterable.<engine.treeModel.Position>}
+	 * @returns {Iterable.<engine.model.Position>}
 	 */
 	*getPositions( options = {} ) {
 		options.boundaries = this;
@@ -337,9 +337,9 @@ export default class Range {
 	}
 
 	/**
-	 * Returns an array containing one or two {engine.treeModel.Range ranges} that are a result of transforming this
-	 * {@link engine.treeModel.Range range} by inserting `howMany` nodes at `insertPosition`. Two {@link engine.treeModel.Range ranges} are
-	 * returned if the insertion was inside this {@link engine.treeModel.Range range} and `spread` is set to `true`.
+	 * Returns an array containing one or two {engine.model.Range ranges} that are a result of transforming this
+	 * {@link engine.model.Range range} by inserting `howMany` nodes at `insertPosition`. Two {@link engine.model.Range ranges} are
+	 * returned if the insertion was inside this {@link engine.model.Range range} and `spread` is set to `true`.
 	 *
 	 * Examples:
 	 *
@@ -363,13 +363,13 @@ export default class Range {
 	 *		// transformed array has one range: from [ 2, 7 ] to [ 4, 0, 5 ] because range was expanded
 	 *
 	 * @protected
-	 * @param {engine.treeModel.Position} insertPosition Position where nodes are inserted.
+	 * @param {engine.model.Position} insertPosition Position where nodes are inserted.
 	 * @param {Number} howMany How many nodes are inserted.
-	 * @param {Boolean} [spread] Flag indicating whether this {engine.treeModel.Range range} should be spread if insertion
+	 * @param {Boolean} [spread] Flag indicating whether this {engine.model.Range range} should be spread if insertion
 	 * was inside the range. Defaults to `false`.
 	 * @param {Boolean} [isSticky] Flag indicating whether insertion should expand a range if it is in a place of
 	 * range boundary. Defaults to `false`.
-	 * @returns {Array.<engine.treeModel.Range>} Result of the transformation.
+	 * @returns {Array.<engine.model.Range>} Result of the transformation.
 	 */
 	getTransformedByInsertion( insertPosition, howMany, spread, isSticky ) {
 		isSticky = !!isSticky;
@@ -400,15 +400,15 @@ export default class Range {
 	}
 
 	/**
-	 * Returns an array containing {engine.treeModel.Range ranges} that are a result of transforming this
-	 * {@link engine.treeModel.Range range} by moving `howMany` nodes from `sourcePosition` to `targetPosition`.
+	 * Returns an array containing {engine.model.Range ranges} that are a result of transforming this
+	 * {@link engine.model.Range range} by moving `howMany` nodes from `sourcePosition` to `targetPosition`.
 	 *
-	 * @param {engine.treeModel.Position} sourcePosition Position from which nodes are moved.
-	 * @param {engine.treeModel.Position} targetPosition Position to where nodes are moved.
+	 * @param {engine.model.Position} sourcePosition Position from which nodes are moved.
+	 * @param {engine.model.Position} targetPosition Position to where nodes are moved.
 	 * @param {Number} howMany How many nodes are moved.
-	 * @param {Boolean} [spread] Flag indicating whether this {engine.treeModel.Range range} should be spread if insertion
+	 * @param {Boolean} [spread] Flag indicating whether this {engine.model.Range range} should be spread if insertion
 	 * was inside the range. Defaults to `false`.
-	 * @returns {Array.<engine.treeModel.Range>} Result of the transformation.
+	 * @returns {Array.<engine.model.Range>} Result of the transformation.
 	 */
 	getTransformedByMove( sourcePosition, targetPosition, howMany, spread ) {
 		let result;
@@ -460,7 +460,7 @@ export default class Range {
 	/**
 	 * Two ranges equal if their start and end positions equal.
 	 *
-	 * @param {engine.treeModel.Range} otherRange Range to compare with.
+	 * @param {engine.model.Range} otherRange Range to compare with.
 	 * @returns {Boolean} True if ranges equal.
 	 */
 	isEqual( otherRange ) {
@@ -470,7 +470,7 @@ export default class Range {
 	/**
 	 * Checks and returns whether this range intersects with given range.
 	 *
-	 * @param {engine.treeModel.Range} otherRange Range to compare with.
+	 * @param {engine.model.Range} otherRange Range to compare with.
 	 * @returns {Boolean} True if ranges intersect.
 	 */
 	isIntersecting( otherRange ) {
@@ -480,8 +480,8 @@ export default class Range {
 	/**
 	 * Creates a range inside an element which starts before the first child and ends after the last child.
 	 *
-	 * @param {engine.treeModel.Element} element Element which is a parent for the range.
-	 * @returns {engine.treeModel.Range} Created range.
+	 * @param {engine.model.Element} element Element which is a parent for the range.
+	 * @returns {engine.model.Range} Created range.
 	 */
 	static createFromElement( element ) {
 		return this.createFromParentsAndOffsets( element, 0, element, element.getChildCount() );
@@ -490,8 +490,8 @@ export default class Range {
 	/**
 	 * Creates a range on given element only. The range starts just before the element and ends before the first child of the element.
 	 *
-	 * @param {engine.treeModel.Element} element Element on which range should be created.
-	 * @returns {engine.treeModel.Range} Created range.
+	 * @param {engine.model.Element} element Element on which range should be created.
+	 * @returns {engine.model.Range} Created range.
 	 */
 	static createOnElement( element ) {
 		return this.createFromParentsAndOffsets( element.parent, element.getIndex(), element, 0 );
@@ -500,9 +500,9 @@ export default class Range {
 	/**
 	 * Creates a new range spreading from specified position to the same position moved by given shift.
 	 *
-	 * @param {engine.treeModel.Position} position Beginning of the range.
+	 * @param {engine.model.Position} position Beginning of the range.
 	 * @param {Number} shift How long the range should be.
-	 * @returns {engine.treeModel.Range}
+	 * @returns {engine.model.Range}
 	 */
 	static createFromPositionAndShift( position, shift ) {
 		return new this( position, position.getShiftedBy( shift ) );
@@ -511,11 +511,11 @@ export default class Range {
 	/**
 	 * Creates a range from given parents and offsets.
 	 *
-	 * @param {engine.treeModel.Element} startElement Start position parent element.
+	 * @param {engine.model.Element} startElement Start position parent element.
 	 * @param {Number} startOffset Start position offset.
-	 * @param {engine.treeModel.Element} endElement End position parent element.
+	 * @param {engine.model.Element} endElement End position parent element.
 	 * @param {Number} endOffset End position offset.
-	 * @returns {engine.treeModel.Range} Created range.
+	 * @returns {engine.model.Range} Created range.
 	 */
 	static createFromParentsAndOffsets( startElement, startOffset, endElement, endOffset ) {
 		return new this(
@@ -527,10 +527,21 @@ export default class Range {
 	/**
 	 * Creates and returns a new instance of Range which is equal to passed range.
 	 *
-	 * @param {engine.treeModel.Range} range Range to clone.
-	 * @returns {engine.treeModel.Range}
+	 * @param {engine.model.Range} range Range to clone.
+	 * @returns {engine.model.Range}
 	 */
 	static createFromRange( range ) {
 		return new this( range.start, range.end );
 	}
+
+	/**
+	 * Creates Range from deserilized object, ie. from parsed JSON string.
+	 *
+	 * @param {Object} json Deserialized JSON object.
+	 * @param {engine.model.Document} doc Document on which this operation will be applied.
+	 * @returns {engine.model.Range}
+	 */
+	static fromJSON( json, doc ) {
+		return new this( Position.fromJSON( json.start, doc ), Position.fromJSON( json.end, doc ) );
+	}
 }

+ 53 - 0
packages/ckeditor5-engine/src/model/rootelement.js

@@ -0,0 +1,53 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+import Element from './element.js';
+
+/**
+ * Class for nodes that are roots of trees in tree data model.
+ *
+ * @memberOf engine.model
+ * @extends engine.model.Element
+ */
+export default class RootElement extends Element {
+	/**
+	 * Creates tree root node.
+	 *
+	 * @param {engine.model.Document} doc {@link engine.model.Document} that is an owner of the root.
+	 * @param {String} name Node name.
+	 * @param {String} rootName Root name inside parent {@link engine.model.Document}.
+	 */
+	constructor( doc, name, rootName ) {
+		super( name );
+
+		/**
+		 * {@link engine.model.Document} that is an owner of this root.
+		 *
+		 * @readonly
+		 * @member {engine.model.Document} engine.model.RootElement#document
+		 */
+		this.document = doc;
+
+		/**
+		 * Name of this root inside {@link engine.model.Document} that is an owner of this root.
+		 *
+		 * @readonly
+		 * @member {String} engine.model.RootElement#rootName
+		 */
+		this.rootName = rootName;
+	}
+
+	/**
+	 * Custom toJSON method to solve child-parent circular dependencies.
+	 *
+	 * @method engine.model.RootElement#toJSON
+	 * @returns {String} Name of this root inside {@link engine.model.Document} that is an owner of this root.
+	 */
+	toJSON() {
+		return this.rootName;
+	}
+}

+ 26 - 26
packages/ckeditor5-engine/src/treemodel/schema.js

@@ -13,25 +13,25 @@ import isString from '../../utils/lib/lodash/isString.js';
 import CKEditorError from '../../utils/ckeditorerror.js';
 
 /**
- * SchemaItem is a singular registry item in {@link engine.treeModel.Schema} that groups and holds allow/disallow rules for
- * one entity. This class is used internally in {@link engine.treeModel.Schema} and should not be used outside it.
+ * SchemaItem is a singular registry item in {@link engine.model.Schema} that groups and holds allow/disallow rules for
+ * one entity. This class is used internally in {@link engine.model.Schema} and should not be used outside it.
  *
- * @see engine.treeModel.Schema
+ * @see engine.model.Schema
  * @protected
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export class SchemaItem {
 	/**
 	 * Creates SchemaItem instance.
 	 *
-	 * @param {engine.treeModel.Schema} schema Schema instance that owns this item.
+	 * @param {engine.model.Schema} schema Schema instance that owns this item.
 	 */
 	constructor( schema ) {
 		/**
 		 * Schema instance that owns this item.
 		 *
 		 * @private
-		 * @member {engine.treeModel.Schema} engine.treeModel.SchemaItem#_schema
+		 * @member {engine.model.Schema} engine.model.SchemaItem#_schema
 		 */
 		this._schema = schema;
 
@@ -39,7 +39,7 @@ export class SchemaItem {
 		 * Paths in which the entity, represented by this item, is allowed.
 		 *
 		 * @private
-		 * @member {Array} engine.treeModel.SchemaItem#_allowed
+		 * @member {Array} engine.model.SchemaItem#_allowed
 		 */
 		this._allowed = [];
 
@@ -47,7 +47,7 @@ export class SchemaItem {
 		 * Paths in which the entity, represented by this item, is disallowed.
 		 *
 		 * @private
-		 * @member {Array} engine.treeModel.SchemaItem#_disallowed
+		 * @member {Array} engine.model.SchemaItem#_disallowed
 		 */
 		this._disallowed = [];
 
@@ -55,7 +55,7 @@ export class SchemaItem {
 		 * Attributes that are required by the entity represented by this item.
 		 *
 		 * @protected
-		 * @member {Array} engine.treeModel.SchemaItem#_requiredAttributes
+		 * @member {Array} engine.model.SchemaItem#_requiredAttributes
 		 */
 		this._requiredAttributes = [];
 	}
@@ -136,7 +136,7 @@ export class SchemaItem {
 	 * Checks whether given set of attributes fulfills required attributes of this item.
 	 *
 	 * @protected
-	 * @see engine.treeModel.SchemaItem#requireAttributes
+	 * @see engine.model.SchemaItem#requireAttributes
 	 * @param {Array.<String>} attributesToCheck Attributes to check.
 	 * @returns {Boolean} `true` if given set or attributes fulfills required attributes, `false` otherwise.
 	 */
@@ -214,7 +214,7 @@ export class SchemaItem {
 		const json = clone( this );
 
 		// Due to circular references we need to remove parent reference.
-		json._schema = '[treeModel.Schema]';
+		json._schema = '[model.Schema]';
 
 		return json;
 	}
@@ -240,7 +240,7 @@ export class SchemaItem {
  * E.g. `p` can inherit from `$block`, so whenever given attribute is allowed on the `$block` it will automatically be
  * also allowed on the `p` element. By default, `$text` item already inherits from `$inline`.
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class Schema {
 	/**
@@ -251,7 +251,7 @@ export default class Schema {
 		 * Schema items registered in the schema.
 		 *
 		 * @private
-		 * @member {Map} engine.treeModel.Schema#_items
+		 * @member {Map} engine.model.Schema#_items
 		 */
 		this._items = new Map();
 
@@ -259,7 +259,7 @@ export default class Schema {
 		 * Description of what entities are a base for given entity.
 		 *
 		 * @private
-		 * @member {Map} engine.treeModel.Schema#_extensionChains
+		 * @member {Map} engine.model.Schema#_extensionChains
 		 */
 		this._extensionChains = new Map();
 
@@ -285,7 +285,7 @@ export default class Schema {
 	 *		schema.registerItem( 'div', '$block' );
 	 *		schema.allow( { name: 'header', inside: 'div p' } ); // inside: [ 'div', 'p' ] would also work.
 	 *
-	 * @param {engine.treeModel.SchemaQuery} query Allowed query.
+	 * @param {engine.model.SchemaQuery} query Allowed query.
 	 */
 	allow( query ) {
 		this._getItem( query.name ).allow( Schema._normalizeQueryPath( query.inside ), query.attributes );
@@ -294,8 +294,8 @@ export default class Schema {
 	/**
 	 * Disallows given query in the schema.
 	 *
-	 * @see {@link engine.treeModel.Schema#allow}
-	 * @param {engine.treeModel.SchemaQuery} query Disallowed query.
+	 * @see {@link engine.model.Schema#allow}
+	 * @param {engine.model.SchemaQuery} query Disallowed query.
 	 */
 	disallow( query ) {
 		this._getItem( query.name ).disallow( Schema._normalizeQueryPath( query.inside ), query.attributes );
@@ -350,7 +350,7 @@ export default class Schema {
 	 *		};
 	 *		if ( schema.check( query ) ) { ... }
 	 *
-	 * @param {engine.treeModel.SchemaQuery} query Query to check.
+	 * @param {engine.model.SchemaQuery} query Query to check.
 	 * @returns {Boolean} `true` if given query is allowed in schema, `false` otherwise.
 	 */
 	check( query ) {
@@ -467,12 +467,12 @@ export default class Schema {
 	}
 
 	/**
-	 * Returns {@link engine.treeModel.SchemaItem schema item} that was registered in the schema under given name.
+	 * Returns {@link engine.model.SchemaItem schema item} that was registered in the schema under given name.
 	 * If item has not been found, throws error.
 	 *
 	 * @private
 	 * @param {String} itemName Name to look for in schema.
-	 * @returns {engine.treeModel.SchemaItem} Schema item registered under given name.
+	 * @returns {engine.model.SchemaItem} Schema item registered under given name.
 	 */
 	_getItem( itemName ) {
 		if ( !this.hasItem( itemName ) ) {
@@ -488,10 +488,10 @@ export default class Schema {
 	}
 
 	/**
-	 * Normalizes a path to an entity by converting it from {@link engine.treeModel.SchemaPath} to an array of strings.
+	 * Normalizes a path to an entity by converting it from {@link engine.model.SchemaPath} to an array of strings.
 	 *
 	 * @protected
-	 * @param {engine.treeModel.SchemaPath} path Path to normalize.
+	 * @param {engine.model.SchemaPath} path Path to normalize.
 	 * @returns {Array.<String>} Normalized path.
 	 */
 	static _normalizeQueryPath( path ) {
@@ -523,11 +523,11 @@ export default class Schema {
 }
 
 /**
- * Object with query used by {@link engine.treeModel.Schema} to query schema or add allow/disallow rules to schema.
+ * Object with query used by {@link engine.model.Schema} to query schema or add allow/disallow rules to schema.
  *
- * @typedef {Object} engine.treeModel.SchemaQuery
+ * @typedef {Object} engine.model.SchemaQuery
  * @property {String} name Entity name.
- * @property {engine.treeModel.SchemaPath} inside Path inside which the entity is placed.
+ * @property {engine.model.SchemaPath} inside Path inside which the entity is placed.
  * @property {Array.<String>|String} [attributes] If set, the query applies only to entities that has attribute(s) with given key.
  */
 
@@ -536,5 +536,5 @@ export default class Schema {
  * an array of strings. If string is passed, entities from the path should be divided by ` ` (space character). If
  * an array is passed, unrecognized items are skipped. If position is passed, it is assumed that the entity is at given position.
  *
- * @typedef {String|Array.<String|engine.treeModel.Element>|engine.treeModel.Position} engine.treeModel.SchemaPath
+ * @typedef {String|Array.<String|engine.model.Element>|engine.model.Position} engine.model.SchemaPath
  */

+ 51 - 51
packages/ckeditor5-engine/src/treemodel/selection.js

@@ -17,26 +17,26 @@ import mix from '../../utils/mix.js';
 const storePrefix = 'selection:';
 
 /**
- * Represents a selection that is made on nodes in {@link engine.treeModel.Document}. `Selection` instance is
- * created by {@link engine.treeModel.Document}. You should not need to create an instance of `Selection`.
+ * Represents a selection that is made on nodes in {@link engine.model.Document}. `Selection` instance is
+ * created by {@link engine.model.Document}. You should not need to create an instance of `Selection`.
  *
  * Keep in mind that selection always contains at least one range. If no ranges has been added to selection or all ranges
- * got removed from selection, the selection will be reset to contain {@link engine.treeModel.Selection#_getDefaultRange the default range}.
+ * got removed from selection, the selection will be reset to contain {@link engine.model.Selection#_getDefaultRange the default range}.
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class Selection {
 	/**
 	 * Creates an empty selection.
 	 *
-	 * @param {engine.treeModel.Document} document Document which owns this selection.
+	 * @param {engine.model.Document} document Document which owns this selection.
 	 */
 	constructor( document ) {
 		/**
 		 * List of attributes set on current selection.
 		 *
 		 * @protected
-		 * @member {Map} engine.treeModel.Selection#_attrs
+		 * @member {Map} engine.model.Selection#_attrs
 		 */
 		this._attrs = new Map();
 
@@ -44,7 +44,7 @@ export default class Selection {
 		 * Document which owns this selection.
 		 *
 		 * @private
-		 * @member {engine.treeModel.Document} engine.treeModel.Selection#_document
+		 * @member {engine.model.Document} engine.model.Selection#_document
 		 */
 		this._document = document;
 
@@ -52,7 +52,7 @@ export default class Selection {
 		 * Specifies whether the last added range was added as a backward or forward range.
 		 *
 		 * @private
-		 * @member {Boolean} engine.treeModel.Selection#_lastRangeBackward
+		 * @member {Boolean} engine.model.Selection#_lastRangeBackward
 		 */
 		this._lastRangeBackward = false;
 
@@ -60,19 +60,19 @@ export default class Selection {
 		 * Stores all ranges that are selected.
 		 *
 		 * @private
-		 * @member {Array.<engine.treeModel.LiveRange>} engine.treeModel.Selection#_ranges
+		 * @member {Array.<engine.model.LiveRange>} engine.model.Selection#_ranges
 		 */
 		this._ranges = [];
 	}
 
 	/**
 	 * Selection anchor. Anchor may be described as a position where the selection starts. Together with
-	 * {@link engine.treeModel.Selection#focus} they define the direction of selection, which is important
+	 * {@link engine.model.Selection#focus} they define the direction of selection, which is important
 	 * when expanding/shrinking selection. Anchor is always the start or end of the most recent added range.
 	 * It may be a bit unintuitive when there are multiple ranges in selection.
 	 *
-	 * @see engine.treeModel.Selection#focus
-	 * @type {engine.treeModel.LivePosition}
+	 * @see engine.model.Selection#focus
+	 * @type {engine.model.LivePosition}
 	 */
 	get anchor() {
 		let range = this._ranges.length ? this._ranges[ this._ranges.length - 1 ] : this._getDefaultRange();
@@ -83,8 +83,8 @@ export default class Selection {
 	/**
 	 * Selection focus. Focus is a position where the selection ends.
 	 *
-	 * @see engine.treeModel.Selection#anchor
-	 * @type {engine.treeModel.LivePosition}
+	 * @see engine.model.Selection#anchor
+	 * @type {engine.model.LivePosition}
 	 */
 	get focus() {
 		let range = this._ranges.length ? this._ranges[ this._ranges.length - 1 ] : this._getDefaultRange();
@@ -121,7 +121,7 @@ export default class Selection {
 	}
 
 	/**
-	 * Specifies whether the {@link engine.treeModel.Selection#focus} precedes {@link engine.treeModel.Selection#anchor}.
+	 * Specifies whether the {@link engine.model.Selection#focus} precedes {@link engine.model.Selection#anchor}.
 	 *
 	 * @type {Boolean}
 	 */
@@ -130,16 +130,16 @@ export default class Selection {
 	}
 
 	/**
-	 * Adds a range to the selection. Added range is copied and converted to {@link engine.treeModel.LiveRange}. This means
+	 * Adds a range to the selection. Added range is copied and converted to {@link engine.model.LiveRange}. This means
 	 * that passed range is not saved in the Selection instance and you can safely operate on it.
 	 *
 	 * Accepts a flag describing in which way the selection is made - passed range might be selected from
-	 * {@link engine.treeModel.Range#start} to {@link engine.treeModel.Range#end} or from {@link engine.treeModel.Range#end}
-	 * to {@link engine.treeModel.Range#start}. The flag is used to set {@link engine.treeModel.Selection#anchor} and
-	 * {@link engine.treeModel.Selection#focus} properties.
+	 * {@link engine.model.Range#start} to {@link engine.model.Range#end} or from {@link engine.model.Range#end}
+	 * to {@link engine.model.Range#start}. The flag is used to set {@link engine.model.Selection#anchor} and
+	 * {@link engine.model.Selection#focus} properties.
 	 *
-	 * @fires engine.treeModel.Selection#change:range
-	 * @param {engine.treeModel.Range} range Range to add.
+	 * @fires engine.model.Selection#change:range
+	 * @param {engine.model.Range} range Range to add.
 	 * @param {Boolean} [isBackward] Flag describing if added range was selected forward - from start to end (`false`)
 	 * or backward - from end to start (`true`). Defaults to `false`.
 	 */
@@ -162,7 +162,7 @@ export default class Selection {
 	/**
 	 * Returns an iterator that contains copies of all ranges added to the selection.
 	 *
-	 * @returns {Iterator.<engine.treeModel.Range>}
+	 * @returns {Iterator.<engine.model.Range>}
 	 */
 	*getRanges() {
 		if ( this._ranges.length ) {
@@ -175,11 +175,11 @@ export default class Selection {
 	}
 
 	/**
-	 * Returns the first range in the selection. First range is the one which {@link engine.treeModel.Range#start start} position
-	 * {@link engine.treeModel.Position#isBefore is before} start position of all other ranges (not to confuse with the first range
+	 * Returns the first range in the selection. First range is the one which {@link engine.model.Range#start start} position
+	 * {@link engine.model.Position#isBefore is before} start position of all other ranges (not to confuse with the first range
 	 * added to the selection).
 	 *
-	 * @returns {engine.treeModel.Range}
+	 * @returns {engine.model.Range}
 	 */
 	getFirstRange() {
 		let first = null;
@@ -196,10 +196,10 @@ export default class Selection {
 	}
 
 	/**
-	 * Returns the first position in the selection. First position is the position that {@link engine.treeModel.Position#isBefore is before}
+	 * Returns the first position in the selection. First position is the position that {@link engine.model.Position#isBefore is before}
 	 * any other position in the selection ranges.
 	 *
-	 * @returns {engine.treeModel.Position}
+	 * @returns {engine.model.Position}
 	 */
 	getFirstPosition() {
 		return Position.createFromPosition( this.getFirstRange().start );
@@ -208,7 +208,7 @@ export default class Selection {
 	/**
 	 * Removes all ranges that were added to the selection. Fires update event.
 	 *
-	 * @fires engine.treeModel.Selection#change:range
+	 * @fires engine.model.Selection#change:range
 	 */
 	removeAllRanges() {
 		this.destroy();
@@ -222,8 +222,8 @@ export default class Selection {
 	 * is treated like the last added range and is used to set {@link #anchor} and {@link #focus}. Accepts a flag
 	 * describing in which way the selection is made (see {@link #addRange}).
 	 *
-	 * @fires engine.treeModel.Selection#change:range
-	 * @param {Array.<engine.treeModel.Range>} newRanges Array of ranges to set.
+	 * @fires engine.model.Selection#change:range
+	 * @param {Array.<engine.model.Range>} newRanges Array of ranges to set.
 	 * @param {Boolean} [isLastBackward] Flag describing if last added range was selected forward - from start to end (`false`)
 	 * or backward - from end to start (`true`). Defaults to `false`.
 	 */
@@ -243,10 +243,10 @@ export default class Selection {
 	/**
 	 * Sets collapsed selection in the specified location.
 	 *
-	 * The location can be specified in the same form as {@link engine.treeModel.Position.createAt} parameters.
+	 * The location can be specified in the same form as {@link engine.model.Position.createAt} parameters.
 	 *
-	 * @fires engine.treeModel.Selection#change:range
-	 * @param {engine.treeModel.Node|engine.treeModel.Position} nodeOrPosition
+	 * @fires engine.model.Selection#change:range
+	 * @param {engine.model.Node|engine.model.Position} nodeOrPosition
 	 * @param {Number|'END'|'BEFORE'|'AFTER'} [offset=0] Offset or one of the flags. Used only when
 	 * first parameter is a node.
 	 */
@@ -258,12 +258,12 @@ export default class Selection {
 	}
 
 	/**
-	 * Sets {@link engine.treeModel.Selection#focus} in the specified location.
+	 * Sets {@link engine.model.Selection#focus} in the specified location.
 	 *
-	 * The location can be specified in the same form as {@link engine.treeModel.Position.createAt} parameters.
+	 * The location can be specified in the same form as {@link engine.model.Position.createAt} parameters.
 	 *
-	 * @fires engine.treeModel.Selection#change:range
-	 * @param {engine.treeModel.Node|engine.treeModel.Position} nodeOrPosition
+	 * @fires engine.model.Selection#change:range
+	 * @param {engine.model.Node|engine.model.Position} nodeOrPosition
 	 * @param {Number|'END'|'BEFORE'|'AFTER'} [offset=0] Offset or one of the flags. Used only when
 	 * first parameter is a node.
 	 */
@@ -291,7 +291,7 @@ export default class Selection {
 	/**
 	 * Removes all attributes from the selection.
 	 *
-	 * @fires engine.treeModel.Selection#change:attribute
+	 * @fires engine.model.Selection#change:attribute
 	 */
 	clearAttributes() {
 		this._attrs.clear();
@@ -332,7 +332,7 @@ export default class Selection {
 	/**
 	 * Removes an attribute with given key from the selection.
 	 *
-	 * @fires engine.treeModel.Selection#change:attribute
+	 * @fires engine.model.Selection#change:attribute
 	 * @param {String} key Key of attribute to remove.
 	 */
 	removeAttribute( key ) {
@@ -345,7 +345,7 @@ export default class Selection {
 	/**
 	 * Sets attribute on the selection. If attribute with the same key already is set, it overwrites its values.
 	 *
-	 * @fires engine.treeModel.Selection#change:attribute
+	 * @fires engine.model.Selection#change:attribute
 	 * @param {String} key Key of attribute to set.
 	 * @param {*} value Attribute value.
 	 */
@@ -359,7 +359,7 @@ export default class Selection {
 	/**
 	 * Removes all attributes from the selection and sets given attributes.
 	 *
-	 * @fires engine.treeModel.Selection#change:attribute
+	 * @fires engine.model.Selection#change:attribute
 	 * @param {Iterable|Object} attrs Iterable object containing attributes to be set.
 	 */
 	setAttributesTo( attrs ) {
@@ -370,11 +370,11 @@ export default class Selection {
 	}
 
 	/**
-	 * Converts given range to {@link engine.treeModel.LiveRange} and adds it to internal ranges array. Throws an error
+	 * Converts given range to {@link engine.model.LiveRange} and adds it to internal ranges array. Throws an error
 	 * if given range is intersecting with any range that is already stored in this selection.
 	 *
 	 * @private
-	 * @param {engine.treeModel.Range} range Range to add.
+	 * @param {engine.model.Range} range Range to add.
 	 */
 	_pushRange( range ) {
 		for ( let i = 0; i < this._ranges.length ; i++ ) {
@@ -383,8 +383,8 @@ export default class Selection {
 				 * Trying to add a range that intersects with another range from selection.
 				 *
 				 * @error selection-range-intersects
-				 * @param {engine.treeModel.Range} addedRange Range that was added to the selection.
-				 * @param {engine.treeModel.Range} intersectingRange Range from selection that intersects with `addedRange`.
+				 * @param {engine.model.Range} addedRange Range that was added to the selection.
+				 * @param {engine.model.Range} intersectingRange Range from selection that intersects with `addedRange`.
 				 */
 				throw new CKEditorError(
 					'selection-range-intersects: Trying to add a range that intersects with another range from selection.',
@@ -562,12 +562,12 @@ export default class Selection {
 
 	/**
 	 * Returns a default range for this selection. The default range is a collapsed range that starts and ends
-	 * at the beginning of this selection's document {@link engine.treeModel.Document#_getDefaultRoot default root}.
+	 * at the beginning of this selection's document {@link engine.model.Document#_getDefaultRoot default root}.
 	 * This "artificial" range is important for algorithms that base on selection, so they won't break or need
 	 * special logic if there are no real ranges in the selection.
 	 *
 	 * @private
-	 * @returns {engine.treeModel.Range}
+	 * @returns {engine.model.Range}
 	 */
 	_getDefaultRange() {
 		const defaultRoot = this._document._getDefaultRoot();
@@ -590,14 +590,14 @@ export default class Selection {
 mix( Selection, EmitterMixin );
 
 /**
- * Fired whenever selection ranges are changed through {@link engine.treeModel.Selection Selection API}. Not fired when
- * {@link engine.treeModel.LiveRange live ranges} inserted in selection change because of Tree Model changes.
+ * Fired whenever selection ranges are changed through {@link engine.model.Selection Selection API}. Not fired when
+ * {@link engine.model.LiveRange live ranges} inserted in selection change because of Tree Model changes.
  *
- * @event engine.treeModel.Selection#change:range
+ * @event engine.model.Selection#change:range
  */
 
 /**
  * Fired whenever selection attributes are changed.
  *
- * @event engine.treeModel.Selection#change:attribute
+ * @event engine.model.Selection#change:attribute
  */

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

@@ -8,12 +8,12 @@
 import toMap from '../../utils/tomap.js';
 
 /**
- * Data structure for text with attributes. Note that `Text` is not a {@link engine.treeModel.Node}. This class is used
+ * Data structure for text with attributes. Note that `Text` is not a {@link engine.model.Node}. This class is used
  * as an aggregator for multiple characters that have same attributes. Example usage:
  *
- *		let myElem = new Element( 'li', [], new Text( 'text with attributes', { foo: true, bar: true } ) );
+ *        let myElem = new Element( 'li', [], new Text( 'text with attributes', { foo: true, bar: true } ) );
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class Text {
 	/**
@@ -27,7 +27,7 @@ export default class Text {
 		 * Text.
 		 *
 		 * @readonly
-		 * @member {String} engine.treeModel.Text#text
+		 * @member {String} engine.model.Text#text
 		 */
 		this.text = text || '';
 
@@ -35,7 +35,7 @@ export default class Text {
 		 * List of attributes bound with the text.
 		 *
 		 * @protected
-		 * @member {Map} engine.treeModel.Text#_attrs
+		 * @member {Map} engine.model.Text#_attrs
 		 */
 		this._attrs = toMap( attrs );
 	}
@@ -82,7 +82,7 @@ export default class Text {
 	/**
 	 * Removes all attributes from text and sets given attributes.
 	 *
-	 * @param {Iterable|Object} attrs Iterable object containing attributes to be set. See {@link engine.treeModel.Text#getAttributes}.
+	 * @param {Iterable|Object} attrs Iterable object containing attributes to be set. See {@link engine.model.Text#getAttributes}.
 	 */
 	setAttributesTo( attrs ) {
 		this._attrs = toMap( attrs );
@@ -104,4 +104,21 @@ export default class Text {
 	clearAttributes() {
 		this._attrs.clear();
 	}
+
+	/**
+	 * Custom toJSON method to solve child-parent circular dependencies.
+	 *
+	 * @returns {Object} Clone of this object with the parent property replaced with its name.
+	 */
+	toJSON() {
+		let json = {
+			text: this.text
+		};
+
+		if ( this._attrs.size ) {
+			json.attributes = [ ...this._attrs ];
+		}
+
+		return json;
+	}
 }

+ 18 - 18
packages/ckeditor5-engine/src/treemodel/textproxy.js

@@ -11,69 +11,69 @@ import toMap from '../../utils/tomap.js';
 /**
  * TextProxy is an aggregator for multiple CharacterProxy instances that are placed next to each other in
  * tree model, in the same parent, and all have same attributes set. Instances of this class are created and returned
- * in various algorithms that "merge characters" (see {@link engine.treeModel.TreeWalker}, {@link engine.treeModel.Range}).
+ * in various algorithms that "merge characters" (see {@link engine.model.TreeWalker}, {@link engine.model.Range}).
  *
  * **Note:** TextProxy instances are created on the fly basing on the current state of tree model and attributes
  * set on characters. Because of this it is highly unrecommended to store references to TextProxy instances
  * because they might get invalidated due to operations on Document. This is especially true when you change
  * attributes of TextProxy.
  *
- * Difference between {@link engine.treeModel.TextProxy} and {@link engine.treeModel.Text} is that the former is a set of
- * nodes taken from tree model, while {@link engine.treeModel.Text} is simply a string with attributes set.
+ * Difference between {@link engine.model.TextProxy} and {@link engine.model.Text} is that the former is a set of
+ * nodes taken from tree model, while {@link engine.model.Text} is simply a string with attributes set.
  *
- * You should never create an instance of this class by your own. Instead, use string literals or {@link engine.treeModel.Text}.
+ * You should never create an instance of this class by your own. Instead, use string literals or {@link engine.model.Text}.
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class TextProxy {
 	/**
 	 * Creates a text fragment.
 	 *
 	 * @protected
-	 * @param {engine.treeModel.CharacterProxy} firstCharacter First character node contained in {@link engine.treeModel.TextProxy}.
-	 * @param {Number} length Whole text contained in {@link engine.treeModel.TextProxy}.
+	 * @param {engine.model.CharacterProxy} firstCharacter First character node contained in {@link engine.model.TextProxy}.
+	 * @param {Number} length Whole text contained in {@link engine.model.TextProxy}.
 	 * @constructor
 	 */
 	constructor( firstCharacter, length ) {
 		/**
-		 * First character node contained in {@link engine.treeModel.TextProxy}.
+		 * First character node contained in {@link engine.model.TextProxy}.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.CharacterProxy} engine.treeModel.TextProxy#first
+		 * @member {engine.model.CharacterProxy} engine.model.TextProxy#first
 		 */
 		this.first = firstCharacter;
 
 		/**
-		 * Characters contained in {@link engine.treeModel.TextProxy}.
+		 * Characters contained in {@link engine.model.TextProxy}.
 		 *
 		 * @readonly
-		 * @member {String} engine.treeModel.TextProxy#text
+		 * @member {String} engine.model.TextProxy#text
 		 */
 		this.text = firstCharacter._nodeListText.text.substr( this.first._index, length );
 
 		/**
-		 * Last {@link engine.treeModel.CharacterProxy character node} contained in {@link engine.treeModel.TextProxy}.
+		 * Last {@link engine.model.CharacterProxy character node} contained in {@link engine.model.TextProxy}.
 		 *
 		 * @readonly
-		 * @member {engine.treeModel.CharacterProxy} engine.treeModel.TextProxy#last
+		 * @member {engine.model.CharacterProxy} engine.model.TextProxy#last
 		 */
 		this.last = this.getCharAt( this.text.length - 1 );
 	}
 
 	/**
-	 * A common parent of all character nodes contained in {@link engine.treeModel.TextProxy}.
+	 * A common parent of all character nodes contained in {@link engine.model.TextProxy}.
 	 *
-	 * @type {engine.treeModel.Element}
+	 * @type {engine.model.Element}
 	 */
 	get commonParent() {
 		return this.first.parent;
 	}
 
 	/**
-	 * Gets a character at given index and creates a {@link engine.treeModel.CharacterProxy} out of it.
+	 * Gets a character at given index and creates a {@link engine.model.CharacterProxy} out of it.
 	 *
 	 * @param {Number} index Character index.
-	 * @returns {engine.treeModel.CharacterProxy}
+	 * @returns {engine.model.CharacterProxy}
 	 */
 	getCharAt( index ) {
 		if ( index < 0 || index >= this.text.length ) {
@@ -137,7 +137,7 @@ export default class TextProxy {
 	 * will be refreshed, but other may get invalidated. It is highly unrecommended to store references to TextProxy instances.
 	 *
 	 * @param {Iterable|Object} attrs Iterable object containing attributes to be set.
-	 * See {@link engine.treeModel.TextProxy#getAttributes}.
+	 * See {@link engine.model.TextProxy#getAttributes}.
 	 */
 	setAttributesTo( attrs ) {
 		let attrsMap = toMap( attrs );

+ 35 - 34
packages/ckeditor5-engine/src/treemodel/treewalker.js

@@ -14,24 +14,25 @@ import CKEditorError from '../../utils/ckeditorerror.js';
 /**
  * Position iterator class. It allows to iterate forward and backward over the document.
  *
- * @memberOf engine.treeModel
+ * @memberOf engine.model
  */
 export default class TreeWalker {
 	/**
 	 * Creates a range iterator. All parameters are optional, but you have to specify either `boundaries` or `startPosition`.
 	 *
 	 * @param {Object} options Object with configuration.
-	 * @param {engine.treeModel.Range} [options.boundaries=null] Range to define boundaries of the iterator.
-	 * @param {engine.treeModel.Position} [options.startPosition] Starting position.
+	 * @param {engine.model.Position} [options.startPosition] Starting position.
+	 * @param {engine.model.Range} [options.boundaries=null] Range to define boundaries of the iterator.
+	 * @param {engine.model.Position} [options.startPosition] Starting position.
 	 * @param {'FORWARD'|'BACKWARD'} [options.direction='FORWARD'] Walking direction.
 	 * @param {Boolean} [options.singleCharacters=false] Flag indicating whether all consecutive characters with the same attributes
-	 * should be returned one by one as multiple {@link engine.treeModel.CharacterProxy} (`true`) objects or as one
-	 * {@link engine.treeModel.TextProxy} (`false`).
+	 * should be returned one by one as multiple {@link engine.model.CharacterProxy} (`true`) objects or as one
+	 * {@link engine.model.TextProxy} (`false`).
 	 * @param {Boolean} [options.shallow=false] Flag indicating whether iterator should enter elements or not. If the
 	 * iterator is shallow child nodes of any iterated node will not be returned along with `ELEMENT_END` tag.
 	 * @param {Boolean} [options.ignoreElementEnd=false] Flag indicating whether iterator should ignore `ELEMENT_END`
 	 * tags. If the option is true walker will not return a parent node of start position. If this option is `true`
-	 * each {@link engine.treeModel.Element} will be returned once, while if the option is `false` they might be returned
+	 * each {@link engine.model.Element} will be returned once, while if the option is `false` they might be returned
 	 * twice: for `'ELEMENT_START'` and `'ELEMENT_END'`.
 	 * @constructor
 	 */
@@ -69,7 +70,7 @@ export default class TreeWalker {
 		 *
 		 * If boundaries are not defined they are set before first and after last child of the root node.
 		 *
-		 * @member {engine.treeModel.Range} engine.treeModel.TreeWalker#boundaries
+		 * @member {engine.model.Range} engine.model.TreeWalker#boundaries
 		 */
 		this.boundaries = boundaries;
 
@@ -77,7 +78,7 @@ export default class TreeWalker {
 		 * Start boundary cached for optimization purposes.
 		 *
 		 * @private
-		 * @member {engine.treeModel.Element} engine.treeModel.TreeWalker#_boundaryStartParent
+		 * @member {engine.model.Element} engine.model.TreeWalker#_boundaryStartParent
 		 */
 		this._boundaryStartParent = this.boundaries ? this.boundaries.start.parent : null;
 
@@ -85,15 +86,15 @@ export default class TreeWalker {
 		 * End boundary cached for optimization purposes.
 		 *
 		 * @private
-		 * @member {engine.treeModel.Element} engine.treeModel.TreeWalker#_boundaryEndParent
+		 * @member {engine.model.Element} engine.model.TreeWalker#_boundaryEndParent
 		 */
 		this._boundaryEndParent = this.boundaries ? this.boundaries.end.parent : null;
 
 		/**
 		 * Iterator position. This is always static position, even if the initial position was a
-		 * {@link engine.treeModel.LivePosition live position}.
+		 * {@link engine.model.LivePosition live position}.
 		 *
-		 * @member {engine.treeModel.Position} engine.treeModel.TreeWalker#position
+		 * @member {engine.model.Position} engine.model.TreeWalker#position
 		 */
 		if ( startPosition ) {
 			this.position = Position.createFromPosition( startPosition );
@@ -104,16 +105,16 @@ export default class TreeWalker {
 		/**
 		 * Walking direction. Defaults `FORWARD`.
 		 *
-		 * @member engine.treeModel.TreeWalker#direction
-		 * @type {'BACKWARD'|'FORWARD'} core.treeModel.TreeWalkerDirection
+		 * @member engine.model.TreeWalker#direction
+		 * @type {'BACKWARD'|'FORWARD'} core.model.TreeWalkerDirection
 		 */
 		this.direction = direction;
 
 		/**
 		 * Flag indicating whether all consecutive characters with the same attributes should be
-		 * returned as one {@link engine.treeModel.CharacterProxy} (`true`) or one by one (`false`).
+		 * returned as one {@link engine.model.CharacterProxy} (`true`) or one by one (`false`).
 		 *
-		 * @member {Boolean} engine.treeModel.TreeWalker#singleCharacters
+		 * @member {Boolean} engine.model.TreeWalker#singleCharacters
 		 */
 		this.singleCharacters = !!singleCharacters;
 
@@ -121,17 +122,17 @@ export default class TreeWalker {
 		 * Flag indicating whether iterator should enter elements or not. If the iterator is shallow child nodes of any
 		 * iterated node will not be returned along with `ELEMENT_END` tag.
 		 *
-		 * @member {Boolean} engine.treeModel.TreeWalker#shallow
+		 * @member {Boolean} engine.model.TreeWalker#shallow
 		 */
 		this.shallow = !!shallow;
 
 		/**
 		 * Flag indicating whether iterator should ignore `ELEMENT_END` tags. If the option is true walker will not
-		 * return a parent node of the start position. If this option is `true` each {@link engine.treeModel.Element} will
+		 * return a parent node of the start position. If this option is `true` each {@link engine.model.Element} will
 		 * be returned once, while if the option is `false` they might be returned twice:
 		 * for `'ELEMENT_START'` and `'ELEMENT_END'`.
 		 *
-		 * @member {Boolean} engine.treeModel.TreeWalker#ignoreElementEnd
+		 * @member {Boolean} engine.model.TreeWalker#ignoreElementEnd
 		 */
 		this.ignoreElementEnd = !!ignoreElementEnd;
 
@@ -139,7 +140,7 @@ export default class TreeWalker {
 		 * Parent of the most recently visited node. Cached for optimization purposes.
 		 *
 		 * @private
-		 * @member {engine.treeModel.Element|engine.treeModel.DocumentFragment} engine.treeModel.TreeWalker#_visitedParent
+		 * @member {engine.model.Element|engine.model.DocumentFragment} engine.model.TreeWalker#_visitedParent
 		 */
 		this._visitedParent = this.position.parent;
 	}
@@ -175,7 +176,7 @@ export default class TreeWalker {
 	 *
 	 * @private
 	 * @returns {Boolean} return.done True if iterator is done.
-	 * @returns {engine.treeModel.TreeWalkerValue} return.value Information about taken step.
+	 * @returns {engine.model.TreeWalkerValue} return.value Information about taken step.
 	 */
 	_next() {
 		const previousPosition = this.position;
@@ -248,7 +249,7 @@ export default class TreeWalker {
 	 *
 	 * @private
 	 * @returns {Boolean} return.done True if iterator is done.
-	 * @returns {core.treeModel.TreeWalkerValue} return.value Information about taken step.
+	 * @returns {core.model.TreeWalkerValue} return.value Information about taken step.
 	 */
 	_previous() {
 		const previousPosition = this.position;
@@ -332,29 +333,29 @@ function formatReturnValue( type, item, previousPosition, nextPosition, length )
 }
 
 /**
- * Type of the step made by {@link engine.treeModel.TreeWalker}.
+ * Type of the step made by {@link engine.model.TreeWalker}.
  * Possible values: `'ELEMENT_START'` if walker is at the beginning of a node, `'ELEMENT_END'` if walker is at the end of node,
  * `'CHARACTER'` if walker traversed over a character, or `'TEXT'` if walker traversed over multiple characters (available in
- * character merging mode, see {@link engine.treeModel.TreeWalker#constructor}).
+ * character merging mode, see {@link engine.model.TreeWalker#constructor}).
  *
- * @typedef {String} engine.treeModel.TreeWalkerValueType
+ * @typedef {String} engine.model.TreeWalkerValueType
  */
 
 /**
- * Object returned by {@link engine.treeModel.TreeWalker} when traversing model.
+ * Object returned by {@link engine.model.TreeWalker} when traversing tree model.
  *
- * @typedef {Object} engine.treeModel.TreeWalkerValue
- * @property {engine.treeModel.TreeWalkerValueType} type
- * @property {engine.treeModel.Item} item Item between old and new positions of {@link engine.treeModel.TreeWalker}.
- * @property {engine.treeModel.Position} previousPosition Previous position of the iterator.
+ * @typedef {Object} engine.model.TreeWalkerValue
+ * @property {engine.model.TreeWalkerValueType} type
+ * @property {engine.model.Item} item Item between old and new positions of {@link engine.model.TreeWalker}.
+ * @property {engine.model.Position} previousPosition Previous position of the iterator.
  * * Forward iteration: For `'ELEMENT_END'` it is the last position inside the element. For all other types it is the
  * position before the item. Note that it is more efficient to use this position then calculate the position before
- * the node using {@link engine.treeModel.Position.createBefore}. It is also more efficient to get the
- * position after node by shifting `previousPosition` by `length`, using {@link engine.treeModel.Position#getShiftedBy},
- * then calculate the position using {@link engine.treeModel.Position.createAfter}.
+ * the node using {@link engine.model.Position.createBefore}. It is also more efficient to get the
+ * position after node by shifting `previousPosition` by `length`, using {@link engine.model.Position#getShiftedBy},
+ * then calculate the position using {@link engine.model.Position.createAfter}.
  * * Backward iteration: For `'ELEMENT_START'` it is the first position inside the element. For all other types it is
  * the position after item.
- * @property {engine.treeModel.Position} nextPosition Next position of the iterator.
+ * @property {engine.model.Position} nextPosition Next position of the iterator.
  * * Forward iteration: For `'ELEMENT_START'` it is the first position inside the element. For all other types it is
  * the position after the item.
  * * Backward iteration: For `'ELEMENT_END'` it is last position inside element. For all other types it is the position
@@ -366,5 +367,5 @@ function formatReturnValue( type, item, previousPosition, nextPosition, length )
 /**
  * Tree walking directions.
  *
- * @typedef {'FORWARD'|'BACKWARD'} core.treeModel.TreeWalkerDirection
+ * @typedef {'FORWARD'|'BACKWARD'} core.model.TreeWalkerDirection
  */

+ 0 - 10
packages/ckeditor5-engine/src/treemodel/item.jsdoc

@@ -1,10 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/**
- * Item is a {@link engine.treeModel.Node Node} or {engine.treeModel.TextProxy TextProxy}.
- *
- * @typedef {engine.treeModel.Node|engine.treeModel.TextProxy} engine.treeModel.Item
- */

+ 0 - 9
packages/ckeditor5-engine/src/treemodel/operation.jsdoc

@@ -1,9 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/**
- * Core &rarr; TreeModel &rarr; Operation namespace (`engine.treeModel.operation`).
- * @namespace engine.treeModel.operation
- */

+ 0 - 91
packages/ckeditor5-engine/src/treemodel/operation/operation.js

@@ -1,91 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-import clone from '../../../utils/lib/lodash/clone.js';
-
-/**
- * Abstract base operation class.
- *
- * @abstract
- * @memberOf engine.treeModel.operation
- */
-export default class Operation {
-	/**
-	 * Base operation constructor.
-	 * @param {Number} baseVersion {@link engine.treeModel.Document#version} on which the operation can be applied.
-	 */
-	constructor( baseVersion ) {
-		/**
-		 * {@link engine.treeModel.Document#version} on which operation can be applied. If you try to
-		 * {@link engine.treeModel.Document#applyOperation apply} operation with different base version than the
-		 * {@link engine.treeModel.Document#version document version} the {@link document-applyOperation-wrong-version}
-		 * error is thrown.
-		 *
-		 * @member {Number} engine.treeModel.operation.Operation#baseVersion
-		 */
-		this.baseVersion = baseVersion;
-
-		/**
-		 * Operation type.
-		 *
-		 * @member {String} engine.treeModel.operation.Operation#type
-		 */
-
-		/**
-		 * {@link engine.treeModel.Delta Delta} which the operation is a part of. This property is set by the
-		 * {@link engine.treeModel.Delta delta} when the operations is added to it by the
-		 * {@link engine.treeModel.Delta#addOperation} method.
-		 *
-		 * @member {engine.treeModel.Delta} engine.treeModel.operation.Operation#delta
-		 */
-
-		/**
-		 * Creates and returns an operation that has the same parameters as this operation.
-		 *
-		 * @method engine.treeModel.operation.Operation#clone
-		 * @returns {engine.treeModel.operation.Operation} Clone of this operation.
-		 */
-
-		/**
-		 * Creates and returns a reverse operation. Reverse operation when executed right after
-		 * the original operation will bring back tree model state to the point before the original
-		 * operation execution. In other words, it reverses changes done by the original operation.
-		 *
-		 * Keep in mind that tree model state may change since executing the original operation,
-		 * so reverse operation will be "outdated". In that case you will need to
-		 * {@link engine.treeModel.operation.transform} it by all operations that were executed after the original operation.
-		 *
-		 * @method engine.treeModel.operation.Operation#getReversed
-		 * @returns {engine.treeModel.operation.Operation} Reversed operation.
-		 */
-
-		/**
-		 * Executes the operation - modifications described by the operation attributes
-		 * will be applied to the tree model.
-		 *
-		 * @protected
-		 * @method engine.treeModel.operation.Operation#_execute
-		 * @returns {Object} Object with additional information about the applied changes. Always has `range`
-		 * property containing changed nodes. May have additional properties depending on the operation type.
-		 */
-	}
-
-	/**
-	 * Custom toJSON method to solve child-parent circular dependencies.
-	 *
-	 * @method engine.treeModel.operation.Operation#toJSON
-	 * @returns {Object} Clone of this object with the delta property replaced with string.
-	 */
-	toJSON() {
-		const json = clone( this );
-
-		// Due to circular references we need to remove parent reference.
-		json.delta = this.delta ? '[engine.treeModel.Delta]' : null;
-
-		return json;
-	}
-}

+ 0 - 34
packages/ckeditor5-engine/src/treemodel/rootelement.js

@@ -1,34 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-import Element from './element.js';
-
-/**
- * Class for nodes that are roots of trees in tree data model.
- *
- * @memberOf engine.treeModel
- * @extends engine.treeModel.Element
- */
-export default class RootElement extends Element {
-	/**
-	 * Creates tree root node.
-	 *
-	 * @param {engine.treeModel.Document} doc {@link engine.treeModel.Document} that is an owner of the root.
-	 * @param {String} name Node name.
-	 */
-	constructor( doc, name ) {
-		super( name );
-
-		/**
-		 * {@link engine.treeModel.Document} that is an owner of this root.
-		 *
-		 * @readonly
-		 * @member {engine.treeModel.Document} engine.treeModel.RootElement#doc
-		 */
-		this.document = doc;
-	}
-}

+ 12 - 12
packages/ckeditor5-engine/src/treeview/attributeelement.js

@@ -13,30 +13,30 @@ const DEFAULT_PRIORITY = 10;
 
 /**
  * Attributes are elements which define document presentation. They are mostly elements like `<b>` or `<span>`.
- * Attributes can be broken and merged by the {@link engine.treeView.Writer}.
+ * Attributes can be broken and merged by the {@link engine.view.Writer}.
  *
- * Editing engine does not define fixed HTML DTD. This is why the type of the {@link engine.treeView.Element} need to
- * be defined by the feature developer. Creating an element you should use {@link engine.treeView.ContainerElement}
+ * Editing engine does not define fixed HTML DTD. This is why the type of the {@link engine.view.Element} need to
+ * be defined by the feature developer. Creating an element you should use {@link engine.view.ContainerElement}
  * class or `AttributeElement`.
  *
- * @memberOf engine.treeView
- * @extends engine.treeView.Element
+ * @memberOf engine.view
+ * @extends engine.view.Element
  */
 export default class AttributeElement extends Element {
 	/**
 	 * Creates a attribute element.
 	 *
-	 * @see engine.treeView.Element
+	 * @see engine.view.Element
 	 */
 	constructor( name, attrs, children ) {
 		super( name, attrs, children );
 
 		/**
 		 * Element priority. Attributes have to have the same priority to be
-		 * {@link engine.treeView.Element#isSimilar similar}. Setting different priorities on similar
+		 * {@link engine.view.Element#isSimilar similar}. Setting different priorities on similar
  		 * nodes may prevent merging, e.g. two `<abbr>` nodes next each other shouldn't be merged.
 		 *
-		 * @member {Number} engine.treeView.AttributeElement#priority
+		 * @member {Number} engine.view.AttributeElement#priority
 		 */
 		this.priority = DEFAULT_PRIORITY;
 	}
@@ -46,7 +46,7 @@ export default class AttributeElement extends Element {
 	 *
 	 * @param {Boolean} deep If set to `true` clones element and all its children recursively. When set to `false`,
 	 * element will be cloned without any children.
-	 * @returns {engine.treeView.AttributeElement} Clone of this element.
+	 * @returns {engine.view.AttributeElement} Clone of this element.
 	 */
 	clone( deep ) {
 		const cloned = super.clone( deep );
@@ -62,7 +62,7 @@ export default class AttributeElement extends Element {
 	 * Both elements should have the same name, attributes and priority to be considered as similar.
 	 * Two similar elements can contain different set of children nodes.
 	 *
-	 * @param {engine.treeView.Element} otherElement
+	 * @param {engine.view.Element} otherElement
 	 * @returns {Boolean}
 	 */
 	isSimilar( otherElement ) {
@@ -70,7 +70,7 @@ export default class AttributeElement extends Element {
 	}
 
 	/**
-	 * Returns block {@link engine.treeView.filler filler} offset or `null` if a block filler is not needed.
+	 * Returns block {@link engine.view.filler filler} offset or `null` if a block filler is not needed.
 	 *
 	 * @returns {Number|null} Block filler offset or `null` if block filler is not needed.
 	 */
@@ -102,6 +102,6 @@ export default class AttributeElement extends Element {
 /**
  * Default attribute priority.
  *
- * @member {Number} engine.treeView.AttributeElement.DEFAULT_PRIORITY
+ * @member {Number} engine.view.AttributeElement.DEFAULT_PRIORITY
  */
 AttributeElement.DEFAULT_PRIORITY = DEFAULT_PRIORITY;

+ 12 - 12
packages/ckeditor5-engine/src/treeview/containerelement.js

@@ -9,27 +9,27 @@ import Element from './element.js';
 
 /**
  * Containers are elements which define document structure. They define boundaries for
- * {@link engine.treeView.AttributeElement attributes}. They are mostly use for block elements like `<p>` or `<div>`.
+ * {@link engine.view.AttributeElement attributes}. They are mostly use for block elements like `<p>` or `<div>`.
  *
- * Editing engine does not define fixed HTML DTD. This is why the type of the {@link engine.treeView.Element} need to
+ * Editing engine does not define fixed HTML DTD. This is why the type of the {@link engine.view.Element} need to
  * be defined by the feature developer.
  *
- * Creating an element you should use `ContainerElement` class or {@link engine.treeView.AttributeElement}. This is
+ * Creating an element you should use `ContainerElement` class or {@link engine.view.AttributeElement}. This is
  * important to define the type of the element because of two reasons:
  *
- * Firstly, {@link engine.treeView.DomConverter} needs the information what is an editable block to convert elements to
- * DOM properly. {@link engine.treeView.DomConverter} will ensure that `ContainerElement` is editable and it is possible
+ * Firstly, {@link engine.view.DomConverter} needs the information what is an editable block to convert elements to
+ * DOM properly. {@link engine.view.DomConverter} will ensure that `ContainerElement` is editable and it is possible
  * to put caret inside it, even if the container is empty.
  *
- * Secondly, {@link engine.treeView.Writer} uses this information.
- * Nodes {@link engine.treeView.Writer#breakAttributes breaking} and {@link engine.treeView.Writer#mergeAttributes merging}
+ * Secondly, {@link engine.view.Writer} uses this information.
+ * Nodes {@link engine.view.Writer#breakAttributes breaking} and {@link engine.view.Writer#mergeAttributes merging}
  * is performed only in a bounds of a container nodes.
  *
  * For instance if `<p>` is an container and `<b>` is attribute:
  *
  *		<p><b>fo^o</b></p>
  *
- * {@link engine.treeView.Writer#breakAttributes breakAttributes} will create:
+ * {@link engine.view.Writer#breakAttributes breakAttributes} will create:
  *
  *		<p><b>fo</b><b>o</b></p>
  *
@@ -39,21 +39,21 @@ import Element from './element.js';
  *		<span color="red">foobar</span>		// attribute
  *		<span data-widget>foobar</span>		// container
  *
- * @memberOf engine.treeView
- * @extends engine.treeView.Element
+ * @memberOf engine.view
+ * @extends engine.view.Element
  */
 export default class ContainerElement extends Element {
 	/**
 	 * Creates a container element.
 	 *
-	 * @see engine.treeView.Element
+	 * @see engine.view.Element
 	 */
 	constructor( name, attrs, children ) {
 		super( name, attrs, children );
 	}
 
 	/**
-	 * Returns block {@link engine.treeView.filler filler} offset or `null` if block filler is not needed.
+	 * Returns block {@link engine.view.filler filler} offset or `null` if block filler is not needed.
 	 *
 	 * @returns {Number|null} Block filler offset or `null` if block filler is not needed.
 	 */

+ 29 - 29
packages/ckeditor5-engine/src/treeview/document.js

@@ -17,13 +17,13 @@ import EmitterMixin from '../../utils/emittermixin.js';
 /**
  * Document class creates an abstract layer over the content editable area.
  * It combines the actual tree of view elements, tree of DOM elements,
- * {@link engine.treeView.DomConverter DOM Converter}, {@link engine.treeView.Renderer renderer} and all
- * {@link engine.treeView.Observer observers}.
+ * {@link engine.view.DomConverter DOM Converter}, {@link engine.view.Renderer renderer} and all
+ * {@link engine.view.Observer observers}.
  *
  * If you want to only transform the tree of view elements to the DOM elements you can use the
- * {@link engine.treeView.DomConverter DomConverter}.
+ * {@link engine.view.DomConverter DomConverter}.
  *
- * @memberOf engine.treeView
+ * @memberOf engine.view
  * @mixes utils.EmitterMixin
  */
 export default class Document {
@@ -35,7 +35,7 @@ export default class Document {
 		 * Roots of the DOM tree. Map on the `HTMLElement`s with roots names as keys.
 		 *
 		 * @readonly
-		 * @member {Map} engine.treeView.Document#domRoots
+		 * @member {Map} engine.view.Document#domRoots
 		 */
 		this.domRoots = new Map();
 
@@ -43,7 +43,7 @@ export default class Document {
 		 * Selection done on this document.
 		 *
 		 * @readonly
-		 * @member {engine.treeView.Selection} engine.treeView.Document#selection
+		 * @member {engine.view.Selection} engine.view.Document#selection
 		 */
 		this.selection = new Selection();
 
@@ -51,40 +51,40 @@ export default class Document {
 		 * Tree View writer.
 		 *
 		 * @readonly
-		 * @member {engine.treeView.Writer} engine.treeView.Document#writer
+		 * @member {engine.view.Writer} engine.view.Document#writer
 		 */
 		this.writer = new Writer();
 
 		/**
-		 * Instance of the {@link engine.treeView.DomConverter domConverter} use by
-		 * {@link engine.treeView.Document#renderer renderer} and {@link engine.treeView.observer.Observer observers}.
+		 * Instance of the {@link engine.view.DomConverter domConverter} use by
+		 * {@link engine.view.Document#renderer renderer} and {@link engine.view.observer.Observer observers}.
 		 *
 		 * @readonly
-		 * @member {engine.treeView.DomConverter} engine.treeView.Document#domConverter
+		 * @member {engine.view.DomConverter} engine.view.Document#domConverter
 		 */
 		this.domConverter = new DomConverter();
 
 		/**
-		 * Roots of the view tree. Map of the {engine.treeView.Element view elements} with roots names as keys.
+		 * Roots of the view tree. Map of the {engine.view.Element view elements} with roots names as keys.
 		 *
 		 * @readonly
-		 * @member {Map} engine.treeView.Document#viewRoots
+		 * @member {Map} engine.view.Document#viewRoots
 		 */
 		this.viewRoots = new Map();
 
 		/**
-		 * Instance of the {@link engine.treeView.Document#renderer renderer}.
+		 * Instance of the {@link engine.view.Document#renderer renderer}.
 		 *
 		 * @readonly
-		 * @member {engine.treeView.Renderer} engine.treeView.Document#renderer
+		 * @member {engine.view.Renderer} engine.view.Document#renderer
 		 */
 		this.renderer = new Renderer( this.domConverter, this.selection );
 
 		/**
-		 * Map of registered {@link engine.treeView.Observer observers}.
+		 * Map of registered {@link engine.view.Observer observers}.
 		 *
 		 * @private
-		 * @member {Map.<Function, engine.treeView.Observer>} engine.treeView.Document_#observers
+		 * @member {Map.<Function, engine.view.Observer>} engine.view.Document_#observers
 		 */
 		this._observers = new Map();
 
@@ -92,17 +92,17 @@ export default class Document {
 	}
 
 	/**
-	 * Creates observer of the given type if not yet created, {@link engine.treeView.Observer#enable enables} it
-	 * and {@link engine.treeView.observer.Observer#observe attaches} to all existing and future
-	 * {@link engine.treeView.Document#domRoots DOM roots}.
+	 * Creates observer of the given type if not yet created, {@link engine.view.Observer#enable enables} it
+	 * and {@link engine.view.observer.Observer#observe attaches} to all existing and future
+	 * {@link engine.view.Document#domRoots DOM roots}.
 	 *
 	 * Note: Observers are recognized by their constructor (classes). A single observer will be instantiated and used only
 	 * when registered for the first time. This means that features and other components can register a single observer
 	 * multiple times without caring whether it has been already added or not.
 	 *
 	 * @param {Function} Observer The constructor of an observer to add.
-	 * Should create an instance inheriting from {@link engine.treeView.observer.Observer}.
-	 * @returns {engine.treeView.observer.Observer} Added observer instance.
+	 * Should create an instance inheriting from {@link engine.view.observer.Observer}.
+	 * @returns {engine.view.observer.Observer} Added observer instance.
 	 */
 	addObserver( Observer ) {
 		let observer = this._observers.get( Observer );
@@ -128,24 +128,24 @@ export default class Document {
 	 * Returns observer of the given type or `undefined` if such observer has not been added yet.
 	 *
 	 * @param {Function} Observer The constructor of an observer to get.
-	 * @returns {engine.treeView.observer.Observer|undefined} Observer instance or undefined.
+	 * @returns {engine.view.observer.Observer|undefined} Observer instance or undefined.
 	 */
 	getObserver( Observer ) {
 		return this._observers.get( Observer );
 	}
 
 	/**
-	 * Creates a root for the HTMLElement. It adds elements to {@link engine.treeView.Document#domRoots} and
-	 * {@link engine.treeView.Document#viewRoots}.
+	 * Creates a root for the HTMLElement. It adds elements to {@link engine.view.Document#domRoots} and
+	 * {@link engine.view.Document#viewRoots}.
 	 *
 	 * The constructor copies the element name and attributes to create the
 	 * root of the view, but does not copy its children. This means that while
-	 * {@link engine.treeView.Document#render rendering}, the whole content of this
+	 * {@link engine.view.Document#render rendering}, the whole content of this
 	 * root element will be removed but the root name and attributes will be preserved.
 	 *
 	 * @param {HTMLElement} domRoot DOM element in which the tree view should do change.
 	 * @param {String} [name='main'] Name of the root.
-	 * @returns {engine.treeView.element} The created view root element.
+	 * @returns {engine.view.element} The created view root element.
 	 */
 	createRoot( domRoot, name = 'main' ) {
 		const viewRoot = this.domConverter.domToView( domRoot, { bind: true, withChildren: false } );
@@ -168,11 +168,11 @@ export default class Document {
 	}
 
 	/**
-	 * Get a {@link engine.treeView.Document#viewRoots view root element} with the specified name. If the name is not
+	 * Get a {@link engine.view.Document#viewRoots view root element} with the specified name. If the name is not
 	 * specific "main" root is returned.
 	 *
 	 * @param {String} [name='main']  Name of the root.
-	 * @returns {engine.treeView.element} The view root element with the specified name.
+	 * @returns {engine.view.element} The view root element with the specified name.
 	 */
 	getRoot( name = 'main' ) {
 		return this.viewRoots.get( name );
@@ -206,5 +206,5 @@ mix( Document, EmitterMixin );
  * * `ATTRIBUTES` - for element attributes changes,
  * * `TEXT` - for text nodes changes.
  *
- * @typedef {String} engine.treeView.ChangeType
+ * @typedef {String} engine.view.ChangeType
  */

+ 13 - 13
packages/ckeditor5-engine/src/treeview/documentfragment.js

@@ -12,13 +12,13 @@ import EmitterMixin from '../../utils/emittermixin.js';
 /**
  * DocumentFragment class.
  *
- * @memberOf engine.treeView
+ * @memberOf engine.view
  */
 export default class DocumentFragment {
 	/**
 	 * Creates new DocumentFragment instance.
 	 *
-	 * @param {engine.treeView.Node|Iterable.<engine.treeView.Node>} [children] List of nodes to be inserted into
+	 * @param {engine.view.Node|Iterable.<engine.view.Node>} [children] List of nodes to be inserted into
 	 * created document fragment.
 	 */
 	constructor( children ) {
@@ -26,7 +26,7 @@ export default class DocumentFragment {
 		 * Array of child nodes.
 		 *
 		 * @protected
-		 * @member {Array.<engine.treeView.Element>} engine.treeView.DocumentFragment#_children
+		 * @member {Array.<engine.view.Element>} engine.view.DocumentFragment#_children
 		 */
 		this._children = [];
 
@@ -43,10 +43,10 @@ export default class DocumentFragment {
 	}
 
 	/**
-	 * {@link engine.treeView.DocumentFragment#insertChildren Insert} a child node or a list of child nodes at the end
+	 * {@link engine.view.DocumentFragment#insertChildren Insert} a child node or a list of child nodes at the end
 	 * and sets the parent of these nodes to this fragment.
 	 *
-	 * @param {engine.treeView.Node|Iterable.<engine.treeView.Node>} nodes Node or the list of nodes to be inserted.
+	 * @param {engine.view.Node|Iterable.<engine.view.Node>} nodes Node or the list of nodes to be inserted.
 	 * @returns {Number} Number of appended nodes.
 	 */
 	appendChildren( nodes ) {
@@ -57,7 +57,7 @@ export default class DocumentFragment {
 	 * Gets child at the given index.
 	 *
 	 * @param {Number} index Index of child.
-	 * @returns {engine.treeView.Node} Child node.
+	 * @returns {engine.view.Node} Child node.
 	 */
 	getChild( index ) {
 		return this._children[ index ];
@@ -75,7 +75,7 @@ export default class DocumentFragment {
 	/**
 	 * Gets index of the given child node. Returns `-1` if child node is not found.
 	 *
-	 * @param {engine.treeView.Node} node Child node.
+	 * @param {engine.view.Node} node Child node.
 	 * @returns {Number} Index of the child node.
 	 */
 	getChildIndex( node ) {
@@ -85,7 +85,7 @@ export default class DocumentFragment {
 	/**
 	 * Gets child nodes iterator.
 	 *
-	 * @returns {Iterable.<engine.treeView.Node>} Child nodes iterator.
+	 * @returns {Iterable.<engine.view.Node>} Child nodes iterator.
 	 */
 	getChildren() {
 		return this._children[ Symbol.iterator ]();
@@ -96,7 +96,7 @@ export default class DocumentFragment {
 	 * this fragment.
 	 *
 	 * @param {Number} index Position where nodes should be inserted.
-	 * @param {engine.treeView.Node|Iterable.<engine.treeView.Node>} nodes Node or list of nodes to be inserted.
+	 * @param {engine.view.Node|Iterable.<engine.view.Node>} nodes Node or list of nodes to be inserted.
 	 * @returns {Number} Number of inserted nodes.
 	 */
 	insertChildren( index, nodes ) {
@@ -123,7 +123,7 @@ export default class DocumentFragment {
 	 *
 	 * @param {Number} index Number of the first node to remove.
 	 * @param {Number} [howMany=1] Number of nodes to remove.
-	 * @returns {Array.<engine.treeView.Node>} The array of removed nodes.
+	 * @returns {Array.<engine.view.Node>} The array of removed nodes.
 	 */
 	removeChildren( index, howMany = 1 ) {
 		this._fireChange( 'CHILDREN', this );
@@ -139,9 +139,9 @@ export default class DocumentFragment {
 	 * Fires `change` event with given type of the change.
 	 *
 	 * @private
-	 * @param {engine.treeView.ChangeType} type Type of the change.
-	 * @param {engine.treeView.Node} node Changed node.
-	 * @fires engine.treeView.Node#change
+	 * @param {engine.view.ChangeType} type Type of the change.
+	 * @param {engine.view.Node} node Changed node.
+	 * @fires engine.view.Node#change
 	 */
 	_fireChange( type, node ) {
 		this.fire( 'change', type, node );

+ 66 - 66
packages/ckeditor5-engine/src/treeview/domconverter.js

@@ -17,22 +17,22 @@ import indexOf from '../../utils/dom/indexof.js';
 
 /**
  * DomConverter is a set of tools to do transformations between DOM nodes and view nodes. It also handles
- * {@link engine.treeView.DomConverter#bindElements binding} these nodes.
+ * {@link engine.view.DomConverter#bindElements binding} these nodes.
  *
- * DomConverter does not check which nodes should be rendered (use {@link engine.treeView.Renderer}), does not keep a
- * state of a tree nor keeps synchronization between tree view and DOM tree (use {@link engine.treeView.Document}).
+ * DomConverter does not check which nodes should be rendered (use {@link engine.view.Renderer}), does not keep a
+ * state of a tree nor keeps synchronization between tree view and DOM tree (use {@link engine.view.Document}).
  *
  * DomConverter keeps DOM elements to View element bindings, so when the converter will be destroyed, the binding will
  * be lost. Two converters will keep separate binding maps, so one tree view can be bound with two DOM trees.
  *
- * @memberOf engine.treeView
+ * @memberOf engine.view
  */
 export default class DomConverter {
 	/**
 	 * Creates DOM converter.
 	 *
 	 * @param {Object} options Object with configuration options.
-	 * @param {Function} [options.blockFiller=engine.treeView.filler.BR_FILLER] Block filler creator.
+	 * @param {Function} [options.blockFiller=engine.view.filler.BR_FILLER] Block filler creator.
 	 */
 	constructor( options = {} ) {
 		// Using WeakMap prevent memory leaks: when the converter will be destroyed all referenced between View and DOM
@@ -46,11 +46,11 @@ export default class DomConverter {
 		// I've been here. Seen stuff. Afraid of code now.
 
 		/**
-		 * Block {@link engine.treeView.filler filler} creator, which is used to create all block fillers during the
+		 * Block {@link engine.view.filler filler} creator, which is used to create all block fillers during the
 		 * view to DOM conversion and to recognize block fillers during the DOM to view conversion.
 		 *
 		 * @readonly
-		 * @member {Function} engine.treeView.DomConverter#blockFiller
+		 * @member {Function} engine.view.DomConverter#blockFiller
 		 */
 		this.blockFiller = options.blockFiller || BR_FILLER;
 
@@ -58,7 +58,7 @@ export default class DomConverter {
 		 * DOM to View mapping.
 		 *
 		 * @private
-		 * @member {WeakMap} engine.treeView.DomConverter#_domToViewMapping
+		 * @member {WeakMap} engine.view.DomConverter#_domToViewMapping
 		 */
 		this._domToViewMapping = new WeakMap();
 
@@ -66,18 +66,18 @@ export default class DomConverter {
 		 * View to DOM mapping.
 		 *
 		 * @private
-		 * @member {WeakMap} engine.treeView.DomConverter#_viewToDomMapping
+		 * @member {WeakMap} engine.view.DomConverter#_viewToDomMapping
 		 */
 		this._viewToDomMapping = new WeakMap();
 	}
 
 	/**
 	 * Binds DOM and View elements, so it will be possible to get corresponding elements using
-	 * {@link engine.treeView.DomConverter#getCorrespondingViewElement getCorrespondingViewElement} and
-	 * {@link engine.treeView.DomConverter#getCorrespondingDomElement getCorrespondingDomElement}.
+	 * {@link engine.view.DomConverter#getCorrespondingViewElement getCorrespondingViewElement} and
+	 * {@link engine.view.DomConverter#getCorrespondingDomElement getCorrespondingDomElement}.
 	 *
 	 * @param {HTMLElement} domElement DOM element to bind.
-	 * @param {engine.treeView.Element} viewElement View element to bind.
+	 * @param {engine.view.Element} viewElement View element to bind.
 	 */
 	bindElements( domElement, viewElement ) {
 		this._domToViewMapping.set( domElement, viewElement );
@@ -86,11 +86,11 @@ export default class DomConverter {
 
 	/**
 	 * Binds DOM and View document fragments, so it will be possible to get corresponding document fragments using
-	 * {@link engine.treeView.DomConverter#getCorrespondingViewDocumentFragment getCorrespondingViewDocumentFragment} and
-	 * {@link engine.treeView.DomConverter#getCorrespondingDomDocumentFragment getCorrespondingDomDocumentFragment}.
+	 * {@link engine.view.DomConverter#getCorrespondingViewDocumentFragment getCorrespondingViewDocumentFragment} and
+	 * {@link engine.view.DomConverter#getCorrespondingDomDocumentFragment getCorrespondingDomDocumentFragment}.
 	 *
 	 * @param {DocumentFragment} domFragment DOM document fragment to bind.
-	 * @param {engine.treeView.DocumentFragment} viewFragment View document fragment to bind.
+	 * @param {engine.view.DocumentFragment} viewFragment View document fragment to bind.
 	 */
 	bindDocumentFragments( domFragment, viewFragment ) {
 		this._domToViewMapping.set( domFragment, viewFragment );
@@ -101,7 +101,7 @@ export default class DomConverter {
 	 * Converts view to DOM. For all text nodes, not bound elements and document fragments new items will
 	 * be created. For bound elements and document fragments function will return corresponding items.
 	 *
-	 * @param {engine.treeView.Node|engine.treeView.DocumentFragment} viewNode View node or document fragment to transform.
+	 * @param {engine.view.Node|engine.view.DocumentFragment} viewNode View node or document fragment to transform.
 	 * @param {document} domDocument Document which will be used to create DOM nodes.
 	 * @param {Object} [options] Conversion options.
 	 * @param {Boolean} [options.bind=false] Determines whether new elements will be bound.
@@ -150,12 +150,12 @@ export default class DomConverter {
 	}
 
 	/**
-	 * Converts children of the view element to DOM using {@link engine.treeView.DomConverter#viewToDom} method.
-	 * Additionally this method adds block {@link engine.treeView.filler filler} to the list of children, if needed.
+	 * Converts children of the view element to DOM using {@link engine.view.DomConverter#viewToDom} method.
+	 * Additionally this method adds block {@link engine.view.filler filler} to the list of children, if needed.
 	 *
-	 * @param {engine.treeView.Element|engine.treeView.DocumentFragment} viewElement Parent view element.
+	 * @param {engine.view.Element|engine.view.DocumentFragment} viewElement Parent view element.
 	 * @param {document} domDocument Document which will be used to create DOM nodes.
-	 * @param {Object} options See {@link engine.treeView.DomConverter#viewToDom} options parameter.
+	 * @param {Object} options See {@link engine.view.DomConverter#viewToDom} options parameter.
 	 * @returns {Iterable.<Node>} DOM nodes.
 	 */
 	*viewChildrenToDom( viewElement, domDocument, options = {} ) {
@@ -178,10 +178,10 @@ export default class DomConverter {
 	}
 
 	/**
-	 * Converts view {@link engine.treeView.Range} to DOM range.
-	 * Inline and block {@link engine.treeView.filler fillers} are handled during the conversion.
+	 * Converts view {@link engine.view.Range} to DOM range.
+	 * Inline and block {@link engine.view.filler fillers} are handled during the conversion.
 	 *
-	 * @param {engine.treeView.Range} viewRange View range.
+	 * @param {engine.view.Range} viewRange View range.
 	 * @returns {Range} DOM range.
 	 */
 	viewRangeToDom( viewRange ) {
@@ -196,12 +196,12 @@ export default class DomConverter {
 	}
 
 	/**
-	 * Converts view {@link engine.treeView.Position} to DOM parent and offset.
+	 * Converts view {@link engine.view.Position} to DOM parent and offset.
 	 *
-	 * Inline and block {@link engine.treeView.filler fillers} are handled during the conversion.
+	 * Inline and block {@link engine.view.filler fillers} are handled during the conversion.
 	 * If the converted position is directly before inline filler it is moved inside the filler.
 	 *
-	 * @param {engine.treeView.position} viewPosition View position.
+	 * @param {engine.view.position} viewPosition View position.
 	 * @returns {Object} position
 	 * @returns {Node} position.parent DOM position parent.
 	 * @returns {Number} position.offset DOM position offset.
@@ -247,14 +247,14 @@ export default class DomConverter {
 	/**
 	 * Converts DOM to view. For all text nodes, not bound elements and document fragments new items will
 	 * be created. For bound elements and document fragments function will return corresponding items. For
-	 * {@link engine.treeView.filler fillers} `null` will be returned.
+	 * {@link engine.view.filler fillers} `null` will be returned.
 	 *
 	 * @param {Node|DocumentFragment} domNode DOM node or document fragment to transform.
 	 * @param {Object} [options] Conversion options.
 	 * @param {Boolean} [options.bind=false] Determines whether new elements will be bound.
 	 * @param {Boolean} [options.withChildren=true] It true node's and document fragment's children will be converted too.
-	 * @returns {engine.treeView.Node|engine.treeView.DocumentFragment|null} Converted node or document fragment. Null
-	 * if DOM node is a {@link engine.treeView.filler filler}.
+	 * @returns {engine.view.Node|engine.view.DocumentFragment|null} Converted node or document fragment. Null
+	 * if DOM node is a {@link engine.view.filler filler}.
 	 */
 	domToView( domNode, options = {} ) {
 		if ( isBlockFiller( domNode, this.blockFiller )  ) {
@@ -308,12 +308,12 @@ export default class DomConverter {
 	}
 
 	/**
-	 * Converts children of the DOM element to view nodes using {@link engine.treeView.DomConverter#domToView} method.
-	 * Additionally this method omits block {@link engine.treeView.filler filler}, if it exists in the DOM parent.
+	 * Converts children of the DOM element to view nodes using {@link engine.view.DomConverter#domToView} method.
+	 * Additionally this method omits block {@link engine.view.filler filler}, if it exists in the DOM parent.
 	 *
 	 * @param {HTMLElement} domElement Parent DOM element.
-	 * @param {Object} options See {@link engine.treeView.DomConverter#domToView} options parameter.
-	 * @returns {Iterable.<engine.treeView.Node>} View nodes.
+	 * @param {Object} options See {@link engine.view.DomConverter#domToView} options parameter.
+	 * @returns {Iterable.<engine.view.Node>} View nodes.
 	 */
 	*domChildrenToView( domElement, options = {} ) {
 		for ( let i = 0; i < domElement.childNodes.length; i++ ) {
@@ -327,11 +327,11 @@ export default class DomConverter {
 	}
 
 	/**
-	 * Converts DOM selection to view {@link engine.treeView.Selection}.
+	 * Converts DOM selection to view {@link engine.view.Selection}.
 	 * Ranges which cannot be converted will be omitted.
 	 *
 	 * @param {Selection} domSelection DOM selection.
-	 * @returns {engine.treeView.Selection} View selection.
+	 * @returns {engine.view.Selection} View selection.
 	 */
 	domSelectionToView( domSelection ) {
 		const viewSelection = new ViewSelection();
@@ -349,11 +349,11 @@ export default class DomConverter {
 	}
 
 	/**
-	 * Converts DOM Range to view {@link engine.treeView.range}.
+	 * Converts DOM Range to view {@link engine.view.range}.
 	 * If the start or end position can not be converted `null` is returned.
 	 *
 	 * @param {Range} domRange DOM range.
-	 * @returns {engine.treeView.Range|null} View range.
+	 * @returns {engine.view.Range|null} View range.
 	 */
 	domRangeToView( domRange ) {
 		const viewStart = this.domPositionToView( domRange.startContainer, domRange.startOffset );
@@ -367,16 +367,16 @@ export default class DomConverter {
 	}
 
 	/**
-	 * Converts DOM parent and offset to view {@link engine.treeView.Position}.
+	 * Converts DOM parent and offset to view {@link engine.view.Position}.
 	 *
-	 * If the position is inside a {@link engine.treeView.filler filler} which has no corresponding view node,
+	 * If the position is inside a {@link engine.view.filler filler} which has no corresponding view node,
 	 * position of the filler will be converted and returned.
 	 *
 	 * If structures are too different and it is not possible to find corresponding position then `null` will be returned.
 	 *
 	 * @param {Node} domParent DOM position parent.
 	 * @param {Number} domOffset DOM position offset.
-	 * @returns {engine.treeView.Position} viewPosition View position.
+	 * @returns {engine.view.Position} viewPosition View position.
 	 */
 	domPositionToView( domParent, domOffset ) {
 		if ( isBlockFiller( domParent, this.blockFiller ) ) {
@@ -424,15 +424,15 @@ export default class DomConverter {
 
 	/**
 	 * Gets corresponding view item. This function use
-	 * {@link engine.treeView.DomConverter#getCorrespondingViewElement getCorrespondingViewElement}
-	 * for elements, {@link  engine.treeView.DomConverter#getCorrespondingViewText getCorrespondingViewText} for text
-	 * nodes and {@link engine.treeView.DomConverter#getCorrespondingViewDocumentFragment getCorrespondingViewDocumentFragment}
+	 * {@link engine.view.DomConverter#getCorrespondingViewElement getCorrespondingViewElement}
+	 * for elements, {@link  engine.view.DomConverter#getCorrespondingViewText getCorrespondingViewText} for text
+	 * nodes and {@link engine.view.DomConverter#getCorrespondingViewDocumentFragment getCorrespondingViewDocumentFragment}
 	 * for document fragments.
 	 *
-	 * Note that for the block or inline {@link engine.treeView.filler filler} this method returns `null`.
+	 * Note that for the block or inline {@link engine.view.filler filler} this method returns `null`.
 	 *
 	 * @param {Node|DocumentFragment} domNode DOM node or document fragment.
-	 * @returns {engine.treeView.Node|engine.treeView.DocumentFragment|null} Corresponding view item.
+	 * @returns {engine.view.Node|engine.view.DocumentFragment|null} Corresponding view item.
 	 */
 	getCorrespondingView( domNode ) {
 		if ( domNode instanceof HTMLElement ) {
@@ -448,10 +448,10 @@ export default class DomConverter {
 
 	/**
 	 * Gets corresponding view element. Returns element if an view element was
-	 * {@link engine.treeView.DomConverter#bindElements bound} to the given DOM element or `null` otherwise.
+	 * {@link engine.view.DomConverter#bindElements bound} to the given DOM element or `null` otherwise.
 	 *
 	 * @param {HTMLElement} domElement DOM element.
-	 * @returns {engine.treeView.Element|null} Corresponding element or `null` if no element was bound.
+	 * @returns {engine.view.Element|null} Corresponding element or `null` if no element was bound.
 	 */
 	getCorrespondingViewElement( domElement ) {
 		return this._domToViewMapping.get( domElement );
@@ -459,31 +459,31 @@ export default class DomConverter {
 
 	/**
 	 * Gets corresponding view document fragment. Returns document fragment if an view element was
-	 * {@link engine.treeView.DomConverter#bindDocumentFragments bound} to the given DOM fragment or `null` otherwise.
+	 * {@link engine.view.DomConverter#bindDocumentFragments bound} to the given DOM fragment or `null` otherwise.
 	 *
 	 * @param {DocumentFragment} domFragment DOM element.
-	 * @returns {engine.treeView.DocumentFragment|null} Corresponding document fragment or `null` if none element was bound.
+	 * @returns {engine.view.DocumentFragment|null} Corresponding document fragment or `null` if none element was bound.
 	 */
 	getCorrespondingViewDocumentFragment( domFragment ) {
 		return this._domToViewMapping.get( domFragment );
 	}
 
 	/**
-	 * Gets corresponding text node. Text nodes are not {@link engine.treeView.DomConverter#bindElements bound},
+	 * Gets corresponding text node. Text nodes are not {@link engine.view.DomConverter#bindElements bound},
 	 * corresponding text node is returned based on the sibling or parent.
 	 *
-	 * If the directly previous sibling is a {@link engine.treeView.DomConverter#bindElements bound} element, it is used
+	 * If the directly previous sibling is a {@link engine.view.DomConverter#bindElements bound} element, it is used
 	 * to find the corresponding text node.
 	 *
-	 * If this is a first child in the parent and the parent is a {@link engine.treeView.DomConverter#bindElements bound}
+	 * If this is a first child in the parent and the parent is a {@link engine.view.DomConverter#bindElements bound}
 	 * element, it is used to find the corresponding text node.
 	 *
 	 * Otherwise `null` is returned.
 	 *
-	 * Note that for the block or inline {@link engine.treeView.filler filler} this method returns `null`.
+	 * Note that for the block or inline {@link engine.view.filler filler} this method returns `null`.
 	 *
 	 * @param {Text} domText DOM text node.
-	 * @returns {engine.treeView.Text|null} Corresponding view text node or `null`, if it was not possible to find a
+	 * @returns {engine.view.Text|null} Corresponding view text node or `null`, if it was not possible to find a
 	 * corresponding node.
 	 */
 	getCorrespondingViewText( domText ) {
@@ -534,12 +534,12 @@ export default class DomConverter {
 
 	/**
 	 * Gets corresponding DOM item. This function uses
-	 * {@link engine.treeView.DomConverter#getCorrespondingDomElement getCorrespondingDomElement} for
-	 * elements, {@link engine.treeView.DomConverter#getCorrespondingDomText getCorrespondingDomText} for text nodes
-	 * and {@link engine.treeView.DomConverter#getCorrespondingDomDocumentFragment getCorrespondingDomDocumentFragment}
+	 * {@link engine.view.DomConverter#getCorrespondingDomElement getCorrespondingDomElement} for
+	 * elements, {@link engine.view.DomConverter#getCorrespondingDomText getCorrespondingDomText} for text nodes
+	 * and {@link engine.view.DomConverter#getCorrespondingDomDocumentFragment getCorrespondingDomDocumentFragment}
 	 * for document fragments.
 	 *
-	 * @param {engine.treeView.Node|engine.treeView.DomFragment} viewNode View node or document fragment.
+	 * @param {engine.view.Node|engine.view.DomFragment} viewNode View node or document fragment.
 	 * @returns {Node|DocumentFragment|null} Corresponding DOM node or document fragment.
 	 */
 	getCorrespondingDom( viewNode ) {
@@ -554,9 +554,9 @@ export default class DomConverter {
 
 	/**
 	 * Gets corresponding DOM element. Returns element if an DOM element was
-	 * {@link engine.treeView.DomConverter#bindElements bound} to the given view element or `null` otherwise.
+	 * {@link engine.view.DomConverter#bindElements bound} to the given view element or `null` otherwise.
 	 *
-	 * @param {engine.treeView.Element} viewElement View element.
+	 * @param {engine.view.Element} viewElement View element.
 	 * @returns {HTMLElement|null} Corresponding element or `null` if none element was bound.
 	 */
 	getCorrespondingDomElement( viewElement ) {
@@ -565,9 +565,9 @@ export default class DomConverter {
 
 	/**
 	 * Gets corresponding DOM document fragment. Returns document fragment if an DOM element was
-	 * {@link engine.treeView.DomConverter#bindDocumentFragments bound} to the given view document fragment or `null` otherwise.
+	 * {@link engine.view.DomConverter#bindDocumentFragments bound} to the given view document fragment or `null` otherwise.
 	 *
-	 * @param {engine.treeView.DocumentFragment} viewDocumentFragment View document fragment.
+	 * @param {engine.view.DocumentFragment} viewDocumentFragment View document fragment.
 	 * @returns {DocumentFragment|null} Corresponding document fragment or `null` if no fragment was bound.
 	 */
 	getCorrespondingDomDocumentFragment( viewDocumentFragment ) {
@@ -575,18 +575,18 @@ export default class DomConverter {
 	}
 
 	/**
-	 * Gets corresponding text node. Text nodes are not {@link engine.treeView.DomConverter#bindElements bound},
+	 * Gets corresponding text node. Text nodes are not {@link engine.view.DomConverter#bindElements bound},
 	 * corresponding text node is returned based on the sibling or parent.
 	 *
-	 * If the directly previous sibling is a {@link engine.treeView.DomConverter#bindElements bound} element, it is used
+	 * If the directly previous sibling is a {@link engine.view.DomConverter#bindElements bound} element, it is used
 	 * to find the corresponding text node.
 	 *
-	 * If this is a first child in the parent and the parent is a {@link engine.treeView.DomConverter#bindElements bound}
+	 * If this is a first child in the parent and the parent is a {@link engine.view.DomConverter#bindElements bound}
 	 * element, it is used to find the corresponding text node.
 	 *
 	 * Otherwise `null` is returned.
 	 *
-	 * @param {engine.treeView.Text} viewText View text node.
+	 * @param {engine.view.Text} viewText View text node.
 	 * @returns {Text|null} Corresponding DOM text node or `null`, if it was not possible to find a corresponding node.
 	 */
 	getCorrespondingDomText( viewText ) {

+ 31 - 31
packages/ckeditor5-engine/src/treeview/element.js

@@ -13,16 +13,16 @@ import isPlainObject from '../../utils/lib/lodash/isPlainObject.js';
 /**
  * Tree view element.
  *
- * Editing engine does not define fixed HTML DTD. This is why the type of the {@link engine.treeView.Element} need to
- * be defined by the feature developer. Creating an element you should use {@link engine.treeView.ContainerElement}
- * class or {@link engine.treeView.AttributeElement}.
+ * Editing engine does not define fixed HTML DTD. This is why the type of the {@link engine.view.Element} need to
+ * be defined by the feature developer. Creating an element you should use {@link engine.view.ContainerElement}
+ * class or {@link engine.view.AttributeElement}.
  *
  * Note that for view elements which are not created from model, like elements from mutations, paste or
- * {@link engine.treeController.DataController#set data.set} it is not possible to define the type of the element, so
- * these will be instances of the {@link engine.treeView.Element}.
+ * {@link engine.DataController#set data.set} it is not possible to define the type of the element, so
+ * these will be instances of the {@link engine.view.Element}.
  *
- * @memberOf engine.treeView
- * @extends engine.treeView.Node
+ * @memberOf engine.view
+ * @extends engine.view.Node
  */
 export default class Element extends Node {
 	/**
@@ -36,7 +36,7 @@ export default class Element extends Node {
 	 *
 	 * @param {String} name Node name.
 	 * @param {Object|Iterable} [attrs] Collection of attributes.
-	 * @param {engine.treeView.Node|Iterable.<engine.treeView.Node>} [children] List of nodes to be inserted into created element.
+	 * @param {engine.view.Node|Iterable.<engine.view.Node>} [children] List of nodes to be inserted into created element.
 	 */
 	constructor( name, attrs, children ) {
 		super();
@@ -45,7 +45,7 @@ export default class Element extends Node {
 		 * Name of the element.
 		 *
 		 * @readonly
-		 * @member {String} engine.treeView.Element#name
+		 * @member {String} engine.view.Element#name
 		 */
 		this.name = name;
 
@@ -53,7 +53,7 @@ export default class Element extends Node {
 		 * Map of attributes, where attributes names are keys and attributes values are values.
 		 *
 		 * @protected
-		 * @member {Map} engine.treeView.Element#_attrs
+		 * @member {Map} engine.view.Element#_attrs
 		 */
 		if ( isPlainObject( attrs ) ) {
 			this._attrs = objectToMap( attrs );
@@ -65,7 +65,7 @@ export default class Element extends Node {
 		 * Array of child nodes.
 		 *
 		 * @protected
-		 * @member {Array.<engine.treeView.Node>} engine.treeView.Element#_children
+		 * @member {Array.<engine.view.Node>} engine.view.Element#_children
 		 */
 		this._children = [];
 
@@ -77,7 +77,7 @@ export default class Element extends Node {
 		 * Set of classes associated with element instance.
 		 *
 		 * @protected
-		 * @member {Set} engine.treeView.Element#_classes
+		 * @member {Set} engine.view.Element#_classes
 		 */
 		this._classes = new Set();
 
@@ -92,7 +92,7 @@ export default class Element extends Node {
 		 * Map of styles.
 		 *
 		 * @protected
-		 * @member {Set} engine.treeView.Element#_styles
+		 * @member {Set} engine.view.Element#_styles
 		 */
 		this._styles = new Map();
 
@@ -108,7 +108,7 @@ export default class Element extends Node {
 	 *
 	 * @param {Boolean} deep If set to `true` clones element and all its children recursively. When set to `false`,
 	 * element will be cloned without any children.
-	 * @returns {engine.treeView.Element} Clone of this element.
+	 * @returns {engine.view.Element} Clone of this element.
 	 */
 	clone( deep ) {
 		const childrenClone = [];
@@ -131,11 +131,11 @@ export default class Element extends Node {
 	}
 
 	/**
-	 * {@link engine.treeView.Element#insert Insert} a child node or a list of child nodes at the end of this node and sets
+	 * {@link engine.view.Element#insert Insert} a child node or a list of child nodes at the end of this node and sets
 	 * the parent of these nodes to this element.
 	 *
-	 * @fires engine.treeView.Node#change
-	 * @param {engine.treeView.Node|Iterable.<engine.treeView.Node>} nodes Node or the list of nodes to be inserted.
+	 * @fires engine.view.Node#change
+	 * @param {engine.view.Node|Iterable.<engine.view.Node>} nodes Node or the list of nodes to be inserted.
 	 * @returns {Number} Number of appended nodes.
 
 	 */
@@ -147,7 +147,7 @@ export default class Element extends Node {
 	 * Gets child at the given index.
 	 *
 	 * @param {Number} index Index of child.
-	 * @returns {engine.treeView.Node} Child node.
+	 * @returns {engine.view.Node} Child node.
 	 */
 	getChild( index ) {
 		return this._children[ index ];
@@ -165,7 +165,7 @@ export default class Element extends Node {
 	/**
 	 * Gets index of the given child node. Returns `-1` if child node is not found.
 	 *
-	 * @param {engine.treeView.Node} node Child node.
+	 * @param {engine.view.Node} node Child node.
 	 * @returns {Number} Index of the child node.
 	 */
 	getChildIndex( node ) {
@@ -175,7 +175,7 @@ export default class Element extends Node {
 	/**
 	 * Gets child nodes iterator.
 	 *
-	 * @returns {Iterable.<engine.treeView.Node>} Child nodes iterator.
+	 * @returns {Iterable.<engine.view.Node>} Child nodes iterator.
 	 */
 	getChildren() {
 		return this._children[ Symbol.iterator ]();
@@ -254,7 +254,7 @@ export default class Element extends Node {
 	 *
 	 * @param {String} key Attribute key.
 	 * @param {String} value Attribute value.
-	 * @fires engine.treeView.Node#change
+	 * @fires engine.view.Node#change
 	 */
 	setAttribute( key, value ) {
 		this._fireChange( 'ATTRIBUTES', this );
@@ -273,8 +273,8 @@ export default class Element extends Node {
 	 * this element.
 	 *
 	 * @param {Number} index Position where nodes should be inserted.
-	 * @param {engine.treeView.Node|Iterable.<engine.treeView.Node>} nodes Node or the list of nodes to be inserted.
-	 * @fires engine.treeView.Node#change
+	 * @param {engine.view.Node|Iterable.<engine.view.Node>} nodes Node or the list of nodes to be inserted.
+	 * @fires engine.view.Node#change
 	 * @returns {Number} Number of inserted nodes.
 	 */
 	insertChildren( index, nodes ) {
@@ -301,7 +301,7 @@ export default class Element extends Node {
 	 *
 	 * @param {String} key Attribute key.
 	 * @returns {Boolean} Returns true if an attribute existed and has been removed.
-	 * @fires engine.treeView.Node#change
+	 * @fires engine.view.Node#change
 	 */
 	removeAttribute( key ) {
 		this._fireChange( 'ATTRIBUTES', this );
@@ -337,8 +337,8 @@ export default class Element extends Node {
 	 *
 	 * @param {Number} index Number of the first node to remove.
 	 * @param {Number} [howMany=1] Number of nodes to remove.
-	 * @returns {Array.<engine.treeView.Node>} The array of removed nodes.
-	 * @fires engine.treeView.Node#change
+	 * @returns {Array.<engine.view.Node>} The array of removed nodes.
+	 * @fires engine.view.Node#change
 	 */
 	removeChildren( index, howMany = 1 ) {
 		this._fireChange( 'CHILDREN', this );
@@ -355,7 +355,7 @@ export default class Element extends Node {
 	 * Both elements should have the same name and attributes to be considered as similar. Two similar elements
 	 * can contain different set of children nodes.
 	 *
-	 * @param {engine.treeView.Element} otherElement
+	 * @param {engine.view.Element} otherElement
 	 * @returns {Boolean}
 	 */
 	isSimilar( otherElement ) {
@@ -410,7 +410,7 @@ export default class Element extends Node {
 	 *		element.addClass( 'foo', 'bar' ); // Adds 'foo' and 'bar' classes.
 	 *
 	 * @param {...String} className
-	 * @fires engine.treeView.Node#change
+	 * @fires engine.view.Node#change
 	 */
 	addClass( ...className ) {
 		this._fireChange( 'ATTRIBUTES', this );
@@ -424,7 +424,7 @@ export default class Element extends Node {
 	 *		element.removeClass( 'foo', 'bar' ); // Removes both 'foo' and 'bar' classes.
 	 *
 	 * @param {...String} className
-	 * @fires engine.treeView.Node#change
+	 * @fires engine.view.Node#change
 	 */
 	removeClass( ...className ) {
 		this._fireChange( 'ATTRIBUTES', this );
@@ -470,7 +470,7 @@ export default class Element extends Node {
 	 *
 	 * @param {String|Object} property Property name or object with key - value pairs.
 	 * @param {String} [value] Value to set. This parameter is ignored if object is provided as the first parameter.
-	 * @fires engine.treeView.Node#change
+	 * @fires engine.view.Node#change
 	 */
 	setStyle( property, value ) {
 		this._fireChange( 'ATTRIBUTES', this );
@@ -532,7 +532,7 @@ export default class Element extends Node {
 	 *		element.removeStyle( 'color', 'border-top' ); // Removes both 'color' and 'border-top' styles.
 	 *
 	 * @param {...String} property
-	 * @fires engine.treeView.Node#change
+	 * @fires engine.view.Node#change
 	 */
 	removeStyle( ...property ) {
 		this._fireChange( 'ATTRIBUTES', this );

+ 20 - 20
packages/ckeditor5-engine/src/treeview/filler.js

@@ -18,29 +18,29 @@ import { keyCodes } from '../../utils/keyboard.js';
  * as browsers do natively. So instead of an empty `<p>` there will be `<p><br></p>`. The advantage of block filler is that
  * it is transparent for the selection, so when the caret is before the `<br>` and user presses right arrow he will be
  * moved to the next paragraph, not after the `<br>`. The disadvantage is that it breaks a block, so it can not be used
- * in the middle of a line of text. The {@link engine.treeView.filler.BR_FILLER `<br>` filler} can be replaced with any other
- * character in the data output, for instance {@link engine.treeView.filler.NBSP_FILLER non-breaking space}.
+ * in the middle of a line of text. The {@link engine.view.filler.BR_FILLER `<br>` filler} can be replaced with any other
+ * character in the data output, for instance {@link engine.view.filler.NBSP_FILLER non-breaking space}.
  *
  * * Inline filler is a filler which does not break a line of text, so it can be used inside the text, for instance in the empty
  * `<b>` surrendered by text: `foo<b></b>bar`, if we want to put the caret there. CKEditor uses a sequence of the zero-width
- * spaces as an {@link engine.treeView.filler.INLINE_FILLER inline filler} having the predetermined
- * {@link engine.treeView.filler.INLINE_FILLER_LENGTH length}. A sequence is used, instead of a single character to
+ * spaces as an {@link engine.view.filler.INLINE_FILLER inline filler} having the predetermined
+ * {@link engine.view.filler.INLINE_FILLER_LENGTH length}. A sequence is used, instead of a single character to
  * avoid threating random zero-width spaces as the inline filler. Disadvantage of the inline filler is that it is not
  * transparent for the selection. The arrow key moves the caret between zero-width spaces characters, so the additional
  * code is needed to handle the caret.
  *
- * Both inline and block fillers are handled by the {@link engine.treeView.renderer renderer} and are not present in the
+ * Both inline and block fillers are handled by the {@link engine.view.renderer renderer} and are not present in the
  * view.
  *
- * @namespace engine.treeView.filler
+ * @namespace engine.view.filler
  */
 
 /**
  * `<br> filler creator. This is a function which creates `<br data-cke-filler="true">` element.
  * It defines how the filler is created.
  *
- * @see engine.treeView.filler.NBSP_FILLER_FILLER
- * @member {Function} engine.treeView.filler.BR_FILLER
+ * @see engine.view.filler.NBSP_FILLER_FILLER
+ * @member {Function} engine.view.filler.BR_FILLER
  */
 export const BR_FILLER = ( domDocument ) => {
 	const fillerBr = domDocument.createElement( 'br' );
@@ -53,22 +53,22 @@ export const BR_FILLER = ( domDocument ) => {
  * Non-breaking space filler creator. This is a function which creates `&nbsp;` text node.
  * It defines how the filler is created.
  *
- * @see engine.treeView.filler.BR_FILLER
- * @member {Function} engine.treeView.filler.NBSP_FILLER_FILLER
+ * @see engine.view.filler.BR_FILLER
+ * @member {Function} engine.view.filler.NBSP_FILLER_FILLER
  */
 export const NBSP_FILLER = ( domDocument ) => domDocument.createTextNode( '&nbsp;' );
 
 /**
- * Length of the {@link engine.treeView.filler.INLINE_FILLER INLINE_FILLER}.
+ * Length of the {@link engine.view.filler.INLINE_FILLER INLINE_FILLER}.
  *
- * @member {Function} engine.treeView.filler.INLINE_FILLER_LENGTH
+ * @member {Function} engine.view.filler.INLINE_FILLER_LENGTH
  */
 export const INLINE_FILLER_LENGTH = 7;
 
 /**
  * Inline filler which is sequence of the zero width spaces.
  *
- * @member {String} engine.treeView.filler.INLINE_FILLER
+ * @member {String} engine.view.filler.INLINE_FILLER
  */
 export let INLINE_FILLER = '';
 
@@ -77,34 +77,34 @@ for ( let i = 0; i < INLINE_FILLER_LENGTH; i++ ) {
 }
 
 /**
- * Checks if the text node starts with the {@link engine.treeView.filler.INLINE_FILLER inline filler}.
+ * Checks if the text node starts with the {@link engine.view.filler.INLINE_FILLER inline filler}.
  *
  *		startsWithFiller( document.createTextNode( INLINE_FILLER ) ); // true
  *		startsWithFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ); // true
  *		startsWithFiller( document.createTextNode( 'foo' ) ); // false
  *
  * @param {Text} domText DOM text node.
- * @returns {Boolean} True if the text node starts with the {@link engine.treeView.filler.INLINE_FILLER inline filler}.
+ * @returns {Boolean} True if the text node starts with the {@link engine.view.filler.INLINE_FILLER inline filler}.
  */
 export function startsWithFiller( domText ) {
 	return ( domText.data.substr( 0, INLINE_FILLER_LENGTH ) === INLINE_FILLER );
 }
 
 /**
- * Checks if the text node contains only the {@link engine.treeView.filler.INLINE_FILLER inline filler}.
+ * Checks if the text node contains only the {@link engine.view.filler.INLINE_FILLER inline filler}.
  *
  *		isInlineFiller( document.createTextNode( INLINE_FILLER ) ); // true
  *		isInlineFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ); // false
  *
  * @param {Text} domText DOM text node.
- * @returns {Boolean} True if the text node contains only the {@link engine.treeView.filler.INLINE_FILLER inline filler}.
+ * @returns {Boolean} True if the text node contains only the {@link engine.view.filler.INLINE_FILLER inline filler}.
  */
 export function isInlineFiller( domText ) {
 	return domText.data.length == INLINE_FILLER_LENGTH && startsWithFiller( domText );
 }
 
 /**
- * Get string data from the text node, removing an {@link engine.treeView.filler.INLINE_FILLER inline filler} from it,
+ * Get string data from the text node, removing an {@link engine.view.filler.INLINE_FILLER inline filler} from it,
  * if text node contains it.
  *
  *		getDataWithoutFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ) == 'foo' // true
@@ -132,7 +132,7 @@ const templateBlockFillers = new WeakMap();
  *
  * @param {Node} domNode DOM node to check.
  * @param {Function} blockFiller Block filler creator.
- * @returns {Boolean} True if text node contains only {@link engine.treeView.filler.INLINE_FILLER inline filler}.
+ * @returns {Boolean} True if text node contains only {@link engine.view.filler.INLINE_FILLER inline filler}.
  */
 export function isBlockFiller( domNode, blockFiller ) {
 	let templateBlockFiller = templateBlockFillers.get( blockFiller );
@@ -149,7 +149,7 @@ export function isBlockFiller( domNode, blockFiller ) {
  * Assign key observer which move cursor from the end of the inline filler to the begging of it when
  * the left arrow is pressed, so the filler does not break navigation.
  *
- * @param {engine.treeView.Document} document Document instance we should inject quirks handling on.
+ * @param {engine.view.Document} document Document instance we should inject quirks handling on.
  */
 export function injectQuirksHandling( document ) {
 	document.on( 'keydown', jumpOverInlineFiller );

+ 20 - 20
packages/ckeditor5-engine/src/treeview/matcher.js

@@ -7,15 +7,15 @@
 
 /**
  * View matcher class.
- * Instance of this class can be used to find {@link engine.treeView.Element elements} that match given pattern.
+ * Instance of this class can be used to find {@link engine.view.Element elements} that match given pattern.
  *
- * @memberOf engine.treeView
+ * @memberOf engine.view
  */
 export default class Matcher {
 	/**
 	 * Creates new instance of Matcher.
 	 *
-	 * @param {String|RegExp|Object} [pattern] Match patterns. See {@link engine.treeView.Matcher#add add method} for
+	 * @param {String|RegExp|Object} [pattern] Match patterns. See {@link engine.view.Matcher#add add method} for
 	 * more information.
 	 */
 	constructor( ...pattern ) {
@@ -90,9 +90,9 @@ export default class Matcher {
 	 *
 	 * @param {Object|String|RegExp|function} pattern Object describing pattern details. If string or regular expression
 	 * is provided it will be used to match element's name. Pattern can be also provided in a form
-	 * of a function - then this function will be called with each {@link engine.treeView.Element element} as a parameter.
+	 * of a function - then this function will be called with each {@link engine.view.Element element} as a parameter.
 	 * Function's return value will be stored under `match` key of the object returned from
-	 * {@link engine.treeView.Matcher#match match} or {@link engine.treeView.Matcher#matchAll matchAll} methods.
+	 * {@link engine.view.Matcher#match match} or {@link engine.view.Matcher#matchAll matchAll} methods.
 	 * @param {String|RegExp} [pattern.name] Name or regular expression to match element's name.
 	 * @param {Object} [pattern.attribute] Object with key-value pairs representing attributes to match. Each object key
 	 * represents attribute name. Value under that key can be either a string or a regular expression and it will be
@@ -121,7 +121,7 @@ export default class Matcher {
 
 	/**
 	 * Matches elements for currently stored patterns. Returns match information about first found
-	 * {@link engine.treeView.Element element}, otherwise returns `null`.
+	 * {@link engine.view.Element element}, otherwise returns `null`.
 	 *
 	 * Example of returned object:
 	 *
@@ -136,11 +136,11 @@ export default class Matcher {
 	 *			}
 	 *		}
 	 *
-	 * @see engine.treeView.Matcher#add
-	 * @see engine.treeView.Matcher#matchAll
-	 * @param {...core.treeView.Element} element View element to match against stored patterns.
+	 * @see engine.view.Matcher#add
+	 * @see engine.view.Matcher#matchAll
+	 * @param {...core.view.Element} element View element to match against stored patterns.
 	 * @returns {Object|null} result
-	 * @returns {core.treeView.Element} result.element Matched view element.
+	 * @returns {core.view.Element} result.element Matched view element.
 	 * @returns {Object|String|RegExp|function} result.pattern Pattern that was used to find matched element.
 	 * @returns {Object} result.match Object representing matched element parts.
 	 * @returns {Boolean} [result.match.name] True if name of the element was matched.
@@ -168,13 +168,13 @@ export default class Matcher {
 
 	/**
 	 * Matches elements for currently stored patterns. Returns array of match information with all found
-	 * {@link engine.treeView.Element elements}. If no element is found - returns `null`.
+	 * {@link engine.view.Element elements}. If no element is found - returns `null`.
 	 *
-	 * @see engine.treeView.Matcher#add
-	 * @see engine.treeView.Matcher#match
-	 * @param {...engine.treeView.Element} element View element to match against stored patterns.
+	 * @see engine.view.Matcher#add
+	 * @see engine.view.Matcher#match
+	 * @param {...engine.view.Element} element View element to match against stored patterns.
 	 * @returns {Array.<Object>|null} Array with match information about found elements or `null`. For more information
-	 * see {@link engine.treeView.Matcher#match match method} description.
+	 * see {@link engine.view.Matcher#match match method} description.
 	 */
 	matchAll( ...element ) {
 		const results = [];
@@ -210,10 +210,10 @@ export default class Matcher {
 
 }
 
-// Returns match information if {@link engine.treeView.Element element} is matching provided pattern.
+// Returns match information if {@link engine.view.Element element} is matching provided pattern.
 // If element cannot be matched to provided pattern - returns `null`.
 //
-// @param {engine.treeView.Element} element
+// @param {engine.view.Element} element
 // @param {Object|String|RegExp|function} pattern
 // @returns {Object|null} Returns object with match information or null if element is not matching.
 function isElementMatching( element, pattern ) {
@@ -280,7 +280,7 @@ function matchName( pattern, name ) {
 //
 // @param {Object} patterns Object with information about attributes to match. Each key of the object will be
 // used as attribute name. Value of each key can be a string or regular expression to match against attribute value.
-// @param {engine.treeView.Element} element Element which attributes will be tested.
+// @param {engine.view.Element} element Element which attributes will be tested.
 // @returns {Array|null} Returns array with matched attribute names or `null` if no attributes were matched.
 function matchAttributes( patterns, element ) {
 	const match = [];
@@ -313,7 +313,7 @@ function matchAttributes( patterns, element ) {
 // Checks if classes of provided element can be matched against provided patterns.
 //
 // @param {Array.<String|RegExp>} patterns Array of strings or regular expressions to match against element's classes.
-// @param {engine.treeView.Element} element Element which classes will be tested.
+// @param {engine.view.Element} element Element which classes will be tested.
 // @returns {Array|null} Returns array with matched class names or `null` if no classes were matched.
 function matchClasses( patterns, element ) {
 	const match = [];
@@ -345,7 +345,7 @@ function matchClasses( patterns, element ) {
 //
 // @param {Object} patterns Object with information about styles to match. Each key of the object will be
 // used as style name. Value of each key can be a string or regular expression to match against style value.
-// @param {engine.treeView.Element} element Element which styles will be tested.
+// @param {engine.view.Element} element Element which styles will be tested.
 // @returns {Array|null} Returns array with matched style names or `null` if no styles were matched.
 function matchStyles( patterns, element ) {
 	const match = [];

+ 26 - 26
packages/ckeditor5-engine/src/treeview/node.js

@@ -13,7 +13,7 @@ import mix from '../../utils/mix.js';
  * Abstract tree view node class.
  *
  * @abstract
- * @memberOf engine.treeView
+ * @memberOf engine.view
  */
 export default class Node {
 	/**
@@ -23,18 +23,18 @@ export default class Node {
 	 */
 	constructor() {
 		/**
-		 * Parent element. Null by default. Set by {@link engine.treeView.Element#insertChildren}.
+		 * Parent element. Null by default. Set by {@link engine.view.Element#insertChildren}.
 		 *
 		 * @readonly
-		 * @member {engine.treeView.Element|engine.treeView.DocumentFragment|null} engine.treeView.Node#parent
+		 * @member {engine.view.Element|engine.view.DocumentFragment|null} engine.view.Node#parent
 		 */
 		this.parent = null;
 
 		/**
-		 * {@link engine.treeView.Document} reference.
+		 * {@link engine.view.Document} reference.
 		 *
 		 * @protected
-		 * @member {engine.treeView.Document} engine.treeView.Node#_document
+		 * @member {engine.view.Document} engine.view.Node#_document
 		 */
 		this._document = null;
 	}
@@ -58,9 +58,9 @@ export default class Node {
 			/**
 			 * The node's parent does not contain this node. It means that the document tree is corrupted.
 			 *
-			 * @error treeview-node-not-found-in-parent
+			 * @error view-node-not-found-in-parent
 			 */
-			throw new CKEditorError( 'treeview-node-not-found-in-parent: The node\'s parent does not contain this node.' );
+			throw new CKEditorError( 'view-node-not-found-in-parent: The node\'s parent does not contain this node.' );
 		}
 
 		return pos;
@@ -69,7 +69,7 @@ export default class Node {
 	/**
 	 * Returns nodes next sibling or `null` if it is the last child.
 	 *
-	 * @returns {engine.treeView.Node|null} Nodes next sibling or `null` if it is the last child.
+	 * @returns {engine.view.Node|null} Nodes next sibling or `null` if it is the last child.
 	 */
 	getNextSibling() {
 		const index = this.getIndex();
@@ -80,7 +80,7 @@ export default class Node {
 	/**
 	 * Returns nodes previous sibling or `null` if it is the first child.
 	 *
-	 * @returns {engine.treeView.Node|null} Nodes previous sibling or `null` if it is the first child.
+	 * @returns {engine.view.Node|null} Nodes previous sibling or `null` if it is the first child.
 	 */
 	getPreviousSibling() {
 		const index = this.getIndex();
@@ -89,11 +89,11 @@ export default class Node {
 	}
 
 	/**
-	 * Gets {@link engine.treeView.Document} reference. If the node has {@link engine.treeView.Document}, assign by
-	 * {@link engine.treeView.Node#setDocument} it will be returned. Otherwise {@link engine.treeView.Document} of the parents node
+	 * Gets {@link engine.view.Document} reference. If the node has {@link engine.view.Document}, assign by
+	 * {@link engine.view.Node#setDocument} it will be returned. Otherwise {@link engine.view.Document} of the parents node
 	 * will be returned. If node has no parent, `null` will be returned.
 	 *
-	 * @returns {engine.treeView.Document|null} Tree view of the node, tree view of the parent or null.
+	 * @returns {engine.view.Document|null} Tree view of the node, tree view of the parent or null.
 	 */
 	getDocument() {
 		if ( this._document ) {
@@ -127,10 +127,10 @@ export default class Node {
 	}
 
 	/**
-	 * Sets the {@link engine.treeView.Document} of the node. Note that not all of nodes need to have {@link engine.treeView.Document}
-	 * assigned, see {@link engine.treeView.Node#getDocument}.
+	 * Sets the {@link engine.view.Document} of the node. Note that not all of nodes need to have {@link engine.view.Document}
+	 * assigned, see {@link engine.view.Node#getDocument}.
 	 *
-	 * @param {engine.treeView.Document} document Document.
+	 * @param {engine.view.Document} document Document.
 	 */
 	setDocument( document ) {
 		this._document = document;
@@ -144,9 +144,9 @@ export default class Node {
 	}
 
 	/**
-	 * @param {engine.treeView.ChangeType} type Type of the change.
-	 * @param {engine.treeView.Node} node Changed node.
-	 * @fires engine.treeView.Node#change
+	 * @param {engine.view.ChangeType} type Type of the change.
+	 * @param {engine.view.Node} node Changed node.
+	 * @fires engine.view.Node#change
 	 */
 	_fireChange( type, node ) {
 		this.fire( 'change', type, node );
@@ -159,28 +159,28 @@ export default class Node {
 	/**
 	 * Clones this node.
 	 *
-	 * @method treeView.Node#clone
-	 * @returns {treeView.Node} Clone of this node.
+	 * @method view.Node#clone
+	 * @returns {view.Node} Clone of this node.
 	 */
 
 	/**
 	 * Checks if provided node is similar to this node.
 	 *
-	 * @method treeView.Node#isSimilar
+	 * @method view.Node#isSimilar
 	 * @returns {Boolean} True if nodes are similar.
 	 */
 
 	/**
 	 * Fired when a node changes.
 	 *
-	 * * In case of {@link engine.treeView.Text text nodes} it will be a change of the text data.
-	 * * In case of {@link engine.treeView.Element elements} it will be a change of child nodes or attributes.
+	 * * In case of {@link engine.view.Text text nodes} it will be a change of the text data.
+	 * * In case of {@link engine.view.Element elements} it will be a change of child nodes or attributes.
 	 *
 	 * Change event is bubbling, it is fired on the ancestors chain.
 	 *
-	 * @event engine.treeView.Node#change
-	 * @param {engine.treeView.ChangeType} Type of the change.
-	 * @param {engine.treeView.Node} Changed node.
+	 * @event engine.view.Node#change
+	 * @param {engine.view.ChangeType} Type of the change.
+	 * @param {engine.view.Node} Changed node.
 	 */
 }
 

+ 7 - 7
packages/ckeditor5-engine/src/treeview/observer/domeventdata.js

@@ -8,15 +8,15 @@
 import extend from '../../../utils/lib/lodash/extend.js';
 
 /**
- * Information about a DOM event in context of the {@link engine.treeView.Document}.
+ * Information about a DOM event in context of the {@link engine.view.Document}.
  * It wraps the native event, which usually should not be used as the wrapper contains
  * additional data (like key code for keyboard events).
  *
- * @memberOf engine.treeView.observer
+ * @memberOf engine.view.observer
  */
 export default class DomEventData {
 	/**
-	 * @param {engine.treeView.Document} document The instance of the tree view Document.
+	 * @param {engine.view.Document} document The instance of the tree view Document.
 	 * @param {Event} domEvent The DOM event.
 	 * @param {Object} [additionalData] Additional properties that the instance should contain.
 	 */
@@ -25,7 +25,7 @@ export default class DomEventData {
 		 * The instance of the document.
 		 *
 		 * @readonly
-		 * @member {engine.treeView.Document} engine.treeView.observer.DomEvent#treeView
+		 * @member {engine.view.Document} engine.view.observer.DomEvent#view
 		 */
 		this.document = document;
 
@@ -33,7 +33,7 @@ export default class DomEventData {
 		 * The DOM event.
 		 *
 		 * @readonly
-		 * @member {Event} engine.treeView.observer.DomEvent#domEvent
+		 * @member {Event} engine.view.observer.DomEvent#domEvent
 		 */
 		this.domEvent = domEvent;
 
@@ -41,7 +41,7 @@ export default class DomEventData {
 		 * The DOM target.
 		 *
 		 * @readonly
-		 * @member {HTMLElement} engine.treeView.observer.DomEvent#target
+		 * @member {HTMLElement} engine.view.observer.DomEvent#target
 		 */
 		this.domTarget = domEvent.target;
 
@@ -52,7 +52,7 @@ export default class DomEventData {
 	 * The tree view element representing the target.
 	 *
 	 * @readonly
-	 * @type engine.treeView.Element
+	 * @type engine.view.Element
 	 */
 	get target() {
 		return this.document.domConverter.getCorrespondingViewElement( this.domTarget );

+ 15 - 15
packages/ckeditor5-engine/src/treeview/observer/domeventobserver.js

@@ -10,12 +10,12 @@ import DomEventData from './domeventdata.js';
 
 /**
  * Base class for DOM event observers. This class handles
- * {@link engine.treeView.observer.Observer#observe adding} listeners to DOM elements,
- * {@link engine.treeView.observer.Observer#disable disabling} and
- * {@link engine.treeView.observer.Observer#enable re-enabling} events.
+ * {@link engine.view.observer.Observer#observe adding} listeners to DOM elements,
+ * {@link engine.view.observer.Observer#disable disabling} and
+ * {@link engine.view.observer.Observer#enable re-enabling} events.
  * Child class needs to define
- * {@link engine.treeView.observer.DomEventObserver#domEventType DOM event type} and
- * {@link engine.treeView.observer.DomEventObserver#onDomEvent callback}.
+ * {@link engine.view.observer.DomEventObserver#domEventType DOM event type} and
+ * {@link engine.view.observer.DomEventObserver#onDomEvent callback}.
  *
  * For instance:
  *
@@ -30,8 +30,8 @@ import DomEventData from './domeventdata.js';
  *			}
  *		}
  *
- * @memberOf engine.treeView.observer
- * @extends engine.treeView.observer.Observer
+ * @memberOf engine.view.observer
+ * @extends engine.view.observer.Observer
  */
 export default class DomEventObserver extends Observer {
 	/**
@@ -39,16 +39,16 @@ export default class DomEventObserver extends Observer {
 	 * if the obsever should listen to multiple DOM events.
 	 *
 	 * @readonly
-	 * @member {String|Array.<String>} engine.treeView.observer.DomEventObserver#domEventType
+	 * @member {String|Array.<String>} engine.view.observer.DomEventObserver#domEventType
 	 */
 
 	/**
 	 * Callback which should be called when the DOM event occurred. Note that the callback will not be called if
-	 * observer {@link engine.treeView.observer.DomEventObserver#isEnabled is not enabled}.
+	 * observer {@link engine.view.observer.DomEventObserver#isEnabled is not enabled}.
 	 *
-	 * @see engine.treeView.observer.DomEventObserver#domEventType
+	 * @see engine.view.observer.DomEventObserver#domEventType
 	 * @abstract
-	 * @method engine.treeView.observer.DomEventObserver#onDomEvent
+	 * @method engine.view.observer.DomEventObserver#onDomEvent
 	 */
 
 	/**
@@ -63,14 +63,14 @@ export default class DomEventObserver extends Observer {
 	}
 
 	/**
-	 * Calls {@link engine.treeView.Document#fire} if observer
-	 * {@link engine.treeView.observer.DomEventObserver#isEnabled is enabled}.
+	 * Calls {@link engine.view.Document#fire} if observer
+	 * {@link engine.view.observer.DomEventObserver#isEnabled is enabled}.
 	 *
-	 * @see engine.treeView.Document#fire
+	 * @see engine.view.Document#fire
 	 * @param {String} eventType The event type (name).
 	 * @param {Event} domEvent The DOM event.
 	 * @param {Object} [additionalData] The additional data which should extend the
-	 * {@link engine.treeView.observer.DomEventData event data} object.
+	 * {@link engine.view.observer.DomEventData event data} object.
 	 */
 	fire( eventType, domEvent, additionalData ) {
 		if ( this.isEnabled ) {

+ 7 - 7
packages/ckeditor5-engine/src/treeview/observer/focusobserver.js

@@ -8,10 +8,10 @@
 import DomEventObserver from './domeventobserver.js';
 
 /**
- * {@link engine.treeView.Document#focus Focus} and {@link engine.treeView.Document#blur blur} events observer.
+ * {@link engine.view.Document#focus Focus} and {@link engine.view.Document#blur blur} events observer.
  *
- * @memberOf engine.treeView.observer
- * @extends engine.treeView.observer.DomEventObserver
+ * @memberOf engine.view.observer
+ * @extends engine.view.observer.DomEventObserver
  */
 export default class FocusObserver extends DomEventObserver {
 	constructor( document ) {
@@ -28,13 +28,13 @@ export default class FocusObserver extends DomEventObserver {
 /**
  * Fired when one of the editables gets focus.
  *
- * @event engine.treeView.Document#focus
- * @param {engine.treeView.observer.DomEventData} data Event data.
+ * @event engine.view.Document#focus
+ * @param {engine.view.observer.DomEventData} data Event data.
  */
 
 /**
  * Fired when one of the editables loses focus.
  *
- * @event engine.treeView.Document#blur
- * @param {engine.treeView.observer.DomEventData} data Event data.
+ * @event engine.view.Document#blur
+ * @param {engine.view.observer.DomEventData} data Event data.
  */

+ 9 - 9
packages/ckeditor5-engine/src/treeview/observer/keyobserver.js

@@ -9,10 +9,10 @@ import DomEventObserver from './domeventobserver.js';
 import { getCode } from '../../../utils/keyboard.js';
 
 /**
- * {@link engine.treeView.Document#keydown Key down} event observer.
+ * {@link engine.view.Document#keydown Key down} event observer.
  *
- * @memberOf engine.treeView.observer
- * @extends engine.treeView.observer.DomEventObserver
+ * @memberOf engine.view.observer
+ * @extends engine.view.observer.DomEventObserver
  */
 export default class KeyObserver extends DomEventObserver {
 	constructor( document ) {
@@ -39,15 +39,15 @@ export default class KeyObserver extends DomEventObserver {
 /**
  * Fired when a key has been pressed.
  *
- * @event engine.treeView.Document#keydown
- * @param {engine.treeView.observer.keyObserver.KeyEventData} keyEventData
+ * @event engine.view.Document#keydown
+ * @param {engine.view.observer.keyObserver.KeyEventData} keyEventData
  */
 
 /**
- * The value of the {@link engine.treeView.Document#keydown} event.
+ * The value of the {@link engine.view.Document#keydown} event.
  *
- * @class engine.treeView.observer.keyObserver.KeyEventData
- * @extends engine.treeView.observer.DomEventData
+ * @class engine.view.observer.keyObserver.KeyEventData
+ * @extends engine.view.observer.DomEventData
  * @implements utils.keyboard.KeystrokeData
  */
 
@@ -55,5 +55,5 @@ export default class KeyObserver extends DomEventObserver {
  * Code of the whole keystroke. See {@link utils.keyboard.getCode}.
  *
  * @readonly
- * @member {Number} engine.treeView.observer.keyObserver.KeyEventData#keystroke
+ * @member {Number} engine.view.observer.keyObserver.KeyEventData#keystroke
  */

+ 30 - 30
packages/ckeditor5-engine/src/treeview/observer/mutationobserver.js

@@ -9,18 +9,18 @@ import Observer from './observer.js';
 import { startsWithFiller, getDataWithoutFiller } from '../filler.js';
 
 /**
- * Mutation observer class observes changes in the DOM, fires {@link engine.treeView.Document#mutations} event, mark view elements
- * as changed and call {@link engine.treeView.render}. Because all mutated nodes are marked as "to be rendered" and the
- * {@link engine.treeView.render} is called, all changes will be reverted, unless the mutation will be handled by the
- * {@link engine.treeView.Document#mutations} event listener. It means user will see only handled changes, and the editor will
+ * Mutation observer class observes changes in the DOM, fires {@link engine.view.Document#mutations} event, mark view elements
+ * as changed and call {@link engine.view.render}. Because all mutated nodes are marked as "to be rendered" and the
+ * {@link engine.view.render} is called, all changes will be reverted, unless the mutation will be handled by the
+ * {@link engine.view.Document#mutations} event listener. It means user will see only handled changes, and the editor will
  * block all changes which are not handled.
  *
  * Mutation Observer also take care of reducing number of mutations which are fired. It removes duplicates and
  * mutations on elements which do not have corresponding view elements. Also
- * {@link engine.treeView.Document.MutatatedText text mutation} is fired only if parent element do not change child list.
+ * {@link engine.view.Document.MutatatedText text mutation} is fired only if parent element do not change child list.
  *
- * @memberOf engine.treeView.observer
- * @extends engine.treeView.observer.Observer
+ * @memberOf engine.view.observer
+ * @extends engine.view.observer.Observer
  */
 export default class MutationObserver extends Observer {
 	constructor( document ) {
@@ -30,7 +30,7 @@ export default class MutationObserver extends Observer {
 		 * Native mutation observer config.
 		 *
 		 * @private
-		 * @member {Object} engine.treeView.observer.MutationObserver#_config
+		 * @member {Object} engine.view.observer.MutationObserver#_config
 		 */
 		this._config = {
 			childList: true,
@@ -40,16 +40,16 @@ export default class MutationObserver extends Observer {
 		};
 
 		/**
-		 * Reference to the {@link engine.treeView.Document#domConverter}.
+		 * Reference to the {@link engine.view.Document#domConverter}.
 		 *
-		 * @member {engine.treeView.DomConverter} engine.treeView.observer.MutationObserver#domConverter
+		 * @member {engine.view.DomConverter} engine.view.observer.MutationObserver#domConverter
 		 */
 		this.domConverter = document.domConverter;
 
 		/**
-		 * Reference to the {@link engine.treeView.Document#renderer}.
+		 * Reference to the {@link engine.view.Document#renderer}.
 		 *
-		 * @member {engine.treeView.Renderer} engine.treeView.observer.MutationObserver#renderer
+		 * @member {engine.view.Renderer} engine.view.observer.MutationObserver#renderer
 		 */
 		this.renderer = document.renderer;
 
@@ -57,7 +57,7 @@ export default class MutationObserver extends Observer {
 		 * Observed DOM elements.
 		 *
 		 * @private
-		 * @member {Array.<HTMLElement>} engine.treeView.observer.MutationObserver#_domElements
+		 * @member {Array.<HTMLElement>} engine.view.observer.MutationObserver#_domElements
 		 */
 		this._domElements = [];
 
@@ -65,13 +65,13 @@ export default class MutationObserver extends Observer {
 		 * Native mutation observer.
 		 *
 		 * @private
-		 * @member {MutationObserver} engine.treeView.observer.MutationObserver#_mutationObserver
+		 * @member {MutationObserver} engine.view.observer.MutationObserver#_mutationObserver
 		 */
 		this._mutationObserver = new window.MutationObserver( this._onMutations.bind( this ) );
 	}
 
 	/**
-	 * Synchronously fires {@link engine.treeView.Document#mutations} event with all mutations in record queue.
+	 * Synchronously fires {@link engine.view.Document#mutations} event with all mutations in record queue.
 	 * At the same time empties the queue so mutations will not be fired twice.
 	 *
 	 * @returns {[type]} [description]
@@ -115,7 +115,7 @@ export default class MutationObserver extends Observer {
 	 * Handles mutations. Deduplicates, mark view elements to sync, fire event and call render.
 	 *
 	 * @private
-	 * @method engine.treeView.observer.MutationObserver#_onMutations
+	 * @method engine.view.observer.MutationObserver#_onMutations
 	 * @param {Array.<Object>} domMutations Array of native mutations.
 	 */
 	_onMutations( domMutations ) {
@@ -201,23 +201,23 @@ export default class MutationObserver extends Observer {
  * Fired when mutation occurred. If tree view is not changed on this event, DOM will be reverter to the state before
  * mutation, so all changes which should be applied, should be handled on this event.
  *
- * @event engine.treeView.Document#mutations
- * @param {Array.<engine.treeView.Document~MutatatedText|engine.treeView.Document~MutatatedChildren>} viewMutations
+ * @event engine.view.Document#mutations
+ * @param {Array.<engine.view.Document~MutatatedText|engine.view.Document~MutatatedChildren>} viewMutations
  * Array of mutations.
- * For mutated texts it will be {@link engine.treeView.Document~MutatatedText} and for mutated elements it will be
- * {@link engine.treeView.Document~MutatatedElement}. You can recognize the type based on the `type` property.
+ * For mutated texts it will be {@link engine.view.Document~MutatatedText} and for mutated elements it will be
+ * {@link engine.view.Document~MutatatedElement}. You can recognize the type based on the `type` property.
  */
 
 /**
  * Mutation item for text.
  *
- * @see engine.treeView.Document#mutations
- * @see engine.treeView.MutatatedChildren
+ * @see engine.view.Document#mutations
+ * @see engine.view.MutatatedChildren
  *
- * @typedef {Object} engine.treeView.MutatatedText
+ * @typedef {Object} engine.view.MutatatedText
  *
  * @property {String} type For text mutations it is always 'text'.
- * @property {engine.treeView.Text} node Mutated text node.
+ * @property {engine.view.Text} node Mutated text node.
  * @property {String} oldText Old text.
  * @property {String} newText New text.
  */
@@ -225,13 +225,13 @@ export default class MutationObserver extends Observer {
 /**
  * Mutation item for child nodes.
  *
- * @see engine.treeView.Document#mutations
- * @see engine.treeView.MutatatedText
+ * @see engine.view.Document#mutations
+ * @see engine.view.MutatatedText
  *
- * @typedef {Object} engine.treeView.MutatatedChildren
+ * @typedef {Object} engine.view.MutatatedChildren
  *
  * @property {String} type For child nodes mutations it is always 'children'.
- * @property {engine.treeView.Element} node Parent of the mutated children.
- * @property {Array.<engine.treeView.Node>} oldChildren Old child nodes.
- * @property {Array.<engine.treeView.Node>} newChildren New child nodes.
+ * @property {engine.view.Element} node Parent of the mutated children.
+ * @property {Array.<engine.view.Node>} oldChildren Old child nodes.
+ * @property {Array.<engine.view.Node>} newChildren New child nodes.
  */

+ 12 - 12
packages/ckeditor5-engine/src/treeview/observer/observer.js

@@ -7,23 +7,23 @@
 
 /**
  * Abstract base observer class. Observers are classes which observe changes on DOM elements, do the preliminary
- * processing and fire events on the {@link engine.treeView.Document} objects.
+ * processing and fire events on the {@link engine.view.Document} objects.
  *
  * @abstract
- * @memberOf engine.treeView.observer
+ * @memberOf engine.view.observer
  */
 export default class Observer {
 	/**
 	 * Creates an instance of the observer.
 	 *
-	 * @param {engine.treeView.Document} document
+	 * @param {engine.view.Document} document
 	 */
 	constructor( document ) {
 		/**
-		 * Reference to the {@link engine.treeView.Document} object.
+		 * Reference to the {@link engine.view.Document} object.
 		 *
 		 * @readonly
-		 * @member {engine.treeView.Document} engine.treeView.observer.Observer#document
+		 * @member {engine.view.Document} engine.view.observer.Observer#document
 		 */
 		this.document = document;
 
@@ -31,20 +31,20 @@ export default class Observer {
 		 * State of the observer. If it is disabled events will not be fired.
 		 *
 		 * @readonly
-		 * @member {Boolean} engine.treeView.observer.Observer#isEnabled
+		 * @member {Boolean} engine.view.observer.Observer#isEnabled
 		 */
 		this.isEnabled = false;
 	}
 
 	/**
 	 * Enables the observer. This method is called when then observer is registered to the
-	 * {@link engine.treeView.Document} and after {@link engine.treeView.Document#render rendering}
-	 * (all observers are {@link engine.treeView.observer.Observer#disable disabled} before rendering).
+	 * {@link engine.view.Document} and after {@link engine.view.Document#render rendering}
+	 * (all observers are {@link engine.view.observer.Observer#disable disabled} before rendering).
 	 *
 	 * A typical use case for disabling observers is that mutation observers need to be disabled for the rendering.
 	 * However, a child class may not need to be disabled, so it can implement an empty method.
 	 *
-	 * @see engine.treeView.observer.Observer#disable
+	 * @see engine.view.observer.Observer#disable
 	 */
 	enable() {
 		this.isEnabled = true;
@@ -52,9 +52,9 @@ export default class Observer {
 
 	/**
 	 * Disables the observer. This method is called before
-	 * {@link engine.treeView.Document#render rendering} to prevent firing events during rendering.
+	 * {@link engine.view.Document#render rendering} to prevent firing events during rendering.
 	 *
-	 * @see engine.treeView.observer.Observer#enable
+	 * @see engine.view.observer.Observer#enable
 	 */
 	disable() {
 		this.isEnabled = false;
@@ -63,7 +63,7 @@ export default class Observer {
 	/**
 	 * Starts observing the given root element.
 	 *
-	 * @method engine.treeView.observer.Observer#observe
+	 * @method engine.view.observer.Observer#observe
 	 * @param {HTMLElement} domElement
 	 * @param {String} name The name of the root element.
 	 */

+ 8 - 0
packages/ckeditor5-engine/src/view/observer/observer.jsdoc

@@ -0,0 +1,8 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/**
+ * @namespace engine.view.observer
+ */

+ 21 - 21
packages/ckeditor5-engine/src/treeview/observer/selectionobserver.js

@@ -11,13 +11,13 @@ import MutationObserver from './mutationobserver.js';
 /**
  * Selection observer class observes selection changes in the document. If selection changes on the document this
  * observer checks if there are any mutations and if DOM selection is different than the
- * {@link engine.treeView.Document#selection view selection}. Selection observer fires
- * {@link engine.treeView.Document#selectionChange} event only if selection change was the only change in the document
+ * {@link engine.view.Document#selection view selection}. Selection observer fires
+ * {@link engine.view.Document#selectionChange} event only if selection change was the only change in the document
  * and DOM selection is different then the view selection.
  *
- * @see engine.treeView.MutationObserver
- * @memberOf engine.treeView.observer
- * @extends engine.treeView.observer.Observer
+ * @see engine.view.MutationObserver
+ * @memberOf engine.view.observer
+ * @extends engine.view.observer.Observer
  */
 export default class SelectionObserver extends Observer {
 	constructor( document ) {
@@ -25,35 +25,35 @@ export default class SelectionObserver extends Observer {
 
 		/**
 		 * Instance of the mutation observer. Selection observer calls
-		 * {@link engine.treeView.observer.MutationObserver#flush} to ensure that the mutations will be handled before the
-		 * {@link engine.treeView.Document#selectionChange} event is fired.
+		 * {@link engine.view.observer.MutationObserver#flush} to ensure that the mutations will be handled before the
+		 * {@link engine.view.Document#selectionChange} event is fired.
 		 *
 		 * @readonly
-		 * @member {engine.treeView.observer.MutationObserver} engine.treeView.observer.SelectionObserver#mutationObserver
+		 * @member {engine.view.observer.MutationObserver} engine.view.observer.SelectionObserver#mutationObserver
 		 */
 		this.mutationObserver = document.getObserver( MutationObserver );
 
 		/**
-		 * Reference to the {@link engine.treeView.Document} object.
+		 * Reference to the {@link engine.view.Document} object.
 		 *
 		 * @readonly
-		 * @member {engine.treeView.Document} engine.treeView.observer.SelectionObserver#document
+		 * @member {engine.view.Document} engine.view.observer.SelectionObserver#document
 		 */
 		this.document = document;
 
 		/**
-		 * Reference to the TreeView {@link engine.treeView.Selection} object used to compare new selection with it.
+		 * Reference to the view {@link engine.view.Selection} object used to compare new selection with it.
 		 *
 		 * @readonly
-		 * @member {engine.treeView.Document} engine.treeView.observer.SelectionObserver#selection
+		 * @member {engine.view.Document} engine.view.observer.SelectionObserver#selection
 		 */
 		this.selection = document.selection;
 
 		/**
-		 * Reference to the {@link engine.treeView.Document#domConverter}.
+		 * Reference to the {@link engine.view.Document#domConverter}.
 		 *
 		 * @readonly
-		 * @member {engine.treeView.DomConverter} engine.treeView.observer.SelectionObserver#domConverter
+		 * @member {engine.view.DomConverter} engine.view.observer.SelectionObserver#domConverter
 		 */
 		this.domConverter = document.domConverter;
 
@@ -62,7 +62,7 @@ export default class SelectionObserver extends Observer {
 		 * document.
 		 *
 		 * @private
-		 * @member {WeakSet.<Document>} engine.treeView.observer.SelectionObserver#_documents
+		 * @member {WeakSet.<Document>} engine.view.observer.SelectionObserver#_documents
 		 */
 		this._documents = new WeakSet();
 	}
@@ -84,8 +84,8 @@ export default class SelectionObserver extends Observer {
 	}
 
 	/**
-	 * Selection change listener. {@link engine.treeView.observer.MutationObserver#flush Flush} mutations, check if
-	 * selection changes and fires {@link engine.treeView.Document#selectionChange} event.
+	 * Selection change listener. {@link engine.view.observer.MutationObserver#flush Flush} mutations, check if
+	 * selection changes and fires {@link engine.view.Document#selectionChange} event.
 	 *
 	 * @private
 	 * @param {Document} domDocument DOM document.
@@ -122,10 +122,10 @@ export default class SelectionObserver extends Observer {
  * Fired when selection has changed. This event is fired only when the selection change was the only change that happened
  * in the document, and old selection is different then the new selection.
  *
- * @event engine.treeView.Document#selectionChange
+ * @event engine.view.Document#selectionChange
  * @param {Object} data
- * @param {engine.treeView.Selection} data.oldSelection Old View selection which is
- * {@link engine.treeView.Document#selection}.
- * @param {engine.treeView.Selection} data.newSelection New View selection which is converted DOM selection.
+ * @param {engine.view.Selection} data.oldSelection Old View selection which is
+ * {@link engine.view.Document#selection}.
+ * @param {engine.view.Selection} data.newSelection New View selection which is converted DOM selection.
  * @param {Selection} data.domSelection Native DOM selection.
  */

+ 25 - 25
packages/ckeditor5-engine/src/treeview/position.js

@@ -13,27 +13,27 @@ import CKEditorError from '../../utils/ckeditorerror.js';
 /**
  * Position in the tree. Position is always located before or after a node.
  *
- * @memberOf engine.treeView
+ * @memberOf engine.view
  */
 export default class Position {
 	/**
 	 * Creates a position.
 	 *
-	 * @param {engine.treeView.Node} parent Position parent node.
+	 * @param {engine.view.Node} parent Position parent node.
 	 * @param {Number} offset Position offset.
 	 */
 	constructor( parent, offset ) {
 		/**
 		 * Position parent node.
 		 *
-		 * @member {engine.treeView.Node} engine.treeView.Position#parent
+		 * @member {engine.view.Node} engine.view.Position#parent
 		 */
 		this.parent = parent;
 
 		/**
 		 * Position offset.
 		 *
-		 * @member {Number} engine.treeView.Position#offset
+		 * @member {Number} engine.view.Position#offset
 		 */
 		this.offset = offset;
 	}
@@ -43,7 +43,7 @@ export default class Position {
 	 * inside text node.
 	 *
 	 * @readonly
-	 * @type {engine.treeView.Node|null}
+	 * @type {engine.view.Node|null}
 	 */
 	get nodeAfter() {
 		if ( this.parent instanceof Text ) {
@@ -58,7 +58,7 @@ export default class Position {
 	 * inside text node.
 	 *
 	 * @readonly
-	 * @type {engine.treeView.Node|null}
+	 * @type {engine.view.Node|null}
 	 */
 	get nodeBefore() {
 		if ( this.parent instanceof Text ) {
@@ -72,7 +72,7 @@ export default class Position {
 	 * Returns a new instance of Position with offset incremented by `shift` value.
 	 *
 	 * @param {Number} shift How position offset should get changed. Accepts negative values.
-	 * @returns {engine.treeView.Position} Shifted position.
+	 * @returns {engine.view.Position} Shifted position.
 	 */
 	getShiftedBy( shift ) {
 		let shifted = Position.createFromPosition( this );
@@ -86,7 +86,7 @@ export default class Position {
 	/**
 	 * Checks whether this position equals given position.
 	 *
-	 * @param {engine.treeView.Position} otherPosition Position to compare with.
+	 * @param {engine.view.Position} otherPosition Position to compare with.
 	 * @returns {Boolean} True if positions are same.
 	 */
 	isEqual( otherPosition ) {
@@ -98,9 +98,9 @@ export default class Position {
 	 * this position is after give one. Two positions may be located inside separate roots and in that situation this
 	 * method will still return `false`.
 	 *
-	 * @see engine.treeView.Position#isAfter
-	 * @see engine.treeView.Position#compareWith
-	 * @param {engine.treeView.Position} otherPosition Position to compare with.
+	 * @see engine.view.Position#isAfter
+	 * @see engine.view.Position#compareWith
+	 * @param {engine.view.Position} otherPosition Position to compare with.
 	 * @returns {Boolean} Returns `true` if this position is before given position.
 	 */
 	isBefore( otherPosition ) {
@@ -112,9 +112,9 @@ export default class Position {
 	 * this position is before give one. Two positions may be located inside separate roots and in that situation this
 	 * method will still return `false`.
 	 *
-	 * @see engine.treeView.Position#isBefore
-	 * @see engine.treeView.Position#compareWith
-	 * @param {engine.treeView.Position} otherPosition Position to compare with.
+	 * @see engine.view.Position#isBefore
+	 * @see engine.view.Position#compareWith
+	 * @param {engine.view.Position} otherPosition Position to compare with.
 	 * @returns {Boolean} Returns `true` if this position is after given position.
 	 */
 	isAfter( otherPosition ) {
@@ -125,8 +125,8 @@ export default class Position {
 	 * Checks whether this position is before, after or in same position that other position. Two positions may be also
 	 * different when they are located in separate roots.
 	 *
-	 * @param {engine.treeView.Position} otherPosition Position to compare with.
-	 * @returns {engine.treeView.PositionRelation}
+	 * @param {engine.view.Position} otherPosition Position to compare with.
+	 * @returns {engine.view.PositionRelation}
 	 */
 	compareWith( otherPosition ) {
 		if ( this.isEqual( otherPosition ) ) {
@@ -189,8 +189,8 @@ export default class Position {
 	/**
 	 * Creates a new position after the given node.
 	 *
-	 * @param {engine.treeView.Node} node Node after which the position should be located.
-	 * @returns {engine.treeView.Position}
+	 * @param {engine.view.Node} node Node after which the position should be located.
+	 * @returns {engine.view.Position}
 	 */
 	static createAfter( node ) {
 		if ( !node.parent ) {
@@ -198,7 +198,7 @@ export default class Position {
 			 * You can not make a position after a root.
 			 *
 			 * @error position-after-root
-			 * @param {engine.treeView.Node} root
+			 * @param {engine.view.Node} root
 			 */
 			throw new CKEditorError( 'position-after-root: You can not make position after root.', { root: node } );
 		}
@@ -209,8 +209,8 @@ export default class Position {
 	/**
 	 * Creates a new position before the given node.
 	 *
-	 * @param {engine.treeView.node} node Node before which the position should be located.
-	 * @returns {engine.treeView.Position}
+	 * @param {engine.view.node} node Node before which the position should be located.
+	 * @returns {engine.view.Position}
 	 */
 	static createBefore( node ) {
 		if ( !node.parent ) {
@@ -218,7 +218,7 @@ export default class Position {
 			 * You cannot make a position before a root.
 			 *
 			 * @error position-before-root
-			 * @param {engine.treeView.Node} root
+			 * @param {engine.view.Node} root
 			 */
 			throw new CKEditorError( 'position-before-root: You can not make position before root.', { root: node } );
 		}
@@ -229,8 +229,8 @@ export default class Position {
 	/**
 	 * Creates and returns a new instance of `Position`, which is equal to the passed position.
 	 *
-	 * @param {engine.treeView.Position} position Position to be cloned.
-	 * @returns {engine.treeView.Position}
+	 * @param {engine.view.Position} position Position to be cloned.
+	 * @returns {engine.view.Position}
 	 */
 	static createFromPosition( position ) {
 		return new this( position.parent, position.offset );
@@ -241,5 +241,5 @@ export default class Position {
  * A flag indicating whether this position is `'BEFORE'` or `'AFTER'` or `'SAME'` as given position.
  * If positions are in different roots `'DIFFERENT'` flag is returned.
  *
- * @typedef {String} engine.treeView.PositionRelation
+ * @typedef {String} engine.view.PositionRelation
  */

+ 15 - 15
packages/ckeditor5-engine/src/treeview/range.js

@@ -10,30 +10,30 @@ import Position from './position.js';
 /**
  * Tree view range.
  *
- * @memberOf engine.treeView
+ * @memberOf engine.view
  */
 export default class Range {
 	/**
 	 * Creates a range spanning from `start` position to `end` position.
-	 * **Note:** Constructor creates it's own {@link engine.treeView.Position} instances basing on passed values.
+	 * **Note:** Constructor creates it's own {@link engine.view.Position} instances basing on passed values.
 	 *
-	 * @param {engine.treeView.Position} start Start position.
-	 * @param {engine.treeView.Position} end End position.
+	 * @param {engine.view.Position} start Start position.
+	 * @param {engine.view.Position} end End position.
 	 */
 	constructor( start, end ) {
 		/**
 		 * Start position.
 		 *
-		 * @member engine.treeView.Range#start
-		 * @type {engine.treeView.Position}
+		 * @member engine.view.Range#start
+		 * @type {engine.view.Position}
 		 */
 		this.start = Position.createFromPosition( start );
 
 		/**
 		 * End position.
 		 *
-		 * @member engine.treeView.Range#end
-		 * @type {engine.treeView.Position}
+		 * @member engine.view.Range#end
+		 * @type {engine.view.Position}
 		 */
 		this.end = Position.createFromPosition( end );
 	}
@@ -50,7 +50,7 @@ export default class Range {
 	/**
 	 * Two ranges equal if their start and end positions equal.
 	 *
-	 * @param {engine.treeView.Range} otherRange Range to compare with.
+	 * @param {engine.view.Range} otherRange Range to compare with.
 	 * @returns {Boolean} True if ranges equal.
 	 */
 	isEqual( otherRange ) {
@@ -60,7 +60,7 @@ export default class Range {
 	/**
 	 * Checks and returns whether this range intersects with given range.
 	 *
-	 * @param {engine.treeView.Range} otherRange Range to compare with.
+	 * @param {engine.view.Range} otherRange Range to compare with.
 	 * @returns {Boolean} True if ranges intersect.
 	 */
 	isIntersecting( otherRange ) {
@@ -70,11 +70,11 @@ export default class Range {
 	/**
 	 * Creates a range from given parents and offsets.
 	 *
-	 * @param {engine.treeView.Element} startElement Start position parent element.
+	 * @param {engine.view.Element} startElement Start position parent element.
 	 * @param {Number} startOffset Start position offset.
-	 * @param {engine.treeView.Element} endElement End position parent element.
+	 * @param {engine.view.Element} endElement End position parent element.
 	 * @param {Number} endOffset End position offset.
-	 * @returns {engine.treeView.Range} Created range.
+	 * @returns {engine.view.Range} Created range.
 	 */
 	static createFromParentsAndOffsets( startElement, startOffset, endElement, endOffset ) {
 		return new this(
@@ -86,8 +86,8 @@ export default class Range {
 	/**
 	 * Creates and returns a new instance of Range which is equal to passed range.
 	 *
-	 * @param {engine.treeView.Range} range Range to clone.
-	 * @returns {engine.treeView.Range}
+	 * @param {engine.view.Range} range Range to clone.
+	 * @returns {engine.view.Range}
 	 */
 	static createFromRange( range ) {
 		return new this( range.start, range.end );

+ 30 - 30
packages/ckeditor5-engine/src/treeview/renderer.js

@@ -18,31 +18,31 @@ import CKEditorError from '../../utils/ckeditorerror.js';
 /**
  * Renderer updates DOM structure and selection, to make them a reflection of the view structure and selection.
  *
- * View nodes which may need to be rendered needs to be {@link engine.treeView.Renderer#markToSync marked}.
- * Then, on {@link engine.treeView.Renderer#render render}, renderer compares the view nodes with the DOM nodes
+ * View nodes which may need to be rendered needs to be {@link engine.view.Renderer#markToSync marked}.
+ * Then, on {@link engine.view.Renderer#render render}, renderer compares the view nodes with the DOM nodes
  * in order to check which ones really need to be refreshed. Finally, it creates DOM nodes from these view nodes,
- * {@link engine.treeView.DomConverter#bindElements binds} them and inserts into the DOM tree.
+ * {@link engine.view.DomConverter#bindElements binds} them and inserts into the DOM tree.
  *
- * Every time {@link engine.treeView.Renderer#render render} is called, renderer additionally checks if
- * {@link engine.treeView.Renderer#selection selection} needs update and updates it if so.
+ * Every time {@link engine.view.Renderer#render render} is called, renderer additionally checks if
+ * {@link engine.view.Renderer#selection selection} needs update and updates it if so.
  *
- * Renderer uses {@link engine.treeView.DomConverter} to transform and bind nodes.
+ * Renderer uses {@link engine.view.DomConverter} to transform and bind nodes.
  *
- * @memberOf engine.treeView
+ * @memberOf engine.view
  */
 export default class Renderer {
 	/**
 	 * Creates a renderer instance.
 	 *
-	 * @param {engine.treeView.DomConverter} domConverter Converter instance.
-	 * @param {engine.treeView.Selection} selection View selection.
+	 * @param {engine.view.DomConverter} domConverter Converter instance.
+	 * @param {engine.view.Selection} selection View selection.
 	 */
 	constructor( domConverter, selection ) {
 		/**
 		 * Converter instance.
 		 *
 		 * @readonly
-		 * @member {engine.treeView.DomConverter} engine.treeView.Renderer#domConverter
+		 * @member {engine.view.DomConverter} engine.view.Renderer#domConverter
 		 */
 		this.domConverter = domConverter;
 
@@ -50,7 +50,7 @@ export default class Renderer {
 		 * Set of nodes which attributes changed and may need to be rendered.
 		 *
 		 * @readonly
-		 * @member {Set.<engine.treeView.Node>} engine.treeView.Renderer#markedAttributes
+		 * @member {Set.<engine.view.Node>} engine.view.Renderer#markedAttributes
 		 */
 		this.markedAttributes = new Set();
 
@@ -58,7 +58,7 @@ export default class Renderer {
 		 * Set of elements which child lists changed and may need to be rendered.
 		 *
 		 * @readonly
-		 * @member {Set.<engine.treeView.Node>} engine.treeView.Renderer#markedChildren
+		 * @member {Set.<engine.view.Node>} engine.view.Renderer#markedChildren
 		 */
 		this.markedChildren = new Set();
 
@@ -66,7 +66,7 @@ export default class Renderer {
 		 * Set of text nodes which text data changed and may need to be rendered.
 		 *
 		 * @readonly
-		 * @member {Set.<engine.treeView.Node>} engine.treeView.Renderer#markedTexts
+		 * @member {Set.<engine.view.Node>} engine.view.Renderer#markedTexts
 		 */
 		this.markedTexts = new Set();
 
@@ -74,16 +74,16 @@ export default class Renderer {
 		 * View selection. Renderer updates DOM Selection to make it match this one.
 		 *
 		 * @readonly
-		 * @member {engine.treeView.Selection} engine.treeView.Renderer#selection
+		 * @member {engine.view.Selection} engine.view.Renderer#selection
 		 */
 		this.selection = selection;
 
 		/**
-		 * Position of the inline {@link engine.treeView.filler filler}.
+		 * Position of the inline {@link engine.view.filler filler}.
 		 * It should always be put BEFORE the text which contains filler.
 		 *
 		 * @private
-		 * @member {engine.treeView.Position} engine.treeView.Renderer#_inlineFillerPosition
+		 * @member {engine.view.Position} engine.view.Renderer#_inlineFillerPosition
 		 */
 		this._inlineFillerPosition = null;
 
@@ -95,7 +95,7 @@ export default class Renderer {
 		 * is rendered.
 		 *
 		 * @private
-		 * @member {Selection} engine.treeView.Renderer#_domSelection
+		 * @member {Selection} engine.view.Renderer#_domSelection
 		 */
 		this._domSelection = null;
 	}
@@ -105,12 +105,12 @@ export default class Renderer {
 	 *
 	 * Note that only view nodes which parents have corresponding DOM elements need to be marked to be synchronized.
 	 *
-	 * @see engine.treeView.Renderer#markedAttributes
-	 * @see engine.treeView.Renderer#markedChildren
-	 * @see engine.treeView.Renderer#markedTexts
+	 * @see engine.view.Renderer#markedAttributes
+	 * @see engine.view.Renderer#markedChildren
+	 * @see engine.view.Renderer#markedTexts
 	 *
-	 * @param {engine.treeView.ChangeType} type Type of the change.
-	 * @param {engine.treeView.Node} node Node to be marked.
+	 * @param {engine.view.ChangeType} type Type of the change.
+	 * @param {engine.view.Node} node Node to be marked.
 	 */
 	markToSync( type, node ) {
 		if ( type === 'TEXT' ) {
@@ -140,8 +140,8 @@ export default class Renderer {
 	}
 
 	/**
-	 * Render method checks {@link engine.treeView.Renderer#markedAttributes},
-	 * {@link engine.treeView.Renderer#markedChildren} and {@link engine.treeView.Renderer#markedTexts} and updats all
+	 * Render method checks {@link engine.view.Renderer#markedAttributes},
+	 * {@link engine.view.Renderer#markedChildren} and {@link engine.view.Renderer#markedTexts} and updats all
 	 * nodes which need to be updated. Then it clears all three sets. Also, every time render is called it compares and
 	 * if needed updates the selection.
 	 *
@@ -153,12 +153,12 @@ export default class Renderer {
 	 *
 	 * For text nodes it updates the text string if it is different. Note that if parent element is marked as an element
 	 * which changed child list, text node update will not be done, because it may not be possible do find a
-	 * {@link engine.treeView.DomConverter#getCorrespondingDomText corresponding DOM text}. The change will be handled
+	 * {@link engine.view.DomConverter#getCorrespondingDomText corresponding DOM text}. The change will be handled
 	 * in the parent element.
 	 *
 	 * For elements, which child lists have changed, it calculates a {@link diff} and adds or removs children which have changed.
 	 *
-	 * Rendering also handles {@link engine.treeView.filler fillers}. Especially, it checks if the inline filler is needed
+	 * Rendering also handles {@link engine.view.filler fillers}. Especially, it checks if the inline filler is needed
 	 * at selection position and adds or removes it. To prevent breaking text composition inline filler will not be
 	 * removed as long selection is in the text node which needed it at first.
 	 */
@@ -260,7 +260,7 @@ export default class Renderer {
 	}
 
 	/**
-	 * Checks if the inline {@link engine.treeView.filler fillers} should be added.
+	 * Checks if the inline {@link engine.view.filler fillers} should be added.
 	 *
 	 * @private
 	 * @returns {Boolean} True if the inline fillers should be added.
@@ -297,7 +297,7 @@ export default class Renderer {
 	 * Checks if text needs to be updated and possibly updates it.
 	 *
 	 * @private
-	 * @param {engine.treeView.Text} viewText View text to update.
+	 * @param {engine.view.Text} viewText View text to update.
 	 */
 	_updateText( viewText ) {
 		const domText = this.domConverter.getCorrespondingDom( viewText );
@@ -320,7 +320,7 @@ export default class Renderer {
 	 * Checks if attributes list needs to be updated and possibly updates it.
 	 *
 	 * @private
-	 * @param {engine.treeView.Element} viewElement View element to update.
+	 * @param {engine.view.Element} viewElement View element to update.
 	 */
 	_updateAttrs( viewElement ) {
 		const domElement = this.domConverter.getCorrespondingDom( viewElement );
@@ -344,7 +344,7 @@ export default class Renderer {
 	 * Checks if elements child list needs to be updated and possibly updates it.
 	 *
 	 * @private
-	 * @param {engine.treeView.Element} viewElement View element to update.
+	 * @param {engine.view.Element} viewElement View element to update.
 	 */
 	_updateChildren( viewElement ) {
 		const domConverter = this.domConverter;

+ 49 - 49
packages/ckeditor5-engine/src/treeview/selection.js

@@ -14,18 +14,18 @@ import EmitterMixin from '../../utils/emittermixin.js';
 /**
  * Class representing selection in tree view.
  *
- * Selection can consist of {@link engine.treeView.Range ranges} that can be added using
- * {@link engine.treeView.Selection#addRange addRange} and {@link engine.treeView.Selection#setRanges setRanges} methods.
+ * Selection can consist of {@link engine.view.Range ranges} that can be added using
+ * {@link engine.view.Selection#addRange addRange} and {@link engine.view.Selection#setRanges setRanges} methods.
  * Both methods create copies of provided ranges and store those copies internally. Further modifications to passed
  * ranges will not change selection's state.
- * Selection's ranges can be obtained via {@link engine.treeView.Selection#getRanges getRanges},
- * {@link engine.treeView.Selection#getFirstRange getFirstRange} and {@link engine.treeView.Selection#getLastRange getLastRange}
+ * Selection's ranges can be obtained via {@link engine.view.Selection#getRanges getRanges},
+ * {@link engine.view.Selection#getFirstRange getFirstRange} and {@link engine.view.Selection#getLastRange getLastRange}
  * methods, which return copies of ranges stored inside selection. Modifications made on these copies will not change
- * selection's state. Similar situation occurs when getting {@link engine.treeView.Selection#anchor anchor},
- * {@link engine.treeView.Selection#focus focus}, {@link engine.treeView.Selection#getFirstPosition first} and
- * {@link engine.treeView.Selection#getLastPosition last} positions - all will return copies of requested positions.
+ * selection's state. Similar situation occurs when getting {@link engine.view.Selection#anchor anchor},
+ * {@link engine.view.Selection#focus focus}, {@link engine.view.Selection#getFirstPosition first} and
+ * {@link engine.view.Selection#getLastPosition last} positions - all will return copies of requested positions.
  *
- * @memberOf engine.treeView
+ * @memberOf engine.view
  */
 export default class Selection {
 	/**
@@ -36,7 +36,7 @@ export default class Selection {
 		 * Stores all ranges that are selected.
 		 *
 		 * @protected
-		 * @member {Array.<engine.treeView.Range>} engine.treeView.Selection#_ranges
+		 * @member {Array.<engine.view.Range>} engine.view.Selection#_ranges
 		 */
 		this._ranges = [];
 
@@ -44,19 +44,19 @@ export default class Selection {
 		 * Specifies whether the last added range was added as a backward or forward range.
 		 *
 		 * @protected
-		 * @member {Boolean} engine.treeView.Selection#_lastRangeBackward
+		 * @member {Boolean} engine.view.Selection#_lastRangeBackward
 		 */
 		this._lastRangeBackward = false;
 	}
 
 	/**
 	 * Selection anchor. Anchor may be described as a position where the selection starts. Together with
-	 * {@link engine.treeView.Selection#focus focus} they define the direction of selection, which is important
+	 * {@link engine.view.Selection#focus focus} they define the direction of selection, which is important
 	 * when expanding/shrinking selection. Anchor is always the start or end of the most recent added range.
 	 * It may be a bit unintuitive when there are multiple ranges in selection.
 	 *
-	 * @see engine.treeView.Selection#focus
-	 * @type {engine.treeView.Position}
+	 * @see engine.view.Selection#focus
+	 * @type {engine.view.Position}
 	 */
 	get anchor() {
 		if ( !this._ranges.length ) {
@@ -71,8 +71,8 @@ export default class Selection {
 	/**
 	 * Selection focus. Focus is a position where the selection ends.
 	 *
-	 * @see engine.treeView.Selection#anchor
-	 * @type {engine.treeView.Position}
+	 * @see engine.view.Selection#anchor
+	 * @type {engine.view.Position}
 	 */
 	get focus() {
 		if ( !this._ranges.length ) {
@@ -104,7 +104,7 @@ export default class Selection {
 	}
 
 	/**
-	 * Specifies whether the {@link engine.treeView.Selection#focus} precedes {@link engine.treeView.Selection#anchor}.
+	 * Specifies whether the {@link engine.view.Selection#focus} precedes {@link engine.view.Selection#anchor}.
 	 *
 	 * @type {Boolean}
 	 */
@@ -117,16 +117,16 @@ export default class Selection {
 	 * selection instance and you can safely operate on it.
 	 *
 	 * Accepts a flag describing in which way the selection is made - passed range might be selected from
-	 * {@link engine.treeView.Range#start start} to {@link engine.treeView.Range#end end}
-	 * or from {@link engine.treeView.Range#end end} to {@link engine.treeView.Range#start start}.
-	 * The flag is used to set {@link engine.treeView.Selection#anchor anchor} and
-	 * {@link engine.treeView.Selection#focus focus} properties.
+	 * {@link engine.view.Range#start start} to {@link engine.view.Range#end end}
+	 * or from {@link engine.view.Range#end end} to {@link engine.view.Range#start start}.
+	 * The flag is used to set {@link engine.view.Selection#anchor anchor} and
+	 * {@link engine.view.Selection#focus focus} properties.
 	 *
 	 * Throws {@link utils.CKEditorError CKEditorError} `view-selection-range-intersects` if added range intersects
 	 * with ranges already stored in Selection instance.
 	 *
-	 * @fires engine.treeView.Selection#change
-	 * @param {engine.treeView.Range} range
+	 * @fires engine.view.Selection#change
+	 * @param {engine.view.Range} range
 	 */
 	addRange( range, isBackward ) {
 		this._pushRange( range );
@@ -137,7 +137,7 @@ export default class Selection {
 	/**
 	 * Returns an iterator that contains copies of all ranges added to the selection.
 	 *
-	 * @returns {Iterator.<engine.treeView.Range>}
+	 * @returns {Iterator.<engine.view.Range>}
 	 */
 	*getRanges() {
 		for ( let range of this._ranges ) {
@@ -147,11 +147,11 @@ export default class Selection {
 
 	/**
 	 * Returns copy of the first range in the selection. First range is the one which
-	 * {@link engine.treeView.Range#start start} position {@link engine.treeView.Position#isBefore is before} start
+	 * {@link engine.view.Range#start start} position {@link engine.view.Position#isBefore is before} start
 	 * position of all other ranges (not to confuse with the first range added to the selection).
 	 * Returns `null` if no ranges are added to selection.
 	 *
-	 * @returns {engine.treeView.Range|null}
+	 * @returns {engine.view.Range|null}
 	 */
 	getFirstRange() {
 		let first = null;
@@ -166,11 +166,11 @@ export default class Selection {
 	}
 
 	/**
-	 * Returns copy of the last range in the selection. Last range is the one which {@link engine.treeView.Range#end end}
-	 * position {@link engine.treeView.Position#isAfter is after} end position of all other ranges (not to confuse
+	 * Returns copy of the last range in the selection. Last range is the one which {@link engine.view.Range#end end}
+	 * position {@link engine.view.Position#isAfter is after} end position of all other ranges (not to confuse
 	 * with the last range added to the selection). Returns `null` if no ranges are added to selection.
 	 *
-	 * @returns {engine.treeView.Range|null}
+	 * @returns {engine.view.Range|null}
 	 */
 	getLastRange() {
 		let last = null;
@@ -186,10 +186,10 @@ export default class Selection {
 
 	/**
 	 * Returns copy of the first position in the selection. First position is the position that
-	 * {@link engine.treeView.Position#isBefore is before} any other position in the selection ranges.
+	 * {@link engine.view.Position#isBefore is before} any other position in the selection ranges.
 	 * Returns `null` if no ranges are added to selection.
 	 *
-	 * @returns {engine.treeView.Position|null}
+	 * @returns {engine.view.Position|null}
 	 */
 	getFirstPosition() {
 		const firstRange = this.getFirstRange();
@@ -199,10 +199,10 @@ export default class Selection {
 
 	/**
 	 * Returns copy of the last position in the selection. Last position is the position that
-	 * {@link engine.treeView.Position#isAfter is after} any other position in the selection ranges.
+	 * {@link engine.view.Position#isAfter is after} any other position in the selection ranges.
 	 * Returns `null` if no ranges are added to selection.
 	 *
-	 * @returns {engine.treeView.Position|null}
+	 * @returns {engine.view.Position|null}
 	 */
 	getLastPosition() {
 		const lastRange = this.getLastRange();
@@ -213,7 +213,7 @@ export default class Selection {
 	/**
 	 * Two selections equal if they have the same ranges and directions.
 	 *
-	 * @param {engine.treeView.Selection} otherSelection Selection to compare with.
+	 * @param {engine.view.Selection} otherSelection Selection to compare with.
 	 * @returns {Boolean} True if selections equal.
 	 */
 	isEqual( otherSelection ) {
@@ -235,7 +235,7 @@ export default class Selection {
 	/**
 	 * Removes all ranges that were added to the selection.
 	 *
-	 * @fires engine.treeView.Selection#change
+	 * @fires engine.view.Selection#change
 	 */
 	removeAllRanges() {
 		if ( this._ranges.length ) {
@@ -246,12 +246,12 @@ export default class Selection {
 
 	/**
 	 * Replaces all ranges that were added to the selection with given array of ranges. Last range of the array
-	 * is treated like the last added range and is used to set {@link engine.treeView.Selection#anchor anchor} and
-	 * {@link engine.treeView.Selection#focus focus}. Accepts a flag describing in which way the selection is made
-	 * (see {@link engine.treeView.Selection#addRange addRange}).
+	 * is treated like the last added range and is used to set {@link engine.view.Selection#anchor anchor} and
+	 * {@link engine.view.Selection#focus focus}. Accepts a flag describing in which way the selection is made
+	 * (see {@link engine.view.Selection#addRange addRange}).
 	 *
-	 * @fires engine.treeView.Selection#change
-	 * @param {Array.<engine.treeView.Range>} newRanges Array of ranges to set.
+	 * @fires engine.view.Selection#change
+	 * @param {Array.<engine.view.Range>} newRanges Array of ranges to set.
 	 * @param {Boolean} [isLastBackward] Flag describing if last added range was selected forward - from start to end
 	 * (`false`) or backward - from end to start (`true`). Defaults to `false`.
 	 */
@@ -269,7 +269,7 @@ export default class Selection {
 	/**
 	 * Set this selection's ranges and direction to the ranges and direction of the given selection.
 	 *
-	 * @param {engine.treeView.Selection} otherSelection Other selection.
+	 * @param {engine.view.Selection} otherSelection Other selection.
 	 */
 	setTo( otherSelection ) {
 		this.removeAllRanges();
@@ -282,11 +282,11 @@ export default class Selection {
 	}
 
 	/**
-	 * Collapses selection to the {@link engine.treeView.Selection#getFirstPosition first position} in stored ranges.
+	 * Collapses selection to the {@link engine.view.Selection#getFirstPosition first position} in stored ranges.
 	 * All ranges will be removed beside one collapsed range. Nothing will be changed if there are no ranges stored
 	 * inside selection.
 	 *
-	 * @fires engine.treeView.Selection#change
+	 * @fires engine.view.Selection#change
 	 */
 	collapseToStart() {
 		const startPosition = this.getFirstPosition();
@@ -298,11 +298,11 @@ export default class Selection {
 	}
 
 	/**
-	 * Collapses selection to the {@link engine.treeView.Selection#getLastPosition last position} in stored ranges.
+	 * Collapses selection to the {@link engine.view.Selection#getLastPosition last position} in stored ranges.
 	 * All ranges will be removed beside one collapsed range. Nothing will be changed if there are no ranges stored
 	 * inside selection.
 	 *
-	 * @fires engine.treeView.Selection#change
+	 * @fires engine.view.Selection#change
 	 */
 	collapseToEnd() {
 		const endPosition = this.getLastPosition();
@@ -320,7 +320,7 @@ export default class Selection {
 	 * with ranges already stored in selection instance.
 	 *
 	 * @private
-	 * @param {engine.treeView.Range} range
+	 * @param {engine.view.Range} range
 	 */
 	_pushRange( range ) {
 		for ( let storedRange of this._ranges ) {
@@ -329,8 +329,8 @@ export default class Selection {
 				 * Trying to add a range that intersects with another range from selection.
 				 *
 				 * @error view-selection-range-intersects
-				 * @param {engine.treeView.Range} addedRange Range that was added to the selection.
-				 * @param {engine.treeView.Range} intersectingRange Range from selection that intersects with `addedRange`.
+				 * @param {engine.view.Range} addedRange Range that was added to the selection.
+				 * @param {engine.view.Range} intersectingRange Range from selection that intersects with `addedRange`.
 				 */
 				throw new CKEditorError(
 					'view-selection-range-intersects: Trying to add a range that intersects with another range from selection.',
@@ -346,7 +346,7 @@ export default class Selection {
 mix( Selection, EmitterMixin );
 
 /**
- * Fired whenever selection ranges are changed through {@link engine.treeView.Selection Selection API}.
+ * Fired whenever selection ranges are changed through {@link engine.view.Selection Selection API}.
  *
- * @event engine.treeView.Selection#change
+ * @event engine.view.Selection#change
  */

+ 7 - 7
packages/ckeditor5-engine/src/treeview/text.js

@@ -10,8 +10,8 @@ import Node from './node.js';
 /**
  * Tree view text node.
  *
- * @memberOf engine.treeView
- * @extends engine.treeView.Node
+ * @memberOf engine.view
+ * @extends engine.view.Node
  */
 export default class Text extends Node {
 	/**
@@ -25,10 +25,10 @@ export default class Text extends Node {
 		/**
 		 * The text content.
 		 *
-		 * Setting the data fires the {@link engine.treeView.Node#event:change change event}.
+		 * Setting the data fires the {@link engine.view.Node#event:change change event}.
 		 *
 		 * @private
-		 * @member {String} engine.treeView.Text#_data
+		 * @member {String} engine.view.Text#_data
 		 */
 		this._data = data;
 	}
@@ -36,7 +36,7 @@ export default class Text extends Node {
 	/**
 	 * Clones this node.
 	 *
-	 * @returns {engine.treeView.Text} Text node that is a clone of this node.
+	 * @returns {engine.view.Text} Text node that is a clone of this node.
 	 */
 	clone() {
 		return new Text( this.data );
@@ -45,7 +45,7 @@ export default class Text extends Node {
 	/**
 	 * The text content.
 	 *
-	 * Setting the data fires the {@link treeView.Node#change change event}.
+	 * Setting the data fires the {@link view.Node#change change event}.
 	 */
 	get data() {
 		return this._data;
@@ -61,7 +61,7 @@ export default class Text extends Node {
 	 * Checks if this text node is similar to other text node.
 	 * Both nodes should have the same data to be considered as similar.
 	 *
-	 * @param {engine.treeView.Text} otherNode Node to check if it is same as this node.
+	 * @param {engine.view.Text} otherNode Node to check if it is same as this node.
 	 * @returns {Boolean}
 	 */
 	isSimilar( otherNode ) {

+ 1 - 1
packages/ckeditor5-engine/src/treemodel/treemodel.jsdoc

@@ -4,5 +4,5 @@
  */
 
 /**
- * @namespace engine.treeModel
+ * @namespace engine.view
  */

+ 107 - 107
packages/ckeditor5-engine/src/treeview/writer.js

@@ -16,17 +16,17 @@ import isIterable from '../../utils/isiterable.js';
 
 /**
  * Tree View Writer class.
- * Writer defines a high-level API for TreeView manipulations.
+ * Writer defines a high-level API for view manipulations.
  *
- * @memberOf engine.treeView
+ * @memberOf engine.view
  */
  export default class Writer {
 	/**
-	 * Returns first parent container of specified {@link engine.treeView.Position Position}.
+	 * Returns first parent container of specified {@link engine.view.Position Position}.
 	 * Position's parent node is checked as first, then next parents are checked.
 	 *
-	 * @param {engine.treeView.Position} position Position used as a start point to locate parent container.
-	 * @returns {engine.treeView.Element|undefined} Parent container element or `undefined` if container is not found.
+	 * @param {engine.view.Position} position Position used as a start point to locate parent container.
+	 * @returns {engine.view.Element|undefined} Parent container element or `undefined` if container is not found.
 	 */
 	getParentContainer( position ) {
 		let parent = position.parent;
@@ -50,10 +50,10 @@ import isIterable from '../../utils/isiterable.js';
 	 *		<p>foo<b><u>{}bar</u></b></p> -> <p>foo{}<b><u>bar</u></b></p>
 	 *		<p>foo<b><u>b{}ar</u></b></p> -> <p>foo<b><u>b</u></b>[]<b><u>ar</u></b></p>
 	 *
-	 * @see engine.treeView.AttributeElement
-	 * @see engine.treeView.ContainerElement
-	 * @param {engine.treeView.Position} position Position where to break attributes.
-	 * @returns {engine.treeView.Position} New position after breaking the attributes.
+	 * @see engine.view.AttributeElement
+	 * @see engine.view.ContainerElement
+	 * @param {engine.view.Position} position Position where to break attributes.
+	 * @returns {engine.view.Position} New position after breaking the attributes.
 	 */
 	breakAttributes( position ) {
 		return this._breakAttributes( position, false );
@@ -64,11 +64,11 @@ import isIterable from '../../utils/isiterable.js';
 	 * splitting text nodes).
 	 *
 	 * @private
-	 * @param {engine.treeView.Position} position Position where to break attributes.
+	 * @param {engine.view.Position} position Position where to break attributes.
 	 * @param {Boolean} [forceSplitText = false] If set to `true`, will break text nodes even if they are directly in
 	 * container element. This behavior will result in incorrect view state, but is needed by other `Writer` methods
 	 * which then fixes view state. Defaults to `false`.
-	 * @returns {engine.treeView.Position} New position after breaking the attributes.
+	 * @returns {engine.view.Position} New position after breaking the attributes.
 	 */
 	_breakAttributes( position, forceSplitText = false ) {
 		const positionOffset = position.offset;
@@ -135,17 +135,17 @@ import isIterable from '../../utils/isiterable.js';
 	}
 
 	/**
-	 * Uses {@link engine.treeView.Writer#breakAttributes breakAttributes} method to break attributes on
-	 * {@link engine.treeView.Range#start start} and {@link engine.treeView.Range#end end} positions of
-	 * provided {@link engine.treeView.Range Range}.
+	 * Uses {@link engine.view.Writer#breakAttributes breakAttributes} method to break attributes on
+	 * {@link engine.view.Range#start start} and {@link engine.view.Range#end end} positions of
+	 * provided {@link engine.view.Range Range}.
 	 *
-	 * Throws {@link utils.CKEditorError CKEditorError} `treeview-writer-invalid-range-container` when
-	 * {@link engine.treeView.Range#start start} and {@link engine.treeView.Range#end end} positions are not placed inside
+	 * Throws {@link utils.CKEditorError CKEditorError} `view-writer-invalid-range-container` when
+	 * {@link engine.view.Range#start start} and {@link engine.view.Range#end end} positions are not placed inside
 	 * same parent container.
 	 *
-	 * @see engine.treeView.Writer#breakAttribute
-	 * @param {engine.treeView.Range} range Range which `start` and `end` positions will be used to break attributes.
-	 * @returns {engine.treeView.Range} New range with located at break positions.
+	 * @see engine.view.Writer#breakAttribute
+	 * @param {engine.view.Range} range Range which `start` and `end` positions will be used to break attributes.
+	 * @returns {engine.view.Range} New range with located at break positions.
 	 */
 	breakRange( range ) {
 		return this._breakRange( range );
@@ -156,12 +156,12 @@ import isIterable from '../../utils/isiterable.js';
 	 * splitting text nodes).
 	 *
 	 * @private
-	 * @see engine.treeView.Writer#_breakAttribute
-	 * @param {engine.treeView.Range} range Range which `start` and `end` positions will be used to break attributes.
+	 * @see engine.view.Writer#_breakAttribute
+	 * @param {engine.view.Range} range Range which `start` and `end` positions will be used to break attributes.
 	 * @param {Boolean} [forceSplitText = false] If set to `true`, will break text nodes even if they are directly in
 	 * container element. This behavior will result in incorrect view state, but is needed by other `Writer` methods
 	 * which then fixes view state. Defaults to `false`.
-	 * @returns {engine.treeView.Range} New range with located at break positions.
+	 * @returns {engine.view.Range} New range with located at break positions.
 	 */
 	_breakRange( range, forceSplitText = false ) {
 		const rangeStart = range.start;
@@ -172,9 +172,9 @@ import isIterable from '../../utils/isiterable.js';
 			/**
 			 * Range is not placed inside same container.
 			 *
-			 * @error treeview-writer-invalid-range-container
+			 * @error view-writer-invalid-range-container
 			 */
-			throw new CKEditorError( 'treeview-writer-invalid-range-container' );
+			throw new CKEditorError( 'view-writer-invalid-range-container' );
 		}
 
 		// Break at the collapsed position. Return new collapsed range.
@@ -196,7 +196,7 @@ import isIterable from '../../utils/isiterable.js';
 
 	/**
 	 * Merges attribute nodes. It also merges text nodes if needed.
-	 * Only {@link engine.treeView.AttributeElement#isSimilar similar} `attribute` nodes can be merged.
+	 * Only {@link engine.view.AttributeElement#isSimilar similar} `attribute` nodes can be merged.
 	 *
 	 * In following examples `<p>` is a container and `<b>` is an attribute node:
 	 *
@@ -209,10 +209,10 @@ import isIterable from '../../utils/isiterable.js';
 	 *		<p><b>[]</b></p> -> <p>[]</p>
 	 *		<p><b>foo</b><i>[]</i><b>bar</b></p> -> <p><b>foo{}bar</b></p>
 	 *
-	 * @see engine.treeView.AttributeElement
-	 * @see engine.treeView.ContainerElement
-	 * @param {engine.treeView.Position} position Merge position.
-	 * @returns {engine.treeView.Position} Position after merge.
+	 * @see engine.view.AttributeElement
+	 * @see engine.view.ContainerElement
+	 * @param {engine.view.Position} position Merge position.
+	 * @returns {engine.view.Position} Position after merge.
 	 */
 	mergeAttributes( position ) {
 		const positionOffset = position.offset;
@@ -269,16 +269,16 @@ import isIterable from '../../utils/isiterable.js';
 	 * Insert node or nodes at specified position. Takes care about breaking attributes before insertion
 	 * and merging them afterwards.
 	 *
-	 * Throws {@link utils.CKEditorError CKEditorError} `treeview-writer-insert-invalid-node` when nodes to insert
-	 * contains instances that are not {@link engine.treeView.Text Texts},
-	 * {@link engine.treeView.AttributeElement AttributeElements} or
-	 * {@link engine.treeView.ContainerElement ContainerElements}.
+	 * Throws {@link utils.CKEditorError CKEditorError} `view-writer-insert-invalid-node` when nodes to insert
+	 * contains instances that are not {@link engine.view.Text Texts},
+	 * {@link engine.view.AttributeElement AttributeElements} or
+	 * {@link engine.view.ContainerElement ContainerElements}.
 	 *
-	 * @param {engine.treeView.Position} position Insertion position.
-	 * @param {engine.treeView.Text|engine.treeView.AttributeElement|engine.treeView.ContainerElement
-	 * |Iterable.<engine.treeView.Text|engine.treeView.AttributeElement|engine.treeView.ContainerElement>} nodes Node or
+	 * @param {engine.view.Position} position Insertion position.
+	 * @param {engine.view.Text|engine.view.AttributeElement|engine.view.ContainerElement
+	 * |Iterable.<engine.view.Text|engine.view.AttributeElement|engine.view.ContainerElement>} nodes Node or
 	 * nodes to insert.
-	 * @returns {engine.treeView.Range} Range around inserted nodes.
+	 * @returns {engine.view.Range} Range around inserted nodes.
 	 */
 	insert( position, nodes ) {
 		nodes = isIterable( nodes ) ? [ ...nodes ] : [ nodes ];
@@ -311,13 +311,13 @@ import isIterable from '../../utils/isiterable.js';
 	/**
 	 * Removes provided range from the container.
 	 *
-	 * Throws {@link utils.CKEditorError CKEditorError} `treeview-writer-invalid-range-container` when
-	 * {@link engine.treeView.Range#start start} and {@link engine.treeView.Range#end end} positions are not placed inside
+	 * Throws {@link utils.CKEditorError CKEditorError} `view-writer-invalid-range-container` when
+	 * {@link engine.view.Range#start start} and {@link engine.view.Range#end end} positions are not placed inside
 	 * same parent container.
 	 *
-	 * @param {engine.treeView.Range} range Range to remove from container. After removing, it will be updated
+	 * @param {engine.view.Range} range Range to remove from container. After removing, it will be updated
 	 * to a collapsed range showing the new position.
-	 * @returns {engine.treeView.DocumentFragment} Document fragment containing removed nodes.
+	 * @returns {engine.view.DocumentFragment} Document fragment containing removed nodes.
 	 */
 	remove( range ) {
 		// Range should be placed inside one container.
@@ -325,9 +325,9 @@ import isIterable from '../../utils/isiterable.js';
 			/**
 			 * Range is not placed inside same container.
 			 *
-			 * @error treeview-writer-invalid-range-container
+			 * @error view-writer-invalid-range-container
 			 */
-			throw new CKEditorError( 'treeview-writer-invalid-range-container' );
+			throw new CKEditorError( 'view-writer-invalid-range-container' );
 		}
 
 		// If range is collapsed - nothing to remove.
@@ -356,14 +356,14 @@ import isIterable from '../../utils/isiterable.js';
 	/**
 	 * Moves nodes from provided range to target position.
 	 *
-	 * Throws {@link utils.CKEditorError CKEditorError} `treeview-writer-invalid-range-container` when
-	 * {@link engine.treeView.Range#start start} and {@link engine.treeView.Range#end end} positions are not placed inside
+	 * Throws {@link utils.CKEditorError CKEditorError} `view-writer-invalid-range-container` when
+	 * {@link engine.view.Range#start start} and {@link engine.view.Range#end end} positions are not placed inside
 	 * same parent container.
 	 *
-	 * @param {engine.treeView.Range} sourceRange Range containing nodes to move.
-	 * @param {engine.treeView.Position} targetPosition Position to insert.
-	 * @returns {engine.treeView.Range} Range in target container. Inserted nodes are placed between
-	 * {@link engine.treeView.Range#start start} and {@link engine.treeView.Range#end end} positions.
+	 * @param {engine.view.Range} sourceRange Range containing nodes to move.
+	 * @param {engine.view.Position} targetPosition Position to insert.
+	 * @returns {engine.view.Range} Range in target container. Inserted nodes are placed between
+	 * {@link engine.view.Range#start start} and {@link engine.view.Range#end end} positions.
 	 */
 	move( sourceRange, targetPosition ) {
 		const nodes = this.remove( sourceRange );
@@ -372,24 +372,24 @@ import isIterable from '../../utils/isiterable.js';
 	}
 
 	/**
-	 * Wraps elements within range with provided {@link engine.treeView.AttributeElement AttributeElement}.
+	 * Wraps elements within range with provided {@link engine.view.AttributeElement AttributeElement}.
 	 *
-	 * Throws {@link utils.CKEditorError} `treeview-writer-invalid-range-container` when {@link engine.treeView.Range#start}
-	 * and {@link engine.treeView.Range#end} positions are not placed inside same parent container.
-	 * Throws {@link utils.CKEditorError} `treeview-writer-wrap-invalid-attribute` when passed attribute element is not
-	 * an instance of {engine.treeView.AttributeElement AttributeElement}.
+	 * Throws {@link utils.CKEditorError} `view-writer-invalid-range-container` when {@link engine.view.Range#start}
+	 * and {@link engine.view.Range#end} positions are not placed inside same parent container.
+	 * Throws {@link utils.CKEditorError} `view-writer-wrap-invalid-attribute` when passed attribute element is not
+	 * an instance of {engine.view.AttributeElement AttributeElement}.
 	 *
-	 * @param {engine.treeView.Range} range Range to wrap.
-	 * @param {engine.treeView.AttributeElement} attribute Attribute element to use as wrapper.
+	 * @param {engine.view.Range} range Range to wrap.
+	 * @param {engine.view.AttributeElement} attribute Attribute element to use as wrapper.
 	 */
 	wrap( range, attribute ) {
 		if ( !( attribute instanceof AttributeElement ) ) {
 			/**
 			 * Attribute element need to be instance of attribute element.
 			 *
-			 * @error treeview-writer-wrap-invalid-attribute
+			 * @error view-writer-wrap-invalid-attribute
 			 */
-			throw new CKEditorError( 'treeview-writer-wrap-invalid-attribute' );
+			throw new CKEditorError( 'view-writer-wrap-invalid-attribute' );
 		}
 
 		// Range should be placed inside one container.
@@ -397,9 +397,9 @@ import isIterable from '../../utils/isiterable.js';
 			/**
 			 * Range is not placed inside same container.
 			 *
-			 * @error treeview-writer-invalid-range-container
+			 * @error view-writer-invalid-range-container
 			 */
-			throw new CKEditorError( 'treeview-writer-invalid-range-container' );
+			throw new CKEditorError( 'view-writer-invalid-range-container' );
 		}
 
 		// If range is collapsed - nothing to wrap.
@@ -450,11 +450,11 @@ import isIterable from '../../utils/isiterable.js';
 	 * Wraps position with provided attribute. Returns new position after wrapping. This method will also merge newly
 	 * added attribute with its siblings whenever possible.
 	 *
-	 * Throws {@link utils.CKEditorError} `treeview-writer-wrap-invalid-attribute` when passed attribute element is not
-	 * an instance of {engine.treeView.AttributeElement AttributeElement}.
+	 * Throws {@link utils.CKEditorError} `view-writer-wrap-invalid-attribute` when passed attribute element is not
+	 * an instance of {engine.view.AttributeElement AttributeElement}.
 	 *
-	 * @param {engine.treeView.Position} position
-	 * @param {engine.treeView.AttributeElement} attribute
+	 * @param {engine.view.Position} position
+	 * @param {engine.view.AttributeElement} attribute
 	 * @returns {Position} New position after wrapping.
 	 */
 	wrapPosition( position, attribute ) {
@@ -462,9 +462,9 @@ import isIterable from '../../utils/isiterable.js';
 			/**
 			 * Attribute element need to be instance of attribute element.
 			 *
-			 * @error treeview-writer-wrap-invalid-attribute
+			 * @error view-writer-wrap-invalid-attribute
 			 */
-			throw new CKEditorError( 'treeview-writer-wrap-invalid-attribute' );
+			throw new CKEditorError( 'view-writer-wrap-invalid-attribute' );
 		}
 
 		// Return same position when trying to wrap with attribute similar to position parent.
@@ -510,21 +510,21 @@ import isIterable from '../../utils/isiterable.js';
 	/**
 	 * Unwraps nodes within provided range from attribute element.
 	 *
-	 * Throws {@link utils.CKEditorError CKEditorError} `treeview-writer-invalid-range-container` when
-	 * {@link engine.treeView.Range#start start} and {@link engine.treeView.Range#end end} positions are not placed inside
+	 * Throws {@link utils.CKEditorError CKEditorError} `view-writer-invalid-range-container` when
+	 * {@link engine.view.Range#start start} and {@link engine.view.Range#end end} positions are not placed inside
 	 * same parent container.
 	 *
-	 * @param {engine.treeView.Range} range
-	 * @param {engine.treeView.AttributeElement} element
+	 * @param {engine.view.Range} range
+	 * @param {engine.view.AttributeElement} element
 	 */
 	unwrap( range, attribute ) {
 		if ( !( attribute instanceof AttributeElement ) ) {
 			/**
 			 * Attribute element need to be instance of attribute element.
 			 *
-			 * @error treeview-writer-unwrap-invalid-attribute
+			 * @error view-writer-unwrap-invalid-attribute
 			 */
-			throw new CKEditorError( 'treeview-writer-unwrap-invalid-attribute' );
+			throw new CKEditorError( 'view-writer-unwrap-invalid-attribute' );
 		}
 
 		// Range should be placed inside one container.
@@ -532,9 +532,9 @@ import isIterable from '../../utils/isiterable.js';
 			/**
 			 * Range is not placed inside same container.
 			 *
-			 * @error treeview-writer-invalid-range-container
+			 * @error view-writer-invalid-range-container
 			 */
-			throw new CKEditorError( 'treeview-writer-invalid-range-container' );
+			throw new CKEditorError( 'view-writer-invalid-range-container' );
 		}
 
 		// If range is collapsed - nothing to unwrap.
@@ -578,11 +578,11 @@ import isIterable from '../../utils/isiterable.js';
 // `startOffset` and `endOffset` will be unwrapped.
 //
 // @private
-// @param {engine.treeView.Writer} writer
-// @param {engine.treeView.Element} parent
+// @param {engine.view.Writer} writer
+// @param {engine.view.Element} parent
 // @param {Number} startOffset
 // @param {Number} endOffset
-// @param {engine.treeView.Element} attribute
+// @param {engine.view.Element} attribute
 function unwrapChildren( writer, parent, startOffset, endOffset, attribute ) {
 	let i = startOffset;
 	const unwrapPositions = [];
@@ -647,11 +647,11 @@ function unwrapChildren( writer, parent, startOffset, endOffset, attribute ) {
 // `startOffset` and `endOffset` will be wrapped.
 
 // @private
-// @param {engine.treeView.Writer} writer
-// @param {engine.treeView.Element} parent
+// @param {engine.view.Writer} writer
+// @param {engine.view.Element} parent
 // @param {Number} startOffset
 // @param {Number} endOffset
-// @param {engine.treeView.Element} attribute
+// @param {engine.view.Element} attribute
 function wrapChildren( writer, parent, startOffset, endOffset, attribute ) {
 	let i = startOffset;
 	const wrapPositions = [];
@@ -710,8 +710,8 @@ function wrapChildren( writer, parent, startOffset, endOffset, attribute ) {
 //		<p>[]foo</p>  ->  <p>{}foo</p>
 //
 // @private
-// @param {engine.treeView.Position} position
-// @returns {engine.treeView.Position} Position located inside text node or same position if there is no text nodes
+// @param {engine.view.Position} position
+// @returns {engine.view.Position} Position located inside text node or same position if there is no text nodes
 // before or after position location.
 function movePositionToTextNode( position ) {
 	const nodeBefore = position.nodeBefore;
@@ -736,8 +736,8 @@ function movePositionToTextNode( position ) {
 //		<p>foobar{}</p> -> <p>foobar[]</p>
 //
 // @private
-// @param {engine.treeView.Position} position Position that need to be placed inside text node.
-// @returns {engine.treeView.Position} New position after breaking text node.
+// @param {engine.view.Position} position Position that need to be placed inside text node.
+// @returns {engine.view.Position} New position after breaking text node.
 function breakTextNode( position ) {
 	if ( position.offset == position.parent.data.length ) {
 		return new Position( position.parent.parent, position.parent.getIndex() + 1 );
@@ -763,10 +763,10 @@ function breakTextNode( position ) {
 // Merges two text nodes into first node. Removes second node and returns merge position.
 //
 // @private
-// @param {engine.treeView.Text} t1 First text node to merge. Data from second text node will be moved at the end of
+// @param {engine.view.Text} t1 First text node to merge. Data from second text node will be moved at the end of
 // this text node.
-// @param {engine.treeView.Text} t2 Second text node to merge. This node will be removed after merging.
-// @returns {engine.treeView.Position} Position after merging text nodes.
+// @param {engine.view.Text} t2 Second text node to merge. This node will be removed after merging.
+// @returns {engine.view.Position} Position after merging text nodes.
 function mergeTextNodes( t1, t2 ) {
 	// Merge text data into first text node and remove second one.
 	const nodeBeforeLength = t1.data.length;
@@ -776,14 +776,14 @@ function mergeTextNodes( t1, t2 ) {
 	return new Position( t1, nodeBeforeLength );
 }
 
-// Wraps one {@link engine.treeView.AttributeElement AttributeElement} into another by merging them if possible.
+// Wraps one {@link engine.view.AttributeElement AttributeElement} into another by merging them if possible.
 // Two AttributeElements can be merged when there is no attribute or style conflicts between them.
 // When merging is possible - all attributes, styles and classes are moved from wrapper element to element being
 // wrapped.
 //
 // @private
-// @param {engine.treeView.AttributeElement} wrapper Wrapper AttributeElement.
-// @param {engine.treeView.AttributeElement} toWrap AttributeElement to wrap using wrapper element.
+// @param {engine.view.AttributeElement} wrapper Wrapper AttributeElement.
+// @param {engine.view.AttributeElement} toWrap AttributeElement to wrap using wrapper element.
 // @returns {Boolean} Returns `true` if elements are merged.
 function wrapAttributeElement( wrapper, toWrap ) {
 	// Can't merge if name or priority differs.
@@ -839,12 +839,12 @@ function wrapAttributeElement( wrapper, toWrap ) {
 	return true;
 }
 
-// Unwraps {@link engine.treeView.AttributeElement AttributeElement} from another by removing corresponding attributes,
+// Unwraps {@link engine.view.AttributeElement AttributeElement} from another by removing corresponding attributes,
 // classes and styles. All attributes, classes and styles from wrapper should be present inside element being unwrapped.
 //
 // @private
-// @param {engine.treeView.AttributeElement} wrapper Wrapper AttributeElement.
-// @param {engine.treeView.AttributeElement} toUnwrap AttributeElement to unwrap using wrapper element.
+// @param {engine.view.AttributeElement} wrapper Wrapper AttributeElement.
+// @param {engine.view.AttributeElement} toUnwrap AttributeElement to unwrap using wrapper element.
 // @returns {Boolean} Returns `true` if elements are unwrapped.
 function unwrapAttributeElement( wrapper, toUnwrap ) {
 	// Can't unwrap if name or priority differs.
@@ -897,12 +897,12 @@ function unwrapAttributeElement( wrapper, toUnwrap ) {
 	return true;
 }
 
-// Returns `true` if range is located in same {@link engine.treeView.AttributeElement AttributeElement}
-// (`start` and `end` positions are located inside same {@link engine.treeView.AttributeElement AttributeElement}),
+// Returns `true` if range is located in same {@link engine.view.AttributeElement AttributeElement}
+// (`start` and `end` positions are located inside same {@link engine.view.AttributeElement AttributeElement}),
 // starts on 0 offset and ends after last child node.
 //
 // @private
-// @param {engine.treeView.Range} Range
+// @param {engine.view.Range} Range
 // @returns {Boolean}
 function rangeSpansOnAllChildren( range ) {
 	return range.start.parent == range.end.parent && range.start.parent instanceof AttributeElement &&
@@ -910,26 +910,26 @@ function rangeSpansOnAllChildren( range ) {
 }
 
 // Checks if provided nodes are valid to insert by writer. Checks if each node is an instance of
-// {@link engine.treeView.Text Text} or {@link engine.treeView.AttributeElement AttributeElement} or
-// {@link engine.treeView.ContainerElement ContainerElement}.
+// {@link engine.view.Text Text} or {@link engine.view.AttributeElement AttributeElement} or
+// {@link engine.view.ContainerElement ContainerElement}.
 //
-// Throws {@link utils.CKEditorError CKEditorError} `treeview-writer-insert-invalid-node` when nodes to insert
-// contains instances that are not {@link engine.treeView.Text Texts},
-// {@link engine.treeView.AttributeElement AttributeElements} or
-// {@link engine.treeView.ContainerElement ContainerElements}.
+// Throws {@link utils.CKEditorError CKEditorError} `view-writer-insert-invalid-node` when nodes to insert
+// contains instances that are not {@link engine.view.Text Texts},
+// {@link engine.view.AttributeElement AttributeElements} or
+// {@link engine.view.ContainerElement ContainerElements}.
 //
 // @private
-// @param Iterable.<engine.treeView.Text|engine.treeView.AttributeElement|engine.treeView.ContainerElement> nodes
+// @param Iterable.<engine.view.Text|engine.view.AttributeElement|engine.view.ContainerElement> nodes
 function validateNodesToInsert( nodes ) {
 	for ( let node of nodes ) {
 		if ( !( node instanceof Text || node instanceof AttributeElement || node instanceof ContainerElement ) ) {
 			/**
-			 * Inserted nodes should be instance of {@link engine.treeView.AttributeElement AttributeElement},
-			 * {@link engine.treeView.ContainerElement ContainerElement} or {@link engine.treeView.Text Text}.
+			 * Inserted nodes should be instance of {@link engine.view.AttributeElement AttributeElement},
+			 * {@link engine.view.ContainerElement ContainerElement} or {@link engine.view.Text Text}.
 			 *
-			 * @error treeview-writer-insert-invalid-node
+			 * @error view-writer-insert-invalid-node
 			 */
-			throw new CKEditorError( 'treeview-writer-insert-invalid-node' );
+			throw new CKEditorError( 'view-writer-insert-invalid-node' );
 		}
 
 		if ( !( node instanceof Text ) ) {

+ 6 - 6
packages/ckeditor5-engine/tests/_utils-tests/model.js

@@ -6,12 +6,12 @@
 'use strict';
 
 import { stringify, parse, getData, setData } from '/tests/engine/_utils/model.js';
-import Document from '/ckeditor5/engine/treemodel/document.js';
-import DocumentFragment from '/ckeditor5/engine/treemodel/documentfragment.js';
-import Element from '/ckeditor5/engine/treemodel/element.js';
-import Text from '/ckeditor5/engine/treemodel/text.js';
-import Range from '/ckeditor5/engine/treemodel/range.js';
-import Position from '/ckeditor5/engine/treemodel/position.js';
+import Document from '/ckeditor5/engine/model/document.js';
+import DocumentFragment from '/ckeditor5/engine/model/documentfragment.js';
+import Element from '/ckeditor5/engine/model/element.js';
+import Text from '/ckeditor5/engine/model/text.js';
+import Range from '/ckeditor5/engine/model/range.js';
+import Position from '/ckeditor5/engine/model/position.js';
 
 describe( 'model test utils', () => {
 	let document, root, selection, sandbox;

+ 9 - 9
packages/ckeditor5-engine/tests/_utils-tests/view.js

@@ -8,15 +8,15 @@
 /* bender-tags: browser-only */
 
 import { parse, stringify, getData, setData }from '/tests/engine/_utils/view.js';
-import DocumentFragment from '/ckeditor5/engine/treeview/documentfragment.js';
-import Position from '/ckeditor5/engine/treeview/position.js';
-import Element from '/ckeditor5/engine/treeview/element.js';
-import AttributeElement from '/ckeditor5/engine/treeview/attributeelement.js';
-import ContainerElement from '/ckeditor5/engine/treeview/containerelement.js';
-import Text from '/ckeditor5/engine/treeview/text.js';
-import Selection from '/ckeditor5/engine/treeview/selection.js';
-import Range from '/ckeditor5/engine/treeview/range.js';
-import Document from '/ckeditor5/engine/treeview/document.js';
+import DocumentFragment from '/ckeditor5/engine/view/documentfragment.js';
+import Position from '/ckeditor5/engine/view/position.js';
+import Element from '/ckeditor5/engine/view/element.js';
+import AttributeElement from '/ckeditor5/engine/view/attributeelement.js';
+import ContainerElement from '/ckeditor5/engine/view/containerelement.js';
+import Text from '/ckeditor5/engine/view/text.js';
+import Selection from '/ckeditor5/engine/view/selection.js';
+import Range from '/ckeditor5/engine/view/range.js';
+import Document from '/ckeditor5/engine/view/document.js';
 
 describe( 'view test utils', () => {
 	describe( 'getData, setData', () => {

+ 21 - 21
packages/ckeditor5-engine/tests/_utils/model.js

@@ -5,20 +5,20 @@
 
 'use strict';
 
-import TreeWalker from '/ckeditor5/engine/treemodel/treewalker.js';
-import Range from '/ckeditor5/engine/treemodel/range.js';
-import Position from '/ckeditor5/engine/treemodel/position.js';
-import Text from '/ckeditor5/engine/treemodel/text.js';
-import RootElement from '/ckeditor5/engine/treemodel/rootelement.js';
-import Element from '/ckeditor5/engine/treemodel/element.js';
-import DocumentFragment from '/ckeditor5/engine/treemodel/documentfragment.js';
-import Selection from '/ckeditor5/engine/treemodel/selection.js';
-import Document from '/ckeditor5/engine/treemodel/document.js';
+import TreeWalker from '/ckeditor5/engine/model/treewalker.js';
+import Range from '/ckeditor5/engine/model/range.js';
+import Position from '/ckeditor5/engine/model/position.js';
+import Text from '/ckeditor5/engine/model/text.js';
+import RootElement from '/ckeditor5/engine/model/rootelement.js';
+import Element from '/ckeditor5/engine/model/element.js';
+import DocumentFragment from '/ckeditor5/engine/model/documentfragment.js';
+import Selection from '/ckeditor5/engine/model/selection.js';
+import Document from '/ckeditor5/engine/model/document.js';
 
 /**
- * Writes the contents of the {@link engine.treeModel.Document Document} to an HTML-like string.
+ * Writes the contents of the {@link engine.model.Document Document} to an HTML-like string.
  *
- * @param {engine.treeModel.Document} document
+ * @param {engine.model.Document} document
  * @param {Object} [options]
  * @param {Boolean} [options.withoutSelection=false] Whether to write the selection. When set to `true` selection will
  * be not included in returned string.
@@ -38,9 +38,9 @@ export function getData( document, options = {} ) {
 getData._stringify = stringify;
 
 /**
- * Sets the contents of the {@link engine.treeModel.Document Document} provided as HTML-like string.
+ * Sets the contents of the {@link engine.model.Document Document} provided as HTML-like string.
  *
- * @param {engine.treeModel.Document} document
+ * @param {engine.model.Document} document
  * @param {String} data HTML-like string to write into Document.
  * @param {Object} options
  * @param {String} [options.rootName] Root name where parsed data will be stored. If not provided, default `main` name will be
@@ -59,9 +59,9 @@ setData._parse = parse;
 /**
  * Converts model nodes to HTML-like string representation.
  *
- * @param {engine.treeModel.RootElement|engine.treeModel.Element|engine.treeModel.Text|
- * engine.treeModel.DocumentFragment} node Node to stringify.
- * @param {engine.treeModel.Selection|engine.treeModel.Position|engine.treeModel.Range} [selectionOrPositionOrRange = null ]
+ * @param {engine.model.RootElement|engine.model.Element|engine.model.Text|
+ * engine.model.DocumentFragment} node Node to stringify.
+ * @param {engine.model.Selection|engine.model.Position|engine.model.Range} [selectionOrPositionOrRange = null ]
  * Selection instance which ranges will be included in returned string data. If Range instance is provided - it will be
  * converted to selection containing this range. If Position instance is provided - it will be converted to selection
  * containing one range collapsed at this position.
@@ -116,15 +116,15 @@ export function stringify( node, selectionOrPositionOrRange = null ) {
 }
 
 /**
- * Parses HTML-like string and returns model {@link engine.treeModel.RootElement rootElement}.
+ * Parses HTML-like string and returns model {@link engine.model.RootElement rootElement}.
  *
  * @param {String} data HTML-like string to be parsed.
  * @param {Object} options
- * @param {engine.treeModel.Document} [options.document] Document from which root element and selection will be used. If
- * not provided new {engine.treeModel.Document document} instance will be created.
+ * @param {engine.model.Document} [options.document] Document from which root element and selection will be used. If
+ * not provided new {engine.model.Document document} instance will be created.
  * @param {String} [options.rootName='main'] When `document` option is provided this root name will be used to create
- * {engine.treeModel.RootElement RootElement} instance.
- * @returns {engine.treeModel.RootElement|Object} Returns parsed RootElement or object with two fields `model`
+ * {engine.model.RootElement RootElement} instance.
+ * @returns {engine.model.RootElement|Object} Returns parsed RootElement or object with two fields `model`
  * and `selection` when selection ranges were included in data to parse.
  */
 export function parse( data, options = {} ) {

+ 72 - 72
packages/ckeditor5-engine/tests/_utils/view.js

@@ -5,15 +5,15 @@
 
 'use strict';
 
-import ViewDocumentFragment from '/ckeditor5/engine/treeview/documentfragment.js';
+import ViewDocumentFragment from '/ckeditor5/engine/view/documentfragment.js';
 import HtmlDataProcessor from '/ckeditor5/engine/dataprocessor/htmldataprocessor.js';
-import ViewElement from '/ckeditor5/engine/treeview/element.js';
-import Selection from '/ckeditor5/engine/treeview/selection.js';
-import Range from '/ckeditor5/engine/treeview/range.js';
-import Position from '/ckeditor5/engine/treeview/position.js';
-import AttributeElement from '/ckeditor5/engine/treeview/attributeelement.js';
-import ContainerElement from '/ckeditor5/engine/treeview/containerelement.js';
-import ViewText from '/ckeditor5/engine/treeview/text.js';
+import ViewElement from '/ckeditor5/engine/view/element.js';
+import Selection from '/ckeditor5/engine/view/selection.js';
+import Range from '/ckeditor5/engine/view/range.js';
+import Position from '/ckeditor5/engine/view/position.js';
+import AttributeElement from '/ckeditor5/engine/view/attributeelement.js';
+import ContainerElement from '/ckeditor5/engine/view/containerelement.js';
+import ViewText from '/ckeditor5/engine/view/text.js';
 
 const ELEMENT_RANGE_START_TOKEN = '[';
 const ELEMENT_RANGE_END_TOKEN = ']';
@@ -21,9 +21,9 @@ const TEXT_RANGE_START_TOKEN = '{';
 const TEXT_RANGE_END_TOKEN = '}';
 
 /**
- * Writes the contents of the {@link engine.treeView.Document Document} to an HTML-like string.
+ * Writes the contents of the {@link engine.view.Document Document} to an HTML-like string.
  *
- * @param {engine.treeView.Document} document
+ * @param {engine.view.Document} document
  * @param {Object} [options]
  * @param {Boolean} [options.withoutSelection=false] Whether to write the selection. When set to `true` selection will
  * be not included in returned string.
@@ -54,9 +54,9 @@ export function getData( document, options = {} ) {
 getData._stringify = stringify;
 
 /**
- * Sets the contents of the {@link engine.treeView.Document Document} provided as HTML-like string.
+ * Sets the contents of the {@link engine.view.Document Document} provided as HTML-like string.
  *
- * @param {engine.treeView.Document} document
+ * @param {engine.view.Document} document
  * @param {String} data HTML-like string to write into Document.
  * @param {Object} options
  * @param {String} [rootName] Root name where parsed data will be stored. If not provided, default `main` name will be
@@ -77,17 +77,17 @@ setData._parse = parse;
 
 /**
  * Converts view elements to HTML-like string representation.
- * Root element can be provided as {@link engine.treeView.Text Text}:
+ * Root element can be provided as {@link engine.view.Text Text}:
  *
  *		const text = new Text( 'foobar' );
  *		stringify( text ); // 'foobar'
  *
- * or as {@link engine.treeView.Element Element}:
+ * or as {@link engine.view.Element Element}:
  *
  *		const element = new Element( 'p', null, new Text( 'foobar' ) );
  *		stringify( element ); // '<p>foobar</p>'
  *
- * or as {@link engine.treeView.DocumentFragment DocumentFragment}:
+ * or as {@link engine.view.DocumentFragment DocumentFragment}:
  *
  *		const text = new Text( 'foobar' );
  *		const b = new Element( 'b', { name: 'test' }, text );
@@ -96,7 +96,7 @@ setData._parse = parse;
  *
  *		stringify( fragment ); // '<p style="color:red;"></p><b name="test">foobar</b>'
  *
- * Additionally {@link engine.treeView.Selection Selection} instance can be provided, then ranges from that selection
+ * Additionally {@link engine.view.Selection Selection} instance can be provided, then ranges from that selection
  * will be included in output data.
  * If range position is placed inside element node, it will be represented with `[` and `]`:
  *
@@ -127,8 +127,8 @@ setData._parse = parse;
  *
  *		stringify( text, selection ); // '{f}oo{ba}r'
  *
- * Instead of {@link engine.treeView.Selection Selection} instance {@link engine.treeView.Range Range} or
- * {@link engine.treeView.Position Position} instance can be provided. If Range instance is provided - it will be
+ * Instead of {@link engine.view.Selection Selection} instance {@link engine.view.Range Range} or
+ * {@link engine.view.Position Position} instance can be provided. If Range instance is provided - it will be
  * converted to selection containing this range. If Position instance is provided - it will be converted to selection
  * containing one range collapsed at this position.
  *
@@ -141,7 +141,7 @@ setData._parse = parse;
  *
  * Additional options object can be provided.
  * If `options.showType` is set to `true`, element's types will be
- * presented for {@link engine.treeView.AttributeElement AttributeElements} and {@link engine.treeView.ContainerElement
+ * presented for {@link engine.view.AttributeElement AttributeElements} and {@link engine.view.ContainerElement
  * ContainerElements}:
  *
  *		const attribute = new AttributeElement( 'b' );
@@ -150,14 +150,14 @@ setData._parse = parse;
  *		getData( container, null, { showType: true } ); // '<container:p></container:p>'
  *
  * If `options.showPriority` is set to `true`, priority will be displayed for all
- * {@link engine.treeView.AttributeElement AttributeElements}.
+ * {@link engine.view.AttributeElement AttributeElements}.
  *
  *		const attribute = new AttributeElement( 'b' );
  *		attribute.priority = 20;
  *		getData( attribute, null, { showPriority: true } ); // <b:20></b:20>
  *
- * @param {engine.treeView.Text|engine.treeView.Element|engine.treeView.DocumentFragment} node Node to stringify.
- * @param {engine.treeView.Selection|engine.treeView.Position|engine.treeView.Range} [selectionOrPositionOrRange = null ]
+ * @param {engine.view.Text|engine.view.Element|engine.view.DocumentFragment} node Node to stringify.
+ * @param {engine.view.Selection|engine.view.Position|engine.view.Range} [selectionOrPositionOrRange = null ]
  * Selection instance which ranges will be included in returned string data. If Range instance is provided - it will be
  * converted to selection containing this range. If Position instance is provided - it will be converted to selection
  * containing one range collapsed at this position.
@@ -167,7 +167,7 @@ setData._parse = parse;
  * @param {Boolean} [options.showPriority=false] When set to `true` AttributeElement's priority will be printed
  * (`<span:12>`, `<b:10>`).
  * @param {Boolean} [options.ignoreRoot=false] When set to `true` root's element opening and closing will not be printed.
- * Mainly used by `getData` function to ignore {@link engine.treeView.Document Document's} root element.
+ * Mainly used by `getData` function to ignore {@link engine.view.Document Document's} root element.
  * @returns {String} HTML-like string representing the view.
  */
 export function stringify( node, selectionOrPositionOrRange = null, options = {} ) {
@@ -190,21 +190,21 @@ export function stringify( node, selectionOrPositionOrRange = null, options = {}
 
 /**
  * Parses HTML-like string and returns view tree nodes.
- * Simple string will be converted to {@link engine.treeView.Text Text} node:
+ * Simple string will be converted to {@link engine.view.Text Text} node:
  *
  *		parse( 'foobar' ); // Returns instance of Text.
  *
- * {@link engine.treeView.Element Elements} will be parsed with attributes an children:
+ * {@link engine.view.Element Elements} will be parsed with attributes an children:
  *
  *		parse( '<b name="baz">foobar</b>' ); // Returns instance of Element with `baz` attribute and text child node.
  *
- * Multiple nodes provided on root level will be converted to {@link engine.treeView.DocumentFragment DocumentFragment}:
+ * Multiple nodes provided on root level will be converted to {@link engine.view.DocumentFragment DocumentFragment}:
  *
  *		parse( '<b>foo</b><i>bar</i>' ); // Returns DocumentFragment with two child elements.
  *
- * Method can parse multiple {@link engine.treeView.Range ranges} provided in string data and return
- * {@link engine.treeView.Selection Selection} instance containing these ranges. Ranges placed inside
- * {@link engine.treeView.Text Text} nodes should be marked using `{` and `}` brackets:
+ * Method can parse multiple {@link engine.view.Range ranges} provided in string data and return
+ * {@link engine.view.Selection Selection} instance containing these ranges. Ranges placed inside
+ * {@link engine.view.Text Text} nodes should be marked using `{` and `}` brackets:
  *
  *		const { text, selection } = parse( 'f{ooba}r' );
  *
@@ -220,8 +220,8 @@ export function stringify( node, selectionOrPositionOrRange = null, options = {}
  * In above example first range (`{fo}`) will be added to selection as second one, second range (`{ar}`) will be added
  * as third and third range (`{ba}`) will be added as first one.
  *
- * If selection's last range should be added as backward one (so the {@link engine.treeView.Selection#anchor selection
- * anchor} is represented by `end` position and {@link engine.treeView.Selection#focus selection focus} is
+ * If selection's last range should be added as backward one (so the {@link engine.view.Selection#anchor selection
+ * anchor} is represented by `end` position and {@link engine.view.Selection#focus selection focus} is
  * represented by `start` position) use `lastRangeBackward` flag:
  *
  *		const { root, selection } = parse( `{foo}bar{baz}`, { lastRangeBackward: true } );
@@ -229,15 +229,15 @@ export function stringify( node, selectionOrPositionOrRange = null, options = {}
  * @param {String} data HTML-like string to be parsed.
  * @param {Object} options
  * @param {Array.<Number>} [options.order] Array with order of parsed ranges added to returned
- * {@link engine.treeView.Selection Selection} instance. Each element should represent desired position of each range in
+ * {@link engine.view.Selection Selection} instance. Each element should represent desired position of each range in
  * selection instance. For example: `[2, 3, 1]` means that first range will be placed as second, second as third and third as first.
  * @param {Boolean} [options.lastRangeBackward=false] If set to true last range will be added as backward to the returned
- * {@link engine.treeView.Selection Selection} instance.
- * @param {engine.treeView.Element|engine.treeView.DocumentFragment} [options.rootElement=null] Default root to use when parsing elements.
+ * {@link engine.view.Selection Selection} instance.
+ * @param {engine.view.Element|engine.view.DocumentFragment} [options.rootElement=null] Default root to use when parsing elements.
  * When set to `null` root element will be created automatically. If set to
- * {@link engine.treeView.Element Element} or {@link engine.treeView.DocumentFragment DocumentFragment} - this node
+ * {@link engine.view.Element Element} or {@link engine.view.DocumentFragment DocumentFragment} - this node
  * will be used as root for all parsed nodes.
- * @returns {engine.treeView.Text|engine.treeView.Element|engine.treeView.DocumentFragment|Object} Returns parsed view node
+ * @returns {engine.view.Text|engine.view.Element|engine.view.DocumentFragment|Object} Returns parsed view node
  * or object with two fields `view` and `selection` when selection ranges were included in data to parse.
  */
 export function parse( data, options = {} ) {
@@ -263,20 +263,20 @@ export function parse( data, options = {} ) {
 }
 
 /**
- * Private helper class used for converting ranges represented as text inside view {@link engine.treeView.Text Text nodes}.
+ * Private helper class used for converting ranges represented as text inside view {@link engine.view.Text Text nodes}.
  *
  * @private
  */
 class RangeParser {
 	/**
-	 * Parses the view, and returns ranges represented inside {@link engine.treeView.Text Text nodes}.
+	 * Parses the view, and returns ranges represented inside {@link engine.view.Text Text nodes}.
 	 * Method will remove all occurrences of `{`, `}`, `[` and `]` from found text nodes. If text node is empty after
 	 * the process - it will be removed too.
 	 *
-	 * @param {engine.treeView.Node} node Starting node.
+	 * @param {engine.view.Node} node Starting node.
 	 * @param {Array.<Number>} order Ranges order. Each element should represent desired position of the range after
 	 * sorting. For example: `[2, 3, 1]` means that first range will be placed as second, second as third and third as first.
-	 * @returns {Array.<engine.treeView.Range>} Array with ranges found.
+	 * @returns {Array.<engine.view.Range>} Array with ranges found.
 	 */
 	parse( node, order ) {
 		this._positions = [];
@@ -307,7 +307,7 @@ class RangeParser {
 	 * too.
 	 *
 	 * @private
-	 * @param {engine.treeView.Node} node Staring node.
+	 * @param {engine.view.Node} node Staring node.
 	 */
 	_getPositions( node ) {
 		if ( node instanceof ViewDocumentFragment || node instanceof ViewElement ) {
@@ -397,7 +397,7 @@ class RangeParser {
 	 * For example: `[2, 3, 1]` means that first range will be placed as second, second as third and third as first.
 	 *
 	 * @private
-	 * @param {Array.<engine.treeView.Range>} ranges Ranges to sort.
+	 * @param {Array.<engine.view.Range>} ranges Ranges to sort.
 	 * @param {Array.<Number>} rangesOrder Array with new ranges order.
 	 * @returns {Array} Sorted ranges array.
 	 */
@@ -421,7 +421,7 @@ class RangeParser {
 	 * Uses all found bracket positions to create ranges from them.
 	 *
 	 * @private
-	 * @returns {Array.<engine.treeView.Range}
+	 * @returns {Array.<engine.view.Range}
 	 */
 	_createRanges() {
 		const ranges = [];
@@ -467,11 +467,11 @@ class ViewParser {
 	 * Parses HTML-like string to view tree elements.
 	 *
 	 * @param {String} data
-	 * @param {engine.treeView.Element|engine.treeView.DocumentFragment} [rootElement=null] Default root to use when parsing elements.
+	 * @param {engine.view.Element|engine.view.DocumentFragment} [rootElement=null] Default root to use when parsing elements.
 	 * When set to `null` root element will be created automatically. If set to
-	 * {@link engine.treeView.Element Element} or {@link engine.treeView.DocumentFragment DocumentFragment} - this node
+	 * {@link engine.view.Element Element} or {@link engine.view.DocumentFragment DocumentFragment} - this node
 	 * will be used as root for all parsed nodes.
-	 * @returns {engine.treeView.Node|engine.treeView.DocumentFragment}
+	 * @returns {engine.view.Node|engine.view.DocumentFragment}
 	 */
 	parse( data, rootElement = null ) {
 		const htmlProcessor = new HtmlDataProcessor();
@@ -493,9 +493,9 @@ class ViewParser {
 	 *
 	 * @private
 	 * @param {Node} domNode
-	 * @param {engine.treeView.Element|engine.treeView.DocumentFragment} [rootElement=null] Default root element to use
+	 * @param {engine.view.Element|engine.view.DocumentFragment} [rootElement=null] Default root element to use
 	 * when parsing elements.
-	 * @returns {engine.treeView.Node|engine.treeView.DocumentFragment}
+	 * @returns {engine.view.Node|engine.view.DocumentFragment}
 	 */
 	_walkDom( domNode, rootElement = null ) {
 		const isDomElement = domNode instanceof window.Element;
@@ -533,11 +533,11 @@ class ViewParser {
 	}
 
 	/**
-	 * Converts DOM Element to {engine.treeView.Element view Element}.
+	 * Converts DOM Element to {engine.view.Element view Element}.
 	 *
 	 * @private
 	 * @param {Element} domElement DOM element to convert.
-	 * @returns {engine.treeView.Element|engine.treeView.AttributeElement|engine.treeView.ContainerElement} Tree view
+	 * @returns {engine.view.Element|engine.view.AttributeElement|engine.view.ContainerElement} Tree view
 	 * element converted from DOM element.
 	 */
 	_convertElement( domElement ) {
@@ -568,7 +568,7 @@ class ViewParser {
 	}
 
 	/**
-	 * Converts DOM element tag name to information needed for creating {@link engine.treeView.Element view Element} instance.
+	 * Converts DOM element tag name to information needed for creating {@link engine.view.Element view Element} instance.
 	 * Name can be provided in couple formats: as a simple element's name (`div`), as a type and name (`container:div`,
 	 * `attribute:span`), as a name and priority (`span:12`) and as a type, priority, name trio (`attribute:span:12`);
 	 *
@@ -677,7 +677,7 @@ class ViewStringify {
 	 * Creates ViewStringify instance.
 	 *
 	 * @param root
-	 * @param {engine.treeView.Selection} [selection=null] Selection which ranges should be also converted to string.
+	 * @param {engine.view.Selection} [selection=null] Selection which ranges should be also converted to string.
 	 * @param {Object} [options] Options object.
 	 * @param {Boolean} [options.showType=false] When set to `true` type of elements will be printed ( `<container:p>`
 	 * instead of `<p>` and `<attribute:b>` instead of `<b>`.
@@ -718,7 +718,7 @@ class ViewStringify {
 	 * Calls `callback` with parsed chunks of string data.
 	 *
 	 * @private
-	 * @param {engine.treeView.DocumentFragment|engine.treeView.Element|engine.treeView.Text} root
+	 * @param {engine.view.DocumentFragment|engine.view.Element|engine.view.Text} root
 	 * @param {Function} callback
 	 */
 	_walkView( root, callback ) {
@@ -750,11 +750,11 @@ class ViewStringify {
 	}
 
 	/**
-	 * Checks if given {@link engine.treeView.Element Element} has {@link engine.treeView.Range#start range start} or
-	 * {@link engine.treeView.Range#start range end} placed at given offset and returns its string representation.
+	 * Checks if given {@link engine.view.Element Element} has {@link engine.view.Range#start range start} or
+	 * {@link engine.view.Range#start range end} placed at given offset and returns its string representation.
 	 *
 	 * @private
-	 * @param {engine.treeView.Element} element
+	 * @param {engine.view.Element} element
 	 * @param {Number} offset
 	 */
 	_stringifyElementRanges( element, offset ) {
@@ -780,12 +780,12 @@ class ViewStringify {
 	}
 
 	/**
-	 * Checks if given {@link engine.treeView.Element Text node} has {@link engine.treeView.Range#start range start} or
-	 * {@link engine.treeView.Range#start range end} placed somewhere inside. Returns string representation of text
+	 * Checks if given {@link engine.view.Element Text node} has {@link engine.view.Range#start range start} or
+	 * {@link engine.view.Range#start range end} placed somewhere inside. Returns string representation of text
 	 * with range delimiters placed inside.
 	 *
 	 * @private
-	 * @param {engine.treeView.Text} node
+	 * @param {engine.view.Text} node
 	 */
 	_stringifyTextRanges( node ) {
 		const length = node.data.length;
@@ -825,13 +825,13 @@ class ViewStringify {
 	}
 
 	/**
-	 * Converts passed {@link engine.treeView.Element Element} to opening tag.
+	 * Converts passed {@link engine.view.Element Element} to opening tag.
 	 * Depending on current configuration opening tag can be simple (`<a>`), contain type prefix (`<container:p>` or
 	 * `<attribute:a>`), contain priority information ( `<attribute:a priority=20>` ). Element's attributes also
 	 * will be included (`<a href="http://ckeditor.com" name="foobar">`).
 	 *
 	 * @private
-	 * @param {engine.treeView.Element} element
+	 * @param {engine.view.Element} element
 	 * @returns {String}
 	 */
 	_stringifyElementOpen( element ) {
@@ -845,12 +845,12 @@ class ViewStringify {
 	}
 
 	/**
-	 * Converts passed {@link engine.treeView.Element Element} to closing tag.
+	 * Converts passed {@link engine.view.Element Element} to closing tag.
 	 * Depending on current configuration opening tag can be simple (`</a>`) or contain type prefix (`</container:p>` or
 	 * `</attribute:a>`).
 	 *
 	 * @private
-	 * @param {engine.treeView.Element} element
+	 * @param {engine.view.Element} element
 	 * @returns {String}
 	 */
 	_stringifyElementClose( element ) {
@@ -862,13 +862,13 @@ class ViewStringify {
 	}
 
 	/**
-	 * Converts passed {@link engine.treeView.Element Element's} type to its string representation
-	 * Returns 'attribute' for {@link engine.treeView.AttributeElement AttributeElements} and
-	 * 'container' for {@link engine.treeView.ContainerElement ContainerElements}. Returns empty string when current
+	 * Converts passed {@link engine.view.Element Element's} type to its string representation
+	 * Returns 'attribute' for {@link engine.view.AttributeElement AttributeElements} and
+	 * 'container' for {@link engine.view.ContainerElement ContainerElements}. Returns empty string when current
 	 * configuration is preventing showing elements' types.
 	 *
 	 * @private
-	 * @param {engine.treeView.Element} element
+	 * @param {engine.view.Element} element
 	 * @returns {String}
 	 */
 	_stringifyElementType( element ) {
@@ -886,13 +886,13 @@ class ViewStringify {
 	}
 
 	/**
-	 * Converts passed {@link engine.treeView.Element Element} to its priority representation.
+	 * Converts passed {@link engine.view.Element Element} to its priority representation.
 	 * Priority string representation will be returned when passed element is an instance of
-	 * {@link engine.treeView.AttributeElement AttributeElement} and current configuration allow to show priority.
+	 * {@link engine.view.AttributeElement AttributeElement} and current configuration allow to show priority.
 	 * Otherwise returns empty string.
 	 *
 	 * @private
-	 * @param {engine.treeView.Element} element
+	 * @param {engine.view.Element} element
 	 * @returns {String}
 	 */
 	_stringifyElementPriority( element ) {
@@ -904,11 +904,11 @@ class ViewStringify {
 	}
 
 	/**
-	 * Converts passed {@link engine.treeView.Element Element} attributes to their string representation.
+	 * Converts passed {@link engine.view.Element Element} attributes to their string representation.
 	 * If element has no attributes - empty string is returned.
 	 *
 	 * @private
-	 * @param {engine.treeView.Element} element
+	 * @param {engine.view.Element} element
 	 * @returns {String}
 	 */
 	_stringifyElementAttributes( element ) {

+ 23 - 23
packages/ckeditor5-engine/tests/treecontroller/advanced-converters.js

@@ -3,30 +3,30 @@
  * For licensing, see LICENSE.md.
  */
 
-/* bender-tags: treecontroller */
+/* bender-tags: conversion */
 
 'use strict';
 
-import ModelDocument from '/ckeditor5/engine/treemodel/document.js';
-import ModelDocumentFragment from '/ckeditor5/engine/treemodel/documentfragment.js';
-import ModelElement from '/ckeditor5/engine/treemodel/element.js';
-import ModelText from '/ckeditor5/engine/treemodel/text.js';
-import ModelTextProxy from '/ckeditor5/engine/treemodel/textproxy.js';
-import ModelRange from '/ckeditor5/engine/treemodel/range.js';
-import ModelPosition from '/ckeditor5/engine/treemodel/position.js';
-import ModelWalker from '/ckeditor5/engine/treemodel/treewalker.js';
-
-import ViewElement from '/ckeditor5/engine/treeview/element.js';
-import ViewContainerElement from '/ckeditor5/engine/treeview/containerelement.js';
-import ViewAttributeElement from '/ckeditor5/engine/treeview/attributeelement.js';
-import ViewText from '/ckeditor5/engine/treeview/text.js';
-import ViewWriter from  '/ckeditor5/engine/treeview/writer.js';
-import ViewPosition from '/ckeditor5/engine/treeview/position.js';
-import ViewRange from '/ckeditor5/engine/treeview/range.js';
-
-import Mapper from '/ckeditor5/engine/treecontroller/mapper.js';
-import ModelConversionDispatcher from '/ckeditor5/engine/treecontroller/modelconversiondispatcher.js';
-import ViewConversionDispatcher from '/ckeditor5/engine/treecontroller/viewconversiondispatcher.js';
+import ModelDocument from '/ckeditor5/engine/model/document.js';
+import ModelDocumentFragment from '/ckeditor5/engine/model/documentfragment.js';
+import ModelElement from '/ckeditor5/engine/model/element.js';
+import ModelText from '/ckeditor5/engine/model/text.js';
+import ModelTextProxy from '/ckeditor5/engine/model/textproxy.js';
+import ModelRange from '/ckeditor5/engine/model/range.js';
+import ModelPosition from '/ckeditor5/engine/model/position.js';
+import ModelWalker from '/ckeditor5/engine/model/treewalker.js';
+
+import ViewElement from '/ckeditor5/engine/view/element.js';
+import ViewContainerElement from '/ckeditor5/engine/view/containerelement.js';
+import ViewAttributeElement from '/ckeditor5/engine/view/attributeelement.js';
+import ViewText from '/ckeditor5/engine/view/text.js';
+import ViewWriter from  '/ckeditor5/engine/view/writer.js';
+import ViewPosition from '/ckeditor5/engine/view/position.js';
+import ViewRange from '/ckeditor5/engine/view/range.js';
+
+import Mapper from '/ckeditor5/engine/conversion/mapper.js';
+import ModelConversionDispatcher from '/ckeditor5/engine/conversion/modelconversiondispatcher.js';
+import ViewConversionDispatcher from '/ckeditor5/engine/conversion/viewconversiondispatcher.js';
 
 import {
 	insertElement,
@@ -38,8 +38,8 @@ import {
 	move,
 	remove,
 	eventNameToConsumableType
-} from '/ckeditor5/engine/treecontroller/model-to-view-converters.js';
-import { convertToModelFragment, convertText } from '/ckeditor5/engine/treecontroller/view-to-model-converters.js';
+} from '/ckeditor5/engine/conversion/model-to-view-converters.js';
+import { convertToModelFragment, convertText } from '/ckeditor5/engine/conversion/view-to-model-converters.js';
 
 let modelDoc, modelRoot, viewRoot, mapper, writer, modelDispatcher, viewDispatcher;
 

+ 11 - 11
packages/ckeditor5-engine/tests/treecontroller/mapper.js

@@ -3,22 +3,22 @@
  * For licensing, see LICENSE.md.
  */
 
-/* bender-tags: treecontroller */
+/* bender-tags: conversion */
 
 'use strict';
 
-import Mapper from '/ckeditor5/engine/treecontroller/mapper.js';
+import Mapper from '/ckeditor5/engine/conversion/mapper.js';
 
-import ModelElement from '/ckeditor5/engine/treemodel/element.js';
-import ModelRootElement from '/ckeditor5/engine/treemodel/rootelement.js';
-import ModelText from '/ckeditor5/engine/treemodel/text.js';
-import ModelPosition from '/ckeditor5/engine/treemodel/position.js';
-import ModelRange from '/ckeditor5/engine/treemodel/range.js';
+import ModelElement from '/ckeditor5/engine/model/element.js';
+import ModelRootElement from '/ckeditor5/engine/model/rootelement.js';
+import ModelText from '/ckeditor5/engine/model/text.js';
+import ModelPosition from '/ckeditor5/engine/model/position.js';
+import ModelRange from '/ckeditor5/engine/model/range.js';
 
-import ViewElement from '/ckeditor5/engine/treeview/element.js';
-import ViewText from '/ckeditor5/engine/treeview/text.js';
-import ViewPosition from '/ckeditor5/engine/treeview/position.js';
-import ViewRange from '/ckeditor5/engine/treeview/range.js';
+import ViewElement from '/ckeditor5/engine/view/element.js';
+import ViewText from '/ckeditor5/engine/view/text.js';
+import ViewPosition from '/ckeditor5/engine/view/position.js';
+import ViewRange from '/ckeditor5/engine/view/range.js';
 
 describe( 'Mapper', () => {
 	let modelDiv, modelP, modelImg;

+ 17 - 17
packages/ckeditor5-engine/tests/treecontroller/model-converter-builder.js

@@ -3,38 +3,38 @@
  * For licensing, see LICENSE.md.
  */
 
-/* bender-tags: treecontroller */
+/* bender-tags: conversion */
 
 'use strict';
 
-import BuildModelConverterFor from '/ckeditor5/engine/treecontroller/model-converter-builder.js';
+import BuildModelConverterFor from '/ckeditor5/engine/conversion/model-converter-builder.js';
 
-import ModelDocument from '/ckeditor5/engine/treemodel/document.js';
-import ModelElement from '/ckeditor5/engine/treemodel/element.js';
-import ModelText from '/ckeditor5/engine/treemodel/text.js';
-import ModelRange from '/ckeditor5/engine/treemodel/range.js';
-import ModelPosition from '/ckeditor5/engine/treemodel/position.js';
+import ModelDocument from '/ckeditor5/engine/model/document.js';
+import ModelElement from '/ckeditor5/engine/model/element.js';
+import ModelText from '/ckeditor5/engine/model/text.js';
+import ModelRange from '/ckeditor5/engine/model/range.js';
+import ModelPosition from '/ckeditor5/engine/model/position.js';
 
-import ViewElement from '/ckeditor5/engine/treeview/element.js';
-import ViewContainerElement from '/ckeditor5/engine/treeview/containerelement.js';
-import ViewAttributeElement from '/ckeditor5/engine/treeview/attributeelement.js';
-import ViewText from '/ckeditor5/engine/treeview/text.js';
-import ViewWriter from '/ckeditor5/engine/treeview/writer.js';
-import ViewSelection from '/ckeditor5/engine/treeview/selection.js';
+import ViewElement from '/ckeditor5/engine/view/element.js';
+import ViewContainerElement from '/ckeditor5/engine/view/containerelement.js';
+import ViewAttributeElement from '/ckeditor5/engine/view/attributeelement.js';
+import ViewText from '/ckeditor5/engine/view/text.js';
+import ViewWriter from '/ckeditor5/engine/view/writer.js';
+import ViewSelection from '/ckeditor5/engine/view/selection.js';
 
-import Mapper from '/ckeditor5/engine/treecontroller/mapper.js';
-import ModelConversionDispatcher from '/ckeditor5/engine/treecontroller/modelconversiondispatcher.js';
+import Mapper from '/ckeditor5/engine/conversion/mapper.js';
+import ModelConversionDispatcher from '/ckeditor5/engine/conversion/modelconversiondispatcher.js';
 
 import {
 	insertText,
 	move,
 	remove
-} from '/ckeditor5/engine/treecontroller/model-to-view-converters.js';
+} from '/ckeditor5/engine/conversion/model-to-view-converters.js';
 
 import {
 	convertCollapsedSelection,
 	clearAttributes
-} from '/ckeditor5/engine/treecontroller/model-selection-to-view-converters.js';
+} from '/ckeditor5/engine/conversion/model-selection-to-view-converters.js';
 
 function viewAttributesToString( item ) {
 	let result = '';

+ 13 - 13
packages/ckeditor5-engine/tests/treecontroller/model-selection-to-view-converters.js

@@ -3,34 +3,34 @@
  * For licensing, see LICENSE.md.
  */
 
-/* bender-tags: treecontroller */
+/* bender-tags: conversion */
 
 'use strict';
 
-import ModelDocument from '/ckeditor5/engine/treemodel/document.js';
-import ModelElement from '/ckeditor5/engine/treemodel/element.js';
-import ModelRange from '/ckeditor5/engine/treemodel/range.js';
-import ModelPosition from '/ckeditor5/engine/treemodel/position.js';
+import ModelDocument from '/ckeditor5/engine/model/document.js';
+import ModelElement from '/ckeditor5/engine/model/element.js';
+import ModelRange from '/ckeditor5/engine/model/range.js';
+import ModelPosition from '/ckeditor5/engine/model/position.js';
 
-import ViewContainerElement from '/ckeditor5/engine/treeview/containerelement.js';
-import ViewAttributeElement from '/ckeditor5/engine/treeview/attributeelement.js';
-import ViewWriter from  '/ckeditor5/engine/treeview/writer.js';
-import ViewSelection from  '/ckeditor5/engine/treeview/selection.js';
+import ViewContainerElement from '/ckeditor5/engine/view/containerelement.js';
+import ViewAttributeElement from '/ckeditor5/engine/view/attributeelement.js';
+import ViewWriter from  '/ckeditor5/engine/view/writer.js';
+import ViewSelection from  '/ckeditor5/engine/view/selection.js';
 
-import Mapper from '/ckeditor5/engine/treecontroller/mapper.js';
-import ModelConversionDispatcher from '/ckeditor5/engine/treecontroller/modelconversiondispatcher.js';
+import Mapper from '/ckeditor5/engine/conversion/mapper.js';
+import ModelConversionDispatcher from '/ckeditor5/engine/conversion/modelconversiondispatcher.js';
 import {
 	convertRangeSelection,
 	convertCollapsedSelection,
 	convertSelectionAttribute,
 	clearAttributes
-} from '/ckeditor5/engine/treecontroller/model-selection-to-view-converters.js';
+} from '/ckeditor5/engine/conversion/model-selection-to-view-converters.js';
 
 import {
 	insertElement,
 	insertText,
 	wrap
-} from '/ckeditor5/engine/treecontroller/model-to-view-converters.js';
+} from '/ckeditor5/engine/conversion/model-to-view-converters.js';
 
 import { stringify as stringifyView } from '/tests/engine/_utils/view.js';
 import { setData as setModelData } from '/tests/engine/_utils/model.js';

+ 0 - 0
packages/ckeditor5-engine/tests/treecontroller/model-to-view-converters.js


Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů