markmap-view 0.18.8-alpha.2 → 0.18.8
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 +17 -17
- package/dist/constants.d.ts +1 -1
- package/dist/index.js +126 -126
- package/dist/types.d.ts +1 -1
- package/dist/view.d.ts +1 -1
- package/package.json +3 -3
package/dist/browser/index.js
CHANGED
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
}
|
|
328
328
|
const isMacintosh = typeof navigator !== "undefined" && navigator.userAgent.includes("Macintosh");
|
|
329
329
|
const defaultColorFn = d32.scaleOrdinal(d32.schemeCategory10);
|
|
330
|
-
const
|
|
330
|
+
const lineWidthFactory = (baseWidth = 1, deltaWidth = 3, k = 2) => (node) => baseWidth + deltaWidth / k ** node.state.depth;
|
|
331
331
|
const defaultOptions = {
|
|
332
332
|
autoFit: false,
|
|
333
333
|
duration: 500,
|
|
@@ -343,7 +343,7 @@
|
|
|
343
343
|
var _a;
|
|
344
344
|
return defaultColorFn(`${((_a = node.state) == null ? void 0 : _a.path) || ""}`);
|
|
345
345
|
},
|
|
346
|
-
|
|
346
|
+
lineWidth: lineWidthFactory(),
|
|
347
347
|
maxWidth: 0,
|
|
348
348
|
nodeMinHeight: 16,
|
|
349
349
|
paddingX: 8,
|
|
@@ -353,7 +353,7 @@
|
|
|
353
353
|
function deriveOptions(jsonOptions) {
|
|
354
354
|
const derivedOptions = {};
|
|
355
355
|
const options = { ...jsonOptions };
|
|
356
|
-
const { color, colorFreezeLevel,
|
|
356
|
+
const { color, colorFreezeLevel, lineWidth } = options;
|
|
357
357
|
if ((color == null ? void 0 : color.length) === 1) {
|
|
358
358
|
const solidColor = color[0];
|
|
359
359
|
derivedOptions.color = () => solidColor;
|
|
@@ -374,9 +374,9 @@
|
|
|
374
374
|
return color2(node);
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
|
-
if (
|
|
378
|
-
const args = Array.isArray(
|
|
379
|
-
derivedOptions.
|
|
377
|
+
if (lineWidth) {
|
|
378
|
+
const args = Array.isArray(lineWidth) ? lineWidth : [lineWidth, 0, 1];
|
|
379
|
+
derivedOptions.lineWidth = lineWidthFactory(
|
|
380
380
|
...args
|
|
381
381
|
);
|
|
382
382
|
}
|
|
@@ -1094,7 +1094,7 @@
|
|
|
1094
1094
|
const newSize = [el.scrollWidth, el.scrollHeight];
|
|
1095
1095
|
d.state.size = newSize;
|
|
1096
1096
|
});
|
|
1097
|
-
const {
|
|
1097
|
+
const { lineWidth, paddingX, spacingHorizontal, spacingVertical } = this.options;
|
|
1098
1098
|
const layout = flextree({}).children((d) => {
|
|
1099
1099
|
var _a;
|
|
1100
1100
|
if (!((_a = d.payload) == null ? void 0 : _a.fold)) return d.children;
|
|
@@ -1102,7 +1102,7 @@
|
|
|
1102
1102
|
const [width, height] = node.data.state.size;
|
|
1103
1103
|
return [height, width + (width ? paddingX * 2 : 0) + spacingHorizontal];
|
|
1104
1104
|
}).spacing((a, b) => {
|
|
1105
|
-
return a.parent === b.parent ? spacingVertical : spacingVertical * 2;
|
|
1105
|
+
return (a.parent === b.parent ? spacingVertical : spacingVertical * 2) + lineWidth(a.data);
|
|
1106
1106
|
});
|
|
1107
1107
|
const tree = layout.hierarchy(this.state.data);
|
|
1108
1108
|
layout(tree);
|
|
@@ -1170,7 +1170,7 @@
|
|
|
1170
1170
|
return rect;
|
|
1171
1171
|
}
|
|
1172
1172
|
async renderData(originData) {
|
|
1173
|
-
const { paddingX, autoFit, color, maxWidth,
|
|
1173
|
+
const { paddingX, autoFit, color, maxWidth, lineWidth } = this.options;
|
|
1174
1174
|
const rootNode = this.state.data;
|
|
1175
1175
|
if (!rootNode) return;
|
|
1176
1176
|
const nodeMap = {};
|
|
@@ -1303,13 +1303,13 @@
|
|
|
1303
1303
|
);
|
|
1304
1304
|
this.transition(mmLineExit).attr("x1", (d) => d.state.rect.width).attr("stroke-width", 0);
|
|
1305
1305
|
mmLineEnter.attr("x1", (d) => d.state.rect.width).attr("x2", (d) => d.state.rect.width);
|
|
1306
|
-
mmLineMerge.attr("y1", (d) => d.state.rect.height).attr("y2", (d) => d.state.rect.height);
|
|
1307
|
-
this.transition(mmLineMerge).attr("x1", -1).attr("x2", (d) => d.state.rect.width + 2).attr("stroke", (d) => color(d)).attr("stroke-width",
|
|
1306
|
+
mmLineMerge.attr("y1", (d) => d.state.rect.height + lineWidth(d) / 2).attr("y2", (d) => d.state.rect.height + lineWidth(d) / 2);
|
|
1307
|
+
this.transition(mmLineMerge).attr("x1", -1).attr("x2", (d) => d.state.rect.width + 2).attr("stroke", (d) => color(d)).attr("stroke-width", lineWidth);
|
|
1308
1308
|
const mmCircleExit = mmGExit.selectAll(
|
|
1309
1309
|
childSelector("circle")
|
|
1310
1310
|
);
|
|
1311
1311
|
this.transition(mmCircleExit).attr("r", 0).attr("stroke-width", 0);
|
|
1312
|
-
mmCircleMerge.attr("cx", (d) => d.state.rect.width).attr("cy", (d) => d.state.rect.height);
|
|
1312
|
+
mmCircleMerge.attr("cx", (d) => d.state.rect.width).attr("cy", (d) => d.state.rect.height + lineWidth(d) / 2);
|
|
1313
1313
|
this.transition(mmCircleMerge).attr("r", 6).attr("stroke-width", "1.5");
|
|
1314
1314
|
this.transition(mmFoExit).style("opacity", 0);
|
|
1315
1315
|
mmFoMerge.attr("width", (d) => Math.max(0, d.state.rect.width - paddingX * 2)).attr("height", (d) => d.state.rect.height);
|
|
@@ -1318,20 +1318,20 @@
|
|
|
1318
1318
|
const targetRect = getOriginTargetRect(d.target);
|
|
1319
1319
|
const pathTarget = [
|
|
1320
1320
|
targetRect.x + targetRect.width,
|
|
1321
|
-
targetRect.y + targetRect.height
|
|
1321
|
+
targetRect.y + targetRect.height + lineWidth(d.target) / 2
|
|
1322
1322
|
];
|
|
1323
1323
|
return linkShape({ source: pathTarget, target: pathTarget });
|
|
1324
1324
|
}).attr("stroke-width", 0).remove();
|
|
1325
|
-
this.transition(mmPathMerge).attr("stroke", (d) => color(d.target)).attr("stroke-width", (d) =>
|
|
1325
|
+
this.transition(mmPathMerge).attr("stroke", (d) => color(d.target)).attr("stroke-width", (d) => lineWidth(d.target)).attr("d", (d) => {
|
|
1326
1326
|
const origSource = d.source;
|
|
1327
1327
|
const origTarget = d.target;
|
|
1328
1328
|
const source = [
|
|
1329
1329
|
origSource.state.rect.x + origSource.state.rect.width,
|
|
1330
|
-
origSource.state.rect.y + origSource.state.rect.height
|
|
1330
|
+
origSource.state.rect.y + origSource.state.rect.height + lineWidth(origSource) / 2
|
|
1331
1331
|
];
|
|
1332
1332
|
const target = [
|
|
1333
1333
|
origTarget.state.rect.x,
|
|
1334
|
-
origTarget.state.rect.y + origTarget.state.rect.height
|
|
1334
|
+
origTarget.state.rect.y + origTarget.state.rect.height + lineWidth(origTarget) / 2
|
|
1335
1335
|
];
|
|
1336
1336
|
return linkShape({ source, target });
|
|
1337
1337
|
});
|
|
@@ -1472,7 +1472,7 @@
|
|
|
1472
1472
|
exports.deriveOptions = deriveOptions;
|
|
1473
1473
|
exports.globalCSS = globalCSS;
|
|
1474
1474
|
exports.isMacintosh = isMacintosh;
|
|
1475
|
-
exports.
|
|
1475
|
+
exports.lineWidthFactory = lineWidthFactory;
|
|
1476
1476
|
exports.loadCSS = loadCSS;
|
|
1477
1477
|
exports.loadJS = loadJS;
|
|
1478
1478
|
exports.refreshHook = refreshHook;
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IMarkmapOptions, INode } from 'markmap-common';
|
|
2
2
|
export declare const isMacintosh: boolean;
|
|
3
3
|
export declare const defaultColorFn: import("d3").ScaleOrdinal<string, string, never>;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const lineWidthFactory: (baseWidth?: number, deltaWidth?: number, k?: number) => (node: INode) => number;
|
|
5
5
|
export declare const defaultOptions: IMarkmapOptions;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hook as dt, getId as pt, debounce as gt, addClass as ut, walkTree as R, noop as X } from "markmap-common";
|
|
2
2
|
import { loadCSS as ze, loadJS as we } from "markmap-common";
|
|
3
3
|
import { scaleOrdinal as Y, schemeCategory10 as mt, linkHorizontal as ft, zoomTransform as w, select as xt, zoom as yt, min as G, max as V, zoomIdentity as kt, minIndex as vt } from "d3";
|
|
4
|
-
const Z = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), bt = Y(mt), q = (e =
|
|
4
|
+
const Z = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), bt = Y(mt), q = (e = 1, t = 3, i = 2) => (n) => e + t / i ** n.state.depth, J = {
|
|
5
5
|
autoFit: !1,
|
|
6
6
|
duration: 500,
|
|
7
7
|
embedGlobalCSS: !0,
|
|
@@ -16,7 +16,7 @@ const Z = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), b
|
|
|
16
16
|
var t;
|
|
17
17
|
return bt(`${((t = e.state) == null ? void 0 : t.path) || ""}`);
|
|
18
18
|
},
|
|
19
|
-
|
|
19
|
+
lineWidth: q(),
|
|
20
20
|
maxWidth: 0,
|
|
21
21
|
nodeMinHeight: 16,
|
|
22
22
|
paddingX: 8,
|
|
@@ -24,28 +24,28 @@ const Z = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), b
|
|
|
24
24
|
spacingVertical: 5
|
|
25
25
|
};
|
|
26
26
|
function ke(e) {
|
|
27
|
-
const t = {}, i = { ...e }, { color: n, colorFreezeLevel: s,
|
|
27
|
+
const t = {}, i = { ...e }, { color: n, colorFreezeLevel: s, lineWidth: a } = i;
|
|
28
28
|
if ((n == null ? void 0 : n.length) === 1) {
|
|
29
|
-
const
|
|
30
|
-
t.color = () =>
|
|
29
|
+
const l = n[0];
|
|
30
|
+
t.color = () => l;
|
|
31
31
|
} else if (n != null && n.length) {
|
|
32
|
-
const
|
|
33
|
-
t.color = (h) =>
|
|
32
|
+
const l = Y(n);
|
|
33
|
+
t.color = (h) => l(`${h.state.path}`);
|
|
34
34
|
}
|
|
35
35
|
if (s) {
|
|
36
|
-
const
|
|
36
|
+
const l = t.color || J.color;
|
|
37
37
|
t.color = (h) => (h = {
|
|
38
38
|
...h,
|
|
39
39
|
state: {
|
|
40
40
|
...h.state,
|
|
41
41
|
path: h.state.path.split(".").slice(0, s).join(".")
|
|
42
42
|
}
|
|
43
|
-
},
|
|
43
|
+
}, l(h));
|
|
44
44
|
}
|
|
45
45
|
if (a) {
|
|
46
|
-
const
|
|
47
|
-
t.
|
|
48
|
-
...
|
|
46
|
+
const l = Array.isArray(a) ? a : [a, 0, 1];
|
|
47
|
+
t.lineWidth = q(
|
|
48
|
+
...l
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
return [
|
|
@@ -58,12 +58,12 @@ function ke(e) {
|
|
|
58
58
|
"paddingX",
|
|
59
59
|
"spacingHorizontal",
|
|
60
60
|
"spacingVertical"
|
|
61
|
-
].forEach((
|
|
62
|
-
const h = i[
|
|
63
|
-
typeof h == "number" && (t[
|
|
64
|
-
}), ["zoom", "pan"].forEach((
|
|
65
|
-
const h = i[
|
|
66
|
-
h != null && (t[
|
|
61
|
+
].forEach((l) => {
|
|
62
|
+
const h = i[l];
|
|
63
|
+
typeof h == "number" && (t[l] = h);
|
|
64
|
+
}), ["zoom", "pan"].forEach((l) => {
|
|
65
|
+
const h = i[l];
|
|
66
|
+
h != null && (t[l] = !!h);
|
|
67
67
|
}), t;
|
|
68
68
|
}
|
|
69
69
|
function Et(e) {
|
|
@@ -93,10 +93,10 @@ function wt() {
|
|
|
93
93
|
return this.eachAfter(zt);
|
|
94
94
|
}
|
|
95
95
|
function Ct(e) {
|
|
96
|
-
var t = this, i, n = [t], s, a,
|
|
96
|
+
var t = this, i, n = [t], s, a, c;
|
|
97
97
|
do
|
|
98
98
|
for (i = n.reverse(), n = []; t = i.pop(); )
|
|
99
|
-
if (e(t), s = t.children, s) for (a = 0,
|
|
99
|
+
if (e(t), s = t.children, s) for (a = 0, c = s.length; a < c; ++a)
|
|
100
100
|
n.push(s[a]);
|
|
101
101
|
while (n.length);
|
|
102
102
|
return this;
|
|
@@ -108,8 +108,8 @@ function St(e) {
|
|
|
108
108
|
return this;
|
|
109
109
|
}
|
|
110
110
|
function Rt(e) {
|
|
111
|
-
for (var t = this, i = [t], n = [], s, a,
|
|
112
|
-
if (n.push(t), s = t.children, s) for (a = 0,
|
|
111
|
+
for (var t = this, i = [t], n = [], s, a, c; t = i.pop(); )
|
|
112
|
+
if (n.push(t), s = t.children, s) for (a = 0, c = s.length; a < c; ++a)
|
|
113
113
|
i.push(s[a]);
|
|
114
114
|
for (; t = n.pop(); )
|
|
115
115
|
e(t);
|
|
@@ -127,20 +127,20 @@ function jt(e) {
|
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
function _t(e) {
|
|
130
|
-
for (var t = this, i =
|
|
130
|
+
for (var t = this, i = Ot(t, e), n = [t]; t !== i; )
|
|
131
131
|
t = t.parent, n.push(t);
|
|
132
132
|
for (var s = n.length; e !== i; )
|
|
133
133
|
n.splice(s, 0, e), e = e.parent;
|
|
134
134
|
return n;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function Ot(e, t) {
|
|
137
137
|
if (e === t) return e;
|
|
138
138
|
var i = e.ancestors(), n = t.ancestors(), s = null;
|
|
139
139
|
for (e = i.pop(), t = n.pop(); e === t; )
|
|
140
140
|
s = e, e = i.pop(), t = n.pop();
|
|
141
141
|
return s;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function Mt() {
|
|
144
144
|
for (var e = this, t = [e]; e = e.parent; )
|
|
145
145
|
t.push(e);
|
|
146
146
|
return t;
|
|
@@ -164,11 +164,11 @@ function Ht() {
|
|
|
164
164
|
}), t;
|
|
165
165
|
}
|
|
166
166
|
function H(e, t) {
|
|
167
|
-
var i = new j(e), n = +e.value && (i.value = e.value), s, a = [i],
|
|
167
|
+
var i = new j(e), n = +e.value && (i.value = e.value), s, a = [i], c, o, l, h;
|
|
168
168
|
for (t == null && (t = Ft); s = a.pop(); )
|
|
169
169
|
if (n && (s.value = +s.data.value), (o = t(s.data)) && (h = o.length))
|
|
170
|
-
for (s.children = new Array(h),
|
|
171
|
-
a.push(
|
|
170
|
+
for (s.children = new Array(h), l = h - 1; l >= 0; --l)
|
|
171
|
+
a.push(c = s.children[l] = new j(o[l])), c.parent = s, c.depth = s.depth + 1;
|
|
172
172
|
return i.eachBefore(Dt);
|
|
173
173
|
}
|
|
174
174
|
function Bt() {
|
|
@@ -198,7 +198,7 @@ j.prototype = H.prototype = {
|
|
|
198
198
|
sum: Xt,
|
|
199
199
|
sort: jt,
|
|
200
200
|
path: _t,
|
|
201
|
-
ancestors:
|
|
201
|
+
ancestors: Mt,
|
|
202
202
|
descendants: At,
|
|
203
203
|
leaves: Tt,
|
|
204
204
|
links: Ht,
|
|
@@ -227,28 +227,28 @@ const $t = "d3-flextree", Nt = "2.1.2", Wt = "build/d3-flextree.js", It = "index
|
|
|
227
227
|
function tt(e) {
|
|
228
228
|
const t = Object.assign({}, ee, e);
|
|
229
229
|
function i(o) {
|
|
230
|
-
const
|
|
231
|
-
return typeof
|
|
230
|
+
const l = t[o];
|
|
231
|
+
return typeof l == "function" ? l : () => l;
|
|
232
232
|
}
|
|
233
233
|
function n(o) {
|
|
234
|
-
const
|
|
235
|
-
return
|
|
234
|
+
const l = c(a(), o, (h) => h.children);
|
|
235
|
+
return l.update(), l.data;
|
|
236
236
|
}
|
|
237
237
|
function s() {
|
|
238
|
-
const o = i("nodeSize"),
|
|
238
|
+
const o = i("nodeSize"), l = i("spacing");
|
|
239
239
|
return class Q extends H.prototype.constructor {
|
|
240
240
|
constructor(d) {
|
|
241
241
|
super(d);
|
|
242
242
|
}
|
|
243
243
|
copy() {
|
|
244
|
-
const d =
|
|
244
|
+
const d = c(this.constructor, this, (g) => g.children);
|
|
245
245
|
return d.each((g) => g.data = g.data.data), d;
|
|
246
246
|
}
|
|
247
247
|
get size() {
|
|
248
248
|
return o(this);
|
|
249
249
|
}
|
|
250
250
|
spacing(d) {
|
|
251
|
-
return
|
|
251
|
+
return l(this, d);
|
|
252
252
|
}
|
|
253
253
|
get nodes() {
|
|
254
254
|
return this.descendants();
|
|
@@ -315,7 +315,7 @@ function tt(e) {
|
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
317
|
function a() {
|
|
318
|
-
const o = s(),
|
|
318
|
+
const o = s(), l = i("nodeSize"), h = i("spacing");
|
|
319
319
|
return class extends o {
|
|
320
320
|
constructor(d) {
|
|
321
321
|
super(d), Object.assign(this, {
|
|
@@ -334,7 +334,7 @@ function tt(e) {
|
|
|
334
334
|
});
|
|
335
335
|
}
|
|
336
336
|
get size() {
|
|
337
|
-
return
|
|
337
|
+
return l(this.data);
|
|
338
338
|
}
|
|
339
339
|
spacing(d) {
|
|
340
340
|
return h(this.data, d.data);
|
|
@@ -356,7 +356,7 @@ function tt(e) {
|
|
|
356
356
|
}
|
|
357
357
|
};
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function c(o, l, h) {
|
|
360
360
|
const d = (g, u) => {
|
|
361
361
|
const m = new o(g);
|
|
362
362
|
Object.assign(m, {
|
|
@@ -374,7 +374,7 @@ function tt(e) {
|
|
|
374
374
|
m
|
|
375
375
|
)), m;
|
|
376
376
|
};
|
|
377
|
-
return d(
|
|
377
|
+
return d(l, null);
|
|
378
378
|
}
|
|
379
379
|
return Object.assign(n, {
|
|
380
380
|
nodeSize(o) {
|
|
@@ -386,13 +386,13 @@ function tt(e) {
|
|
|
386
386
|
children(o) {
|
|
387
387
|
return arguments.length ? (t.children = o, n) : t.children;
|
|
388
388
|
},
|
|
389
|
-
hierarchy(o,
|
|
390
|
-
const h = typeof
|
|
391
|
-
return
|
|
389
|
+
hierarchy(o, l) {
|
|
390
|
+
const h = typeof l > "u" ? t.children : l;
|
|
391
|
+
return c(s(), o, h);
|
|
392
392
|
},
|
|
393
393
|
dump(o) {
|
|
394
|
-
const
|
|
395
|
-
const u = d + " ", m = d + " ", { x, y } = g, v =
|
|
394
|
+
const l = i("nodeSize"), h = (d) => (g) => {
|
|
395
|
+
const u = d + " ", m = d + " ", { x, y } = g, v = l(g), b = g.children || [], z = b.length === 0 ? " " : `,${u}children: [${m}${b.map(h(m)).join(m)}${u}],${d}`;
|
|
396
396
|
return `{ size: [${v.join(", ")}],${u}x: ${x}, y: ${y}${z}},`;
|
|
397
397
|
};
|
|
398
398
|
return h(`
|
|
@@ -404,9 +404,9 @@ tt.version = te;
|
|
|
404
404
|
const et = (e, t = 0) => (e.y = t, (e.children || []).reduce((i, n) => {
|
|
405
405
|
const [s, a] = i;
|
|
406
406
|
et(n, e.y + e.ySize);
|
|
407
|
-
const
|
|
407
|
+
const c = (s === 0 ? n.lExt : n.rExt).bottom;
|
|
408
408
|
s !== 0 && ne(e, s, a);
|
|
409
|
-
const o = de(
|
|
409
|
+
const o = de(c, s, a);
|
|
410
410
|
return [s + 1, o];
|
|
411
411
|
}, [0, null]), re(e), he(e), e), rt = (e, t, i) => {
|
|
412
412
|
typeof t > "u" && (t = -e.relX - e.prelim, i = 0);
|
|
@@ -414,38 +414,38 @@ const et = (e, t = 0) => (e.y = t, (e.children || []).reduce((i, n) => {
|
|
|
414
414
|
return e.relX = n + e.prelim - i, e.prelim = 0, e.x = i + e.relX, (e.children || []).forEach((s) => rt(s, n, e.x)), e;
|
|
415
415
|
}, re = (e) => {
|
|
416
416
|
(e.children || []).reduce((t, i) => {
|
|
417
|
-
const [n, s] = t, a = n + i.shift,
|
|
418
|
-
return i.relX +=
|
|
417
|
+
const [n, s] = t, a = n + i.shift, c = s + a + i.change;
|
|
418
|
+
return i.relX += c, [a, c];
|
|
419
419
|
}, [0, 0]);
|
|
420
420
|
}, ne = (e, t, i) => {
|
|
421
421
|
const n = e.children[t - 1], s = e.children[t];
|
|
422
|
-
let a = n,
|
|
422
|
+
let a = n, c = n.relX, o = s, l = s.relX, h = !0;
|
|
423
423
|
for (; a && o; ) {
|
|
424
424
|
a.bottom > i.lowY && (i = i.next);
|
|
425
|
-
const d =
|
|
426
|
-
(d > 0 || d < 0 && h) && (
|
|
425
|
+
const d = c + a.prelim - (l + o.prelim) + a.xSize / 2 + o.xSize / 2 + a.spacing(o);
|
|
426
|
+
(d > 0 || d < 0 && h) && (l += d, ie(s, d), se(e, t, i.index, d)), h = !1;
|
|
427
427
|
const g = a.bottom, u = o.bottom;
|
|
428
|
-
g <= u && (a = ae(a), a && (
|
|
428
|
+
g <= u && (a = ae(a), a && (c += a.relX)), g >= u && (o = oe(o), o && (l += o.relX));
|
|
429
429
|
}
|
|
430
|
-
!a && o ? le(e, t, o,
|
|
430
|
+
!a && o ? le(e, t, o, l) : a && !o && ce(e, t, a, c);
|
|
431
431
|
}, ie = (e, t) => {
|
|
432
432
|
e.relX += t, e.lExtRelX += t, e.rExtRelX += t;
|
|
433
433
|
}, se = (e, t, i, n) => {
|
|
434
434
|
const s = e.children[t], a = t - i;
|
|
435
435
|
if (a > 1) {
|
|
436
|
-
const
|
|
437
|
-
e.children[i + 1].shift +=
|
|
436
|
+
const c = n / a;
|
|
437
|
+
e.children[i + 1].shift += c, s.shift -= c, s.change -= n - c;
|
|
438
438
|
}
|
|
439
439
|
}, oe = (e) => e.hasChildren ? e.firstChild : e.lThr, ae = (e) => e.hasChildren ? e.lastChild : e.rThr, le = (e, t, i, n) => {
|
|
440
|
-
const s = e.firstChild, a = s.lExt,
|
|
440
|
+
const s = e.firstChild, a = s.lExt, c = e.children[t];
|
|
441
441
|
a.lThr = i;
|
|
442
442
|
const o = n - i.relX - s.lExtRelX;
|
|
443
|
-
a.relX += o, a.prelim -= o, s.lExt =
|
|
443
|
+
a.relX += o, a.prelim -= o, s.lExt = c.lExt, s.lExtRelX = c.lExtRelX;
|
|
444
444
|
}, ce = (e, t, i, n) => {
|
|
445
|
-
const s = e.children[t], a = s.rExt,
|
|
445
|
+
const s = e.children[t], a = s.rExt, c = e.children[t - 1];
|
|
446
446
|
a.rThr = i;
|
|
447
447
|
const o = n - i.relX - s.rExtRelX;
|
|
448
|
-
a.relX += o, a.prelim -= o, s.rExt =
|
|
448
|
+
a.relX += o, a.prelim -= o, s.rExt = c.rExt, s.rExtRelX = c.rExtRelX;
|
|
449
449
|
}, he = (e) => {
|
|
450
450
|
if (e.hasChildren) {
|
|
451
451
|
const t = e.firstChild, i = e.lastChild, n = (t.prelim + t.relX - t.xSize / 2 + i.relX + i.prelim + i.xSize / 2) / 2;
|
|
@@ -465,7 +465,7 @@ const et = (e, t = 0) => (e.y = t, (e.children || []).reduce((i, n) => {
|
|
|
465
465
|
index: t,
|
|
466
466
|
next: i
|
|
467
467
|
};
|
|
468
|
-
}, nt = ".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;--markmap-highlight-node-bg: #ff02;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-highlight rect{fill:var(--markmap-highlight-node-bg)}.markmap-dark .markmap{--markmap-code-bg: #1a1b26;--markmap-code-color: #ddd;--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", ve = nt,
|
|
468
|
+
}, nt = ".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;--markmap-highlight-node-bg: #ff02;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-highlight rect{fill:var(--markmap-highlight-node-bg)}.markmap-dark .markmap{--markmap-code-bg: #1a1b26;--markmap-code-color: #ddd;--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", ve = nt, M = "g.markmap-node", pe = "path.markmap-link", ge = "g.markmap-highlight", A = ft();
|
|
469
469
|
function U(e, t) {
|
|
470
470
|
const i = vt(e, t);
|
|
471
471
|
return e[i];
|
|
@@ -519,9 +519,9 @@ class it {
|
|
|
519
519
|
async toggleNode(t, i = !1) {
|
|
520
520
|
var s, a;
|
|
521
521
|
const n = (s = t.payload) != null && s.fold ? 0 : 1;
|
|
522
|
-
i ? R(t, (
|
|
523
|
-
|
|
524
|
-
...
|
|
522
|
+
i ? R(t, (c, o) => {
|
|
523
|
+
c.payload = {
|
|
524
|
+
...c.payload,
|
|
525
525
|
fold: n
|
|
526
526
|
}, o();
|
|
527
527
|
}) : t.payload = {
|
|
@@ -532,12 +532,12 @@ class it {
|
|
|
532
532
|
_initializeData(t) {
|
|
533
533
|
let i = 0;
|
|
534
534
|
const { color: n, initialExpandLevel: s } = this.options;
|
|
535
|
-
let a = 0,
|
|
536
|
-
return R(t, (o,
|
|
535
|
+
let a = 0, c = 0;
|
|
536
|
+
return R(t, (o, l, h) => {
|
|
537
537
|
var g, u, m, x;
|
|
538
|
-
|
|
538
|
+
c += 1, o.children = (g = o.children) == null ? void 0 : g.map((y) => ({ ...y })), i += 1, o.state = {
|
|
539
539
|
...o.state,
|
|
540
|
-
depth:
|
|
540
|
+
depth: c,
|
|
541
541
|
id: i,
|
|
542
542
|
rect: {
|
|
543
543
|
x: 0,
|
|
@@ -548,45 +548,45 @@ class it {
|
|
|
548
548
|
size: [0, 0]
|
|
549
549
|
}, o.state.key = [(u = h == null ? void 0 : h.state) == null ? void 0 : u.id, o.state.id].filter(Boolean).join(".") + Et(o.content), o.state.path = [(m = h == null ? void 0 : h.state) == null ? void 0 : m.path, o.state.id].filter(Boolean).join("."), n(o);
|
|
550
550
|
const d = ((x = o.payload) == null ? void 0 : x.fold) === 2;
|
|
551
|
-
d ? a += 1 : (a || s >= 0 && o.state.depth >= s) && (o.payload = { ...o.payload, fold: 1 }),
|
|
551
|
+
d ? a += 1 : (a || s >= 0 && o.state.depth >= s) && (o.payload = { ...o.payload, fold: 1 }), l(), d && (a -= 1), c -= 1;
|
|
552
552
|
}), t;
|
|
553
553
|
}
|
|
554
554
|
_relayout() {
|
|
555
555
|
if (!this.state.data) return;
|
|
556
|
-
this.g.selectAll(k(
|
|
556
|
+
this.g.selectAll(k(M)).selectAll(
|
|
557
557
|
k("foreignObject")
|
|
558
|
-
).each(function(
|
|
559
|
-
var
|
|
560
|
-
const
|
|
561
|
-
|
|
558
|
+
).each(function(l) {
|
|
559
|
+
var g;
|
|
560
|
+
const h = (g = this.firstChild) == null ? void 0 : g.firstChild, d = [h.scrollWidth, h.scrollHeight];
|
|
561
|
+
l.state.size = d;
|
|
562
562
|
});
|
|
563
|
-
const {
|
|
564
|
-
var
|
|
565
|
-
if (!((
|
|
566
|
-
}).nodeSize((
|
|
567
|
-
const [
|
|
568
|
-
return [
|
|
569
|
-
}).spacing((
|
|
570
|
-
|
|
571
|
-
const
|
|
572
|
-
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
x:
|
|
576
|
-
y:
|
|
577
|
-
width:
|
|
578
|
-
height:
|
|
563
|
+
const { lineWidth: t, paddingX: i, spacingHorizontal: n, spacingVertical: s } = this.options, a = tt({}).children((l) => {
|
|
564
|
+
var h;
|
|
565
|
+
if (!((h = l.payload) != null && h.fold)) return l.children;
|
|
566
|
+
}).nodeSize((l) => {
|
|
567
|
+
const [h, d] = l.data.state.size;
|
|
568
|
+
return [d, h + (h ? i * 2 : 0) + n];
|
|
569
|
+
}).spacing((l, h) => (l.parent === h.parent ? s : s * 2) + t(l.data)), c = a.hierarchy(this.state.data);
|
|
570
|
+
a(c);
|
|
571
|
+
const o = c.descendants();
|
|
572
|
+
o.forEach((l) => {
|
|
573
|
+
const h = l.data;
|
|
574
|
+
h.state.rect = {
|
|
575
|
+
x: l.y,
|
|
576
|
+
y: l.x - l.xSize / 2,
|
|
577
|
+
width: l.ySize - n,
|
|
578
|
+
height: l.xSize
|
|
579
579
|
};
|
|
580
580
|
}), this.state.rect = {
|
|
581
|
-
x1: G(
|
|
582
|
-
y1: G(
|
|
581
|
+
x1: G(o, (l) => l.data.state.rect.x) || 0,
|
|
582
|
+
y1: G(o, (l) => l.data.state.rect.y) || 0,
|
|
583
583
|
x2: V(
|
|
584
|
-
|
|
585
|
-
(
|
|
584
|
+
o,
|
|
585
|
+
(l) => l.data.state.rect.x + l.data.state.rect.width
|
|
586
586
|
) || 0,
|
|
587
587
|
y2: V(
|
|
588
|
-
|
|
589
|
-
(
|
|
588
|
+
o,
|
|
589
|
+
(l) => l.data.state.rect.y + l.data.state.rect.height
|
|
590
590
|
) || 0
|
|
591
591
|
};
|
|
592
592
|
}
|
|
@@ -609,27 +609,27 @@ class it {
|
|
|
609
609
|
return a.x -= s, a.y -= s, a.width += 2 * s, a.height += 2 * s, a;
|
|
610
610
|
}
|
|
611
611
|
async renderData(t) {
|
|
612
|
-
const { paddingX: i, autoFit: n, color: s, maxWidth: a,
|
|
612
|
+
const { paddingX: i, autoFit: n, color: s, maxWidth: a, lineWidth: c } = this.options, o = this.state.data;
|
|
613
613
|
if (!o) return;
|
|
614
|
-
const
|
|
614
|
+
const l = {}, h = {}, d = [];
|
|
615
615
|
R(o, (r, p, f) => {
|
|
616
616
|
var E;
|
|
617
|
-
(E = r.payload) != null && E.fold || p(),
|
|
617
|
+
(E = r.payload) != null && E.fold || p(), l[r.state.id] = r, f && (h[r.state.id] = f.state.id), d.push(r);
|
|
618
618
|
});
|
|
619
619
|
const g = {}, u = {}, m = (r) => {
|
|
620
620
|
!r || g[r.state.id] || R(r, (p, f) => {
|
|
621
621
|
g[p.state.id] = r.state.id, f();
|
|
622
622
|
});
|
|
623
|
-
}, x = (r) => u[g[r.state.id]] || o.state.rect, y = (r) => (
|
|
623
|
+
}, x = (r) => u[g[r.state.id]] || o.state.rect, y = (r) => (l[g[r.state.id]] || o).state.rect;
|
|
624
624
|
u[o.state.id] = o.state.rect, t && m(t);
|
|
625
625
|
const { highlight: v } = this.state;
|
|
626
626
|
let b = this.g.selectAll(k(ge)).selectAll(k("rect")).data(v ? [this._getHighlightRect(v)] : []).join("rect").attr("x", (r) => r.x).attr("y", (r) => r.y).attr("width", (r) => r.width).attr("height", (r) => r.height);
|
|
627
|
-
const z = this.g.selectAll(k(
|
|
627
|
+
const z = this.g.selectAll(k(M)).each((r) => {
|
|
628
628
|
u[r.state.id] = r.state.rect;
|
|
629
629
|
}).data(d, (r) => r.state.key), B = z.enter().append("g").attr("data-depth", (r) => r.state.depth).attr("data-path", (r) => r.state.path).each((r) => {
|
|
630
|
-
m(
|
|
630
|
+
m(l[h[r.state.id]]);
|
|
631
631
|
}), C = z.exit().each((r) => {
|
|
632
|
-
m(
|
|
632
|
+
m(l[h[r.state.id]]);
|
|
633
633
|
}), S = z.merge(B).attr(
|
|
634
634
|
"class",
|
|
635
635
|
(r) => {
|
|
@@ -673,13 +673,13 @@ class it {
|
|
|
673
673
|
var p;
|
|
674
674
|
return (p = r.payload) != null && p.fold ? [] : r.children.map((f) => ({ source: r, target: f }));
|
|
675
675
|
}
|
|
676
|
-
),
|
|
676
|
+
), O = this.g.selectAll(k(pe)).data(st, (r) => r.target.state.key), ot = O.exit(), at = O.enter().insert("path", "g").attr("class", "markmap-link").attr("data-depth", (r) => r.target.state.depth).attr("data-path", (r) => r.target.state.path).attr("d", (r) => {
|
|
677
677
|
const p = x(r.target), f = [
|
|
678
678
|
p.x + p.width,
|
|
679
679
|
p.y + p.height
|
|
680
680
|
];
|
|
681
681
|
return A({ source: f, target: f });
|
|
682
|
-
}).attr("stroke-width", 0).merge(
|
|
682
|
+
}).attr("stroke-width", 0).merge(O);
|
|
683
683
|
this.svg.style(
|
|
684
684
|
"--markmap-max-width",
|
|
685
685
|
a ? `${a}px` : null
|
|
@@ -696,23 +696,23 @@ class it {
|
|
|
696
696
|
const lt = C.selectAll(
|
|
697
697
|
k("line")
|
|
698
698
|
);
|
|
699
|
-
this.transition(lt).attr("x1", (r) => r.state.rect.width).attr("stroke-width", 0), L.attr("x1", (r) => r.state.rect.width).attr("x2", (r) => r.state.rect.width), D.attr("y1", (r) => r.state.rect.height).attr("y2", (r) => r.state.rect.height), this.transition(D).attr("x1", -1).attr("x2", (r) => r.state.rect.width + 2).attr("stroke", (r) => s(r)).attr("stroke-width",
|
|
699
|
+
this.transition(lt).attr("x1", (r) => r.state.rect.width).attr("stroke-width", 0), L.attr("x1", (r) => r.state.rect.width).attr("x2", (r) => r.state.rect.width), D.attr("y1", (r) => r.state.rect.height + c(r) / 2).attr("y2", (r) => r.state.rect.height + c(r) / 2), this.transition(D).attr("x1", -1).attr("x2", (r) => r.state.rect.width + 2).attr("stroke", (r) => s(r)).attr("stroke-width", c);
|
|
700
700
|
const ct = C.selectAll(
|
|
701
701
|
k("circle")
|
|
702
702
|
);
|
|
703
|
-
this.transition(ct).attr("r", 0).attr("stroke-width", 0), N.attr("cx", (r) => r.state.rect.width).attr("cy", (r) => r.state.rect.height), this.transition(N).attr("r", 6).attr("stroke-width", "1.5"), this.transition(P).style("opacity", 0), K.attr("width", (r) => Math.max(0, r.state.rect.width - i * 2)).attr("height", (r) => r.state.rect.height), this.transition(K).style("opacity", 1), this.transition(ot).attr("d", (r) => {
|
|
703
|
+
this.transition(ct).attr("r", 0).attr("stroke-width", 0), N.attr("cx", (r) => r.state.rect.width).attr("cy", (r) => r.state.rect.height + c(r) / 2), this.transition(N).attr("r", 6).attr("stroke-width", "1.5"), this.transition(P).style("opacity", 0), K.attr("width", (r) => Math.max(0, r.state.rect.width - i * 2)).attr("height", (r) => r.state.rect.height), this.transition(K).style("opacity", 1), this.transition(ot).attr("d", (r) => {
|
|
704
704
|
const p = y(r.target), f = [
|
|
705
705
|
p.x + p.width,
|
|
706
|
-
p.y + p.height
|
|
706
|
+
p.y + p.height + c(r.target) / 2
|
|
707
707
|
];
|
|
708
708
|
return A({ source: f, target: f });
|
|
709
|
-
}).attr("stroke-width", 0).remove(), this.transition(at).attr("stroke", (r) => s(r.target)).attr("stroke-width", (r) =>
|
|
709
|
+
}).attr("stroke-width", 0).remove(), this.transition(at).attr("stroke", (r) => s(r.target)).attr("stroke-width", (r) => c(r.target)).attr("d", (r) => {
|
|
710
710
|
const p = r.source, f = r.target, E = [
|
|
711
711
|
p.state.rect.x + p.state.rect.width,
|
|
712
|
-
p.state.rect.y + p.state.rect.height
|
|
712
|
+
p.state.rect.y + p.state.rect.height + c(p) / 2
|
|
713
713
|
], ht = [
|
|
714
714
|
f.state.rect.x,
|
|
715
|
-
f.state.rect.y + f.state.rect.height
|
|
715
|
+
f.state.rect.y + f.state.rect.height + c(f) / 2
|
|
716
716
|
];
|
|
717
717
|
return A({ source: E, target: ht });
|
|
718
718
|
}), n && this.fit();
|
|
@@ -725,19 +725,19 @@ class it {
|
|
|
725
725
|
* Fit the content to the viewport.
|
|
726
726
|
*/
|
|
727
727
|
async fit(t = this.options.maxInitialScale) {
|
|
728
|
-
const i = this.svg.node(), { width: n, height: s } = i.getBoundingClientRect(), { fitRatio: a } = this.options, { x1:
|
|
728
|
+
const i = this.svg.node(), { width: n, height: s } = i.getBoundingClientRect(), { fitRatio: a } = this.options, { x1: c, y1: o, x2: l, y2: h } = this.state.rect, d = l - c, g = h - o, u = Math.min(
|
|
729
729
|
n / d * a,
|
|
730
730
|
s / g * a,
|
|
731
731
|
t
|
|
732
732
|
), m = kt.translate(
|
|
733
|
-
(n - d * u) / 2 -
|
|
733
|
+
(n - d * u) / 2 - c * u,
|
|
734
734
|
(s - g * u) / 2 - o * u
|
|
735
735
|
).scale(u);
|
|
736
736
|
return this.transition(this.svg).call(this.zoom.transform, m).end().catch(X);
|
|
737
737
|
}
|
|
738
738
|
findElement(t) {
|
|
739
739
|
let i;
|
|
740
|
-
return this.g.selectAll(k(
|
|
740
|
+
return this.g.selectAll(k(M)).each(function(s) {
|
|
741
741
|
s === t && (i = {
|
|
742
742
|
data: s,
|
|
743
743
|
g: this
|
|
@@ -751,21 +751,21 @@ class it {
|
|
|
751
751
|
var v;
|
|
752
752
|
const n = (v = this.findElement(t)) == null ? void 0 : v.data;
|
|
753
753
|
if (!n) return;
|
|
754
|
-
const s = this.svg.node(), a = s.getBoundingClientRect(),
|
|
754
|
+
const s = this.svg.node(), a = s.getBoundingClientRect(), c = w(s), [o, l] = [
|
|
755
755
|
n.state.rect.x,
|
|
756
756
|
n.state.rect.x + n.state.rect.width + 2
|
|
757
|
-
].map((b) => b *
|
|
757
|
+
].map((b) => b * c.k + c.x), [h, d] = [
|
|
758
758
|
n.state.rect.y,
|
|
759
759
|
n.state.rect.y + n.state.rect.height
|
|
760
|
-
].map((b) => b *
|
|
760
|
+
].map((b) => b * c.k + c.y), g = {
|
|
761
761
|
left: 0,
|
|
762
762
|
right: 0,
|
|
763
763
|
top: 0,
|
|
764
764
|
bottom: 0,
|
|
765
765
|
...i
|
|
766
|
-
}, u = [g.left - o, a.width - g.right -
|
|
766
|
+
}, u = [g.left - o, a.width - g.right - l], m = [g.top - h, a.height - g.bottom - d], x = u[0] * u[1] > 0 ? U(u, Math.abs) / c.k : 0, y = m[0] * m[1] > 0 ? U(m, Math.abs) / c.k : 0;
|
|
767
767
|
if (x || y) {
|
|
768
|
-
const b =
|
|
768
|
+
const b = c.translate(x, y);
|
|
769
769
|
return this.transition(this.svg).call(this.zoom.transform, b).end().catch(X);
|
|
770
770
|
}
|
|
771
771
|
}
|
|
@@ -773,15 +773,15 @@ class it {
|
|
|
773
773
|
var x;
|
|
774
774
|
const n = (x = this.findElement(t)) == null ? void 0 : x.data;
|
|
775
775
|
if (!n) return;
|
|
776
|
-
const s = this.svg.node(), a = s.getBoundingClientRect(),
|
|
776
|
+
const s = this.svg.node(), a = s.getBoundingClientRect(), c = w(s), o = (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, h = {
|
|
777
777
|
left: 0,
|
|
778
778
|
right: 0,
|
|
779
779
|
top: 0,
|
|
780
780
|
bottom: 0,
|
|
781
781
|
...i
|
|
782
|
-
}, d = (h.left + a.width - h.right) / 2, g = (h.top + a.height - h.bottom) / 2, u = (d - o) /
|
|
782
|
+
}, d = (h.left + a.width - h.right) / 2, g = (h.top + a.height - h.bottom) / 2, u = (d - o) / c.k, m = (g - l) / c.k;
|
|
783
783
|
if (u || m) {
|
|
784
|
-
const y =
|
|
784
|
+
const y = c.translate(u, m);
|
|
785
785
|
return this.transition(this.svg).call(this.zoom.transform, y).end().catch(X);
|
|
786
786
|
}
|
|
787
787
|
}
|
|
@@ -789,11 +789,11 @@ class it {
|
|
|
789
789
|
* Scale content with it pinned at the center of the viewport.
|
|
790
790
|
*/
|
|
791
791
|
async rescale(t) {
|
|
792
|
-
const i = this.svg.node(), { width: n, height: s } = i.getBoundingClientRect(), a = n / 2,
|
|
792
|
+
const i = this.svg.node(), { width: n, height: s } = i.getBoundingClientRect(), a = n / 2, c = s / 2, o = w(i), l = o.translate(
|
|
793
793
|
(a - o.x) * (1 - t) / o.k,
|
|
794
|
-
(
|
|
794
|
+
(c - o.y) * (1 - t) / o.k
|
|
795
795
|
).scale(t);
|
|
796
|
-
return this.transition(this.svg).call(this.zoom.transform,
|
|
796
|
+
return this.transition(this.svg).call(this.zoom.transform, l).end().catch(X);
|
|
797
797
|
}
|
|
798
798
|
destroy() {
|
|
799
799
|
this.svg.on(".zoom", null), this.svg.html(null), this._disposeList.forEach((t) => {
|
|
@@ -815,7 +815,7 @@ export {
|
|
|
815
815
|
ke as deriveOptions,
|
|
816
816
|
ve as globalCSS,
|
|
817
817
|
Z as isMacintosh,
|
|
818
|
-
q as
|
|
818
|
+
q as lineWidthFactory,
|
|
819
819
|
ze as loadCSS,
|
|
820
820
|
we as loadJS,
|
|
821
821
|
ue as refreshHook,
|
package/dist/types.d.ts
CHANGED
package/dist/view.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare class Markmap {
|
|
|
21
21
|
toggleRecursively: boolean;
|
|
22
22
|
zoom: boolean;
|
|
23
23
|
color: (node: INode) => string;
|
|
24
|
-
|
|
24
|
+
lineWidth: (node: INode) => number;
|
|
25
25
|
maxWidth: number;
|
|
26
26
|
nodeMinHeight: number;
|
|
27
27
|
paddingX: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-view",
|
|
3
|
-
"version": "0.18.8
|
|
3
|
+
"version": "0.18.8",
|
|
4
4
|
"description": "View markmaps in browser",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"@types/d3": "^7.4.0",
|
|
47
47
|
"@types/d3-flextree": "^2.1.1",
|
|
48
48
|
"d3-flextree": "^2.1.2",
|
|
49
|
-
"markmap-common": "0.18.8
|
|
49
|
+
"markmap-common": "0.18.8"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"markmap-common": "*"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "476d2e8abb528af6f6f0c468c6c63791b7c1911a"
|
|
55
55
|
}
|