Trilium Frontend API
    Preparing search index...

    Class EditorSelection

    An editor selection holds one or more selection ranges.

    Index

    Properties

    mainIndex: number

    The index of the main range in the selection (which is usually the range that was added last).

    ranges: readonly SelectionRange[]

    The ranges in the selection, sorted by position. Ranges cannot overlap (but they may touch, if they aren't empty).

    Accessors

    • get main(): SelectionRange

      Get the primary selection range. Usually, you should make sure your code applies to all ranges, by using methods like changeByRange.

      Returns SelectionRange

    Methods

    • Make sure the selection only has one range. Returns a selection holding only the main range from this selection.

      Returns EditorSelection

    • Compare this selection to another selection. By default, ranges are compared only by position. When includeAssoc is true, cursor ranges must also have the same assoc value.

      Parameters

      Returns boolean

    • Map a selection through a change. Used to adjust the selection position for changes.

      Parameters

      Returns EditorSelection

    • Replace a given range with another range, and then normalize the selection to merge and sort ranges if necessary.

      Parameters

      Returns EditorSelection

    • Convert this selection to an object that can be serialized to JSON.

      Returns any

    • Sort and merge the given set of ranges, creating a valid selection.

      Parameters

      Returns EditorSelection

    • Create a cursor selection range at the given position. You can safely ignore the optional arguments in most situations.

      Parameters

      • pos: number
      • Optionalassoc: number
      • OptionalbidiLevel: number
      • OptionalgoalColumn: number

      Returns SelectionRange

    • Create a selection from a JSON representation.

      Parameters

      • json: any

      Returns EditorSelection

    • Create a selection range.

      Parameters

      • anchor: number
      • head: number
      • OptionalgoalColumn: number
      • OptionalbidiLevel: number
      • Optionalassoc: number

      Returns SelectionRange

    • Create a selection holding a single range.

      Parameters

      • anchor: number
      • Optionalhead: number

      Returns EditorSelection