Class

TokenList (engine/view)

@ckeditor/ckeditor5-engine/src/view/tokenlist

class

Token list. Allows handling (adding, removing, retrieving) a set of tokens (for example class names).

Filtering

Properties

  • readonly

    isEmpty : boolean

    Returns true if token list has no tokens set.

  • readonly

    size : number

    Number of tokens.

  • private

    _set : Set<string>

    The set of tokens.

Methods

  • clear() → void

    Removes all tokens.

    Returns

    void
  • has( name ) → boolean

    Checks if a given token is set.

    Parameters

    name : string

    Returns

    boolean
  • isSimilar( other ) → boolean

    Returns true if both attributes have the same tokens.

    Parameters

    other : TokenList

    Returns

    boolean
  • keys() → Array<string>

    Returns all tokens.

    Returns

    Array<string>
  • remove( tokens ) → void

    Removes given token.

    Parameters

    tokens : ArrayOrItem<string>

    Returns

    void
  • set( tokens ) → void

    Sets a given token without affecting other tokens.

    Parameters

    tokens : ArrayOrItem<string>

    Returns

    void
  • setTo( value ) → TokenList

    Resets the value to the given one.

    Parameters

    value : string

    Returns

    TokenList
  • toString() → string

    Returns a normalized tokens string.

    Returns

    string
  • internal

    _canMergeFrom() → boolean

    Used by _canMergeAttributesFrom to verify if the given attribute can be merged without conflicts into the attribute.

    This method is indirectly used by the DowncastWriter while downcasting an AttributeElement to merge it with other AttributeElement.

    Returns

    boolean
  • internal

    _clone() → TokenList

    Clones the attribute value.

    Returns

    TokenList
  • internal

    _getConsumables( [ name ] ) → Array<string>

    Returns a list of consumables for the attribute.

    Could be filtered by the given token name.

    Parameters

    [ name ] : string

    Returns

    Array<string>
  • internal

    _getTokensMatch( tokenPattern ) → undefined | Array<string>

    Used by the Matcher to collect matching attribute tokens.

    Parameters

    tokenPattern : string | true | RegExp

    The matched token name pattern.

    Returns

    undefined | Array<string>

    An array of matching tokens.

  • internal

    _isMatching( other ) → boolean

    Used by _canSubtractAttributesOf to verify if the given attribute can be fully subtracted from the attribute.

    This method is indirectly used by the DowncastWriter while down-casting an AttributeElement to unwrap the AttributeElement.

    Parameters

    other : TokenList

    Returns

    boolean
  • internal

    _mergeFrom( other ) → void

    Used by _mergeAttributesFrom to merge a given attribute into the attribute.

    This method is indirectly used by the DowncastWriter while down-casting an AttributeElement to merge it with other AttributeElement.

    Parameters

    other : TokenList

    Returns

    void