JsMind
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 default export of the jsmind package. In the UMD build it is also available as the global jsMind.
This page is generated from the published typings dist/jsmind.d.ts with TypeDoc.
JsMind
Class
Main class for jsMind mind map operations.
mind
mind: JmMind | nullThe currently opened mind map, or null if none is open.
options
options: JsMindOptionsThe options for this jsMind instance.
Mind
static Mind: typeof JmMindThe mind map model class. Construct a map with new jsMind.Mind(), then pass it to JsMind.open.
NodeSide
static NodeSide: { Center: 0; SideA: 1; SideB: -1 }Node side values used when placing a node to the left, right, or center. Same object as the JmNodeSide enumeration in the typings.
Serializer
static Serializer: typeof JmMindSerializerFactoryFactory for serializers. jsMind.Serializer.create('json') and jsMind.Serializer.create('freemind') are the supported formats.
commands
get commands(): JmCommanderCommands that change what is displayed - export, zoom - without changing the map.
Remarks
Reachable from outside so that the caller can hold on to it: a shell, a toolbar button or a keyboard shortcut keeps this reference and calls it, instead of going through the instance every time.
Author
static get Author(): stringGets the author of jsMind.
Returns: The author string.
Version
static get Version(): stringGets the version of jsMind.
Returns: The version string.
close
close(): voidCloses the current mind map, if one is open.
After close, JsMind.mind is null until you JsMind.open another map.
exportImage
exportImage(options?: JmExportImageOptions): Promise<JmExportImageResult>Renders the open mind map to an image.
The size is the rendered content's own size: whitespace inside the container is part of the picture, and a map larger than its container is not cropped.
Returns: The encoded image, as a Blob, plus its pixel dimensions.
Throws
JsMindErrorIf no mind map is open, or if the browser cannot encode the result.
Parameters
| Name | Type | Description |
|---|---|---|
options (optional) | JmExportImageOptions | Scale, format, quality and background transparency. Defaults to PNG at 2x. |
open
open(mind: JmMind): Promise<void>Opens a mind map.
Remarks
Opening replaces whatever is displayed. A map that is already open is closed first, which drops its rendered nodes and its observer: without that, opening a second map on the same view stacks it on top of the first, and opening the map that is already open keeps rendering the previous style.
Opened is also when the instance's viewport mode is applied: an instance created without options owns the box from here on - overflow is already the viewport's, and the map starts at the identity rather than at the corner the previous one was left at. An instance created with { view: { viewportMode: 'native' } } keeps native scrolling, and its JsMind.commands refuse to move the map.
Returns: A promise that resolves when the mind map has been opened.
Parameters
| Name | Type | Description |
|---|---|---|
mind | JmMind | The mind map instance to open. |
serialize
serialize(): stringSerializes the current mind map to JSON.
Returns: JSON string representation of the mind map.
Throws
ErrorIf no mind map is open or serialization fails.
create
static create(container: string | HTMLElement, options?: JsMindOptionsInput): Promise<JsMind>Creates a jsMind instance and attaches its view to a container.
Returns: A promise that resolves to the new instance. No mind map is open yet; call JsMind.open with a JmMind to display one.
Parameters
| Name | Type | Description |
|---|---|---|
container | string | HTMLElement | The container element, or the id of an element in the document. |
options (optional) | JsMindOptionsInput | Configuration for the instance. Every group and every field in it may be omitted, and omitted ones use the library defaults - which include taking the container's box over with the transform viewport. { view: { viewportMode: 'native' } } keeps native scrolling instead, and is what a host without its own gestures wants for a map larger than its box. |