Trilium Frontend API
    Preparing search index...

    Class NodeProp<T>

    Each node type or individual tree can have metadata associated with it in props. Instances of this class represent prop names.

    Type Parameters

    • T
    Index

    Constructors

    • Create a new node prop type.

      Type Parameters

      • T

      Parameters

      • Optionalconfig: {
            combine?: (a: T, b: T) => T;
            deserialize?: (str: string) => T;
            perNode?: boolean;
        }
        • Optionalcombine?: (a: T, b: T) => T

          If configuring another value for this prop when it already exists on a node should combine the old and new values, rather than overwrite the old value, you can pass a function that does the combining here.

        • Optionaldeserialize?: (str: string) => T

          The deserialize function to use for this prop, used for example when directly providing the prop from a grammar file. Defaults to a function that raises an error.

        • OptionalperNode?: boolean

          By default, node props are stored in the node type. It can sometimes be useful to directly store information (usually related to the parsing algorithm) in nodes themselves. Set this to true to enable that for this prop.

      Returns NodeProp<T>

    Properties

    deserialize: (str: string) => T

    A method that deserializes a value of this prop from a string. Can be used to allow a prop to be directly written in a grammar file.

    perNode: boolean

    Indicates whether this prop is stored per node type or per tree node.

    closedBy: NodeProp<readonly string[]>

    Prop that is used to describe matching delimiters. For opening delimiters, this holds an array of node names (written as a space-separated string when declaring this prop in a grammar) for the node types of closing delimiters that match it.

    contextHash: NodeProp<number>

    The hash of the context that the node was parsed in, if any. Used to limit reuse of contextual nodes.

    group: NodeProp<readonly string[]>

    Used to assign node types to groups (for example, all node types that represent an expression could be tagged with an "Expression" group).

    isolate: NodeProp<"auto" | "rtl" | "ltr">

    Attached to nodes to indicate these should be displayed in a bidirectional text isolate, so that direction-neutral characters on their sides don't incorrectly get associated with surrounding text. You'll generally want to set this for nodes that contain arbitrary text, like strings and comments, and for nodes that appear inside arbitrary text, like HTML tags. When not given a value, in a grammar declaration, defaults to "auto".

    lookAhead: NodeProp<number>

    The distance beyond the end of the node that the tokenizer looked ahead for any of the tokens inside the node. (The LR parser only stores this when it is larger than 25, for efficiency reasons.)

    This per-node prop is used to replace a given node, or part of a node, with another tree. This is useful to include trees from different languages in mixed-language parsers.

    openedBy: NodeProp<readonly string[]>

    The inverse of closedBy. This is attached to closing delimiters, holding an array of node names of types of matching opening delimiters.

    Methods

    • This is meant to be used with NodeSet.extend or LRParser.configure to compute prop values for each node type in the set. Takes a match object or function that returns undefined if the node type doesn't get this prop, and the prop's value if it does.

      Parameters

      • match: { [selector: string]: T } | ((type: NodeType) => T)

      Returns NodePropSource