CKEDITOR.dom.walker
Utility class to "walk" the DOM inside range boundaries. If the range starts or ends in the middle of the text node, this node will be included as a whole. Outside changes to the range may break the walker.
The walker may return nodes that are not totally included in the range boundaries. Let us take the following range representation, where the square brackets indicate the boundaries:
[<p>Some <b>sample] text</b>
While walking forward into the above range, the following nodes are
returned: <p>, "Some ", <b> and "sample". Going
backwards instead we have: "sample" and "Some ". So note that the
walker always returns nodes when "entering" them, but not when
"leaving" them. The guard function is instead called both when
entering and when leaving nodes.
Filtering
Properties
-
evaluator : FunctionCKEDITOR.dom.walker#evaluatorA function executed for every matched node to check whether it is to be considered in the walk or not. If not provided, all matched nodes are considered good.
If the function returns
false, the node is ignored. -
guard : FunctionCKEDITOR.dom.walker#guardA function executed for every node the walk passes by to check whether the walk is to be finished. It is called both when entering and when exiting nodes, as well as for the matched nodes.
If this function returns
false, the walking ends and no more nodes are evaluated. -
Defaults to
{}
Static properties
-
A hash of element names which in browsers that do not need
<br>fillers can be selection containers despite being empty.
Methods
-
constructor( range ) → walkerCKEDITOR.dom.walker#constructorCreates a walker class instance.
Parameters
range : rangeThe range within which to walk.
Returns
walker
-
checkBackward() → BooleanCKEDITOR.dom.walker#checkBackwardCheck all nodes on the left, executing the evaluation function.
Returns
Booleanfalseif the evaluator function returnedfalsefor any of the matched nodes. Otherwisetrue.
-
checkForward() → BooleanCKEDITOR.dom.walker#checkForwardChecks all nodes on the right, executing the evaluation function.
Returns
Booleanfalseif the evaluator function returnedfalsefor any of the matched nodes. Otherwisetrue.
-
end()CKEDITOR.dom.walker#endStops walking. No more nodes are retrieved if this function is called.
-
lastBackward() → nodeCKEDITOR.dom.walker#lastBackwardExecutes a full walk backwards (to the left), until no more nodes are available, returning the last valid node.
Returns
nodeThe last node on the left or
nullif no valid nodes are available.
-
lastForward() → nodeCKEDITOR.dom.walker#lastForwardExecutes a full walk forward (to the right), until no more nodes are available, returning the last valid node.
Returns
nodeThe last node on the right or
nullif no valid nodes are available.
-
next() → nodeCKEDITOR.dom.walker#nextRetrieves the next node (on the right).
Returns
nodeThe next node or
nullif no more nodes are available.
-
previous() → nodeCKEDITOR.dom.walker#previousRetrieves the previous node (on the left).
Returns
nodeThe previous node or
nullif no more nodes are available.
-
reset()CKEDITOR.dom.walker#resetResets the walker.
Static methods
-
Returns a function which checks whether the node is a block boundary. See CKEDITOR.dom.element.isBlockBoundary.
Parameters
customNodeNames : Object
Returns
Function
-
Returns a function which checks whether the node is a bogus (filler) node from
contenteditableelement's point of view.Parameters
[ isReject ] : Boolean-
Defaults to
false
Returns
Function
-
Returns a function which checks whether the node is a bookmark node or the bookmark node inner content.
Parameters
[ contentOnly ] : BooleanWhether only test against the text content of a bookmark node instead of the element itself (default).
Defaults to
false[ isReject ] : BooleanWhether to return
falsefor the bookmark node instead oftrue(default).Defaults to
false
Returns
Function
-
Returns a function which checks whether the node can be a container or a sibling of the selection end.
This includes:
- text nodes (but not whitespaces),
- inline elements,
- intersection of CKEDITOR.dtd.$empty and CKEDITOR.dtd.$block (currently
it is only
<hr>), - non-editable blocks (special case — such blocks cannot be containers nor siblings, they need to be selected entirely),
- empty blocks which can contain text (old IEs only).
Parameters
[ isReject ] : BooleanWhether to return
falsefor the ignored element instead oftrue(default).Defaults to
false
Returns
Function
-
Returns a function which checks whether the node is empty.
Parameters
[ isReject ] : BooleanWhether to return
falsefor the ignored element instead oftrue(default).Defaults to
false
Returns
Function
-
Returns a function which checks whether the node should be ignored in terms of "editability".
This includes:
- whitespaces (see whitespaces),
- bookmarks (see bookmark),
- temporary elements (see temp).
Parameters
[ isReject ] : BooleanWhether to return
falsefor the ignored element instead oftrue(default).Defaults to
false
Returns
Function
-
Returns a function which checks whether the node is invisible in the WYSIWYG mode.
Parameters
[ isReject ] : Boolean-
Defaults to
false
Returns
Function
-
Returns a function which checks whether the node type is equal to the passed one.
Parameters
type : Number[ isReject ] : Boolean-
Defaults to
false
Returns
Function
-
Returns a function which checks whether the node is a temporary element (element with the
data-cke-tempattribute) or its child.Parameters
[ isReject ] : BooleanWhether to return
falsefor the temporary element instead oftrue(default).Defaults to
false
Returns
Function
-
Returns a function which checks whether the node is a text node containing only whitespace characters.
Parameters
[ isReject ] : Boolean-
Defaults to
false
Returns
Function