@umbraci/jsmind 0.10.14 → 0.10.15

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 (69) 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 +632 -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 +129 -0
  57. package/types/generated/jsmind.node.d.ts +69 -0
  58. package/types/generated/jsmind.option.d.ts +78 -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 +374 -0
  63. package/types/generated/plugins/history/history-diff.d.ts +310 -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.multiline-text-v2.d.ts +58 -0
  67. package/types/generated/plugins/jsmind.multiline-text.d.ts +43 -0
  68. package/types/generated/plugins/jsmind.screenshot.d.ts +83 -0
  69. package/types/tsconfig.declaration.json +19 -19
@@ -0,0 +1,129 @@
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 {Set<Node>} */
13
+ selected_nodes: Set<Node>;
14
+ /** @type {Record<string, Node>} */
15
+ nodes: Record<string, Node>;
16
+ /**
17
+ * Get a node by id.
18
+ * @param {string} node_id
19
+ * @returns {Node | null}
20
+ */
21
+ get_node(node_id: string): Node | null;
22
+ /**
23
+ * Set the root node, only once.
24
+ * @param {string} node_id
25
+ * @param {string} topic
26
+ * @param {Record<string, any>=} data
27
+ * @returns {Node | null}
28
+ */
29
+ set_root(node_id: string, topic: string, data?: Record<string, any> | undefined): Node | null;
30
+ /**
31
+ * Add a child node under parent.
32
+ * @param {Node} parent_node
33
+ * @param {string} node_id
34
+ * @param {string} topic
35
+ * @param {Record<string, any>=} data
36
+ * @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)
37
+ * @param {boolean=} expanded
38
+ * @param {number=} idx
39
+ * @returns {Node | null}
40
+ */
41
+ 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;
42
+ /**
43
+ * Insert a node before target node.
44
+ * @param {Node} node_before
45
+ * @param {string} node_id
46
+ * @param {string} topic
47
+ * @param {Record<string, any>=} data
48
+ * @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)
49
+ * @returns {Node | null}
50
+ */
51
+ 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;
52
+ /**
53
+ * Get previous sibling of a node or node id.
54
+ * @param {string | Node} node
55
+ * @returns {Node | null}
56
+ */
57
+ get_node_before(node: string | Node): Node | null;
58
+ /**
59
+ * Insert a node after target node.
60
+ * @param {Node} node_after
61
+ * @param {string} node_id
62
+ * @param {string} topic
63
+ * @param {Record<string, any>=} data
64
+ * @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)
65
+ * @returns {Node | null}
66
+ */
67
+ 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;
68
+ /**
69
+ * Get next sibling of a node or node id.
70
+ * @param {string | Node} node
71
+ * @returns {Node | null}
72
+ */
73
+ get_node_after(node: string | Node): Node | null;
74
+ /**
75
+ * Move a node to new parent/position.
76
+ * @param {Node} node
77
+ * @param {string=} before_id - The ID of the node before which to place the moved node. Special values: "_first_", "_last_"
78
+ * @param {string=} parent_id
79
+ * @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)
80
+ * @returns {Node | null}
81
+ */
82
+ move_node(node: Node, before_id?: string | undefined, parent_id?: string | undefined, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): Node | null;
83
+ /**
84
+ * Propagate direction to descendants.
85
+ * @param {Node} node
86
+ * @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)
87
+ */
88
+ _flow_node_direction(node: Node, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): void;
89
+ /**
90
+ * Re-index node among siblings based on before_id marker.
91
+ * @param {Node} node
92
+ * @param {string} before_id
93
+ * @returns {Node}
94
+ */
95
+ _move_node_internal(node: Node, before_id: string): Node;
96
+ /**
97
+ * Internal move implementation.
98
+ * @param {Node} node
99
+ * @param {string} before_id
100
+ * @param {string} parent_id
101
+ * @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)
102
+ * @returns {Node | null}
103
+ */
104
+ _move_node(node: Node, before_id: string, parent_id: string, direction?: ("left" | "center" | "right" | "-1" | "0" | "1" | number) | undefined): Node | null;
105
+ /**
106
+ * Remove a node from the mind.
107
+ * @param {Node} node
108
+ * @returns {boolean}
109
+ */
110
+ remove_node(node: Node): boolean;
111
+ /**
112
+ * Remove a node and its subtree from the cached selection set.
113
+ * @param {Node} node
114
+ * @private
115
+ */
116
+ private _purge_selection;
117
+ /**
118
+ * Put node into the map if id is not taken.
119
+ * @param {Node} node
120
+ * @returns {boolean}
121
+ */
122
+ _put_node(node: Node): boolean;
123
+ /**
124
+ * Re-index children by Node.compare.
125
+ * @param {Node} node
126
+ */
127
+ _update_index(node: Node): void;
128
+ }
129
+ 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,78 @@
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
+ selection?: {
64
+ enable_multi_select?: boolean;
65
+ include_descendants?: boolean;
66
+ filter?: (node: import("./jsmind.node.js").Node) => boolean;
67
+ };
68
+ fieldNames?: {
69
+ id?: string;
70
+ topic?: string;
71
+ children?: string;
72
+ parentid?: string;
73
+ isroot?: string;
74
+ direction?: string;
75
+ expanded?: string;
76
+ };
77
+ plugin?: Record<string, object>;
78
+ };
@@ -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
+ };