jsmind 0.5.3 → 0.5.5
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/README.md +4 -7
- package/docs/en/1.usage.md +8 -8
- package/docs/en/2.options.md +8 -3
- package/docs/en/3.operation.md +17 -4
- package/docs/zh/1.usage.md +7 -11
- package/docs/zh/2.options.md +6 -1
- package/docs/zh/3.operation.md +19 -5
- package/es6/jsmind.js +1 -1
- package/es6/jsmind.js.map +1 -1
- package/js/jsmind.js +41 -6
- package/package.json +1 -1
package/js/jsmind.js
CHANGED
|
@@ -68,7 +68,8 @@
|
|
|
68
68
|
layout: {
|
|
69
69
|
hspace: 30,
|
|
70
70
|
vspace: 20,
|
|
71
|
-
pspace: 13
|
|
71
|
+
pspace: 13,
|
|
72
|
+
cousin_space: 0
|
|
72
73
|
},
|
|
73
74
|
default_event_handle: {
|
|
74
75
|
enable_mousedown_handle: true,
|
|
@@ -115,7 +116,25 @@
|
|
|
115
116
|
};
|
|
116
117
|
|
|
117
118
|
// ============= static object =============================================
|
|
118
|
-
jm.direction = {
|
|
119
|
+
jm.direction = {
|
|
120
|
+
left: -1, center: 0, right: 1, of: function (dir) {
|
|
121
|
+
if (!dir || dir === -1 || dir === 0 || dir === 1) {
|
|
122
|
+
return dir;
|
|
123
|
+
}
|
|
124
|
+
if (dir === '-1' || dir === '0' || dir === '1') {
|
|
125
|
+
return parseInt(dir);
|
|
126
|
+
}
|
|
127
|
+
if (dir.toLowerCase() === 'left') {
|
|
128
|
+
return this.left;
|
|
129
|
+
}
|
|
130
|
+
if (dir.toLowerCase() === 'right') {
|
|
131
|
+
return this.right;
|
|
132
|
+
}
|
|
133
|
+
if (dir.toLowerCase() === 'center') {
|
|
134
|
+
return this.center;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
119
138
|
jm.event_type = { show: 1, resize: 2, edit: 3, select: 4 };
|
|
120
139
|
jm.key = { meta: 1 << 13, ctrl: 1 << 12, alt: 1 << 11, shift: 1 << 10 };
|
|
121
140
|
|
|
@@ -1015,7 +1034,8 @@
|
|
|
1015
1034
|
mode: opts.mode,
|
|
1016
1035
|
hspace: opts.layout.hspace,
|
|
1017
1036
|
vspace: opts.layout.vspace,
|
|
1018
|
-
pspace: opts.layout.pspace
|
|
1037
|
+
pspace: opts.layout.pspace,
|
|
1038
|
+
cousin_space: opts.layout.cousin_space
|
|
1019
1039
|
}
|
|
1020
1040
|
var opts_view = {
|
|
1021
1041
|
container: opts.container,
|
|
@@ -1291,7 +1311,10 @@
|
|
|
1291
1311
|
add_node: function (parent_node, nodeid, topic, data, direction) {
|
|
1292
1312
|
if (this.get_editable()) {
|
|
1293
1313
|
var the_parent_node = this.get_node(parent_node);
|
|
1294
|
-
var dir = direction
|
|
1314
|
+
var dir = jm.direction.of(direction)
|
|
1315
|
+
if (dir === undefined) {
|
|
1316
|
+
dir = this.layout.calculate_next_child_direction(the_parent_node);
|
|
1317
|
+
}
|
|
1295
1318
|
var node = this.mind.add_node(the_parent_node, nodeid, topic, data, dir);
|
|
1296
1319
|
if (!!node) {
|
|
1297
1320
|
this.view.add_node(node);
|
|
@@ -1311,7 +1334,10 @@
|
|
|
1311
1334
|
insert_node_before: function (node_before, nodeid, topic, data, direction) {
|
|
1312
1335
|
if (this.get_editable()) {
|
|
1313
1336
|
var the_node_before = this.get_node(node_before);
|
|
1314
|
-
var dir = direction
|
|
1337
|
+
var dir = jm.direction.of(direction)
|
|
1338
|
+
if (dir === undefined) {
|
|
1339
|
+
dir = this.layout.calculate_next_child_direction(the_node_before.parent);
|
|
1340
|
+
}
|
|
1315
1341
|
var node = this.mind.insert_node_before(the_node_before, nodeid, topic, data, dir);
|
|
1316
1342
|
if (!!node) {
|
|
1317
1343
|
this.view.add_node(node);
|
|
@@ -1329,7 +1355,10 @@
|
|
|
1329
1355
|
insert_node_after: function (node_after, nodeid, topic, data, direction) {
|
|
1330
1356
|
if (this.get_editable()) {
|
|
1331
1357
|
var the_node_after = this.get_node(node_after);
|
|
1332
|
-
var dir = direction
|
|
1358
|
+
var dir = jm.direction.of(direction)
|
|
1359
|
+
if (dir === undefined) {
|
|
1360
|
+
dir = this.layout.calculate_next_child_direction(the_node_after.parent);
|
|
1361
|
+
}
|
|
1333
1362
|
var node = this.mind.insert_node_after(the_node_after, nodeid, topic, data, dir);
|
|
1334
1363
|
if (!!node) {
|
|
1335
1364
|
this.view.add_node(node);
|
|
@@ -1852,6 +1881,9 @@
|
|
|
1852
1881
|
this.set_visible(node.children, false);
|
|
1853
1882
|
}
|
|
1854
1883
|
node_outer_height = Math.max(node._data.view.height, node_outer_height);
|
|
1884
|
+
if (node.children.length > 1) {
|
|
1885
|
+
node_outer_height += this.opts.cousin_space;
|
|
1886
|
+
}
|
|
1855
1887
|
|
|
1856
1888
|
layout_data.outer_height = node_outer_height;
|
|
1857
1889
|
layout_data.offset_y = base_y - node_outer_height / 2;
|
|
@@ -1897,6 +1929,9 @@
|
|
|
1897
1929
|
node_outer_height = 0;
|
|
1898
1930
|
}
|
|
1899
1931
|
node_outer_height = Math.max(node._data.view.height, node_outer_height);
|
|
1932
|
+
if (node.children.length > 1) {
|
|
1933
|
+
node_outer_height += this.opts.cousin_space;
|
|
1934
|
+
}
|
|
1900
1935
|
|
|
1901
1936
|
layout_data.outer_height = node_outer_height;
|
|
1902
1937
|
layout_data.offset_y = base_y - node_outer_height / 2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsmind",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
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": "js/jsmind.js",
|
|
6
6
|
"directories": {
|