浏览代码

Update docs description for engine/model classes.

Mateusz Samsel 6 年之前
父节点
当前提交
c241ff0f78

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

@@ -83,6 +83,8 @@ export default class Batch {
 	/**
 	 * Checks whether given object is of `batch` type.
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

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

@@ -522,6 +522,8 @@ export default class Differ {
 	/**
 	 * Checks whether given object is of `differ` type.
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

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

@@ -244,6 +244,8 @@ export default class Document {
 	/**
 	 * Checks whether given object is of `document` type.
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

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

@@ -118,7 +118,7 @@ export default class DocumentFragment {
 	/**
 	 * Checks whether given model tree object is of given type.
 	 *
-	 * Read more in {@link module:engine/model/node~Node#is}.
+	 * Read more in {@link module:engine/model/node~Node#is `Node#is()`} and {@link module:engine/model/model~Model#is `Model#is()`}.
 	 *
 	 * @param {String} type
 	 * @returns {Boolean}

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

@@ -382,6 +382,8 @@ export default class DocumentSelection {
 	 *		selection.is( 'model:node' ); // false
 	 *		selection.is( 'element' ); // false
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

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

@@ -105,7 +105,7 @@ 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()`}.
+	 * Read more in {@link module:engine/model/node~Node#is `Node#is()`} and {@link module:engine/model/model~Model#is `Model#is()`}.
 	 *
 	 * @param {String} type Type to check when `name` parameter is present.
 	 * Otherwise, it acts like the `name` parameter.

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

@@ -100,6 +100,8 @@ export default class History {
 	/**
 	 * Checks whether given object is of `history` type.
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

+ 4 - 0
packages/ckeditor5-engine/src/model/markercollection.js

@@ -75,6 +75,8 @@ export default class MarkerCollection {
 	/**
 	 * Checks whether given object is of `markerCollection` type.
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */
@@ -461,6 +463,8 @@ class Marker {
 	/**
 	 * Checks whether given object is of `marker` type.
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

+ 16 - 0
packages/ckeditor5-engine/src/model/model.js

@@ -720,6 +720,22 @@ export default class Model {
 	/**
 	 * Checks whether given object is of `model` type.
 	 *
+	 * All classes related to {@link module:engine/model/model~Model} might contain `is` method,
+	 * which checks if given object belong to specific type. It might simplify your code for cases,
+	 * when you want to test unknown object for specific type.
+	 * Instead of using `instanceof` and importing entire class for testing,
+	 * there might be used `is` method which test for given name.
+	 * There is also available `model:` prefix in each case, which gives more specific results.
+	 * It helps to distinguish model's classes from view's. Few examples how to use this method you can find below:
+	 *
+	 * 	model.is( 'model' ) // return true
+	 * 	range.is( 'range' ) // return true
+	 * 	range.is( 'model:range' ) // return true
+	 * 	range.is( 'view:range' ) // return false
+	 * 	document.is( 'model:document' ) // return true
+	 *
+	 * See also {@link module:engine/model/node~Node#is `Node#is()`} for some more details related to elements.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

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

@@ -478,6 +478,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
 	 *
+	 *	Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @method #is
 	 * @param {String} type
 	 * @returns {Boolean}

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

@@ -173,6 +173,8 @@ export default class NodeList {
 	/**
 	 * Checks whether given object is of `nodeList` type.
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

+ 9 - 6
packages/ckeditor5-engine/src/model/operation/operation.js

@@ -87,21 +87,24 @@ export default class Operation {
 	 * attribute operation. You need to use analogical syntax for other {@link module:engine/model/operation/operation~Operation}.
 	 *
 	 * 	// Examples for AttributeOperation.
-	 * 	operation.is( 'operation' ) // true for any operation
-	 * 	operation.is( 'model:operation' ) // true for any operation
+	 *
+	 * 	operation instanceof AttributeOperation
+	 *
+	 * 	operation.is( 'operation' ) // true for AttributeOperation and other operations
+	 * 	operation.is( 'model:operation' ) // true for AttributeOperation and other operations
 	 * 	operation.is( 'attributeOperation' ) // true for AttributeOperation
 	 * 	operation.is( 'model:operation:attribute' ) // true for AttributeOperation
 	 *
-	 * 	// Random examples for other Operations
+	 * 	// Disallowed syntax
+	 * 	operation.is( 'operation:attribute' ) // will return false
+	 *
+	 * 	// Few examples for other Operations
 	 * 	operation.is( 'model:operation:no ) // true for no-operation
 	 * 	operation.is( 'noOperation' ) // true for no-operation
 	 * 	operation.is( 'model:operation:marker ) // true for marker operation
 	 * 	operation.is( 'insertOperation' ) // true for insert operation
 	 * 	operation.is( 'model:operation:rootAttribute' ) // true for rootAttributeOperation
 	 *
-	 * 	// Disallowed syntax
-	 * 	operation.is( 'operation:attribute' ) // will always return false
-	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

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

@@ -505,6 +505,8 @@ export default class Position {
 	/**
 	 * Checks whether given object is of `position` type.
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

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

@@ -146,6 +146,8 @@ export default class Range {
 	/**
 	 * Checks whether given object is of `range` type.
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

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

@@ -190,6 +190,8 @@ export default class Schema {
 	/**
 	 * Checks whether given object is of `schema` type.
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

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

@@ -634,6 +634,8 @@ export default class Selection {
 	 *		selection.is( 'element' ); // false
 	 *		selection.is( 'view:selection' ); // false
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

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

@@ -175,7 +175,7 @@ export default class TextProxy {
 	/**
 	 * Checks whether given object is of `textProxy` type.
 	 *
-	 * Read more in {@link module:engine/model/node~Node#is}.
+	 * Read more in {@link module:engine/model/node~Node#is `Node#is()`} and {@link module:engine/model/model~Model#is `Model#is()`}.
 	 *
 	 * @param {String} type
 	 * @returns {Boolean}

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

@@ -155,6 +155,8 @@ export default class TreeWalker {
 	/**
 	 * Checks whether given object is of `treeWalker` type.
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */

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

@@ -82,6 +82,8 @@ export default class Writer {
 	/**
 	 * Checks whether given object is of `writer` type.
 	 *
+	 * Read more at {@link module:engine/model/model~Model#is `Model#is()`}.
+	 *
 	 * @param {String} type
 	 * @returns {Boolean}
 	 */