Report an issue
Class

TextWatcher (typing)

@ckeditor/ckeditor5-typing/src/textwatcher

class private

The text watcher feature.

Fires the matched:data, matched:selection and unmatched events on typing or selection changes.

Filtering

Methods

  • constructor( model, testCallback )

    Creates a text watcher instance.

    Parameters

    model : Model
    testCallback : function

    The function used to match the text.

  • _evaluateTextBeforeSelection( suffix )

    private

    Checks the editor content for matched text.

    Parameters

    suffix : 'data' | 'selection'

    A suffix used for generating the event name.

    Fires

  • _getText() → String | undefined

    private

    Returns the text before the caret from the current selection block.

    Returns

    String | undefined

    The text from the block or undefined if the selection is not collapsed.

  • _startListening()

    private

    Starts listening to the editor for typing and selection events.

Events

  • matched:data( eventInfo )

    Fired whenever the text watcher found a match for data changes.

    Parameters

    eventInfo : EventInfo

    An object containing information about the fired event.

  • matched:selection( eventInfo )

    Fired whenever the text watcher found a match for selection changes.

    Parameters

    eventInfo : EventInfo

    An object containing information about the fired event.

  • unmatched( eventInfo )

    Fired whenever the text does not match anymore. Fired only when the text watcher found a match.

    Parameters

    eventInfo : EventInfo

    An object containing information about the fired event.