Explorar o código

Docs: Added an example.

Piotrek Koszuliński %!s(int64=6) %!d(string=hai) anos
pai
achega
3762bfa30d
Modificáronse 1 ficheiros con 10 adicións e 0 borrados
  1. 10 0
      packages/ckeditor5-engine/src/model/range.js

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

@@ -336,6 +336,16 @@ export default class Range {
 	/**
 	 * Creates a {@link module:engine/model/treewalker~TreeWalker TreeWalker} instance with this range as a boundary.
 	 *
+	 * For example, to iterate over all items in the entire document root:
+	 *
+	 *		// Create a range spanning over the entire root content:
+	 *		const range = editor.model.createRangeIn( editor.model.document.getRoot() );
+	 *
+	 *		// Iterate over all items in this range:
+	 *		for ( const value of range.getWalker() ) {
+	 *			console.log( value.item );
+	 *		}
+	 *
 	 * @param {Object} options Object with configuration options. See {@link module:engine/model/treewalker~TreeWalker}.
 	 * @param {module:engine/model/position~Position} [options.startPosition]
 	 * @param {Boolean} [options.singleCharacters=false]