Trilium Frontend API
    Preparing search index...

    Class TextAbstract

    The data structure for documents.

    Implements

    Index

    Constructors

    Properties

    "[iterator]": () => Iterator<string>
    children: readonly Text[]

    If this is a branch node, children will hold the Text objects that it is made up of. For leaf nodes, this holds null.

    length: number

    The length of the string.

    lines: number

    The number of lines in the string (always >= 1).

    empty: Text

    The empty document.

    Methods

    • Append another document to this one.

      Parameters

      Returns Text

    • Test whether this text is equal to another instance.

      Parameters

      Returns boolean

    • Iterate over the text. When dir is -1, iteration happens from end to start. This will return lines and the breaks between them as separate strings.

      Parameters

      • Optionaldir: -1 | 1

      Returns TextIterator

    • Return a cursor that iterates over the given range of lines, without returning the line breaks between, and yielding empty strings for empty lines.

      When from and to are given, they should be 1-based line numbers.

      Parameters

      • Optionalfrom: number
      • Optionalto: number

      Returns TextIterator

    • Iterate over a range of the text. When from > to, the iterator will run in reverse.

      Parameters

      • from: number
      • Optionalto: number

      Returns TextIterator

    • Get the description for the given (1-based) line number.

      Parameters

      • n: number

      Returns Line

    • Get the line description around the given position.

      Parameters

      • pos: number

      Returns Line

    • Replace a range of the text with the given content.

      Parameters

      • from: number
      • to: number
      • text: Text

      Returns Text

    • Retrieve the text between the given points.

      Parameters

      • from: number
      • Optionalto: number

      Returns Text

    • Retrieve a part of the document as a string

      Parameters

      • from: number
      • Optionalto: number
      • OptionallineSep: string

      Returns string

    • Convert the document to an array of lines (which can be deserialized again via Text.of).

      Returns string[]

    • Return the document as a string, using newline characters to separate lines.

      Returns string

    • Create a Text instance for the given array of lines.

      Parameters

      • text: readonly string[]

      Returns Text