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