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
constructor(id: string, content: JmNodeContent)Creates a new node.
Throws
JsMindErrorIf the node ID or content is invalid.
Parameters
| Name | Type | Description |
|---|---|---|
id | string | The unique identifier of the node. |
content | JmNodeContent | The content of the node. |
children
children: JmNode[]Array of child nodes.
content
content: JmNodeContentThe content of the node.
data
data: Record<string, unknown>Additional data associated with the node.
folded
folded: booleanWhether the node is folded (collapsed).
id
id: stringThe unique identifier of the node.
parent
parent: JmNode | nullThe parent node, or null if this is the root node.
side
side: JmNodeSideThe direction of the node.
style
style?: JmNodeStyleVisual 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
equals(other: JmNode): booleanCompares this node with another node.
Returns: True if they are equal, false otherwise.
Parameters
| Name | Type | Description |
|---|---|---|
other | JmNode | The other node to compare with. |
getAllSubnodeIds
getAllSubnodeIds(): string[]Lists all subnode IDs recursively.
Returns: Array of all subnode IDs including this node's children and their descendants.
isDescendant
isDescendant(potentialAncestor: JmNode): booleanChecks if this node is a descendant of another node.
Returns: True if this node is a descendant of potentialAncestor.
Parameters
| Name | Type | Description |
|---|---|---|
potentialAncestor | JmNode | The potential ancestor node. |
isRoot
isRoot(): booleanChecks 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
constructor(type: "text", value: unknown)Creates a content object.
Throws
ErrorIf the content type is invalid.
Parameters
| Name | Type | Description |
|---|---|---|
type | "text" | The type of content. |
value | unknown | The actual content value. |
type
type: "text"The type of the content.
value
value: unknownThe actual content value.
getText
getText(): stringReturns the text value of this content.
Returns: The text value.
Throws
ErrorIf the content is not text type.
hasType
hasType(type: "text"): booleanChecks if content is of specific type.
Returns: True if content is of the specified type.
Parameters
| Name | Type | Description |
|---|---|---|
type | "text" | The type to check. |
isText
isText(): booleanChecks if content is text type.
Returns: True if content is text type.
createText
static createText(text: string): JmNodeContentCreates a text content object.
Returns: The content object.
Parameters
| Name | Type | Description |
|---|---|---|
text | string | The text content. |
fromObject
static fromObject(obj: { type: "text"; value: unknown }): JmNodeContentCreates a content object from an object with type and value.
Returns: The content object.
Parameters
| Name | Type | Description |
|---|---|---|
obj | The object to create content from. |
JmNodeContentType
Enumeration
Enumeration for content types of node.
Members
| Name | Value | Description |
|---|---|---|
Text | "text" | Text content type. |
JmNodeSide
Enumeration
Enumeration for directions of node.
Members
| Name | Value | Description |
|---|---|---|
Center | 0 | Center direction. |
SideA | 1 | Right direction. |
SideB | -1 | Left direction. |
NodeCreationOptions
Interface
Options for creating a new node.
Properties
| Name | Type | Description |
|---|---|---|
data (optional) | Record<string, unknown> | Additional data for the node (default: {}). |
folded (optional) | boolean | Whether the node is folded (default: false). |
nodeId (optional) | string | Optional custom node ID. |
side (optional) | JmNodeSide | Direction of the node (default: null). |
style (optional) | JmNodeStyle | Visual overrides for the node (default: none). |
NodeDestinationOptions
Interface
Options for specifying node destination.
Properties
| Name | Type | Description |
|---|---|---|
parentId | string | The ID of the target parent node (required). |
position (optional) | number | The position index among siblings (if not provided, adds to end). |
side (optional) | JmNodeSide | The direction of the node (if not provided, keeps current direction). |