JmMind
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.
The mind map model. Construct a map with new jsMind.Mind(), then pass it to JsMind.open.
This page is generated from the published typings dist/jsmind.d.ts with TypeDoc.
JmMind
Class
Represents a mind map with nodes and edges.
Constructor
constructor(metadata?: Partial<MindMetadata>, options?: Partial<MindOptions>)Creates a new mind map.
Parameters
| Name | Type | Description |
|---|---|---|
metadata (optional) | Partial<MindMetadata> | Metadata for the mind map. |
options (optional) | Partial<MindOptions> | Configuration options for the mind map. |
meta
meta: MindMetadataMetadata for the mind map.
observerManager
observerManager: JmObserverManager<JmMind>Manager for observers of this mind map.
options
options: MindOptionsConfiguration options for the mind map.
style
style?: JmStyleStyle declaration for the mind map.
Remarks
This mind map inherits from style.theme (default "default") and overrides whatever else the declaration lists. Resolution and deep merging happen at render time via resolveJmStyle, not here — this field only stores what the file said.
root
get root(): JmNodeGets the root node.
Returns: The root node.
addChildNode
addChildNode(content: unknown, parentId: string): JmNodeAdds a child node under a parent. A string is stored as text content; a JmNodeContent is used as-is.
Returns: The created node.
Throws
JsMindErrorIfparentIdis missing,contentis missing, orcontentis not a string or JmNodeContent.
Parameters
| Name | Type | Description |
|---|---|---|
content | unknown | Text, or a JmNodeContent object. |
parentId | string | The parent node ID. |
addEdge
addEdge(sourceNodeId: string, targetNodeId: string, type: "link", options?: EdgeCreationOptions): JmEdgeAdds an edge between two nodes.
Returns: The created edge.
Throws
JsMindErrorIf the source or target node does not exist.
Parameters
| Name | Type | Description |
|---|---|---|
sourceNodeId | string | The source node ID. |
targetNodeId | string | The target node ID. |
type | "link" | The edge type. |
options (optional) | EdgeCreationOptions | Optional edge creation options. |
addNode
addNode(content: JmNodeContent, destOptions: NodeDestinationOptions, nodeOptions?: NodeCreationOptions): JmNodeAdds a new node to the mind map at a specific destination.
Returns: The created node.
Throws
JsMindErrorIf destOptions.parentId is missing.
Parameters
| Name | Type | Description |
|---|---|---|
content | JmNodeContent | Content for the new node. |
destOptions | NodeDestinationOptions | Destination options (required). |
nodeOptions (optional) | NodeCreationOptions | Optional node creation options. |
findNodeById
findNodeById(nodeId: string): JmNode | nullFinds a node from the mind map by the given ID.
Returns: The corresponding node in this mind map if it exists, otherwise null.
Parameters
| Name | Type | Description |
|---|---|---|
nodeId | string | The given node ID. |
getEdges
getEdges(nodeId: string, type?: "link" | null): JmEdge[]Gets all edges for a specific node.
Returns: Array of edges involving the node.
Parameters
| Name | Type | Description |
|---|---|---|
nodeId | string | The node ID. |
type (optional) | "link" | null | Optional edge type filter. |
moveNode
moveNode(nodeId: string, destOptions: NodeDestinationOptions): JmNodeMoves a node to a new parent and position.
Returns: The moved node.
Throws
JsMindErrorIf destOptions are missing, node not found, or invalid move operation.
Parameters
| Name | Type | Description |
|---|---|---|
nodeId | string | The ID of the node to move. |
destOptions | NodeDestinationOptions | Destination options. |
removeEdge
removeEdge(edgeId: string): booleanRemoves an edge by ID.
Returns: True if the edge was removed, false if not found.
Parameters
| Name | Type | Description |
|---|---|---|
edgeId | string | The edge ID to remove. |
removeNode
removeNode(nodeId: string): voidRemoves a node and all its descendants.
Throws
JsMindErrorIf trying to remove the root node.
Parameters
| Name | Type | Description |
|---|---|---|
nodeId | string | The ID of the node to remove. |
MindMetadata
Interface
Metadata for the mind map.
Properties
| Name | Type | Description |
|---|---|---|
author | string | The author of the mind map. |
name | string | The name of the mind map. |
version | string | The version of the mind map. |
MindOptions
Interface
Configuration options for the mind map.
Properties
| Name | Type | Description |
|---|---|---|
rootNodeId | string |
JmObserver
Interface
Interface for observer pattern.
Properties
| Name | Type | Description |
|---|---|---|
update | unknown | This method will be called when state changes in observed object. |
JmObserverManager
Class
Manager for observers of an observed object.
Constructor
constructor(observedObject: T)Creates an observer manager for an observed object.
Parameters
| Name | Type | Description |
|---|---|---|
observedObject | T | The object to observe. |
observedObject
observedObject: TThe object being observed.
addObserver
addObserver(observer: JmObserver<T>): voidAdds an observer to the observed object.
Throws
JsMindErrorIf the observer is not a valid JmObserver instance.
Parameters
| Name | Type | Description |
|---|---|---|
observer | JmObserver<T> | An object that contains an update(observedObject, event) method. |
clearObservers
clearObservers(): voidRemoves all observers from the object.
notifyObservers
notifyObservers(event: unknown): Promise<void>Notifies the event to all observers.
Remarks
This is an asynchronous method. Each observer is notified in a separate asynchronous operation.
Parameters
| Name | Type | Description |
|---|---|---|
event | unknown | Events are defined by different observed objects, which represent specific information about the changes. |
removeObserver
removeObserver(observer: JmObserver<T>): voidRemoves an observer that was previously added by the addObserver method.
Parameters
| Name | Type | Description |
|---|---|---|
observer | JmObserver<T> | The observer to remove. |