@umbraci/jsmind 0.10.1 → 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.1",
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,45 +220,41 @@ 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.
225
224
  *
226
- * **Field Names Support**: This method now supports custom field names configured via `options.fieldNames`.
227
- * You can use your own property names (e.g., 'name' instead of 'topic', 'key' instead of 'id').
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
228
  *
229
- * @example
230
- * // Using standard field names
231
- * jm.add_nodes('parent_id', [
232
- * { id: 'node1', topic: 'Node 1', children: [...] }
233
- * ]);
229
+ * **Note**: This is a batch operation API that uses standard field names only.
230
+ * For data import with custom fieldNames, use `show()` instead.
234
231
  *
235
232
  * @example
236
- * // Using custom field names (requires fieldNames configuration)
237
- * var jm = new jsMind({
238
- * fieldNames: { id: 'key', topic: 'name', children: 'items' }
239
- * });
233
+ * // Using standard field names
240
234
  * jm.add_nodes('parent_id', [
241
- * { key: 'node1', name: 'Node 1', items: [...] }
235
+ * { id: 'node1', topic: 'Node 1', data: { color: 'red' }, children: [
236
+ * { id: 'node1-1', topic: 'Child 1' }
237
+ * ]}
242
238
  * ]);
243
239
  *
244
240
  * @param {string | import('./jsmind.node.js').Node} parent_node - Parent node for all new nodes
245
- * @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. Field names can be customized via options.fieldNames.
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)
246
242
  * @returns {Array<import('./jsmind.node.js').Node|null>} Array of created nodes (flattened from all levels)
247
243
  */
248
244
  add_nodes(parent_node: string | import("./jsmind.node.js").Node, nodes_data: Array<{
249
- id?: string;
250
- topic?: string;
245
+ id: string;
246
+ topic: string;
251
247
  data?: Record<string, any>;
252
248
  direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number);
253
249
  children?: any[];
254
- [key: string]: any;
255
250
  }>): Array<import("./jsmind.node.js").Node | null>;
256
251
  /**
257
- * Recursively add nodes using existing format processors.
258
- * Supports custom field names via options.fieldNames configuration.
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.
259
255
  * @private
260
256
  * @param {import('./jsmind.node.js').Node} parent_node
261
- * @param {object} node_data - Node data object with standard or custom field names
257
+ * @param {object} node_data - Node data object with standard field names (id, topic, children, data, direction)
262
258
  * @returns {Array<import('./jsmind.node.js').Node|null>}
263
259
  */
264
260
  private _add_nodes_recursive;
@@ -303,11 +299,14 @@ declare class jsMind {
303
299
  */
304
300
  remove_node(node: string | import("./jsmind.node.js").Node): boolean;
305
301
  /**
306
- * Update the topic (text content) of a node.
302
+ * Update the topic (text content) and/or data of a node.
307
303
  * @param {string} node_id
308
- * @param {string} topic
304
+ * @param {string|{topic?:string, data?:Record<string,any>}} topic_or_options - Topic string or options object
309
305
  */
310
- 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;
311
310
  /**
312
311
  * Move a node and optionally change direction.
313
312
  * @param {string} node_id
@@ -321,7 +320,14 @@ declare class jsMind {
321
320
  * @returns {void}
322
321
  */
323
322
  select_node(node: string | import("./jsmind.node.js").Node): void;
324
- /** @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
+ */
325
331
  get_selected_node(): import("./jsmind.node.js").Node | null;
326
332
  /** clear selection */
327
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
  }