@umbraci/jsmind 0.10.14 → 0.10.17

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.
Files changed (70) hide show
  1. package/LICENSE +24 -24
  2. package/README.md +116 -116
  3. package/dist/jsmind.copy-paste.js +9 -0
  4. package/dist/jsmind.copy-paste.js.map +1 -0
  5. package/dist/jsmind.draggable-node.js +1 -1
  6. package/dist/jsmind.draggable-node.js.map +1 -1
  7. package/dist/jsmind.history.js +1 -1
  8. package/dist/jsmind.history.js.map +1 -1
  9. package/dist/jsmind.js +1 -1
  10. package/dist/jsmind.js.map +1 -1
  11. package/dist/jsmind.multi-select.js +1 -1
  12. package/dist/jsmind.multi-select.js.map +1 -1
  13. package/dist/jsmind.multiline-text.js +1 -1
  14. package/dist/jsmind.multiline-text.js.map +1 -1
  15. package/dist/jsmind.screenshot.js +1 -1
  16. package/dist/jsmind.screenshot.js.map +1 -1
  17. package/es/jsmind.copy-paste.js +9 -0
  18. package/es/jsmind.copy-paste.js.map +1 -0
  19. package/es/jsmind.draggable-node.js +1 -1
  20. package/es/jsmind.draggable-node.js.map +1 -1
  21. package/es/jsmind.history.js +1 -1
  22. package/es/jsmind.history.js.map +1 -1
  23. package/es/jsmind.js +1 -1
  24. package/es/jsmind.js.map +1 -1
  25. package/es/jsmind.multi-select.js +1 -1
  26. package/es/jsmind.multi-select.js.map +1 -1
  27. package/es/jsmind.multiline-text.js +1 -1
  28. package/es/jsmind.multiline-text.js.map +1 -1
  29. package/es/jsmind.screenshot.js +1 -1
  30. package/es/jsmind.screenshot.js.map +1 -1
  31. package/lib/jsmind.copy-paste.js +9 -0
  32. package/lib/jsmind.copy-paste.js.map +1 -0
  33. package/lib/jsmind.draggable-node.js +1 -1
  34. package/lib/jsmind.draggable-node.js.map +1 -1
  35. package/lib/jsmind.history.js +1 -1
  36. package/lib/jsmind.history.js.map +1 -1
  37. package/lib/jsmind.js +1 -1
  38. package/lib/jsmind.js.map +1 -1
  39. package/lib/jsmind.multi-select.js +1 -1
  40. package/lib/jsmind.multi-select.js.map +1 -1
  41. package/lib/jsmind.multiline-text.js +1 -1
  42. package/lib/jsmind.multiline-text.js.map +1 -1
  43. package/lib/jsmind.screenshot.js +1 -1
  44. package/lib/jsmind.screenshot.js.map +1 -1
  45. package/package.json +115 -115
  46. package/style/jsmind.css +408 -408
  47. package/types/generated/index.d.ts +8 -0
  48. package/types/generated/jsmind.common.d.ts +68 -0
  49. package/types/generated/jsmind.d.ts +438 -0
  50. package/types/generated/jsmind.data_provider.d.ts +56 -0
  51. package/types/generated/jsmind.dom.d.ts +59 -0
  52. package/types/generated/jsmind.enhanced-plugin.d.ts +103 -0
  53. package/types/generated/jsmind.format.d.ts +113 -0
  54. package/types/generated/jsmind.graph.d.ts +180 -0
  55. package/types/generated/jsmind.layout_provider.d.ts +182 -0
  56. package/types/generated/jsmind.mind.d.ts +121 -0
  57. package/types/generated/jsmind.node.d.ts +69 -0
  58. package/types/generated/jsmind.option.d.ts +73 -0
  59. package/types/generated/jsmind.plugin.d.ts +21 -0
  60. package/types/generated/jsmind.shortcut_provider.d.ts +52 -0
  61. package/types/generated/jsmind.util.d.ts +26 -0
  62. package/types/generated/jsmind.view_provider.d.ts +347 -0
  63. package/types/generated/plugins/history/history-diff.d.ts +297 -0
  64. package/types/generated/plugins/history/jsmind.history.d.ts +87 -0
  65. package/types/generated/plugins/jsmind.draggable-node.d.ts +262 -0
  66. package/types/generated/plugins/jsmind.multi-select.d.ts +238 -0
  67. package/types/generated/plugins/jsmind.multiline-text-v2.d.ts +58 -0
  68. package/types/generated/plugins/jsmind.multiline-text.d.ts +43 -0
  69. package/types/generated/plugins/jsmind.screenshot.d.ts +83 -0
  70. package/types/tsconfig.declaration.json +19 -19
