jsmind 0.8.6 → 0.8.8-patch
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/LICENSE +2 -2
- package/README.md +2 -2
- package/es6/jsmind.draggable-node.js +2 -2
- package/es6/jsmind.draggable-node.js.map +1 -1
- package/es6/jsmind.js +2 -2
- package/es6/jsmind.js.map +1 -1
- package/es6/jsmind.screenshot.js +2 -2
- package/es6/jsmind.screenshot.js.map +1 -1
- package/package.json +32 -7
- package/style/jsmind.css +1 -1
- package/types/generated/index.d.ts +8 -0
- package/types/generated/jsmind.common.d.ts +66 -0
- package/types/generated/jsmind.d.ts +314 -0
- package/types/generated/jsmind.data_provider.d.ts +56 -0
- package/types/generated/jsmind.dom.d.ts +59 -0
- package/types/generated/jsmind.format.d.ts +100 -0
- package/types/generated/jsmind.graph.d.ts +180 -0
- package/types/generated/jsmind.layout_provider.d.ts +182 -0
- package/types/generated/jsmind.mind.d.ts +121 -0
- package/types/generated/jsmind.node.d.ts +62 -0
- package/types/generated/jsmind.option.d.ts +64 -0
- package/types/generated/jsmind.plugin.d.ts +21 -0
- package/types/generated/jsmind.shortcut_provider.d.ts +52 -0
- package/types/generated/jsmind.util.d.ts +26 -0
- package/types/generated/jsmind.view_provider.d.ts +347 -0
- package/types/generated/plugins/jsmind.draggable-node.d.ts +229 -0
- package/types/generated/plugins/jsmind.screenshot.d.ts +83 -0
- package/types/tsconfig.declaration.json +19 -0
- package/docs/en/1.usage.md +0 -243
- package/docs/en/2.options.md +0 -262
- package/docs/en/3.operation.md +0 -156
- package/docs/en/4.contribution.md +0 -40
- package/docs/en/5.development.md +0 -88
- package/docs/en/experimental-features.md +0 -27
- package/docs/en/index.md +0 -32
- package/docs/en/plugin-screenshot.md +0 -72
- package/docs/index.md +0 -19
- package/docs/zh/1.usage.md +0 -273
- package/docs/zh/2.options.md +0 -267
- package/docs/zh/3.operation.md +0 -159
- package/docs/zh/4.contribution.md +0 -43
- package/docs/zh/5.development.md +0 -81
- package/docs/zh/experimental-features.md +0 -27
- package/docs/zh/index.md +0 -32
- package/docs/zh/plugin-screenshot.md +0 -74
- package/example/1_basic.html +0 -77
- package/example/1_basic_cn.html +0 -77
- package/example/2_features.html +0 -211
- package/example/2_features.js +0 -462
- package/example/2_features_cn.html +0 -218
- package/example/3_requirejs.html +0 -59
- package/example/ant.png +0 -0
- package/example/data_example.json +0 -95
- package/example/demo.html +0 -107
- package/js/README.md +0 -7
- package/js-legacy/jsmind.draggable-node.js +0 -389
- package/js-legacy/jsmind.js +0 -3128
- package/js-legacy/jsmind.screenshot.js +0 -351
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Draggable node plugin for jsMind.
|
|
3
|
+
*/
|
|
4
|
+
export class DraggableNode {
|
|
5
|
+
/**
|
|
6
|
+
* Create draggable node plugin instance.
|
|
7
|
+
* @param {import('../jsmind.js').default} jm - jsMind instance
|
|
8
|
+
* @param {Partial<DraggableNodeOptions>} options - Plugin options
|
|
9
|
+
*/
|
|
10
|
+
constructor(jm: import("../jsmind.js").default, options: Partial<DraggableNodeOptions>);
|
|
11
|
+
version: string;
|
|
12
|
+
/** @type {import('../jsmind.js').default} */
|
|
13
|
+
jm: import("../jsmind.js").default;
|
|
14
|
+
/** @type {DraggableNodeOptions} */
|
|
15
|
+
options: DraggableNodeOptions;
|
|
16
|
+
/** @type {HTMLCanvasElement|null} */
|
|
17
|
+
e_canvas: HTMLCanvasElement | null;
|
|
18
|
+
/** @type {CanvasRenderingContext2D|null} */
|
|
19
|
+
canvas_ctx: CanvasRenderingContext2D | null;
|
|
20
|
+
/** @type {HTMLElement|null} */
|
|
21
|
+
shadow: HTMLElement | null;
|
|
22
|
+
/** @type {number} */
|
|
23
|
+
shadow_p_x: number;
|
|
24
|
+
/** @type {number} */
|
|
25
|
+
shadow_p_y: number;
|
|
26
|
+
/** @type {number} */
|
|
27
|
+
shadow_w: number;
|
|
28
|
+
/** @type {number} */
|
|
29
|
+
shadow_h: number;
|
|
30
|
+
/** @type {import('../jsmind.node.js').Node|null} */
|
|
31
|
+
active_node: import("../jsmind.node.js").Node | null;
|
|
32
|
+
/** @type {import('../jsmind.node.js').Node|null} */
|
|
33
|
+
target_node: import("../jsmind.node.js").Node | null;
|
|
34
|
+
/** @type {number|null} */
|
|
35
|
+
target_direct: number | null;
|
|
36
|
+
/** @type {number} */
|
|
37
|
+
client_w: number;
|
|
38
|
+
/** @type {number} */
|
|
39
|
+
client_h: number;
|
|
40
|
+
/** @type {number} */
|
|
41
|
+
offset_x: number;
|
|
42
|
+
/** @type {number} */
|
|
43
|
+
offset_y: number;
|
|
44
|
+
/** @type {number} */
|
|
45
|
+
hlookup_delay: number;
|
|
46
|
+
/** @type {number} */
|
|
47
|
+
hlookup_timer: number;
|
|
48
|
+
/** @type {boolean} */
|
|
49
|
+
capture: boolean;
|
|
50
|
+
/** @type {boolean} */
|
|
51
|
+
moved: boolean;
|
|
52
|
+
/** @type {boolean} */
|
|
53
|
+
canvas_draggable: boolean;
|
|
54
|
+
/** @type {HTMLElement} */
|
|
55
|
+
view_panel: HTMLElement;
|
|
56
|
+
/** @type {DOMRect|null} */
|
|
57
|
+
view_panel_rect: DOMRect | null;
|
|
58
|
+
/** Initialize the draggable node plugin. */
|
|
59
|
+
init(): void;
|
|
60
|
+
/** Resize canvas and shadow elements. */
|
|
61
|
+
resize(): void;
|
|
62
|
+
/** Create canvas for drawing drag lines. */
|
|
63
|
+
create_canvas(): void;
|
|
64
|
+
create_shadow(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Reset shadow element style and cache its size.
|
|
67
|
+
* @param {HTMLElement} el - The node element to mirror as shadow
|
|
68
|
+
*/
|
|
69
|
+
reset_shadow(el: HTMLElement): void;
|
|
70
|
+
/** Show the shadow element. */
|
|
71
|
+
show_shadow(): void;
|
|
72
|
+
/** Hide the shadow element. */
|
|
73
|
+
hide_shadow(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Draw a helper line between the shadow and target node.
|
|
76
|
+
* @param {{x:number,y:number}} shadow_p - Shadow anchor point
|
|
77
|
+
* @param {{x:number,y:number}} node_p - Target node anchor point
|
|
78
|
+
* @param {boolean} invalid - Whether current target is invalid
|
|
79
|
+
*/
|
|
80
|
+
magnet_shadow(shadow_p: {
|
|
81
|
+
x: number;
|
|
82
|
+
y: number;
|
|
83
|
+
}, node_p: {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
}, invalid: boolean): void;
|
|
87
|
+
/** Clear helper lines from canvas. */
|
|
88
|
+
clear_lines(): void;
|
|
89
|
+
/**
|
|
90
|
+
* Draw a straight helper line.
|
|
91
|
+
* @param {number} x1
|
|
92
|
+
* @param {number} y1
|
|
93
|
+
* @param {number} x2
|
|
94
|
+
* @param {number} y2
|
|
95
|
+
*/
|
|
96
|
+
canvas_lineto(x1: number, y1: number, x2: number, y2: number): void;
|
|
97
|
+
/** Bind mouse/touch events for dragging. */
|
|
98
|
+
event_bind(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Begin dragging interaction.
|
|
101
|
+
* @param {MouseEvent|TouchEvent} e - Pointer down event
|
|
102
|
+
*/
|
|
103
|
+
dragstart(e: MouseEvent | TouchEvent): void;
|
|
104
|
+
view_draggable: boolean;
|
|
105
|
+
client_hw: number;
|
|
106
|
+
client_hh: number;
|
|
107
|
+
/**
|
|
108
|
+
* Drag handler to move shadow and auto-scroll container.
|
|
109
|
+
* @param {MouseEvent|TouchEvent} e - Pointer move event
|
|
110
|
+
*/
|
|
111
|
+
drag(e: MouseEvent | TouchEvent): void;
|
|
112
|
+
/**
|
|
113
|
+
* Finish dragging, move the node if applicable.
|
|
114
|
+
* @param {MouseEvent|TouchEvent} e - Pointer up event
|
|
115
|
+
*/
|
|
116
|
+
dragend(e: MouseEvent | TouchEvent): void;
|
|
117
|
+
/**
|
|
118
|
+
* Find the closest node element from an event target.
|
|
119
|
+
* @param {HTMLElement} el - Current DOM element
|
|
120
|
+
* @returns {HTMLElement|null} Matched node element or null
|
|
121
|
+
*/
|
|
122
|
+
find_node_element(el: HTMLElement): HTMLElement | null;
|
|
123
|
+
/** Recompute target node under the shadow and draw helper. */
|
|
124
|
+
lookup_target_node(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Get X coordinate of root node center.
|
|
127
|
+
* @returns {number}
|
|
128
|
+
*/
|
|
129
|
+
get_root_x(): number;
|
|
130
|
+
/**
|
|
131
|
+
* Lookup overlapping node's parent near the shadow position.
|
|
132
|
+
* @param {number} direction - Direction constant
|
|
133
|
+
* @returns {import('../jsmind.node.js').Node|null}
|
|
134
|
+
*/
|
|
135
|
+
lookup_overlapping_node_parent(direction: number): import("../jsmind.node.js").Node | null;
|
|
136
|
+
/**
|
|
137
|
+
* Find node's parent by a screen location.
|
|
138
|
+
* @param {number} x - Client X
|
|
139
|
+
* @param {number} y - Client Y
|
|
140
|
+
* @returns {import('../jsmind.node.js').Node|null}
|
|
141
|
+
*/
|
|
142
|
+
lookup_node_parent_by_location(x: number, y: number): import("../jsmind.node.js").Node | null;
|
|
143
|
+
/**
|
|
144
|
+
* Lookup the closest node along a direction.
|
|
145
|
+
* @param {number} direction
|
|
146
|
+
* @returns {import('../jsmind.node.js').Node}
|
|
147
|
+
*/
|
|
148
|
+
lookup_close_node(direction: number): import("../jsmind.node.js").Node;
|
|
149
|
+
/**
|
|
150
|
+
* Check if shadow is on the target side of a node.
|
|
151
|
+
* @param {import('../jsmind.node.js').Node} node
|
|
152
|
+
* @param {number} dir
|
|
153
|
+
* @returns {boolean}
|
|
154
|
+
*/
|
|
155
|
+
shadow_on_target_side(node: import("../jsmind.node.js").Node, dir: number): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Distance from shadow to the right side of a node.
|
|
158
|
+
* @param {import('../jsmind.node.js').Node} node
|
|
159
|
+
* @returns {number}
|
|
160
|
+
*/
|
|
161
|
+
shadow_to_right_of_node(node: import("../jsmind.node.js").Node): number;
|
|
162
|
+
/**
|
|
163
|
+
* Distance from shadow to the left side of a node.
|
|
164
|
+
* @param {import('../jsmind.node.js').Node} node
|
|
165
|
+
* @returns {number}
|
|
166
|
+
*/
|
|
167
|
+
shadow_to_left_of_node(node: import("../jsmind.node.js").Node): number;
|
|
168
|
+
/**
|
|
169
|
+
* Vertical distance between shadow centerline and node centerline.
|
|
170
|
+
* @param {import('../jsmind.node.js').Node} node
|
|
171
|
+
* @returns {number}
|
|
172
|
+
*/
|
|
173
|
+
shadow_to_base_line_of_node(node: import("../jsmind.node.js").Node): number;
|
|
174
|
+
/**
|
|
175
|
+
* Manhattan distance to a node along a direction.
|
|
176
|
+
* @param {import('../jsmind.node.js').Node} node
|
|
177
|
+
* @param {number} dir
|
|
178
|
+
* @returns {number}
|
|
179
|
+
*/
|
|
180
|
+
shadow_to_node(node: import("../jsmind.node.js").Node, dir: number): number;
|
|
181
|
+
/**
|
|
182
|
+
* Calculate connection points of a node and the shadow.
|
|
183
|
+
* @param {import('../jsmind.node.js').Node} node
|
|
184
|
+
* @param {number} dir
|
|
185
|
+
* @returns {{sp:{x:number,y:number}, np:{x:number,y:number}}}
|
|
186
|
+
*/
|
|
187
|
+
calc_point_of_node(node: import("../jsmind.node.js").Node, dir: number): {
|
|
188
|
+
sp: {
|
|
189
|
+
x: number;
|
|
190
|
+
y: number;
|
|
191
|
+
};
|
|
192
|
+
np: {
|
|
193
|
+
x: number;
|
|
194
|
+
y: number;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Move a node to a new parent/position.
|
|
199
|
+
* @param {import('../jsmind.node.js').Node} src_node
|
|
200
|
+
* @param {import('../jsmind.node.js').Node|null} target_node
|
|
201
|
+
* @param {number|null} target_direct
|
|
202
|
+
*/
|
|
203
|
+
move_node(src_node: import("../jsmind.node.js").Node, target_node: import("../jsmind.node.js").Node | null, target_direct: number | null): void;
|
|
204
|
+
/**
|
|
205
|
+
* Handle jsMind events.
|
|
206
|
+
* @param {number|string} type - Event type
|
|
207
|
+
* @param {object} [data] - Event data
|
|
208
|
+
*/
|
|
209
|
+
jm_event_handle(type: number | string, data?: object): void;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Draggable node plugin registration.
|
|
213
|
+
* @type {import('../jsmind.plugin.js').Plugin<Partial<DraggableNodeOptions>>}
|
|
214
|
+
*/
|
|
215
|
+
export const draggable_plugin: import("../jsmind.plugin.js").Plugin<Partial<DraggableNodeOptions>>;
|
|
216
|
+
export default DraggableNode;
|
|
217
|
+
/**
|
|
218
|
+
* Default options for draggable node plugin.
|
|
219
|
+
*/
|
|
220
|
+
export type DraggableNodeOptions = {
|
|
221
|
+
line_width?: number;
|
|
222
|
+
line_color?: string;
|
|
223
|
+
line_color_invalid?: string;
|
|
224
|
+
lookup_delay?: number;
|
|
225
|
+
lookup_interval?: number;
|
|
226
|
+
scrolling_trigger_width?: number;
|
|
227
|
+
scrolling_step_length?: number;
|
|
228
|
+
shadow_node_class_name?: string;
|
|
229
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Screenshot plugin for jsMind.
|
|
3
|
+
*/
|
|
4
|
+
export class JmScreenshot {
|
|
5
|
+
/**
|
|
6
|
+
* Create screenshot plugin instance.
|
|
7
|
+
* @param {import('../jsmind.js').default} jm - jsMind instance
|
|
8
|
+
* @param {Partial<ScreenshotOptions>} options - Plugin options
|
|
9
|
+
*/
|
|
10
|
+
constructor(jm: import("../jsmind.js").default, options: Partial<ScreenshotOptions>);
|
|
11
|
+
version: string;
|
|
12
|
+
/** @type {import('../jsmind.js').default} */
|
|
13
|
+
jm: import("../jsmind.js").default;
|
|
14
|
+
/** @type {ScreenshotOptions} */
|
|
15
|
+
options: ScreenshotOptions;
|
|
16
|
+
/** @type {number} */
|
|
17
|
+
dpr: number;
|
|
18
|
+
/** Take a screenshot of the mind map. */
|
|
19
|
+
shoot(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Create canvas for screenshot.
|
|
22
|
+
* @returns {HTMLCanvasElement} Canvas element
|
|
23
|
+
*/
|
|
24
|
+
create_canvas(): HTMLCanvasElement;
|
|
25
|
+
/**
|
|
26
|
+
* Clean up canvas element.
|
|
27
|
+
* @param {HTMLCanvasElement} c - Canvas to remove
|
|
28
|
+
*/
|
|
29
|
+
clear(c: HTMLCanvasElement): void;
|
|
30
|
+
/**
|
|
31
|
+
* Draw background on canvas.
|
|
32
|
+
* @param {CanvasRenderingContext2D} ctx - Canvas context
|
|
33
|
+
* @returns {Promise<CanvasRenderingContext2D>} Promise resolving to context
|
|
34
|
+
*/
|
|
35
|
+
draw_background(ctx: CanvasRenderingContext2D): Promise<CanvasRenderingContext2D>;
|
|
36
|
+
/**
|
|
37
|
+
* Draw connection lines on canvas by copying from view graph.
|
|
38
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
39
|
+
* @returns {Promise<CanvasRenderingContext2D>}
|
|
40
|
+
*/
|
|
41
|
+
draw_lines(ctx: CanvasRenderingContext2D): Promise<CanvasRenderingContext2D>;
|
|
42
|
+
/**
|
|
43
|
+
* Draw node DOM into canvas via SVG snapshot.
|
|
44
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
45
|
+
* @returns {Promise<CanvasRenderingContext2D>}
|
|
46
|
+
*/
|
|
47
|
+
draw_nodes(ctx: CanvasRenderingContext2D): Promise<CanvasRenderingContext2D>;
|
|
48
|
+
/**
|
|
49
|
+
* Draw watermark text on canvas.
|
|
50
|
+
* @param {HTMLCanvasElement} c
|
|
51
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
52
|
+
* @returns {CanvasRenderingContext2D}
|
|
53
|
+
*/
|
|
54
|
+
draw_watermark(c: HTMLCanvasElement, ctx: CanvasRenderingContext2D): CanvasRenderingContext2D;
|
|
55
|
+
/**
|
|
56
|
+
* Load image from URL and resolve img element.
|
|
57
|
+
* @param {string} url
|
|
58
|
+
* @returns {Promise<HTMLImageElement>}
|
|
59
|
+
*/
|
|
60
|
+
load_image(url: string): Promise<HTMLImageElement>;
|
|
61
|
+
/**
|
|
62
|
+
* Trigger download of canvas content as PNG.
|
|
63
|
+
* @param {HTMLCanvasElement} c
|
|
64
|
+
*/
|
|
65
|
+
download(c: HTMLCanvasElement): void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Screenshot plugin registration.
|
|
69
|
+
* @type {import('../jsmind.plugin.js').Plugin<Partial<ScreenshotOptions>>}
|
|
70
|
+
*/
|
|
71
|
+
export const screenshot_plugin: import("../jsmind.plugin.js").Plugin<Partial<ScreenshotOptions>>;
|
|
72
|
+
export default JmScreenshot;
|
|
73
|
+
/**
|
|
74
|
+
* Default options for screenshot plugin.
|
|
75
|
+
*/
|
|
76
|
+
export type ScreenshotOptions = {
|
|
77
|
+
filename?: string | null;
|
|
78
|
+
watermark?: {
|
|
79
|
+
left?: string | Location;
|
|
80
|
+
right?: string;
|
|
81
|
+
};
|
|
82
|
+
background?: string;
|
|
83
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"strict": false,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"emitDeclarationOnly": true,
|
|
11
|
+
"stripInternal": true,
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"checkJs": false,
|
|
14
|
+
"rootDirs": ["../src"],
|
|
15
|
+
"outDir": "./generated",
|
|
16
|
+
"baseUrl": "."
|
|
17
|
+
},
|
|
18
|
+
"include" : ["../src/**/*.ts", "../src/**/*.js"]
|
|
19
|
+
}
|
package/docs/en/1.usage.md
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
[Table of Contents](index.md)
|
|
2
|
-
|
|
3
|
-
* [Usage *](1.usage.md)
|
|
4
|
-
* [Options](2.options.md)
|
|
5
|
-
* [Operation](3.operation.md)
|
|
6
|
-
* [Experimental Features](experimental-features.md)
|
|
7
|
-
* [Screenshot (Export as Image)](plugin-screenshot.md)
|
|
8
|
-
* [Contribution](4.contribution.md)
|
|
9
|
-
* [Development Guide](5.development.md)
|
|
10
|
-
|
|
11
|
-
1.1. Basic Framework
|
|
12
|
-
===
|
|
13
|
-
|
|
14
|
-
At first, 2 files (jsmind.css and jsmind.js) are required. Here we link to the resources on the CDN. It is recommended to use the latest version.
|
|
15
|
-
|
|
16
|
-
```html
|
|
17
|
-
<link type="text/css" rel="stylesheet" href="https://unpkg.com/jsmind@0.8.6/style/jsmind.css" />
|
|
18
|
-
|
|
19
|
-
<script type="text/javascript" src="https://unpkg.com/jsmind@0.8.6/es6/jsmind.js"></script>
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
> CDNs in common use: [UNPKG](https://unpkg.com/jsmind/), [jsDelivr](https://www.jsdelivr.com/package/npm/jsmind/), and [the mirror of jsDelivr in China](https://jsd.onmicrosoft.cn/npm/jsmind/). the resource urls would look like:
|
|
23
|
-
> - https://unpkg.com/jsmind@0.8.6/es6/jsmind.js
|
|
24
|
-
> - https://cdn.jsdelivr.net/npm/jsmind@0.8.6/es6/jsmind.js
|
|
25
|
-
> - https://jsd.onmicrosoft.cn/npm/jsmind@0.8.6/es6/jsmind.js
|
|
26
|
-
>
|
|
27
|
-
> The version number appear in the url of CDN. It's strongly recommended that you also specify the version number in your project to avoid the risks that caused by version upgrades. Access the [jsMind on NPM](https://www.npmjs.com/package/jsmind) to get the latest version number of jsMind.
|
|
28
|
-
|
|
29
|
-
Add script jsmind.draggable-node.js for enabling draggable node feature.
|
|
30
|
-
|
|
31
|
-
```html
|
|
32
|
-
<script type="text/javascript" src="https://unpkg.com/jsmind@0.8.6/es6/jsmind.draggable-node.js"></script>
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
The second, a div element should be in your HTML as container
|
|
36
|
-
|
|
37
|
-
```html
|
|
38
|
-
<div id="jsmind_container"></div>
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
The last, show an empty mindmap:
|
|
42
|
-
|
|
43
|
-
```html
|
|
44
|
-
<script type="text/javascript">
|
|
45
|
-
var options = { // for more detail at next chapter
|
|
46
|
-
container:'jsmind_container', // [required] id of container
|
|
47
|
-
editable:true, // [required] whether allow edit or not
|
|
48
|
-
theme:'orange' // [required] theme
|
|
49
|
-
};
|
|
50
|
-
var jm = new jsMind(options);
|
|
51
|
-
jm.show();
|
|
52
|
-
</script>
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Or, show a mindmap with some topics:
|
|
56
|
-
|
|
57
|
-
```html
|
|
58
|
-
<script type="text/javascript">
|
|
59
|
-
var mind = { /* jsMind data, for more detail at next section */ };
|
|
60
|
-
var options = {
|
|
61
|
-
container:'jsmind_container',
|
|
62
|
-
editable:true,
|
|
63
|
-
theme:'orange'
|
|
64
|
-
};
|
|
65
|
-
var jm = new jsMind(options);
|
|
66
|
-
// show it
|
|
67
|
-
jm.show(mind);
|
|
68
|
-
</script>
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
1.2. Data Format
|
|
72
|
-
===
|
|
73
|
-
|
|
74
|
-
3 formats are supported by jsMind: `node_tree`,`node_array` and `freemind`. jsMind can load mind maps in these formats, and can also export data to any of these formats.
|
|
75
|
-
|
|
76
|
-
These are simple demo for the data format:
|
|
77
|
-
|
|
78
|
-
A. `node_tree` format, default format in jsMind
|
|
79
|
-
|
|
80
|
-
```javascript
|
|
81
|
-
var mind = {
|
|
82
|
-
"meta":{
|
|
83
|
-
"name":"jsMind remote",
|
|
84
|
-
"author":"hizzgdev@163.com",
|
|
85
|
-
"version":"0.2"
|
|
86
|
-
},
|
|
87
|
-
"format":"node_tree",
|
|
88
|
-
"data":{"id":"root","topic":"jsMind","children":[
|
|
89
|
-
{"id":"easy","topic":"Easy","direction":"left","children":[
|
|
90
|
-
{"id":"easy1","topic":"Easy to show"},
|
|
91
|
-
{"id":"easy2","topic":"Easy to edit"},
|
|
92
|
-
{"id":"easy3","topic":"Easy to store"},
|
|
93
|
-
{"id":"easy4","topic":"Easy to embed"}
|
|
94
|
-
]},
|
|
95
|
-
{"id":"open","topic":"Open Source","direction":"right","children":[
|
|
96
|
-
{"id":"open1","topic":"on GitHub"},
|
|
97
|
-
{"id":"open2","topic":"BSD License"}
|
|
98
|
-
]},
|
|
99
|
-
{"id":"powerful","topic":"Powerful","direction":"right","children":[
|
|
100
|
-
{"id":"powerful1","topic":"Base on Javascript"},
|
|
101
|
-
{"id":"powerful2","topic":"Base on HTML5"},
|
|
102
|
-
{"id":"powerful3","topic":"Depends on you"}
|
|
103
|
-
]},
|
|
104
|
-
{"id":"other","topic":"test node","direction":"left","children":[
|
|
105
|
-
{"id":"other1","topic":"I'm from local variable"},
|
|
106
|
-
{"id":"other2","topic":"I can do everything"}
|
|
107
|
-
]}
|
|
108
|
-
]}
|
|
109
|
-
};
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
B. `node_array` format
|
|
113
|
-
|
|
114
|
-
```javascript
|
|
115
|
-
var mind = {
|
|
116
|
-
"meta":{
|
|
117
|
-
"name":"example",
|
|
118
|
-
"author":"hizzgdev@163.com",
|
|
119
|
-
"version":"0.2"
|
|
120
|
-
},
|
|
121
|
-
"format":"node_array",
|
|
122
|
-
"data":[
|
|
123
|
-
{"id":"root", "isroot":true, "topic":"jsMind"},
|
|
124
|
-
|
|
125
|
-
{"id":"easy", "parentid":"root", "topic":"Easy", "direction":"left"},
|
|
126
|
-
{"id":"easy1", "parentid":"easy", "topic":"Easy to show"},
|
|
127
|
-
{"id":"easy2", "parentid":"easy", "topic":"Easy to edit"},
|
|
128
|
-
{"id":"easy3", "parentid":"easy", "topic":"Easy to store"},
|
|
129
|
-
{"id":"easy4", "parentid":"easy", "topic":"Easy to embed"},
|
|
130
|
-
|
|
131
|
-
{"id":"open", "parentid":"root", "topic":"Open Source", "direction":"right"},
|
|
132
|
-
{"id":"open1", "parentid":"open", "topic":"on GitHub"},
|
|
133
|
-
{"id":"open2", "parentid":"open", "topic":"BSD License"},
|
|
134
|
-
|
|
135
|
-
{"id":"powerful", "parentid":"root", "topic":"Powerful", "direction":"right"},
|
|
136
|
-
{"id":"powerful1", "parentid":"powerful", "topic":"Base on Javascript"},
|
|
137
|
-
{"id":"powerful2", "parentid":"powerful", "topic":"Base on HTML5"},
|
|
138
|
-
{"id":"powerful3", "parentid":"powerful", "topic":"Depends on you"},
|
|
139
|
-
]
|
|
140
|
-
};
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
C. `freemind` format
|
|
144
|
-
|
|
145
|
-
```javascript
|
|
146
|
-
var mind = {
|
|
147
|
-
"meta":{
|
|
148
|
-
"name":"example",
|
|
149
|
-
"author":"hizzgdev@163.com",
|
|
150
|
-
"version":"0.2"
|
|
151
|
-
},
|
|
152
|
-
"format":"freemind",
|
|
153
|
-
"data":"<map version=\"1.0.1\"> <node ID=\"root\" TEXT=\"jsMind\" > <node ID=\"easy\" POSITION=\"left\" TEXT=\"Easy\" > <node ID=\"easy1\" TEXT=\"Easy to show\" /> <node ID=\"easy2\" TEXT=\"Easy to edit\" /> <node ID=\"easy3\" TEXT=\"Easy to store\" /> <node ID=\"easy4\" TEXT=\"Easy to embed\" /> </node> <node ID=\"open\" POSITION=\"right\" TEXT=\"Open Source\" > <node ID=\"open1\" TEXT=\"on GitHub\" /> <node ID=\"open2\" TEXT=\"BSD License\" /> </node> <node ID=\"powerful\" POSITION=\"right\" TEXT=\"Powerful\" > <node ID=\"powerful1\" TEXT=\"Base on Javascript\" /> <node ID=\"powerful2\" TEXT=\"Base on HTML5\" /> <node ID=\"powerful3\" TEXT=\"Depends on you\" /> </node> <node ID=\"other\" POSITION=\"left\" TEXT=\"test node\" > <node ID=\"other1\" TEXT=\"I'm from local variable\" /> <node ID=\"other2\" TEXT=\"I can do everything\" /> </node> </node> </map>"
|
|
154
|
-
};
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
1.3. Themes
|
|
158
|
-
===
|
|
159
|
-
|
|
160
|
-
15 themes were supported in jsmind, you can preview those themes by visiting [feature-demo](http://hizzgdev.github.io/jsmind/example/2_features.html).
|
|
161
|
-
|
|
162
|
-
+ primary
|
|
163
|
-
+ warning
|
|
164
|
-
+ danger
|
|
165
|
-
+ success
|
|
166
|
-
+ info
|
|
167
|
-
+ greensea
|
|
168
|
-
+ nephrite
|
|
169
|
-
+ belizehole
|
|
170
|
-
+ wisteria
|
|
171
|
-
+ asphalt
|
|
172
|
-
+ orange
|
|
173
|
-
+ pumpkin
|
|
174
|
-
+ pomegranate
|
|
175
|
-
+ clouds
|
|
176
|
-
+ asbestos
|
|
177
|
-
|
|
178
|
-
or, you can add your custom theme in jsmind.css.
|
|
179
|
-
|
|
180
|
-
```css
|
|
181
|
-
/* greensea theme */
|
|
182
|
-
jmnodes.theme-greensea jmnode{background-color:#1abc9c;color:#fff;}
|
|
183
|
-
jmnodes.theme-greensea jmnode:hover{background-color:#16a085;}
|
|
184
|
-
jmnodes.theme-greensea jmnode.selected{background-color:#11f;color:#fff;}
|
|
185
|
-
jmnodes.theme-greensea jmnode.root{}
|
|
186
|
-
jmnodes.theme-greensea jmexpander{}
|
|
187
|
-
jmnodes.theme-greensea jmexpander:hover{}
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
1.4. Styles
|
|
191
|
-
===
|
|
192
|
-
|
|
193
|
-
In addition to the Themes, there are some styles can be set at node level:
|
|
194
|
-
|
|
195
|
-
* background-color: the background color of a node, e.g. `#1abc9c`, `blue`
|
|
196
|
-
* foreground-color: the foreground color of a node, e.g. `#1abc9c`, `blue`
|
|
197
|
-
* width: node width (px), e.g. `400`
|
|
198
|
-
* height: node height (px), e.g. `400`
|
|
199
|
-
* font-size: font size of the topic of a node (px), e.g. `32`
|
|
200
|
-
* font-weight: font weight of the topic of a node, e.g. `bold`
|
|
201
|
-
* font-style: font style of the topic of a node, e.g.`italic`
|
|
202
|
-
* background-image: background image url e.g. `http://fakeurl.com/fake-picture.png`, or a data url, e.g. `data:image/png;base64,...`
|
|
203
|
-
* background-rotation: the rotation of the background image, e.g. `30`
|
|
204
|
-
* leading-line-color: the color of the leading line of a node, e.g. `#1abc9c`, `blue`
|
|
205
|
-
|
|
206
|
-
How to set:
|
|
207
|
-
|
|
208
|
-
* set by api: add the settings to the `data` parameter of `add_node` [[3.4. Operation - Add Node](3.operation.md)]
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
```javascript
|
|
212
|
-
let data = {'width': 400, 'leading-line-color': '#33ff33'}
|
|
213
|
-
jm.add_node(....., data)
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
* set on data define (data file): add the settings to `node`, e.g.
|
|
217
|
-
|
|
218
|
-
```javascript
|
|
219
|
-
|
|
220
|
-
var mind = {
|
|
221
|
-
...
|
|
222
|
-
format: 'node_tree',
|
|
223
|
-
data: {
|
|
224
|
-
id: 'root',
|
|
225
|
-
topic: 'jsMind',
|
|
226
|
-
children: [
|
|
227
|
-
{
|
|
228
|
-
'id': 'image-node',
|
|
229
|
-
'background-image': 'ant.png',
|
|
230
|
-
'width': '100',
|
|
231
|
-
'height': '100',
|
|
232
|
-
}
|
|
233
|
-
],
|
|
234
|
-
...
|
|
235
|
-
}
|
|
236
|
-
```
|
|
237
|
-
copyright notice
|
|
238
|
-
===
|
|
239
|
-
|
|
240
|
-
Reproduction and deduction are prohibited.
|
|
241
|
-
|
|
242
|
-
The jsMind project is still being updated and the corresponding documentation is updated at the same time as the version is updated. In order to avoid confusion to the user, it is forbidden to reprint this document without written permission and to make changes of any kind to this document.
|
|
243
|
-
|