Trilium Frontend API
    Preparing search index...

    Class NoteContext

    Abstract class for all components in the Trilium's frontend.

    Contains also event implementation with following properties:

    • event / command distribution is synchronous which among others mean that events are well-ordered - event which was sent out first will also be processed first by the component
    • execution of the event / command is asynchronous - each component executes the event on its own without regard for other components.
    • although the execution is async, we are collecting all the promises, and therefore it is possible to wait until the event / command is executed in all components - by simply awaiting the triggerEvent().

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    • Parameters

      • OptionalntxId: string
      • OptionalhoistedNoteId: string
      • OptionalmainNtxId: string

      Returns NoteContext

    Properties

    _position: number
    $widget: any
    children: default[]
    componentId: string
    hoistedNoteId: string
    initialized: Promise<void>
    lastActiveNtxId?: string

    ntxId of the split most recently focused within this tab; re-activating the tab restores it. Only meaningful on a main context.

    mainNtxId: string
    noteId?: string
    notePath?: string
    ntxId: string
    parent?: TypedComponent<any>
    parentNoteId?: string
    pinned: boolean

    When true, this tab stays on its current note: navigations to a different note open a new tab instead. Only meaningful on a main context.

    viewScope?: ViewScope

    Accessors

    • get note(): FNote

      Returns FNote

    • get notePathArray(): string[]

      Returns string[]

    • get position(): number

      Returns number

    • set position(newPosition: number): void

      Parameters

      • newPosition: number

      Returns void

    • get sanitizedClassName(): string

      Returns string

    Methods

    • Parameters

      • fun: (arg: unknown) => Promise<unknown>
      • data: unknown

      Returns Promise<unknown>

    • Parameters

      Returns this

    • Clear specific context data.

      Parameters

      Returns void

    • Parameters

      • __namedParameters: { loadResults: default }

      Returns Promise<void>

    • Returns Promise<default>

    • Returns a promise which will retrieve the JQuery element of the content of this note context.

      Do note that retrieving the content element needs to be handled by the type widget, which is the one which provides the content element by listening to the executeWithContentElement event. Not all note types support this.

      If no content could be determined null is returned instead.

      Returns Promise<any>

    • See docs for isMainContext() for better explanation.

      Returns NoteContext

    • Returns Promise<string>

    • Returns {
          active: boolean;
          hoistedNoteId: string;
          lastActiveNtxId: string;
          mainNtxId: string;
          notePath: string;
          ntxId: string;
          pinned: boolean;
          viewScope: ViewScope;
      }

    • Parameters

      • inputNotePath: string

      Returns Promise<string>

    • Returns NoteContext[]

    • Check if context data exists for a given key.

      Parameters

      Returns boolean

    • Returns boolean

    • Returns boolean

    • Returns boolean

    • A main context represents a tab and also the first split. Further splits are the children contexts of the main context. Imagine you have a tab with 3 splits, each showing notes A, B, C (in this order). In such a scenario, A context is the main context (also representing the tab as a whole), and B, C are the children of context A.

      Returns boolean

      true if the context is main (= tab)

    • Returns Promise<boolean>

    • Removes a child component from this component's children array. This is used for cleanup when a widget is unmounted to prevent event listener accumulation.

      Parameters

      Returns void

    • Returns void

    • Parameters

      • resolvedNotePath: string

      Returns void

    • Set metadata for this note context (e.g., table of contents, PDF pages, code outline). This data can be consumed by sidebar/toolbar components.

      Type Parameters

      Parameters

      • key: K

        Unique identifier for the data type (e.g., "toc", "pdfPages", "codeOutline")

      • value: NoteContextDataMap[K]

        The data to store (will be cleared when switching notes)

      Returns void

    • Returns void

    • Parameters

      • noteIdToHoist: string

      Returns Promise<void>

    • Returns Promise<void>

    • Parameters

      Returns Promise<NoteContext>

      the note context that ended up showing the note: usually this, or a new tab when a pinned tab redirected the navigation. undefined if nothing was navigated.

    • Type Parameters

      • T

      Parameters

      • promise: Promise<T>

      Returns Promise<T>

    • Returns Promise<void>

    • Returns string