Trilium Frontend API
    Preparing search index...

    Class Facet<Input, Output>

    A facet is a labeled value that is associated with an editor state. It takes inputs from any number of extensions, and combines those into a single output value.

    Examples of uses of facets are the tab size, editor attributes, and update listeners.

    Note that Facet instances can be used anywhere where FacetReader is expected.

    Type Parameters

    • Input
    • Output = readonly Input[]

    Implements

    Index

    Properties

    Accessors

    Methods

    Properties

    tag: Output

    Dummy tag that makes sure TypeScript doesn't consider all object types as conforming to this type. Not actually present on the object.

    Accessors

    • get reader(): FacetReader<Output>

      Returns a facet reader for this facet, which can be used to read it but not to define values for it.

      Returns FacetReader<Output>

    Methods

    • Create an extension that computes a value for the facet from a state. You must take care to declare the parts of the state that this value depends on, since your function is only called again for a new state when one of those parts changed.

      In cases where your value depends only on a single field, you'll want to use the from method instead.

      Parameters

      Returns Extension

    • Create an extension that computes zero or more values for this facet from a state.

      Parameters

      Returns Extension

    • Shorthand method for registering a facet source with a state field as input. If the field's type corresponds to this facet's input type, the getter function can be omitted. If given, it will be used to retrieve the input from the field value.

      Type Parameters

      • T

      Parameters

      Returns Extension

    • Shorthand method for registering a facet source with a state field as input. If the field's type corresponds to this facet's input type, the getter function can be omitted. If given, it will be used to retrieve the input from the field value.

      Type Parameters

      • T

      Parameters

      Returns Extension

    • Returns an extension that adds the given value to this facet.

      Parameters

      Returns Extension