markmap-view
Advanced tools
Comparing version 0.2.6 to 0.2.7
@@ -1,2 +0,2 @@ | ||
/*! markmap-view v0.2.6 | MIT License */ | ||
/*! markmap-view v0.2.7 | MIT License */ | ||
'use strict'; | ||
@@ -10,7 +10,7 @@ | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
for (var k in e) { | ||
n[k] = e[k]; | ||
}); | ||
} | ||
n['default'] = e; | ||
} | ||
n["default"] = e; | ||
return Object.freeze(n); | ||
@@ -39,41 +39,2 @@ } | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
_setPrototypeOf(subClass, superClass); | ||
} | ||
function count(node) { | ||
@@ -83,5 +44,3 @@ var sum = 0, | ||
i = children && children.length; | ||
if (!i) sum = 1;else while (--i >= 0) { | ||
sum += children[i].value; | ||
} | ||
if (!i) sum = 1;else while (--i >= 0) sum += children[i].value; | ||
node.value = sum; | ||
@@ -160,5 +119,3 @@ } | ||
while (--i >= 0) { | ||
sum += children[i].value; | ||
} | ||
while (--i >= 0) sum += children[i].value; | ||
@@ -301,5 +258,3 @@ node.value = sum; | ||
do { | ||
node.height = height; | ||
} while ((node = node.parent) && node.height < ++height); | ||
do node.height = height; while ((node = node.parent) && node.height < ++height); | ||
} | ||
@@ -327,11 +282,86 @@ function Node(data) { | ||
var version = "2.1.1"; | ||
var name = "d3-flextree"; | ||
var version$1 = "2.1.2"; | ||
var main = "build/d3-flextree.js"; | ||
var module$1 = "index"; | ||
var author = { | ||
name: "Chris Maloney", | ||
url: "http://chrismaloney.org" | ||
}; | ||
var description = "Flexible tree layout algorithm that allows for variable node sizes."; | ||
var keywords = [ | ||
"d3", | ||
"d3-module", | ||
"layout", | ||
"tree", | ||
"hierarchy", | ||
"d3-hierarchy", | ||
"plugin", | ||
"d3-plugin", | ||
"infovis", | ||
"visualization", | ||
"2d" | ||
]; | ||
var homepage = "https://github.com/klortho/d3-flextree"; | ||
var license = "WTFPL"; | ||
var repository = { | ||
type: "git", | ||
url: "https://github.com/klortho/d3-flextree.git" | ||
}; | ||
var scripts = { | ||
clean: "rm -rf build demo test", | ||
"build:demo": "rollup -c --environment BUILD:demo", | ||
"build:dev": "rollup -c --environment BUILD:dev", | ||
"build:prod": "rollup -c --environment BUILD:prod", | ||
"build:test": "rollup -c --environment BUILD:test", | ||
build: "rollup -c", | ||
lint: "eslint index.js src", | ||
"test:main": "node test/bundle.js", | ||
"test:browser": "node test/browser-tests.js", | ||
test: "npm-run-all test:*", | ||
prepare: "npm-run-all clean build lint test" | ||
}; | ||
var dependencies = { | ||
"d3-hierarchy": "^1.1.5" | ||
}; | ||
var devDependencies = { | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-preset-es2015-rollup": "^3.0.0", | ||
d3: "^4.13.0", | ||
"d3-selection-multi": "^1.0.1", | ||
eslint: "^4.19.1", | ||
jsdom: "^11.6.2", | ||
"npm-run-all": "^4.1.2", | ||
rollup: "^0.55.3", | ||
"rollup-plugin-babel": "^2.7.1", | ||
"rollup-plugin-commonjs": "^8.0.2", | ||
"rollup-plugin-copy": "^0.2.3", | ||
"rollup-plugin-json": "^2.3.0", | ||
"rollup-plugin-node-resolve": "^3.0.2", | ||
"rollup-plugin-uglify": "^3.0.0", | ||
"uglify-es": "^3.3.9" | ||
}; | ||
var packageInfo = { | ||
name: name, | ||
version: version$1, | ||
main: main, | ||
module: module$1, | ||
"jsnext:main": "index", | ||
author: author, | ||
description: description, | ||
keywords: keywords, | ||
homepage: homepage, | ||
license: license, | ||
repository: repository, | ||
scripts: scripts, | ||
dependencies: dependencies, | ||
devDependencies: devDependencies | ||
}; | ||
var defaults = Object.freeze({ | ||
children: function children(data) { | ||
return data.children; | ||
}, | ||
nodeSize: function nodeSize(node) { | ||
return node.data.size; | ||
}, | ||
const { | ||
version | ||
} = packageInfo; | ||
const defaults = Object.freeze({ | ||
children: data => data.children, | ||
nodeSize: node => node.data.size, | ||
spacing: 0 | ||
@@ -344,15 +374,11 @@ }); // Create a layout function with customizable options. Per D3-style, the | ||
function flextree(options) { | ||
var opts = Object.assign({}, defaults, options); | ||
const opts = Object.assign({}, defaults, options); | ||
function accessor(name) { | ||
var opt = opts[name]; | ||
return typeof opt === 'function' ? opt : function () { | ||
return opt; | ||
}; | ||
const opt = opts[name]; | ||
return typeof opt === 'function' ? opt : () => opt; | ||
} | ||
function layout(tree) { | ||
var wtree = wrap(getWrapper(), tree, function (node) { | ||
return node.children; | ||
}); | ||
const wtree = wrap(getWrapper(), tree, node => node.children); | ||
wtree.update(); | ||
@@ -363,31 +389,91 @@ return wtree.data; | ||
function getFlexNode() { | ||
var nodeSize = accessor('nodeSize'); | ||
const nodeSize = accessor('nodeSize'); | ||
const spacing = accessor('spacing'); | ||
return class FlexNode extends hierarchy.prototype.constructor { | ||
constructor(data) { | ||
super(data); | ||
} | ||
var _spacing = accessor('spacing'); | ||
copy() { | ||
const c = wrap(this.constructor, this, node => node.children); | ||
c.each(node => node.data = node.data.data); | ||
return c; | ||
} | ||
return /*#__PURE__*/function (_hierarchy$prototype$) { | ||
_inheritsLoose(FlexNode, _hierarchy$prototype$); | ||
get size() { | ||
return nodeSize(this); | ||
} | ||
function FlexNode(data) { | ||
return _hierarchy$prototype$.call(this, data) || this; | ||
spacing(oNode) { | ||
return spacing(this, oNode); | ||
} | ||
var _proto = FlexNode.prototype; | ||
get nodes() { | ||
return this.descendants(); | ||
} | ||
_proto.copy = function copy() { | ||
var c = wrap(this.constructor, this, function (node) { | ||
return node.children; | ||
}); | ||
c.each(function (node) { | ||
return node.data = node.data.data; | ||
}); | ||
return c; | ||
}; | ||
get xSize() { | ||
return this.size[0]; | ||
} | ||
_proto.spacing = function spacing(oNode) { | ||
return _spacing(this, oNode); | ||
}; | ||
get ySize() { | ||
return this.size[1]; | ||
} | ||
FlexNode.maxExtents = function maxExtents(e0, e1) { | ||
get top() { | ||
return this.y; | ||
} | ||
get bottom() { | ||
return this.y + this.ySize; | ||
} | ||
get left() { | ||
return this.x - this.xSize / 2; | ||
} | ||
get right() { | ||
return this.x + this.xSize / 2; | ||
} | ||
get root() { | ||
const ancs = this.ancestors(); | ||
return ancs[ancs.length - 1]; | ||
} | ||
get numChildren() { | ||
return this.hasChildren ? this.children.length : 0; | ||
} | ||
get hasChildren() { | ||
return !this.noChildren; | ||
} | ||
get noChildren() { | ||
return this.children === null; | ||
} | ||
get firstChild() { | ||
return this.hasChildren ? this.children[0] : null; | ||
} | ||
get lastChild() { | ||
return this.hasChildren ? this.children[this.numChildren - 1] : null; | ||
} | ||
get extents() { | ||
return (this.children || []).reduce((acc, kid) => FlexNode.maxExtents(acc, kid.extents), this.nodeExtents); | ||
} | ||
get nodeExtents() { | ||
return { | ||
top: this.top, | ||
bottom: this.bottom, | ||
left: this.left, | ||
right: this.right | ||
}; | ||
} | ||
static maxExtents(e0, e1) { | ||
return { | ||
top: Math.min(e0.top, e1.top), | ||
@@ -398,112 +484,15 @@ bottom: Math.max(e0.bottom, e1.bottom), | ||
}; | ||
}; | ||
} | ||
_createClass(FlexNode, [{ | ||
key: "size", | ||
get: function get() { | ||
return nodeSize(this); | ||
} | ||
}, { | ||
key: "nodes", | ||
get: function get() { | ||
return this.descendants(); | ||
} | ||
}, { | ||
key: "xSize", | ||
get: function get() { | ||
return this.size[0]; | ||
} | ||
}, { | ||
key: "ySize", | ||
get: function get() { | ||
return this.size[1]; | ||
} | ||
}, { | ||
key: "top", | ||
get: function get() { | ||
return this.y; | ||
} | ||
}, { | ||
key: "bottom", | ||
get: function get() { | ||
return this.y + this.ySize; | ||
} | ||
}, { | ||
key: "left", | ||
get: function get() { | ||
return this.x - this.xSize / 2; | ||
} | ||
}, { | ||
key: "right", | ||
get: function get() { | ||
return this.x + this.xSize / 2; | ||
} | ||
}, { | ||
key: "root", | ||
get: function get() { | ||
var ancs = this.ancestors(); | ||
return ancs[ancs.length - 1]; | ||
} | ||
}, { | ||
key: "numChildren", | ||
get: function get() { | ||
return this.hasChildren ? this.children.length : 0; | ||
} | ||
}, { | ||
key: "hasChildren", | ||
get: function get() { | ||
return !this.noChildren; | ||
} | ||
}, { | ||
key: "noChildren", | ||
get: function get() { | ||
return this.children === null; | ||
} | ||
}, { | ||
key: "firstChild", | ||
get: function get() { | ||
return this.hasChildren ? this.children[0] : null; | ||
} | ||
}, { | ||
key: "lastChild", | ||
get: function get() { | ||
return this.hasChildren ? this.children[this.numChildren - 1] : null; | ||
} | ||
}, { | ||
key: "extents", | ||
get: function get() { | ||
return (this.children || []).reduce(function (acc, kid) { | ||
return FlexNode.maxExtents(acc, kid.extents); | ||
}, this.nodeExtents); | ||
} | ||
}, { | ||
key: "nodeExtents", | ||
get: function get() { | ||
return { | ||
top: this.top, | ||
bottom: this.bottom, | ||
left: this.left, | ||
right: this.right | ||
}; | ||
} | ||
}]); | ||
return FlexNode; | ||
}(hierarchy.prototype.constructor); | ||
}; | ||
} | ||
function getWrapper() { | ||
var FlexNode = getFlexNode(); | ||
var nodeSize = accessor('nodeSize'); | ||
var _spacing2 = accessor('spacing'); | ||
return /*#__PURE__*/function (_FlexNode) { | ||
_inheritsLoose(_class, _FlexNode); | ||
function _class(data) { | ||
var _this; | ||
_this = _FlexNode.call(this, data) || this; | ||
Object.assign(_assertThisInitialized(_this), { | ||
const FlexNode = getFlexNode(); | ||
const nodeSize = accessor('nodeSize'); | ||
const spacing = accessor('spacing'); | ||
return class extends FlexNode { | ||
constructor(data) { | ||
super(data); | ||
Object.assign(this, { | ||
x: 0, | ||
@@ -515,56 +504,49 @@ y: 0, | ||
change: 0, | ||
lExt: _assertThisInitialized(_this), | ||
lExt: this, | ||
lExtRelX: 0, | ||
lThr: null, | ||
rExt: _assertThisInitialized(_this), | ||
rExt: this, | ||
rExtRelX: 0, | ||
rThr: null | ||
}); | ||
return _this; | ||
} | ||
var _proto2 = _class.prototype; | ||
get size() { | ||
return nodeSize(this.data); | ||
} | ||
_proto2.spacing = function spacing(oNode) { | ||
return _spacing2(this.data, oNode.data); | ||
}; | ||
spacing(oNode) { | ||
return spacing(this.data, oNode.data); | ||
} | ||
_proto2.update = function update() { | ||
get x() { | ||
return this.data.x; | ||
} | ||
set x(v) { | ||
this.data.x = v; | ||
} | ||
get y() { | ||
return this.data.y; | ||
} | ||
set y(v) { | ||
this.data.y = v; | ||
} | ||
update() { | ||
layoutChildren(this); | ||
resolveX(this); | ||
return this; | ||
}; | ||
} | ||
_createClass(_class, [{ | ||
key: "size", | ||
get: function get() { | ||
return nodeSize(this.data); | ||
} | ||
}, { | ||
key: "x", | ||
get: function get() { | ||
return this.data.x; | ||
}, | ||
set: function set(v) { | ||
this.data.x = v; | ||
} | ||
}, { | ||
key: "y", | ||
get: function get() { | ||
return this.data.y; | ||
}, | ||
set: function set(v) { | ||
this.data.y = v; | ||
} | ||
}]); | ||
return _class; | ||
}(FlexNode); | ||
}; | ||
} | ||
function wrap(FlexClass, treeData, children) { | ||
var _wrap = function _wrap(data, parent) { | ||
var node = new FlexClass(data); | ||
const _wrap = (data, parent) => { | ||
const node = new FlexClass(data); | ||
Object.assign(node, { | ||
parent: parent, | ||
parent, | ||
depth: parent === null ? 0 : parent.depth + 1, | ||
@@ -574,14 +556,10 @@ height: 0, | ||
}); | ||
var kidsData = children(data) || []; | ||
node.children = kidsData.length === 0 ? null : kidsData.map(function (kd) { | ||
return _wrap(kd, node); | ||
}); | ||
const kidsData = children(data) || []; | ||
node.children = kidsData.length === 0 ? null : kidsData.map(kd => _wrap(kd, node)); | ||
if (node.children) { | ||
Object.assign(node, node.children.reduce(function (hl, kid) { | ||
return { | ||
height: Math.max(hl.height, kid.height + 1), | ||
length: hl.length + kid.length | ||
}; | ||
}, node)); | ||
Object.assign(node, node.children.reduce((hl, kid) => ({ | ||
height: Math.max(hl.height, kid.height + 1), | ||
length: hl.length + kid.length | ||
}), node)); | ||
} | ||
@@ -596,29 +574,33 @@ | ||
Object.assign(layout, { | ||
nodeSize: function nodeSize(arg) { | ||
nodeSize(arg) { | ||
return arguments.length ? (opts.nodeSize = arg, layout) : opts.nodeSize; | ||
}, | ||
spacing: function spacing(arg) { | ||
spacing(arg) { | ||
return arguments.length ? (opts.spacing = arg, layout) : opts.spacing; | ||
}, | ||
children: function children(arg) { | ||
children(arg) { | ||
return arguments.length ? (opts.children = arg, layout) : opts.children; | ||
}, | ||
hierarchy: function hierarchy(treeData, children) { | ||
var kids = typeof children === 'undefined' ? opts.children : children; | ||
hierarchy(treeData, children) { | ||
const kids = typeof children === 'undefined' ? opts.children : children; | ||
return wrap(getFlexNode(), treeData, kids); | ||
}, | ||
dump: function dump(tree) { | ||
var nodeSize = accessor('nodeSize'); | ||
var _dump = function _dump(i0) { | ||
return function (node) { | ||
var i1 = i0 + ' '; | ||
var i2 = i0 + ' '; | ||
var x = node.x, | ||
y = node.y; | ||
var size = nodeSize(node); | ||
var kids = node.children || []; | ||
var kdumps = kids.length === 0 ? ' ' : "," + i1 + "children: [" + i2 + kids.map(_dump(i2)).join(i2) + i1 + "]," + i0; | ||
return "{ size: [" + size.join(', ') + "]," + i1 + "x: " + x + ", y: " + y + kdumps + "},"; | ||
}; | ||
dump(tree) { | ||
const nodeSize = accessor('nodeSize'); | ||
const _dump = i0 => node => { | ||
const i1 = i0 + ' '; | ||
const i2 = i0 + ' '; | ||
const { | ||
x, | ||
y | ||
} = node; | ||
const size = nodeSize(node); | ||
const kids = node.children || []; | ||
const kdumps = kids.length === 0 ? ' ' : `,${i1}children: [${i2}${kids.map(_dump(i2)).join(i2)}${i1}],${i0}`; | ||
return `{ size: [${size.join(', ')}],${i1}x: ${x}, y: ${y}${kdumps}},`; | ||
}; | ||
@@ -628,2 +610,3 @@ | ||
} | ||
}); | ||
@@ -634,17 +617,12 @@ return layout; | ||
var layoutChildren = function layoutChildren(w, y) { | ||
if (y === void 0) { | ||
y = 0; | ||
} | ||
const layoutChildren = (w, y = 0) => { | ||
w.y = y; | ||
(w.children || []).reduce(function (acc, kid) { | ||
var i = acc[0], | ||
lastLows = acc[1]; | ||
(w.children || []).reduce((acc, kid) => { | ||
const [i, lastLows] = acc; | ||
layoutChildren(kid, w.y + w.ySize); // The lowest vertical coordinate while extreme nodes still point | ||
// in current subtree. | ||
var lowY = (i === 0 ? kid.lExt : kid.rExt).bottom; | ||
const lowY = (i === 0 ? kid.lExt : kid.rExt).bottom; | ||
if (i !== 0) separate(w, i, lastLows); | ||
var lows = updateLows(lowY, i, lastLows); | ||
const lows = updateLows(lowY, i, lastLows); | ||
return [i + 1, lows]; | ||
@@ -661,3 +639,3 @@ }, [0, null]); | ||
var resolveX = function resolveX(w, prevSum, parentX) { | ||
const resolveX = (w, prevSum, parentX) => { | ||
// A call to resolveX without arguments is assumed to be for the root of | ||
@@ -670,9 +648,7 @@ // the tree. This will set the root's x-coord to zero. | ||
var sum = prevSum + w.relX; | ||
const sum = prevSum + w.relX; | ||
w.relX = sum + w.prelim - parentX; | ||
w.prelim = 0; | ||
w.x = parentX + w.relX; | ||
(w.children || []).forEach(function (k) { | ||
return resolveX(k, sum, w.x); | ||
}); | ||
(w.children || []).forEach(k => resolveX(k, sum, w.x)); | ||
return w; | ||
@@ -683,8 +659,7 @@ }; // Process shift and change for all children, to add intermediate spacing to | ||
var shiftChange = function shiftChange(w) { | ||
(w.children || []).reduce(function (acc, child) { | ||
var lastShiftSum = acc[0], | ||
lastChangeSum = acc[1]; | ||
var shiftSum = lastShiftSum + child.shift; | ||
var changeSum = lastChangeSum + shiftSum + child.change; | ||
const shiftChange = w => { | ||
(w.children || []).reduce((acc, child) => { | ||
const [lastShiftSum, lastChangeSum] = acc; | ||
const shiftSum = lastShiftSum + child.shift; | ||
const changeSum = lastChangeSum + shiftSum + child.change; | ||
child.relX += changeSum; | ||
@@ -698,10 +673,10 @@ return [shiftSum, changeSum]; | ||
var separate = function separate(w, i, lows) { | ||
var lSib = w.children[i - 1]; | ||
var curSubtree = w.children[i]; | ||
var rContour = lSib; | ||
var rSumMods = lSib.relX; | ||
var lContour = curSubtree; | ||
var lSumMods = curSubtree.relX; | ||
var isFirst = true; | ||
const separate = (w, i, lows) => { | ||
const lSib = w.children[i - 1]; | ||
const curSubtree = w.children[i]; | ||
let rContour = lSib; | ||
let rSumMods = lSib.relX; | ||
let lContour = curSubtree; | ||
let lSumMods = curSubtree.relX; | ||
let isFirst = true; | ||
@@ -713,3 +688,3 @@ while (rContour && lContour) { | ||
var dist = rSumMods + rContour.prelim - (lSumMods + lContour.prelim) + rContour.xSize / 2 + lContour.xSize / 2 + rContour.spacing(lContour); | ||
const dist = rSumMods + rContour.prelim - (lSumMods + lContour.prelim) + rContour.xSize / 2 + lContour.xSize / 2 + rContour.spacing(lContour); | ||
@@ -725,4 +700,4 @@ if (dist > 0 || dist < 0 && isFirst) { | ||
var rightBottom = rContour.bottom; | ||
var leftBottom = lContour.bottom; | ||
const rightBottom = rContour.bottom; | ||
const leftBottom = lContour.bottom; | ||
@@ -749,3 +724,3 @@ if (rightBottom <= leftBottom) { | ||
var moveSubtree = function moveSubtree(subtree, distance) { | ||
const moveSubtree = (subtree, distance) => { | ||
subtree.relX += distance; | ||
@@ -756,8 +731,8 @@ subtree.lExtRelX += distance; | ||
var distributeExtra = function distributeExtra(w, curSubtreeI, leftSibI, dist) { | ||
var curSubtree = w.children[curSubtreeI]; | ||
var n = curSubtreeI - leftSibI; // Are there intermediate children? | ||
const distributeExtra = (w, curSubtreeI, leftSibI, dist) => { | ||
const curSubtree = w.children[curSubtreeI]; | ||
const n = curSubtreeI - leftSibI; // Are there intermediate children? | ||
if (n > 1) { | ||
var delta = dist / n; | ||
const delta = dist / n; | ||
w.children[leftSibI + 1].shift += delta; | ||
@@ -769,17 +744,17 @@ curSubtree.shift -= delta; | ||
var nextLContour = function nextLContour(w) { | ||
const nextLContour = w => { | ||
return w.hasChildren ? w.firstChild : w.lThr; | ||
}; | ||
var nextRContour = function nextRContour(w) { | ||
const nextRContour = w => { | ||
return w.hasChildren ? w.lastChild : w.rThr; | ||
}; | ||
var setLThr = function setLThr(w, i, lContour, lSumMods) { | ||
var firstChild = w.firstChild; | ||
var lExt = firstChild.lExt; | ||
var curSubtree = w.children[i]; | ||
const setLThr = (w, i, lContour, lSumMods) => { | ||
const firstChild = w.firstChild; | ||
const lExt = firstChild.lExt; | ||
const curSubtree = w.children[i]; | ||
lExt.lThr = lContour; // Change relX so that the sum of modifier after following thread is correct. | ||
var diff = lSumMods - lContour.relX - firstChild.lExtRelX; | ||
const diff = lSumMods - lContour.relX - firstChild.lExtRelX; | ||
lExt.relX += diff; // Change preliminary x coordinate so that the node does not move. | ||
@@ -794,8 +769,8 @@ | ||
var setRThr = function setRThr(w, i, rContour, rSumMods) { | ||
var curSubtree = w.children[i]; | ||
var rExt = curSubtree.rExt; | ||
var lSib = w.children[i - 1]; | ||
const setRThr = (w, i, rContour, rSumMods) => { | ||
const curSubtree = w.children[i]; | ||
const rExt = curSubtree.rExt; | ||
const lSib = w.children[i - 1]; | ||
rExt.rThr = rContour; | ||
var diff = rSumMods - rContour.relX - curSubtree.rExtRelX; | ||
const diff = rSumMods - rContour.relX - curSubtree.rExtRelX; | ||
rExt.relX += diff; | ||
@@ -808,9 +783,9 @@ rExt.prelim -= diff; | ||
var positionRoot = function positionRoot(w) { | ||
const positionRoot = w => { | ||
if (w.hasChildren) { | ||
var k0 = w.firstChild; | ||
var kf = w.lastChild; | ||
var prelim = (k0.prelim + k0.relX - k0.xSize / 2 + kf.relX + kf.prelim + kf.xSize / 2) / 2; | ||
const k0 = w.firstChild; | ||
const kf = w.lastChild; | ||
const prelim = (k0.prelim + k0.relX - k0.xSize / 2 + kf.relX + kf.prelim + kf.xSize / 2) / 2; | ||
Object.assign(w, { | ||
prelim: prelim, | ||
prelim, | ||
lExt: k0.lExt, | ||
@@ -826,12 +801,10 @@ lExtRelX: k0.lExtRelX, | ||
var updateLows = function updateLows(lowY, index, lastLows) { | ||
const updateLows = (lowY, index, lastLows) => { | ||
// Remove siblings that are hidden by the new subtree. | ||
while (lastLows !== null && lowY >= lastLows.lowY) { | ||
lastLows = lastLows.next; | ||
} // Prepend the new subtree. | ||
while (lastLows !== null && lowY >= lastLows.lowY) lastLows = lastLows.next; // Prepend the new subtree. | ||
return { | ||
lowY: lowY, | ||
index: index, | ||
lowY, | ||
index, | ||
next: lastLows | ||
@@ -841,3 +814,3 @@ }; | ||
/*! markmap-common v0.1.5 | MIT License */ | ||
/*! markmap-common v0.1.6 | MIT License */ | ||
class Hook { | ||
@@ -1080,9 +1053,2 @@ constructor() { | ||
constructor(svg, opts) { | ||
this.options = void 0; | ||
this.state = void 0; | ||
this.svg = void 0; | ||
this.styleNode = void 0; | ||
this.g = void 0; | ||
this.zoom = void 0; | ||
this.viewHooks = void 0; | ||
this.revokers = []; | ||
@@ -1302,5 +1268,5 @@ ['handleZoom', 'handleClick'].forEach(key => { | ||
fo.append('xhtml:div').select(function select(d) { | ||
const node = d.data.p.el.cloneNode(true); | ||
this.replaceWith(node); | ||
return node; | ||
const clone = d.data.p.el.cloneNode(true); | ||
this.replaceWith(clone); | ||
return clone; | ||
}).attr('xmlns', 'http://www.w3.org/1999/xhtml'); | ||
@@ -1307,0 +1273,0 @@ return fo; |
@@ -1,2 +0,2 @@ | ||
/*! markmap-view v0.2.6 | MIT License */ | ||
/*! markmap-view v0.2.7 | MIT License */ | ||
import * as d3 from 'd3'; | ||
@@ -22,41 +22,2 @@ | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
_setPrototypeOf(subClass, superClass); | ||
} | ||
function count(node) { | ||
@@ -66,5 +27,3 @@ var sum = 0, | ||
i = children && children.length; | ||
if (!i) sum = 1;else while (--i >= 0) { | ||
sum += children[i].value; | ||
} | ||
if (!i) sum = 1;else while (--i >= 0) sum += children[i].value; | ||
node.value = sum; | ||
@@ -143,5 +102,3 @@ } | ||
while (--i >= 0) { | ||
sum += children[i].value; | ||
} | ||
while (--i >= 0) sum += children[i].value; | ||
@@ -284,5 +241,3 @@ node.value = sum; | ||
do { | ||
node.height = height; | ||
} while ((node = node.parent) && node.height < ++height); | ||
do node.height = height; while ((node = node.parent) && node.height < ++height); | ||
} | ||
@@ -310,11 +265,86 @@ function Node(data) { | ||
var version = "2.1.1"; | ||
var name = "d3-flextree"; | ||
var version$1 = "2.1.2"; | ||
var main = "build/d3-flextree.js"; | ||
var module = "index"; | ||
var author = { | ||
name: "Chris Maloney", | ||
url: "http://chrismaloney.org" | ||
}; | ||
var description = "Flexible tree layout algorithm that allows for variable node sizes."; | ||
var keywords = [ | ||
"d3", | ||
"d3-module", | ||
"layout", | ||
"tree", | ||
"hierarchy", | ||
"d3-hierarchy", | ||
"plugin", | ||
"d3-plugin", | ||
"infovis", | ||
"visualization", | ||
"2d" | ||
]; | ||
var homepage = "https://github.com/klortho/d3-flextree"; | ||
var license = "WTFPL"; | ||
var repository = { | ||
type: "git", | ||
url: "https://github.com/klortho/d3-flextree.git" | ||
}; | ||
var scripts = { | ||
clean: "rm -rf build demo test", | ||
"build:demo": "rollup -c --environment BUILD:demo", | ||
"build:dev": "rollup -c --environment BUILD:dev", | ||
"build:prod": "rollup -c --environment BUILD:prod", | ||
"build:test": "rollup -c --environment BUILD:test", | ||
build: "rollup -c", | ||
lint: "eslint index.js src", | ||
"test:main": "node test/bundle.js", | ||
"test:browser": "node test/browser-tests.js", | ||
test: "npm-run-all test:*", | ||
prepare: "npm-run-all clean build lint test" | ||
}; | ||
var dependencies = { | ||
"d3-hierarchy": "^1.1.5" | ||
}; | ||
var devDependencies = { | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-preset-es2015-rollup": "^3.0.0", | ||
d3: "^4.13.0", | ||
"d3-selection-multi": "^1.0.1", | ||
eslint: "^4.19.1", | ||
jsdom: "^11.6.2", | ||
"npm-run-all": "^4.1.2", | ||
rollup: "^0.55.3", | ||
"rollup-plugin-babel": "^2.7.1", | ||
"rollup-plugin-commonjs": "^8.0.2", | ||
"rollup-plugin-copy": "^0.2.3", | ||
"rollup-plugin-json": "^2.3.0", | ||
"rollup-plugin-node-resolve": "^3.0.2", | ||
"rollup-plugin-uglify": "^3.0.0", | ||
"uglify-es": "^3.3.9" | ||
}; | ||
var packageInfo = { | ||
name: name, | ||
version: version$1, | ||
main: main, | ||
module: module, | ||
"jsnext:main": "index", | ||
author: author, | ||
description: description, | ||
keywords: keywords, | ||
homepage: homepage, | ||
license: license, | ||
repository: repository, | ||
scripts: scripts, | ||
dependencies: dependencies, | ||
devDependencies: devDependencies | ||
}; | ||
var defaults = Object.freeze({ | ||
children: function children(data) { | ||
return data.children; | ||
}, | ||
nodeSize: function nodeSize(node) { | ||
return node.data.size; | ||
}, | ||
const { | ||
version | ||
} = packageInfo; | ||
const defaults = Object.freeze({ | ||
children: data => data.children, | ||
nodeSize: node => node.data.size, | ||
spacing: 0 | ||
@@ -327,15 +357,11 @@ }); // Create a layout function with customizable options. Per D3-style, the | ||
function flextree(options) { | ||
var opts = Object.assign({}, defaults, options); | ||
const opts = Object.assign({}, defaults, options); | ||
function accessor(name) { | ||
var opt = opts[name]; | ||
return typeof opt === 'function' ? opt : function () { | ||
return opt; | ||
}; | ||
const opt = opts[name]; | ||
return typeof opt === 'function' ? opt : () => opt; | ||
} | ||
function layout(tree) { | ||
var wtree = wrap(getWrapper(), tree, function (node) { | ||
return node.children; | ||
}); | ||
const wtree = wrap(getWrapper(), tree, node => node.children); | ||
wtree.update(); | ||
@@ -346,31 +372,91 @@ return wtree.data; | ||
function getFlexNode() { | ||
var nodeSize = accessor('nodeSize'); | ||
const nodeSize = accessor('nodeSize'); | ||
const spacing = accessor('spacing'); | ||
return class FlexNode extends hierarchy.prototype.constructor { | ||
constructor(data) { | ||
super(data); | ||
} | ||
var _spacing = accessor('spacing'); | ||
copy() { | ||
const c = wrap(this.constructor, this, node => node.children); | ||
c.each(node => node.data = node.data.data); | ||
return c; | ||
} | ||
return /*#__PURE__*/function (_hierarchy$prototype$) { | ||
_inheritsLoose(FlexNode, _hierarchy$prototype$); | ||
get size() { | ||
return nodeSize(this); | ||
} | ||
function FlexNode(data) { | ||
return _hierarchy$prototype$.call(this, data) || this; | ||
spacing(oNode) { | ||
return spacing(this, oNode); | ||
} | ||
var _proto = FlexNode.prototype; | ||
get nodes() { | ||
return this.descendants(); | ||
} | ||
_proto.copy = function copy() { | ||
var c = wrap(this.constructor, this, function (node) { | ||
return node.children; | ||
}); | ||
c.each(function (node) { | ||
return node.data = node.data.data; | ||
}); | ||
return c; | ||
}; | ||
get xSize() { | ||
return this.size[0]; | ||
} | ||
_proto.spacing = function spacing(oNode) { | ||
return _spacing(this, oNode); | ||
}; | ||
get ySize() { | ||
return this.size[1]; | ||
} | ||
FlexNode.maxExtents = function maxExtents(e0, e1) { | ||
get top() { | ||
return this.y; | ||
} | ||
get bottom() { | ||
return this.y + this.ySize; | ||
} | ||
get left() { | ||
return this.x - this.xSize / 2; | ||
} | ||
get right() { | ||
return this.x + this.xSize / 2; | ||
} | ||
get root() { | ||
const ancs = this.ancestors(); | ||
return ancs[ancs.length - 1]; | ||
} | ||
get numChildren() { | ||
return this.hasChildren ? this.children.length : 0; | ||
} | ||
get hasChildren() { | ||
return !this.noChildren; | ||
} | ||
get noChildren() { | ||
return this.children === null; | ||
} | ||
get firstChild() { | ||
return this.hasChildren ? this.children[0] : null; | ||
} | ||
get lastChild() { | ||
return this.hasChildren ? this.children[this.numChildren - 1] : null; | ||
} | ||
get extents() { | ||
return (this.children || []).reduce((acc, kid) => FlexNode.maxExtents(acc, kid.extents), this.nodeExtents); | ||
} | ||
get nodeExtents() { | ||
return { | ||
top: this.top, | ||
bottom: this.bottom, | ||
left: this.left, | ||
right: this.right | ||
}; | ||
} | ||
static maxExtents(e0, e1) { | ||
return { | ||
top: Math.min(e0.top, e1.top), | ||
@@ -381,112 +467,15 @@ bottom: Math.max(e0.bottom, e1.bottom), | ||
}; | ||
}; | ||
} | ||
_createClass(FlexNode, [{ | ||
key: "size", | ||
get: function get() { | ||
return nodeSize(this); | ||
} | ||
}, { | ||
key: "nodes", | ||
get: function get() { | ||
return this.descendants(); | ||
} | ||
}, { | ||
key: "xSize", | ||
get: function get() { | ||
return this.size[0]; | ||
} | ||
}, { | ||
key: "ySize", | ||
get: function get() { | ||
return this.size[1]; | ||
} | ||
}, { | ||
key: "top", | ||
get: function get() { | ||
return this.y; | ||
} | ||
}, { | ||
key: "bottom", | ||
get: function get() { | ||
return this.y + this.ySize; | ||
} | ||
}, { | ||
key: "left", | ||
get: function get() { | ||
return this.x - this.xSize / 2; | ||
} | ||
}, { | ||
key: "right", | ||
get: function get() { | ||
return this.x + this.xSize / 2; | ||
} | ||
}, { | ||
key: "root", | ||
get: function get() { | ||
var ancs = this.ancestors(); | ||
return ancs[ancs.length - 1]; | ||
} | ||
}, { | ||
key: "numChildren", | ||
get: function get() { | ||
return this.hasChildren ? this.children.length : 0; | ||
} | ||
}, { | ||
key: "hasChildren", | ||
get: function get() { | ||
return !this.noChildren; | ||
} | ||
}, { | ||
key: "noChildren", | ||
get: function get() { | ||
return this.children === null; | ||
} | ||
}, { | ||
key: "firstChild", | ||
get: function get() { | ||
return this.hasChildren ? this.children[0] : null; | ||
} | ||
}, { | ||
key: "lastChild", | ||
get: function get() { | ||
return this.hasChildren ? this.children[this.numChildren - 1] : null; | ||
} | ||
}, { | ||
key: "extents", | ||
get: function get() { | ||
return (this.children || []).reduce(function (acc, kid) { | ||
return FlexNode.maxExtents(acc, kid.extents); | ||
}, this.nodeExtents); | ||
} | ||
}, { | ||
key: "nodeExtents", | ||
get: function get() { | ||
return { | ||
top: this.top, | ||
bottom: this.bottom, | ||
left: this.left, | ||
right: this.right | ||
}; | ||
} | ||
}]); | ||
return FlexNode; | ||
}(hierarchy.prototype.constructor); | ||
}; | ||
} | ||
function getWrapper() { | ||
var FlexNode = getFlexNode(); | ||
var nodeSize = accessor('nodeSize'); | ||
var _spacing2 = accessor('spacing'); | ||
return /*#__PURE__*/function (_FlexNode) { | ||
_inheritsLoose(_class, _FlexNode); | ||
function _class(data) { | ||
var _this; | ||
_this = _FlexNode.call(this, data) || this; | ||
Object.assign(_assertThisInitialized(_this), { | ||
const FlexNode = getFlexNode(); | ||
const nodeSize = accessor('nodeSize'); | ||
const spacing = accessor('spacing'); | ||
return class extends FlexNode { | ||
constructor(data) { | ||
super(data); | ||
Object.assign(this, { | ||
x: 0, | ||
@@ -498,56 +487,49 @@ y: 0, | ||
change: 0, | ||
lExt: _assertThisInitialized(_this), | ||
lExt: this, | ||
lExtRelX: 0, | ||
lThr: null, | ||
rExt: _assertThisInitialized(_this), | ||
rExt: this, | ||
rExtRelX: 0, | ||
rThr: null | ||
}); | ||
return _this; | ||
} | ||
var _proto2 = _class.prototype; | ||
get size() { | ||
return nodeSize(this.data); | ||
} | ||
_proto2.spacing = function spacing(oNode) { | ||
return _spacing2(this.data, oNode.data); | ||
}; | ||
spacing(oNode) { | ||
return spacing(this.data, oNode.data); | ||
} | ||
_proto2.update = function update() { | ||
get x() { | ||
return this.data.x; | ||
} | ||
set x(v) { | ||
this.data.x = v; | ||
} | ||
get y() { | ||
return this.data.y; | ||
} | ||
set y(v) { | ||
this.data.y = v; | ||
} | ||
update() { | ||
layoutChildren(this); | ||
resolveX(this); | ||
return this; | ||
}; | ||
} | ||
_createClass(_class, [{ | ||
key: "size", | ||
get: function get() { | ||
return nodeSize(this.data); | ||
} | ||
}, { | ||
key: "x", | ||
get: function get() { | ||
return this.data.x; | ||
}, | ||
set: function set(v) { | ||
this.data.x = v; | ||
} | ||
}, { | ||
key: "y", | ||
get: function get() { | ||
return this.data.y; | ||
}, | ||
set: function set(v) { | ||
this.data.y = v; | ||
} | ||
}]); | ||
return _class; | ||
}(FlexNode); | ||
}; | ||
} | ||
function wrap(FlexClass, treeData, children) { | ||
var _wrap = function _wrap(data, parent) { | ||
var node = new FlexClass(data); | ||
const _wrap = (data, parent) => { | ||
const node = new FlexClass(data); | ||
Object.assign(node, { | ||
parent: parent, | ||
parent, | ||
depth: parent === null ? 0 : parent.depth + 1, | ||
@@ -557,14 +539,10 @@ height: 0, | ||
}); | ||
var kidsData = children(data) || []; | ||
node.children = kidsData.length === 0 ? null : kidsData.map(function (kd) { | ||
return _wrap(kd, node); | ||
}); | ||
const kidsData = children(data) || []; | ||
node.children = kidsData.length === 0 ? null : kidsData.map(kd => _wrap(kd, node)); | ||
if (node.children) { | ||
Object.assign(node, node.children.reduce(function (hl, kid) { | ||
return { | ||
height: Math.max(hl.height, kid.height + 1), | ||
length: hl.length + kid.length | ||
}; | ||
}, node)); | ||
Object.assign(node, node.children.reduce((hl, kid) => ({ | ||
height: Math.max(hl.height, kid.height + 1), | ||
length: hl.length + kid.length | ||
}), node)); | ||
} | ||
@@ -579,29 +557,33 @@ | ||
Object.assign(layout, { | ||
nodeSize: function nodeSize(arg) { | ||
nodeSize(arg) { | ||
return arguments.length ? (opts.nodeSize = arg, layout) : opts.nodeSize; | ||
}, | ||
spacing: function spacing(arg) { | ||
spacing(arg) { | ||
return arguments.length ? (opts.spacing = arg, layout) : opts.spacing; | ||
}, | ||
children: function children(arg) { | ||
children(arg) { | ||
return arguments.length ? (opts.children = arg, layout) : opts.children; | ||
}, | ||
hierarchy: function hierarchy(treeData, children) { | ||
var kids = typeof children === 'undefined' ? opts.children : children; | ||
hierarchy(treeData, children) { | ||
const kids = typeof children === 'undefined' ? opts.children : children; | ||
return wrap(getFlexNode(), treeData, kids); | ||
}, | ||
dump: function dump(tree) { | ||
var nodeSize = accessor('nodeSize'); | ||
var _dump = function _dump(i0) { | ||
return function (node) { | ||
var i1 = i0 + ' '; | ||
var i2 = i0 + ' '; | ||
var x = node.x, | ||
y = node.y; | ||
var size = nodeSize(node); | ||
var kids = node.children || []; | ||
var kdumps = kids.length === 0 ? ' ' : "," + i1 + "children: [" + i2 + kids.map(_dump(i2)).join(i2) + i1 + "]," + i0; | ||
return "{ size: [" + size.join(', ') + "]," + i1 + "x: " + x + ", y: " + y + kdumps + "},"; | ||
}; | ||
dump(tree) { | ||
const nodeSize = accessor('nodeSize'); | ||
const _dump = i0 => node => { | ||
const i1 = i0 + ' '; | ||
const i2 = i0 + ' '; | ||
const { | ||
x, | ||
y | ||
} = node; | ||
const size = nodeSize(node); | ||
const kids = node.children || []; | ||
const kdumps = kids.length === 0 ? ' ' : `,${i1}children: [${i2}${kids.map(_dump(i2)).join(i2)}${i1}],${i0}`; | ||
return `{ size: [${size.join(', ')}],${i1}x: ${x}, y: ${y}${kdumps}},`; | ||
}; | ||
@@ -611,2 +593,3 @@ | ||
} | ||
}); | ||
@@ -617,17 +600,12 @@ return layout; | ||
var layoutChildren = function layoutChildren(w, y) { | ||
if (y === void 0) { | ||
y = 0; | ||
} | ||
const layoutChildren = (w, y = 0) => { | ||
w.y = y; | ||
(w.children || []).reduce(function (acc, kid) { | ||
var i = acc[0], | ||
lastLows = acc[1]; | ||
(w.children || []).reduce((acc, kid) => { | ||
const [i, lastLows] = acc; | ||
layoutChildren(kid, w.y + w.ySize); // The lowest vertical coordinate while extreme nodes still point | ||
// in current subtree. | ||
var lowY = (i === 0 ? kid.lExt : kid.rExt).bottom; | ||
const lowY = (i === 0 ? kid.lExt : kid.rExt).bottom; | ||
if (i !== 0) separate(w, i, lastLows); | ||
var lows = updateLows(lowY, i, lastLows); | ||
const lows = updateLows(lowY, i, lastLows); | ||
return [i + 1, lows]; | ||
@@ -644,3 +622,3 @@ }, [0, null]); | ||
var resolveX = function resolveX(w, prevSum, parentX) { | ||
const resolveX = (w, prevSum, parentX) => { | ||
// A call to resolveX without arguments is assumed to be for the root of | ||
@@ -653,9 +631,7 @@ // the tree. This will set the root's x-coord to zero. | ||
var sum = prevSum + w.relX; | ||
const sum = prevSum + w.relX; | ||
w.relX = sum + w.prelim - parentX; | ||
w.prelim = 0; | ||
w.x = parentX + w.relX; | ||
(w.children || []).forEach(function (k) { | ||
return resolveX(k, sum, w.x); | ||
}); | ||
(w.children || []).forEach(k => resolveX(k, sum, w.x)); | ||
return w; | ||
@@ -666,8 +642,7 @@ }; // Process shift and change for all children, to add intermediate spacing to | ||
var shiftChange = function shiftChange(w) { | ||
(w.children || []).reduce(function (acc, child) { | ||
var lastShiftSum = acc[0], | ||
lastChangeSum = acc[1]; | ||
var shiftSum = lastShiftSum + child.shift; | ||
var changeSum = lastChangeSum + shiftSum + child.change; | ||
const shiftChange = w => { | ||
(w.children || []).reduce((acc, child) => { | ||
const [lastShiftSum, lastChangeSum] = acc; | ||
const shiftSum = lastShiftSum + child.shift; | ||
const changeSum = lastChangeSum + shiftSum + child.change; | ||
child.relX += changeSum; | ||
@@ -681,10 +656,10 @@ return [shiftSum, changeSum]; | ||
var separate = function separate(w, i, lows) { | ||
var lSib = w.children[i - 1]; | ||
var curSubtree = w.children[i]; | ||
var rContour = lSib; | ||
var rSumMods = lSib.relX; | ||
var lContour = curSubtree; | ||
var lSumMods = curSubtree.relX; | ||
var isFirst = true; | ||
const separate = (w, i, lows) => { | ||
const lSib = w.children[i - 1]; | ||
const curSubtree = w.children[i]; | ||
let rContour = lSib; | ||
let rSumMods = lSib.relX; | ||
let lContour = curSubtree; | ||
let lSumMods = curSubtree.relX; | ||
let isFirst = true; | ||
@@ -696,3 +671,3 @@ while (rContour && lContour) { | ||
var dist = rSumMods + rContour.prelim - (lSumMods + lContour.prelim) + rContour.xSize / 2 + lContour.xSize / 2 + rContour.spacing(lContour); | ||
const dist = rSumMods + rContour.prelim - (lSumMods + lContour.prelim) + rContour.xSize / 2 + lContour.xSize / 2 + rContour.spacing(lContour); | ||
@@ -708,4 +683,4 @@ if (dist > 0 || dist < 0 && isFirst) { | ||
var rightBottom = rContour.bottom; | ||
var leftBottom = lContour.bottom; | ||
const rightBottom = rContour.bottom; | ||
const leftBottom = lContour.bottom; | ||
@@ -732,3 +707,3 @@ if (rightBottom <= leftBottom) { | ||
var moveSubtree = function moveSubtree(subtree, distance) { | ||
const moveSubtree = (subtree, distance) => { | ||
subtree.relX += distance; | ||
@@ -739,8 +714,8 @@ subtree.lExtRelX += distance; | ||
var distributeExtra = function distributeExtra(w, curSubtreeI, leftSibI, dist) { | ||
var curSubtree = w.children[curSubtreeI]; | ||
var n = curSubtreeI - leftSibI; // Are there intermediate children? | ||
const distributeExtra = (w, curSubtreeI, leftSibI, dist) => { | ||
const curSubtree = w.children[curSubtreeI]; | ||
const n = curSubtreeI - leftSibI; // Are there intermediate children? | ||
if (n > 1) { | ||
var delta = dist / n; | ||
const delta = dist / n; | ||
w.children[leftSibI + 1].shift += delta; | ||
@@ -752,17 +727,17 @@ curSubtree.shift -= delta; | ||
var nextLContour = function nextLContour(w) { | ||
const nextLContour = w => { | ||
return w.hasChildren ? w.firstChild : w.lThr; | ||
}; | ||
var nextRContour = function nextRContour(w) { | ||
const nextRContour = w => { | ||
return w.hasChildren ? w.lastChild : w.rThr; | ||
}; | ||
var setLThr = function setLThr(w, i, lContour, lSumMods) { | ||
var firstChild = w.firstChild; | ||
var lExt = firstChild.lExt; | ||
var curSubtree = w.children[i]; | ||
const setLThr = (w, i, lContour, lSumMods) => { | ||
const firstChild = w.firstChild; | ||
const lExt = firstChild.lExt; | ||
const curSubtree = w.children[i]; | ||
lExt.lThr = lContour; // Change relX so that the sum of modifier after following thread is correct. | ||
var diff = lSumMods - lContour.relX - firstChild.lExtRelX; | ||
const diff = lSumMods - lContour.relX - firstChild.lExtRelX; | ||
lExt.relX += diff; // Change preliminary x coordinate so that the node does not move. | ||
@@ -777,8 +752,8 @@ | ||
var setRThr = function setRThr(w, i, rContour, rSumMods) { | ||
var curSubtree = w.children[i]; | ||
var rExt = curSubtree.rExt; | ||
var lSib = w.children[i - 1]; | ||
const setRThr = (w, i, rContour, rSumMods) => { | ||
const curSubtree = w.children[i]; | ||
const rExt = curSubtree.rExt; | ||
const lSib = w.children[i - 1]; | ||
rExt.rThr = rContour; | ||
var diff = rSumMods - rContour.relX - curSubtree.rExtRelX; | ||
const diff = rSumMods - rContour.relX - curSubtree.rExtRelX; | ||
rExt.relX += diff; | ||
@@ -791,9 +766,9 @@ rExt.prelim -= diff; | ||
var positionRoot = function positionRoot(w) { | ||
const positionRoot = w => { | ||
if (w.hasChildren) { | ||
var k0 = w.firstChild; | ||
var kf = w.lastChild; | ||
var prelim = (k0.prelim + k0.relX - k0.xSize / 2 + kf.relX + kf.prelim + kf.xSize / 2) / 2; | ||
const k0 = w.firstChild; | ||
const kf = w.lastChild; | ||
const prelim = (k0.prelim + k0.relX - k0.xSize / 2 + kf.relX + kf.prelim + kf.xSize / 2) / 2; | ||
Object.assign(w, { | ||
prelim: prelim, | ||
prelim, | ||
lExt: k0.lExt, | ||
@@ -809,12 +784,10 @@ lExtRelX: k0.lExtRelX, | ||
var updateLows = function updateLows(lowY, index, lastLows) { | ||
const updateLows = (lowY, index, lastLows) => { | ||
// Remove siblings that are hidden by the new subtree. | ||
while (lastLows !== null && lowY >= lastLows.lowY) { | ||
lastLows = lastLows.next; | ||
} // Prepend the new subtree. | ||
while (lastLows !== null && lowY >= lastLows.lowY) lastLows = lastLows.next; // Prepend the new subtree. | ||
return { | ||
lowY: lowY, | ||
index: index, | ||
lowY, | ||
index, | ||
next: lastLows | ||
@@ -824,3 +797,3 @@ }; | ||
/*! markmap-common v0.1.5 | MIT License */ | ||
/*! markmap-common v0.1.6 | MIT License */ | ||
class Hook { | ||
@@ -1063,9 +1036,2 @@ constructor() { | ||
constructor(svg, opts) { | ||
this.options = void 0; | ||
this.state = void 0; | ||
this.svg = void 0; | ||
this.styleNode = void 0; | ||
this.g = void 0; | ||
this.zoom = void 0; | ||
this.viewHooks = void 0; | ||
this.revokers = []; | ||
@@ -1285,5 +1251,5 @@ ['handleZoom', 'handleClick'].forEach(key => { | ||
fo.append('xhtml:div').select(function select(d) { | ||
const node = d.data.p.el.cloneNode(true); | ||
this.replaceWith(node); | ||
return node; | ||
const clone = d.data.p.el.cloneNode(true); | ||
this.replaceWith(clone); | ||
return clone; | ||
}).attr('xmlns', 'http://www.w3.org/1999/xhtml'); | ||
@@ -1290,0 +1256,0 @@ return fo; |
@@ -1,2 +0,2 @@ | ||
/*! markmap-view v0.2.6 | MIT License */ | ||
/*! markmap-view v0.2.7 | MIT License */ | ||
(function (exports, d3) { | ||
@@ -9,7 +9,7 @@ 'use strict'; | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
for (var k in e) { | ||
n[k] = e[k]; | ||
}); | ||
} | ||
n['default'] = e; | ||
} | ||
n["default"] = e; | ||
return Object.freeze(n); | ||
@@ -38,41 +38,2 @@ } | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
_setPrototypeOf(subClass, superClass); | ||
} | ||
function count(node) { | ||
@@ -82,5 +43,3 @@ var sum = 0, | ||
i = children && children.length; | ||
if (!i) sum = 1;else while (--i >= 0) { | ||
sum += children[i].value; | ||
} | ||
if (!i) sum = 1;else while (--i >= 0) sum += children[i].value; | ||
node.value = sum; | ||
@@ -159,5 +118,3 @@ } | ||
while (--i >= 0) { | ||
sum += children[i].value; | ||
} | ||
while (--i >= 0) sum += children[i].value; | ||
@@ -300,5 +257,3 @@ node.value = sum; | ||
do { | ||
node.height = height; | ||
} while ((node = node.parent) && node.height < ++height); | ||
do node.height = height; while ((node = node.parent) && node.height < ++height); | ||
} | ||
@@ -326,11 +281,86 @@ function Node(data) { | ||
var version = "2.1.1"; | ||
var name = "d3-flextree"; | ||
var version$1 = "2.1.2"; | ||
var main = "build/d3-flextree.js"; | ||
var module = "index"; | ||
var author = { | ||
name: "Chris Maloney", | ||
url: "http://chrismaloney.org" | ||
}; | ||
var description = "Flexible tree layout algorithm that allows for variable node sizes."; | ||
var keywords = [ | ||
"d3", | ||
"d3-module", | ||
"layout", | ||
"tree", | ||
"hierarchy", | ||
"d3-hierarchy", | ||
"plugin", | ||
"d3-plugin", | ||
"infovis", | ||
"visualization", | ||
"2d" | ||
]; | ||
var homepage = "https://github.com/klortho/d3-flextree"; | ||
var license = "WTFPL"; | ||
var repository = { | ||
type: "git", | ||
url: "https://github.com/klortho/d3-flextree.git" | ||
}; | ||
var scripts = { | ||
clean: "rm -rf build demo test", | ||
"build:demo": "rollup -c --environment BUILD:demo", | ||
"build:dev": "rollup -c --environment BUILD:dev", | ||
"build:prod": "rollup -c --environment BUILD:prod", | ||
"build:test": "rollup -c --environment BUILD:test", | ||
build: "rollup -c", | ||
lint: "eslint index.js src", | ||
"test:main": "node test/bundle.js", | ||
"test:browser": "node test/browser-tests.js", | ||
test: "npm-run-all test:*", | ||
prepare: "npm-run-all clean build lint test" | ||
}; | ||
var dependencies = { | ||
"d3-hierarchy": "^1.1.5" | ||
}; | ||
var devDependencies = { | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-preset-es2015-rollup": "^3.0.0", | ||
d3: "^4.13.0", | ||
"d3-selection-multi": "^1.0.1", | ||
eslint: "^4.19.1", | ||
jsdom: "^11.6.2", | ||
"npm-run-all": "^4.1.2", | ||
rollup: "^0.55.3", | ||
"rollup-plugin-babel": "^2.7.1", | ||
"rollup-plugin-commonjs": "^8.0.2", | ||
"rollup-plugin-copy": "^0.2.3", | ||
"rollup-plugin-json": "^2.3.0", | ||
"rollup-plugin-node-resolve": "^3.0.2", | ||
"rollup-plugin-uglify": "^3.0.0", | ||
"uglify-es": "^3.3.9" | ||
}; | ||
var packageInfo = { | ||
name: name, | ||
version: version$1, | ||
main: main, | ||
module: module, | ||
"jsnext:main": "index", | ||
author: author, | ||
description: description, | ||
keywords: keywords, | ||
homepage: homepage, | ||
license: license, | ||
repository: repository, | ||
scripts: scripts, | ||
dependencies: dependencies, | ||
devDependencies: devDependencies | ||
}; | ||
var defaults = Object.freeze({ | ||
children: function children(data) { | ||
return data.children; | ||
}, | ||
nodeSize: function nodeSize(node) { | ||
return node.data.size; | ||
}, | ||
const { | ||
version | ||
} = packageInfo; | ||
const defaults = Object.freeze({ | ||
children: data => data.children, | ||
nodeSize: node => node.data.size, | ||
spacing: 0 | ||
@@ -343,15 +373,11 @@ }); // Create a layout function with customizable options. Per D3-style, the | ||
function flextree(options) { | ||
var opts = Object.assign({}, defaults, options); | ||
const opts = Object.assign({}, defaults, options); | ||
function accessor(name) { | ||
var opt = opts[name]; | ||
return typeof opt === 'function' ? opt : function () { | ||
return opt; | ||
}; | ||
const opt = opts[name]; | ||
return typeof opt === 'function' ? opt : () => opt; | ||
} | ||
function layout(tree) { | ||
var wtree = wrap(getWrapper(), tree, function (node) { | ||
return node.children; | ||
}); | ||
const wtree = wrap(getWrapper(), tree, node => node.children); | ||
wtree.update(); | ||
@@ -362,31 +388,91 @@ return wtree.data; | ||
function getFlexNode() { | ||
var nodeSize = accessor('nodeSize'); | ||
const nodeSize = accessor('nodeSize'); | ||
const spacing = accessor('spacing'); | ||
return class FlexNode extends hierarchy.prototype.constructor { | ||
constructor(data) { | ||
super(data); | ||
} | ||
var _spacing = accessor('spacing'); | ||
copy() { | ||
const c = wrap(this.constructor, this, node => node.children); | ||
c.each(node => node.data = node.data.data); | ||
return c; | ||
} | ||
return /*#__PURE__*/function (_hierarchy$prototype$) { | ||
_inheritsLoose(FlexNode, _hierarchy$prototype$); | ||
get size() { | ||
return nodeSize(this); | ||
} | ||
function FlexNode(data) { | ||
return _hierarchy$prototype$.call(this, data) || this; | ||
spacing(oNode) { | ||
return spacing(this, oNode); | ||
} | ||
var _proto = FlexNode.prototype; | ||
get nodes() { | ||
return this.descendants(); | ||
} | ||
_proto.copy = function copy() { | ||
var c = wrap(this.constructor, this, function (node) { | ||
return node.children; | ||
}); | ||
c.each(function (node) { | ||
return node.data = node.data.data; | ||
}); | ||
return c; | ||
}; | ||
get xSize() { | ||
return this.size[0]; | ||
} | ||
_proto.spacing = function spacing(oNode) { | ||
return _spacing(this, oNode); | ||
}; | ||
get ySize() { | ||
return this.size[1]; | ||
} | ||
FlexNode.maxExtents = function maxExtents(e0, e1) { | ||
get top() { | ||
return this.y; | ||
} | ||
get bottom() { | ||
return this.y + this.ySize; | ||
} | ||
get left() { | ||
return this.x - this.xSize / 2; | ||
} | ||
get right() { | ||
return this.x + this.xSize / 2; | ||
} | ||
get root() { | ||
const ancs = this.ancestors(); | ||
return ancs[ancs.length - 1]; | ||
} | ||
get numChildren() { | ||
return this.hasChildren ? this.children.length : 0; | ||
} | ||
get hasChildren() { | ||
return !this.noChildren; | ||
} | ||
get noChildren() { | ||
return this.children === null; | ||
} | ||
get firstChild() { | ||
return this.hasChildren ? this.children[0] : null; | ||
} | ||
get lastChild() { | ||
return this.hasChildren ? this.children[this.numChildren - 1] : null; | ||
} | ||
get extents() { | ||
return (this.children || []).reduce((acc, kid) => FlexNode.maxExtents(acc, kid.extents), this.nodeExtents); | ||
} | ||
get nodeExtents() { | ||
return { | ||
top: this.top, | ||
bottom: this.bottom, | ||
left: this.left, | ||
right: this.right | ||
}; | ||
} | ||
static maxExtents(e0, e1) { | ||
return { | ||
top: Math.min(e0.top, e1.top), | ||
@@ -397,112 +483,15 @@ bottom: Math.max(e0.bottom, e1.bottom), | ||
}; | ||
}; | ||
} | ||
_createClass(FlexNode, [{ | ||
key: "size", | ||
get: function get() { | ||
return nodeSize(this); | ||
} | ||
}, { | ||
key: "nodes", | ||
get: function get() { | ||
return this.descendants(); | ||
} | ||
}, { | ||
key: "xSize", | ||
get: function get() { | ||
return this.size[0]; | ||
} | ||
}, { | ||
key: "ySize", | ||
get: function get() { | ||
return this.size[1]; | ||
} | ||
}, { | ||
key: "top", | ||
get: function get() { | ||
return this.y; | ||
} | ||
}, { | ||
key: "bottom", | ||
get: function get() { | ||
return this.y + this.ySize; | ||
} | ||
}, { | ||
key: "left", | ||
get: function get() { | ||
return this.x - this.xSize / 2; | ||
} | ||
}, { | ||
key: "right", | ||
get: function get() { | ||
return this.x + this.xSize / 2; | ||
} | ||
}, { | ||
key: "root", | ||
get: function get() { | ||
var ancs = this.ancestors(); | ||
return ancs[ancs.length - 1]; | ||
} | ||
}, { | ||
key: "numChildren", | ||
get: function get() { | ||
return this.hasChildren ? this.children.length : 0; | ||
} | ||
}, { | ||
key: "hasChildren", | ||
get: function get() { | ||
return !this.noChildren; | ||
} | ||
}, { | ||
key: "noChildren", | ||
get: function get() { | ||
return this.children === null; | ||
} | ||
}, { | ||
key: "firstChild", | ||
get: function get() { | ||
return this.hasChildren ? this.children[0] : null; | ||
} | ||
}, { | ||
key: "lastChild", | ||
get: function get() { | ||
return this.hasChildren ? this.children[this.numChildren - 1] : null; | ||
} | ||
}, { | ||
key: "extents", | ||
get: function get() { | ||
return (this.children || []).reduce(function (acc, kid) { | ||
return FlexNode.maxExtents(acc, kid.extents); | ||
}, this.nodeExtents); | ||
} | ||
}, { | ||
key: "nodeExtents", | ||
get: function get() { | ||
return { | ||
top: this.top, | ||
bottom: this.bottom, | ||
left: this.left, | ||
right: this.right | ||
}; | ||
} | ||
}]); | ||
return FlexNode; | ||
}(hierarchy.prototype.constructor); | ||
}; | ||
} | ||
function getWrapper() { | ||
var FlexNode = getFlexNode(); | ||
var nodeSize = accessor('nodeSize'); | ||
var _spacing2 = accessor('spacing'); | ||
return /*#__PURE__*/function (_FlexNode) { | ||
_inheritsLoose(_class, _FlexNode); | ||
function _class(data) { | ||
var _this; | ||
_this = _FlexNode.call(this, data) || this; | ||
Object.assign(_assertThisInitialized(_this), { | ||
const FlexNode = getFlexNode(); | ||
const nodeSize = accessor('nodeSize'); | ||
const spacing = accessor('spacing'); | ||
return class extends FlexNode { | ||
constructor(data) { | ||
super(data); | ||
Object.assign(this, { | ||
x: 0, | ||
@@ -514,56 +503,49 @@ y: 0, | ||
change: 0, | ||
lExt: _assertThisInitialized(_this), | ||
lExt: this, | ||
lExtRelX: 0, | ||
lThr: null, | ||
rExt: _assertThisInitialized(_this), | ||
rExt: this, | ||
rExtRelX: 0, | ||
rThr: null | ||
}); | ||
return _this; | ||
} | ||
var _proto2 = _class.prototype; | ||
get size() { | ||
return nodeSize(this.data); | ||
} | ||
_proto2.spacing = function spacing(oNode) { | ||
return _spacing2(this.data, oNode.data); | ||
}; | ||
spacing(oNode) { | ||
return spacing(this.data, oNode.data); | ||
} | ||
_proto2.update = function update() { | ||
get x() { | ||
return this.data.x; | ||
} | ||
set x(v) { | ||
this.data.x = v; | ||
} | ||
get y() { | ||
return this.data.y; | ||
} | ||
set y(v) { | ||
this.data.y = v; | ||
} | ||
update() { | ||
layoutChildren(this); | ||
resolveX(this); | ||
return this; | ||
}; | ||
} | ||
_createClass(_class, [{ | ||
key: "size", | ||
get: function get() { | ||
return nodeSize(this.data); | ||
} | ||
}, { | ||
key: "x", | ||
get: function get() { | ||
return this.data.x; | ||
}, | ||
set: function set(v) { | ||
this.data.x = v; | ||
} | ||
}, { | ||
key: "y", | ||
get: function get() { | ||
return this.data.y; | ||
}, | ||
set: function set(v) { | ||
this.data.y = v; | ||
} | ||
}]); | ||
return _class; | ||
}(FlexNode); | ||
}; | ||
} | ||
function wrap(FlexClass, treeData, children) { | ||
var _wrap = function _wrap(data, parent) { | ||
var node = new FlexClass(data); | ||
const _wrap = (data, parent) => { | ||
const node = new FlexClass(data); | ||
Object.assign(node, { | ||
parent: parent, | ||
parent, | ||
depth: parent === null ? 0 : parent.depth + 1, | ||
@@ -573,14 +555,10 @@ height: 0, | ||
}); | ||
var kidsData = children(data) || []; | ||
node.children = kidsData.length === 0 ? null : kidsData.map(function (kd) { | ||
return _wrap(kd, node); | ||
}); | ||
const kidsData = children(data) || []; | ||
node.children = kidsData.length === 0 ? null : kidsData.map(kd => _wrap(kd, node)); | ||
if (node.children) { | ||
Object.assign(node, node.children.reduce(function (hl, kid) { | ||
return { | ||
height: Math.max(hl.height, kid.height + 1), | ||
length: hl.length + kid.length | ||
}; | ||
}, node)); | ||
Object.assign(node, node.children.reduce((hl, kid) => ({ | ||
height: Math.max(hl.height, kid.height + 1), | ||
length: hl.length + kid.length | ||
}), node)); | ||
} | ||
@@ -595,29 +573,33 @@ | ||
Object.assign(layout, { | ||
nodeSize: function nodeSize(arg) { | ||
nodeSize(arg) { | ||
return arguments.length ? (opts.nodeSize = arg, layout) : opts.nodeSize; | ||
}, | ||
spacing: function spacing(arg) { | ||
spacing(arg) { | ||
return arguments.length ? (opts.spacing = arg, layout) : opts.spacing; | ||
}, | ||
children: function children(arg) { | ||
children(arg) { | ||
return arguments.length ? (opts.children = arg, layout) : opts.children; | ||
}, | ||
hierarchy: function hierarchy(treeData, children) { | ||
var kids = typeof children === 'undefined' ? opts.children : children; | ||
hierarchy(treeData, children) { | ||
const kids = typeof children === 'undefined' ? opts.children : children; | ||
return wrap(getFlexNode(), treeData, kids); | ||
}, | ||
dump: function dump(tree) { | ||
var nodeSize = accessor('nodeSize'); | ||
var _dump = function _dump(i0) { | ||
return function (node) { | ||
var i1 = i0 + ' '; | ||
var i2 = i0 + ' '; | ||
var x = node.x, | ||
y = node.y; | ||
var size = nodeSize(node); | ||
var kids = node.children || []; | ||
var kdumps = kids.length === 0 ? ' ' : "," + i1 + "children: [" + i2 + kids.map(_dump(i2)).join(i2) + i1 + "]," + i0; | ||
return "{ size: [" + size.join(', ') + "]," + i1 + "x: " + x + ", y: " + y + kdumps + "},"; | ||
}; | ||
dump(tree) { | ||
const nodeSize = accessor('nodeSize'); | ||
const _dump = i0 => node => { | ||
const i1 = i0 + ' '; | ||
const i2 = i0 + ' '; | ||
const { | ||
x, | ||
y | ||
} = node; | ||
const size = nodeSize(node); | ||
const kids = node.children || []; | ||
const kdumps = kids.length === 0 ? ' ' : `,${i1}children: [${i2}${kids.map(_dump(i2)).join(i2)}${i1}],${i0}`; | ||
return `{ size: [${size.join(', ')}],${i1}x: ${x}, y: ${y}${kdumps}},`; | ||
}; | ||
@@ -627,2 +609,3 @@ | ||
} | ||
}); | ||
@@ -633,17 +616,12 @@ return layout; | ||
var layoutChildren = function layoutChildren(w, y) { | ||
if (y === void 0) { | ||
y = 0; | ||
} | ||
const layoutChildren = (w, y = 0) => { | ||
w.y = y; | ||
(w.children || []).reduce(function (acc, kid) { | ||
var i = acc[0], | ||
lastLows = acc[1]; | ||
(w.children || []).reduce((acc, kid) => { | ||
const [i, lastLows] = acc; | ||
layoutChildren(kid, w.y + w.ySize); // The lowest vertical coordinate while extreme nodes still point | ||
// in current subtree. | ||
var lowY = (i === 0 ? kid.lExt : kid.rExt).bottom; | ||
const lowY = (i === 0 ? kid.lExt : kid.rExt).bottom; | ||
if (i !== 0) separate(w, i, lastLows); | ||
var lows = updateLows(lowY, i, lastLows); | ||
const lows = updateLows(lowY, i, lastLows); | ||
return [i + 1, lows]; | ||
@@ -660,3 +638,3 @@ }, [0, null]); | ||
var resolveX = function resolveX(w, prevSum, parentX) { | ||
const resolveX = (w, prevSum, parentX) => { | ||
// A call to resolveX without arguments is assumed to be for the root of | ||
@@ -669,9 +647,7 @@ // the tree. This will set the root's x-coord to zero. | ||
var sum = prevSum + w.relX; | ||
const sum = prevSum + w.relX; | ||
w.relX = sum + w.prelim - parentX; | ||
w.prelim = 0; | ||
w.x = parentX + w.relX; | ||
(w.children || []).forEach(function (k) { | ||
return resolveX(k, sum, w.x); | ||
}); | ||
(w.children || []).forEach(k => resolveX(k, sum, w.x)); | ||
return w; | ||
@@ -682,8 +658,7 @@ }; // Process shift and change for all children, to add intermediate spacing to | ||
var shiftChange = function shiftChange(w) { | ||
(w.children || []).reduce(function (acc, child) { | ||
var lastShiftSum = acc[0], | ||
lastChangeSum = acc[1]; | ||
var shiftSum = lastShiftSum + child.shift; | ||
var changeSum = lastChangeSum + shiftSum + child.change; | ||
const shiftChange = w => { | ||
(w.children || []).reduce((acc, child) => { | ||
const [lastShiftSum, lastChangeSum] = acc; | ||
const shiftSum = lastShiftSum + child.shift; | ||
const changeSum = lastChangeSum + shiftSum + child.change; | ||
child.relX += changeSum; | ||
@@ -697,10 +672,10 @@ return [shiftSum, changeSum]; | ||
var separate = function separate(w, i, lows) { | ||
var lSib = w.children[i - 1]; | ||
var curSubtree = w.children[i]; | ||
var rContour = lSib; | ||
var rSumMods = lSib.relX; | ||
var lContour = curSubtree; | ||
var lSumMods = curSubtree.relX; | ||
var isFirst = true; | ||
const separate = (w, i, lows) => { | ||
const lSib = w.children[i - 1]; | ||
const curSubtree = w.children[i]; | ||
let rContour = lSib; | ||
let rSumMods = lSib.relX; | ||
let lContour = curSubtree; | ||
let lSumMods = curSubtree.relX; | ||
let isFirst = true; | ||
@@ -712,3 +687,3 @@ while (rContour && lContour) { | ||
var dist = rSumMods + rContour.prelim - (lSumMods + lContour.prelim) + rContour.xSize / 2 + lContour.xSize / 2 + rContour.spacing(lContour); | ||
const dist = rSumMods + rContour.prelim - (lSumMods + lContour.prelim) + rContour.xSize / 2 + lContour.xSize / 2 + rContour.spacing(lContour); | ||
@@ -724,4 +699,4 @@ if (dist > 0 || dist < 0 && isFirst) { | ||
var rightBottom = rContour.bottom; | ||
var leftBottom = lContour.bottom; | ||
const rightBottom = rContour.bottom; | ||
const leftBottom = lContour.bottom; | ||
@@ -748,3 +723,3 @@ if (rightBottom <= leftBottom) { | ||
var moveSubtree = function moveSubtree(subtree, distance) { | ||
const moveSubtree = (subtree, distance) => { | ||
subtree.relX += distance; | ||
@@ -755,8 +730,8 @@ subtree.lExtRelX += distance; | ||
var distributeExtra = function distributeExtra(w, curSubtreeI, leftSibI, dist) { | ||
var curSubtree = w.children[curSubtreeI]; | ||
var n = curSubtreeI - leftSibI; // Are there intermediate children? | ||
const distributeExtra = (w, curSubtreeI, leftSibI, dist) => { | ||
const curSubtree = w.children[curSubtreeI]; | ||
const n = curSubtreeI - leftSibI; // Are there intermediate children? | ||
if (n > 1) { | ||
var delta = dist / n; | ||
const delta = dist / n; | ||
w.children[leftSibI + 1].shift += delta; | ||
@@ -768,17 +743,17 @@ curSubtree.shift -= delta; | ||
var nextLContour = function nextLContour(w) { | ||
const nextLContour = w => { | ||
return w.hasChildren ? w.firstChild : w.lThr; | ||
}; | ||
var nextRContour = function nextRContour(w) { | ||
const nextRContour = w => { | ||
return w.hasChildren ? w.lastChild : w.rThr; | ||
}; | ||
var setLThr = function setLThr(w, i, lContour, lSumMods) { | ||
var firstChild = w.firstChild; | ||
var lExt = firstChild.lExt; | ||
var curSubtree = w.children[i]; | ||
const setLThr = (w, i, lContour, lSumMods) => { | ||
const firstChild = w.firstChild; | ||
const lExt = firstChild.lExt; | ||
const curSubtree = w.children[i]; | ||
lExt.lThr = lContour; // Change relX so that the sum of modifier after following thread is correct. | ||
var diff = lSumMods - lContour.relX - firstChild.lExtRelX; | ||
const diff = lSumMods - lContour.relX - firstChild.lExtRelX; | ||
lExt.relX += diff; // Change preliminary x coordinate so that the node does not move. | ||
@@ -793,8 +768,8 @@ | ||
var setRThr = function setRThr(w, i, rContour, rSumMods) { | ||
var curSubtree = w.children[i]; | ||
var rExt = curSubtree.rExt; | ||
var lSib = w.children[i - 1]; | ||
const setRThr = (w, i, rContour, rSumMods) => { | ||
const curSubtree = w.children[i]; | ||
const rExt = curSubtree.rExt; | ||
const lSib = w.children[i - 1]; | ||
rExt.rThr = rContour; | ||
var diff = rSumMods - rContour.relX - curSubtree.rExtRelX; | ||
const diff = rSumMods - rContour.relX - curSubtree.rExtRelX; | ||
rExt.relX += diff; | ||
@@ -807,9 +782,9 @@ rExt.prelim -= diff; | ||
var positionRoot = function positionRoot(w) { | ||
const positionRoot = w => { | ||
if (w.hasChildren) { | ||
var k0 = w.firstChild; | ||
var kf = w.lastChild; | ||
var prelim = (k0.prelim + k0.relX - k0.xSize / 2 + kf.relX + kf.prelim + kf.xSize / 2) / 2; | ||
const k0 = w.firstChild; | ||
const kf = w.lastChild; | ||
const prelim = (k0.prelim + k0.relX - k0.xSize / 2 + kf.relX + kf.prelim + kf.xSize / 2) / 2; | ||
Object.assign(w, { | ||
prelim: prelim, | ||
prelim, | ||
lExt: k0.lExt, | ||
@@ -825,12 +800,10 @@ lExtRelX: k0.lExtRelX, | ||
var updateLows = function updateLows(lowY, index, lastLows) { | ||
const updateLows = (lowY, index, lastLows) => { | ||
// Remove siblings that are hidden by the new subtree. | ||
while (lastLows !== null && lowY >= lastLows.lowY) { | ||
lastLows = lastLows.next; | ||
} // Prepend the new subtree. | ||
while (lastLows !== null && lowY >= lastLows.lowY) lastLows = lastLows.next; // Prepend the new subtree. | ||
return { | ||
lowY: lowY, | ||
index: index, | ||
lowY, | ||
index, | ||
next: lastLows | ||
@@ -840,3 +813,3 @@ }; | ||
/*! markmap-common v0.1.5 | MIT License */ | ||
/*! markmap-common v0.1.6 | MIT License */ | ||
class Hook { | ||
@@ -1079,9 +1052,2 @@ constructor() { | ||
constructor(svg, opts) { | ||
this.options = void 0; | ||
this.state = void 0; | ||
this.svg = void 0; | ||
this.styleNode = void 0; | ||
this.g = void 0; | ||
this.zoom = void 0; | ||
this.viewHooks = void 0; | ||
this.revokers = []; | ||
@@ -1301,5 +1267,5 @@ ['handleZoom', 'handleClick'].forEach(key => { | ||
fo.append('xhtml:div').select(function select(d) { | ||
const node = d.data.p.el.cloneNode(true); | ||
this.replaceWith(node); | ||
return node; | ||
const clone = d.data.p.el.cloneNode(true); | ||
this.replaceWith(clone); | ||
return clone; | ||
}).attr('xmlns', 'http://www.w3.org/1999/xhtml'); | ||
@@ -1461,2 +1427,2 @@ return fo; | ||
}(this.markmap = this.markmap || {}, d3)); | ||
})(this.markmap = this.markmap || {}, d3); |
@@ -1,4 +0,4 @@ | ||
/*! markmap-view v0.2.6 | MIT License */ | ||
!function(t,e){"use strict";function n(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){e[n]=t[n]})),e.default=t,Object.freeze(e)}var r=n(e);function i(){return(i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function o(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function a(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function s(t,e,n){return e&&a(t.prototype,e),n&&a(t,n),t}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function l(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,c(t,e)}function h(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function u(t,e){var n,r,i,o,a,s=new g(t),c=+t.value&&(s.value=t.value),l=[s];for(null==e&&(e=d);n=l.pop();)if(c&&(n.value=+n.data.value),(i=e(n.data))&&(a=i.length))for(n.children=new Array(a),o=a-1;o>=0;--o)l.push(r=n.children[o]=new g(i[o])),r.parent=n,r.depth=n.depth+1;return s.eachBefore(p)}function d(t){return t.children}function f(t){t.data=t.data.data}function p(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function g(t){this.data=t,this.depth=this.height=0,this.parent=null}g.prototype=u.prototype={constructor:g,count:function(){return this.eachAfter(h)},each:function(t){var e,n,r,i,o=this,a=[o];do{for(e=a.reverse(),a=[];o=e.pop();)if(t(o),n=o.children)for(r=0,i=n.length;r<i;++r)a.push(n[r])}while(a.length);return this},eachAfter:function(t){for(var e,n,r,i=this,o=[i],a=[];i=o.pop();)if(a.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)o.push(e[n]);for(;i=a.pop();)t(i);return this},eachBefore:function(t){for(var e,n,r=this,i=[r];r=i.pop();)if(t(r),e=r.children)for(n=e.length-1;n>=0;--n)i.push(e[n]);return this},sum:function(t){return this.eachAfter((function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t)}))},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){var t=[];return this.each((function(e){t.push(e)})),t},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e)})),t},links:function(){var t=this,e=[];return t.each((function(n){n!==t&&e.push({source:n.parent,target:n})})),e},copy:function(){return u(this).eachBefore(f)}};var m=Object.freeze({children:function(t){return t.children},nodeSize:function(t){return t.data.size},spacing:0});function v(t){var e=Object.assign({},m,t);function n(t){var n=e[t];return"function"==typeof n?n:function(){return n}}function r(t){var e,r,c,h=a((e=i(),r=n("nodeSize"),c=n("spacing"),function(t){function e(e){var n;return n=t.call(this,e)||this,Object.assign(o(n),{x:0,y:0,relX:0,prelim:0,shift:0,change:0,lExt:o(n),lExtRelX:0,lThr:null,rExt:o(n),rExtRelX:0,rThr:null}),n}l(e,t);var n=e.prototype;return n.spacing=function(t){return c(this.data,t.data)},n.update=function(){return y(this),x(this),this},s(e,[{key:"size",get:function(){return r(this.data)}},{key:"x",get:function(){return this.data.x},set:function(t){this.data.x=t}},{key:"y",get:function(){return this.data.y},set:function(t){this.data.y=t}}]),e}(e)),t,(function(t){return t.children}));return h.update(),h.data}function i(){var t=n("nodeSize"),e=n("spacing");return function(n){function r(t){return n.call(this,t)||this}l(r,n);var i=r.prototype;return i.copy=function(){var t=a(this.constructor,this,(function(t){return t.children}));return t.each((function(t){return t.data=t.data.data})),t},i.spacing=function(t){return e(this,t)},r.maxExtents=function(t,e){return{top:Math.min(t.top,e.top),bottom:Math.max(t.bottom,e.bottom),left:Math.min(t.left,e.left),right:Math.max(t.right,e.right)}},s(r,[{key:"size",get:function(){return t(this)}},{key:"nodes",get:function(){return this.descendants()}},{key:"xSize",get:function(){return this.size[0]}},{key:"ySize",get:function(){return this.size[1]}},{key:"top",get:function(){return this.y}},{key:"bottom",get:function(){return this.y+this.ySize}},{key:"left",get:function(){return this.x-this.xSize/2}},{key:"right",get:function(){return this.x+this.xSize/2}},{key:"root",get:function(){var t=this.ancestors();return t[t.length-1]}},{key:"numChildren",get:function(){return this.hasChildren?this.children.length:0}},{key:"hasChildren",get:function(){return!this.noChildren}},{key:"noChildren",get:function(){return null===this.children}},{key:"firstChild",get:function(){return this.hasChildren?this.children[0]:null}},{key:"lastChild",get:function(){return this.hasChildren?this.children[this.numChildren-1]:null}},{key:"extents",get:function(){return(this.children||[]).reduce((function(t,e){return r.maxExtents(t,e.extents)}),this.nodeExtents)}},{key:"nodeExtents",get:function(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}]),r}(u.prototype.constructor)}function a(t,e,n){return function e(r,i){var o=new t(r);Object.assign(o,{parent:i,depth:null===i?0:i.depth+1,height:0,length:1});var a=n(r)||[];return o.children=0===a.length?null:a.map((function(t){return e(t,o)})),o.children&&Object.assign(o,o.children.reduce((function(t,e){return{height:Math.max(t.height,e.height+1),length:t.length+e.length}}),o)),o}(e,null)}return Object.assign(r,{nodeSize:function(t){return arguments.length?(e.nodeSize=t,r):e.nodeSize},spacing:function(t){return arguments.length?(e.spacing=t,r):e.spacing},children:function(t){return arguments.length?(e.children=t,r):e.children},hierarchy:function(t,n){var r=void 0===n?e.children:n;return a(i(),t,r)},dump:function(t){var e=n("nodeSize");return function t(n){return function(r){var i=n+" ",o=n+" ",a=r.x,s=r.y,c=e(r),l=r.children||[],h=0===l.length?" ":","+i+"children: ["+o+l.map(t(o)).join(o)+i+"],"+n;return"{ size: ["+c.join(", ")+"],"+i+"x: "+a+", y: "+s+h+"},"}}("\n")(t)}}),r}v.version="2.1.1";var y=function t(e,n){return void 0===n&&(n=0),e.y=n,(e.children||[]).reduce((function(n,r){var i=n[0],o=n[1];t(r,e.y+e.ySize);var a=(0===i?r.lExt:r.rExt).bottom;return 0!==i&&k(e,i,o),[i+1,C(a,i,o)]}),[0,null]),z(e),$(e),e},x=function t(e,n,r){void 0===n&&(n=-e.relX-e.prelim,r=0);var i=n+e.relX;return e.relX=i+e.prelim-r,e.prelim=0,e.x=r+e.relX,(e.children||[]).forEach((function(n){return t(n,i,e.x)})),e},z=function(t){(t.children||[]).reduce((function(t,e){var n=t[0],r=t[1],i=n+e.shift,o=r+i+e.change;return e.relX+=o,[i,o]}),[0,0])},k=function(t,e,n){for(var r=t.children[e-1],i=t.children[e],o=r,a=r.relX,s=i,c=i.relX,l=!0;o&&s;){o.bottom>n.lowY&&(n=n.next);var h=a+o.prelim-(c+s.prelim)+o.xSize/2+s.xSize/2+o.spacing(s);(h>0||h<0&&l)&&(c+=h,S(i,h),b(t,e,n.index,h)),l=!1;var u=o.bottom,d=s.bottom;u<=d&&(o=w(o))&&(a+=o.relX),u>=d&&(s=E(s))&&(c+=s.relX)}!o&&s?X(t,e,s,c):o&&!s&&O(t,e,o,a)},S=function(t,e){t.relX+=e,t.lExtRelX+=e,t.rExtRelX+=e},b=function(t,e,n,r){var i=t.children[e],o=e-n;if(o>1){var a=r/o;t.children[n+1].shift+=a,i.shift-=a,i.change-=r-a}},E=function(t){return t.hasChildren?t.firstChild:t.lThr},w=function(t){return t.hasChildren?t.lastChild:t.rThr},X=function(t,e,n,r){var i=t.firstChild,o=i.lExt,a=t.children[e];o.lThr=n;var s=r-n.relX-i.lExtRelX;o.relX+=s,o.prelim-=s,i.lExt=a.lExt,i.lExtRelX=a.lExtRelX},O=function(t,e,n,r){var i=t.children[e],o=i.rExt,a=t.children[e-1];o.rThr=n;var s=r-n.relX-i.rExtRelX;o.relX+=s,o.prelim-=s,i.rExt=a.rExt,i.rExtRelX=a.rExtRelX},$=function(t){if(t.hasChildren){var e=t.firstChild,n=t.lastChild,r=(e.prelim+e.relX-e.xSize/2+n.relX+n.prelim+n.xSize/2)/2;Object.assign(t,{prelim:r,lExt:e.lExt,lExtRelX:e.lExtRelX,rExt:n.rExt,rExtRelX:n.rExtRelX})}},C=function(t,e,n){for(;null!==n&&t>=n.lowY;)n=n.next;return{lowY:t,index:e,next:n}}; | ||
/*! markmap-common v0.1.5 | MIT License */ | ||
class j{constructor(){this.listeners=[]}tap(t){return this.listeners.push(t),()=>this.revoke(t)}revoke(t){const e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)}revokeAll(){this.listeners.splice(0)}call(...t){for(const e of this.listeners)e(...t)}}function M(){return(M=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}const R=Math.random().toString(36).slice(2,8);let I=0;function A(){}function H(t,e,n="c"){const r=(t,i)=>e(t,(()=>{var e;null==(e=t[n])||e.forEach((e=>{r(e,t)}))}),i);r(t)}function B(t){if(Array.from)return Array.from(t);const e=[];for(let n=0;n<t.length;n+=1)e.push(t[n]);return e}function T(t,...e){const n=(t||"").split(" ").filter(Boolean);return e.forEach((t=>{t&&n.indexOf(t)<0&&n.push(t)})),n.join(" ")}function N(t){if("string"==typeof t){const e=t;t=t=>t.tagName===e}const e=t;return function(){let t=B(this.childNodes);return e&&(t=t.filter((t=>e(t)))),t}}function D(t,e,n){const r=document.createElement(t);return e&&Object.entries(e).forEach((([t,e])=>{r[t]=e})),n&&Object.entries(n).forEach((([t,e])=>{r.setAttribute(t,e)})),r}const P=function(t){const e={};return function(...n){const r=`${n[0]}`;let i=e[r];return i||(i={value:t(...n)},e[r]=i),i.value}}((t=>{document.head.append(D("link",{rel:"preload",as:"script",href:t}))}));function Y(t,e){if("script"===t.type)return new Promise(((e,n)=>{var r;document.head.append(D("script",M({},t.data,{onload:e,onerror:n}))),null!=(r=t.data)&&r.src||e()}));if("iife"===t.type){const{fn:n,getParams:r}=t.data;n(...(null==r?void 0:r(e))||[])}}function _(t){"style"===t.type?document.head.append(D("style",{textContent:t.data})):"stylesheet"===t.type&&document.head.append(D("link",M({rel:"stylesheet"},t.data)))}function F(t){const e=t.data;return Math.max(6-2*e.d,1.5)}function V(t,e){return t[r.minIndex(t,e)]}function Z(t){t.stopPropagation()}const L=new j;class J{constructor(t,e){this.options=void 0,this.state=void 0,this.svg=void 0,this.styleNode=void 0,this.g=void 0,this.zoom=void 0,this.viewHooks=void 0,this.revokers=[],["handleZoom","handleClick"].forEach((t=>{this[t]=this[t].bind(this)})),this.viewHooks={transformHtml:new j},this.svg=t.datum?t:r.select(t),this.styleNode=this.svg.append("style"),this.zoom=r.zoom().on("zoom",this.handleZoom),this.options=i({},J.defaultOptions,e),this.state={id:this.options.id||(I+=1,`mm-${R}-${I}`)},this.g=this.svg.append("g").attr("class",`${this.state.id}-g`),this.updateStyle(),this.svg.call(this.zoom),this.revokers.push(L.tap((()=>{this.setData()})))}getStyleContent(){const{style:t,nodeFont:e}=this.options,{id:n}=this.state;return`.${n} { line-height: 1; }\n.${n} a { color: #0097e6; }\n.${n} a:hover { color: #00a8ff; }\n.${n}-g > path { fill: none; }\n.${n}-g > g > circle { cursor: pointer; }\n.${n}-fo > div { display: inline-block; font: ${e}; white-space: nowrap; }\n.${n}-fo code { font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; }\n.${n}-fo :not(pre) > code { padding: .2em .4em; }\n.${n}-fo del { text-decoration: line-through; }\n.${n}-fo em { font-style: italic; }\n.${n}-fo strong { font-weight: bolder; }\n.${n}-fo pre { margin: 0; padding: .2em .4em; }\n${"function"==typeof t?t(n):""}\n`}updateStyle(){this.svg.attr("class",T(this.svg.attr("class"),this.state.id)),this.styleNode.text(this.getStyleContent())}handleZoom(t){const{transform:e}=t;this.g.attr("transform",e)}handleClick(t,e){var n;const{data:r}=e;r.p=i({},r.p,{f:!(null!=(n=r.p)&&n.f)}),this.renderData(e.data)}initializeData(t){let e=0;const{nodeFont:n,color:r,nodeMinHeight:o}=this.options,{id:a}=this.state,s=document.createElement("div"),c=`${a}-container`;s.className=T(s.className,`${a}-fo`,c);const l=document.createElement("style");l.textContent=`\n${this.getStyleContent()}\n.${c} {\n position: absolute;\n width: 0;\n height: 0;\n top: -100px;\n left: -100px;\n overflow: hidden;\n font: ${n};\n}\n.${c} > div {\n display: inline-block;\n}\n`,document.body.append(l,s),H(t,((t,n)=>{var o;t.c=null==(o=t.c)?void 0:o.map((t=>i({},t))),e+=1;const a=document.createElement("div");a.innerHTML=t.v,s.append(a),t.p=i({},t.p,{i:e,el:a}),r(t),n()}));const h=B(s.childNodes);this.viewHooks.transformHtml.call(this,h),H(t,((t,e,n)=>{var r;const i=t.p.el.getBoundingClientRect();t.v=t.p.el.innerHTML,t.p.s=[Math.ceil(i.width),Math.max(Math.ceil(i.height),o)],t.p.k=`${(null==n||null==(r=n.p)?void 0:r.i)||""}.${t.p.i}:${t.v}`,e()})),s.remove(),l.remove()}setOptions(t){Object.assign(this.options,t)}setData(t,e){t&&(this.state.data=t),this.initializeData(this.state.data),e&&this.setOptions(e),this.renderData()}renderData(t){var e,n;if(!this.state.data)return;const{spacingHorizontal:i,paddingX:o,spacingVertical:a,autoFit:s,color:c}=this.options,{id:l}=this.state,h=v().children((t=>{var e;return!(null!=(e=t.p)&&e.f)&&t.c})).nodeSize((t=>{const[e,n]=t.data.p.s;return[n,e+(e?2*o:0)+i]})).spacing(((t,e)=>t.parent===e.parent?a:2*a)),u=h.hierarchy(this.state.data);h(u),function(t,e){H(t,((t,n)=>{t.ySizeInner=t.ySize-e,t.y+=e,n()}),"children")}(u,i);const d=u.descendants().reverse(),f=u.links(),p=r.linkHorizontal(),g=r.min(d,(t=>t.x-t.xSize/2)),m=r.max(d,(t=>t.x+t.xSize/2)),y=r.min(d,(t=>t.y)),x=r.max(d,(t=>t.y+t.ySizeInner));Object.assign(this.state,{minX:g,maxX:m,minY:y,maxY:x}),s&&this.fit();const z=t&&d.find((e=>e.data===t))||u,k=null!=(e=z.data.p.x0)?e:z.x,S=null!=(n=z.data.p.y0)?n:z.y,b=this.g.selectAll(N("g")).data(d,(t=>t.data.p.k)),E=b.enter().append("g").attr("transform",(t=>`translate(${S+z.ySizeInner-t.ySizeInner},${k+z.xSize/2-t.xSize})`)),w=this.transition(b.exit());w.select("rect").attr("width",0).attr("x",(t=>t.ySizeInner)),w.select("foreignObject").style("opacity",0),w.attr("transform",(t=>`translate(${z.y+z.ySizeInner-t.ySizeInner},${z.x+z.xSize/2-t.xSize})`)).remove();const X=b.merge(E);this.transition(X).attr("transform",(t=>`translate(${t.y},${t.x-t.xSize/2})`));const O=X.selectAll(N("rect")).data((t=>[t]),(t=>t.data.p.k)).join((t=>t.append("rect").attr("x",(t=>t.ySizeInner)).attr("y",(t=>t.xSize-F(t)/2)).attr("width",0).attr("height",F)),(t=>t),(t=>t.remove()));this.transition(O).attr("x",-1).attr("width",(t=>t.ySizeInner+2)).attr("fill",(t=>c(t.data)));const $=X.selectAll(N("circle")).data((t=>t.data.c?[t]:[]),(t=>t.data.p.k)).join((t=>t.append("circle").attr("stroke-width","1.5").attr("cx",(t=>t.ySizeInner)).attr("cy",(t=>t.xSize)).attr("r",0).on("click",this.handleClick)),(t=>t),(t=>t.remove()));this.transition($).attr("r",6).attr("stroke",(t=>c(t.data))).attr("fill",(t=>{var e;return null!=(e=t.data.p)&&e.f&&t.data.c?c(t.data):"#fff"}));const C=X.selectAll(N("foreignObject")).data((t=>[t]),(t=>t.data.p.k)).join((t=>{const e=t.append("foreignObject").attr("class",`${l}-fo`).attr("x",o).attr("y",0).style("opacity",0).attr("height",(t=>t.xSize)).on("mousedown",Z).on("dblclick",Z);return e.append("xhtml:div").select((function(t){const e=t.data.p.el.cloneNode(!0);return this.replaceWith(e),e})).attr("xmlns","http://www.w3.org/1999/xhtml"),e}),(t=>t),(t=>t.remove())).attr("width",(t=>Math.max(0,t.ySizeInner-2*o)));this.transition(C).style("opacity",1);const j=this.g.selectAll(N("path")).data(f,(t=>t.target.data.p.k)).join((t=>{const e=[S+z.ySizeInner,k+z.xSize/2];return t.insert("path","g").attr("d",p({source:e,target:e}))}),(t=>t),(t=>{const e=[z.y+z.ySizeInner,z.x+z.xSize/2];return this.transition(t).attr("d",p({source:e,target:e})).remove()}));this.transition(j).attr("stroke",(t=>c(t.target.data))).attr("stroke-width",(t=>F(t.target))).attr("d",(t=>{const e=[t.source.y+t.source.ySizeInner,t.source.x+t.source.xSize/2],n=[t.target.y,t.target.x+t.target.xSize/2];return p({source:e,target:n})})),d.forEach((t=>{t.data.p.x0=t.x,t.data.p.y0=t.y}))}transition(t){const{duration:e}=this.options;return t.transition().duration(e)}async fit(){const t=this.svg.node(),{width:e,height:n}=t.getBoundingClientRect(),{fitRatio:i}=this.options,{minX:o,maxX:a,minY:s,maxY:c}=this.state,l=c-s,h=a-o,u=Math.min(e/l*i,n/h*i,2),d=r.zoomIdentity.translate((e-l*u)/2-s*u,(n-h*u)/2-o*u).scale(u);return this.transition(this.svg).call(this.zoom.transform,d).end().catch(A)}async ensureView(t,e){let n,o;if(this.g.selectAll(N("g")).each((function(e){e.data===t&&(n=this,o=e)})),!n||!o)return;const a=this.svg.node(),s=a.getBoundingClientRect(),c=r.zoomTransform(a),[l,h]=[o.y,o.y+o.ySizeInner+2].map((t=>t*c.k+c.x)),[u,d]=[o.x-o.xSize/2,o.x+o.xSize/2].map((t=>t*c.k+c.y)),f=i({left:0,right:0,top:0,bottom:0},e),p=[f.left-l,s.width-f.right-h],g=[f.top-u,s.height-f.bottom-d],m=p[0]*p[1]>0?V(p,Math.abs)/c.k:0,v=g[0]*g[1]>0?V(g,Math.abs)/c.k:0;if(m||v){const t=c.translate(m,v);return this.transition(this.svg).call(this.zoom.transform,t).end().catch(A)}}async rescale(t){const e=this.svg.node(),{width:n,height:i}=e.getBoundingClientRect(),o=n/2,a=i/2,s=r.zoomTransform(e),c=s.translate((o-s.x)*(1-t)/s.k,(a-s.y)*(1-t)/s.k).scale(t);return this.transition(this.svg).call(this.zoom.transform,c).end().catch(A)}destroy(){this.svg.remove(),this.revokers.forEach((t=>{t()}))}static create(t,e,n){const r=new J(t,e);return n&&(r.setData(n),r.fit()),r}}var W;J.defaultOptions={duration:500,nodeFont:"300 16px/20px sans-serif",nodeMinHeight:16,spacingVertical:5,spacingHorizontal:80,autoFit:!1,fitRatio:.95,color:(W=r.scaleOrdinal(r.schemeCategory10),t=>W(t.p.i)),paddingX:8},t.Markmap=J,t.loadCSS=function(t){for(const e of t)_(e)},t.loadJS=async function(t,e){const n=t.filter((t=>{var e;return"script"===t.type&&(null==(e=t.data)?void 0:e.src)}));n.length>1&&n.forEach((t=>P(t.data.src))),e=M({getMarkmap:()=>window.markmap},e);for(const n of t)await Y(n,e)},t.refreshHook=L}(this.markmap=this.markmap||{},d3); | ||
/*! markmap-view v0.2.7 | MIT License */ | ||
!function(t,e){"use strict";function n(t){if(t&&t.__esModule)return t;var e=Object.create(null);if(t)for(var n in t)e[n]=t[n];return e.default=t,Object.freeze(e)}var r=n(e);function i(){return i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i.apply(this,arguments)}function s(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function o(t,e){var n,r,i,s,o,l=new h(t),d=+t.value&&(l.value=t.value),u=[l];for(null==e&&(e=a);n=u.pop();)if(d&&(n.value=+n.data.value),(i=e(n.data))&&(o=i.length))for(n.children=new Array(o),s=o-1;s>=0;--s)u.push(r=n.children[s]=new h(i[s])),r.parent=n,r.depth=n.depth+1;return l.eachBefore(c)}function a(t){return t.children}function l(t){t.data=t.data.data}function c(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function h(t){this.data=t,this.depth=this.height=0,this.parent=null}h.prototype=o.prototype={constructor:h,count:function(){return this.eachAfter(s)},each:function(t){var e,n,r,i,s=this,o=[s];do{for(e=o.reverse(),o=[];s=e.pop();)if(t(s),n=s.children)for(r=0,i=n.length;r<i;++r)o.push(n[r])}while(o.length);return this},eachAfter:function(t){for(var e,n,r,i=this,s=[i],o=[];i=s.pop();)if(o.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)s.push(e[n]);for(;i=o.pop();)t(i);return this},eachBefore:function(t){for(var e,n,r=this,i=[r];r=i.pop();)if(t(r),e=r.children)for(n=e.length-1;n>=0;--n)i.push(e[n]);return this},sum:function(t){return this.eachAfter((function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t)}))},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){var t=[];return this.each((function(e){t.push(e)})),t},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e)})),t},links:function(){var t=this,e=[];return t.each((function(n){n!==t&&e.push({source:n.parent,target:n})})),e},copy:function(){return o(this).eachBefore(l)}};var d={name:"d3-flextree",version:"2.1.2",main:"build/d3-flextree.js",module:"index","jsnext:main":"index",author:{name:"Chris Maloney",url:"http://chrismaloney.org"},description:"Flexible tree layout algorithm that allows for variable node sizes.",keywords:["d3","d3-module","layout","tree","hierarchy","d3-hierarchy","plugin","d3-plugin","infovis","visualization","2d"],homepage:"https://github.com/klortho/d3-flextree",license:"WTFPL",repository:{type:"git",url:"https://github.com/klortho/d3-flextree.git"},scripts:{clean:"rm -rf build demo test","build:demo":"rollup -c --environment BUILD:demo","build:dev":"rollup -c --environment BUILD:dev","build:prod":"rollup -c --environment BUILD:prod","build:test":"rollup -c --environment BUILD:test",build:"rollup -c",lint:"eslint index.js src","test:main":"node test/bundle.js","test:browser":"node test/browser-tests.js",test:"npm-run-all test:*",prepare:"npm-run-all clean build lint test"},dependencies:{"d3-hierarchy":"^1.1.5"},devDependencies:{"babel-plugin-external-helpers":"^6.22.0","babel-preset-es2015-rollup":"^3.0.0",d3:"^4.13.0","d3-selection-multi":"^1.0.1",eslint:"^4.19.1",jsdom:"^11.6.2","npm-run-all":"^4.1.2",rollup:"^0.55.3","rollup-plugin-babel":"^2.7.1","rollup-plugin-commonjs":"^8.0.2","rollup-plugin-copy":"^0.2.3","rollup-plugin-json":"^2.3.0","rollup-plugin-node-resolve":"^3.0.2","rollup-plugin-uglify":"^3.0.0","uglify-es":"^3.3.9"}};const{version:u}=d,p=Object.freeze({children:t=>t.children,nodeSize:t=>t.data.size,spacing:0});function f(t){const e=Object.assign({},p,t);function n(t){const n=e[t];return"function"==typeof n?n:()=>n}function r(t){const e=s(function(){const t=i(),e=n("nodeSize"),r=n("spacing");return class extends t{constructor(t){super(t),Object.assign(this,{x:0,y:0,relX:0,prelim:0,shift:0,change:0,lExt:this,lExtRelX:0,lThr:null,rExt:this,rExtRelX:0,rThr:null})}get size(){return e(this.data)}spacing(t){return r(this.data,t.data)}get x(){return this.data.x}set x(t){this.data.x=t}get y(){return this.data.y}set y(t){this.data.y=t}update(){return g(this),m(this),this}}}(),t,(t=>t.children));return e.update(),e.data}function i(){const t=n("nodeSize"),e=n("spacing");return class n extends o.prototype.constructor{constructor(t){super(t)}copy(){const t=s(this.constructor,this,(t=>t.children));return t.each((t=>t.data=t.data.data)),t}get size(){return t(this)}spacing(t){return e(this,t)}get nodes(){return this.descendants()}get xSize(){return this.size[0]}get ySize(){return this.size[1]}get top(){return this.y}get bottom(){return this.y+this.ySize}get left(){return this.x-this.xSize/2}get right(){return this.x+this.xSize/2}get root(){const t=this.ancestors();return t[t.length-1]}get numChildren(){return this.hasChildren?this.children.length:0}get hasChildren(){return!this.noChildren}get noChildren(){return null===this.children}get firstChild(){return this.hasChildren?this.children[0]:null}get lastChild(){return this.hasChildren?this.children[this.numChildren-1]:null}get extents(){return(this.children||[]).reduce(((t,e)=>n.maxExtents(t,e.extents)),this.nodeExtents)}get nodeExtents(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}static maxExtents(t,e){return{top:Math.min(t.top,e.top),bottom:Math.max(t.bottom,e.bottom),left:Math.min(t.left,e.left),right:Math.max(t.right,e.right)}}}}function s(t,e,n){const r=(e,i)=>{const s=new t(e);Object.assign(s,{parent:i,depth:null===i?0:i.depth+1,height:0,length:1});const o=n(e)||[];return s.children=0===o.length?null:o.map((t=>r(t,s))),s.children&&Object.assign(s,s.children.reduce(((t,e)=>({height:Math.max(t.height,e.height+1),length:t.length+e.length})),s)),s};return r(e,null)}return Object.assign(r,{nodeSize(t){return arguments.length?(e.nodeSize=t,r):e.nodeSize},spacing(t){return arguments.length?(e.spacing=t,r):e.spacing},children(t){return arguments.length?(e.children=t,r):e.children},hierarchy(t,n){const r=void 0===n?e.children:n;return s(i(),t,r)},dump(t){const e=n("nodeSize"),r=t=>n=>{const i=t+" ",s=t+" ",{x:o,y:a}=n,l=e(n),c=n.children||[],h=0===c.length?" ":`,${i}children: [${s}${c.map(r(s)).join(s)}${i}],${t}`;return`{ size: [${l.join(", ")}],${i}x: ${o}, y: ${a}${h}},`};return r("\n")(t)}}),r}f.version=u;const g=(t,e=0)=>(t.y=e,(t.children||[]).reduce(((e,n)=>{const[r,i]=e;g(n,t.y+t.ySize);const s=(0===r?n.lExt:n.rExt).bottom;0!==r&&y(t,r,i);return[r+1,$(s,r,i)]}),[0,null]),x(t),E(t),t),m=(t,e,n)=>{void 0===e&&(e=-t.relX-t.prelim,n=0);const r=e+t.relX;return t.relX=r+t.prelim-n,t.prelim=0,t.x=n+t.relX,(t.children||[]).forEach((e=>m(e,r,t.x))),t},x=t=>{(t.children||[]).reduce(((t,e)=>{const[n,r]=t,i=n+e.shift,s=r+i+e.change;return e.relX+=s,[i,s]}),[0,0])},y=(t,e,n)=>{const r=t.children[e-1],i=t.children[e];let s=r,o=r.relX,a=i,l=i.relX,c=!0;for(;s&&a;){s.bottom>n.lowY&&(n=n.next);const r=o+s.prelim-(l+a.prelim)+s.xSize/2+a.xSize/2+s.spacing(a);(r>0||r<0&&c)&&(l+=r,v(i,r),z(t,e,n.index,r)),c=!1;const h=s.bottom,d=a.bottom;h<=d&&(s=S(s),s&&(o+=s.relX)),h>=d&&(a=b(a),a&&(l+=a.relX))}!s&&a?k(t,e,a,l):s&&!a&&w(t,e,s,o)},v=(t,e)=>{t.relX+=e,t.lExtRelX+=e,t.rExtRelX+=e},z=(t,e,n,r)=>{const i=t.children[e],s=e-n;if(s>1){const e=r/s;t.children[n+1].shift+=e,i.shift-=e,i.change-=r-e}},b=t=>t.hasChildren?t.firstChild:t.lThr,S=t=>t.hasChildren?t.lastChild:t.rThr,k=(t,e,n,r)=>{const i=t.firstChild,s=i.lExt,o=t.children[e];s.lThr=n;const a=r-n.relX-i.lExtRelX;s.relX+=a,s.prelim-=a,i.lExt=o.lExt,i.lExtRelX=o.lExtRelX},w=(t,e,n,r)=>{const i=t.children[e],s=i.rExt,o=t.children[e-1];s.rThr=n;const a=r-n.relX-i.rExtRelX;s.relX+=a,s.prelim-=a,i.rExt=o.rExt,i.rExtRelX=o.rExtRelX},E=t=>{if(t.hasChildren){const e=t.firstChild,n=t.lastChild,r=(e.prelim+e.relX-e.xSize/2+n.relX+n.prelim+n.xSize/2)/2;Object.assign(t,{prelim:r,lExt:e.lExt,lExtRelX:e.lExtRelX,rExt:n.rExt,rExtRelX:n.rExtRelX})}},$=(t,e,n)=>{for(;null!==n&&t>=n.lowY;)n=n.next;return{lowY:t,index:e,next:n}}; | ||
/*! markmap-common v0.1.6 | MIT License */ | ||
class X{constructor(){this.listeners=[]}tap(t){return this.listeners.push(t),()=>this.revoke(t)}revoke(t){const e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)}revokeAll(){this.listeners.splice(0)}call(...t){for(const e of this.listeners)e(...t)}}function j(){return j=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},j.apply(this,arguments)}const C=Math.random().toString(36).slice(2,8);let O=0;function M(){}function I(t,e,n="c"){const r=(t,i)=>e(t,(()=>{var e;null==(e=t[n])||e.forEach((e=>{r(e,t)}))}),i);r(t)}function R(t){if(Array.from)return Array.from(t);const e=[];for(let n=0;n<t.length;n+=1)e.push(t[n]);return e}function A(t,...e){const n=(t||"").split(" ").filter(Boolean);return e.forEach((t=>{t&&n.indexOf(t)<0&&n.push(t)})),n.join(" ")}function B(t){if("string"==typeof t){const e=t;t=t=>t.tagName===e}const e=t;return function(){let t=R(this.childNodes);return e&&(t=t.filter((t=>e(t)))),t}}function D(t,e,n){const r=document.createElement(t);return e&&Object.entries(e).forEach((([t,e])=>{r[t]=e})),n&&Object.entries(n).forEach((([t,e])=>{r.setAttribute(t,e)})),r}const H=function(t){const e={};return function(...n){const r=`${n[0]}`;let i=e[r];return i||(i={value:t(...n)},e[r]=i),i.value}}((t=>{document.head.append(D("link",{rel:"preload",as:"script",href:t}))}));function T(t,e){if("script"===t.type)return new Promise(((e,n)=>{var r;document.head.append(D("script",j({},t.data,{onload:e,onerror:n}))),null!=(r=t.data)&&r.src||e()}));if("iife"===t.type){const{fn:n,getParams:r}=t.data;n(...(null==r?void 0:r(e))||[])}}function N(t){"style"===t.type?document.head.append(D("style",{textContent:t.data})):"stylesheet"===t.type&&document.head.append(D("link",j({rel:"stylesheet"},t.data)))}function F(t){const e=t.data;return Math.max(6-2*e.d,1.5)}function L(t,e){return t[r.minIndex(t,e)]}function Y(t){t.stopPropagation()}const P=new X;class U{constructor(t,e){this.revokers=[],["handleZoom","handleClick"].forEach((t=>{this[t]=this[t].bind(this)})),this.viewHooks={transformHtml:new X},this.svg=t.datum?t:r.select(t),this.styleNode=this.svg.append("style"),this.zoom=r.zoom().on("zoom",this.handleZoom),this.options=i({},U.defaultOptions,e),this.state={id:this.options.id||(O+=1,`mm-${C}-${O}`)},this.g=this.svg.append("g").attr("class",`${this.state.id}-g`),this.updateStyle(),this.svg.call(this.zoom),this.revokers.push(P.tap((()=>{this.setData()})))}getStyleContent(){const{style:t,nodeFont:e}=this.options,{id:n}=this.state;return`.${n} { line-height: 1; }\n.${n} a { color: #0097e6; }\n.${n} a:hover { color: #00a8ff; }\n.${n}-g > path { fill: none; }\n.${n}-g > g > circle { cursor: pointer; }\n.${n}-fo > div { display: inline-block; font: ${e}; white-space: nowrap; }\n.${n}-fo code { font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; }\n.${n}-fo :not(pre) > code { padding: .2em .4em; }\n.${n}-fo del { text-decoration: line-through; }\n.${n}-fo em { font-style: italic; }\n.${n}-fo strong { font-weight: bolder; }\n.${n}-fo pre { margin: 0; padding: .2em .4em; }\n${"function"==typeof t?t(n):""}\n`}updateStyle(){this.svg.attr("class",A(this.svg.attr("class"),this.state.id)),this.styleNode.text(this.getStyleContent())}handleZoom(t){const{transform:e}=t;this.g.attr("transform",e)}handleClick(t,e){var n;const{data:r}=e;r.p=i({},r.p,{f:!(null!=(n=r.p)&&n.f)}),this.renderData(e.data)}initializeData(t){let e=0;const{nodeFont:n,color:r,nodeMinHeight:s}=this.options,{id:o}=this.state,a=document.createElement("div"),l=`${o}-container`;a.className=A(a.className,`${o}-fo`,l);const c=document.createElement("style");c.textContent=`\n${this.getStyleContent()}\n.${l} {\n position: absolute;\n width: 0;\n height: 0;\n top: -100px;\n left: -100px;\n overflow: hidden;\n font: ${n};\n}\n.${l} > div {\n display: inline-block;\n}\n`,document.body.append(c,a),I(t,((t,n)=>{var s;t.c=null==(s=t.c)?void 0:s.map((t=>i({},t))),e+=1;const o=document.createElement("div");o.innerHTML=t.v,a.append(o),t.p=i({},t.p,{i:e,el:o}),r(t),n()}));const h=R(a.childNodes);this.viewHooks.transformHtml.call(this,h),I(t,((t,e,n)=>{var r;const i=t.p.el.getBoundingClientRect();t.v=t.p.el.innerHTML,t.p.s=[Math.ceil(i.width),Math.max(Math.ceil(i.height),s)],t.p.k=`${(null==n||null==(r=n.p)?void 0:r.i)||""}.${t.p.i}:${t.v}`,e()})),a.remove(),c.remove()}setOptions(t){Object.assign(this.options,t)}setData(t,e){t&&(this.state.data=t),this.initializeData(this.state.data),e&&this.setOptions(e),this.renderData()}renderData(t){var e,n;if(!this.state.data)return;const{spacingHorizontal:i,paddingX:s,spacingVertical:o,autoFit:a,color:l}=this.options,{id:c}=this.state,h=f().children((t=>{var e;return!(null!=(e=t.p)&&e.f)&&t.c})).nodeSize((t=>{const[e,n]=t.data.p.s;return[n,e+(e?2*s:0)+i]})).spacing(((t,e)=>t.parent===e.parent?o:2*o)),d=h.hierarchy(this.state.data);h(d),function(t,e){I(t,((t,n)=>{t.ySizeInner=t.ySize-e,t.y+=e,n()}),"children")}(d,i);const u=d.descendants().reverse(),p=d.links(),g=r.linkHorizontal(),m=r.min(u,(t=>t.x-t.xSize/2)),x=r.max(u,(t=>t.x+t.xSize/2)),y=r.min(u,(t=>t.y)),v=r.max(u,(t=>t.y+t.ySizeInner));Object.assign(this.state,{minX:m,maxX:x,minY:y,maxY:v}),a&&this.fit();const z=t&&u.find((e=>e.data===t))||d,b=null!=(e=z.data.p.x0)?e:z.x,S=null!=(n=z.data.p.y0)?n:z.y,k=this.g.selectAll(B("g")).data(u,(t=>t.data.p.k)),w=k.enter().append("g").attr("transform",(t=>`translate(${S+z.ySizeInner-t.ySizeInner},${b+z.xSize/2-t.xSize})`)),E=this.transition(k.exit());E.select("rect").attr("width",0).attr("x",(t=>t.ySizeInner)),E.select("foreignObject").style("opacity",0),E.attr("transform",(t=>`translate(${z.y+z.ySizeInner-t.ySizeInner},${z.x+z.xSize/2-t.xSize})`)).remove();const $=k.merge(w);this.transition($).attr("transform",(t=>`translate(${t.y},${t.x-t.xSize/2})`));const X=$.selectAll(B("rect")).data((t=>[t]),(t=>t.data.p.k)).join((t=>t.append("rect").attr("x",(t=>t.ySizeInner)).attr("y",(t=>t.xSize-F(t)/2)).attr("width",0).attr("height",F)),(t=>t),(t=>t.remove()));this.transition(X).attr("x",-1).attr("width",(t=>t.ySizeInner+2)).attr("fill",(t=>l(t.data)));const j=$.selectAll(B("circle")).data((t=>t.data.c?[t]:[]),(t=>t.data.p.k)).join((t=>t.append("circle").attr("stroke-width","1.5").attr("cx",(t=>t.ySizeInner)).attr("cy",(t=>t.xSize)).attr("r",0).on("click",this.handleClick)),(t=>t),(t=>t.remove()));this.transition(j).attr("r",6).attr("stroke",(t=>l(t.data))).attr("fill",(t=>{var e;return null!=(e=t.data.p)&&e.f&&t.data.c?l(t.data):"#fff"}));const C=$.selectAll(B("foreignObject")).data((t=>[t]),(t=>t.data.p.k)).join((t=>{const e=t.append("foreignObject").attr("class",`${c}-fo`).attr("x",s).attr("y",0).style("opacity",0).attr("height",(t=>t.xSize)).on("mousedown",Y).on("dblclick",Y);return e.append("xhtml:div").select((function(t){const e=t.data.p.el.cloneNode(!0);return this.replaceWith(e),e})).attr("xmlns","http://www.w3.org/1999/xhtml"),e}),(t=>t),(t=>t.remove())).attr("width",(t=>Math.max(0,t.ySizeInner-2*s)));this.transition(C).style("opacity",1);const O=this.g.selectAll(B("path")).data(p,(t=>t.target.data.p.k)).join((t=>{const e=[S+z.ySizeInner,b+z.xSize/2];return t.insert("path","g").attr("d",g({source:e,target:e}))}),(t=>t),(t=>{const e=[z.y+z.ySizeInner,z.x+z.xSize/2];return this.transition(t).attr("d",g({source:e,target:e})).remove()}));this.transition(O).attr("stroke",(t=>l(t.target.data))).attr("stroke-width",(t=>F(t.target))).attr("d",(t=>{const e=[t.source.y+t.source.ySizeInner,t.source.x+t.source.xSize/2],n=[t.target.y,t.target.x+t.target.xSize/2];return g({source:e,target:n})})),u.forEach((t=>{t.data.p.x0=t.x,t.data.p.y0=t.y}))}transition(t){const{duration:e}=this.options;return t.transition().duration(e)}async fit(){const t=this.svg.node(),{width:e,height:n}=t.getBoundingClientRect(),{fitRatio:i}=this.options,{minX:s,maxX:o,minY:a,maxY:l}=this.state,c=l-a,h=o-s,d=Math.min(e/c*i,n/h*i,2),u=r.zoomIdentity.translate((e-c*d)/2-a*d,(n-h*d)/2-s*d).scale(d);return this.transition(this.svg).call(this.zoom.transform,u).end().catch(M)}async ensureView(t,e){let n,s;if(this.g.selectAll(B("g")).each((function(e){e.data===t&&(n=this,s=e)})),!n||!s)return;const o=this.svg.node(),a=o.getBoundingClientRect(),l=r.zoomTransform(o),[c,h]=[s.y,s.y+s.ySizeInner+2].map((t=>t*l.k+l.x)),[d,u]=[s.x-s.xSize/2,s.x+s.xSize/2].map((t=>t*l.k+l.y)),p=i({left:0,right:0,top:0,bottom:0},e),f=[p.left-c,a.width-p.right-h],g=[p.top-d,a.height-p.bottom-u],m=f[0]*f[1]>0?L(f,Math.abs)/l.k:0,x=g[0]*g[1]>0?L(g,Math.abs)/l.k:0;if(m||x){const t=l.translate(m,x);return this.transition(this.svg).call(this.zoom.transform,t).end().catch(M)}}async rescale(t){const e=this.svg.node(),{width:n,height:i}=e.getBoundingClientRect(),s=n/2,o=i/2,a=r.zoomTransform(e),l=a.translate((s-a.x)*(1-t)/a.k,(o-a.y)*(1-t)/a.k).scale(t);return this.transition(this.svg).call(this.zoom.transform,l).end().catch(M)}destroy(){this.svg.remove(),this.revokers.forEach((t=>{t()}))}static create(t,e,n){const r=new U(t,e);return n&&(r.setData(n),r.fit()),r}}var V;U.defaultOptions={duration:500,nodeFont:"300 16px/20px sans-serif",nodeMinHeight:16,spacingVertical:5,spacingHorizontal:80,autoFit:!1,fitRatio:.95,color:(V=r.scaleOrdinal(r.schemeCategory10),t=>V(t.p.i)),paddingX:8},t.Markmap=U,t.loadCSS=function(t){for(const e of t)N(e)},t.loadJS=async function(t,e){const n=t.filter((t=>{var e;return"script"===t.type&&(null==(e=t.data)?void 0:e.src)}));n.length>1&&n.forEach((t=>H(t.data.src))),e=j({getMarkmap:()=>window.markmap},e);for(const n of t)await T(n,e)},t.refreshHook=P}(this.markmap=this.markmap||{},d3); |
{ | ||
"name": "markmap-view", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "View markmaps in browser", | ||
@@ -24,3 +24,2 @@ "author": "Gerald <gera2ld@live.com>", | ||
"clean": "del-cli dist types", | ||
"lint": "eslint --ext .ts .", | ||
"build:js": "rollup -c rollup.conf.js", | ||
@@ -46,3 +45,3 @@ "build:types": "tsc" | ||
"d3-flextree": "^2.1.1", | ||
"markmap-common": "^0.1.5" | ||
"markmap-common": "^0.1.6" | ||
}, | ||
@@ -52,3 +51,3 @@ "engines": { | ||
}, | ||
"gitHead": "c1b04d45e3d7a9be432c2980ee105983abac7470" | ||
"gitHead": "fbec667e1706813f9f60bea6a971f3820858ca40" | ||
} |
@@ -13,3 +13,3 @@ import * as d3 from 'd3'; | ||
declare function createViewHooks(): { | ||
transformHtml: Hook<(mm: Markmap, nodes: HTMLElement[]) => void>; | ||
transformHtml: Hook<[mm: Markmap, nodes: HTMLElement[]]>; | ||
}; | ||
@@ -19,3 +19,3 @@ /** | ||
*/ | ||
export declare const refreshHook: Hook<() => void>; | ||
export declare const refreshHook: Hook<[]>; | ||
export declare class Markmap { | ||
@@ -22,0 +22,0 @@ static defaultOptions: IMarkmapOptions; |
import { INode } from 'markmap-common'; | ||
import { Markmap } from '.'; | ||
export declare type IMarkmap = typeof Markmap; | ||
export interface IMarkmapOptions { | ||
@@ -5,0 +3,0 @@ id?: string; |
131874
3694
Updatedmarkmap-common@^0.1.6