Browse Source

Fixed docs and order of methods in class.

Kamil Piechaczek 7 years ago
parent
commit
fb4d26b683

+ 41 - 41
packages/ckeditor5-engine/src/model/documentfragment.js

@@ -25,8 +25,8 @@ export default class DocumentFragment {
 	/**
 	 * Creates an empty `DocumentFragment`.
 	 *
-	 * **Note:** Constructor of this class shouldn't be used directly in the code. Instead of use the
-	 * {@link module:engine/model/writer~Writer#createDocumentFragment} method.
+	 * **Note:** Constructor of this class shouldn't be used directly in the code.
+	 * Use the {@link module:engine/model/writer~Writer#createDocumentFragment} method instead.
 	 *
 	 * @protected
 	 * @param {module:engine/model/node~Node|Iterable.<module:engine/model/node~Node>} [children]
@@ -221,6 +221,45 @@ export default class DocumentFragment {
 	}
 
 	/**
+	 * Converts `DocumentFragment` instance to plain object and returns it.
+	 * Takes care of converting all of this document fragment's children.
+	 *
+	 * @returns {Object} `DocumentFragment` instance converted to plain object.
+	 */
+	toJSON() {
+		const json = [];
+
+		for ( const node of this._children ) {
+			json.push( node.toJSON() );
+		}
+
+		return json;
+	}
+
+	/**
+	 * Creates a `DocumentFragment` instance from given plain object (i.e. parsed JSON string).
+	 * Converts `DocumentFragment` children to proper nodes.
+	 *
+	 * @param {Object} json Plain object to be converted to `DocumentFragment`.
+	 * @returns {module:engine/model/documentfragment~DocumentFragment} `DocumentFragment` instance created using given plain object.
+	 */
+	static fromJSON( json ) {
+		const children = [];
+
+		for ( const child of json ) {
+			if ( child.name ) {
+				// If child has name property, it is an Element.
+				children.push( Element.fromJSON( child ) );
+			} else {
+				// Otherwise, it is a Text node.
+				children.push( Text.fromJSON( child ) );
+			}
+		}
+
+		return new DocumentFragment( children );
+	}
+
+	/**
 	 * {@link #_insertChildren Inserts} one or more nodes at the end of this document fragment.
 	 *
 	 * @protected
@@ -271,45 +310,6 @@ export default class DocumentFragment {
 
 		return nodes;
 	}
-
-	/**
-	 * Converts `DocumentFragment` instance to plain object and returns it.
-	 * Takes care of converting all of this document fragment's children.
-	 *
-	 * @returns {Object} `DocumentFragment` instance converted to plain object.
-	 */
-	toJSON() {
-		const json = [];
-
-		for ( const node of this._children ) {
-			json.push( node.toJSON() );
-		}
-
-		return json;
-	}
-
-	/**
-	 * Creates a `DocumentFragment` instance from given plain object (i.e. parsed JSON string).
-	 * Converts `DocumentFragment` children to proper nodes.
-	 *
-	 * @param {Object} json Plain object to be converted to `DocumentFragment`.
-	 * @returns {module:engine/model/documentfragment~DocumentFragment} `DocumentFragment` instance created using given plain object.
-	 */
-	static fromJSON( json ) {
-		const children = [];
-
-		for ( const child of json ) {
-			if ( child.name ) {
-				// If child has name property, it is an Element.
-				children.push( Element.fromJSON( child ) );
-			} else {
-				// Otherwise, it is a Text node.
-				children.push( Text.fromJSON( child ) );
-			}
-		}
-
-		return new DocumentFragment( children );
-	}
 }
 
 // Converts strings to Text and non-iterables to arrays.

+ 2 - 2
packages/ckeditor5-engine/src/model/element.js

@@ -25,8 +25,8 @@ export default class Element extends Node {
 	/**
 	 * Creates a model element.
 	 *
-	 * **Note:** Constructor of this class shouldn't be used directly in the code. Instead of use the
-	 * {@link module:engine/model/writer~Writer#createElement} method.
+	 * **Note:** Constructor of this class shouldn't be used directly in the code.
+	 * Use the {@link module:engine/model/writer~Writer#createElement} method instead.
 	 *
 	 * @protected
 	 * @param {String} name Element's name.

+ 2 - 2
packages/ckeditor5-engine/src/model/text.js

@@ -26,8 +26,8 @@ export default class Text extends Node {
 	/**
 	 * Creates a text node.
 	 *
-	 * **Note:** Constructor of this class shouldn't be used directly in the code. Instead of use the
-	 * {@link module:engine/model/writer~Writer#createText} method.
+	 * **Note:** Constructor of this class shouldn't be used directly in the code.
+	 * Use the {@link module:engine/model/writer~Writer#createText} method instead.
 	 *
 	 * @protected
 	 * @param {String} data Node's text.

+ 2 - 2
packages/ckeditor5-engine/src/view/element.js

@@ -38,12 +38,12 @@ export default class Element extends Node {
 	 *		new Element( 'div', [ [ 'class', 'editor' ], [ 'contentEditable', 'true' ] ] ); // map-like iterator
 	 *		new Element( 'div', mapOfAttributes ); // map
 	 *
-	 * **Note:** Constructor of this class shouldn't be used directly in the code. Instead of use the
+	 * **Note:** Constructor of this class shouldn't be used directly in the code. Use the
 	 * {@link module:engine/view/writer~Writer#createAttributeElement} for inline element,
 	 * {@link module:engine/view/writer~Writer#createContainerElement} for block element,
 	 * {@link module:engine/view/writer~Writer#createEditableElement} for editable element,
 	 * {@link module:engine/view/writer~Writer#createEmptyElement} for empty element or
-	 * {@link module:engine/view/writer~Writer#createUIElement} for UI element.
+	 * {@link module:engine/view/writer~Writer#createUIElement} for UI element instead.
 	 *
 	 * @protected
 	 * @param {String} name Node name.

+ 2 - 2
packages/ckeditor5-engine/src/view/text.js

@@ -18,8 +18,8 @@ export default class Text extends Node {
 	/**
 	 * Creates a tree view text node.
 	 *
-	 * **Note:** Constructor of this class shouldn't be used directly in the code. Instead of use the
-	 * {@link module:engine/view/writer~Writer#createText} method.
+	 * **Note:** Constructor of this class shouldn't be used directly in the code.
+	 * Use the {@link module:engine/view/writer~Writer#createText} method instead.
 	 *
 	 * @protected
 	 * @param {String} data Text.