@@ -0,0 +1,121 @@
1
+ export class Mind {
2
+ /** @type {string | null} */
3
+ name: string | null;
4
+ /** @type {string | null} */
5
+ author: string | null;
6
+ /** @type {string | null} */
7
+ version: string | null;
8
+ /** @type {Node | null} */
9
+ root: Node | null;
10
+ /** @type {Node | null} */
11
+ selected: Node | null;
12
+ /** @type {Record<string, Node>} */
13
+ nodes: Record<string, Node>;
14
+ /**
15
+ * Get a node by id.
16
+ * @param {string} node_id
17
+ * @returns {Node | null}
18
+ */
19
+ get_node(node_id: string): Node | null;
20
+ /**
21
+ * Set the root node, only once.
22
+ * @param {string} node_id
23
+ * @param {string} topic
24
+ * @param {Record<string, any>=} data
25
+ * @returns {Node | null}
26
+ */
27
+ set_root(node_id: string, topic: string, data?: Record<string, any> | undefined): Node | null;
28
+ /**
29
+ * Add a child node under parent.
30
+ * @param {Node} parent_node
31
+ * @param {string} node_id
32
+ * @param {string} topic
33
+ * @param {Record<string, any>=} data
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
+ * @param {boolean=} expanded
36
+ * @param {number=} idx
37
+ * @returns {Node | null}
38
+ */
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
+ /**
41
+ * Insert a node before target node.
42
+ * @param {Node} node_before
43
+ * @param {string} node_id
44
+ * @param {string} topic
45
+ * @param {Record<string, any>=} data
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
+ * @returns {Node | null}
48
+ */
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
+ /**
51
+ * Get previous sibling of a node or node id.
52
+ * @param {string | Node} node
53
+ * @returns {Node | null}
54
+ */
55
+ get_node_before(node: string | Node): Node | null;
56
+ /**
57
+ * Insert a node after target node.
58
+ * @param {Node} node_after
59
+ * @param {string} node_id
60
+ * @param {string} topic
61
+ * @param {Record<string, any>=} data
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
+ * @returns {Node | null}
64
+ */
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
+ /**
67
+ * Get next sibling of a node or node id.
68
+ * @param {string | Node} node
69
+ * @returns {Node | null}
70
+ */
71
+ get_node_after(node: string | Node): Node | null;
72
+ /**
73
+ * Move a node to new parent/position.
74
+ * @param {Node} node
75
+ * @param {string=} before_id - The ID of the node before which to place the moved node. Special values: "_first_", "_last_"
76
+ * @param {string=} parent_id
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
+ * @returns {Node | null}
79
+ */
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
+ /**
82
+ * Propagate direction to descendants.
83
+ * @param {Node} node
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
+ */
86
+ _flow_node_direction(node: Node, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): void;
87
+ /**
88
+ * Re-index node among siblings based on before_id marker.
89
+ * @param {Node} node
90
+ * @param {string} before_id
91
+ * @returns {Node}
92
+ */
93
+ _move_node_internal(node: Node, before_id: string): Node;
94
+ /**
95
+ * Internal move implementation.
96
+ * @param {Node} node
97
+ * @param {string} before_id
98
+ * @param {string} parent_id
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
+ * @returns {Node | null}
101
+ */
102
+ _move_node(node: Node, before_id: string, parent_id: string, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): Node | null;
103
+ /**
104
+ * Remove a node from the mind.
105
+ * @param {Node} node
106
+ * @returns {boolean}
107
+ */
108
+ remove_node(node: Node): boolean;
109
+ /**
110
+ * Put node into the map if id is not taken.
111
+ * @param {Node} node
112
+ * @returns {boolean}
113
+ */
114
+ _put_node(node: Node): boolean;
115
+ /**
116
+ * Re-index children by Node.compare.
117
+ * @param {Node} node
118
+ */
119
+ _update_index(node: Node): void;
120
+ }
121
+ import { Node } from './jsmind.node.js';
@@ -0,0 +1,69 @@
1
+ export class Node {
2
+ /**
3
+ * Compare two nodes by index for ordering.
4
+ * @param {Node} node1
5
+ * @param {Node} node2
6
+ * @returns {number}
7
+ */
8
+ static compare(node1: Node, node2: Node): number;
9
+ /**
10
+ * Check if node is the same as or a descendant of parent_node.
11
+ * @param {Node} parent_node
12
+ * @param {Node} node
13
+ * @returns {boolean}
14
+ */
15
+ static inherited(parent_node: Node, node: Node): boolean;
16
+ /**
17
+ * Runtime check for Node instance.
18
+ * @param {unknown} n
19
+ * @returns {n is Node}
20
+ */
21
+ static is_node(n: unknown): n is Node;
22
+ /**
23
+ * Create a Node instance.
24
+ * @param {string} sId - Node id
25
+ * @param {number} iIndex - Node index (order among siblings). Use -1 for tail
26
+ * @param {string} sTopic - Node topic text
27
+ * @param {Record<string, any>=} oData - Arbitrary node data
28
+ * @param {boolean=} bIsRoot - Whether it is the root node
29
+ * @param {Node | null=} oParent - Parent node
30
+ * @param {number=} eDirection - Direction for children under root (-1 left, 0 center, 1 right)
31
+ * @param {boolean=} bExpanded - Expanded state
32
+ */
33
+ constructor(sId: string, iIndex: number, sTopic: string, oData?: Record<string, any> | undefined, bIsRoot?: boolean | undefined, oParent?: (Node | null) | undefined, eDirection?: number | undefined, bExpanded?: boolean | undefined);
34
+ id: string;
35
+ index: number;
36
+ topic: string;
37
+ /** @type {Record<string, any>} */
38
+ data: Record<string, any>;
39
+ isroot: boolean;
40
+ parent: Node;
41
+ direction: number;
42
+ expanded: boolean;
43
+ /** @type {Node[]} */
44
+ children: Node[];
45
+ _data: {};
46
+ /**
47
+ * Get absolute location of this node in view coordinates.
48
+ * @returns {{x:number,y:number}}
49
+ */
50
+ get_location(): {
51
+ x: number;
52
+ y: number;
53
+ };
54
+ /**
55
+ * Get rendered size of this node.
56
+ * @returns {{w:number,h:number}}
57
+ */
58
+ get_size(): {
59
+ w: number;
60
+ h: number;
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>;
69
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Merge user options with defaults. Throws if container missing.
3
+ * @param {JsMindRuntimeOptions} options
4
+ * @returns {JsMindRuntimeOptions}
5
+ */
6
+ export function merge_option(options: JsMindRuntimeOptions): JsMindRuntimeOptions;
7
+ export type JsMindRuntimeOptions = {
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";
22
+ custom_line_render?: (this: object, arg: {
23
+ ctx: CanvasRenderingContext2D | SVGPathElement;
24
+ start_point: {
25
+ x: number;
26
+ y: number;
27
+ };
28
+ end_point: {
29
+ x: number;
30
+ y: number;
31
+ };
32
+ }) => void;
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
+ };
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
+ };
45
+ layout?: {
46
+ hspace?: number;
47
+ vspace?: number;
48
+ pspace?: number;
49
+ cousin_space?: number;
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;
56
+ };
57
+ shortcut?: {
58
+ enable?: boolean;
59
+ handles?: Record<string, (jm: import("./jsmind.js").default, e: KeyboardEvent) => void>;
60
+ mapping?: Record<string, number | number[]>;
61
+ id_generator?: () => string;
62
+ };
63
+ fieldNames?: {
64
+ id?: string;
65
+ topic?: string;
66
+ children?: string;
67
+ parentid?: string;
68
+ isroot?: string;
69
+ direction?: string;
70
+ expanded?: string;
71
+ };
72
+ plugin?: Record<string, object>;
73
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Register a plugin instance.
3
+ * @param {Plugin<object>} plugin
4
+ */
5
+ export function register(plugin: Plugin<object>): void;
6
+ /**
7
+ * Apply registered plugins asynchronously.
8
+ * @param {import('./jsmind.js').default} jm
9
+ * @param {Record<string, object>} options
10
+ */
11
+ export function apply(jm: import("./jsmind.js").default, options: Record<string, object>): void;
12
+ export class Plugin {
13
+ /**
14
+ * @template [TOptions=object]
15
+ * @param {string} name
16
+ * @param {(jm: import('./jsmind.js').default, options: TOptions)=>void} fn_init
17
+ */
18
+ constructor(name: string, fn_init: (jm: import("./jsmind.js").default, options: TOptions) => void);
19
+ name: string;
20
+ fn_init: (jm: import("./jsmind.js").default, options: TOptions) => void;
21
+ }
@@ -0,0 +1,52 @@
1
+ export class ShortcutProvider {
2
+ /**
3
+ * @param {import('./jsmind.js').default} jm
4
+ * @param {{ enable:boolean, handles: Record<string,(jm: import('./jsmind.js').default, e: KeyboardEvent)=>void>, mapping: Record<string, number|number[]>, id_generator?: ()=>string }} options
5
+ */
6
+ constructor(jm: import("./jsmind.js").default, options: {
7
+ enable: boolean;
8
+ handles: Record<string, (jm: import("./jsmind.js").default, e: KeyboardEvent) => void>;
9
+ mapping: Record<string, number | number[]>;
10
+ id_generator?: () => string;
11
+ });
12
+ jm: import("./jsmind.js").default;
13
+ opts: {
14
+ enable: boolean;
15
+ handles: Record<string, (jm: import("./jsmind.js").default, e: KeyboardEvent) => void>;
16
+ mapping: Record<string, number | number[]>;
17
+ id_generator?: () => string;
18
+ };
19
+ /** @type {Record<string, number|number[]>} */
20
+ mapping: Record<string, number | number[]>;
21
+ /** @type {Record<string,(jm: import('./jsmind.js').default, e: KeyboardEvent)=>void>} */
22
+ handles: Record<string, (jm: import("./jsmind.js").default, e: KeyboardEvent) => void>;
23
+ /** @type {()=>string|null} */
24
+ _newid: () => string | null;
25
+ /** @type {Record<number,(jm: import('./jsmind.js').default, e: KeyboardEvent)=>void>} */
26
+ _mapping: Record<number, (jm: import("./jsmind.js").default, e: KeyboardEvent) => void>;
27
+ init(): void;
28
+ enable_shortcut(): void;
29
+ disable_shortcut(): void;
30
+ /** @param {KeyboardEvent} e */
31
+ handler(e: KeyboardEvent): boolean;
32
+ /** @param {import('./jsmind.js').default} _jm @param {KeyboardEvent} e */
33
+ handle_addchild(_jm: import("./jsmind.js").default, e: KeyboardEvent): void;
34
+ /** @param {import('./jsmind.js').default} _jm @param {KeyboardEvent} e */
35
+ handle_addbrother(_jm: import("./jsmind.js").default, e: KeyboardEvent): void;
36
+ /** @param {import('./jsmind.js').default} _jm @param {KeyboardEvent} e */
37
+ handle_editnode(_jm: import("./jsmind.js").default, e: KeyboardEvent): void;
38
+ /** @param {import('./jsmind.js').default} _jm @param {KeyboardEvent} e */
39
+ handle_delnode(_jm: import("./jsmind.js").default, e: KeyboardEvent): void;
40
+ /** @param {import('./jsmind.js').default} _jm @param {KeyboardEvent} e */
41
+ handle_toggle(_jm: import("./jsmind.js").default, e: KeyboardEvent): void;
42
+ /** @param {import('./jsmind.js').default} _jm @param {KeyboardEvent} e */
43
+ handle_up(_jm: import("./jsmind.js").default, e: KeyboardEvent): void;
44
+ /** @param {import('./jsmind.js').default} _jm @param {KeyboardEvent} e */
45
+ handle_down(_jm: import("./jsmind.js").default, e: KeyboardEvent): void;
46
+ /** @param {import('./jsmind.js').default} _jm @param {KeyboardEvent} e */
47
+ handle_left(_jm: import("./jsmind.js").default, e: KeyboardEvent): void;
48
+ /** @param {import('./jsmind.js').default} _jm @param {KeyboardEvent} e */
49
+ handle_right(_jm: import("./jsmind.js").default, e: KeyboardEvent): void;
50
+ /** @param {import('./jsmind.js').default} _jm @param {KeyboardEvent} e @param {number} d */
51
+ _handle_direction(_jm: import("./jsmind.js").default, e: KeyboardEvent, d: number): void;
52
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Misc utility collection.
3
+ * @type {{
4
+ * file: { read: (file: File, cb:(result:string,name:string)=>void)=>void, save:(data:string,type:string,name:string)=>void},
5
+ * json: { json2string:(v:unknown)=>string, string2json:(s:string)=>unknown, merge:(b:object,a:object)=>object },
6
+ * uuid: { newid:()=>string },
7
+ * text: { is_empty:(s?:string)=>boolean }
8
+ * }}
9
+ */
10
+ export const util: {
11
+ file: {
12
+ read: (file: File, cb: (result: string, name: string) => void) => void;
13
+ save: (data: string, type: string, name: string) => void;
14
+ };
15
+ json: {
16
+ json2string: (v: unknown) => string;
17
+ string2json: (s: string) => unknown;
18
+ merge: (b: object, a: object) => object;
19
+ };
20
+ uuid: {
21
+ newid: () => string;
22
+ };
23
+ text: {
24
+ is_empty: (s?: string) => boolean;
25
+ };
26
+ };