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 : Function
CKEDITOR.dom.walker#evaluator
A 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 : Function
CKEDITOR.dom.walker#guard
A 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 ) → walker
CKEDITOR.dom.walker#constructor
Creates a walker class instance.
Parameters
range : range
The range within which to walk.
Returns
walker
-
checkBackward() → Boolean
CKEDITOR.dom.walker#checkBackward
Check all nodes on the left, executing the evaluation function.
Returns
Boolean
false
if the evaluator function returnedfalse
for any of the matched nodes. Otherwisetrue
.
-
checkForward() → Boolean
CKEDITOR.dom.walker#checkForward
Checks all nodes on the right, executing the evaluation function.
Returns
Boolean
false
if the evaluator function returnedfalse
for any of the matched nodes. Otherwisetrue
.
-
end()
CKEDITOR.dom.walker#end
Stops walking. No more nodes are retrieved if this function is called.
-
lastBackward() → node
CKEDITOR.dom.walker#lastBackward
Executes a full walk backwards (to the left), until no more nodes are available, returning the last valid node.
Returns
node
The last node on the left or
null
if no valid nodes are available.
-
lastForward() → node
CKEDITOR.dom.walker#lastForward
Executes a full walk forward (to the right), until no more nodes are available, returning the last valid node.
Returns
node
The last node on the right or
null
if no valid nodes are available.
-
next() → node
CKEDITOR.dom.walker#next
Retrieves the next node (on the right).
Returns
node
The next node or
null
if no more nodes are available.
-
previous() → node
CKEDITOR.dom.walker#previous
Retrieves the previous node (on the left).
Returns
node
The previous node or
null
if no more nodes are available.
-
reset()
CKEDITOR.dom.walker#reset
Resets 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
contenteditable
element'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 ] : Boolean
Whether only test against the text content of a bookmark node instead of the element itself (default).
Defaults to
false
[ isReject ] : Boolean
Whether to return
false
for 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 ] : Boolean
Whether to return
false
for the ignored element instead oftrue
(default).Defaults to
false
Returns
Function
-
Returns a function which checks whether the node is empty.
Parameters
[ isReject ] : Boolean
Whether to return
false
for 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 ] : Boolean
Whether to return
false
for 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-temp
attribute) or its child.Parameters
[ isReject ] : Boolean
Whether to return
false
for 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