Report an issue
Class

HighlightStack (widget)

@ckeditor/ckeditor5-widget/src/highlightstack

class

Class used to handle correct order of highlights on elements.

When different highlights are applied to same element correct order should be preserved:

  • highlight with highest priority should be applied,
  • if two highlights have same priority - sort by CSS class provided in HighlightDescriptor.

This way, highlight will be applied with the same rules it is applied on texts.

Filtering

Methods

  • constructor()

    Creates class instance.

  • add( descriptor, writer )

    Adds highlight descriptor to the stack.

    Parameters

    descriptor : HighlightDescriptor
    writer : Writer

    Fires

  • remove( id, writer )

    Removes highlight descriptor from the stack.

    Parameters

    id : String

    Id of the descriptor to remove.

    writer : Writer

    Fires

  • _insertDescriptor( descriptor )

    private

    Inserts given descriptor in correct place in the stack. It also takes care about updating information when descriptor with same id is already present.

    Parameters

    descriptor : HighlightDescriptor
  • _removeDescriptor( id )

    private

    Removes descriptor with given id from the stack.

    Parameters

    id : String

    Descriptor's id.

Events

  • change:top( eventInfo, data = { [data.newDescriptor], [data.oldDescriptor] }, writer )

    Fired when top element on HighlightStack has been changed

    Parameters

    eventInfo : EventInfo

    An object containing information about the fired event.

    data : Object

    Additional information about the change.

    Properties
    [ data.newDescriptor ] : HighlightDescriptor

    New highlight descriptor. It will be undefined when last descriptor is removed from the stack.

    [ data.oldDescriptor ] : HighlightDescriptor

    Old highlight descriptor. It will be undefined when first descriptor is added to the stack.

    writer : Writer

    View writer that can be used to modify element.