jsmind 0.4.8 → 0.4.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/js/jsmind.js CHANGED
@@ -1,6 +1,6 @@
1
- /*
2
- * Released under BSD License
3
- * Copyright (c) 2014-2021 hizzgdev@163.com
1
+ /**
2
+ * @license BSD
3
+ * @copyright 2014-2022 hizzgdev@163.com
4
4
  *
5
5
  * Project Home:
6
6
  * https://github.com/hizzgdev/jsmind/
@@ -12,7 +12,7 @@
12
12
  // __name__ should be a const value, Never try to change it easily.
13
13
  var __name__ = 'jsMind';
14
14
  // library version
15
- var __version__ = '0.4.8';
15
+ var __version__ = '0.4.10';
16
16
  // author
17
17
  var __author__ = 'hizzgdev@163.com';
18
18
 
@@ -107,7 +107,7 @@
107
107
  return;
108
108
  }
109
109
  this.options = opts;
110
- this.inited = false;
110
+ this.initialized = false;
111
111
  this.mind = null;
112
112
  this.event_handles = [];
113
113
  this.init();
@@ -119,7 +119,7 @@
119
119
  jm.key = { meta: 1 << 13, ctrl: 1 << 12, alt: 1 << 11, shift: 1 << 10 };
120
120
 
121
121
  jm.node = function (sId, iIndex, sTopic, oData, bIsRoot, oParent, eDirection, bExpanded) {
122
- if (!sId) { logger.error('invalid nodeid'); return; }
122
+ if (!sId) { logger.error('invalid node id'); return; }
123
123
  if (typeof iIndex != 'number') { logger.error('invalid node index'); return; }
124
124
  if (typeof bExpanded === 'undefined') { bExpanded = true; }
125
125
  this.id = sId;
@@ -174,6 +174,10 @@
174
174
  return false;
175
175
  };
176
176
 
177
+ jm.node.is_node = function (n) {
178
+ return !!n && n instanceof jm.node;
179
+ };
180
+
177
181
  jm.node.prototype = {
178
182
  get_location: function () {
179
183
  var vd = this._data.view;
@@ -215,39 +219,22 @@
215
219
  if (this.root == null) {
216
220
  this.root = new jm.node(nodeid, 0, topic, data, true);
217
221
  this._put_node(this.root);
222
+ return this.root;
218
223
  } else {
219
224
  logger.error('root node is already exist');
225
+ return null;
220
226
  }
221
227
  },
222
228
 
223
- add_node: function (parent_node, nodeid, topic, data, idx, direction, expanded) {
229
+ add_node: function (parent_node, nodeid, topic, data, direction, expanded, idx) {
224
230
  if (!jm.util.is_node(parent_node)) {
225
- var the_parent_node = this.get_node(parent_node);
226
- if (!the_parent_node) {
227
- logger.error('the parent_node[id=' + parent_node + '] can not be found.');
228
- return null;
229
- } else {
230
- return this.add_node(the_parent_node, nodeid, topic, data, idx, direction, expanded);
231
- }
231
+ logger.error('the parent_node ' + parent_node + ' is not a node.');
232
+ return null;
232
233
  }
233
- var nodeindex = idx || -1;
234
- var node = null;
234
+ var node_index = idx || -1;
235
+ var node = new jm.node(nodeid, node_index, topic, data, false, parent_node, parent_node.direction, expanded);
235
236
  if (parent_node.isroot) {
236
- var d = jm.direction.right;
237
- if (isNaN(direction)) {
238
- if (jm.current.options.mode !== 'side') {
239
- var children = parent_node.children;
240
- var children_len = children.length;
241
- var r = 0;
242
- for (var i = 0; i < children_len; i++) { if (children[i].direction === jm.direction.left) { r--; } else { r++; } }
243
- d = (children_len > 1 && r > 0) ? jm.direction.left : jm.direction.right;
244
- }
245
- } else {
246
- d = (direction != jm.direction.left) ? jm.direction.right : jm.direction.left;
247
- }
248
- node = new jm.node(nodeid, nodeindex, topic, data, false, parent_node, d, expanded);
249
- } else {
250
- node = new jm.node(nodeid, nodeindex, topic, data, false, parent_node, parent_node.direction, expanded);
237
+ node.direction = direction || jm.direction.right;
251
238
  }
252
239
  if (this._put_node(node)) {
253
240
  parent_node.children.push(node);
@@ -259,18 +246,13 @@
259
246
  return node;
260
247
  },
261
248
 
262
- insert_node_before: function (node_before, nodeid, topic, data) {
249
+ insert_node_before: function (node_before, nodeid, topic, data, direction) {
263
250
  if (!jm.util.is_node(node_before)) {
264
- var the_node_before = this.get_node(node_before);
265
- if (!the_node_before) {
266
- logger.error('the node_before[id=' + node_before + '] can not be found.');
267
- return null;
268
- } else {
269
- return this.insert_node_before(the_node_before, nodeid, topic, data);
270
- }
251
+ logger.error('the node_before ' + node_before + ' is not a node.');
252
+ return null;
271
253
  }
272
254
  var node_index = node_before.index - 0.5;
273
- return this.add_node(node_before.parent, nodeid, topic, data, node_index);
255
+ return this.add_node(node_before.parent, nodeid, topic, data, direction, true, node_index);
274
256
  },
275
257
 
276
258
  get_node_before: function (node) {
@@ -292,18 +274,13 @@
292
274
  }
293
275
  },
294
276
 
295
- insert_node_after: function (node_after, nodeid, topic, data) {
277
+ insert_node_after: function (node_after, nodeid, topic, data, direction) {
296
278
  if (!jm.util.is_node(node_after)) {
297
- var the_node_after = this.get_node(node_after);
298
- if (!the_node_after) {
299
- logger.error('the node_after[id=' + node_after + '] can not be found.');
300
- return null;
301
- } else {
302
- return this.insert_node_after(the_node_after, nodeid, topic, data);
303
- }
279
+ logger.error('the node_after ' + node_after + ' is not a node.');
280
+ return null;
304
281
  }
305
282
  var node_index = node_after.index + 0.5;
306
- return this.add_node(node_after.parent, nodeid, topic, data, node_index);
283
+ return this.add_node(node_after.parent, nodeid, topic, data, direction, true, node_index);
307
284
  },
308
285
 
309
286
  get_node_after: function (node) {
@@ -319,27 +296,22 @@
319
296
  if (node.isroot) { return null; }
320
297
  var idx = node.index;
321
298
  var brothers = node.parent.children;
322
- if (brothers.length >= idx) {
299
+ if (brothers.length > idx) {
323
300
  return node.parent.children[idx];
324
301
  } else {
325
302
  return null;
326
303
  }
327
304
  },
328
305
 
329
- move_node: function (node, beforeid, parentid, direction) {
306
+ move_node: function (node, before_id, parent_id, direction) {
330
307
  if (!jm.util.is_node(node)) {
331
- var the_node = this.get_node(node);
332
- if (!the_node) {
333
- logger.error('the node[id=' + node + '] can not be found.');
334
- return null;
335
- } else {
336
- return this.move_node(the_node, beforeid, parentid, direction);
337
- }
308
+ logger.error('the parameter node ' + node + ' is not a node.');
309
+ return null;
338
310
  }
339
- if (!parentid) {
340
- parentid = node.parent.id;
311
+ if (!parent_id) {
312
+ parent_id = node.parent.id;
341
313
  }
342
- return this._move_node(node, beforeid, parentid, direction);
314
+ return this._move_node(node, before_id, parent_id, direction);
343
315
  },
344
316
 
345
317
  _flow_node_direction: function (node, direction) {
@@ -375,6 +347,11 @@
375
347
 
376
348
  _move_node: function (node, beforeid, parentid, direction) {
377
349
  if (!!node && !!parentid) {
350
+ var parent_node = this.get_node(parentid)
351
+ if (jm.node.inherited(node, parent_node)) {
352
+ logger.error('can not move a node to its children');
353
+ return null;
354
+ }
378
355
  if (node.parent.id != parentid) {
379
356
  // remove from parent's children
380
357
  var sibling = node.parent.children;
@@ -385,8 +362,8 @@
385
362
  break;
386
363
  }
387
364
  }
388
- node.parent = this.get_node(parentid);
389
- node.parent.children.push(node);
365
+ node.parent = parent_node;
366
+ parent_node.children.push(node);
390
367
  }
391
368
 
392
369
  if (node.parent.isroot) {
@@ -406,16 +383,7 @@
406
383
 
407
384
  remove_node: function (node) {
408
385
  if (!jm.util.is_node(node)) {
409
- var the_node = this.get_node(node);
410
- if (!the_node) {
411
- logger.error('the node[id=' + node + '] can not be found.');
412
- return false;
413
- } else {
414
- return this.remove_node(the_node);
415
- }
416
- }
417
- if (!node) {
418
- logger.error('fail, the node can not be found');
386
+ logger.error('the parameter node ' + node + ' is not a node.');
419
387
  return false;
420
388
  }
421
389
  if (node.isroot) {
@@ -537,7 +505,7 @@
537
505
  if (node_parent.isroot) {
538
506
  d = node_json.direction == 'left' ? jm.direction.left : jm.direction.right;
539
507
  }
540
- var node = mind.add_node(node_parent, node_json.id, node_json.topic, data, null, d, node_json.expanded);
508
+ var node = mind.add_node(node_parent, node_json.id, node_json.topic, data, d, node_json.expanded);
541
509
  if (!!node_json['children']) {
542
510
  var children = node_json.children;
543
511
  for (var i = 0; i < children.length; i++) {
@@ -616,9 +584,9 @@
616
584
  var narray = node_array.slice(0);
617
585
  // reverse array for improving looping performance
618
586
  narray.reverse();
619
- var root_id = df._extract_root(mind, narray);
620
- if (!!root_id) {
621
- df._extract_subnode(mind, root_id, narray);
587
+ var root_node = df._extract_root(mind, narray);
588
+ if (!!root_node) {
589
+ df._extract_subnode(mind, root_node, narray);
622
590
  } else {
623
591
  logger.error('root node can not be found');
624
592
  }
@@ -631,15 +599,15 @@
631
599
  if ('isroot' in node_array[i] && node_array[i].isroot) {
632
600
  var root_json = node_array[i];
633
601
  var data = df._extract_data(root_json);
634
- mind.set_root(root_json.id, root_json.topic, data);
602
+ var node = mind.set_root(root_json.id, root_json.topic, data);
635
603
  node_array.splice(i, 1);
636
- return root_json.id;
604
+ return node;
637
605
  }
638
606
  }
639
607
  return null;
640
608
  },
641
609
 
642
- _extract_subnode: function (mind, parentid, node_array) {
610
+ _extract_subnode: function (mind, parent_node, node_array) {
643
611
  var df = jm.format.node_array;
644
612
  var i = node_array.length;
645
613
  var node_json = null;
@@ -647,17 +615,17 @@
647
615
  var extract_count = 0;
648
616
  while (i--) {
649
617
  node_json = node_array[i];
650
- if (node_json.parentid == parentid) {
618
+ if (node_json.parentid == parent_node.id) {
651
619
  data = df._extract_data(node_json);
652
620
  var d = null;
653
621
  var node_direction = node_json.direction;
654
622
  if (!!node_direction) {
655
623
  d = node_direction == 'left' ? jm.direction.left : jm.direction.right;
656
624
  }
657
- mind.add_node(parentid, node_json.id, node_json.topic, data, null, d, node_json.expanded);
625
+ var node = mind.add_node(parent_node, node_json.id, node_json.topic, data, d, node_json.expanded);
658
626
  node_array.splice(i, 1);
659
627
  extract_count++;
660
- var sub_extract_count = df._extract_subnode(mind, node_json.id, node_array);
628
+ var sub_extract_count = df._extract_subnode(mind, node, node_array);
661
629
  if (sub_extract_count > 0) {
662
630
  // reset loop index after extract subordinate node
663
631
  i = node_array.length;
@@ -794,7 +762,7 @@
794
762
  return node;
795
763
  },
796
764
 
797
- _load_node: function (mind, parent_id, xml_node) {
765
+ _load_node: function (mind, parent_node, xml_node) {
798
766
  var df = jm.format.freemind;
799
767
  var node_id = xml_node.getAttribute('ID');
800
768
  var node_topic = xml_node.getAttribute('TEXT');
@@ -821,17 +789,18 @@
821
789
  node_direction = node_position == 'left' ? jm.direction.left : jm.direction.right;
822
790
  }
823
791
  //logger.debug(node_position +':'+ node_direction);
824
- if (!!parent_id) {
825
- mind.add_node(parent_id, node_id, node_topic, node_data, null, node_direction, node_expanded);
792
+ var node = null;
793
+ if (!!parent_node) {
794
+ node = mind.add_node(parent_node, node_id, node_topic, node_data, node_direction, node_expanded);
826
795
  } else {
827
- mind.set_root(node_id, node_topic, node_data);
796
+ node = mind.set_root(node_id, node_topic, node_data);
828
797
  }
829
798
  var children = xml_node.childNodes;
830
799
  var child = null;
831
800
  for (var i = 0; i < children.length; i++) {
832
801
  child = children[i];
833
802
  if (child.nodeType == 1 && child.tagName == 'node') {
834
- df._load_node(mind, node_id, child);
803
+ df._load_node(mind, node, child);
835
804
  }
836
805
  }
837
806
  },
@@ -891,31 +860,17 @@
891
860
  return !!node && node instanceof jm.node;
892
861
  },
893
862
  ajax: {
894
- _xhr: function () {
895
- var xhr = null;
896
- if (window.XMLHttpRequest) {
897
- xhr = new XMLHttpRequest();
898
- } else {
899
- try {
900
- xhr = new ActiveXObject('Microsoft.XMLHTTP');
901
- } catch (e) { }
902
- }
903
- return xhr;
904
- },
905
- _eurl: function (url) {
906
- return encodeURIComponent(url);
907
- },
908
863
  request: function (url, param, method, callback, fail_callback) {
909
864
  var a = jm.util.ajax;
910
865
  var p = null;
911
866
  var tmp_param = [];
912
867
  for (var k in param) {
913
- tmp_param.push(a._eurl(k) + '=' + a._eurl(param[k]));
868
+ tmp_param.push(encodeURIComponent(k) + '=' + encodeURIComponent(param[k]));
914
869
  }
915
870
  if (tmp_param.length > 0) {
916
871
  p = tmp_param.join('&');
917
872
  }
918
- var xhr = a._xhr();
873
+ var xhr = new XMLHttpRequest();
919
874
  if (!xhr) { return; }
920
875
  xhr.onreadystatechange = function () {
921
876
  if (xhr.readyState == 4) {
@@ -1011,28 +966,10 @@
1011
966
 
1012
967
  json: {
1013
968
  json2string: function (json) {
1014
- if (!!JSON) {
1015
- try {
1016
- var json_str = JSON.stringify(json);
1017
- return json_str;
1018
- } catch (e) {
1019
- logger.warn(e);
1020
- logger.warn('can not convert to string');
1021
- return null;
1022
- }
1023
- }
969
+ return JSON.stringify(json);
1024
970
  },
1025
971
  string2json: function (json_str) {
1026
- if (!!JSON) {
1027
- try {
1028
- var json = JSON.parse(json_str);
1029
- return json;
1030
- } catch (e) {
1031
- logger.warn(e);
1032
- logger.warn('can not parse to json');
1033
- return null;
1034
- }
1035
- }
972
+ return JSON.parse(json_str);
1036
973
  },
1037
974
  merge: function (b, a) {
1038
975
  for (var o in a) {
@@ -1054,7 +991,7 @@
1054
991
 
1055
992
  uuid: {
1056
993
  newid: function () {
1057
- return (new Date().getTime().toString(16) + Math.random().toString(16).substr(2)).substr(2, 16);
994
+ return (new Date().getTime().toString(16) + Math.random().toString(16).substring(2)).substring(2, 18);
1058
995
  }
1059
996
  },
1060
997
 
@@ -1068,8 +1005,8 @@
1068
1005
 
1069
1006
  jm.prototype = {
1070
1007
  init: function () {
1071
- if (this.inited) { return; }
1072
- this.inited = true;
1008
+ if (this.initialized) { return; }
1009
+ this.initialized = true;
1073
1010
 
1074
1011
  var opts = this.options;
1075
1012
 
@@ -1188,7 +1125,7 @@
1188
1125
  },
1189
1126
 
1190
1127
  // Use [Ctrl] + Mousewheel, to zoom in/out.
1191
- mousewheel_handle: function(event) {
1128
+ mousewheel_handle: function (event) {
1192
1129
  // Test if mousewheel option is enabled and Ctrl key is pressed.
1193
1130
  if (!this.options.default_event_handle["enable_mousewheel_handle"] || !window.event.ctrlKey) {
1194
1131
  return
@@ -1343,20 +1280,25 @@
1343
1280
  return this.mind.root;
1344
1281
  },
1345
1282
 
1346
- get_node: function (nodeid) {
1347
- return this.mind.get_node(nodeid);
1283
+ get_node: function (node) {
1284
+ if (jm.util.is_node(node)) {
1285
+ return node;
1286
+ }
1287
+ return this.mind.get_node(node);
1348
1288
  },
1349
1289
 
1350
1290
  add_node: function (parent_node, nodeid, topic, data) {
1351
1291
  if (this.get_editable()) {
1352
- var node = this.mind.add_node(parent_node, nodeid, topic, data);
1292
+ var the_parent_node = this.get_node(parent_node);
1293
+ var direction = this.layout.calculate_next_child_direction(the_parent_node);
1294
+ var node = this.mind.add_node(the_parent_node, nodeid, topic, data, direction);
1353
1295
  if (!!node) {
1354
1296
  this.view.add_node(node);
1355
1297
  this.layout.layout();
1356
1298
  this.view.show(false);
1357
1299
  this.view.reset_node_custom_style(node);
1358
- this.expand_node(parent_node);
1359
- this.invoke_event_handle(jm.event_type.edit, { evt: 'add_node', data: [parent_node.id, nodeid, topic, data], node: nodeid });
1300
+ this.expand_node(the_parent_node);
1301
+ this.invoke_event_handle(jm.event_type.edit, { evt: 'add_node', data: [the_parent_node.id, nodeid, topic, data], node: nodeid });
1360
1302
  }
1361
1303
  return node;
1362
1304
  } else {
@@ -1367,13 +1309,14 @@
1367
1309
 
1368
1310
  insert_node_before: function (node_before, nodeid, topic, data) {
1369
1311
  if (this.get_editable()) {
1370
- var beforeid = jm.util.is_node(node_before) ? node_before.id : node_before;
1371
- var node = this.mind.insert_node_before(node_before, nodeid, topic, data);
1312
+ var the_node_before = this.get_node(node_before);
1313
+ var direction = this.layout.calculate_next_child_direction(the_node_before.parent);
1314
+ var node = this.mind.insert_node_before(the_node_before, nodeid, topic, data, direction);
1372
1315
  if (!!node) {
1373
1316
  this.view.add_node(node);
1374
1317
  this.layout.layout();
1375
1318
  this.view.show(false);
1376
- this.invoke_event_handle(jm.event_type.edit, { evt: 'insert_node_before', data: [beforeid, nodeid, topic, data], node: nodeid });
1319
+ this.invoke_event_handle(jm.event_type.edit, { evt: 'insert_node_before', data: [the_node_before.id, nodeid, topic, data], node: nodeid });
1377
1320
  }
1378
1321
  return node;
1379
1322
  } else {
@@ -1384,13 +1327,14 @@
1384
1327
 
1385
1328
  insert_node_after: function (node_after, nodeid, topic, data) {
1386
1329
  if (this.get_editable()) {
1387
- var afterid = jm.util.is_node(node_after) ? node_after.id : node_after;
1388
- var node = this.mind.insert_node_after(node_after, nodeid, topic, data);
1330
+ var the_node_after = this.get_node(node_after);
1331
+ var direction = this.layout.calculate_next_child_direction(the_node_after.parent);
1332
+ var node = this.mind.insert_node_after(the_node_after, nodeid, topic, data, direction);
1389
1333
  if (!!node) {
1390
1334
  this.view.add_node(node);
1391
1335
  this.layout.layout();
1392
1336
  this.view.show(false);
1393
- this.invoke_event_handle(jm.event_type.edit, { evt: 'insert_node_after', data: [afterid, nodeid, topic, data], node: nodeid });
1337
+ this.invoke_event_handle(jm.event_type.edit, { evt: 'insert_node_after', data: [the_node_after.id, nodeid, topic, data], node: nodeid });
1394
1338
  }
1395
1339
  return node;
1396
1340
  } else {
@@ -1458,9 +1402,10 @@
1458
1402
 
1459
1403
  move_node: function (nodeid, beforeid, parentid, direction) {
1460
1404
  if (this.get_editable()) {
1461
- var node = this.mind.move_node(nodeid, beforeid, parentid, direction);
1462
- if (!!node) {
1463
- this.view.update_node(node);
1405
+ var node = this.get_node(nodeid);
1406
+ var updated_node = this.mind.move_node(node, beforeid, parentid, direction);
1407
+ if (!!updated_node) {
1408
+ this.view.update_node(updated_node);
1464
1409
  this.layout.layout();
1465
1410
  this.view.show(false);
1466
1411
  this.invoke_event_handle(jm.event_type.edit, { evt: 'move_node', data: [nodeid, beforeid, parentid, direction], node: nodeid });
@@ -1763,10 +1708,23 @@
1763
1708
  init: function () {
1764
1709
  logger.debug('layout.init');
1765
1710
  },
1711
+
1766
1712
  reset: function () {
1767
1713
  logger.debug('layout.reset');
1768
1714
  this.bounds = { n: 0, s: 0, w: 0, e: 0 };
1769
1715
  },
1716
+
1717
+ calculate_next_child_direction: function (node) {
1718
+ if (this.isside) {
1719
+ return jm.direction.right;
1720
+ }
1721
+ var children = node.children || [];
1722
+ var children_len = children.length;
1723
+ var r = 0;
1724
+ for (var i = 0; i < children_len; i++) { if (children[i].direction === jm.direction.left) { r--; } else { r++; } }
1725
+ return (children_len > 1 && r > 0) ? jm.direction.left : jm.direction.right;
1726
+ },
1727
+
1770
1728
  layout: function () {
1771
1729
  logger.debug('layout.layout');
1772
1730
  this.layout_direction();
@@ -2361,7 +2319,10 @@
2361
2319
 
2362
2320
  this.container.appendChild(this.e_panel);
2363
2321
 
2364
- this.enable_draggable_canvas()
2322
+ // Used to avoid dragging, while editing node.
2323
+ this.dragging_enabled = true
2324
+
2325
+ this.draggable_canvas()
2365
2326
  },
2366
2327
 
2367
2328
  add_event: function (obj, event_name, event_handle) {
@@ -2522,8 +2483,16 @@
2522
2483
  $t(element, node.topic);
2523
2484
  }
2524
2485
  }
2525
- view_data.width = element.clientWidth;
2526
- view_data.height = element.clientHeight;
2486
+ if (this.layout.is_visible(node)) {
2487
+ view_data.width = element.clientWidth;
2488
+ view_data.height = element.clientHeight;
2489
+ } else {
2490
+ let origin_style = element.getAttribute('style');
2491
+ element.style = 'visibility: visible; left:0; top:0;';
2492
+ view_data.width = element.clientWidth;
2493
+ view_data.height = element.clientHeight;
2494
+ element.style = origin_style;
2495
+ }
2527
2496
  },
2528
2497
 
2529
2498
  select_node: function (node) {
@@ -2826,8 +2795,8 @@
2826
2795
  }
2827
2796
  },
2828
2797
 
2829
- // Drag the whole mind map with your mouse, when it's larger that the container
2830
- enable_draggable_canvas: function () {
2798
+ // Drag the whole mind map with your mouse (usefull when it's larger that the container).
2799
+ draggable_canvas: function () {
2831
2800
  // If draggable option is true.
2832
2801
  if (this.opts.draggable) {
2833
2802
  // Dragging disabled by default.
@@ -2850,7 +2819,7 @@
2850
2819
  })
2851
2820
  // Follow current mouse position and move mind map accordingly.
2852
2821
  jm.util.dom.add_event(this.container, 'mousemove', (eventMove) => {
2853
- if (dragging) {
2822
+ if (this.dragging_enabled && dragging) {
2854
2823
  this.e_panel.scrollBy(x - eventMove.clientX, y - eventMove.clientY)
2855
2824
  // Record new current position.
2856
2825
  x = eventMove.clientX
@@ -2860,6 +2829,18 @@
2860
2829
  }
2861
2830
  },
2862
2831
 
2832
+ get_draggable_canvas: function () {
2833
+ return this.opts.draggable
2834
+ },
2835
+
2836
+ enable_draggable_canvas: function () {
2837
+ this.dragging_enabled = true
2838
+ },
2839
+
2840
+ disable_draggable_canvas: function () {
2841
+ this.dragging_enabled = false
2842
+ },
2843
+
2863
2844
  };
2864
2845
 
2865
2846
  // shortcut provider
@@ -1,6 +1,6 @@
1
- /*
2
- * Released under BSD License
3
- * Copyright (c) 2014-2021 hizzgdev@163.com
1
+ /**
2
+ * @license BSD
3
+ * @copyright 2014-2022 hizzgdev@163.com
4
4
  *
5
5
  * Project Home:
6
6
  * https://github.com/hizzgdev/jsmind/
package/package.json CHANGED
@@ -1,34 +1,54 @@
1
1
  {
2
- "name": "jsmind",
3
- "version": "0.4.8",
4
- "description": "jsMind is a pure javascript library for mindmap, it base on html5 canvas. jsMind was released under BSD li cense, you can embed it in any project, if only you observe the license.",
5
- "main": "js/jsmind.js",
6
- "directories": {
7
- "doc": "docs",
8
- "example": "example"
9
- },
10
- "scripts": {
11
- "test": "echo \"Error: no test specified\" && exit 1"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/hizzgdev/jsmind.git"
16
- },
17
- "author": {
18
- "name": "hizzgdev@163.com"
19
- },
20
- "license": "BSD-3-Clause",
21
- "bugs": {
22
- "url": "https://github.com/hizzgdev/jsmind/issues"
23
- },
24
- "homepage": "https://github.com/hizzgdev/jsmind#readme",
25
- "keywords": [
26
- "mindmap"
27
- ],
28
- "maintainers": [
29
- {
30
- "name": "hizzgdev",
31
- "email": "hizzgdev@163.com"
2
+ "name": "jsmind",
3
+ "version": "0.4.10",
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
+ "main": "js/jsmind.js",
6
+ "directories": {
7
+ "doc": "docs",
8
+ "example": "example"
9
+ },
10
+ "scripts": {
11
+ "server": "http-server",
12
+ "build": "rollup -c .config/rollup.config.js",
13
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
14
+ "test-legacy": "jest tests/legacy",
15
+ "test-es6": "NODE_OPTIONS=--experimental-vm-modules jest tests/unit",
16
+ "format": "prettier --config .config/prettierrc.json --ignore-path .config/prettierignore --write .",
17
+ "format-check": "prettier --config .config/prettierrc.json --ignore-path .config/prettierignore --check ."
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/hizzgdev/jsmind.git"
22
+ },
23
+ "author": {
24
+ "name": "hizzgdev@163.com"
25
+ },
26
+ "license": "BSD-3-Clause",
27
+ "bugs": {
28
+ "url": "https://github.com/hizzgdev/jsmind/issues"
29
+ },
30
+ "homepage": "https://github.com/hizzgdev/jsmind#readme",
31
+ "keywords": [
32
+ "jsmind",
33
+ "mindmap"
34
+ ],
35
+ "maintainers": [
36
+ {
37
+ "name": "hizzgdev",
38
+ "email": "hizzgdev@163.com"
39
+ }
40
+ ],
41
+ "devDependencies": {
42
+ "http-server": "^14.1.1",
43
+ "jest": "^28.1.0",
44
+ "jest-environment-jsdom": "^28.1.0",
45
+ "prettier": "2.6.2",
46
+ "rollup": "^2.75.5",
47
+ "rollup-plugin-cleanup": "^3.2.1",
48
+ "rollup-plugin-terser": "^7.0.2"
49
+ },
50
+ "jest": {
51
+ "verbose": true,
52
+ "testEnvironment": "jsdom"
32
53
  }
33
- ]
34
54
  }