markmap-view 0.2.3 → 0.2.7

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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! markmap-view v0.2.3 | MIT License */
1
+ /*! markmap-view v0.2.7 | MIT License */
2
2
  (function (exports, d3) {
3
3
  'use strict';
4
4
 
@@ -6,11 +6,11 @@ function _interopNamespace(e) {
6
6
  if (e && e.__esModule) return e;
7
7
  var n = Object.create(null);
8
8
  if (e) {
9
- Object.keys(e).forEach(function (k) {
9
+ for (var k in e) {
10
10
  n[k] = e[k];
11
- });
12
11
  }
13
- n['default'] = e;
12
+ }
13
+ n["default"] = e;
14
14
  return Object.freeze(n);
15
15
  }
16
16
 
@@ -34,52 +34,11 @@ function _extends$1() {
34
34
  return _extends$1.apply(this, arguments);
35
35
  }
36
36
 
37
- function _assertThisInitialized(self) {
38
- if (self === void 0) {
39
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
40
- }
41
-
42
- return self;
43
- }
44
-
45
- function _defineProperties(target, props) {
46
- for (var i = 0; i < props.length; i++) {
47
- var descriptor = props[i];
48
- descriptor.enumerable = descriptor.enumerable || false;
49
- descriptor.configurable = true;
50
- if ("value" in descriptor) descriptor.writable = true;
51
- Object.defineProperty(target, descriptor.key, descriptor);
52
- }
53
- }
54
-
55
- function _createClass(Constructor, protoProps, staticProps) {
56
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
57
- if (staticProps) _defineProperties(Constructor, staticProps);
58
- return Constructor;
59
- }
60
-
61
- function _setPrototypeOf(o, p) {
62
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
63
- o.__proto__ = p;
64
- return o;
65
- };
66
-
67
- return _setPrototypeOf(o, p);
68
- }
69
-
70
- function _inheritsLoose(subClass, superClass) {
71
- subClass.prototype = Object.create(superClass.prototype);
72
- subClass.prototype.constructor = subClass;
73
- _setPrototypeOf(subClass, superClass);
74
- }
75
-
76
37
  function count(node) {
77
38
  var sum = 0,
78
39
  children = node.children,
79
40
  i = children && children.length;
80
- if (!i) sum = 1;else while (--i >= 0) {
81
- sum += children[i].value;
82
- }
41
+ if (!i) sum = 1;else while (--i >= 0) sum += children[i].value;
83
42
  node.value = sum;
84
43
  }
85
44
 
@@ -153,9 +112,7 @@ function node_sum (value) {
153
112
  children = node.children,
154
113
  i = children && children.length;
155
114
 
156
- while (--i >= 0) {
157
- sum += children[i].value;
158
- }
115
+ while (--i >= 0) sum += children[i].value;
159
116
 
160
117
  node.value = sum;
161
118
  });
