Trilium Frontend API
    Preparing search index...

    Type Alias StateFieldSpec<Value>

    type StateFieldSpec<Value> = {
        compare?: (a: Value, b: Value) => boolean;
        create: (state: EditorState) => Value;
        fromJSON?: (json: any, state: EditorState) => Value;
        provide?: (field: StateField<Value>) => Extension;
        toJSON?: (value: Value, state: EditorState) => any;
        update: (value: Value, transaction: Transaction) => Value;
    }

    Type Parameters

    • Value
    Index

    Properties

    compare?: (a: Value, b: Value) => boolean

    Compare two values of the field, returning true when they are the same. This is used to avoid recomputing facets that depend on the field when its value did not change. Defaults to using ===.

    create: (state: EditorState) => Value

    Creates the initial value for the field when a state is created.

    fromJSON?: (json: any, state: EditorState) => Value

    A function that deserializes the JSON representation of this field's content.

    provide?: (field: StateField<Value>) => Extension

    Provide extensions based on this field. The given function will be called once with the initialized field. It will usually want to call some facet's from method to create facet inputs from this field, but can also return other extensions that should be enabled when the field is present in a configuration.

    toJSON?: (value: Value, state: EditorState) => any

    A function used to serialize this field's content to JSON. Only necessary when this field is included in the argument to EditorState.toJSON.

    update: (value: Value, transaction: Transaction) => Value

    Compute a new value from the field's previous value and a transaction.