@umbraci/jsmind 0.10.8 → 0.10.10

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.8",
3
+ "version": "0.10.10",
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",
@@ -192,6 +192,12 @@ declare class jsMind {
192
192
  * @returns {import('./jsmind.node.js').Node}
193
193
  */
194
194
  get_node(node: string | import("./jsmind.node.js").Node): import("./jsmind.node.js").Node;
195
+ /**
196
+ * Get the level/depth of a node in the mind map.
197
+ * @param {string | import('./jsmind.node.js').Node} node - Node id or Node instance
198
+ * @returns {number} Node level (root node is 0, its children are 1, etc.)
199
+ */
200
+ get_node_level(node: string | import("./jsmind.node.js").Node): number;
195
201
  /**
196
202
  * Add node data to the mind map without triggering UI refresh.
197
203
  * @private
@@ -12,13 +12,13 @@
12
12
  * // With default fieldNames
13
13
  * const tree = { data: { id: 'root', topic: 'Root', children: [...] } };
14
14
  * const flatMap = flatten(tree);
15
- * const rootNode = flatMap.get('root'); // { id: 'root', topic: 'Root', data: {...}, _parentid: null, _order: 0 }
15
+ * const rootNode = flatMap.get('root'); // { id: 'root', topic: 'Root', data: {...}, parentid: null, index: 0 }
16
16
  *
17
17
  * @example
18
18
  * // With custom fieldNames: { topic: 'name' }
19
19
  * const tree = { data: { id: 'root', name: 'Root', children: [...] } };
20
20
  * const flatMap = flatten(tree, { fields: ['name', 'data', 'id'] });
21
- * const rootNode = flatMap.get('root'); // { id: 'root', name: 'Root', data: {...}, _parentid: null, _order: 0 }
21
+ * const rootNode = flatMap.get('root'); // { id: 'root', name: 'Root', data: {...}, parentid: null, index: 0 }
22
22
  */
23
23
  export function flatten(tree: NodeTreeFormat | NodeTreeData, opts?: FlattenOptions): Map<string, FlatNode>;
24
24
  /**
@@ -59,6 +59,11 @@ export function flatten(tree: NodeTreeFormat | NodeTreeData, opts?: FlattenOptio
59
59
  * const after = jm.get_data('node_tree');
60
60
  * const result = jm.history.diff(before, after);
61
61
  * // fieldNames are automatically applied, no need to specify fields manually
62
+ *
63
+ * @example
64
+ * // Ignore index changes caused by preceding node deletions
65
+ * const result = jm.history.diff(before, after, { ignoreDeletionShift: true });
66
+ * // Now nodes that only change index due to deletion of previous siblings won't be marked as moved
62
67
  */
63
68
  export function diff(a: NodeTreeFormat | NodeTreeData, b: NodeTreeFormat | NodeTreeData, opts?: DiffOptions): DiffResult;
64
69
  export type NodeTreeFormat = {
@@ -91,11 +96,11 @@ export type FlatNode = {
91
96
  /**
92
97
  * - Parent node ID (structure field)
93
98
  */
94
- _parentid?: string | null;
99
+ parentid?: string | null;
95
100
  /**
96
101
  * - Node order in parent's children (structure field)
97
102
  */
98
- _order?: number;
103
+ index?: number;
99
104
  };
100
105
  export type ChangeDetail = {
101
106
  /**
@@ -261,7 +266,7 @@ export type FlattenOptions = {
261
266
  */
262
267
  childrenKey?: string;
263
268
  /**
264
- * - Whether to include _parentid and _order. Defaults to true
269
+ * - Whether to include parentid and index. Defaults to true
265
270
  */
266
271
  includeStructure?: boolean;
267
272
  };
@@ -287,7 +292,7 @@ export type DiffOptions = {
287
292
  */
288
293
  childrenKey?: string;
289
294
  /**
290
- * - Whether to include _parentid and _order in comparison. Defaults to true
295
+ * - Whether to include parentid and index in comparison. Defaults to true
291
296
  */
292
297
  includeStructure?: boolean;
293
298
  /**
@@ -298,4 +303,8 @@ export type DiffOptions = {
298
303
  * - Whether to categorize updates into moved/modified/movedAndModified. Defaults to false
299
304
  */
300
305
  categorize?: boolean;
306
+ /**
307
+ * - Whether to ignore index changes caused by preceding node deletions. When true, nodes that only change index due to deletion of previous siblings won't be marked as moved. Defaults to false
308
+ */
309
+ ignoreDeletionShift?: boolean;
301
310
  };
@@ -258,8 +258,5 @@ export type DraggableNodeOptions = {
258
258
  scrolling_trigger_width?: number;
259
259
  scrolling_step_length?: number;
260
260
  shadow_node_class_name?: string;
261
- /**
262
- * - Function to validate drag operation, receives (draggedNode, targetNode) and returns boolean to allow/deny
263
- */
264
- before_drop?: Function;
261
+ validate_drag?: (draggedNode: import("../jsmind.node.js").Node, targetNode: import("../jsmind.node.js").Node | null) => boolean;
265
262
  };