Skip to content

Nodes ​

Preview version

The jsMind V2 programming API is currently a preview. The API will change in later updates. Please check this documentation anytime for the interface that is current.

Nodes, their content, and the side values used when placing a child to the left or right of the root.

This page is generated from the published typings dist/jsmind.d.ts with TypeDoc.

JmNode ​

Class

Node of mind map.

Constructor ​

ts
constructor(id: string, content: JmNodeContent)

Creates a new node.

Throws

  • JsMindError If the node ID or content is invalid.

Parameters

NameTypeDescription
idstringThe unique identifier of the node.
contentJmNodeContentThe content of the node.

children ​

ts
children: JmNode[]

Array of child nodes.

content ​

ts
content: JmNodeContent

The content of the node.

data ​

ts
data: Record<string, unknown>

Additional data associated with the node.

folded ​

ts
folded: boolean

Whether the node is folded (collapsed).

id ​

ts
id: string

The unique identifier of the node.

parent ​

ts
parent: JmNode | null

The parent node, or null if this is the root node.

side ​

ts
side: JmNodeSide

The direction of the node.

style ​

ts
style?: JmNodeStyle

Visual overrides for this node.

Remarks

Unset fields fall back to the theme. Storing only the difference keeps theme changes propagating to every node that did not override anything.

equals ​

ts
equals(other: JmNode): boolean

Compares this node with another node.

Returns: True if they are equal, false otherwise.

Parameters

NameTypeDescription
otherJmNodeThe other node to compare with.

getAllSubnodeIds ​

ts
getAllSubnodeIds(): string[]

Lists all subnode IDs recursively.

Returns: Array of all subnode IDs including this node's children and their descendants.

isDescendant ​

ts
isDescendant(potentialAncestor: JmNode): boolean

Checks if this node is a descendant of another node.

Returns: True if this node is a descendant of potentialAncestor.

Parameters

NameTypeDescription
potentialAncestorJmNodeThe potential ancestor node.

isRoot ​

ts
isRoot(): boolean

Checks whether this node is the root (it has no parent).

Returns: True if this node has no parent.

JmNodeContent ​

Class

Content of mind map node.

Constructor ​

ts
constructor(type: "text", value: unknown)

Creates a content object.

Throws

  • Error If the content type is invalid.

Parameters

NameTypeDescription
type"text"The type of content.
valueunknownThe actual content value.

type ​

ts
type: "text"

The type of the content.

value ​

ts
value: unknown

The actual content value.

getText ​

ts
getText(): string

Returns the text value of this content.

Returns: The text value.

Throws

  • Error If the content is not text type.

hasType ​

ts
hasType(type: "text"): boolean

Checks if content is of specific type.

Returns: True if content is of the specified type.

Parameters

NameTypeDescription
type"text"The type to check.

isText ​

ts
isText(): boolean

Checks if content is text type.

Returns: True if content is text type.

createText ​

ts
static createText(text: string): JmNodeContent

Creates a text content object.

Returns: The content object.

Parameters

NameTypeDescription
textstringThe text content.

fromObject ​

ts
static fromObject(obj: { type: "text"; value: unknown }): JmNodeContent

Creates a content object from an object with type and value.

Returns: The content object.

Parameters

NameTypeDescription
objThe object to create content from.

JmNodeContentType ​

Enumeration

Enumeration for content types of node.

Members

NameValueDescription
Text"text"Text content type.

JmNodeSide ​

Enumeration

Enumeration for directions of node.

Members

NameValueDescription
Center0Center direction.
SideA1Right direction.
SideB-1Left direction.

NodeCreationOptions ​

Interface

Options for creating a new node.

Properties

NameTypeDescription
data (optional)Record<string, unknown>Additional data for the node (default: {}).
folded (optional)booleanWhether the node is folded (default: false).
nodeId (optional)stringOptional custom node ID.
side (optional)JmNodeSideDirection of the node (default: null).
style (optional)JmNodeStyleVisual overrides for the node (default: none).

NodeDestinationOptions ​

Interface

Options for specifying node destination.

Properties

NameTypeDescription
parentIdstringThe ID of the target parent node (required).
position (optional)numberThe position index among siblings (if not provided, adds to end).
side (optional)JmNodeSideThe direction of the node (if not provided, keeps current direction).

本文档由 AI 协助生成 / This documentation was prepared with AI assistance