Skip to content

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 ​

ts
constructor(metadata?: Partial<MindMetadata>, options?: Partial<MindOptions>)

Creates a new mind map.

Parameters

NameTypeDescription
metadata (optional)Partial<MindMetadata>Metadata for the mind map.
options (optional)Partial<MindOptions>Configuration options for the mind map.

meta ​

ts
meta: MindMetadata

Metadata for the mind map.

observerManager ​

ts
observerManager: JmObserverManager<JmMind>

Manager for observers of this mind map.

options ​

ts
options: MindOptions

Configuration options for the mind map.

style ​

ts
style?: JmStyle

Style 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 ​

ts
get root(): JmNode

Gets the root node.

Returns: The root node.

addChildNode ​

ts
addChildNode(content: unknown, parentId: string): JmNode

Adds a child node under a parent. A string is stored as text content; a JmNodeContent is used as-is.

Returns: The created node.

Throws

  • JsMindError If parentId is missing, content is missing, or content is not a string or JmNodeContent.

Parameters

NameTypeDescription
contentunknownText, or a JmNodeContent object.
parentIdstringThe parent node ID.

addEdge ​

ts
addEdge(sourceNodeId: string, targetNodeId: string, type: "link", options?: EdgeCreationOptions): JmEdge

Adds an edge between two nodes.

Returns: The created edge.

Throws

  • JsMindError If the source or target node does not exist.

Parameters

NameTypeDescription
sourceNodeIdstringThe source node ID.
targetNodeIdstringThe target node ID.
type"link"The edge type.
options (optional)EdgeCreationOptionsOptional edge creation options.

addNode ​

ts
addNode(content: JmNodeContent, destOptions: NodeDestinationOptions, nodeOptions?: NodeCreationOptions): JmNode

Adds a new node to the mind map at a specific destination.

Returns: The created node.

Throws

  • JsMindError If destOptions.parentId is missing.

Parameters

NameTypeDescription
contentJmNodeContentContent for the new node.
destOptionsNodeDestinationOptionsDestination options (required).
nodeOptions (optional)NodeCreationOptionsOptional node creation options.

findNodeById ​

ts
findNodeById(nodeId: string): JmNode | null

Finds a node from the mind map by the given ID.

Returns: The corresponding node in this mind map if it exists, otherwise null.

Parameters

NameTypeDescription
nodeIdstringThe given node ID.

getEdges ​

ts
getEdges(nodeId: string, type?: "link" | null): JmEdge[]

Gets all edges for a specific node.

Returns: Array of edges involving the node.

Parameters

NameTypeDescription
nodeIdstringThe node ID.
type (optional)"link" | nullOptional edge type filter.

moveNode ​

ts
moveNode(nodeId: string, destOptions: NodeDestinationOptions): JmNode

Moves a node to a new parent and position.

Returns: The moved node.

Throws

  • JsMindError If destOptions are missing, node not found, or invalid move operation.

Parameters

NameTypeDescription
nodeIdstringThe ID of the node to move.
destOptionsNodeDestinationOptionsDestination options.

removeEdge ​

ts
removeEdge(edgeId: string): boolean

Removes an edge by ID.

Returns: True if the edge was removed, false if not found.

Parameters

NameTypeDescription
edgeIdstringThe edge ID to remove.

removeNode ​

ts
removeNode(nodeId: string): void

Removes a node and all its descendants.

Throws

  • JsMindError If trying to remove the root node.

Parameters

NameTypeDescription
nodeIdstringThe ID of the node to remove.

MindMetadata ​

Interface

Metadata for the mind map.

Properties

NameTypeDescription
authorstringThe author of the mind map.
namestringThe name of the mind map.
versionstringThe version of the mind map.

MindOptions ​

Interface

Configuration options for the mind map.

Properties

NameTypeDescription
rootNodeIdstring

JmObserver ​

Interface

Interface for observer pattern.

Properties

NameTypeDescription
updateunknownThis method will be called when state changes in observed object.

JmObserverManager ​

Class

Manager for observers of an observed object.

Constructor ​

ts
constructor(observedObject: T)

Creates an observer manager for an observed object.

Parameters

NameTypeDescription
observedObjectTThe object to observe.

observedObject ​

ts
observedObject: T

The object being observed.

addObserver ​

ts
addObserver(observer: JmObserver<T>): void

Adds an observer to the observed object.

Throws

  • JsMindError If the observer is not a valid JmObserver instance.

Parameters

NameTypeDescription
observerJmObserver<T>An object that contains an update(observedObject, event) method.

clearObservers ​

ts
clearObservers(): void

Removes all observers from the object.

notifyObservers ​

ts
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

NameTypeDescription
eventunknownEvents are defined by different observed objects, which represent specific information about the changes.

removeObserver ​

ts
removeObserver(observer: JmObserver<T>): void

Removes an observer that was previously added by the addObserver method.

Parameters

NameTypeDescription
observerJmObserver<T>The observer to remove.

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