Parcourir la source

Improve description to model's is method.

Mateusz Samsel il y a 6 ans
Parent
commit
85e9ffb119

+ 7 - 2
packages/ckeditor5-engine/src/model/documentfragment.js

@@ -116,9 +116,14 @@ export default class DocumentFragment {
 	}
 
 	/**
-	 * Checks whether given model tree object is of given type.
+	 * Method verifies if the checked object belongs to a given a type. Type's name might be prefixed with a `model:` string,
+	 * for example `model:documentFragment`. Type is a string which usually equal to a name of the class written in camelCase convention.
+	 * If the object is a class instance, which has a parent class with `is()` method, then type verification returns `true`
+	 * for any type match for an entire child-parent chain.
 	 *
-	 * Read more in {@link module:engine/model/node~Node#is `Node#is()`}.
+	 * Acceptable type for this class is `documentFragment` and its prefixed version.
+	 *
+	 * See also: {@link module:engine/model/node~Node#is `Node#is()`}.
 	 *
 	 * @param {String} type
 	 * @returns {Boolean}

+ 8 - 2
packages/ckeditor5-engine/src/model/documentselection.js

@@ -368,8 +368,10 @@ export default class DocumentSelection {
 	}
 
 	/**
-	 * Checks whether object is of given type following the convention set by
-	 * {@link module:engine/model/node~Node#is `Node#is()`}.
+	 * Method verifies if the checked object belongs to a given a type. Type's name might be prefixed with a `model:` string,
+	 * for example `model:selection`. Type is a string which usually equal to a name of the class written in camelCase convention.
+	 * If the object is a class instance, which has a parent class with `is()` method, then type verification returns `true`
+	 * for any type match for an entire child-parent chain.
 	 *
 	 *		const selection = new DocumentSelection( ... );
 	 *
@@ -382,6 +384,10 @@ export default class DocumentSelection {
 	 *		selection.is( 'model:node' ); // false
 	 *		selection.is( 'element' ); // false
 	 *
+	 * Acceptable type for this class is `selection` and its prefixed version.
+	 *
+	 * See also: {@link module:engine/model/node~Node#is `Node#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

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

@@ -89,7 +89,13 @@ export default class Element extends Node {
 	}
 
 	/**
-	 * Checks whether this model object is of the given type.
+	 * Method verifies if the checked object belongs to a given a type. Type's name might be prefixed with a `model:` string,
+	 * for example `model:element`. Type is a string which usually equal to a name of the class written in camelCase convention.
+	 * If the object is a class instance, which has a parent class with `is()` method, then type verification returns `true`
+	 * for any type match for an entire child-parent chain.
+	 *
+	 * There is also possibility to check element's {@link #name} rather than just type. Name might be provided as second attribute
+	 * or might replace the type.
 	 *
 	 *		obj.name; // 'listItem'
 	 *		obj instanceof Element; // true
@@ -105,7 +111,9 @@ export default class Element extends Node {
 	 *		obj.is( 'view:element' ); // false
 	 *		obj.is( 'element', 'image' ); // false
 	 *
-	 * Read more in {@link module:engine/model/node~Node#is `Node#is()`}.
+	 * Acceptable type for this class is `element` and its prefixed version, element's name or combination of both arguments.
+	 *
+	 * See also: {@link module:engine/model/node~Node#is `Node#is()`}.
 	 *
 	 * @param {String} type Type to check when `name` parameter is present.
 	 * Otherwise, it acts like the `name` parameter.

+ 7 - 2
packages/ckeditor5-engine/src/model/markercollection.js

@@ -449,9 +449,14 @@ class Marker {
 	}
 
 	/**
-	 * Checks whether given object is of `marker` type.
+	 * Method verifies if the checked object belongs to a given a type. Type's name might be prefixed with a `model:` string,
+	 * for example `model:marker`. Type is a string which usually equal to a name of the class written in camelCase convention.
+	 * If the object is a class instance, which has a parent class with `is()` method, then type verification returns `true`
+	 * for any type match for an entire child-parent chain.
 	 *
-	 * Read more at {@link module:engine/model/node~Node#is `Node#is()`}.
+	 * Acceptable type for this class is `marker` and its prefixed version.
+	 *
+	 * See also: {@link module:engine/model/node~Node#is `Node#is()`}.
 	 *
 	 * @param {String} type
 	 * @returns {Boolean}

+ 2 - 0
packages/ckeditor5-engine/src/model/node.js

@@ -482,6 +482,8 @@ export default class Node {
 	 *		obj.is( 'text' ); // true for text node, false for element and document fragment
 	 *		obj.is( 'textProxy' ); // true for text proxy object
 	 *
+	 * Acceptable types for this class is `node` and its prefixed version.
+	 *
 	 * @method #is
 	 * @param {String} type
 	 * @returns {Boolean}

+ 8 - 2
packages/ckeditor5-engine/src/model/position.js

@@ -503,9 +503,15 @@ export default class Position {
 	}
 
 	/**
-	 * Checks whether given object is of `position` type.
+	 * Method verifies if the checked object belongs to a given a type. Type's name might be prefixed with a `model:` string,
+	 * for example `model:position`. Type is a string which usually equal to a name of the class written in camelCase convention.
+	 * If the object is a class instance, which has a parent class with `is()` method, then type verification returns `true`
+	 * for any type match for an entire child-parent chain.
 	 *
-	 * Read more at {@link module:engine/model/node~Node#is `Node#is()`}.
+	 * Acceptable type for this class is `position` and its prefixed version.
+	 * For {@link module:engine/model/liveposition~LivePosition} class there also acceptable `livePosition` type and its prefixed version.
+	 *
+	 * See also: {@link module:engine/model/node~Node#is `Node#is()`}.
 	 *
 	 * @param {String} type
 	 * @returns {Boolean}

+ 8 - 2
packages/ckeditor5-engine/src/model/range.js

@@ -144,9 +144,15 @@ export default class Range {
 	}
 
 	/**
-	 * Checks whether given object is of `range` type.
+	 * Method verifies if the checked object belongs to a given a type. Type's name might be prefixed with a `model:` string,
+	 * for example `model:range`. Type is a string which usually equal to a name of the class written in camelCase convention.
+	 * If the object is a class instance, which has a parent class with `is()` method, then type verification returns `true`
+	 * for any type match for an entire child-parent chain.
 	 *
-	 * Read more at {@link module:engine/model/node~Node#is `Node#is()`}.
+	 * Acceptable type for this class is `range` and its prefixed version.
+	 * For {@link module:engine/model/liverange~LiveRange} class there also acceptable `liveRange` type and its prefixed version.
+	 *
+	 * See also: {@link module:engine/model/node~Node#is `Node#is()`}.
 	 *
 	 * @param {String} type
 	 * @returns {Boolean}

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

@@ -623,8 +623,10 @@ export default class Selection {
 	}
 
 	/**
-	 * Checks whether object is of given type following the convention set by
-	 * {@link module:engine/model/node~Node#is `Node#is()`}.
+	 * Method verifies if the checked object belongs to a given a type. Type's name might be prefixed with a `model:` string,
+	 * for example `model:selection`. Type is a string which usually equal to a name of the class written in camelCase convention.
+	 * If the object is a class instance, which has a parent class with `is()` method, then type verification returns `true`
+	 * for any type match for an entire child-parent chain.
 	 *
 	 *		const selection = new Selection( ... );
 	 *
@@ -634,6 +636,9 @@ export default class Selection {
 	 *		selection.is( 'element' ); // false
 	 *		selection.is( 'view:selection' ); // false
 	 *
+	 * Acceptable type for this class is `selection` and its prefixed version.
+	 *
+	 * See also: {@link module:engine/model/node~Node#is `Node#is()`}.
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

+ 7 - 2
packages/ckeditor5-engine/src/model/textproxy.js

@@ -173,9 +173,14 @@ export default class TextProxy {
 	}
 
 	/**
-	 * Checks whether given object is of `textProxy` type.
+	 * Method verifies if the checked object belongs to a given a type. Type's name might be prefixed with a `model:` string,
+	 * for example `model:textProxy`. Type is a string which usually equal to a name of the class written in camelCase convention.
+	 * If the object is a class instance, which has a parent class with `is()` method, then type verification returns `true`
+	 * for any type match for an entire child-parent chain.
 	 *
-	 * Read more in {@link module:engine/model/node~Node#is `Node#is()`}.
+	 * Acceptable type for this class is `textProxy` and its prefixed version.
+	 *
+	 * See also: {@link module:engine/model/node~Node#is `Node#is()`}.
 	 *
 	 * @param {String} type
 	 * @returns {Boolean}