@@ -293,9 +250,7 @@ function copyData(node) {
293
250
  function computeHeight(node) {
294
251
  var height = 0;
295
252
 
296
- do {
297
- node.height = height;
298
- } while ((node = node.parent) && node.height < ++height);
253
+ do node.height = height; while ((node = node.parent) && node.height < ++height);
299
254
  }
300
255
  function Node(data) {
301
256
  this.data = data;
@@ -318,15 +273,90 @@ Node.prototype = hierarchy.prototype = {
318
273
  copy: node_copy
319
274
  };
320
275
 
321
- var version = "2.1.1";
276
+ var name = "d3-flextree";
277
+ var version$1 = "2.1.2";
278
+ var main = "build/d3-flextree.js";
279
+ var module = "index";
280
+ var author = {
281
+ name: "Chris Maloney",
282
+ url: "http://chrismaloney.org"
283
+ };
284
+ var description = "Flexible tree layout algorithm that allows for variable node sizes.";
285
+ var keywords = [
286
+ "d3",
287
+ "d3-module",
288
+ "layout",
289
+ "tree",
290
+ "hierarchy",
291
+ "d3-hierarchy",
292
+ "plugin",
293
+ "d3-plugin",
294
+ "infovis",
295
+ "visualization",
296
+ "2d"
297
+ ];
298
+ var homepage = "https://github.com/klortho/d3-flextree";
299
+ var license = "WTFPL";
300
+ var repository = {
301
+ type: "git",
302
+ url: "https://github.com/klortho/d3-flextree.git"
303
+ };
304
+ var scripts = {
305
+ clean: "rm -rf build demo test",
306
+ "build:demo": "rollup -c --environment BUILD:demo",
307
+ "build:dev": "rollup -c --environment BUILD:dev",
308
+ "build:prod": "rollup -c --environment BUILD:prod",
309
+ "build:test": "rollup -c --environment BUILD:test",
310
+ build: "rollup -c",
311
+ lint: "eslint index.js src",
312
+ "test:main": "node test/bundle.js",
313
+ "test:browser": "node test/browser-tests.js",
314
+ test: "npm-run-all test:*",
315
+ prepare: "npm-run-all clean build lint test"
316
+ };
317
+ var dependencies = {
318
+ "d3-hierarchy": "^1.1.5"
319
+ };
320
+ var devDependencies = {
321
+ "babel-plugin-external-helpers": "^6.22.0",
322
+ "babel-preset-es2015-rollup": "^3.0.0",
323
+ d3: "^4.13.0",
324
+ "d3-selection-multi": "^1.0.1",
325
+ eslint: "^4.19.1",
326
+ jsdom: "^11.6.2",
327
+ "npm-run-all": "^4.1.2",
328
+ rollup: "^0.55.3",
329
+ "rollup-plugin-babel": "^2.7.1",
330
+ "rollup-plugin-commonjs": "^8.0.2",
331
+ "rollup-plugin-copy": "^0.2.3",
332
+ "rollup-plugin-json": "^2.3.0",
333
+ "rollup-plugin-node-resolve": "^3.0.2",
334
+ "rollup-plugin-uglify": "^3.0.0",
335
+ "uglify-es": "^3.3.9"
336
+ };
337
+ var packageInfo = {
338
+ name: name,
339
+ version: version$1,
340
+ main: main,
341
+ module: module,
342
+ "jsnext:main": "index",
343
+ author: author,
344
+ description: description,
345
+ keywords: keywords,
346
+ homepage: homepage,
347
+ license: license,
348
+ repository: repository,
349
+ scripts: scripts,
350
+ dependencies: dependencies,
351
+ devDependencies: devDependencies
352
+ };
322
353
 
323
- var defaults = Object.freeze({
324
- children: function children(data) {
325
- return data.children;
326
- },
327
- nodeSize: function nodeSize(node) {
328
- return node.data.size;
329
- },
354
+ const {
355
+ version
356
+ } = packageInfo;
357
+ const defaults = Object.freeze({
358
+ children: data => data.children,
359
+ nodeSize: node => node.data.size,
330
360
  spacing: 0
331
361
  }); // Create a layout function with customizable options. Per D3-style, the
332
362
  // options can be set at any time using setter methods. The layout function
@@ -334,244 +364,192 @@ var defaults = Object.freeze({
334
364
  // time it is called.
335
365
 
336
366
  function flextree(options) {
337
- var opts = Object.assign({}, defaults, options);
367
+ const opts = Object.assign({}, defaults, options);
338
368
 
339
369
  function accessor(name) {
340
- var opt = opts[name];
341
- return typeof opt === 'function' ? opt : function () {
342
- return opt;
343
- };
370
+ const opt = opts[name];
371
+ return typeof opt === 'function' ? opt : () => opt;
344
372
  }
345
373
 
346
374
  function layout(tree) {
347
- var wtree = wrap(getWrapper(), tree, function (node) {
348
- return node.children;
349
- });
375
+ const wtree = wrap(getWrapper(), tree, node => node.children);
350
376
  wtree.update();
351
377
  return wtree.data;
352
378
  }
353
379
 
354
380
  function getFlexNode() {
355
- var nodeSize = accessor('nodeSize');
381
+ const nodeSize = accessor('nodeSize');
382
+ const spacing = accessor('spacing');
383
+ return class FlexNode extends hierarchy.prototype.constructor {
384
+ constructor(data) {
385
+ super(data);
386
+ }
356
387
 
357
- var _spacing = accessor('spacing');
388
+ copy() {
389
+ const c = wrap(this.constructor, this, node => node.children);
390
+ c.each(node => node.data = node.data.data);
391
+ return c;
392
+ }
358
393
 
359
- return /*#__PURE__*/function (_hierarchy$prototype$) {
360
- _inheritsLoose(FlexNode, _hierarchy$prototype$);
394
+ get size() {
395
+ return nodeSize(this);
396
+ }
361
397
 
362
- function FlexNode(data) {
363
- return _hierarchy$prototype$.call(this, data) || this;
398
+ spacing(oNode) {
399
+ return spacing(this, oNode);
364
400
  }
365
401
 
366
- var _proto = FlexNode.prototype;
402
+ get nodes() {
403
+ return this.descendants();
404
+ }
367
405
 
368
- _proto.copy = function copy() {
369
- var c = wrap(this.constructor, this, function (node) {
370
- return node.children;
371
- });
372
- c.each(function (node) {
373
- return node.data = node.data.data;
374
- });
375
- return c;
376
- };
406
+ get xSize() {
407
+ return this.size[0];
408
+ }
377
409
 
378
- _proto.spacing = function spacing(oNode) {
379
- return _spacing(this, oNode);
380
- };
410
+ get ySize() {
411
+ return this.size[1];
412
+ }
413
+
414
+ get top() {
415
+ return this.y;
416
+ }
417
+
418
+ get bottom() {
419
+ return this.y + this.ySize;
420
+ }
421
+
422
+ get left() {
423
+ return this.x - this.xSize / 2;
424
+ }
425
+
426
+ get right() {
427
+ return this.x + this.xSize / 2;
428
+ }
429
+
430
+ get root() {
431
+ const ancs = this.ancestors();
432
+ return ancs[ancs.length - 1];
433
+ }
434
+
435
+ get numChildren() {
436
+ return this.hasChildren ? this.children.length : 0;
437
+ }
438
+
439
+ get hasChildren() {
440
+ return !this.noChildren;
441
+ }
442
+
443
+ get noChildren() {
444
+ return this.children === null;
445
+ }
446
+
447
+ get firstChild() {
448
+ return this.hasChildren ? this.children[0] : null;
449
+ }
450
+
451
+ get lastChild() {
452
+ return this.hasChildren ? this.children[this.numChildren - 1] : null;
453
+ }
454
+
455
+ get extents() {
456
+ return (this.children || []).reduce((acc, kid) => FlexNode.maxExtents(acc, kid.extents), this.nodeExtents);
457
+ }
458
+
459
+ get nodeExtents() {
460
+ return {
461
+ top: this.top,
462
+ bottom: this.bottom,
463
+ left: this.left,
464
+ right: this.right
465
+ };
466
+ }
381
467
 
382
- FlexNode.maxExtents = function maxExtents(e0, e1) {
468
+ static maxExtents(e0, e1) {
383
469
  return {
384
470
  top: Math.min(e0.top, e1.top),
385
471
  bottom: Math.max(e0.bottom, e1.bottom),
386
472
  left: Math.min(e0.left, e1.left),
387
473
  right: Math.max(e0.right, e1.right)
388
474
  };
389
- };
390
-
391
- _createClass(FlexNode, [{
392
- key: "size",
393
- get: function get() {
394
- return nodeSize(this);
395
- }
396
- }, {
397
- key: "nodes",
398
- get: function get() {
399
- return this.descendants();
400
- }
401
- }, {
402
- key: "xSize",
403
- get: function get() {
404
- return this.size[0];
405
- }
406
- }, {
407
- key: "ySize",
408
- get: function get() {
409
- return this.size[1];
410
- }
411
- }, {
412
- key: "top",
413
- get: function get() {
414
- return this.y;
415
- }
416
- }, {
417
- key: "bottom",
418
- get: function get() {
419
- return this.y + this.ySize;
420
- }
421
- }, {
422
- key: "left",
423
- get: function get() {
424
- return this.x - this.xSize / 2;
425
- }
426
- }, {
427
- key: "right",
428
- get: function get() {
429
- return this.x + this.xSize / 2;
430
- }
431
- }, {
432
- key: "root",
433
- get: function get() {
434
- var ancs = this.ancestors();
435
- return ancs[ancs.length - 1];
436
- }
437
- }, {
438
- key: "numChildren",
439
- get: function get() {
440
- return this.hasChildren ? this.children.length : 0;
441
- }
442
- }, {
443
- key: "hasChildren",
444
- get: function get() {
445
- return !this.noChildren;
446
- }
447
- }, {
448
- key: "noChildren",
449
- get: function get() {
450
- return this.children === null;
451
- }
452
- }, {
453
- key: "firstChild",
454
- get: function get() {
455
- return this.hasChildren ? this.children[0] : null;
456
- }
457
- }, {
458
- key: "lastChild",
459
- get: function get() {
460
- return this.hasChildren ? this.children[this.numChildren - 1] : null;
461
- }
462
- }, {
463
- key: "extents",
464
- get: function get() {
465
- return (this.children || []).reduce(function (acc, kid) {
466
- return FlexNode.maxExtents(acc, kid.extents);
467
- }, this.nodeExtents);
468
- }
469
- }, {
470
- key: "nodeExtents",
471
- get: function get() {
472
- return {
473
- top: this.top,
474
- bottom: this.bottom,
475
- left: this.left,
476
- right: this.right
477
- };
478
- }
479
- }]);
475
+ }
480
476
 
481
- return FlexNode;
482
- }(hierarchy.prototype.constructor);
477
+ };
483
478
  }
484
479
 
485
480
  function getWrapper() {
486
- var FlexNode = getFlexNode();
487
- var nodeSize = accessor('nodeSize');
488
-
489
- var _spacing2 = accessor('spacing');
490
-
491
- return /*#__PURE__*/function (_FlexNode) {
492
- _inheritsLoose(_class, _FlexNode);
493
-
494
- function _class(data) {
495
- var _this;
496
-
497
- _this = _FlexNode.call(this, data) || this;
498
- Object.assign(_assertThisInitialized(_this), {
481
+ const FlexNode = getFlexNode();
482
+ const nodeSize = accessor('nodeSize');
483
+ const spacing = accessor('spacing');
484
+ return class extends FlexNode {
485
+ constructor(data) {
486
+ super(data);
487
+ Object.assign(this, {
499
488
  x: 0,
500
489
  y: 0,
501
490
  relX: 0,
502
491
  prelim: 0,
503
492
  shift: 0,
504
493
  change: 0,
505
- lExt: _assertThisInitialized(_this),
494
+ lExt: this,
506
495
  lExtRelX: 0,
507
496
  lThr: null,
508
- rExt: _assertThisInitialized(_this),
497
+ rExt: this,
509
498
  rExtRelX: 0,
510
499
  rThr: null
511
500
  });
512
- return _this;
513
501
  }
514
502
 
515
- var _proto2 = _class.prototype;
503
+ get size() {
504
+ return nodeSize(this.data);
505
+ }
516
506
 
517
- _proto2.spacing = function spacing(oNode) {
518
- return _spacing2(this.data, oNode.data);
519
- };
507
+ spacing(oNode) {
508
+ return spacing(this.data, oNode.data);
509
+ }
510
+
511
+ get x() {
512
+ return this.data.x;
513
+ }
514
+
515
+ set x(v) {
516
+ this.data.x = v;
517
+ }
520
518
 
521
- _proto2.update = function update() {
519
+ get y() {
520
+ return this.data.y;
521
+ }
522
+
523
+ set y(v) {
524
+ this.data.y = v;
525
+ }
526
+
527
+ update() {
522
528
  layoutChildren(this);
523
529
  resolveX(this);
524
530
  return this;
525
- };
526
-
527
- _createClass(_class, [{
528
- key: "size",
529
- get: function get() {
530
- return nodeSize(this.data);
531
- }
532
- }, {
533
- key: "x",
534
- get: function get() {
535
- return this.data.x;
536
- },
537
- set: function set(v) {
538
- this.data.x = v;
539
- }
540
- }, {
541
- key: "y",
542
- get: function get() {
543
- return this.data.y;
544
- },
545
- set: function set(v) {
546
- this.data.y = v;
547
- }
548
- }]);
531
+ }
549
532
 
550
- return _class;
551
- }(FlexNode);
533
+ };
552
534
  }
553
535
 
554
536
  function wrap(FlexClass, treeData, children) {
555
- var _wrap = function _wrap(data, parent) {
556
- var node = new FlexClass(data);
537
+ const _wrap = (data, parent) => {
538
+ const node = new FlexClass(data);
557
539
  Object.assign(node, {
558
- parent: parent,
540
+ parent,
559
541
  depth: parent === null ? 0 : parent.depth + 1,
560
542
  height: 0,
561
543
  length: 1
562
544
  });
563
- var kidsData = children(data) || [];
564
- node.children = kidsData.length === 0 ? null : kidsData.map(function (kd) {
565
- return _wrap(kd, node);
566
- });
545
+ const kidsData = children(data) || [];
546
+ node.children = kidsData.length === 0 ? null : kidsData.map(kd => _wrap(kd, node));
567
547
 
568
548
  if (node.children) {
569
- Object.assign(node, node.children.reduce(function (hl, kid) {
570
- return {
571
- height: Math.max(hl.height, kid.height + 1),
572
- length: hl.length + kid.length
573
- };
574
- }, node));
549
+ Object.assign(node, node.children.reduce((hl, kid) => ({
550
+ height: Math.max(hl.height, kid.height + 1),
551
+ length: hl.length + kid.length
552
+ }), node));
575
553
  }
576
554
 
577
555
  return node;
@@ -581,57 +559,57 @@ function flextree(options) {
581
559
  }
582
560
 
583
561
  Object.assign(layout, {
584
- nodeSize: function nodeSize(arg) {
562
+ nodeSize(arg) {
585
563
  return arguments.length ? (opts.nodeSize = arg, layout) : opts.nodeSize;
586
564
  },
587
- spacing: function spacing(arg) {
565
+
566
+ spacing(arg) {
588
567
  return arguments.length ? (opts.spacing = arg, layout) : opts.spacing;
589
568
  },
590
- children: function children(arg) {
569
+
570
+ children(arg) {
591
571
  return arguments.length ? (opts.children = arg, layout) : opts.children;
592
572
  },
593
- hierarchy: function hierarchy(treeData, children) {
594
- var kids = typeof children === 'undefined' ? opts.children : children;
573
+
574
+ hierarchy(treeData, children) {
575
+ const kids = typeof children === 'undefined' ? opts.children : children;
595
576
  return wrap(getFlexNode(), treeData, kids);
596
577
  },
597
- dump: function dump(tree) {
598
- var nodeSize = accessor('nodeSize');
599
-
600
- var _dump = function _dump(i0) {
601
- return function (node) {
602
- var i1 = i0 + ' ';
603
- var i2 = i0 + ' ';
604
- var x = node.x,
605
- y = node.y;
606
- var size = nodeSize(node);
607
- var kids = node.children || [];
608
- var kdumps = kids.length === 0 ? ' ' : "," + i1 + "children: [" + i2 + kids.map(_dump(i2)).join(i2) + i1 + "]," + i0;
609
- return "{ size: [" + size.join(', ') + "]," + i1 + "x: " + x + ", y: " + y + kdumps + "},";
610
- };
578
+
579
+ dump(tree) {
580
+ const nodeSize = accessor('nodeSize');
581
+
582
+ const _dump = i0 => node => {
583
+ const i1 = i0 + ' ';
584
+ const i2 = i0 + ' ';
585
+ const {
586
+ x,
587
+ y
588
+ } = node;
589
+ const size = nodeSize(node);
590
+ const kids = node.children || [];
591
+ const kdumps = kids.length === 0 ? ' ' : `,${i1}children: [${i2}${kids.map(_dump(i2)).join(i2)}${i1}],${i0}`;
592
+ return `{ size: [${size.join(', ')}],${i1}x: ${x}, y: ${y}${kdumps}},`;
611
593
  };
612
594
 
613
595
  return _dump('\n')(tree);
614
596
  }
597
+
615
598
  });
616
599
  return layout;
617
600
  }
618
601
  flextree.version = version;
619
602
 
620
- var layoutChildren = function layoutChildren(w, y) {
621
- if (y === void 0) {
622
- y = 0;
623
- }
624
-
603
+ const layoutChildren = (w, y = 0) => {
625
604
  w.y = y;
626
- (w.children || []).reduce(function (acc, kid) {
627
- var i = acc[0],
628
- lastLows = acc[1];
605
+ (w.children || []).reduce((acc, kid) => {
606
+ const [i, lastLows] = acc;
629
607
  layoutChildren(kid, w.y + w.ySize); // The lowest vertical coordinate while extreme nodes still point
630
608
  // in current subtree.
631
609
 
632
- var lowY = (i === 0 ? kid.lExt : kid.rExt).bottom;
610
+ const lowY = (i === 0 ? kid.lExt : kid.rExt).bottom;
633
611
  if (i !== 0) separate(w, i, lastLows);
634
- var lows = updateLows(lowY, i, lastLows);
612
+ const lows = updateLows(lowY, i, lastLows);
635
613
  return [i + 1, lows];
636
614
  }, [0, null]);
637
615
  shiftChange(w);
@@ -643,7 +621,7 @@ var layoutChildren = function layoutChildren(w, y) {
643
621
  // to its parent.
644
622
 
645
623
 
646
- var resolveX = function resolveX(w, prevSum, parentX) {
624
+ const resolveX = (w, prevSum, parentX) => {
647
625
  // A call to resolveX without arguments is assumed to be for the root of
648
626
  // the tree. This will set the root's x-coord to zero.
649
627
  if (typeof prevSum === 'undefined') {
@@ -651,24 +629,21 @@ var resolveX = function resolveX(w, prevSum, parentX) {
651
629
  parentX = 0;
652
630
  }
653
631
 
654
- var sum = prevSum + w.relX;
632
+ const sum = prevSum + w.relX;
655
633
  w.relX = sum + w.prelim - parentX;
656
634
  w.prelim = 0;
657
635
  w.x = parentX + w.relX;
658
- (w.children || []).forEach(function (k) {
659
- return resolveX(k, sum, w.x);
660
- });
636
+ (w.children || []).forEach(k => resolveX(k, sum, w.x));
661
637
  return w;
662
638
  }; // Process shift and change for all children, to add intermediate spacing to
663
639
  // each child's modifier.
664
640
 
665
641
 
666
- var shiftChange = function shiftChange(w) {
667
- (w.children || []).reduce(function (acc, child) {
668
- var lastShiftSum = acc[0],
669
- lastChangeSum = acc[1];
670
- var shiftSum = lastShiftSum + child.shift;
671
- var changeSum = lastChangeSum + shiftSum + child.change;
642
+ const shiftChange = w => {
643
+ (w.children || []).reduce((acc, child) => {
644
+ const [lastShiftSum, lastChangeSum] = acc;
645
+ const shiftSum = lastShiftSum + child.shift;
646
+ const changeSum = lastChangeSum + shiftSum + child.change;
672
647
  child.relX += changeSum;
673
648
  return [shiftSum, changeSum];
674
649
  }, [0, 0]);
@@ -677,21 +652,21 @@ var shiftChange = function shiftChange(w) {
677
652
  /* eslint-disable complexity */
678
653
 
679
654
 
680
- var separate = function separate(w, i, lows) {
681
- var lSib = w.children[i - 1];
682
- var curSubtree = w.children[i];
683
- var rContour = lSib;
684
- var rSumMods = lSib.relX;
685
- var lContour = curSubtree;
686
- var lSumMods = curSubtree.relX;
687
- var isFirst = true;
655
+ const separate = (w, i, lows) => {
656
+ const lSib = w.children[i - 1];
657
+ const curSubtree = w.children[i];
658
+ let rContour = lSib;
659
+ let rSumMods = lSib.relX;
660
+ let lContour = curSubtree;
661
+ let lSumMods = curSubtree.relX;
662
+ let isFirst = true;
688
663
 
689
664
  while (rContour && lContour) {
690
665
  if (rContour.bottom > lows.lowY) lows = lows.next; // How far to the left of the right side of rContour is the left side
691
666
  // of lContour? First compute the center-to-center distance, then add
692
667
  // the "spacing"
693
668
 
694
- var dist = rSumMods + rContour.prelim - (lSumMods + lContour.prelim) + rContour.xSize / 2 + lContour.xSize / 2 + rContour.spacing(lContour);
669
+ const dist = rSumMods + rContour.prelim - (lSumMods + lContour.prelim) + rContour.xSize / 2 + lContour.xSize / 2 + rContour.spacing(lContour);
695
670
 
696
671
  if (dist > 0 || dist < 0 && isFirst) {
697
672
  lSumMods += dist; // Move subtree by changing relX.
@@ -702,8 +677,8 @@ var separate = function separate(w, i, lows) {
702
677
 
703
678
  isFirst = false; // Advance highest node(s) and sum(s) of modifiers
704
679
 
705
- var rightBottom = rContour.bottom;
706
- var leftBottom = lContour.bottom;
680
+ const rightBottom = rContour.bottom;
681
+ const leftBottom = lContour.bottom;
707
682
 
708
683
  if (rightBottom <= leftBottom) {
709
684
  rContour = nextRContour(rContour);
@@ -725,39 +700,39 @@ var separate = function separate(w, i, lows) {
725
700
  // Move subtree by changing relX.
726
701
 
727
702
 
728
- var moveSubtree = function moveSubtree(subtree, distance) {
703
+ const moveSubtree = (subtree, distance) => {
729
704
  subtree.relX += distance;
730
705
  subtree.lExtRelX += distance;
731
706
  subtree.rExtRelX += distance;
732
707
  };
733
708
 
734
- var distributeExtra = function distributeExtra(w, curSubtreeI, leftSibI, dist) {
735
- var curSubtree = w.children[curSubtreeI];
736
- var n = curSubtreeI - leftSibI; // Are there intermediate children?
709
+ const distributeExtra = (w, curSubtreeI, leftSibI, dist) => {
710
+ const curSubtree = w.children[curSubtreeI];
711
+ const n = curSubtreeI - leftSibI; // Are there intermediate children?
737
712
 
738
713
  if (n > 1) {
739
- var delta = dist / n;
714
+ const delta = dist / n;
740
715
  w.children[leftSibI + 1].shift += delta;
741
716
  curSubtree.shift -= delta;
742
717
  curSubtree.change -= dist - delta;
743
718
  }
744
719
  };
745
720
 
746
- var nextLContour = function nextLContour(w) {
721
+ const nextLContour = w => {
747
722
  return w.hasChildren ? w.firstChild : w.lThr;
748
723
  };
749
724
 
750
- var nextRContour = function nextRContour(w) {
725
+ const nextRContour = w => {
751
726
  return w.hasChildren ? w.lastChild : w.rThr;
752
727
  };
753
728
 
754
- var setLThr = function setLThr(w, i, lContour, lSumMods) {
755
- var firstChild = w.firstChild;
756
- var lExt = firstChild.lExt;
757
- var curSubtree = w.children[i];
729
+ const setLThr = (w, i, lContour, lSumMods) => {
730
+ const firstChild = w.firstChild;
731
+ const lExt = firstChild.lExt;
732
+ const curSubtree = w.children[i];
758
733
  lExt.lThr = lContour; // Change relX so that the sum of modifier after following thread is correct.
759
734
 
760
- var diff = lSumMods - lContour.relX - firstChild.lExtRelX;
735
+ const diff = lSumMods - lContour.relX - firstChild.lExtRelX;
761
736
  lExt.relX += diff; // Change preliminary x coordinate so that the node does not move.
762
737
 
763
738
  lExt.prelim -= diff; // Update extreme node and its sum of modifiers.
@@ -767,12 +742,12 @@ var setLThr = function setLThr(w, i, lContour, lSumMods) {
767
742
  }; // Mirror image of setLThr.
768
743
 
769
744
 
770
- var setRThr = function setRThr(w, i, rContour, rSumMods) {
771
- var curSubtree = w.children[i];
772
- var rExt = curSubtree.rExt;
773
- var lSib = w.children[i - 1];
745
+ const setRThr = (w, i, rContour, rSumMods) => {
746
+ const curSubtree = w.children[i];
747
+ const rExt = curSubtree.rExt;
748
+ const lSib = w.children[i - 1];
774
749
  rExt.rThr = rContour;
775
- var diff = rSumMods - rContour.relX - curSubtree.rExtRelX;
750
+ const diff = rSumMods - rContour.relX - curSubtree.rExtRelX;
776
751
  rExt.relX += diff;
777
752
  rExt.prelim -= diff;
778
753
  curSubtree.rExt = lSib.rExt;
@@ -780,13 +755,13 @@ var setRThr = function setRThr(w, i, rContour, rSumMods) {
780
755
  }; // Position root between children, taking into account their modifiers
781
756
 
782
757
 
783
- var positionRoot = function positionRoot(w) {
758
+ const positionRoot = w => {
784
759
  if (w.hasChildren) {
785
- var k0 = w.firstChild;
786
- var kf = w.lastChild;
787
- var prelim = (k0.prelim + k0.relX - k0.xSize / 2 + kf.relX + kf.prelim + kf.xSize / 2) / 2;
760
+ const k0 = w.firstChild;
761
+ const kf = w.lastChild;
762
+ const prelim = (k0.prelim + k0.relX - k0.xSize / 2 + kf.relX + kf.prelim + kf.xSize / 2) / 2;
788
763
  Object.assign(w, {
789
- prelim: prelim,
764
+ prelim,
790
765
  lExt: k0.lExt,
791
766
  lExtRelX: k0.lExtRelX,
792
767
  rExt: kf.rExt,
@@ -797,21 +772,19 @@ var positionRoot = function positionRoot(w) {
797
772
  // lowest vertical coordinate.
798
773
 
799
774
 
800
- var updateLows = function updateLows(lowY, index, lastLows) {
775
+ const updateLows = (lowY, index, lastLows) => {
801
776
  // Remove siblings that are hidden by the new subtree.
802
- while (lastLows !== null && lowY >= lastLows.lowY) {
803
- lastLows = lastLows.next;
804
- } // Prepend the new subtree.
777
+ while (lastLows !== null && lowY >= lastLows.lowY) lastLows = lastLows.next; // Prepend the new subtree.
805
778
 
806
779
 
807
780
  return {
808
- lowY: lowY,
809
- index: index,
781
+ lowY,
782
+ index,
810
783
  next: lastLows
811
784
  };
812
785
  };
813
786
 
814
- /*! markmap-common v0.1.4 | MIT License */
787
+ /*! markmap-common v0.1.6 | MIT License */
815
788
  class Hook {
816
789
  constructor() {
817
790
  this.listeners = [];
@@ -1049,13 +1022,6 @@ function createViewHooks() {
1049
1022
  const refreshHook = new Hook();
1050
1023
  class Markmap {
1051
1024
  constructor(svg, opts) {
1052
- this.options = void 0;
1053
- this.state = void 0;
1054
- this.svg = void 0;
1055
- this.styleNode = void 0;
1056
- this.g = void 0;
1057
- this.zoom = void 0;
1058
- this.viewHooks = void 0;
1059
1025
  this.revokers = [];
1060
1026
  ['handleZoom', 'handleClick'].forEach(key => {
1061
1027
  this[key] = this[key].bind(this);
@@ -1196,9 +1162,8 @@ ${this.getStyleContent()}
1196
1162
  }
1197
1163
 
1198
1164
  setData(data, opts) {
1199
- if (!data) data = _extends$1({}, this.state.data);
1200
- this.state.data = data;
1201
- this.initializeData(data);
1165
+ if (data) this.state.data = data;
1166
+ this.initializeData(this.state.data);
1202
1167
  if (opts) this.setOptions(opts);
1203
1168
  this.renderData();
1204
1169
  }
@@ -1271,9 +1236,9 @@ ${this.getStyleContent()}
1271
1236
  const foreignObject = nodeMerge.selectAll(childSelector('foreignObject')).data(d => [d], d => d.data.p.k).join(enter => {
1272
1237
  const fo = enter.append('foreignObject').attr('class', `${id}-fo`).attr('x', paddingX).attr('y', 0).style('opacity', 0).attr('height', d => d.xSize).on('mousedown', stopPropagation).on('dblclick', stopPropagation);
1273
1238
  fo.append('xhtml:div').select(function select(d) {
1274
- const node = d.data.p.el.cloneNode(true);
1275
- this.replaceWith(node);
1276
- return node;
1239
+ const clone = d.data.p.el.cloneNode(true);
1240
+ this.replaceWith(clone);
1241
+ return clone;
1277
1242
  }).attr('xmlns', 'http://www.w3.org/1999/xhtml');
1278
1243
  return fo;
1279
1244
  }, update => update, exit => exit.remove()).attr('width', d => Math.max(0, d.ySizeInner - paddingX * 2));
@@ -1430,4 +1395,4 @@ exports.loadCSS = loadCSS;
1430
1395
  exports.loadJS = loadJS;
1431
1396
  exports.refreshHook = refreshHook;
1432
1397
 
1433
- }(this.markmap = this.markmap || {}, d3));
1398
+ })(this.markmap = this.markmap || {}, d3);