Documentation - v1.5.3
    Preparing search index...

    Class representing the TokenManager.

    This class manages tokens and token blocks, allowing for operations such as adding, removing, and updating blocks.

    Index

    Constructors

    Properties

    edited: number = 0

    A counter for the number of edits made to the tokens.

    labelManager: LabelManager

    The label manager associated with the TokenManager.

    tokens: TMTokens[]

    An array of tokens or token blocks managed by the TokenManager.

    Accessors

    Methods

    • Adds a block from an Entity or TMTokenBlock structure.

      Parameters

      Returns void

      This method adds a new block to the TokenManager from an Entity or TMTokenBlock structure.

    • Adds a new block of tokens to the TokenManager.

      Parameters

      • start: number

        The start index of the new block.

      • end: number

        The end index of the new block.

      • labelClass: undefined | Label

        The label class for the new block, can be undefined.

      • currentState: string

        The current state of the new block.

      • Optionalhistory: History[] = []

        An optional array of history entries for the new block.

      Returns void

      This method adds a new block of tokens, handling overlapping blocks and updating the tokens array accordingly.

    • Gets all blocks in the specified range.

      Parameters

      • start: number

        The start index of the range.

      • end: number

        The end index of the range.

      Returns TMTokens[]

      • An array of TMTokens that overlap with the specified range.

      This method retrieves all blocks that overlap with the specified start and end indices.

    • Gets a block by its start index.

      Parameters

      • start: number

        The start index of the block to retrieve.

      Returns null | TMTokenBlock

      • The block if found, otherwise null

      This method retrieves a block from the tokens array by its start index.

    • Checks if there are any overlapping blocks in the specified range.

      Parameters

      • start: number

        The start index of the range.

      • end: number

        The end index of the range.

      Returns null | TMTokens[]

      • An array of overlapping blocks if found, otherwise null.

      This method checks if there are any blocks that overlap with the specified start and end indices.

    • Removes a block of tokens by its start index.

      Parameters

      • start: number

        The start index of the block to remove.

      • OptionalreintroduceTokens: boolean = true

        Whether to reintroduce the tokens from the removed block back into the tokens array.

      Returns void

      This method removes a block of tokens from the TokenManager by its start index.

    • Removes duplicate blocks from the tokens array.

      Returns void

      This method removes duplicate blocks from the tokens array, ensuring that each block is unique.

    • Restores the original state of a block by its start index.

      Parameters

      • start: number

        The start index of the block to restore.

      Returns void

      This method restores the original state of a block by its start index, resetting its properties to their original values.