Module

find-and-replace/utils

@ckeditor/ckeditor5-find-and-replace/src/utils

module

Filtering

Functions

  • findByTextCallback( searchTerm, [ options ] = { [options.matchCase], [options.wholeWords] } ) → function

    Creates a text matching callback for a specified search term and matching options.

    Parameters

    searchTerm : String

    The search term.

    [ options ] : Object

    Matching options.

    Properties
    [ options.matchCase ] : Boolean

    If set to true letter casing will be ignored.

    Defaults to false

    [ options.wholeWords ] : Boolean

    If set to true only whole words that match callbackOrText will be matched.

    Defaults to false

    Returns

    function
  • rangeToText( range ) → String

    Returns text representation of a range. The returned text length should be the same as range length. In order to achieve this this function will replace inline elements (text-line) as new line character ("\n").

    Parameters

    range : Range

    The model range.

    Returns

    String

    The text content of the provided range.

  • updateFindResultFromRange( range, model, findCallback, [ startResults ] ) → Collection

    Executes findCallback and updates search results list.

    Parameters

    range : Range

    The model range to scan for matches.

    model : Model

    The model.

    findCallback : function

    The callback that should return true if provided text matches the search term.

    [ startResults ] : Collection

    An optional collection of find matches that the function should start with. This would be a collection returned by a previous updateFindResultFromRange() call.

    Returns

    Collection

    A collection of objects describing find match.

    An example structure:

    {
    	id: resultId,
    	label: foundItem.label,
    	marker
    	}