Back to Trilium

Interface Fancytree

docs/Script API/interfaces/Frontend_Script_API._internal_.Fancytree.html

0.102.219.0 KB
Original Source

Interface Fancytree

interface Fancytree {
$container: JQuery;
$div: JQuery;
focusNode: FancytreeNode;
options: FancytreeOptions;
rootNode: FancytreeNode;
widget: any;
activateKey(key: string | boolean): FancytreeNode;
applyPatch(patchList: NodePatch[]): JQueryPromise<any>;
changeRefKey(oldRefKey: string, newRefKey: string): void;
clearCookies(): void;
clearFilter(): void;
count(): number;
debug(msg: any): void;
enableUpdate(enabled: boolean): void;
expandAll(flag?: boolean, options?: Object): void;
filterBranches(filter: string): number;
filterBranches(filter: (node: FancytreeNode) => boolean): number;
filterNodes(filter: string, leavesOnly?: boolean): number;
filterNodes(
filter: (node: FancytreeNode) => boolean,
leavesOnly?: boolean,
): number;
findAll(
match: string | ((node: FancytreeNode) => undefined | boolean),
): FancytreeNode[];
findNextNode(match: string, startNode?: FancytreeNode): FancytreeNode;
findNextNode(
match: (node: FancytreeNode) => boolean,
startNode?: FancytreeNode,
): FancytreeNode;
generateFormElements(selected?: boolean, active?: boolean): void;
getActiveNode(): FancytreeNode;
getFirstChild(): FancytreeNode;
getFocusNode(ifTreeHasFocus?: boolean): FancytreeNode;
getNodeByKey(key: string, searchRoot?: FancytreeNode): FancytreeNode;
getNodesByRef(refKey: string, rootNode?: FancytreeNode): FancytreeNode[];
getPersistData(): PersistData;
getRootNode(): FancytreeNode;
getSelectedNodes(stopOnParents?: boolean): FancytreeNode[];
hasFocus(): boolean;
info(msg: any): void;
isEditing(): FancytreeNode;
loadKeyPath(
keyPathList: string[],
callback: (node: FancytreeNode, status: string) => void,
): JQueryPromise<any>;
loadKeyPath(
keyPath: string,
callback: (node: FancytreeNode, status: string) => void,
): JQueryPromise<any>;
reactivate(): void;
reload(source?: any): JQueryPromise<any>;
render(force?: boolean, deep?: boolean): void;
setFocus(flag?: boolean): void;
toDict(
includeRoot?: boolean,
callback?: (node: FancytreeNode) => void,
): any;
visit(fn: (node: FancytreeNode) => any): boolean;
warn(msg: any): void;
}

Index

Properties

$container$divfocusNodeoptionsrootNodewidget

Methods

activateKeyapplyPatchchangeRefKeyclearCookiesclearFiltercountdebugenableUpdateexpandAllfilterBranchesfilterNodesfindAllfindNextNodegenerateFormElementsgetActiveNodegetFirstChildgetFocusNodegetNodeByKeygetNodesByRefgetPersistDatagetRootNodegetSelectedNodeshasFocusinfoisEditingloadKeyPathreactivatereloadrendersetFocustoDictvisitwarn

Properties

$container

$container: JQuery

$div

$div: JQuery

focusNode

focusNode: FancytreeNode

options

options: FancytreeOptions

rootNode

rootNode: FancytreeNode

widget

widget: any

Methods

activateKey

activateKey(key: string | boolean): FancytreeNode

Activate node with a given key and fire focus and activate events. A previously activated node will be deactivated. If activeVisible option is set, all parents will be expanded as necessary. Pass key = false, to deactivate the current node only.

Parameters

  • key: string | boolean

Returns FancytreeNode

activate node (null, if not found)

applyPatch

applyPatch(patchList: NodePatch[]): JQueryPromise<any>

(experimental)

Parameters

Returns JQueryPromise<any>

resolved, when all patches have been applied

changeRefKey

changeRefKey(oldRefKey: string, newRefKey: string): void

[ext-clones] Replace a refKey with a new one.

Parameters

  • oldRefKey: string
  • newRefKey: string

Returns void

clearCookies

clearCookies(): void

[ext-persist] Remove persistence cookies of the given type(s). Called like $("#tree").fancytree("getTree").clearCookies("active expanded focus selected");

Returns void

clearFilter

clearFilter(): void

[ext-filter] Reset the filter.

Returns void

count

count(): number

Return the number of nodes.

Returns number

debug

debug(msg: any): void

Write to browser console if debugLevel >= 2 (prepending tree name)

Parameters

  • msg: any

Returns void

enableUpdate

enableUpdate(enabled: boolean): void

Temporarily suppress rendering to improve performance on bulk-updates.

Parameters

  • enabled: boolean

Returns void

previous status

Since

2.19

expandAll

expandAll(flag?: boolean, options?: Object): void

Expand (or collapse) all parent nodes.

Parameters

  • Optionalflag: boolean
  • Optionaloptions: Object

Returns void

filterBranches

filterBranches(filter: string): number

[ext-filter] Dimm or hide whole branches.

Parameters

  • filter: string

Returns number

count

filterBranches(filter: (node: FancytreeNode) => boolean): number

[ext-filter] Dimm or hide whole branches.

Parameters

Returns number

count

filterNodes

filterNodes(filter: string, leavesOnly?: boolean): number

[ext-filter] Dimm or hide nodes.

Parameters

  • filter: string
  • OptionalleavesOnly: boolean

Returns number

count

filterNodes(
filter: (node: FancytreeNode) => boolean,
leavesOnly?: boolean,
): number

[ext-filter] Dimm or hide nodes.

Parameters

  • filter: (node: FancytreeNode) => boolean
  • OptionalleavesOnly: boolean

