markmap-view
Advanced tools
Comparing version 0.18.2 to 0.18.3
@@ -1170,10 +1170,5 @@ (function(exports, d32) { | ||
); | ||
const mmLineEnter = mmLine.enter().append("line"); | ||
const mmLineExit = mmGExit.selectAll( | ||
childSelector("line") | ||
); | ||
const mmLineEnter = mmLine.enter().append("line").attr("stroke", (d) => color(d)).attr("stroke-width", 0); | ||
const mmLineMerge = mmLine.merge(mmLineEnter); | ||
const mmCircle = mmGMerge.selectAll( | ||
childSelector("circle") | ||
).data( | ||
const mmCircle = mmGMerge.selectAll(childSelector("circle")).data( | ||
(d) => { | ||
@@ -1184,9 +1179,11 @@ var _a; | ||
(d) => d.state.key | ||
).join( | ||
(enter) => { | ||
return enter.append("circle").attr("stroke-width", "1.5").attr("r", 0).on("click", (e, d) => this.handleClick(e, d)).on("mousedown", stopPropagation); | ||
}, | ||
(update) => update, | ||
(exit) => exit.remove() | ||
); | ||
const mmCircleEnter = mmCircle.enter().append("circle").attr("stroke-width", 0).attr("r", 0).on("click", (e, d) => this.handleClick(e, d)).on("mousedown", stopPropagation); | ||
const mmCircleMerge = mmCircleEnter.merge(mmCircle).attr("stroke", (d) => color(d)).attr( | ||
"fill", | ||
(d) => { | ||
var _a; | ||
return ((_a = d.payload) == null ? void 0 : _a.fold) && d.children ? color(d) : "var(--markmap-circle-open-bg)"; | ||
} | ||
); | ||
const observer = this.observer; | ||
@@ -1221,3 +1218,7 @@ const mmFo = mmGMerge.selectAll(childSelector("foreignObject")).data( | ||
const mmPathExit = mmPath.exit(); | ||
const mmPathEnter = mmPath.enter().insert("path", "g").attr("class", "markmap-link").attr("data-depth", (d) => d.target.state.depth).attr("data-path", (d) => d.target.state.path); | ||
const pathOrigin = [ | ||
originRect.x + originRect.width, | ||
originRect.y + originRect.height | ||
]; | ||
const mmPathEnter = mmPath.enter().insert("path", "g").attr("class", "markmap-link").attr("data-depth", (d) => d.target.state.depth).attr("data-path", (d) => d.target.state.path).attr("d", linkShape({ source: pathOrigin, target: pathOrigin })).attr("stroke-width", 0); | ||
const mmPathMerge = mmPathEnter.merge(mmPath); | ||
@@ -1230,7 +1231,3 @@ this.svg.style( | ||
this._relayout(); | ||
this.transition(mmGExit).attr("transform", (d) => { | ||
const targetX = originRect.x + originRect.width - d.state.rect.width; | ||
const targetY = originRect.y + originRect.height - d.state.rect.height; | ||
return `translate(${targetX},${targetY})`; | ||
}).remove(); | ||
const targetRect = origin.state.rect; | ||
mmGEnter.attr( | ||
@@ -1240,2 +1237,7 @@ "transform", | ||
); | ||
this.transition(mmGExit).attr("transform", (d) => { | ||
const targetX = targetRect.x + targetRect.width - d.state.rect.width; | ||
const targetY = targetRect.y + targetRect.height - d.state.rect.height; | ||
return `translate(${targetX},${targetY})`; | ||
}).remove(); | ||
this.transition(mmGMerge).attr( | ||
@@ -1245,26 +1247,23 @@ "transform", | ||
); | ||
this.transition(mmLineExit).attr("x1", (d) => d.state.rect.width).attr("x2", (d) => d.state.rect.width); | ||
const mmLineExit = mmGExit.selectAll( | ||
childSelector("line") | ||
); | ||
this.transition(mmLineExit).attr("x1", (d) => d.state.rect.width).attr("stroke-width", 0); | ||
mmLineEnter.attr("x1", (d) => d.state.rect.width).attr("x2", (d) => d.state.rect.width); | ||
mmLineMerge.attr("y1", (d) => d.state.rect.height).attr("y2", (d) => d.state.rect.height).attr("stroke", (d) => color(d)); | ||
this.transition(mmLineMerge).attr("x1", -1).attr("x2", (d) => d.state.rect.width + 2).attr("stroke-width", linkWidth); | ||
mmCircle.attr("cx", (d) => d.state.rect.width).attr("cy", (d) => d.state.rect.height).attr("stroke", (d) => color(d)).attr( | ||
"fill", | ||
(d) => { | ||
var _a; | ||
return ((_a = d.payload) == null ? void 0 : _a.fold) && d.children ? color(d) : "var(--markmap-circle-open-bg)"; | ||
} | ||
mmLineMerge.attr("y1", (d) => d.state.rect.height).attr("y2", (d) => d.state.rect.height); | ||
this.transition(mmLineMerge).attr("x1", -1).attr("x2", (d) => d.state.rect.width + 2).attr("stroke", (d) => color(d)).attr("stroke-width", linkWidth); | ||
const mmCircleExit = mmGExit.selectAll( | ||
childSelector("circle") | ||
); | ||
this.transition(mmCircle).attr("r", 6); | ||
this.transition(mmCircleExit).attr("r", 0).attr("stroke-width", 0); | ||
mmCircleMerge.attr("cx", (d) => d.state.rect.width).attr("cy", (d) => d.state.rect.height); | ||
this.transition(mmCircleMerge).attr("r", 6).attr("stroke-width", "1.5"); | ||
this.transition(mmFoExit).style("opacity", 0); | ||
mmFoMerge.attr("width", (d) => Math.max(0, d.state.rect.width - paddingX * 2)).attr("height", (d) => d.state.rect.height); | ||
this.transition(mmFoMerge).style("opacity", 1); | ||
const pathOrigin = [ | ||
originRect.x + originRect.width, | ||
originRect.y + originRect.height | ||
const pathTarget = [ | ||
targetRect.x + targetRect.width, | ||
targetRect.y + targetRect.height | ||
]; | ||
this.transition(mmPathExit).attr("d", linkShape({ source: pathOrigin, target: pathOrigin })).remove(); | ||
mmPathEnter.attr( | ||
"d", | ||
linkShape({ source: pathOrigin, target: pathOrigin }) | ||
); | ||
this.transition(mmPathExit).attr("d", linkShape({ source: pathTarget, target: pathTarget })).attr("stroke-width", 0).remove(); | ||
this.transition(mmPathMerge).attr("stroke", (d) => color(d.target)).attr("stroke-width", (d) => linkWidth(d.target)).attr("d", (d) => { | ||
@@ -1271,0 +1270,0 @@ const origSource = d.source; |
@@ -1,9 +0,9 @@ | ||
import { Hook as et, getId as nt, debounce as rt, addClass as it, walkTree as j, childSelector as b, noop as E } from "markmap-common"; | ||
import { loadCSS as ce, loadJS as he } from "markmap-common"; | ||
import { scaleOrdinal as L, schemeCategory10 as st, linkHorizontal as ot, zoomTransform as C, select as at, zoom as lt, min as T, max as _, zoomIdentity as ct, minIndex as ht } from "d3"; | ||
const P = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), dt = L(st), W = { | ||
import { Hook as it, getId as ot, debounce as at, addClass as lt, walkTree as j, childSelector as y, noop as C } from "markmap-common"; | ||
import { loadCSS as me, loadJS as ge } from "markmap-common"; | ||
import { scaleOrdinal as W, schemeCategory10 as ct, linkHorizontal as ht, zoomTransform as w, select as dt, zoom as pt, min as H, max as N, zoomIdentity as ut, minIndex as mt } from "d3"; | ||
const I = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), gt = W(ct), K = { | ||
autoFit: !1, | ||
color: (e) => { | ||
var t; | ||
return dt(`${((t = e.state) == null ? void 0 : t.path) || ""}`); | ||
return gt(`${((t = e.state) == null ? void 0 : t.path) || ""}`); | ||
}, | ||
@@ -17,3 +17,3 @@ duration: 500, | ||
paddingX: 8, | ||
scrollForPan: P, | ||
scrollForPan: I, | ||
spacingHorizontal: 80, | ||
@@ -26,20 +26,20 @@ spacingVertical: 5, | ||
}; | ||
function se(e) { | ||
const t = {}, r = { ...e }, { color: n, colorFreezeLevel: s } = r; | ||
function he(e) { | ||
const t = {}, s = { ...e }, { color: n, colorFreezeLevel: i } = s; | ||
if ((n == null ? void 0 : n.length) === 1) { | ||
const i = n[0]; | ||
t.color = () => i; | ||
const r = n[0]; | ||
t.color = () => r; | ||
} else if (n != null && n.length) { | ||
const i = L(n); | ||
t.color = (a) => i(`${a.state.path}`); | ||
const r = W(n); | ||
t.color = (l) => r(`${l.state.path}`); | ||
} | ||
if (s) { | ||
const i = t.color || W.color; | ||
t.color = (a) => (a = { | ||
...a, | ||
if (i) { | ||
const r = t.color || K.color; | ||
t.color = (l) => (l = { | ||
...l, | ||
state: { | ||
...a.state, | ||
path: a.state.path.split(".").slice(0, s).join(".") | ||
...l.state, | ||
path: l.state.path.split(".").slice(0, i).join(".") | ||
} | ||
}, i(a)); | ||
}, r(l)); | ||
} | ||
@@ -56,44 +56,44 @@ return [ | ||
"spacingVertical" | ||
].forEach((i) => { | ||
const a = r[i]; | ||
typeof a == "number" && (t[i] = a); | ||
}), ["zoom", "pan"].forEach((i) => { | ||
const a = r[i]; | ||
a != null && (t[i] = !!a); | ||
].forEach((r) => { | ||
const l = s[r]; | ||
typeof l == "number" && (t[r] = l); | ||
}), ["zoom", "pan"].forEach((r) => { | ||
const l = s[r]; | ||
l != null && (t[r] = !!l); | ||
}), t; | ||
} | ||
function pt(e) { | ||
function ft(e) { | ||
let t = 0; | ||
for (let r = 0; r < e.length; r++) | ||
t = (t << 5) - t + e.charCodeAt(r) | 0; | ||
for (let s = 0; s < e.length; s++) | ||
t = (t << 5) - t + e.charCodeAt(s) | 0; | ||
return (t >>> 0).toString(36); | ||
} | ||
function ut(e) { | ||
var t = 0, r = e.children, n = r && r.length; | ||
function xt(e) { | ||
var t = 0, s = e.children, n = s && s.length; | ||
if (!n) t = 1; | ||
else for (; --n >= 0; ) t += r[n].value; | ||
else for (; --n >= 0; ) t += s[n].value; | ||
e.value = t; | ||
} | ||
function mt() { | ||
return this.eachAfter(ut); | ||
function yt() { | ||
return this.eachAfter(xt); | ||
} | ||
function gt(e) { | ||
var t = this, r, n = [t], s, l, c; | ||
function kt(e) { | ||
var t = this, s, n = [t], i, a, c; | ||
do | ||
for (r = n.reverse(), n = []; t = r.pop(); ) | ||
if (e(t), s = t.children, s) for (l = 0, c = s.length; l < c; ++l) | ||
n.push(s[l]); | ||
for (s = n.reverse(), n = []; t = s.pop(); ) | ||
if (e(t), i = t.children, i) for (a = 0, c = i.length; a < c; ++a) | ||
n.push(i[a]); | ||
while (n.length); | ||
return this; | ||
} | ||
function ft(e) { | ||
for (var t = this, r = [t], n, s; t = r.pop(); ) | ||
if (e(t), n = t.children, n) for (s = n.length - 1; s >= 0; --s) | ||
r.push(n[s]); | ||
function vt(e) { | ||
for (var t = this, s = [t], n, i; t = s.pop(); ) | ||
if (e(t), n = t.children, n) for (i = n.length - 1; i >= 0; --i) | ||
s.push(n[i]); | ||
return this; | ||
} | ||
function xt(e) { | ||
for (var t = this, r = [t], n = [], s, l, c; t = r.pop(); ) | ||
if (n.push(t), s = t.children, s) for (l = 0, c = s.length; l < c; ++l) | ||
r.push(s[l]); | ||
function bt(e) { | ||
for (var t = this, s = [t], n = [], i, a, c; t = s.pop(); ) | ||
if (n.push(t), i = t.children, i) for (a = 0, c = i.length; a < c; ++a) | ||
s.push(i[a]); | ||
for (; t = n.pop(); ) | ||
@@ -103,9 +103,9 @@ e(t); | ||
} | ||
function yt(e) { | ||
function zt(e) { | ||
return this.eachAfter(function(t) { | ||
for (var r = +e(t.data) || 0, n = t.children, s = n && n.length; --s >= 0; ) r += n[s].value; | ||
t.value = r; | ||
for (var s = +e(t.data) || 0, n = t.children, i = n && n.length; --i >= 0; ) s += n[i].value; | ||
t.value = s; | ||
}); | ||
} | ||
function kt(e) { | ||
function Et(e) { | ||
return this.eachBefore(function(t) { | ||
@@ -115,17 +115,17 @@ t.children && t.children.sort(e); | ||
} | ||
function vt(e) { | ||
for (var t = this, r = bt(t, e), n = [t]; t !== r; ) | ||
function Ct(e) { | ||
for (var t = this, s = wt(t, e), n = [t]; t !== s; ) | ||
t = t.parent, n.push(t); | ||
for (var s = n.length; e !== r; ) | ||
n.splice(s, 0, e), e = e.parent; | ||
for (var i = n.length; e !== s; ) | ||
n.splice(i, 0, e), e = e.parent; | ||
return n; | ||
} | ||
function bt(e, t) { | ||
function wt(e, t) { | ||
if (e === t) return e; | ||
var r = e.ancestors(), n = t.ancestors(), s = null; | ||
for (e = r.pop(), t = n.pop(); e === t; ) | ||
s = e, e = r.pop(), t = n.pop(); | ||
return s; | ||
var s = e.ancestors(), n = t.ancestors(), i = null; | ||
for (e = s.pop(), t = n.pop(); e === t; ) | ||
i = e, e = s.pop(), t = n.pop(); | ||
return i; | ||
} | ||
function zt() { | ||
function St() { | ||
for (var e = this, t = [e]; e = e.parent; ) | ||
@@ -135,3 +135,3 @@ t.push(e); | ||
} | ||
function St() { | ||
function Xt() { | ||
var e = []; | ||
@@ -142,3 +142,3 @@ return this.each(function(t) { | ||
} | ||
function Et() { | ||
function Rt() { | ||
var e = []; | ||
@@ -149,26 +149,26 @@ return this.eachBefore(function(t) { | ||
} | ||
function Ct() { | ||
function jt() { | ||
var e = this, t = []; | ||
return e.each(function(r) { | ||
r !== e && t.push({ source: r.parent, target: r }); | ||
return e.each(function(s) { | ||
s !== e && t.push({ source: s.parent, target: s }); | ||
}), t; | ||
} | ||
function O(e, t) { | ||
var r = new w(e), n = +e.value && (r.value = e.value), s, l = [r], c, i, a, d; | ||
for (t == null && (t = Xt); s = l.pop(); ) | ||
if (n && (s.value = +s.data.value), (i = t(s.data)) && (d = i.length)) | ||
for (s.children = new Array(d), a = d - 1; a >= 0; --a) | ||
l.push(c = s.children[a] = new w(i[a])), c.parent = s, c.depth = s.depth + 1; | ||
return r.eachBefore(jt); | ||
function A(e, t) { | ||
var s = new S(e), n = +e.value && (s.value = e.value), i, a = [s], c, r, l, d; | ||
for (t == null && (t = Bt); i = a.pop(); ) | ||
if (n && (i.value = +i.data.value), (r = t(i.data)) && (d = r.length)) | ||
for (i.children = new Array(d), l = d - 1; l >= 0; --l) | ||
a.push(c = i.children[l] = new S(r[l])), c.parent = i, c.depth = i.depth + 1; | ||
return s.eachBefore(Ot); | ||
} | ||
function wt() { | ||
return O(this).eachBefore(Rt); | ||
function Mt() { | ||
return A(this).eachBefore(At); | ||
} | ||
function Xt(e) { | ||
function Bt(e) { | ||
return e.children; | ||
} | ||
function Rt(e) { | ||
function At(e) { | ||
e.data = e.data.data; | ||
} | ||
function jt(e) { | ||
function Ot(e) { | ||
var t = 0; | ||
@@ -179,36 +179,36 @@ do | ||
} | ||
function w(e) { | ||
function S(e) { | ||
this.data = e, this.depth = this.height = 0, this.parent = null; | ||
} | ||
w.prototype = O.prototype = { | ||
constructor: w, | ||
count: mt, | ||
each: gt, | ||
eachAfter: xt, | ||
eachBefore: ft, | ||
sum: yt, | ||
sort: kt, | ||
path: vt, | ||
ancestors: zt, | ||
descendants: St, | ||
leaves: Et, | ||
links: Ct, | ||
copy: wt | ||
S.prototype = A.prototype = { | ||
constructor: S, | ||
count: yt, | ||
each: kt, | ||
eachAfter: bt, | ||
eachBefore: vt, | ||
sum: zt, | ||
sort: Et, | ||
path: Ct, | ||
ancestors: St, | ||
descendants: Xt, | ||
leaves: Rt, | ||
links: jt, | ||
copy: Mt | ||
}; | ||
const Mt = "d3-flextree", Bt = "2.1.2", Ot = "build/d3-flextree.js", $t = "index", At = { name: "Chris Maloney", url: "http://chrismaloney.org" }, Dt = "Flexible tree layout algorithm that allows for variable node sizes.", Ft = ["d3", "d3-module", "layout", "tree", "hierarchy", "d3-hierarchy", "plugin", "d3-plugin", "infovis", "visualization", "2d"], Tt = "https://github.com/klortho/d3-flextree", _t = "WTFPL", Ht = { type: "git", url: "https://github.com/klortho/d3-flextree.git" }, Nt = { 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" }, Lt = { "d3-hierarchy": "^1.1.5" }, Pt = { "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" }, Wt = { | ||
name: Mt, | ||
version: Bt, | ||
main: Ot, | ||
module: $t, | ||
const $t = "d3-flextree", Dt = "2.1.2", Ft = "build/d3-flextree.js", Tt = "index", _t = { name: "Chris Maloney", url: "http://chrismaloney.org" }, Ht = "Flexible tree layout algorithm that allows for variable node sizes.", Nt = ["d3", "d3-module", "layout", "tree", "hierarchy", "d3-hierarchy", "plugin", "d3-plugin", "infovis", "visualization", "2d"], Lt = "https://github.com/klortho/d3-flextree", Pt = "WTFPL", Wt = { type: "git", url: "https://github.com/klortho/d3-flextree.git" }, It = { 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" }, Kt = { "d3-hierarchy": "^1.1.5" }, Gt = { "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" }, Vt = { | ||
name: $t, | ||
version: Dt, | ||
main: Ft, | ||
module: Tt, | ||
"jsnext:main": "index", | ||
author: At, | ||
description: Dt, | ||
keywords: Ft, | ||
homepage: Tt, | ||
license: _t, | ||
repository: Ht, | ||
scripts: Nt, | ||
dependencies: Lt, | ||
devDependencies: Pt | ||
}, { version: It } = Wt, Kt = Object.freeze({ | ||
author: _t, | ||
description: Ht, | ||
keywords: Nt, | ||
homepage: Lt, | ||
license: Pt, | ||
repository: Wt, | ||
scripts: It, | ||
dependencies: Kt, | ||
devDependencies: Gt | ||
}, { version: Ut } = Vt, Yt = Object.freeze({ | ||
children: (e) => e.children, | ||
@@ -218,15 +218,15 @@ nodeSize: (e) => e.data.size, | ||
}); | ||
function K(e) { | ||
const t = Object.assign({}, Kt, e); | ||
function r(i) { | ||
const a = t[i]; | ||
return typeof a == "function" ? a : () => a; | ||
function V(e) { | ||
const t = Object.assign({}, Yt, e); | ||
function s(r) { | ||
const l = t[r]; | ||
return typeof l == "function" ? l : () => l; | ||
} | ||
function n(i) { | ||
const a = c(l(), i, (d) => d.children); | ||
return a.update(), a.data; | ||
function n(r) { | ||
const l = c(a(), r, (d) => d.children); | ||
return l.update(), l.data; | ||
} | ||
function s() { | ||
const i = r("nodeSize"), a = r("spacing"); | ||
return class I extends O.prototype.constructor { | ||
function i() { | ||
const r = s("nodeSize"), l = s("spacing"); | ||
return class G extends A.prototype.constructor { | ||
constructor(h) { | ||
@@ -240,6 +240,6 @@ super(h); | ||
get size() { | ||
return i(this); | ||
return r(this); | ||
} | ||
spacing(h) { | ||
return a(this, h); | ||
return l(this, h); | ||
} | ||
@@ -288,3 +288,3 @@ get nodes() { | ||
return (this.children || []).reduce( | ||
(h, p) => I.maxExtents(h, p.extents), | ||
(h, p) => G.maxExtents(h, p.extents), | ||
this.nodeExtents | ||
@@ -311,5 +311,5 @@ ); | ||
} | ||
function l() { | ||
const i = s(), a = r("nodeSize"), d = r("spacing"); | ||
return class extends i { | ||
function a() { | ||
const r = i(), l = s("nodeSize"), d = s("spacing"); | ||
return class extends r { | ||
constructor(h) { | ||
@@ -332,3 +332,3 @@ super(h), Object.assign(this, { | ||
get size() { | ||
return a(this.data); | ||
return l(this.data); | ||
} | ||
@@ -351,9 +351,9 @@ spacing(h) { | ||
update() { | ||
return G(this), V(this), this; | ||
return U(this), Y(this), this; | ||
} | ||
}; | ||
} | ||
function c(i, a, d) { | ||
function c(r, l, d) { | ||
const h = (p, u) => { | ||
const g = new i(p); | ||
const g = new r(p); | ||
Object.assign(g, { | ||
@@ -367,5 +367,5 @@ parent: u, | ||
return g.children = f.length === 0 ? null : f.map((x) => h(x, g)), g.children && Object.assign(g, g.children.reduce( | ||
(x, v) => ({ | ||
height: Math.max(x.height, v.height + 1), | ||
length: x.length + v.length | ||
(x, k) => ({ | ||
height: Math.max(x.height, k.height + 1), | ||
length: x.length + k.length | ||
}), | ||
@@ -375,77 +375,77 @@ g | ||
}; | ||
return h(a, null); | ||
return h(l, null); | ||
} | ||
return Object.assign(n, { | ||
nodeSize(i) { | ||
return arguments.length ? (t.nodeSize = i, n) : t.nodeSize; | ||
nodeSize(r) { | ||
return arguments.length ? (t.nodeSize = r, n) : t.nodeSize; | ||
}, | ||
spacing(i) { | ||
return arguments.length ? (t.spacing = i, n) : t.spacing; | ||
spacing(r) { | ||
return arguments.length ? (t.spacing = r, n) : t.spacing; | ||
}, | ||
children(i) { | ||
return arguments.length ? (t.children = i, n) : t.children; | ||
children(r) { | ||
return arguments.length ? (t.children = r, n) : t.children; | ||
}, | ||
hierarchy(i, a) { | ||
const d = typeof a > "u" ? t.children : a; | ||
return c(s(), i, d); | ||
hierarchy(r, l) { | ||
const d = typeof l > "u" ? t.children : l; | ||
return c(i(), r, d); | ||
}, | ||
dump(i) { | ||
const a = r("nodeSize"), d = (h) => (p) => { | ||
const u = h + " ", g = h + " ", { x: f, y: x } = p, v = a(p), k = p.children || [], z = k.length === 0 ? " " : `,${u}children: [${g}${k.map(d(g)).join(g)}${u}],${h}`; | ||
return `{ size: [${v.join(", ")}],${u}x: ${f}, y: ${x}${z}},`; | ||
dump(r) { | ||
const l = s("nodeSize"), d = (h) => (p) => { | ||
const u = h + " ", g = h + " ", { x: f, y: x } = p, k = l(p), b = p.children || [], E = b.length === 0 ? " " : `,${u}children: [${g}${b.map(d(g)).join(g)}${u}],${h}`; | ||
return `{ size: [${k.join(", ")}],${u}x: ${f}, y: ${x}${E}},`; | ||
}; | ||
return d(` | ||
`)(i); | ||
`)(r); | ||
} | ||
}), n; | ||
} | ||
K.version = It; | ||
const G = (e, t = 0) => (e.y = t, (e.children || []).reduce((r, n) => { | ||
const [s, l] = r; | ||
G(n, e.y + e.ySize); | ||
const c = (s === 0 ? n.lExt : n.rExt).bottom; | ||
s !== 0 && Vt(e, s, l); | ||
const i = ee(c, s, l); | ||
return [s + 1, i]; | ||
}, [0, null]), Gt(e), te(e), e), V = (e, t, r) => { | ||
typeof t > "u" && (t = -e.relX - e.prelim, r = 0); | ||
V.version = Ut; | ||
const U = (e, t = 0) => (e.y = t, (e.children || []).reduce((s, n) => { | ||
const [i, a] = s; | ||
U(n, e.y + e.ySize); | ||
const c = (i === 0 ? n.lExt : n.rExt).bottom; | ||
i !== 0 && qt(e, i, a); | ||
const r = ie(c, i, a); | ||
return [i + 1, r]; | ||
}, [0, null]), Zt(e), se(e), e), Y = (e, t, s) => { | ||
typeof t > "u" && (t = -e.relX - e.prelim, s = 0); | ||
const n = t + e.relX; | ||
return e.relX = n + e.prelim - r, e.prelim = 0, e.x = r + e.relX, (e.children || []).forEach((s) => V(s, n, e.x)), e; | ||
}, Gt = (e) => { | ||
(e.children || []).reduce((t, r) => { | ||
const [n, s] = t, l = n + r.shift, c = s + l + r.change; | ||
return r.relX += c, [l, c]; | ||
return e.relX = n + e.prelim - s, e.prelim = 0, e.x = s + e.relX, (e.children || []).forEach((i) => Y(i, n, e.x)), e; | ||
}, Zt = (e) => { | ||
(e.children || []).reduce((t, s) => { | ||
const [n, i] = t, a = n + s.shift, c = i + a + s.change; | ||
return s.relX += c, [a, c]; | ||
}, [0, 0]); | ||
}, Vt = (e, t, r) => { | ||
const n = e.children[t - 1], s = e.children[t]; | ||
let l = n, c = n.relX, i = s, a = s.relX, d = !0; | ||
for (; l && i; ) { | ||
l.bottom > r.lowY && (r = r.next); | ||
const h = c + l.prelim - (a + i.prelim) + l.xSize / 2 + i.xSize / 2 + l.spacing(i); | ||
(h > 0 || h < 0 && d) && (a += h, Ut(s, h), Yt(e, t, r.index, h)), d = !1; | ||
const p = l.bottom, u = i.bottom; | ||
p <= u && (l = qt(l), l && (c += l.relX)), p >= u && (i = Zt(i), i && (a += i.relX)); | ||
}, qt = (e, t, s) => { | ||
const n = e.children[t - 1], i = e.children[t]; | ||
let a = n, c = n.relX, r = i, l = i.relX, d = !0; | ||
for (; a && r; ) { | ||
a.bottom > s.lowY && (s = s.next); | ||
const h = c + a.prelim - (l + r.prelim) + a.xSize / 2 + r.xSize / 2 + a.spacing(r); | ||
(h > 0 || h < 0 && d) && (l += h, Jt(i, h), Qt(e, t, s.index, h)), d = !1; | ||
const p = a.bottom, u = r.bottom; | ||
p <= u && (a = ee(a), a && (c += a.relX)), p >= u && (r = te(r), r && (l += r.relX)); | ||
} | ||
!l && i ? Jt(e, t, i, a) : l && !i && Qt(e, t, l, c); | ||
}, Ut = (e, t) => { | ||
!a && r ? ne(e, t, r, l) : a && !r && re(e, t, a, c); | ||
}, Jt = (e, t) => { | ||
e.relX += t, e.lExtRelX += t, e.rExtRelX += t; | ||
}, Yt = (e, t, r, n) => { | ||
const s = e.children[t], l = t - r; | ||
if (l > 1) { | ||
const c = n / l; | ||
e.children[r + 1].shift += c, s.shift -= c, s.change -= n - c; | ||
}, Qt = (e, t, s, n) => { | ||
const i = e.children[t], a = t - s; | ||
if (a > 1) { | ||
const c = n / a; | ||
e.children[s + 1].shift += c, i.shift -= c, i.change -= n - c; | ||
} | ||
}, Zt = (e) => e.hasChildren ? e.firstChild : e.lThr, qt = (e) => e.hasChildren ? e.lastChild : e.rThr, Jt = (e, t, r, n) => { | ||
const s = e.firstChild, l = s.lExt, c = e.children[t]; | ||
l.lThr = r; | ||
const i = n - r.relX - s.lExtRelX; | ||
l.relX += i, l.prelim -= i, s.lExt = c.lExt, s.lExtRelX = c.lExtRelX; | ||
}, Qt = (e, t, r, n) => { | ||
const s = e.children[t], l = s.rExt, c = e.children[t - 1]; | ||
l.rThr = r; | ||
const i = n - r.relX - s.rExtRelX; | ||
l.relX += i, l.prelim -= i, s.rExt = c.rExt, s.rExtRelX = c.rExtRelX; | ||
}, te = (e) => { | ||
}, te = (e) => e.hasChildren ? e.firstChild : e.lThr, ee = (e) => e.hasChildren ? e.lastChild : e.rThr, ne = (e, t, s, n) => { | ||
const i = e.firstChild, a = i.lExt, c = e.children[t]; | ||
a.lThr = s; | ||
const r = n - s.relX - i.lExtRelX; | ||
a.relX += r, a.prelim -= r, i.lExt = c.lExt, i.lExtRelX = c.lExtRelX; | ||
}, re = (e, t, s, n) => { | ||
const i = e.children[t], a = i.rExt, c = e.children[t - 1]; | ||
a.rThr = s; | ||
const r = n - s.relX - i.rExtRelX; | ||
a.relX += r, a.prelim -= r, i.rExt = c.rExt, i.rExtRelX = c.rExtRelX; | ||
}, se = (e) => { | ||
if (e.hasChildren) { | ||
const t = e.firstChild, r = e.lastChild, n = (t.prelim + t.relX - t.xSize / 2 + r.relX + r.prelim + r.xSize / 2) / 2; | ||
const t = e.firstChild, s = e.lastChild, n = (t.prelim + t.relX - t.xSize / 2 + s.relX + s.prelim + s.xSize / 2) / 2; | ||
Object.assign(e, { | ||
@@ -455,21 +455,21 @@ prelim: n, | ||
lExtRelX: t.lExtRelX, | ||
rExt: r.rExt, | ||
rExtRelX: r.rExtRelX | ||
rExt: s.rExt, | ||
rExtRelX: s.rExtRelX | ||
}); | ||
} | ||
}, ee = (e, t, r) => { | ||
for (; r !== null && e >= r.lowY; ) | ||
r = r.next; | ||
}, ie = (e, t, s) => { | ||
for (; s !== null && e >= s.lowY; ) | ||
s = s.next; | ||
return { | ||
lowY: e, | ||
index: t, | ||
next: r | ||
next: s | ||
}; | ||
}, U = ".markmap{--markmap-max-width: 9999px;--markmap-a-color: #0097e6;--markmap-a-hover-color: #00a8ff;--markmap-code-bg: #f0f0f0;--markmap-code-color: #555;--markmap-highlight-bg: #ffeaa7;--markmap-table-border: 1px solid currentColor;--markmap-font: 300 16px/20px sans-serif;--markmap-circle-open-bg: #fff;--markmap-text-color: #333;font:var(--markmap-font);color:var(--markmap-text-color)}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign p{margin:0}.markmap-foreign a{color:var(--markmap-a-color)}.markmap-foreign a:hover{color:var(--markmap-a-hover-color)}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:var(--markmap-code-color);background-color:var(--markmap-code-bg);border-radius:2px}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:var(--markmap-highlight-bg)}.markmap-foreign table,.markmap-foreign th,.markmap-foreign td{border-collapse:collapse;border:var(--markmap-table-border)}.markmap-foreign img{display:inline-block}.markmap-foreign svg{fill:currentColor}.markmap-foreign>div{width:var(--markmap-max-width);text-align:left}.markmap-foreign>div>div{display:inline-block}.markmap-dark .markmap{--markmap-code-bg: #1a1b26;--markmap-code-color: #ddd;--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", oe = U, M = ot(); | ||
function H(e) { | ||
}, Z = ".markmap{--markmap-max-width: 9999px;--markmap-a-color: #0097e6;--markmap-a-hover-color: #00a8ff;--markmap-code-bg: #f0f0f0;--markmap-code-color: #555;--markmap-highlight-bg: #ffeaa7;--markmap-table-border: 1px solid currentColor;--markmap-font: 300 16px/20px sans-serif;--markmap-circle-open-bg: #fff;--markmap-text-color: #333;font:var(--markmap-font);color:var(--markmap-text-color)}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign p{margin:0}.markmap-foreign a{color:var(--markmap-a-color)}.markmap-foreign a:hover{color:var(--markmap-a-hover-color)}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:var(--markmap-code-color);background-color:var(--markmap-code-bg);border-radius:2px}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:var(--markmap-highlight-bg)}.markmap-foreign table,.markmap-foreign th,.markmap-foreign td{border-collapse:collapse;border:var(--markmap-table-border)}.markmap-foreign img{display:inline-block}.markmap-foreign svg{fill:currentColor}.markmap-foreign>div{width:var(--markmap-max-width);text-align:left}.markmap-foreign>div>div{display:inline-block}.markmap-dark .markmap{--markmap-code-bg: #1a1b26;--markmap-code-color: #ddd;--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", de = Z, M = ht(); | ||
function L(e) { | ||
return Math.max(4 - 2 * e.state.depth, 1.5); | ||
} | ||
function N(e, t) { | ||
const r = ht(e, t); | ||
return e[r]; | ||
function P(e, t) { | ||
const s = mt(e, t); | ||
return e[s]; | ||
} | ||
@@ -479,27 +479,27 @@ function B(e) { | ||
} | ||
const ne = new et(); | ||
class Y { | ||
constructor(t, r) { | ||
this.options = W, this.revokers = [], this.handleZoom = (n) => { | ||
const { transform: s } = n; | ||
this.g.attr("transform", s); | ||
const oe = new it(); | ||
class q { | ||
constructor(t, s) { | ||
this.options = K, this.revokers = [], this.handleZoom = (n) => { | ||
const { transform: i } = n; | ||
this.g.attr("transform", i); | ||
}, this.handlePan = (n) => { | ||
n.preventDefault(); | ||
const s = C(this.svg.node()), l = s.translate( | ||
-n.deltaX / s.k, | ||
-n.deltaY / s.k | ||
const i = w(this.svg.node()), a = i.translate( | ||
-n.deltaX / i.k, | ||
-n.deltaY / i.k | ||
); | ||
this.svg.call(this.zoom.transform, l); | ||
}, this.handleClick = (n, s) => { | ||
let l = this.options.toggleRecursively; | ||
(P ? n.metaKey : n.ctrlKey) && (l = !l), this.toggleNode(s, l); | ||
}, this.ensureView = this.ensureVisible, this.svg = t.datum ? t : at(t), this.styleNode = this.svg.append("style"), this.zoom = lt().filter((n) => this.options.scrollForPan && n.type === "wheel" ? n.ctrlKey && !n.button : (!n.ctrlKey || n.type === "wheel") && !n.button).on("zoom", this.handleZoom), this.setOptions(r), this.state = { | ||
id: this.options.id || this.svg.attr("id") || nt(), | ||
this.svg.call(this.zoom.transform, a); | ||
}, this.handleClick = (n, i) => { | ||
let a = this.options.toggleRecursively; | ||
(I ? n.metaKey : n.ctrlKey) && (a = !a), this.toggleNode(i, a); | ||
}, this.ensureView = this.ensureVisible, this.svg = t.datum ? t : dt(t), this.styleNode = this.svg.append("style"), this.zoom = pt().filter((n) => this.options.scrollForPan && n.type === "wheel" ? n.ctrlKey && !n.button : (!n.ctrlKey || n.type === "wheel") && !n.button).on("zoom", this.handleZoom), this.setOptions(s), this.state = { | ||
id: this.options.id || this.svg.attr("id") || ot(), | ||
rect: { x1: 0, y1: 0, x2: 0, y2: 0 } | ||
}, this.g = this.svg.append("g"), this.observer = new ResizeObserver( | ||
rt(() => { | ||
at(() => { | ||
this.renderData(); | ||
}, 100) | ||
), this.revokers.push( | ||
ne.tap(() => { | ||
oe.tap(() => { | ||
this.setData(); | ||
@@ -510,4 +510,4 @@ }) | ||
getStyleContent() { | ||
const { style: t } = this.options, { id: r } = this.state, n = typeof t == "function" ? t(r) : ""; | ||
return [this.options.embedGlobalCSS && U, n].filter(Boolean).join(` | ||
const { style: t } = this.options, { id: s } = this.state, n = typeof t == "function" ? t(s) : ""; | ||
return [this.options.embedGlobalCSS && Z, n].filter(Boolean).join(` | ||
`); | ||
@@ -518,3 +518,3 @@ } | ||
"class", | ||
it(this.svg.attr("class"), "markmap", this.state.id) | ||
lt(this.svg.attr("class"), "markmap", this.state.id) | ||
); | ||
@@ -524,25 +524,25 @@ const t = this.getStyleContent(); | ||
} | ||
async toggleNode(t, r = !1) { | ||
var s, l; | ||
const n = (s = t.payload) != null && s.fold ? 0 : 1; | ||
r ? j(t, (c, i) => { | ||
async toggleNode(t, s = !1) { | ||
var i, a; | ||
const n = (i = t.payload) != null && i.fold ? 0 : 1; | ||
s ? j(t, (c, r) => { | ||
c.payload = { | ||
...c.payload, | ||
fold: n | ||
}, i(); | ||
}, r(); | ||
}) : t.payload = { | ||
...t.payload, | ||
fold: (l = t.payload) != null && l.fold ? 0 : 1 | ||
fold: (a = t.payload) != null && a.fold ? 0 : 1 | ||
}, await this.renderData(t); | ||
} | ||
_initializeData(t) { | ||
let r = 0; | ||
const { color: n, initialExpandLevel: s } = this.options; | ||
let l = 0, c = 0; | ||
j(t, (i, a, d) => { | ||
let s = 0; | ||
const { color: n, initialExpandLevel: i } = this.options; | ||
let a = 0, c = 0; | ||
j(t, (r, l, d) => { | ||
var p, u, g, f; | ||
c += 1, i.children = (p = i.children) == null ? void 0 : p.map((x) => ({ ...x })), r += 1, i.state = { | ||
...i.state, | ||
c += 1, r.children = (p = r.children) == null ? void 0 : p.map((x) => ({ ...x })), s += 1, r.state = { | ||
...r.state, | ||
depth: c, | ||
id: r, | ||
id: s, | ||
rect: { | ||
@@ -555,5 +555,5 @@ x: 0, | ||
size: [0, 0] | ||
}, i.state.key = [(u = d == null ? void 0 : d.state) == null ? void 0 : u.id, i.state.id].filter(Boolean).join(".") + pt(i.content), i.state.path = [(g = d == null ? void 0 : d.state) == null ? void 0 : g.path, i.state.id].filter(Boolean).join("."), n(i); | ||
const h = ((f = i.payload) == null ? void 0 : f.fold) === 2; | ||
h ? l += 1 : (l || s >= 0 && i.state.depth >= s) && (i.payload = { ...i.payload, fold: 1 }), a(), h && (l -= 1), c -= 1; | ||
}, r.state.key = [(u = d == null ? void 0 : d.state) == null ? void 0 : u.id, r.state.id].filter(Boolean).join(".") + ft(r.content), r.state.path = [(g = d == null ? void 0 : d.state) == null ? void 0 : g.path, r.state.id].filter(Boolean).join("."), n(r); | ||
const h = ((f = r.payload) == null ? void 0 : f.fold) === 2; | ||
h ? a += 1 : (a || i >= 0 && r.state.depth >= i) && (r.payload = { ...r.payload, fold: 1 }), l(), h && (a -= 1), c -= 1; | ||
}); | ||
@@ -563,36 +563,36 @@ } | ||
if (!this.state.data) return; | ||
this.g.selectAll(b("g")).selectAll( | ||
b("foreignObject") | ||
).each(function(i) { | ||
this.g.selectAll(y("g")).selectAll( | ||
y("foreignObject") | ||
).each(function(r) { | ||
var h; | ||
const a = (h = this.firstChild) == null ? void 0 : h.firstChild, d = [a.scrollWidth, a.scrollHeight]; | ||
i.state.size = d; | ||
const l = (h = this.firstChild) == null ? void 0 : h.firstChild, d = [l.scrollWidth, l.scrollHeight]; | ||
r.state.size = d; | ||
}); | ||
const { spacingHorizontal: t, paddingX: r, spacingVertical: n } = this.options, s = K({}).children((i) => { | ||
var a; | ||
if (!((a = i.payload) != null && a.fold)) return i.children; | ||
}).nodeSize((i) => { | ||
const [a, d] = i.data.state.size; | ||
return [d, a + (a ? r * 2 : 0) + t]; | ||
}).spacing((i, a) => i.parent === a.parent ? n : n * 2), l = s.hierarchy(this.state.data); | ||
s(l); | ||
const c = l.descendants(); | ||
c.forEach((i) => { | ||
const a = i.data; | ||
a.state.rect = { | ||
x: i.y, | ||
y: i.x - i.xSize / 2, | ||
width: i.ySize - t, | ||
height: i.xSize | ||
const { spacingHorizontal: t, paddingX: s, spacingVertical: n } = this.options, i = V({}).children((r) => { | ||
var l; | ||
if (!((l = r.payload) != null && l.fold)) return r.children; | ||
}).nodeSize((r) => { | ||
const [l, d] = r.data.state.size; | ||
return [d, l + (l ? s * 2 : 0) + t]; | ||
}).spacing((r, l) => r.parent === l.parent ? n : n * 2), a = i.hierarchy(this.state.data); | ||
i(a); | ||
const c = a.descendants(); | ||
c.forEach((r) => { | ||
const l = r.data; | ||
l.state.rect = { | ||
x: r.y, | ||
y: r.x - r.xSize / 2, | ||
width: r.ySize - t, | ||
height: r.xSize | ||
}; | ||
}), this.state.rect = { | ||
x1: T(c, (i) => i.data.state.rect.x) || 0, | ||
y1: T(c, (i) => i.data.state.rect.y) || 0, | ||
x2: _( | ||
x1: H(c, (r) => r.data.state.rect.x) || 0, | ||
y1: H(c, (r) => r.data.state.rect.y) || 0, | ||
x2: N( | ||
c, | ||
(i) => i.data.state.rect.x + i.data.state.rect.width | ||
(r) => r.data.state.rect.x + r.data.state.rect.width | ||
) || 0, | ||
y2: _( | ||
y2: N( | ||
c, | ||
(i) => i.data.state.rect.y + i.data.state.rect.height | ||
(r) => r.data.state.rect.y + r.data.state.rect.height | ||
) || 0 | ||
@@ -607,14 +607,14 @@ }; | ||
} | ||
async setData(t, r) { | ||
r && this.setOptions(r), t && (this.state.data = t), this.state.data && (this._initializeData(this.state.data), this.updateStyle(), await this.renderData()); | ||
async setData(t, s) { | ||
s && this.setOptions(s), t && (this.state.data = t), this.state.data && (this._initializeData(this.state.data), this.updateStyle(), await this.renderData()); | ||
} | ||
async renderData(t) { | ||
const { paddingX: r, autoFit: n, color: s, maxWidth: l } = this.options; | ||
const { paddingX: s, autoFit: n, color: i, maxWidth: a } = this.options; | ||
if (!this.state.data) return; | ||
const c = []; | ||
j(this.state.data, (o, m) => { | ||
var y; | ||
(y = o.payload) != null && y.fold || m(), c.push(o); | ||
var v; | ||
(v = o.payload) != null && v.fold || m(), c.push(o); | ||
}); | ||
const a = (t || this.state.data).state.rect, d = this.g.selectAll(b("g")).data(c, (o) => o.state.key), h = d.enter().append("g").attr("data-depth", (o) => o.state.depth).attr("data-path", (o) => o.state.path), p = d.exit(), u = d.merge(h).attr( | ||
const r = t || this.state.data, l = r.state.rect, d = this.g.selectAll(y("g")).data(c, (o) => o.state.key), h = d.enter().append("g").attr("data-depth", (o) => o.state.depth).attr("data-path", (o) => o.state.path), p = d.exit(), u = d.merge(h).attr( | ||
"class", | ||
@@ -625,10 +625,6 @@ (o) => { | ||
} | ||
), g = u.selectAll(b("line")).data( | ||
), g = u.selectAll(y("line")).data( | ||
(o) => [o], | ||
(o) => o.state.key | ||
), f = g.enter().append("line"), x = p.selectAll( | ||
b("line") | ||
), v = g.merge(f), k = u.selectAll( | ||
b("circle") | ||
).data( | ||
), f = g.enter().append("line").attr("stroke", (o) => i(o)).attr("stroke-width", 0), x = g.merge(f), k = u.selectAll(y("circle")).data( | ||
(o) => { | ||
@@ -639,69 +635,75 @@ var m; | ||
(o) => o.state.key | ||
).join( | ||
(o) => o.append("circle").attr("stroke-width", "1.5").attr("r", 0).on("click", (m, y) => this.handleClick(m, y)).on("mousedown", B), | ||
(o) => o, | ||
(o) => o.remove() | ||
), z = this.observer, $ = u.selectAll(b("foreignObject")).data( | ||
), E = k.enter().append("circle").attr("stroke-width", 0).attr("r", 0).on("click", (o, m) => this.handleClick(o, m)).on("mousedown", B).merge(k).attr("stroke", (o) => i(o)).attr( | ||
"fill", | ||
(o) => { | ||
var m; | ||
return (m = o.payload) != null && m.fold && o.children ? i(o) : "var(--markmap-circle-open-bg)"; | ||
} | ||
), O = this.observer, $ = u.selectAll(y("foreignObject")).data( | ||
(o) => [o], | ||
(o) => o.state.key | ||
), X = $.enter().append("foreignObject").attr("class", "markmap-foreign").attr("x", r).attr("y", 0).style("opacity", 0).on("mousedown", B).on("dblclick", B); | ||
), X = $.enter().append("foreignObject").attr("class", "markmap-foreign").attr("x", s).attr("y", 0).style("opacity", 0).on("mousedown", B).on("dblclick", B); | ||
X.append("xhtml:div").append("xhtml:div").html((o) => o.content).attr("xmlns", "http://www.w3.org/1999/xhtml"), X.each(function() { | ||
var m; | ||
const o = (m = this.firstChild) == null ? void 0 : m.firstChild; | ||
z.observe(o); | ||
O.observe(o); | ||
}); | ||
const A = p.selectAll( | ||
b("foreignObject") | ||
const D = p.selectAll( | ||
y("foreignObject") | ||
); | ||
A.each(function() { | ||
D.each(function() { | ||
var m; | ||
const o = (m = this.firstChild) == null ? void 0 : m.firstChild; | ||
z.unobserve(o); | ||
O.unobserve(o); | ||
}); | ||
const D = X.merge($), Z = c.flatMap( | ||
const F = X.merge($), J = c.flatMap( | ||
(o) => { | ||
var m; | ||
return (m = o.payload) != null && m.fold ? [] : o.children.map((y) => ({ source: o, target: y })); | ||
return (m = o.payload) != null && m.fold ? [] : o.children.map((v) => ({ source: o, target: v })); | ||
} | ||
), R = this.g.selectAll(b("path")).data(Z, (o) => o.target.state.key), q = R.exit(), F = R.enter().insert("path", "g").attr("class", "markmap-link").attr("data-depth", (o) => o.target.state.depth).attr("data-path", (o) => o.target.state.path), J = F.merge(R); | ||
), R = this.g.selectAll(y("path")).data(J, (o) => o.target.state.key), Q = R.exit(), T = [ | ||
l.x + l.width, | ||
l.y + l.height | ||
], tt = R.enter().insert("path", "g").attr("class", "markmap-link").attr("data-depth", (o) => o.target.state.depth).attr("data-path", (o) => o.target.state.path).attr("d", M({ source: T, target: T })).attr("stroke-width", 0).merge(R); | ||
this.svg.style( | ||
"--markmap-max-width", | ||
l ? `${l}px` : null | ||
), await new Promise(requestAnimationFrame), this._relayout(), this.transition(p).attr("transform", (o) => { | ||
const m = a.x + a.width - o.state.rect.width, y = a.y + a.height - o.state.rect.height; | ||
return `translate(${m},${y})`; | ||
}).remove(), h.attr( | ||
a ? `${a}px` : null | ||
), await new Promise(requestAnimationFrame), this._relayout(); | ||
const z = r.state.rect; | ||
h.attr( | ||
"transform", | ||
(o) => `translate(${a.x + a.width - o.state.rect.width},${a.y + a.height - o.state.rect.height})` | ||
), this.transition(u).attr( | ||
(o) => `translate(${l.x + l.width - o.state.rect.width},${l.y + l.height - o.state.rect.height})` | ||
), this.transition(p).attr("transform", (o) => { | ||
const m = z.x + z.width - o.state.rect.width, v = z.y + z.height - o.state.rect.height; | ||
return `translate(${m},${v})`; | ||
}).remove(), this.transition(u).attr( | ||
"transform", | ||
(o) => `translate(${o.state.rect.x},${o.state.rect.y})` | ||
), this.transition(x).attr("x1", (o) => o.state.rect.width).attr("x2", (o) => o.state.rect.width), f.attr("x1", (o) => o.state.rect.width).attr("x2", (o) => o.state.rect.width), v.attr("y1", (o) => o.state.rect.height).attr("y2", (o) => o.state.rect.height).attr("stroke", (o) => s(o)), this.transition(v).attr("x1", -1).attr("x2", (o) => o.state.rect.width + 2).attr("stroke-width", H), k.attr("cx", (o) => o.state.rect.width).attr("cy", (o) => o.state.rect.height).attr("stroke", (o) => s(o)).attr( | ||
"fill", | ||
(o) => { | ||
var m; | ||
return (m = o.payload) != null && m.fold && o.children ? s(o) : "var(--markmap-circle-open-bg)"; | ||
} | ||
), this.transition(k).attr("r", 6), this.transition(A).style("opacity", 0), D.attr("width", (o) => Math.max(0, o.state.rect.width - r * 2)).attr("height", (o) => o.state.rect.height), this.transition(D).style("opacity", 1); | ||
const S = [ | ||
a.x + a.width, | ||
a.y + a.height | ||
); | ||
const et = p.selectAll( | ||
y("line") | ||
); | ||
this.transition(et).attr("x1", (o) => o.state.rect.width).attr("stroke-width", 0), f.attr("x1", (o) => o.state.rect.width).attr("x2", (o) => o.state.rect.width), x.attr("y1", (o) => o.state.rect.height).attr("y2", (o) => o.state.rect.height), this.transition(x).attr("x1", -1).attr("x2", (o) => o.state.rect.width + 2).attr("stroke", (o) => i(o)).attr("stroke-width", L); | ||
const nt = p.selectAll( | ||
y("circle") | ||
); | ||
this.transition(nt).attr("r", 0).attr("stroke-width", 0), E.attr("cx", (o) => o.state.rect.width).attr("cy", (o) => o.state.rect.height), this.transition(E).attr("r", 6).attr("stroke-width", "1.5"), this.transition(D).style("opacity", 0), F.attr("width", (o) => Math.max(0, o.state.rect.width - s * 2)).attr("height", (o) => o.state.rect.height), this.transition(F).style("opacity", 1); | ||
const _ = [ | ||
z.x + z.width, | ||
z.y + z.height | ||
]; | ||
this.transition(q).attr("d", M({ source: S, target: S })).remove(), F.attr( | ||
"d", | ||
M({ source: S, target: S }) | ||
), this.transition(J).attr("stroke", (o) => s(o.target)).attr("stroke-width", (o) => H(o.target)).attr("d", (o) => { | ||
const m = o.source, y = o.target, Q = [ | ||
this.transition(Q).attr("d", M({ source: _, target: _ })).attr("stroke-width", 0).remove(), this.transition(tt).attr("stroke", (o) => i(o.target)).attr("stroke-width", (o) => L(o.target)).attr("d", (o) => { | ||
const m = o.source, v = o.target, rt = [ | ||
m.state.rect.x + m.state.rect.width, | ||
m.state.rect.y + m.state.rect.height | ||
], tt = [ | ||
y.state.rect.x, | ||
y.state.rect.y + y.state.rect.height | ||
], st = [ | ||
v.state.rect.x, | ||
v.state.rect.y + v.state.rect.height | ||
]; | ||
return M({ source: Q, target: tt }); | ||
return M({ source: rt, target: st }); | ||
}), n && this.fit(); | ||
} | ||
transition(t) { | ||
const { duration: r } = this.options; | ||
return t.transition().duration(r); | ||
const { duration: s } = this.options; | ||
return t.transition().duration(s); | ||
} | ||
@@ -712,20 +714,20 @@ /** | ||
async fit(t = this.options.maxInitialScale) { | ||
const r = this.svg.node(), { width: n, height: s } = r.getBoundingClientRect(), { fitRatio: l } = this.options, { x1: c, y1: i, x2: a, y2: d } = this.state.rect, h = a - c, p = d - i, u = Math.min( | ||
n / h * l, | ||
s / p * l, | ||
const s = this.svg.node(), { width: n, height: i } = s.getBoundingClientRect(), { fitRatio: a } = this.options, { x1: c, y1: r, x2: l, y2: d } = this.state.rect, h = l - c, p = d - r, u = Math.min( | ||
n / h * a, | ||
i / p * a, | ||
t | ||
), g = ct.translate( | ||
), g = ut.translate( | ||
(n - h * u) / 2 - c * u, | ||
(s - p * u) / 2 - i * u | ||
(i - p * u) / 2 - r * u | ||
).scale(u); | ||
return this.transition(this.svg).call(this.zoom.transform, g).end().catch(E); | ||
return this.transition(this.svg).call(this.zoom.transform, g).end().catch(C); | ||
} | ||
findElement(t) { | ||
let r; | ||
return this.g.selectAll(b("g")).each(function(s) { | ||
s === t && (r = { | ||
data: s, | ||
let s; | ||
return this.g.selectAll(y("g")).each(function(i) { | ||
i === t && (s = { | ||
data: i, | ||
g: this | ||
}); | ||
}), r; | ||
}), s; | ||
} | ||
@@ -735,13 +737,13 @@ /** | ||
*/ | ||
async ensureVisible(t, r) { | ||
var v; | ||
const n = (v = this.findElement(t)) == null ? void 0 : v.data; | ||
async ensureVisible(t, s) { | ||
var k; | ||
const n = (k = this.findElement(t)) == null ? void 0 : k.data; | ||
if (!n) return; | ||
const s = this.svg.node(), l = s.getBoundingClientRect(), c = C(s), [i, a] = [ | ||
const i = this.svg.node(), a = i.getBoundingClientRect(), c = w(i), [r, l] = [ | ||
n.state.rect.x, | ||
n.state.rect.x + n.state.rect.width + 2 | ||
].map((k) => k * c.k + c.x), [d, h] = [ | ||
].map((b) => b * c.k + c.x), [d, h] = [ | ||
n.state.rect.y, | ||
n.state.rect.y + n.state.rect.height | ||
].map((k) => k * c.k + c.y), p = { | ||
].map((b) => b * c.k + c.y), p = { | ||
left: 0, | ||
@@ -751,14 +753,14 @@ right: 0, | ||
bottom: 0, | ||
...r | ||
}, u = [p.left - i, l.width - p.right - a], g = [p.top - d, l.height - p.bottom - h], f = u[0] * u[1] > 0 ? N(u, Math.abs) / c.k : 0, x = g[0] * g[1] > 0 ? N(g, Math.abs) / c.k : 0; | ||
...s | ||
}, u = [p.left - r, a.width - p.right - l], g = [p.top - d, a.height - p.bottom - h], f = u[0] * u[1] > 0 ? P(u, Math.abs) / c.k : 0, x = g[0] * g[1] > 0 ? P(g, Math.abs) / c.k : 0; | ||
if (f || x) { | ||
const k = c.translate(f, x); | ||
return this.transition(this.svg).call(this.zoom.transform, k).end().catch(E); | ||
const b = c.translate(f, x); | ||
return this.transition(this.svg).call(this.zoom.transform, b).end().catch(C); | ||
} | ||
} | ||
async centerNode(t, r) { | ||
async centerNode(t, s) { | ||
var f; | ||
const n = (f = this.findElement(t)) == null ? void 0 : f.data; | ||
if (!n) return; | ||
const s = this.svg.node(), l = s.getBoundingClientRect(), c = C(s), i = (n.state.rect.x + n.state.rect.width / 2) * c.k + c.x, a = (n.state.rect.y + n.state.rect.height / 2) * c.k + c.y, d = { | ||
const i = this.svg.node(), a = i.getBoundingClientRect(), c = w(i), r = (n.state.rect.x + n.state.rect.width / 2) * c.k + c.x, l = (n.state.rect.y + n.state.rect.height / 2) * c.k + c.y, d = { | ||
left: 0, | ||
@@ -768,7 +770,7 @@ right: 0, | ||
bottom: 0, | ||
...r | ||
}, h = (d.left + l.width - d.right) / 2, p = (d.top + l.height - d.bottom) / 2, u = (h - i) / c.k, g = (p - a) / c.k; | ||
...s | ||
}, h = (d.left + a.width - d.right) / 2, p = (d.top + a.height - d.bottom) / 2, u = (h - r) / c.k, g = (p - l) / c.k; | ||
if (u || g) { | ||
const x = c.translate(u, g); | ||
return this.transition(this.svg).call(this.zoom.transform, x).end().catch(E); | ||
return this.transition(this.svg).call(this.zoom.transform, x).end().catch(C); | ||
} | ||
@@ -780,7 +782,7 @@ } | ||
async rescale(t) { | ||
const r = this.svg.node(), { width: n, height: s } = r.getBoundingClientRect(), l = n / 2, c = s / 2, i = C(r), a = i.translate( | ||
(l - i.x) * (1 - t) / i.k, | ||
(c - i.y) * (1 - t) / i.k | ||
const s = this.svg.node(), { width: n, height: i } = s.getBoundingClientRect(), a = n / 2, c = i / 2, r = w(s), l = r.translate( | ||
(a - r.x) * (1 - t) / r.k, | ||
(c - r.y) * (1 - t) / r.k | ||
).scale(t); | ||
return this.transition(this.svg).call(this.zoom.transform, a).end().catch(E); | ||
return this.transition(this.svg).call(this.zoom.transform, l).end().catch(C); | ||
} | ||
@@ -792,20 +794,20 @@ destroy() { | ||
} | ||
static create(t, r, n = null) { | ||
const s = new Y(t, r); | ||
return n && s.setData(n).then(() => { | ||
s.fit(); | ||
}), s; | ||
static create(t, s, n = null) { | ||
const i = new q(t, s); | ||
return n && i.setData(n).then(() => { | ||
i.fit(); | ||
}), i; | ||
} | ||
} | ||
export { | ||
Y as Markmap, | ||
dt as defaultColorFn, | ||
W as defaultOptions, | ||
se as deriveOptions, | ||
oe as globalCSS, | ||
P as isMacintosh, | ||
ce as loadCSS, | ||
he as loadJS, | ||
ne as refreshHook, | ||
pt as simpleHash | ||
q as Markmap, | ||
gt as defaultColorFn, | ||
K as defaultOptions, | ||
he as deriveOptions, | ||
de as globalCSS, | ||
I as isMacintosh, | ||
me as loadCSS, | ||
ge as loadJS, | ||
oe as refreshHook, | ||
ft as simpleHash | ||
}; |
{ | ||
"name": "markmap-view", | ||
"version": "0.18.2", | ||
"version": "0.18.3", | ||
"description": "View markmaps in browser", | ||
@@ -54,3 +54,3 @@ "author": "Gerald <gera2ld@live.com>", | ||
}, | ||
"gitHead": "75261f82190df5b126faf6f6dc82adeb1c3a2cc2" | ||
"gitHead": "8d690760aa134baeb4fa5c6247c61c6c56544a29" | ||
} |
82820
2321