json-joy
    Preparing search index...

    Class StrApi

    Local changes API for the str JSON CRDT node StrNode. This API allows to insert and delete bytes in the UTF-16 string by referencing its local character positions.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    api: ModelApi<any>
    node: StrNode

    Accessors

    • get events(): NodeEvents<N>

      Event target for listening to node changes. You can subscribe to "view" events, which are triggered every time the node's view changes.

      node.events.on('view', () => {
      // do something...
      });

      Returns NodeEvents<N>

    Methods

    • Returns the API object of the extension if the node is an extension node. When the ext parameter is provided, it checks if the node is an instance of the given extension and returns the object's TypeScript type. Otherwise, it returns the API object of the extension, but without any type checking.

      Returns undefined | ExtApi<any>

      API of the extension

    • Returns the API object of the extension if the node is an extension node. When the ext parameter is provided, it checks if the node is an instance of the given extension and returns the object's TypeScript type. Otherwise, it returns the API object of the extension, but without any type checking.

      Type Parameters

      • EN extends ExtNode<any, any>
      • EApi extends ExtApi<EN>

      Parameters

      • ext: Extension<any, any, EN, EApi, any, any>

        Extension of the node

      Returns EApi

      API of the extension

    • Deletes a range of text at a given position.

      Parameters

      • index: number

        Position at which to delete text.

      • length: number

        Number of UTF-16 code units to delete.

      Returns void

      Reference to itself.

    • Given a character index in local coordinates, find the ID of the character in the global coordinates.

      Parameters

      • index: number

        Index of the character or -1 for before the first character.

      Returns ITimestampStruct

      ID of the character after which the given position is located.

    • Given a position in global coordinates, find the position in local coordinates.

      Parameters

      Returns number

      Index of the character in local coordinates. Returns -1 if the the position refers to the beginning of the string.

    • Find a child node at the given path starting from this node and wrap it in a local changes API.

      Parameters

      • Optionalpath: ApiPath

        Path to the child node to find.

      Returns ValApi<ValNode<any>>

      Local changes API for the child node at the given path.

    • Inserts text at a given position.

      Parameters

      • index: number

        Position at which to insert text.

      • text: string

        Text to insert.

      Returns void

      Reference to itself.