8
0
Просмотр исходного кода

Docs: introduced @typedef NodesSet.

Szymon Cofalik 10 лет назад
Родитель
Сommit
6eb108e173

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

@@ -24,7 +24,7 @@ export default class InsertDelta extends Delta {}
  * @memberOf treeModel.Batch
  * @method insert
  * @param {treeModel.Position} position Position of insertion.
- * @param {treeModel.Node|treeModel.Text|treeModel.NodeList|String|Iterable} nodes The list of nodes to be inserted.
+ * @param {treeModel.NodesSet} nodes The list of nodes to be inserted.
  * List of nodes can be of any type accepted by the {@link treeModel.NodeList} constructor.
  */
 register( 'insert', function( position, nodes ) {
@@ -37,4 +37,4 @@ register( 'insert', function( position, nodes ) {
 	this.addDelta( delta );
 
 	return this;
-} );
+} );

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

@@ -33,7 +33,7 @@ export default class WeakInsertDelta extends Delta {}
  * @memberOf treeModel.Batch
  * @method weakInsert
  * @param {treeModel.Position} position Position of insertion.
- * @param {treeModel.Node|treeModel.Text|treeModel.NodeList|String|Iterable} nodes The list of nodes to be inserted.
+ * @param {treeModel.NodesSet} nodes The list of nodes to be inserted.
  * List of nodes can be of any type accepted by the {@link treeModel.NodeList} constructor.
  */
 register( 'weakInsert', function( position, nodes ) {

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

@@ -21,7 +21,7 @@ export default class Element extends Node {
 	 *
 	 * @param {String} name Node name.
 	 * @param {Iterable} attrs Iterable collection of {@link treeModel.Attribute attributes}.
-	 * @param {treeModel.Node|treeModel.Text|treeModel.CharacterProxy|treeModel.NodeList|String|Iterable} children List of nodes to be inserted
+	 * @param {treeModel.NodesSet} children List of nodes to be inserted
 	 * into created element. List of nodes can be of any type accepted by the {@link treeModel.NodeList} constructor.
 	 * @constructor
 	 */
@@ -85,7 +85,7 @@ export default class Element extends Node {
 	 * All attached nodes should be modified using the {@link treeModel.operation.InsertOperation}.
 	 *
 	 * @param {Number} index Position where nodes should be inserted.
-	 * @param {treeModel.Node|treeModel.Text|treeModel.NodeList|String|Iterable} nodes The list of nodes to be inserted.
+	 * @param {treeModel.NodesSet} nodes The list of nodes to be inserted.
 	 * The list of nodes can be of any type accepted by the {@link treeModel.NodeList} constructor.
 	 */
 	insertChildren( index, nodes ) {

+ 16 - 1
packages/ckeditor5-engine/src/treemodel/nodelist.js

@@ -10,6 +10,19 @@ import Text from './text.js';
 import utils from '../utils.js';
 import langUtils from '../lib/lodash/lang.js';
 
+/**
+ * Value that is convertible to an item kept in {@link treeModel.NodeList} or an iterable collection of such items.
+ * In other words, this is anything that {@link treeModel.NodeList#constructor} is able to take and convert to node:
+ * * {@link treeModel.Element} will be left as is
+ * * {@link treeModel.CharacterProxy} will be left as is
+ * * {@link treeModel.Text} and {String} will be converted to a set of {@link treeModel.CharacterProxy}
+ * * {@link treeModel.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 {treeModel.Element|treeModel.CharacterProxy|treeModel.Text|String|treeModel.NodeList|Iterable} treeModel.NodesSet
+ */
+
 /**
  * This is a private helper-class for {@link treeModel.NodeList} text compression utility.
  *
@@ -92,7 +105,9 @@ export default class NodeList {
 	 *		nodeListA === nodeListB // true
 	 *		nodeListB.length // 3
 	 *
-	 * @param {treeModel.Node|treeModel.Text|String|treeModel.NodeList|Iterable} nodes List of nodes.
+	 * @see {@link treeModel.NodesSet} for more explanation.
+	 *
+	 * @param {treeModel.NodesSet} nodes List of nodes.
 	 * @constructor
 	 */
 	constructor( nodes ) {

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

@@ -21,7 +21,7 @@ export default class InsertOperation extends Operation {
 	 * Creates an insert operation.
 	 *
 	 * @param {treeModel.Position} position Position of insertion.
-	 * @param {treeModel.Node|treeModel.Text|treeModel.NodeList|String|Iterable} nodes The list of nodes to be inserted.
+	 * @param {treeModel.NodesSet} nodes The list of nodes to be inserted.
 	 * List of nodes can be any type accepted by the {@link treeModel.NodeList} constructor.
 	 * @param {Number} baseVersion {@link treeModel.Document#version} on which operation can be applied.
 	 * @constructor