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