Report an issue
Class

CKEDITOR.dom.walker

class

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

    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

    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.

  • private

    _ : Object

    Defaults to {}

Static properties

Methods

  • constructor( range ) → walker

    Creates a walker class instance.

    Parameters

    range : range

    The range within which to walk.

    Returns

    walker
  • checkBackward() → Boolean

    Check all nodes on the left, executing the evaluation function.

    Returns

    Boolean

    false if the evaluator function returned false for any of the matched nodes. Otherwise true.

  • checkForward() → Boolean

    Checks all nodes on the right, executing the evaluation function.

    Returns

    Boolean

    false if the evaluator function returned false for any of the matched nodes. Otherwise true.

  • end()

    Stops walking. No more nodes are retrieved if this function is called.

  • lastBackward() → node

    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

    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

    Retrieves the next node (on the right).

    Returns

    node

    The next node or null if no more nodes are available.

  • previous() → node

    Retrieves the previous node (on the left).

    Returns

    node

    The previous node or null if no more nodes are available.

  • reset()

    Resets the walker.

Static methods

  • static

    blockBoundary( customNodeNames ) → Function

    Returns a function which checks whether the node is a block boundary. See CKEDITOR.dom.element.isBlockBoundary.

    Parameters

    customNodeNames : Object

    Returns

    Function
  • static

    bogus( [ isReject ] ) → 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
  • static

    bookmark( [ contentOnly ], [ isReject ] ) → 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 of true (default).

    Defaults to false

    Returns

    Function
  • since 4.3.0 static

    editable( [ isReject ] ) → 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 of true (default).

    Defaults to false

    Returns

    Function
  • since 4.5.0 static

    empty( [ isReject ] ) → Function

    Returns a function which checks whether the node is empty.

    Parameters

    [ isReject ] : Boolean

    Whether to return false for the ignored element instead of true (default).

    Defaults to false

    Returns

    Function
  • since 4.3.0 static

    ignored( [ isReject ] ) → Function

    Returns a function which checks whether the node should be ignored in terms of "editability".

    This includes:

    Parameters

    [ isReject ] : Boolean

    Whether to return false for the ignored element instead of true (default).

    Defaults to false

    Returns

    Function
  • static

    invisible( [ isReject ] ) → Function

    Returns a function which checks whether the node is invisible in the WYSIWYG mode.

    Parameters

    [ isReject ] : Boolean

    Defaults to false

    Returns

    Function
  • static

    listItemBoundary()

  • static

    nodeType( type, [ isReject ] ) → 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
  • since 4.3.0 static

    temp( [ isReject ] ) → 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 of true (default).

    Defaults to false

    Returns

    Function
  • static

    whitespaces( [ isReject ] ) → 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