Module

typing/utils/inlinehighlight

@ckeditor/ckeditor5-typing/src/utils/inlinehighlight

module

Filtering

Functions

  • inlineHighlight( editor, attributeName, tagName, className )

    Adds a visual highlight style to an attribute element in which the selection is anchored. Together with two-step caret movement, they indicate that the user is typing inside the element.

    Highlight is turned on by adding the given class to the attribute element in the view:

    • The class is removed before the conversion has started, as callbacks added with the 'highest' priority to DowncastDispatcher events.
    • The class is added in the view post fixer, after other changes in the model tree were converted to the view.

    This way, adding and removing the highlight does not interfere with conversion.

    Usage:

    import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
    
    // Make `ck-link_selected` class be applied on an `a` element
    // whenever the corresponding `linkHref` attribute element is selected.
    inlineHighlight( editor, 'linkHref', 'a', 'ck-link_selected' );

    Parameters

    editor : Editor

    The editor instance.

    attributeName : String

    The attribute name to check.

    tagName : String

    The tagName of a view item.

    className : String

    The class name to apply in the view.