trilium
    Preparing search index...

    A FancytreeNode represents the hierarchical data model and operations.

    interface FancytreeNode {
        children: FancytreeNode[];
        data: any;
        expanded: boolean;
        extraClasses: string;
        folder: boolean;
        icon: string;
        key: string;
        lazy: boolean;
        parent: FancytreeNode;
        span: HTMLElement;
        statusNodeType: string;
        title: string;
        tooltip: string;
        tr: HTMLTableRowElement;
        tree: Fancytree;
        unselectable?: boolean;
        unselectableIgnore?: boolean;
        unselectableStatus?: boolean;
        addChildren(
            children: NodeData[],
            insertBefore?: FancytreeNode,
        ): FancytreeNode;
        addChildren(children: NodeData[], insertBefore?: string): FancytreeNode;
        addChildren(children: NodeData[], insertBefore?: number): FancytreeNode;
        addChildren(child: NodeData, insertBefore?: FancytreeNode): FancytreeNode;
        addChildren(child: NodeData, insertBefore?: string): FancytreeNode;
        addChildren(child: NodeData, insertBefore?: number): FancytreeNode;
        addClass(className: string): void;
        addNode(node: NodeData, mode?: string): FancytreeNode;
        applyPatch(patch: NodePatch): JQueryPromise<any>;
        collapseSiblings(): JQueryPromise<any>;
        copyTo(
            node: FancytreeNode,
            mode?: string,
            map?: (node: NodeData) => void,
        ): FancytreeNode;
        countChildren(deep?: boolean): number;
        debug(msg: any): void;
        editCreateNode(mode?: string, init?: Object): void;
        editEnd(applyChanges: boolean): void;
        editStart(): void;
        findAll(match: string): FancytreeNode[];
        findAll(match: (node: FancytreeNode) => boolean): FancytreeNode[];
        findFirst(match: string): FancytreeNode;
        findFirst(match: (node: FancytreeNode) => boolean): FancytreeNode;
        fixSelection3AfterClick(): void;
        fixSelection3FromEndNodes(): void;
        fromDict(dict: NodeData): void;
        getChildren(): FancytreeNode[];
        getCloneList(includeSelf?: boolean): FancytreeNode[];
        getFirstChild(): FancytreeNode;
        getIndex(): number;
        getIndexHier(): string;
        getKeyPath(excludeSelf: boolean): string;
        getLastChild(): FancytreeNode;
        getLevel(): number;
        getNextSibling(): FancytreeNode;
        getParent(): FancytreeNode;
        getParentList(includeRoot: boolean, includeSelf: boolean): FancytreeNode[];
        getPrevSibling(): FancytreeNode;
        hasChildren(): boolean;
        hasFocus(): boolean;
        info(msg: string): void;
        isActive(): boolean;
        isChildOf(otherNode: FancytreeNode): boolean;
        isClone(): boolean;
        isDescendantOf(otherNode: FancytreeNode): boolean;
        isEditing(): boolean;
        isExpanded(): boolean;
        isFirstSibling(): boolean;
        isFolder(): boolean;
        isLastSibling(): boolean;
        isLazy(): boolean;
        isLoaded(): boolean;
        isLoading(): boolean;
        isRootNode(): boolean;
        isSelected(): boolean;
        isStatusNode(): boolean;
        isTopLevel(): boolean;
        isUndefined(): boolean;
        isVisible(): boolean;
        load(forceReload?: boolean): JQueryPromise<any>;
        makeVisible(opts?: Object): JQueryPromise<any>;
        moveTo(
            targetNode: FancytreeNode,
            mode: string,
            map?: (node: FancytreeNode) => void,
        ): void;
        navigate(where: number, activate?: boolean): JQueryPromise<any>;
        remove(): void;
        removeChild(childNode: FancytreeNode): void;
        removeChildren(): void;
        removeClass(className: string): void;
        render(force?: boolean, deep?: boolean): void;
        renderStatus(): void;
        renderTitle(): void;
        reRegister(key: string, refKey: string): boolean;
        resetLazy(): void;
        scheduleAction(mode: string, ms: number): void;
        scrollIntoView(effects?: boolean, options?: Object): JQueryPromise<any>;
        scrollIntoView(effects?: Object, options?: Object): JQueryPromise<any>;
        setActive(flag?: boolean, opts?: Object): JQueryPromise<any>;
        setExpanded(flag?: boolean, opts?: Object): JQueryPromise<any>;
        setFocus(flag?: boolean): void;
        setSelected(flag?: boolean): void;
        setStatus(status: string, message?: string, details?: string): void;
        setTitle(title: string): void;
        sortChildren(
            cmp?: (a: FancytreeNode, b: FancytreeNode) => number,
            deep?: boolean,
        ): void;
        toDict(recursive?: boolean, callback?: (dict: NodeData) => void): NodeData;
        toggleClass(className: string, flag?: boolean): boolean;
        toggleExpanded(): void;
        toggleSelected(): void;
        visit(fn: (node: FancytreeNode) => any, includeSelf?: boolean): boolean;
        visitAndLoad(
            fn: (node: FancytreeNode) => any,
            includeSelf?: boolean,
        ): JQueryPromise<any>;
        visitParents(
            fn: (node: FancytreeNode) => any,
            includeSelf?: boolean,
        ): boolean;
        warn(msg: any): void;
    }
    Index

    Properties

    children: FancytreeNode[]

    Array of child nodes. For lazy nodes, null or undefined means 'not yet loaded'. Use an empty array to define a node that has no children.

    data: any

    Contains all extra data that was passed on node creation

    expanded: boolean

    Use isExpanded(), setExpanded() to access this property.

    extraClasses: string

    Addtional CSS classes, added to the node's <span>.

    folder: boolean

    Folder nodes have different default icons and click behavior. Note: Also non-folders may have children.

    icon: string

    Icon of the tree node.

    key: string

    Node id (must be unique inside the tree)

    lazy: boolean

    True if this node is loaded on demand, i.e. on first expansion.

    The parent node

    span: HTMLElement

    Outer element of single nodes

    statusNodeType: string

    null or type of temporarily generated system node like 'loading', or 'error'.

    title: string

    Display name (may contain HTML)

    tooltip: string

    Alternative description used as hover banner

    tr: HTMLTableRowElement

    Outer element of single nodes for table extension

    tree: Fancytree

    The tree instance

    unselectable?: boolean
    unselectableIgnore?: boolean
    unselectableStatus?: boolean

    Methods

    • Count direct and indirect children.

      Parameters

      • Optionaldeep: boolean

        pass 'false' to only count direct children. (default=true)

      Returns number

    • [ext-edit] Create a new child or sibling node and start edit mode.

      Parameters

      • Optionalmode: string

        'before', 'after', or 'child' (default='child')

      • Optionalinit: Object

        NodeData (or simple title string)

      Returns void

    • [ext-edit] Stop inline editing.

      Parameters

      • applyChanges: boolean

        false: cancel edit, true: save (if modified)

      Returns void

    • Fix selection status, after this node was (de)selected in multi-hier mode. This includes (de)selecting all children.

      Returns void

    • Fix selection status for multi-hier mode. Only end-nodes are considered to update the descendants branch and parents. Should be called after this node has loaded new children or after children have been modified using the API.

      Returns void

    • Return the parent keys separated by options.keyPathSeparator, e.g. "id_1/id_17/id_32".

      Parameters

      • excludeSelf: boolean

      Returns string

    • Return an array of all parent nodes (top-down).

      Parameters

      • includeRoot: boolean

        Include the invisible system root node. (default=false)

      • includeSelf: boolean

        Include the node itself (default=false).

      Returns FancytreeNode[]

    • Return true if this node is a temporarily generated system node like 'loading', or 'error' (node.statusNodeType contains the type).

      Returns boolean

    • Return true if all parent nodes are expanded. Note: this does not check whether the node is scrolled into the visible part of the screen.

      Returns boolean

    • Expand all parents and optionally scroll into visible area as neccessary. Promise is resolved, when lazy loading and animations are done.

      Parameters

      • Optionalopts: Object

        passed to setExpanded(). Defaults to {noAnimation: false, noEvents: false, scrollIntoView: true}

      Returns JQueryPromise<any>

    • Move this node to targetNode.

      Parameters

      • targetNode: FancytreeNode
      • mode: string

        'child': append this node as last child of targetNode. This is the default. To be compatble with the D'n'd hitMode, we also accept 'over'. 'before': add this node as sibling before targetNode. 'after': add this node as sibling after targetNode.

      • Optionalmap: (node: FancytreeNode) => void

        optional callback(FancytreeNode) to allow modifcations

      Returns void

    • Set focus relative to this node and optionally activate.

      Parameters

      • where: number

        The keyCode that would normally trigger this move, e.g. $.ui.keyCode.LEFT would collapse the node if it is expanded or move to the parent oterwise.

      • Optionalactivate: boolean

        (default=true)

      Returns JQueryPromise<any>

    • Remove all child nodes and descendents. This converts the node into a leaf. If this was a lazy node, it is still considered 'loaded'; call node.resetLazy() in order to trigger lazyLoad on next expand.

      Returns void

    • This method renders and updates all HTML markup that is required to display this node in its current state.

      Parameters

      • Optionalforce: boolean

        re-render, even if html markup was already created

      • Optionaldeep: boolean

        also render all descendants, even if parent is collapsed

      Returns void

    • [ext-clones] Update key and/or refKey for an existing node.

      Parameters

      • key: string
      • refKey: string

      Returns boolean

    • Schedule activity for delayed execution (cancel any pending request). scheduleAction('cancel') will only cancel a pending request (if any).

      Parameters

      • mode: string
      • ms: number

      Returns void

    • Mark a lazy node as 'error', 'loading', or 'ok'.

      Parameters

      • status: string

        'error', 'ok'

      • Optionalmessage: string
      • Optionaldetails: string

      Returns void

    • Convert node (or whole branch) into a plain object. The result is compatible with node.addChildren().

      Parameters

      • Optionalrecursive: boolean

        include child nodes.

      • Optionalcallback: (dict: NodeData) => void

        callback(dict) is called for every node, in order to allow modifications

      Returns NodeData

    • Set, clear, or toggle class of node's span tag and .extraClasses.

      Parameters

      • className: string

        class name (separate multiple classes by space)

      • Optionalflag: boolean

        true/false to add/remove class. If omitted, class is toggled.

      Returns boolean

      true if a class was added

    • Call fn(node) for all child nodes. Stop iteration, if fn() returns false. Skip current branch, if fn() returns "skip". Return false if iteration was stopped.

      Parameters

      • fn: (node: FancytreeNode) => any

        the callback function. Return false to stop iteration, return "skip" to skip this node and its children only.

      • OptionalincludeSelf: boolean

        (default=false)

      Returns boolean

    • Call fn(node) for all child nodes and recursively load lazy children. Note: If you need this method, you probably should consider to review your architecture! Recursivley loading nodes is a perfect way for lazy programmers to flood the server with requests ;-)

      Parameters

      • fn: (node: FancytreeNode) => any

        the callback function. Return false to stop iteration, return "skip" to skip this node and its children only.

      • OptionalincludeSelf: boolean

        (default=false)

      Returns JQueryPromise<any>

    • Call fn(node) for all parent nodes, bottom-up, including invisible system root. Stop iteration, if fn() returns false. Return false if iteration was stopped.

      Parameters

      • fn: (node: FancytreeNode) => any

        the callback function. Return false to stop iteration, return "skip" to skip this node and its children only.

      • OptionalincludeSelf: boolean

        (default=false)

      Returns boolean