jsmind 0.8.8 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsmind",
3
- "version": "0.8.8",
3
+ "version": "0.9.0",
4
4
  "description": "jsMind is a pure javascript library for mindmap, it base on html5 canvas. jsMind was released under BSD license, you can embed it in any project, if only you observe the license.",
5
5
  "main": "es6/jsmind.js",
6
6
  "types": "types/generated/index.d.ts",
@@ -92,9 +92,9 @@ export default class jsMind {
92
92
  disable_event_handle(event_handle: "mousedown" | "click" | "dblclick" | "mousewheel"): void;
93
93
  /**
94
94
  * Set theme name.
95
- * @param {string|null} theme
95
+ * @param {string|null=} theme
96
96
  */
97
- set_theme(theme: string | null): void;
97
+ set_theme(theme?: (string | null) | undefined): void;
98
98
  /** bind internal DOM events */
99
99
  _event_bind(): void;
100
100
  /** @param {MouseEvent} e */
@@ -135,7 +135,10 @@ export default class jsMind {
135
135
  expand_all(): void;
136
136
  /** Collapse all nodes */
137
137
  collapse_all(): void;
138
- /** @param {number} depth */
138
+ /**
139
+ * Expand nodes up to a specified depth level.
140
+ * @param {number} depth
141
+ */
139
142
  expand_to_depth(depth: number): void;
140
143
  /** reset view/layout/data */
141
144
  _reset(): void;
@@ -171,51 +174,84 @@ export default class jsMind {
171
174
  */
172
175
  get_node(node: string | import("./jsmind.node.js").Node): import("./jsmind.node.js").Node;
173
176
  /**
174
- * Add a node under parent.
177
+ * Add node data to the mind map without triggering UI refresh.
178
+ * @private
179
+ * @param {import('./jsmind.node.js').Node} parent_node
180
+ * @param {string} node_id
181
+ * @param {string} topic
182
+ * @param {Record<string, any>=} data
183
+ * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number)=} direction
184
+ * @returns {import('./jsmind.node.js').Node|null}
185
+ */
186
+ private _add_node_data;
187
+ /**
188
+ * Refresh UI after node changes.
189
+ * @private
190
+ * @param {import('./jsmind.node.js').Node} parent_node
191
+ */
192
+ private _refresh_node_ui;
193
+ /**
194
+ * Add a new node to the mind map.
175
195
  * @param {string | import('./jsmind.node.js').Node} parent_node
176
196
  * @param {string} node_id
177
197
  * @param {string} topic
178
198
  * @param {Record<string, any>=} data
179
- * @param {number=} direction
199
+ * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number)=} direction - Direction for node placement. Supports string values ('left', 'center', 'right'), numeric strings ('-1', '0', '1'), and numbers (-1, 0, 1)
180
200
  * @returns {import('./jsmind.node.js').Node|null}
181
201
  */
182
- add_node(parent_node: string | import("./jsmind.node.js").Node, node_id: string, topic: string, data?: Record<string, any> | undefined, direction?: number | undefined): import("./jsmind.node.js").Node | null;
202
+ add_node(parent_node: string | import("./jsmind.node.js").Node, node_id: string, topic: string, data?: Record<string, any> | undefined, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): import("./jsmind.node.js").Node | null;
203
+ /**
204
+ * Add multiple nodes to the mind map with optimized performance.
205
+ * @param {string | import('./jsmind.node.js').Node} parent_node - Parent node for all new nodes
206
+ * @param {Array<{node_id: string, topic: string, data?: Record<string, any>, direction?: ('left'|'center'|'right'|'-1'|'0'|'1'|number)}>} nodes_data - Array of node data objects
207
+ * @returns {Array<import('./jsmind.node.js').Node|null>} Array of created nodes
208
+ */
209
+ add_nodes(parent_node: string | import("./jsmind.node.js").Node, nodes_data: Array<{
210
+ node_id: string;
211
+ topic: string;
212
+ data?: Record<string, any>;
213
+ direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number);
214
+ }>): Array<import("./jsmind.node.js").Node | null>;
183
215
  /**
184
216
  * Insert a node before target node.
185
217
  * @param {string | import('./jsmind.node.js').Node} node_before
186
218
  * @param {string} node_id
187
219
  * @param {string} topic
188
220
  * @param {Record<string, any>=} data
189
- * @param {number=} direction
221
+ * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number)=} direction - Direction for node placement. Supports string values ('left', 'center', 'right'), numeric strings ('-1', '0', '1'), and numbers (-1, 0, 1)
190
222
  * @returns {import('./jsmind.node.js').Node|null}
191
223
  */
192
- insert_node_before(node_before: string | import("./jsmind.node.js").Node, node_id: string, topic: string, data?: Record<string, any> | undefined, direction?: number | undefined): import("./jsmind.node.js").Node | null;
224
+ insert_node_before(node_before: string | import("./jsmind.node.js").Node, node_id: string, topic: string, data?: Record<string, any> | undefined, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): import("./jsmind.node.js").Node | null;
193
225
  /**
194
226
  * Insert a node after target node.
195
227
  * @param {string | import('./jsmind.node.js').Node} node_after
196
228
  * @param {string} node_id
197
229
  * @param {string} topic
198
230
  * @param {Record<string, any>=} data
199
- * @param {number=} direction
231
+ * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number)=} direction - Direction for node placement. Supports string values ('left', 'center', 'right'), numeric strings ('-1', '0', '1'), and numbers (-1, 0, 1)
200
232
  * @returns {import('./jsmind.node.js').Node|null}
201
233
  */
202
- insert_node_after(node_after: string | import("./jsmind.node.js").Node, node_id: string, topic: string, data?: Record<string, any> | undefined, direction?: number | undefined): import("./jsmind.node.js").Node | null;
234
+ insert_node_after(node_after: string | import("./jsmind.node.js").Node, node_id: string, topic: string, data?: Record<string, any> | undefined, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): import("./jsmind.node.js").Node | null;
203
235
  /**
204
236
  * Remove a node.
205
237
  * @param {string | import('./jsmind.node.js').Node} node
206
238
  * @returns {boolean}
207
239
  */
208
240
  remove_node(node: string | import("./jsmind.node.js").Node): boolean;
209
- /** @param {string} node_id @param {string} topic */
241
+ /**
242
+ * Update the topic (text content) of a node.
243
+ * @param {string} node_id
244
+ * @param {string} topic
245
+ */
210
246
  update_node(node_id: string, topic: string): void;
211
247
  /**
212
248
  * Move a node and optionally change direction.
213
249
  * @param {string} node_id
214
- * @param {string=} before_id
250
+ * @param {string=} before_id - The ID of the node before which to place the moved node. Special values: "_first_", "_last_"
215
251
  * @param {string=} parent_id
216
- * @param {number=} direction
252
+ * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number)=} direction - Direction for node placement. Supports string values ('left', 'center', 'right'), numeric strings ('-1', '0', '1'), and numbers (-1, 0, 1). Only effective for second-level nodes (children of root). If not provided, direction will be determined automatically.
217
253
  */
218
- move_node(node_id: string, before_id?: string | undefined, parent_id?: string | undefined, direction?: number | undefined): void;
254
+ move_node(node_id: string, before_id?: string | undefined, parent_id?: string | undefined, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): void;
219
255
  /**
220
256
  * @param {string | import('./jsmind.node.js').Node} node
221
257
  * @returns {void}
@@ -227,7 +263,10 @@ export default class jsMind {
227
263
  select_clear(): void;
228
264
  /** @param {string | import('./jsmind.node.js').Node} node */
229
265
  is_node_visible(node: string | import("./jsmind.node.js").Node): boolean;
230
- /** @param {string | import('./jsmind.node.js').Node} node */
266
+ /**
267
+ * Scroll the mind map to center the specified node.
268
+ * @param {string | import('./jsmind.node.js').Node} node
269
+ */
231
270
  scroll_node_to_center(node: string | import("./jsmind.node.js").Node): void;
232
271
  /**
233
272
  * Find the previous sibling node of the given node.
@@ -243,6 +282,7 @@ export default class jsMind {
243
282
  */
244
283
  find_node_after(node: string | import("./jsmind.node.js").Node): import("./jsmind.node.js").Node | null;
245
284
  /**
285
+ * Set background and foreground colors for a node.
246
286
  * @param {string} node_id
247
287
  * @param {string=} bg_color
248
288
  * @param {string=} fg_color
@@ -250,6 +290,7 @@ export default class jsMind {
250
290
  */
251
291
  set_node_color(node_id: string, bg_color?: string | undefined, fg_color?: string | undefined): void;
252
292
  /**
293
+ * Set font style for a node.
253
294
  * @param {string} node_id
254
295
  * @param {number=} size
255
296
  * @param {string=} weight
@@ -258,14 +299,15 @@ export default class jsMind {
258
299
  */
259
300
  set_node_font_style(node_id: string, size?: number | undefined, weight?: string | undefined, style?: string | undefined): void;
260
301
  /**
302
+ * Set background image for a node.
261
303
  * @param {string} node_id
262
- * @param {string} image
304
+ * @param {string=} image
263
305
  * @param {number=} width
264
306
  * @param {number=} height
265
307
  * @param {number=} rotation
266
308
  * @returns {void}
267
309
  */
268
- set_node_background_image(node_id: string, image: string, width?: number | undefined, height?: number | undefined, rotation?: number | undefined): void;
310
+ set_node_background_image(node_id: string, image?: string | undefined, width?: number | undefined, height?: number | undefined, rotation?: number | undefined): void;
269
311
  /**
270
312
  * @param {string} node_id
271
313
  * @param {number} rotation
@@ -31,22 +31,22 @@ export class Mind {
31
31
  * @param {string} node_id
32
32
  * @param {string} topic
33
33
  * @param {Record<string, any>=} data
34
- * @param {number=} direction
34
+ * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number)=} direction - Direction for node placement. Supports string values ('left', 'center', 'right'), numeric strings ('-1', '0', '1'), and numbers (-1, 0, 1)
35
35
  * @param {boolean=} expanded
36
36
  * @param {number=} idx
37
37
  * @returns {Node | null}
38
38
  */
39
- add_node(parent_node: Node, node_id: string, topic: string, data?: Record<string, any> | undefined, direction?: number | undefined, expanded?: boolean | undefined, idx?: number | undefined): Node | null;
39
+ add_node(parent_node: Node, node_id: string, topic: string, data?: Record<string, any> | undefined, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined, expanded?: boolean | undefined, idx?: number | undefined): Node | null;
40
40
  /**
41
41
  * Insert a node before target node.
42
42
  * @param {Node} node_before
43
43
  * @param {string} node_id
44
44
  * @param {string} topic
45
45
  * @param {Record<string, any>=} data
46
- * @param {number=} direction
46
+ * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number)=} direction - Direction for node placement. Supports string values ('left', 'center', 'right'), numeric strings ('-1', '0', '1'), and numbers (-1, 0, 1)
47
47
  * @returns {Node | null}
48
48
  */
49
- insert_node_before(node_before: Node, node_id: string, topic: string, data?: Record<string, any> | undefined, direction?: number | undefined): Node | null;
49
+ insert_node_before(node_before: Node, node_id: string, topic: string, data?: Record<string, any> | undefined, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): Node | null;
50
50
  /**
51
51
  * Get previous sibling of a node or node id.
52
52
  * @param {string | Node} node
@@ -59,10 +59,10 @@ export class Mind {
59
59
  * @param {string} node_id
60
60
  * @param {string} topic
61
61
  * @param {Record<string, any>=} data
62
- * @param {number=} direction
62
+ * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number)=} direction - Direction for node placement. Supports string values ('left', 'center', 'right'), numeric strings ('-1', '0', '1'), and numbers (-1, 0, 1)
63
63
  * @returns {Node | null}
64
64
  */
65
- insert_node_after(node_after: Node, node_id: string, topic: string, data?: Record<string, any> | undefined, direction?: number | undefined): Node | null;
65
+ insert_node_after(node_after: Node, node_id: string, topic: string, data?: Record<string, any> | undefined, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): Node | null;
66
66
  /**
67
67
  * Get next sibling of a node or node id.
68
68
  * @param {string | Node} node
@@ -72,18 +72,18 @@ export class Mind {
72
72
  /**
73
73
  * Move a node to new parent/position.
74
74
  * @param {Node} node
75
- * @param {string=} before_id
75
+ * @param {string=} before_id - The ID of the node before which to place the moved node. Special values: "_first_", "_last_"
76
76
  * @param {string=} parent_id
77
- * @param {number=} direction
77
+ * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number)=} direction - Direction for node placement. Supports string values ('left', 'center', 'right'), numeric strings ('-1', '0', '1'), and numbers (-1, 0, 1)
78
78
  * @returns {Node | null}
79
79
  */
80
- move_node(node: Node, before_id?: string | undefined, parent_id?: string | undefined, direction?: number | undefined): Node | null;
80
+ move_node(node: Node, before_id?: string | undefined, parent_id?: string | undefined, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): Node | null;
81
81
  /**
82
82
  * Propagate direction to descendants.
83
83
  * @param {Node} node
84
- * @param {number=} direction
84
+ * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number)=} direction - Direction for node placement. Supports string values ('left', 'center', 'right'), numeric strings ('-1', '0', '1'), and numbers (-1, 0, 1)
85
85
  */
86
- _flow_node_direction(node: Node, direction?: number | undefined): void;
86
+ _flow_node_direction(node: Node, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): void;
87
87
  /**
88
88
  * Re-index node among siblings based on before_id marker.
89
89
  * @param {Node} node
@@ -96,10 +96,10 @@ export class Mind {
96
96
  * @param {Node} node
97
97
  * @param {string} before_id
98
98
  * @param {string} parent_id
99
- * @param {number=} direction
99
+ * @param {('left'|'center'|'right'|'-1'|'0'|'1'|number)=} direction - Direction for node placement. Supports string values ('left', 'center', 'right'), numeric strings ('-1', '0', '1'), and numbers (-1, 0, 1)
100
100
  * @returns {Node | null}
101
101
  */
102
- _move_node(node: Node, before_id: string, parent_id: string, direction?: number | undefined): Node | null;
102
+ _move_node(node: Node, before_id: string, parent_id: string, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): Node | null;
103
103
  /**
104
104
  * Remove a node from the mind.
105
105
  * @param {Node} node
@@ -1,24 +1,24 @@
1
1
  /**
2
2
  * Merge user options with defaults. Throws if container missing.
3
- * @param {Partial<JsMindRuntimeOptions>} options
3
+ * @param {JsMindRuntimeOptions} options
4
4
  * @returns {JsMindRuntimeOptions}
5
5
  */
6
- export function merge_option(options: Partial<JsMindRuntimeOptions>): JsMindRuntimeOptions;
6
+ export function merge_option(options: JsMindRuntimeOptions): JsMindRuntimeOptions;
7
7
  export type JsMindRuntimeOptions = {
8
8
  container: string | HTMLElement;
9
- editable: boolean;
10
- theme: (string | null);
11
- mode: ("full" | "side");
12
- support_html: boolean;
13
- log_level: "debug" | "info" | "warn" | "error" | "disable";
14
- view: {
15
- engine: "canvas" | "svg";
16
- enable_device_pixel_ratio: boolean;
17
- hmargin: number;
18
- vmargin: number;
19
- line_width: number;
20
- line_color: string;
21
- line_style: "curved" | "straight";
9
+ editable?: boolean;
10
+ theme?: (string | null);
11
+ mode?: ("full" | "side");
12
+ support_html?: boolean;
13
+ log_level?: "debug" | "info" | "warn" | "error" | "disable";
14
+ view?: {
15
+ engine?: "canvas" | "svg";
16
+ enable_device_pixel_ratio?: boolean;
17
+ hmargin?: number;
18
+ vmargin?: number;
19
+ line_width?: number;
20
+ line_color?: string;
21
+ line_style?: "curved" | "straight";
22
22
  custom_line_render?: (this: object, arg: {
23
23
  ctx: CanvasRenderingContext2D | SVGPathElement;
24
24
  start_point: {
@@ -30,35 +30,35 @@ export type JsMindRuntimeOptions = {
30
30
  y: number;
31
31
  };
32
32
  }) => void;
33
- draggable: boolean;
34
- hide_scrollbars_when_draggable: boolean;
35
- node_overflow: "hidden" | "wrap";
36
- zoom: {
37
- min: number;
38
- max: number;
39
- step: number;
40
- mask_key: number;
33
+ draggable?: boolean;
34
+ hide_scrollbars_when_draggable?: boolean;
35
+ node_overflow?: "hidden" | "wrap" | "visible";
36
+ zoom?: {
37
+ min?: number;
38
+ max?: number;
39
+ step?: number;
40
+ mask_key?: number;
41
41
  };
42
- custom_node_render: (null | ((jm: import("./jsmind.js").default, ele: HTMLElement, node: import("./jsmind.node.js").Node) => void));
43
- expander_style: "char" | "number";
42
+ custom_node_render?: (null | ((jm: import("./jsmind.js").default, ele: HTMLElement, node: import("./jsmind.node.js").Node) => void));
43
+ expander_style?: "char" | "number";
44
44
  };
45
- layout: {
46
- hspace: number;
47
- vspace: number;
48
- pspace: number;
49
- cousin_space: number;
45
+ layout?: {
46
+ hspace?: number;
47
+ vspace?: number;
48
+ pspace?: number;
49
+ cousin_space?: number;
50
50
  };
51
- default_event_handle: {
52
- enable_mousedown_handle: boolean;
53
- enable_click_handle: boolean;
54
- enable_dblclick_handle: boolean;
55
- enable_mousewheel_handle: boolean;
51
+ default_event_handle?: {
52
+ enable_mousedown_handle?: boolean;
53
+ enable_click_handle?: boolean;
54
+ enable_dblclick_handle?: boolean;
55
+ enable_mousewheel_handle?: boolean;
56
56
  };
57
- shortcut: {
58
- enable: boolean;
59
- handles: Record<string, (jm: import("./jsmind.js").default, e: KeyboardEvent) => void>;
60
- mapping: Record<string, number | number[]>;
57
+ shortcut?: {
58
+ enable?: boolean;
59
+ handles?: Record<string, (jm: import("./jsmind.js").default, e: KeyboardEvent) => void>;
60
+ mapping?: Record<string, number | number[]>;
61
61
  id_generator?: () => string;
62
62
  };
63
- plugin: Record<string, object>;
63
+ plugin?: Record<string, object>;
64
64
  };