@umbraci/jsmind 0.10.0 → 0.10.2

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": "@umbraci/jsmind",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
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": "lib/jsmind.js",
6
6
  "module": "es/jsmind.js",
@@ -220,30 +220,47 @@ declare class jsMind {
220
220
  */
221
221
  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;
222
222
  /**
223
- * Add multiple nodes to the mind map with optimized performance.
224
- * Supports standard jsMind formats: node_tree, node_array, and freemind with nested children structure.
223
+ * Add multiple nodes in batch.
224
+ *
225
+ * This method provides atomic batch node creation with automatic rollback on failure.
226
+ * All nodes are created in a single operation, and if any node fails to create,
227
+ * all previously created nodes in this batch will be automatically removed.
228
+ *
229
+ * **Note**: This is a batch operation API that uses standard field names only.
230
+ * For data import with custom fieldNames, use `show()` instead.
231
+ *
232
+ * @example
233
+ * // Using standard field names
234
+ * jm.add_nodes('parent_id', [
235
+ * { id: 'node1', topic: 'Node 1', data: { color: 'red' }, children: [
236
+ * { id: 'node1-1', topic: 'Child 1' }
237
+ * ]}
238
+ * ]);
239
+ *
225
240
  * @param {string | import('./jsmind.node.js').Node} parent_node - Parent node for all new nodes
226
- * @param {Array<{id?: string, topic?: string, data?: Record<string, any>, direction?: ('left'|'center'|'right'|'-1'|'0'|'1'|number), children?: Array, [key: string]: any}>} nodes_data - Array of node data objects with same format as add_node
241
+ * @param {Array<{id: string, topic: string, data?: Record<string, any>, direction?: ('left'|'center'|'right'|'-1'|'0'|'1'|number), children?: Array}>} nodes_data - Array of node data objects with standard field names (id, topic, children, data, direction)
227
242
  * @returns {Array<import('./jsmind.node.js').Node|null>} Array of created nodes (flattened from all levels)
228
243
  */
229
244
  add_nodes(parent_node: string | import("./jsmind.node.js").Node, nodes_data: Array<{
230
- id?: string;
231
- topic?: string;
245
+ id: string;
246
+ topic: string;
232
247
  data?: Record<string, any>;
233
248
  direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number);
234
249
  children?: any[];
235
- [key: string]: any;
236
250
  }>): Array<import("./jsmind.node.js").Node | null>;
237
251
  /**
238
- * Recursively add nodes using existing format processors.
252
+ * Recursively add nodes using standard field names.
253
+ * This is a batch operation API that uses standard field names only.
254
+ * For data import with custom fieldNames, use `show()` instead.
239
255
  * @private
240
256
  * @param {import('./jsmind.node.js').Node} parent_node
241
- * @param {object} node_data
257
+ * @param {object} node_data - Node data object with standard field names (id, topic, children, data, direction)
242
258
  * @returns {Array<import('./jsmind.node.js').Node|null>}
243
259
  */
244
260
  private _add_nodes_recursive;
245
261
  /**
246
262
  * Count expected nodes recursively.
263
+ * Supports custom field names via options.fieldNames configuration.
247
264
  * @private
248
265
  * @param {Array} nodes_data
249
266
  * @returns {number}
@@ -282,11 +299,14 @@ declare class jsMind {
282
299
  */
283
300
  remove_node(node: string | import("./jsmind.node.js").Node): boolean;
284
301
  /**
285
- * Update the topic (text content) of a node.
302
+ * Update the topic (text content) and/or data of a node.
286
303
  * @param {string} node_id
287
- * @param {string} topic
304
+ * @param {string|{topic?:string, data?:Record<string,any>}} topic_or_options - Topic string or options object
288
305
  */
289
- update_node(node_id: string, topic: string): void;
306
+ update_node(node_id: string, topic_or_options: string | {
307
+ topic?: string;
308
+ data?: Record<string, any>;
309
+ }): void;
290
310
  /**
291
311
  * Move a node and optionally change direction.
292
312
  * @param {string} node_id
@@ -300,7 +320,14 @@ declare class jsMind {
300
320
  * @returns {void}
301
321
  */
302
322
  select_node(node: string | import("./jsmind.node.js").Node): void;
303
- /** @returns {import('./jsmind.node.js').Node|null} */
323
+ /**
324
+ * Get the currently selected node.
325
+ *
326
+ * This is a query API that returns the internal Node instance.
327
+ * For data export with custom fieldNames, use `get_data()` instead.
328
+ *
329
+ * @returns {import('./jsmind.node.js').Node|null} Node instance or null
330
+ */
304
331
  get_selected_node(): import("./jsmind.node.js").Node | null;
305
332
  /** clear selection */
306
333
  select_clear(): void;
@@ -59,4 +59,11 @@ export class Node {
59
59
  w: number;
60
60
  h: number;
61
61
  };
62
+ /**
63
+ * Convert node to plain object with custom field names.
64
+ * @param {Record<string,string>=} fieldNames - Field names mapping
65
+ * @param {boolean=} includeChildren - Whether to include children nodes (default: false)
66
+ * @returns {Record<string, any>} Plain object representation of node
67
+ */
68
+ toObject(fieldNames?: Record<string, string> | undefined, includeChildren?: boolean | undefined): Record<string, any>;
62
69
  }