Explorar el Código

Other: Introduce ViewPosition.getWalker().

Maciej Gołaszewski hace 7 años
padre
commit
9918e5df83
Se han modificado 1 ficheros con 15 adiciones y 0 borrados
  1. 15 0
      packages/ckeditor5-engine/src/view/position.js

+ 15 - 0
packages/ckeditor5-engine/src/view/position.js

@@ -274,6 +274,21 @@ export default class Position {
 		}
 	}
 
+	/**
+	 * Creates a {@link module:engine/view/treewalker~TreeWalker TreeWalker} instance with this positions as a start position.
+	 *
+	 * @param {Object} options Object with configuration options. See {@link module:engine/view/treewalker~TreeWalker}
+	 * @param {module:engine/view/range~Range} [options.boundaries=null] Range to define boundaries of the iterator.
+	 * @param {Boolean} [options.singleCharacters=false]
+	 * @param {Boolean} [options.shallow=false]
+	 * @param {Boolean} [options.ignoreElementEnd=false]
+	 */
+	getWalker( options = {} ) {
+		options.startPosition = this;
+
+		return new TreeWalker( options );
+	}
+
 	/**
 	 * Creates position at the given location. The location can be specified as:
 	 *