Kaynağa Gözat

Docs: Added an example.

Piotrek Koszuliński 6 yıl önce
ebeveyn
işleme
3762bfa30d
1 değiştirilmiş dosya ile 10 ekleme ve 0 silme
  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]