markmap-view 0.15.9-alpha.6 → 0.16.3-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +16 -8
- package/dist/index.js +234 -226
- package/dist/types.d.ts +8 -0
- package/dist/view.d.ts +5 -9
- package/package.json +5 -4
package/dist/browser/index.js
CHANGED
|
@@ -1154,7 +1154,7 @@
|
|
|
1154
1154
|
};
|
|
1155
1155
|
};
|
|
1156
1156
|
const containerCSS = "/* used for pre-rendering to get the size of each node */\n.markmap-container {\n position: absolute;\n width: 0;\n height: 0;\n top: -100px;\n left: -100px;\n overflow: hidden;\n}\n.markmap-container > .markmap-foreign {\n display: inline-block;\n }\n/* first-child for line wrapping, last-child for max-width detection */\n.markmap-container > .markmap-foreign > div:last-child,\n \n .markmap-container > .markmap-foreign > div:last-child :not(pre) {\n white-space: nowrap;\n }\n.markmap-container > .markmap-foreign > div:last-child code {\n white-space: inherit;\n }\n";
|
|
1157
|
-
const css = ".markmap {\n --markmap-max-width: none;\n --markmap-a-color: #0097e6;\n --markmap-a-hover-color: #00a8ff;\n --markmap-code-bg: #f0f0f0;\n --markmap-code-color: #555;\n --markmap-highlight-bg: #ffeaa7;\n --markmap-table-border: 1px solid currentColor;\n --markmap-font: 300 16px/20px sans-serif;\n\n font: var(--markmap-font);\n}\n\n .markmap-link {\n fill: none;\n }\n\n .markmap-node > circle {\n cursor: pointer;\n }\n\n .markmap-foreign {\n display: inline-block;\n }\n\n .markmap-foreign a {\n color: var(--markmap-a-color);\n }\n\n .markmap-foreign a:hover {\n color: var(--markmap-a-hover-color);\n }\n\n .markmap-foreign code {\n padding: 0.25em;\n font-size: calc(1em - 2px);\n color: var(--markmap-code-color);\n background-color: var(--markmap-code-bg);\n border-radius: 2px;\n }\n\n .markmap-foreign pre {\n margin: 0;\n }\n\n .markmap-foreign pre > code {\n display: block;\n }\n\n .markmap-foreign del {\n text-decoration: line-through;\n }\n\n .markmap-foreign em {\n font-style: italic;\n }\n\n .markmap-foreign strong {\n font-weight: bold;\n }\n\n .markmap-foreign mark {\n background: var(--markmap-highlight-bg);\n }\n\n .markmap-foreign table,\n .markmap-foreign th,\n .markmap-foreign td {\n border-collapse: collapse;\n border: var(--markmap-table-border);\n }\n\n .markmap-foreign img {\n display: inline-block;\n }\n\n .markmap-foreign-testing-max {\n max-width: var(--markmap-max-width);\n }\n\n .markmap-foreign-testing-max img {\n max-width: var(--markmap-max-width);\n max-height: none;\n }\n";
|
|
1157
|
+
const css = ".markmap {\n --markmap-max-width: none;\n --markmap-a-color: #0097e6;\n --markmap-a-hover-color: #00a8ff;\n --markmap-code-bg: #f0f0f0;\n --markmap-code-color: #555;\n --markmap-highlight-bg: #ffeaa7;\n --markmap-table-border: 1px solid currentColor;\n --markmap-font: 300 16px/20px sans-serif;\n --markmap-circle-open-bg: #fff;\n --markmap-text-color: #333;\n\n font: var(--markmap-font);\n color: var(--markmap-text-color);\n}\n\n .markmap-link {\n fill: none;\n }\n\n .markmap-node > circle {\n cursor: pointer;\n }\n\n .markmap-foreign {\n display: inline-block;\n }\n\n .markmap-foreign p {\n margin: 0;\n }\n\n .markmap-foreign a {\n color: var(--markmap-a-color);\n }\n\n .markmap-foreign a:hover {\n color: var(--markmap-a-hover-color);\n }\n\n .markmap-foreign code {\n padding: 0.25em;\n font-size: calc(1em - 2px);\n color: var(--markmap-code-color);\n background-color: var(--markmap-code-bg);\n border-radius: 2px;\n }\n\n .markmap-foreign pre {\n margin: 0;\n }\n\n .markmap-foreign pre > code {\n display: block;\n }\n\n .markmap-foreign del {\n text-decoration: line-through;\n }\n\n .markmap-foreign em {\n font-style: italic;\n }\n\n .markmap-foreign strong {\n font-weight: bold;\n }\n\n .markmap-foreign mark {\n background: var(--markmap-highlight-bg);\n }\n\n .markmap-foreign table,\n .markmap-foreign th,\n .markmap-foreign td {\n border-collapse: collapse;\n border: var(--markmap-table-border);\n }\n\n .markmap-foreign img {\n display: inline-block;\n }\n\n .markmap-foreign svg {\n fill: currentColor;\n }\n\n .markmap-foreign-testing-max {\n max-width: var(--markmap-max-width);\n }\n\n .markmap-foreign-testing-max img {\n max-width: var(--markmap-max-width);\n max-height: none;\n }\n\n.markmap-dark .markmap {\n --markmap-circle-open-bg: #444;\n --markmap-text-color: #eee;\n}\n";
|
|
1158
1158
|
const globalCSS = css;
|
|
1159
1159
|
function linkWidth(nodeData) {
|
|
1160
1160
|
const data = nodeData.data;
|
|
@@ -1462,7 +1462,7 @@
|
|
|
1462
1462
|
"fill",
|
|
1463
1463
|
(d) => {
|
|
1464
1464
|
var _a;
|
|
1465
|
-
return ((_a = d.data.payload) == null ? void 0 : _a.fold) && d.data.children ? color(d.data) : "
|
|
1465
|
+
return ((_a = d.data.payload) == null ? void 0 : _a.fold) && d.data.children ? color(d.data) : "var(--markmap-circle-open-bg)";
|
|
1466
1466
|
}
|
|
1467
1467
|
);
|
|
1468
1468
|
const foreignObject = nodeMerge.selectAll(
|
|
@@ -1549,18 +1549,26 @@
|
|
|
1549
1549
|
).scale(scale);
|
|
1550
1550
|
return this.transition(this.svg).call(this.zoom.transform, initialZoom).end().catch(noop);
|
|
1551
1551
|
}
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
*/
|
|
1555
|
-
async ensureView(node, padding) {
|
|
1556
|
-
let itemData;
|
|
1552
|
+
findElement(node) {
|
|
1553
|
+
let result;
|
|
1557
1554
|
this.g.selectAll(
|
|
1558
1555
|
childSelector("g")
|
|
1559
1556
|
).each(function walk(d) {
|
|
1560
1557
|
if (d.data === node) {
|
|
1561
|
-
|
|
1558
|
+
result = {
|
|
1559
|
+
data: d,
|
|
1560
|
+
g: this
|
|
1561
|
+
};
|
|
1562
1562
|
}
|
|
1563
1563
|
});
|
|
1564
|
+
return result;
|
|
1565
|
+
}
|
|
1566
|
+
/**
|
|
1567
|
+
* Pan the content to make the provided node visible in the viewport.
|
|
1568
|
+
*/
|
|
1569
|
+
async ensureView(node, padding) {
|
|
1570
|
+
var _a;
|
|
1571
|
+
const itemData = (_a = this.findElement(node)) == null ? void 0 : _a.data;
|
|
1564
1572
|
if (!itemData)
|
|
1565
1573
|
return;
|
|
1566
1574
|
const svgNode = this.svg.node();
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Hook as st, getId as at, debounce as lt, addClass as ct, walkTree as T, childSelector as
|
|
2
|
-
import { loadCSS as
|
|
3
|
-
import { scaleOrdinal as V, schemeCategory10 as ht, zoomTransform as A, select as dt, zoom as ut, linkHorizontal as pt, min as H, max as L, zoomIdentity as
|
|
1
|
+
import { Hook as st, getId as at, debounce as lt, addClass as ct, walkTree as T, childSelector as C, noop as M } from "markmap-common";
|
|
2
|
+
import { loadCSS as Ce, loadJS as we } from "markmap-common";
|
|
3
|
+
import { scaleOrdinal as V, schemeCategory10 as ht, zoomTransform as A, select as dt, zoom as ut, linkHorizontal as pt, min as H, max as L, zoomIdentity as mt, minIndex as ft } from "d3";
|
|
4
4
|
const K = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), gt = V(ht), P = {
|
|
5
5
|
autoFit: !1,
|
|
6
6
|
color: (e) => {
|
|
@@ -22,12 +22,12 @@ const K = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), g
|
|
|
22
22
|
toggleRecursively: !1
|
|
23
23
|
};
|
|
24
24
|
function Se(e) {
|
|
25
|
-
const t = {}, n = { ...e }, { color:
|
|
26
|
-
if ((
|
|
27
|
-
const s =
|
|
25
|
+
const t = {}, n = { ...e }, { color: r, colorFreezeLevel: o } = n;
|
|
26
|
+
if ((r == null ? void 0 : r.length) === 1) {
|
|
27
|
+
const s = r[0];
|
|
28
28
|
t.color = () => s;
|
|
29
|
-
} else if (
|
|
30
|
-
const s = V(
|
|
29
|
+
} else if (r != null && r.length) {
|
|
30
|
+
const s = V(r);
|
|
31
31
|
t.color = (l) => s(`${l.state.path}`);
|
|
32
32
|
}
|
|
33
33
|
if (o) {
|
|
@@ -77,28 +77,28 @@ const zt = {
|
|
|
77
77
|
function I(e, t) {
|
|
78
78
|
Array.isArray(t) || (t = [t]), t = t.filter(Boolean), t.length && e.append(...t);
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
for (const
|
|
82
|
-
if (!(
|
|
83
|
-
if (
|
|
84
|
-
e.innerHTML = t[
|
|
85
|
-
else if (
|
|
86
|
-
const o = t[
|
|
87
|
-
o != null && (e[
|
|
80
|
+
function Et(e, t, n) {
|
|
81
|
+
for (const r in t)
|
|
82
|
+
if (!(r === "key" || r === "children" || r === "ref"))
|
|
83
|
+
if (r === "dangerouslySetInnerHTML")
|
|
84
|
+
e.innerHTML = t[r].__html;
|
|
85
|
+
else if (r === "innerHTML" || r === "textContent" || r === "innerText" || r === "value" && ["textarea", "select"].includes(e.tagName)) {
|
|
86
|
+
const o = t[r];
|
|
87
|
+
o != null && (e[r] = o);
|
|
88
88
|
} else
|
|
89
|
-
|
|
89
|
+
r.startsWith("on") ? e[r.toLowerCase()] = t[r] : wt(e, r, t[r], n.isSvg);
|
|
90
90
|
}
|
|
91
|
-
const
|
|
91
|
+
const Ct = {
|
|
92
92
|
className: "class",
|
|
93
93
|
labelFor: "for"
|
|
94
94
|
};
|
|
95
|
-
function wt(e, t, n,
|
|
96
|
-
if (t =
|
|
95
|
+
function wt(e, t, n, r) {
|
|
96
|
+
if (t = Ct[t] || t, n === !0)
|
|
97
97
|
e.setAttribute(t, "");
|
|
98
98
|
else if (n === !1)
|
|
99
99
|
e.removeAttribute(t);
|
|
100
100
|
else {
|
|
101
|
-
const o =
|
|
101
|
+
const o = r ? yt[t] : void 0;
|
|
102
102
|
o !== void 0 ? e.setAttributeNS(o, t, n) : e.setAttribute(t, n);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -116,17 +116,17 @@ function B(e, t = zt) {
|
|
|
116
116
|
if (St(e)) {
|
|
117
117
|
const {
|
|
118
118
|
type: n,
|
|
119
|
-
props:
|
|
119
|
+
props: r
|
|
120
120
|
} = e;
|
|
121
121
|
if (n === bt) {
|
|
122
122
|
const a = document.createDocumentFragment();
|
|
123
|
-
if (
|
|
124
|
-
const c = $(
|
|
123
|
+
if (r.children) {
|
|
124
|
+
const c = $(r.children, t);
|
|
125
125
|
I(a, c);
|
|
126
126
|
}
|
|
127
127
|
return a;
|
|
128
128
|
}
|
|
129
|
-
const o = n(
|
|
129
|
+
const o = n(r);
|
|
130
130
|
return B(o, t);
|
|
131
131
|
}
|
|
132
132
|
if (kt(e))
|
|
@@ -134,14 +134,14 @@ function B(e, t = zt) {
|
|
|
134
134
|
if (vt(e)) {
|
|
135
135
|
let n;
|
|
136
136
|
const {
|
|
137
|
-
type:
|
|
137
|
+
type: r,
|
|
138
138
|
props: o
|
|
139
139
|
} = e;
|
|
140
|
-
if (!t.isSvg &&
|
|
140
|
+
if (!t.isSvg && r === "svg" && (t = Object.assign({}, t, {
|
|
141
141
|
isSvg: !0
|
|
142
|
-
})), t.isSvg ? n = document.createElementNS(xt,
|
|
142
|
+
})), t.isSvg ? n = document.createElementNS(xt, r) : n = document.createElement(r), Et(n, o, t), o.children) {
|
|
143
143
|
let c = t;
|
|
144
|
-
t.isSvg &&
|
|
144
|
+
t.isSvg && r === "foreignObject" && (c = Object.assign({}, c, {
|
|
145
145
|
isSvg: !1
|
|
146
146
|
}));
|
|
147
147
|
const s = $(o.children, c);
|
|
@@ -158,47 +158,47 @@ function O(e) {
|
|
|
158
158
|
return B(e);
|
|
159
159
|
}
|
|
160
160
|
function jt(e) {
|
|
161
|
-
var t = 0, n = e.children,
|
|
162
|
-
if (!
|
|
161
|
+
var t = 0, n = e.children, r = n && n.length;
|
|
162
|
+
if (!r)
|
|
163
163
|
t = 1;
|
|
164
164
|
else
|
|
165
|
-
for (; --
|
|
166
|
-
t += n[
|
|
165
|
+
for (; --r >= 0; )
|
|
166
|
+
t += n[r].value;
|
|
167
167
|
e.value = t;
|
|
168
168
|
}
|
|
169
169
|
function Nt() {
|
|
170
170
|
return this.eachAfter(jt);
|
|
171
171
|
}
|
|
172
172
|
function Rt(e) {
|
|
173
|
-
var t = this, n,
|
|
173
|
+
var t = this, n, r = [t], o, a, c;
|
|
174
174
|
do
|
|
175
|
-
for (n =
|
|
175
|
+
for (n = r.reverse(), r = []; t = n.pop(); )
|
|
176
176
|
if (e(t), o = t.children, o)
|
|
177
177
|
for (a = 0, c = o.length; a < c; ++a)
|
|
178
|
-
|
|
179
|
-
while (
|
|
178
|
+
r.push(o[a]);
|
|
179
|
+
while (r.length);
|
|
180
180
|
return this;
|
|
181
181
|
}
|
|
182
182
|
function Tt(e) {
|
|
183
|
-
for (var t = this, n = [t],
|
|
184
|
-
if (e(t),
|
|
185
|
-
for (o =
|
|
186
|
-
n.push(
|
|
183
|
+
for (var t = this, n = [t], r, o; t = n.pop(); )
|
|
184
|
+
if (e(t), r = t.children, r)
|
|
185
|
+
for (o = r.length - 1; o >= 0; --o)
|
|
186
|
+
n.push(r[o]);
|
|
187
187
|
return this;
|
|
188
188
|
}
|
|
189
189
|
function Mt(e) {
|
|
190
|
-
for (var t = this, n = [t],
|
|
191
|
-
if (
|
|
190
|
+
for (var t = this, n = [t], r = [], o, a, c; t = n.pop(); )
|
|
191
|
+
if (r.push(t), o = t.children, o)
|
|
192
192
|
for (a = 0, c = o.length; a < c; ++a)
|
|
193
193
|
n.push(o[a]);
|
|
194
|
-
for (; t =
|
|
194
|
+
for (; t = r.pop(); )
|
|
195
195
|
e(t);
|
|
196
196
|
return this;
|
|
197
197
|
}
|
|
198
198
|
function At(e) {
|
|
199
199
|
return this.eachAfter(function(t) {
|
|
200
|
-
for (var n = +e(t.data) || 0,
|
|
201
|
-
n +=
|
|
200
|
+
for (var n = +e(t.data) || 0, r = t.children, o = r && r.length; --o >= 0; )
|
|
201
|
+
n += r[o].value;
|
|
202
202
|
t.value = n;
|
|
203
203
|
});
|
|
204
204
|
}
|
|
@@ -208,18 +208,18 @@ function _t(e) {
|
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
function Ot(e) {
|
|
211
|
-
for (var t = this, n = Dt(t, e),
|
|
212
|
-
t = t.parent,
|
|
213
|
-
for (var o =
|
|
214
|
-
|
|
215
|
-
return
|
|
211
|
+
for (var t = this, n = Dt(t, e), r = [t]; t !== n; )
|
|
212
|
+
t = t.parent, r.push(t);
|
|
213
|
+
for (var o = r.length; e !== n; )
|
|
214
|
+
r.splice(o, 0, e), e = e.parent;
|
|
215
|
+
return r;
|
|
216
216
|
}
|
|
217
217
|
function Dt(e, t) {
|
|
218
218
|
if (e === t)
|
|
219
219
|
return e;
|
|
220
|
-
var n = e.ancestors(),
|
|
221
|
-
for (e = n.pop(), t =
|
|
222
|
-
o = e, e = n.pop(), t =
|
|
220
|
+
var n = e.ancestors(), r = t.ancestors(), o = null;
|
|
221
|
+
for (e = n.pop(), t = r.pop(); e === t; )
|
|
222
|
+
o = e, e = n.pop(), t = r.pop();
|
|
223
223
|
return o;
|
|
224
224
|
}
|
|
225
225
|
function $t() {
|
|
@@ -246,9 +246,9 @@ function Ht() {
|
|
|
246
246
|
}), t;
|
|
247
247
|
}
|
|
248
248
|
function F(e, t) {
|
|
249
|
-
var n = new N(e),
|
|
249
|
+
var n = new N(e), r = +e.value && (n.value = e.value), o, a = [n], c, s, l, p;
|
|
250
250
|
for (t == null && (t = It); o = a.pop(); )
|
|
251
|
-
if (
|
|
251
|
+
if (r && (o.value = +o.data.value), (s = t(o.data)) && (p = s.length))
|
|
252
252
|
for (o.children = new Array(p), l = p - 1; l >= 0; --l)
|
|
253
253
|
a.push(c = o.children[l] = new N(s[l])), c.parent = o, c.depth = o.depth + 1;
|
|
254
254
|
return n.eachBefore(Yt);
|
|
@@ -318,7 +318,7 @@ const Vt = "d3-flextree", Kt = "2.1.2", Pt = "build/d3-flextree.js", Ut = "index
|
|
|
318
318
|
prepare: "npm-run-all clean build lint test"
|
|
319
319
|
}, ne = {
|
|
320
320
|
"d3-hierarchy": "^1.1.5"
|
|
321
|
-
},
|
|
321
|
+
}, re = {
|
|
322
322
|
"babel-plugin-external-helpers": "^6.22.0",
|
|
323
323
|
"babel-preset-es2015-rollup": "^3.0.0",
|
|
324
324
|
d3: "^4.13.0",
|
|
@@ -334,7 +334,7 @@ const Vt = "d3-flextree", Kt = "2.1.2", Pt = "build/d3-flextree.js", Ut = "index
|
|
|
334
334
|
"rollup-plugin-node-resolve": "^3.0.2",
|
|
335
335
|
"rollup-plugin-uglify": "^3.0.0",
|
|
336
336
|
"uglify-es": "^3.3.9"
|
|
337
|
-
},
|
|
337
|
+
}, ie = {
|
|
338
338
|
name: Vt,
|
|
339
339
|
version: Kt,
|
|
340
340
|
main: Pt,
|
|
@@ -348,8 +348,8 @@ const Vt = "d3-flextree", Kt = "2.1.2", Pt = "build/d3-flextree.js", Ut = "index
|
|
|
348
348
|
repository: te,
|
|
349
349
|
scripts: ee,
|
|
350
350
|
dependencies: ne,
|
|
351
|
-
devDependencies:
|
|
352
|
-
}, { version: oe } =
|
|
351
|
+
devDependencies: re
|
|
352
|
+
}, { version: oe } = ie, se = Object.freeze({
|
|
353
353
|
children: (e) => e.children,
|
|
354
354
|
nodeSize: (e) => e.data.size,
|
|
355
355
|
spacing: 0
|
|
@@ -360,7 +360,7 @@ function q(e) {
|
|
|
360
360
|
const l = t[s];
|
|
361
361
|
return typeof l == "function" ? l : () => l;
|
|
362
362
|
}
|
|
363
|
-
function
|
|
363
|
+
function r(s) {
|
|
364
364
|
const l = c(a(), s, (p) => p.children);
|
|
365
365
|
return l.update(), l.data;
|
|
366
366
|
}
|
|
@@ -488,33 +488,33 @@ function q(e) {
|
|
|
488
488
|
}
|
|
489
489
|
function c(s, l, p) {
|
|
490
490
|
const h = (u, g) => {
|
|
491
|
-
const
|
|
492
|
-
Object.assign(
|
|
491
|
+
const x = new s(u);
|
|
492
|
+
Object.assign(x, {
|
|
493
493
|
parent: g,
|
|
494
494
|
depth: g === null ? 0 : g.depth + 1,
|
|
495
495
|
height: 0,
|
|
496
496
|
length: 1
|
|
497
497
|
});
|
|
498
|
-
const
|
|
499
|
-
return
|
|
500
|
-
(
|
|
501
|
-
height: Math.max(
|
|
502
|
-
length:
|
|
498
|
+
const m = p(u) || [];
|
|
499
|
+
return x.children = m.length === 0 ? null : m.map((y) => h(y, x)), x.children && Object.assign(x, x.children.reduce(
|
|
500
|
+
(y, f) => ({
|
|
501
|
+
height: Math.max(y.height, f.height + 1),
|
|
502
|
+
length: y.length + f.length
|
|
503
503
|
}),
|
|
504
|
-
|
|
505
|
-
)),
|
|
504
|
+
x
|
|
505
|
+
)), x;
|
|
506
506
|
};
|
|
507
507
|
return h(l, null);
|
|
508
508
|
}
|
|
509
|
-
return Object.assign(
|
|
509
|
+
return Object.assign(r, {
|
|
510
510
|
nodeSize(s) {
|
|
511
|
-
return arguments.length ? (t.nodeSize = s,
|
|
511
|
+
return arguments.length ? (t.nodeSize = s, r) : t.nodeSize;
|
|
512
512
|
},
|
|
513
513
|
spacing(s) {
|
|
514
|
-
return arguments.length ? (t.spacing = s,
|
|
514
|
+
return arguments.length ? (t.spacing = s, r) : t.spacing;
|
|
515
515
|
},
|
|
516
516
|
children(s) {
|
|
517
|
-
return arguments.length ? (t.children = s,
|
|
517
|
+
return arguments.length ? (t.children = s, r) : t.children;
|
|
518
518
|
},
|
|
519
519
|
hierarchy(s, l) {
|
|
520
520
|
const p = typeof l > "u" ? t.children : l;
|
|
@@ -522,34 +522,34 @@ function q(e) {
|
|
|
522
522
|
},
|
|
523
523
|
dump(s) {
|
|
524
524
|
const l = n("nodeSize"), p = (h) => (u) => {
|
|
525
|
-
const g = h + " ",
|
|
526
|
-
return `{ size: [${
|
|
525
|
+
const g = h + " ", x = h + " ", { x: m, y } = u, f = l(u), k = u.children || [], v = k.length === 0 ? " " : `,${g}children: [${x}${k.map(p(x)).join(x)}${g}],${h}`;
|
|
526
|
+
return `{ size: [${f.join(", ")}],${g}x: ${m}, y: ${y}${v}},`;
|
|
527
527
|
};
|
|
528
528
|
return p(`
|
|
529
529
|
`)(s);
|
|
530
530
|
}
|
|
531
|
-
}),
|
|
531
|
+
}), r;
|
|
532
532
|
}
|
|
533
533
|
q.version = oe;
|
|
534
|
-
const J = (e, t = 0) => (e.y = t, (e.children || []).reduce((n,
|
|
534
|
+
const J = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, r) => {
|
|
535
535
|
const [o, a] = n;
|
|
536
|
-
J(
|
|
537
|
-
const c = (o === 0 ?
|
|
536
|
+
J(r, e.y + e.ySize);
|
|
537
|
+
const c = (o === 0 ? r.lExt : r.rExt).bottom;
|
|
538
538
|
o !== 0 && le(e, o, a);
|
|
539
539
|
const s = ge(c, o, a);
|
|
540
540
|
return [o + 1, s];
|
|
541
|
-
}, [0, null]), ae(e),
|
|
541
|
+
}, [0, null]), ae(e), fe(e), e), Q = (e, t, n) => {
|
|
542
542
|
typeof t > "u" && (t = -e.relX - e.prelim, n = 0);
|
|
543
|
-
const
|
|
544
|
-
return e.relX =
|
|
543
|
+
const r = t + e.relX;
|
|
544
|
+
return e.relX = r + e.prelim - n, e.prelim = 0, e.x = n + e.relX, (e.children || []).forEach((o) => Q(o, r, e.x)), e;
|
|
545
545
|
}, ae = (e) => {
|
|
546
546
|
(e.children || []).reduce((t, n) => {
|
|
547
|
-
const [
|
|
547
|
+
const [r, o] = t, a = r + n.shift, c = o + a + n.change;
|
|
548
548
|
return n.relX += c, [a, c];
|
|
549
549
|
}, [0, 0]);
|
|
550
550
|
}, le = (e, t, n) => {
|
|
551
|
-
const
|
|
552
|
-
let a =
|
|
551
|
+
const r = e.children[t - 1], o = e.children[t];
|
|
552
|
+
let a = r, c = r.relX, s = o, l = o.relX, p = !0;
|
|
553
553
|
for (; a && s; ) {
|
|
554
554
|
a.bottom > n.lowY && (n = n.next);
|
|
555
555
|
const h = c + a.prelim - (l + s.prelim) + a.xSize / 2 + s.xSize / 2 + a.spacing(s);
|
|
@@ -557,30 +557,30 @@ const J = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, i) => {
|
|
|
557
557
|
const u = a.bottom, g = s.bottom;
|
|
558
558
|
u <= g && (a = ue(a), a && (c += a.relX)), u >= g && (s = de(s), s && (l += s.relX));
|
|
559
559
|
}
|
|
560
|
-
!a && s ? pe(e, t, s, l) : a && !s &&
|
|
560
|
+
!a && s ? pe(e, t, s, l) : a && !s && me(e, t, a, c);
|
|
561
561
|
}, ce = (e, t) => {
|
|
562
562
|
e.relX += t, e.lExtRelX += t, e.rExtRelX += t;
|
|
563
|
-
}, he = (e, t, n,
|
|
563
|
+
}, he = (e, t, n, r) => {
|
|
564
564
|
const o = e.children[t], a = t - n;
|
|
565
565
|
if (a > 1) {
|
|
566
|
-
const c =
|
|
567
|
-
e.children[n + 1].shift += c, o.shift -= c, o.change -=
|
|
566
|
+
const c = r / a;
|
|
567
|
+
e.children[n + 1].shift += c, o.shift -= c, o.change -= r - c;
|
|
568
568
|
}
|
|
569
|
-
}, de = (e) => e.hasChildren ? e.firstChild : e.lThr, ue = (e) => e.hasChildren ? e.lastChild : e.rThr, pe = (e, t, n,
|
|
569
|
+
}, de = (e) => e.hasChildren ? e.firstChild : e.lThr, ue = (e) => e.hasChildren ? e.lastChild : e.rThr, pe = (e, t, n, r) => {
|
|
570
570
|
const o = e.firstChild, a = o.lExt, c = e.children[t];
|
|
571
571
|
a.lThr = n;
|
|
572
|
-
const s =
|
|
572
|
+
const s = r - n.relX - o.lExtRelX;
|
|
573
573
|
a.relX += s, a.prelim -= s, o.lExt = c.lExt, o.lExtRelX = c.lExtRelX;
|
|
574
|
-
},
|
|
574
|
+
}, me = (e, t, n, r) => {
|
|
575
575
|
const o = e.children[t], a = o.rExt, c = e.children[t - 1];
|
|
576
576
|
a.rThr = n;
|
|
577
|
-
const s =
|
|
577
|
+
const s = r - n.relX - o.rExtRelX;
|
|
578
578
|
a.relX += s, a.prelim -= s, o.rExt = c.rExt, o.rExtRelX = c.rExtRelX;
|
|
579
|
-
},
|
|
579
|
+
}, fe = (e) => {
|
|
580
580
|
if (e.hasChildren) {
|
|
581
|
-
const t = e.firstChild, n = e.lastChild,
|
|
581
|
+
const t = e.firstChild, n = e.lastChild, r = (t.prelim + t.relX - t.xSize / 2 + n.relX + n.prelim + n.xSize / 2) / 2;
|
|
582
582
|
Object.assign(e, {
|
|
583
|
-
prelim:
|
|
583
|
+
prelim: r,
|
|
584
584
|
lExt: t.lExt,
|
|
585
585
|
lExtRelX: t.lExtRelX,
|
|
586
586
|
rExt: n.rExt,
|
|
@@ -595,13 +595,13 @@ const J = (e, t = 0) => (e.y = t, (e.children || []).reduce((n, i) => {
|
|
|
595
595
|
index: t,
|
|
596
596
|
next: n
|
|
597
597
|
};
|
|
598
|
-
}, xe = ".markmap-container{position:absolute;width:0;height:0;top:-100px;left:-100px;overflow:hidden}.markmap-container>.markmap-foreign{display:inline-block}.markmap-container>.markmap-foreign>div:last-child,.markmap-container>.markmap-foreign>div:last-child :not(pre){white-space:nowrap}.markmap-container>.markmap-foreign>div:last-child code{white-space:inherit}", tt = ".markmap{--markmap-max-width: none;--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;font:var(--markmap-font)}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.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-testing-max{max-width:var(--markmap-max-width)}.markmap-foreign-testing-max img{max-width:var(--markmap-max-width);max-height:none}", be = tt;
|
|
598
|
+
}, xe = ".markmap-container{position:absolute;width:0;height:0;top:-100px;left:-100px;overflow:hidden}.markmap-container>.markmap-foreign{display:inline-block}.markmap-container>.markmap-foreign>div:last-child,.markmap-container>.markmap-foreign>div:last-child :not(pre){white-space:nowrap}.markmap-container>.markmap-foreign>div:last-child code{white-space:inherit}", tt = ".markmap{--markmap-max-width: none;--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-testing-max{max-width:var(--markmap-max-width)}.markmap-foreign-testing-max img{max-width:var(--markmap-max-width);max-height:none}.markmap-dark .markmap{--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", be = tt;
|
|
599
599
|
function W(e) {
|
|
600
600
|
const t = e.data;
|
|
601
601
|
return Math.max(4 - 2 * t.state.depth, 1.5);
|
|
602
602
|
}
|
|
603
603
|
function Y(e, t) {
|
|
604
|
-
const n =
|
|
604
|
+
const n = ft(e, t);
|
|
605
605
|
return e[n];
|
|
606
606
|
}
|
|
607
607
|
function D(e) {
|
|
@@ -610,20 +610,20 @@ function D(e) {
|
|
|
610
610
|
const ye = new st();
|
|
611
611
|
class et {
|
|
612
612
|
constructor(t, n) {
|
|
613
|
-
this.options = P, this.revokers = [], this.imgCache = {}, this.handleZoom = (
|
|
614
|
-
const { transform: o } =
|
|
613
|
+
this.options = P, this.revokers = [], this.imgCache = {}, this.handleZoom = (r) => {
|
|
614
|
+
const { transform: o } = r;
|
|
615
615
|
this.g.attr("transform", o);
|
|
616
|
-
}, this.handlePan = (
|
|
617
|
-
|
|
616
|
+
}, this.handlePan = (r) => {
|
|
617
|
+
r.preventDefault();
|
|
618
618
|
const o = A(this.svg.node()), a = o.translate(
|
|
619
|
-
-
|
|
620
|
-
-
|
|
619
|
+
-r.deltaX / o.k,
|
|
620
|
+
-r.deltaY / o.k
|
|
621
621
|
);
|
|
622
622
|
this.svg.call(this.zoom.transform, a);
|
|
623
|
-
}, this.handleClick = (
|
|
623
|
+
}, this.handleClick = (r, o) => {
|
|
624
624
|
let a = this.options.toggleRecursively;
|
|
625
|
-
(K ?
|
|
626
|
-
}, this.svg = t.datum ? t : dt(t), this.styleNode = this.svg.append("style"), this.zoom = ut().filter((
|
|
625
|
+
(K ? r.metaKey : r.ctrlKey) && (a = !a), this.toggleNode(o.data, a);
|
|
626
|
+
}, this.svg = t.datum ? t : dt(t), this.styleNode = this.svg.append("style"), this.zoom = ut().filter((r) => this.options.scrollForPan && r.type === "wheel" ? r.ctrlKey && !r.button : (!r.ctrlKey || r.type === "wheel") && !r.button).on("zoom", this.handleZoom), this.setOptions(n), this.state = {
|
|
627
627
|
id: this.options.id || this.svg.attr("id") || at(),
|
|
628
628
|
minX: 0,
|
|
629
629
|
maxX: 0,
|
|
@@ -636,8 +636,8 @@ class et {
|
|
|
636
636
|
);
|
|
637
637
|
}
|
|
638
638
|
getStyleContent() {
|
|
639
|
-
const { style: t } = this.options, { id: n } = this.state,
|
|
640
|
-
return [this.options.embedGlobalCSS && tt,
|
|
639
|
+
const { style: t } = this.options, { id: n } = this.state, r = typeof t == "function" ? t(n) : "";
|
|
640
|
+
return [this.options.embedGlobalCSS && tt, r].filter(Boolean).join(`
|
|
641
641
|
`);
|
|
642
642
|
}
|
|
643
643
|
updateStyle() {
|
|
@@ -650,11 +650,11 @@ class et {
|
|
|
650
650
|
}
|
|
651
651
|
toggleNode(t, n = !1) {
|
|
652
652
|
var o, a;
|
|
653
|
-
const
|
|
653
|
+
const r = (o = t.payload) != null && o.fold ? 0 : 1;
|
|
654
654
|
n ? T(t, (c, s) => {
|
|
655
655
|
c.payload = {
|
|
656
656
|
...c.payload,
|
|
657
|
-
fold:
|
|
657
|
+
fold: r
|
|
658
658
|
}, s();
|
|
659
659
|
}) : t.payload = {
|
|
660
660
|
...t.payload,
|
|
@@ -663,7 +663,7 @@ class et {
|
|
|
663
663
|
}
|
|
664
664
|
initializeData(t) {
|
|
665
665
|
let n = 0;
|
|
666
|
-
const { color:
|
|
666
|
+
const { color: r, nodeMinHeight: o, maxWidth: a, initialExpandLevel: c } = this.options, { id: s } = this.state, l = O(
|
|
667
667
|
/* @__PURE__ */ j("div", { className: `markmap-container markmap ${s}-g` })
|
|
668
668
|
), p = O(
|
|
669
669
|
/* @__PURE__ */ j("style", { children: [this.getStyleContent(), xe].join(`
|
|
@@ -672,50 +672,50 @@ class et {
|
|
|
672
672
|
document.body.append(l, p);
|
|
673
673
|
const h = a ? `--markmap-max-width: ${a}px` : "";
|
|
674
674
|
let u = 0, g = 0;
|
|
675
|
-
T(t, (
|
|
675
|
+
T(t, (m, y, f) => {
|
|
676
676
|
var b, w, z;
|
|
677
|
-
g += 1,
|
|
678
|
-
const
|
|
677
|
+
g += 1, m.children = (b = m.children) == null ? void 0 : b.map((E) => ({ ...E })), n += 1;
|
|
678
|
+
const k = O(
|
|
679
679
|
/* @__PURE__ */ j(
|
|
680
680
|
"div",
|
|
681
681
|
{
|
|
682
682
|
className: "markmap-foreign markmap-foreign-testing-max",
|
|
683
683
|
style: h,
|
|
684
|
-
children: /* @__PURE__ */ j("div", { dangerouslySetInnerHTML: { __html:
|
|
684
|
+
children: /* @__PURE__ */ j("div", { dangerouslySetInnerHTML: { __html: m.content } })
|
|
685
685
|
}
|
|
686
686
|
)
|
|
687
687
|
);
|
|
688
|
-
l.append(
|
|
689
|
-
...
|
|
688
|
+
l.append(k), m.state = {
|
|
689
|
+
...m.state,
|
|
690
690
|
depth: g,
|
|
691
691
|
id: n,
|
|
692
|
-
el:
|
|
693
|
-
},
|
|
694
|
-
const v = ((z =
|
|
695
|
-
v ? u += 1 : (u || c >= 0 &&
|
|
692
|
+
el: k.firstChild
|
|
693
|
+
}, m.state.path = [(w = f == null ? void 0 : f.state) == null ? void 0 : w.path, m.state.id].filter(Boolean).join("."), r(m);
|
|
694
|
+
const v = ((z = m.payload) == null ? void 0 : z.fold) === 2;
|
|
695
|
+
v ? u += 1 : (u || c >= 0 && m.state.depth >= c) && (m.payload = { ...m.payload, fold: 1 }), y(), v && (u -= 1), g -= 1;
|
|
696
696
|
});
|
|
697
|
-
const
|
|
698
|
-
(
|
|
697
|
+
const x = Array.from(l.childNodes).map(
|
|
698
|
+
(m) => m.firstChild
|
|
699
699
|
);
|
|
700
|
-
this._checkImages(l),
|
|
701
|
-
var
|
|
702
|
-
(
|
|
703
|
-
}), T(t, (
|
|
700
|
+
this._checkImages(l), x.forEach((m) => {
|
|
701
|
+
var y;
|
|
702
|
+
(y = m.parentNode) == null || y.append(m.cloneNode(!0));
|
|
703
|
+
}), T(t, (m, y, f) => {
|
|
704
704
|
var b;
|
|
705
|
-
const
|
|
706
|
-
|
|
705
|
+
const k = m.state, v = k.el.getBoundingClientRect();
|
|
706
|
+
m.content = k.el.innerHTML, k.size = [
|
|
707
707
|
Math.ceil(v.width) + 1,
|
|
708
708
|
Math.max(Math.ceil(v.height), o)
|
|
709
|
-
],
|
|
710
|
-
|
|
709
|
+
], k.key = [(b = f == null ? void 0 : f.state) == null ? void 0 : b.id, k.id].filter(Boolean).join(".") + // FIXME: find a way to check content hash
|
|
710
|
+
m.content, y();
|
|
711
711
|
}), l.remove(), p.remove();
|
|
712
712
|
}
|
|
713
713
|
_checkImages(t) {
|
|
714
714
|
t.querySelectorAll("img").forEach((n) => {
|
|
715
715
|
if (n.width)
|
|
716
716
|
return;
|
|
717
|
-
const
|
|
718
|
-
|
|
717
|
+
const r = this.imgCache[n.src];
|
|
718
|
+
r != null && r[0] ? [n.width, n.height] = r : r || this._loadImage(n.src);
|
|
719
719
|
});
|
|
720
720
|
}
|
|
721
721
|
_loadImage(t) {
|
|
@@ -737,115 +737,115 @@ class et {
|
|
|
737
737
|
renderData(t) {
|
|
738
738
|
if (!this.state.data)
|
|
739
739
|
return;
|
|
740
|
-
const { spacingHorizontal: n, paddingX:
|
|
740
|
+
const { spacingHorizontal: n, paddingX: r, spacingVertical: o, autoFit: a, color: c } = this.options, s = q({}).children((i) => {
|
|
741
741
|
var d;
|
|
742
|
-
if (!((d =
|
|
743
|
-
return
|
|
744
|
-
}).nodeSize((
|
|
745
|
-
const [d, S] =
|
|
746
|
-
return [S, d + (d ?
|
|
747
|
-
}).spacing((
|
|
742
|
+
if (!((d = i.payload) != null && d.fold))
|
|
743
|
+
return i.children;
|
|
744
|
+
}).nodeSize((i) => {
|
|
745
|
+
const [d, S] = i.data.state.size;
|
|
746
|
+
return [S, d + (d ? r * 2 : 0) + n];
|
|
747
|
+
}).spacing((i, d) => i.parent === d.parent ? o : o * 2), l = s.hierarchy(this.state.data);
|
|
748
748
|
s(l);
|
|
749
|
-
const p = l.descendants().reverse(), h = l.links(), u = pt(), g = H(p, (
|
|
749
|
+
const p = l.descendants().reverse(), h = l.links(), u = pt(), g = H(p, (i) => i.x - i.xSize / 2), x = L(p, (i) => i.x + i.xSize / 2), m = H(p, (i) => i.y), y = L(p, (i) => i.y + i.ySize - n);
|
|
750
750
|
Object.assign(this.state, {
|
|
751
751
|
minX: g,
|
|
752
|
-
maxX:
|
|
753
|
-
minY:
|
|
754
|
-
maxY:
|
|
752
|
+
maxX: x,
|
|
753
|
+
minY: m,
|
|
754
|
+
maxY: y
|
|
755
755
|
}), a && this.fit();
|
|
756
|
-
const
|
|
757
|
-
|
|
758
|
-
).data(p, (
|
|
756
|
+
const f = t && p.find((i) => i.data === t) || l, k = f.data.state.x0 ?? f.x, v = f.data.state.y0 ?? f.y, b = this.g.selectAll(
|
|
757
|
+
C("g")
|
|
758
|
+
).data(p, (i) => i.data.state.key), w = b.enter().append("g").attr("data-depth", (i) => i.data.state.depth).attr("data-path", (i) => i.data.state.path).attr(
|
|
759
759
|
"transform",
|
|
760
|
-
(
|
|
760
|
+
(i) => `translate(${v + f.ySize - i.ySize},${k + f.xSize / 2 - i.xSize})`
|
|
761
761
|
), z = this.transition(b.exit());
|
|
762
|
-
z.select("line").attr("x1", (
|
|
762
|
+
z.select("line").attr("x1", (i) => i.ySize - n).attr("x2", (i) => i.ySize - n), z.select("foreignObject").style("opacity", 0), z.attr(
|
|
763
763
|
"transform",
|
|
764
|
-
(
|
|
764
|
+
(i) => `translate(${f.y + f.ySize - i.ySize},${f.x + f.xSize / 2 - i.xSize})`
|
|
765
765
|
).remove();
|
|
766
|
-
const
|
|
766
|
+
const E = b.merge(w).attr(
|
|
767
767
|
"class",
|
|
768
|
-
(
|
|
768
|
+
(i) => {
|
|
769
769
|
var d;
|
|
770
|
-
return ["markmap-node", ((d =
|
|
770
|
+
return ["markmap-node", ((d = i.data.payload) == null ? void 0 : d.fold) && "markmap-fold"].filter(Boolean).join(" ");
|
|
771
771
|
}
|
|
772
772
|
);
|
|
773
|
-
this.transition(
|
|
773
|
+
this.transition(E).attr(
|
|
774
774
|
"transform",
|
|
775
|
-
(
|
|
775
|
+
(i) => `translate(${i.y},${i.x - i.xSize / 2})`
|
|
776
776
|
);
|
|
777
|
-
const nt =
|
|
778
|
-
|
|
777
|
+
const nt = E.selectAll(
|
|
778
|
+
C("line")
|
|
779
779
|
).data(
|
|
780
|
-
(
|
|
781
|
-
(
|
|
780
|
+
(i) => [i],
|
|
781
|
+
(i) => i.data.state.key
|
|
782
782
|
).join(
|
|
783
|
-
(
|
|
784
|
-
(
|
|
785
|
-
(
|
|
783
|
+
(i) => i.append("line").attr("x1", (d) => d.ySize - n).attr("x2", (d) => d.ySize - n),
|
|
784
|
+
(i) => i,
|
|
785
|
+
(i) => i.remove()
|
|
786
786
|
);
|
|
787
|
-
this.transition(nt).attr("x1", -1).attr("x2", (
|
|
788
|
-
const
|
|
789
|
-
|
|
787
|
+
this.transition(nt).attr("x1", -1).attr("x2", (i) => i.ySize - n + 2).attr("y1", (i) => i.xSize).attr("y2", (i) => i.xSize).attr("stroke", (i) => c(i.data)).attr("stroke-width", W);
|
|
788
|
+
const rt = E.selectAll(
|
|
789
|
+
C("circle")
|
|
790
790
|
).data(
|
|
791
|
-
(
|
|
791
|
+
(i) => {
|
|
792
792
|
var d;
|
|
793
|
-
return (d =
|
|
793
|
+
return (d = i.data.children) != null && d.length ? [i] : [];
|
|
794
794
|
},
|
|
795
|
-
(
|
|
795
|
+
(i) => i.data.state.key
|
|
796
796
|
).join(
|
|
797
|
-
(
|
|
798
|
-
(
|
|
799
|
-
(
|
|
797
|
+
(i) => i.append("circle").attr("stroke-width", "1.5").attr("cx", (d) => d.ySize - n).attr("cy", (d) => d.xSize).attr("r", 0).on("click", (d, S) => this.handleClick(d, S)).on("mousedown", D),
|
|
798
|
+
(i) => i,
|
|
799
|
+
(i) => i.remove()
|
|
800
800
|
);
|
|
801
|
-
this.transition(
|
|
801
|
+
this.transition(rt).attr("r", 6).attr("cx", (i) => i.ySize - n).attr("cy", (i) => i.xSize).attr("stroke", (i) => c(i.data)).attr(
|
|
802
802
|
"fill",
|
|
803
|
-
(
|
|
803
|
+
(i) => {
|
|
804
804
|
var d;
|
|
805
|
-
return (d =
|
|
805
|
+
return (d = i.data.payload) != null && d.fold && i.data.children ? c(i.data) : "var(--markmap-circle-open-bg)";
|
|
806
806
|
}
|
|
807
807
|
);
|
|
808
|
-
const
|
|
809
|
-
|
|
808
|
+
const it = E.selectAll(
|
|
809
|
+
C("foreignObject")
|
|
810
810
|
).data(
|
|
811
|
-
(
|
|
812
|
-
(
|
|
811
|
+
(i) => [i],
|
|
812
|
+
(i) => i.data.state.key
|
|
813
813
|
).join(
|
|
814
|
-
(
|
|
815
|
-
const d =
|
|
814
|
+
(i) => {
|
|
815
|
+
const d = i.append("foreignObject").attr("class", "markmap-foreign").attr("x", r).attr("y", 0).style("opacity", 0).on("mousedown", D).on("dblclick", D);
|
|
816
816
|
return d.append("xhtml:div").select(function(R) {
|
|
817
817
|
const X = R.data.state.el.cloneNode(!0);
|
|
818
818
|
return this.replaceWith(X), X;
|
|
819
819
|
}).attr("xmlns", "http://www.w3.org/1999/xhtml"), d;
|
|
820
820
|
},
|
|
821
|
-
(
|
|
822
|
-
(
|
|
821
|
+
(i) => i,
|
|
822
|
+
(i) => i.remove()
|
|
823
823
|
).attr(
|
|
824
824
|
"width",
|
|
825
|
-
(
|
|
826
|
-
).attr("height", (
|
|
827
|
-
this.transition(
|
|
825
|
+
(i) => Math.max(0, i.ySize - n - r * 2)
|
|
826
|
+
).attr("height", (i) => i.xSize);
|
|
827
|
+
this.transition(it).style("opacity", 1);
|
|
828
828
|
const ot = this.g.selectAll(
|
|
829
|
-
|
|
830
|
-
).data(h, (
|
|
831
|
-
(
|
|
829
|
+
C("path")
|
|
830
|
+
).data(h, (i) => i.target.data.state.key).join(
|
|
831
|
+
(i) => {
|
|
832
832
|
const d = [
|
|
833
|
-
v +
|
|
834
|
-
|
|
833
|
+
v + f.ySize - n,
|
|
834
|
+
k + f.xSize / 2
|
|
835
835
|
];
|
|
836
|
-
return
|
|
836
|
+
return i.insert("path", "g").attr("class", "markmap-link").attr("data-depth", (S) => S.target.data.state.depth).attr("data-path", (S) => S.target.data.state.path).attr("d", u({ source: d, target: d }));
|
|
837
837
|
},
|
|
838
|
-
(
|
|
839
|
-
(
|
|
838
|
+
(i) => i,
|
|
839
|
+
(i) => {
|
|
840
840
|
const d = [
|
|
841
|
-
|
|
842
|
-
|
|
841
|
+
f.y + f.ySize - n,
|
|
842
|
+
f.x + f.xSize / 2
|
|
843
843
|
];
|
|
844
|
-
return this.transition(
|
|
844
|
+
return this.transition(i).attr("d", u({ source: d, target: d })).remove();
|
|
845
845
|
}
|
|
846
846
|
);
|
|
847
|
-
this.transition(ot).attr("stroke", (
|
|
848
|
-
const d =
|
|
847
|
+
this.transition(ot).attr("stroke", (i) => c(i.target.data)).attr("stroke-width", (i) => W(i.target)).attr("d", (i) => {
|
|
848
|
+
const d = i.source, S = i.target, R = [
|
|
849
849
|
d.y + d.ySize - n,
|
|
850
850
|
d.x + d.xSize / 2
|
|
851
851
|
], X = [
|
|
@@ -853,8 +853,8 @@ class et {
|
|
|
853
853
|
S.x + S.xSize / 2
|
|
854
854
|
];
|
|
855
855
|
return u({ source: R, target: X });
|
|
856
|
-
}), p.forEach((
|
|
857
|
-
|
|
856
|
+
}), p.forEach((i) => {
|
|
857
|
+
i.data.state.x0 = i.x, i.data.state.y0 = i.y;
|
|
858
858
|
});
|
|
859
859
|
}
|
|
860
860
|
transition(t) {
|
|
@@ -865,50 +865,58 @@ class et {
|
|
|
865
865
|
* Fit the content to the viewport.
|
|
866
866
|
*/
|
|
867
867
|
async fit() {
|
|
868
|
-
const t = this.svg.node(), { width: n, height:
|
|
868
|
+
const t = this.svg.node(), { width: n, height: r } = t.getBoundingClientRect(), { fitRatio: o } = this.options, { minX: a, maxX: c, minY: s, maxY: l } = this.state, p = l - s, h = c - a, u = Math.min(
|
|
869
869
|
n / p * o,
|
|
870
|
-
|
|
870
|
+
r / h * o,
|
|
871
871
|
2
|
|
872
|
-
), g =
|
|
872
|
+
), g = mt.translate(
|
|
873
873
|
(n - p * u) / 2 - s * u,
|
|
874
|
-
(
|
|
874
|
+
(r - h * u) / 2 - a * u
|
|
875
875
|
).scale(u);
|
|
876
876
|
return this.transition(this.svg).call(this.zoom.transform, g).end().catch(M);
|
|
877
877
|
}
|
|
878
|
+
findElement(t) {
|
|
879
|
+
let n;
|
|
880
|
+
return this.g.selectAll(
|
|
881
|
+
C("g")
|
|
882
|
+
).each(function(o) {
|
|
883
|
+
o.data === t && (n = {
|
|
884
|
+
data: o,
|
|
885
|
+
g: this
|
|
886
|
+
});
|
|
887
|
+
}), n;
|
|
888
|
+
}
|
|
878
889
|
/**
|
|
879
890
|
* Pan the content to make the provided node visible in the viewport.
|
|
880
891
|
*/
|
|
881
892
|
async ensureView(t, n) {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
).each(function(v) {
|
|
886
|
-
v.data === t && (i = v);
|
|
887
|
-
}), !i)
|
|
893
|
+
var k;
|
|
894
|
+
const r = (k = this.findElement(t)) == null ? void 0 : k.data;
|
|
895
|
+
if (!r)
|
|
888
896
|
return;
|
|
889
897
|
const o = this.svg.node(), { spacingHorizontal: a } = this.options, c = o.getBoundingClientRect(), s = A(o), [l, p] = [
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
].map((
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
].map((
|
|
898
|
+
r.y,
|
|
899
|
+
r.y + r.ySize - a + 2
|
|
900
|
+
].map((v) => v * s.k + s.x), [h, u] = [
|
|
901
|
+
r.x - r.xSize / 2,
|
|
902
|
+
r.x + r.xSize / 2
|
|
903
|
+
].map((v) => v * s.k + s.y), g = {
|
|
896
904
|
left: 0,
|
|
897
905
|
right: 0,
|
|
898
906
|
top: 0,
|
|
899
907
|
bottom: 0,
|
|
900
908
|
...n
|
|
901
|
-
},
|
|
902
|
-
if (
|
|
903
|
-
const
|
|
904
|
-
return this.transition(this.svg).call(this.zoom.transform,
|
|
909
|
+
}, x = [g.left - l, c.width - g.right - p], m = [g.top - h, c.height - g.bottom - u], y = x[0] * x[1] > 0 ? Y(x, Math.abs) / s.k : 0, f = m[0] * m[1] > 0 ? Y(m, Math.abs) / s.k : 0;
|
|
910
|
+
if (y || f) {
|
|
911
|
+
const v = s.translate(y, f);
|
|
912
|
+
return this.transition(this.svg).call(this.zoom.transform, v).end().catch(M);
|
|
905
913
|
}
|
|
906
914
|
}
|
|
907
915
|
/**
|
|
908
916
|
* Scale content with it pinned at the center of the viewport.
|
|
909
917
|
*/
|
|
910
918
|
async rescale(t) {
|
|
911
|
-
const n = this.svg.node(), { width:
|
|
919
|
+
const n = this.svg.node(), { width: r, height: o } = n.getBoundingClientRect(), a = r / 2, c = o / 2, s = A(n), l = s.translate(
|
|
912
920
|
(a - s.x) * (1 - t) / s.k,
|
|
913
921
|
(c - s.y) * (1 - t) / s.k
|
|
914
922
|
).scale(t);
|
|
@@ -919,9 +927,9 @@ class et {
|
|
|
919
927
|
t();
|
|
920
928
|
});
|
|
921
929
|
}
|
|
922
|
-
static create(t, n,
|
|
930
|
+
static create(t, n, r = null) {
|
|
923
931
|
const o = new et(t, n);
|
|
924
|
-
return
|
|
932
|
+
return r && (o.setData(r), o.fit()), o;
|
|
925
933
|
}
|
|
926
934
|
}
|
|
927
935
|
export {
|
|
@@ -931,7 +939,7 @@ export {
|
|
|
931
939
|
Se as deriveOptions,
|
|
932
940
|
be as globalCSS,
|
|
933
941
|
K as isMacintosh,
|
|
934
|
-
|
|
942
|
+
Ce as loadCSS,
|
|
935
943
|
we as loadJS,
|
|
936
944
|
ye as refreshHook
|
|
937
945
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { INode } from 'markmap-common';
|
|
2
|
+
import { FlextreeNode } from 'd3-flextree';
|
|
2
3
|
export interface IMarkmapState {
|
|
3
4
|
id: string;
|
|
4
5
|
data?: INode;
|
|
@@ -18,3 +19,10 @@ export interface IMarkmapJSONOptions {
|
|
|
18
19
|
zoom?: boolean;
|
|
19
20
|
pan?: boolean;
|
|
20
21
|
}
|
|
22
|
+
export interface IPadding {
|
|
23
|
+
left: number;
|
|
24
|
+
right: number;
|
|
25
|
+
top: number;
|
|
26
|
+
bottom: number;
|
|
27
|
+
}
|
|
28
|
+
export type ID3SVGElement = d3.Selection<SVGElement, FlextreeNode<INode>, HTMLElement, FlextreeNode<INode>>;
|
package/dist/view.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import type * as d3 from 'd3';
|
|
2
2
|
import { FlextreeNode } from 'd3-flextree';
|
|
3
3
|
import { Hook, IMarkmapOptions, INode, IPureNode } from 'markmap-common';
|
|
4
|
-
import { IMarkmapState } from './types';
|
|
4
|
+
import { ID3SVGElement, IMarkmapState, IPadding } from './types';
|
|
5
5
|
export declare const globalCSS: string;
|
|
6
|
-
interface IPadding {
|
|
7
|
-
left: number;
|
|
8
|
-
right: number;
|
|
9
|
-
top: number;
|
|
10
|
-
bottom: number;
|
|
11
|
-
}
|
|
12
|
-
type ID3SVGElement = d3.Selection<SVGElement, FlextreeNode<INode>, HTMLElement, FlextreeNode<INode>>;
|
|
13
6
|
/**
|
|
14
7
|
* A global hook to refresh all markmaps when called.
|
|
15
8
|
*/
|
|
@@ -42,6 +35,10 @@ export declare class Markmap {
|
|
|
42
35
|
* Fit the content to the viewport.
|
|
43
36
|
*/
|
|
44
37
|
fit(): Promise<void>;
|
|
38
|
+
findElement(node: INode): {
|
|
39
|
+
data: FlextreeNode<INode>;
|
|
40
|
+
g: SVGGElement;
|
|
41
|
+
} | undefined;
|
|
45
42
|
/**
|
|
46
43
|
* Pan the content to make the provided node visible in the viewport.
|
|
47
44
|
*/
|
|
@@ -53,4 +50,3 @@ export declare class Markmap {
|
|
|
53
50
|
destroy(): void;
|
|
54
51
|
static create(svg: string | SVGElement | ID3SVGElement, opts?: Partial<IMarkmapOptions>, data?: IPureNode | null): Markmap;
|
|
55
52
|
}
|
|
56
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-view",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.3-alpha.2+0f4c3f8",
|
|
4
4
|
"description": "View markmaps in browser",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"scripts": {
|
|
22
22
|
"clean": "del-cli dist",
|
|
23
23
|
"build:types": "tsc",
|
|
24
|
-
"build:js": "vite build && TARGET=es vite build
|
|
24
|
+
"build:js": "vite build && TARGET=es vite build",
|
|
25
|
+
"build": "run-s clean build:*"
|
|
25
26
|
},
|
|
26
27
|
"bugs": {
|
|
27
28
|
"url": "https://github.com/markmap/markmap/issues"
|
|
@@ -44,10 +45,10 @@
|
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/d3-flextree": "^2.1.1",
|
|
47
|
-
"markmap-common": "0.
|
|
48
|
+
"markmap-common": "0.16.0"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
51
|
"markmap-common": "*"
|
|
51
52
|
},
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "0f4c3f84ff21f0957ec3dbf338ed7a453f050638"
|
|
53
54
|
}
|