Trilium Frontend API
    Preparing search index...

    Class NodeType

    Each node in a syntax tree has a node type associated with it.

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    id: number

    The id of this node in its set. Corresponds to the term ids used in the parser.

    name: string

    The name of the node type. Not necessarily unique, but if the grammar was written properly, different node types with the same name within a node set should play the same semantic role.

    none: NodeType

    An empty dummy node type to use when no actual type is available.

    Accessors

    • get isAnonymous(): boolean

      When true, this node type doesn't correspond to a user-declared named node, for example because it is used to cache repetition.

      Returns boolean

    • get isError(): boolean

      Indicates whether this is an error node.

      Returns boolean

    • get isSkipped(): boolean

      True when this node is produced by a skip rule.

      Returns boolean

    • get isTop(): boolean

      True when this is the top node of a grammar.

      Returns boolean

    Methods

    • Returns true when this node's name or one of its groups matches the given string.

      Parameters

      • name: string | number

      Returns boolean

    • Retrieves a node prop for this type. Will return undefined if the prop isn't present on this node.

      Type Parameters

      • T

      Parameters

      Returns T

    • Define a node type.

      Parameters

      • spec: {
            error?: boolean;
            id: number;
            name?: string;
            props?: readonly ([NodeProp<any>, any] | NodePropSource)[];
            skipped?: boolean;
            top?: boolean;
        }
        • Optionalerror?: boolean

          Whether this node counts as an error node.

        • id: number

          The ID of the node type. When this type is used in a set, the ID must correspond to its index in the type array.

        • Optionalname?: string

          The name of the node type. Leave empty to define an anonymous node.

        • Optionalprops?: readonly ([NodeProp<any>, any] | NodePropSource)[]

          Node props to assign to the type. The value given for any given prop should correspond to the prop's type.

        • Optionalskipped?: boolean

          Whether this node is a skipped node.

        • Optionaltop?: boolean

          Whether this is a top node.

      Returns NodeType

    • Create a function from node types to arbitrary values by specifying an object whose property names are node or group names. Often useful with NodeProp.add. You can put multiple names, separated by spaces, in a single property name to map multiple node names to a single value.

      Type Parameters

      • T

      Parameters

      • map: { [selector: string]: T }

      Returns (node: NodeType) => T