Sfoglia il codice sorgente

Docs and code simplification.

Piotrek Koszuliński 5 anni fa
parent
commit
b493949712

+ 1 - 1
packages/ckeditor5-engine/src/dataprocessor/htmldataprocessor.js

@@ -22,7 +22,7 @@ export default class HtmlDataProcessor {
 	/**
 	 * Creates a new instance of the HTML data processor class.
 	 *
-	 * @param {module:engine/view/document~Document} document
+	 * @param {module:engine/view/document~Document} document The view document instance.
 	 */
 	constructor( document ) {
 		/**

+ 1 - 1
packages/ckeditor5-engine/src/dataprocessor/xmldataprocessor.js

@@ -24,7 +24,7 @@ export default class XmlDataProcessor {
 	/**
 	 * Creates a new instance of the XML data processor class.
 	 *
-	 * @param {module:engine/view/document~Document} document
+	 * @param {module:engine/view/document~Document} document The view document instance.
 	 * @param {Object} options Configuration options.
 	 * @param {Array<String>} [options.namespaces=[]] A list of namespaces allowed to use in the XML input.
 	 */

+ 1 - 1
packages/ckeditor5-engine/src/model/node.js

@@ -189,7 +189,7 @@ export default class Node {
 	}
 
 	/**
-	 * Returns true if a node is in a tree rooted in an element of the root type.
+	 * Returns true if the node is in a tree rooted in the document (is a descendant of one of its roots).
 	 *
 	 * @returns {Boolean}
 	 */

+ 4 - 6
packages/ckeditor5-engine/src/model/rootelement.js

@@ -17,12 +17,12 @@ export default class RootElement extends Element {
 	/**
 	 * Creates root element.
 	 *
-	 * @param {module:engine/model/document~Document} doc Document that is an owner of this root.
+	 * @param {module:engine/model/document~Document} document Document that is an owner of this root.
 	 * @param {String} name Node name.
 	 * @param {String} [rootName='main'] Unique root name used to identify this root
 	 * element by {@link module:engine/model/document~Document}.
 	 */
-	constructor( doc, name, rootName = 'main' ) {
+	constructor( document, name, rootName = 'main' ) {
 		super( name );
 
 		/**
@@ -31,7 +31,7 @@ export default class RootElement extends Element {
 		 * @private
 		 * @member {module:engine/model/document~Document}
 		 */
-		this._doc = doc;
+		this._document = document;
 
 		/**
 		 * Unique root name used to identify this root element by {@link module:engine/model/document~Document}.
@@ -45,13 +45,11 @@ export default class RootElement extends Element {
 	/**
 	 * {@link module:engine/model/document~Document Document} that owns this root element.
 	 *
-	 * In contrary, to {@link module:engine/model/node~Node node}, root element always have a `document`.
-	 *
 	 * @readonly
 	 * @type {module:engine/model/document~Document|null}
 	 */
 	get document() {
-		return this._doc;
+		return this._document;
 	}
 
 	/**

+ 3 - 7
packages/ckeditor5-engine/src/model/selection.js

@@ -829,9 +829,7 @@ function isUnvisitedBlock( element, visited ) {
 
 	visited.add( element );
 
-	const document = element.is( 'rootElement' ) ? element.document : element.root.document;
-
-	return document.model.schema.isBlock( element ) && element.parent;
+	return element.root.document.model.schema.isBlock( element ) && element.parent;
 }
 
 // Checks if the given element is a $block was not previously visited and is a top block in a range.
@@ -844,8 +842,7 @@ function isUnvisitedTopBlock( element, visited, range ) {
 // Marks all ancestors as already visited to not include any of them later on.
 function getParentBlock( position, visited ) {
 	const element = position.parent;
-	const document = element.is( 'rootElement' ) ? element.document : element.root.document;
-	const schema = document.model.schema;
+	const schema = element.root.document.model.schema;
 
 	const ancestors = position.parent.getAncestors( { parentFirst: true, includeSelf: true } );
 
@@ -891,8 +888,7 @@ function isTopBlockInRange( block, range ) {
 // @param {module:engine/model/node~Node} node
 // @returns {module:engine/model/node~Node|undefined}
 function findAncestorBlock( node ) {
-	const document = node.is( 'rootElement' ) ? node.document : node.root.document;
-	const schema = document.model.schema;
+	const schema = node.root.document.model.schema;
 
 	let parent = node.parent;