Returns number

count

findAll

findAll(
match: string | ((node: FancytreeNode) => undefined | boolean),
): FancytreeNode[]

Find all nodes that matches condition.

Parameters

Returns FancytreeNode[]

array of nodes (may be empty)

findNextNode

findNextNode(match: string, startNode?: FancytreeNode): FancytreeNode

Find the next visible node that starts with match, starting at startNode and wrap-around at the end.

Parameters

Returns FancytreeNode

matching node or null

findNextNode(
match: (node: FancytreeNode) => boolean,
startNode?: FancytreeNode,
): FancytreeNode

Find the next visible node that starts with match, starting at startNode and wrap-around at the end.

Parameters

Returns FancytreeNode

matching node or null

generateFormElements

generateFormElements(selected?: boolean, active?: boolean): void

Generate INPUT elements that can be submitted with html forms. In selectMode 3 only the topmost selected nodes are considered.

Parameters

  • Optionalselected: boolean
  • Optionalactive: boolean

Returns void

getActiveNode

getActiveNode(): FancytreeNode

Return the currently active node or null.

Returns FancytreeNode

getFirstChild

getFirstChild(): FancytreeNode

Return the first top level node if any (not the invisible root node).

Returns FancytreeNode

getFocusNode

getFocusNode(ifTreeHasFocus?: boolean): FancytreeNode

Return node that has keyboard focus.

Parameters

  • OptionalifTreeHasFocus: boolean

(default: false) (not yet implemented)

Returns FancytreeNode

getNodeByKey

getNodeByKey(key: string, searchRoot?: FancytreeNode): FancytreeNode

Return node with a given key or null if not found.

Parameters

(optional) only search below this node.

Returns FancytreeNode

getNodesByRef

getNodesByRef(refKey: string, rootNode?: FancytreeNode): FancytreeNode[]

[ext-clones] Return all nodes with a given refKey (null if not found).

Parameters

optionally restrict results to descendants of this node.

Returns FancytreeNode[]

getPersistData

getPersistData(): PersistData

[ext-persist] Return persistence information from cookies Called like $("#tree").fancytree("getTree").getPersistData();

Returns PersistData

getRootNode

getRootNode(): FancytreeNode

Return the invisible system root node.

Returns FancytreeNode

getSelectedNodes

getSelectedNodes(stopOnParents?: boolean): FancytreeNode[]

Return an array of selected nodes.

Parameters

  • OptionalstopOnParents: boolean

only return the topmost selected node (useful with selectMode 3)

Returns FancytreeNode[]

hasFocus

hasFocus(): boolean

Return true if the tree control has keyboard focus

Returns boolean

info

info(msg: any): void

Write to browser console if debugLevel >= 1 (prepending tree name)

Parameters

  • msg: any

Returns void

isEditing

isEditing(): FancytreeNode

[ext-edit] Check if any node in this tree in edit mode.

Returns FancytreeNode

loadKeyPath

loadKeyPath(
keyPathList: string[],
callback: (node: FancytreeNode, status: string) => void,
): JQueryPromise<any>

Make sure that a node with a given ID is loaded, by traversing - and loading - its parents. This method is ment for lazy hierarchies. A callback is executed for every node as we go.

Parameters

  • keyPathList: string[]

one or more key paths (e.g. '/3/2_1/7')

callback(node, status) is called for every visited node ('loading', 'loaded', 'ok', 'error')

Returns JQueryPromise<any>

loadKeyPath(
keyPath: string,
callback: (node: FancytreeNode, status: string) => void,
): JQueryPromise<any>

Make sure that a node with a given ID is loaded, by traversing - and loading - its parents. This method is ment for lazy hierarchies. A callback is executed for every node as we go.

Parameters

  • keyPath: string

a key path (e.g. '/3/2_1/7')

callback(node, status) is called for every visited node ('loading', 'loaded', 'ok', 'error')

Returns JQueryPromise<any>

reactivate

reactivate(): void

Re-fire beforeActivate and activate events.

Returns void

reload

reload(source?: any): JQueryPromise<any>

Reload tree from source and return a promise.

Parameters

  • Optionalsource: any

optional new source (defaults to initial source data)

Returns JQueryPromise<any>

render

render(force?: boolean, deep?: boolean): void

Render tree (i.e. create DOM elements for all top-level nodes).

Parameters

  • Optionalforce: boolean

create DOM elements, even is parent is collapsed (default = false)

  • Optionaldeep: boolean

(default = false)

Returns void

setFocus

setFocus(flag?: boolean): void

Parameters

  • Optionalflag: boolean

(default = true)

Returns void

toDict

toDict(includeRoot?: boolean, callback?: (node: FancytreeNode) => void): any

Return all nodes as nested list of NodeData.

Parameters

  • OptionalincludeRoot: boolean

Returns the hidden system root node (and its children) (default = false)

Called for every node

Returns any

visit

visit(fn: (node: FancytreeNode) => any): boolean

Call fn(node) for all nodes.

Parameters

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

Returns boolean

false, if the iterator was stopped.

warn

warn(msg: any): void

Write warning to browser console (prepending tree info)

Parameters

  • msg: any

Returns void

Settings

Member Visibility

  • Protected
  • Inherited
  • External

ThemeOSLightDark

On This Page

Properties $container$divfocusNodeoptionsrootNodewidget Methods activateKeyapplyPatchchangeRefKeyclearCookiesclearFiltercountdebugenableUpdateexpandAllfilterBranchesfilterNodesfindAllfindNextNodegenerateFormElementsgetActiveNodegetFirstChildgetFocusNodegetNodeByKeygetNodesByRefgetPersistDatagetRootNodegetSelectedNodeshasFocusinfoisEditingloadKeyPathreactivatereloadrendersetFocustoDictvisitwarn