markmap-view 0.17.1-alpha.4 → 0.17.1
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 +7 -3
- package/dist/index.js +32 -28
- package/dist/types.d.ts +18 -12
- package/package.json +3 -3
package/dist/browser/index.js
CHANGED
|
@@ -401,10 +401,14 @@
|
|
|
401
401
|
}
|
|
402
402
|
const numberKeys = [
|
|
403
403
|
"duration",
|
|
404
|
-
"maxWidth",
|
|
405
|
-
"initialExpandLevel",
|
|
406
404
|
"fitRatio",
|
|
407
|
-
"
|
|
405
|
+
"initialExpandLevel",
|
|
406
|
+
"maxInitialScale",
|
|
407
|
+
"maxWidth",
|
|
408
|
+
"nodeMinHeight",
|
|
409
|
+
"paddingX",
|
|
410
|
+
"spacingHorizontal",
|
|
411
|
+
"spacingVertical"
|
|
408
412
|
];
|
|
409
413
|
numberKeys.forEach((key) => {
|
|
410
414
|
const value = options[key];
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Hook as st, getId as at, debounce as lt, addClass as ct, walkTree as
|
|
1
|
+
import { Hook as st, getId as at, debounce as lt, addClass as ct, walkTree as M, childSelector as C, noop as T } from "markmap-common";
|
|
2
2
|
import { loadCSS as Ce, loadJS as we } from "markmap-common";
|
|
3
|
-
import { scaleOrdinal as
|
|
4
|
-
const K = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), gt =
|
|
3
|
+
import { scaleOrdinal as Y, schemeCategory10 as ht, zoomTransform as A, select as dt, zoom as ut, linkHorizontal as pt, min as H, max as I, zoomIdentity as mt, minIndex as ft } from "d3";
|
|
4
|
+
const K = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), gt = Y(ht), P = {
|
|
5
5
|
autoFit: !1,
|
|
6
6
|
color: (e) => {
|
|
7
7
|
var t;
|
|
@@ -28,7 +28,7 @@ function Se(e) {
|
|
|
28
28
|
const s = i[0];
|
|
29
29
|
t.color = () => s;
|
|
30
30
|
} else if (i != null && i.length) {
|
|
31
|
-
const s =
|
|
31
|
+
const s = Y(i);
|
|
32
32
|
t.color = (l) => s(`${l.state.path}`);
|
|
33
33
|
}
|
|
34
34
|
if (o) {
|
|
@@ -43,10 +43,14 @@ function Se(e) {
|
|
|
43
43
|
}
|
|
44
44
|
return [
|
|
45
45
|
"duration",
|
|
46
|
-
"maxWidth",
|
|
47
|
-
"initialExpandLevel",
|
|
48
46
|
"fitRatio",
|
|
49
|
-
"
|
|
47
|
+
"initialExpandLevel",
|
|
48
|
+
"maxInitialScale",
|
|
49
|
+
"maxWidth",
|
|
50
|
+
"nodeMinHeight",
|
|
51
|
+
"paddingX",
|
|
52
|
+
"spacingHorizontal",
|
|
53
|
+
"spacingVertical"
|
|
50
54
|
].forEach((s) => {
|
|
51
55
|
const l = n[s];
|
|
52
56
|
typeof l == "number" && (t[s] = l);
|
|
@@ -186,14 +190,14 @@ function Rt(e) {
|
|
|
186
190
|
while (i.length);
|
|
187
191
|
return this;
|
|
188
192
|
}
|
|
189
|
-
function
|
|
193
|
+
function Mt(e) {
|
|
190
194
|
for (var t = this, n = [t], i, o; t = n.pop(); )
|
|
191
195
|
if (e(t), i = t.children, i)
|
|
192
196
|
for (o = i.length - 1; o >= 0; --o)
|
|
193
197
|
n.push(i[o]);
|
|
194
198
|
return this;
|
|
195
199
|
}
|
|
196
|
-
function
|
|
200
|
+
function Tt(e) {
|
|
197
201
|
for (var t = this, n = [t], i = [], o, a, c; t = n.pop(); )
|
|
198
202
|
if (i.push(t), o = t.children, o)
|
|
199
203
|
for (a = 0, c = o.length; a < c; ++a)
|
|
@@ -246,7 +250,7 @@ function Ft() {
|
|
|
246
250
|
t.children || e.push(t);
|
|
247
251
|
}), e;
|
|
248
252
|
}
|
|
249
|
-
function
|
|
253
|
+
function Ht() {
|
|
250
254
|
var e = this, t = [];
|
|
251
255
|
return e.each(function(n) {
|
|
252
256
|
n !== e && t.push({ source: n.parent, target: n });
|
|
@@ -258,9 +262,9 @@ function F(e, t) {
|
|
|
258
262
|
if (i && (o.value = +o.data.value), (s = t(o.data)) && (p = s.length))
|
|
259
263
|
for (o.children = new Array(p), l = p - 1; l >= 0; --l)
|
|
260
264
|
a.push(c = o.children[l] = new N(s[l])), c.parent = o, c.depth = o.depth + 1;
|
|
261
|
-
return n.eachBefore(
|
|
265
|
+
return n.eachBefore(Vt);
|
|
262
266
|
}
|
|
263
|
-
function
|
|
267
|
+
function It() {
|
|
264
268
|
return F(this).eachBefore(Wt);
|
|
265
269
|
}
|
|
266
270
|
function Lt(e) {
|
|
@@ -269,7 +273,7 @@ function Lt(e) {
|
|
|
269
273
|
function Wt(e) {
|
|
270
274
|
e.data = e.data.data;
|
|
271
275
|
}
|
|
272
|
-
function
|
|
276
|
+
function Vt(e) {
|
|
273
277
|
var t = 0;
|
|
274
278
|
do
|
|
275
279
|
e.height = t;
|
|
@@ -282,18 +286,18 @@ N.prototype = F.prototype = {
|
|
|
282
286
|
constructor: N,
|
|
283
287
|
count: Nt,
|
|
284
288
|
each: Rt,
|
|
285
|
-
eachAfter:
|
|
286
|
-
eachBefore:
|
|
289
|
+
eachAfter: Tt,
|
|
290
|
+
eachBefore: Mt,
|
|
287
291
|
sum: At,
|
|
288
292
|
sort: _t,
|
|
289
293
|
path: Ot,
|
|
290
294
|
ancestors: $t,
|
|
291
295
|
descendants: Bt,
|
|
292
296
|
leaves: Ft,
|
|
293
|
-
links:
|
|
294
|
-
copy:
|
|
297
|
+
links: Ht,
|
|
298
|
+
copy: It
|
|
295
299
|
};
|
|
296
|
-
const
|
|
300
|
+
const Yt = "d3-flextree", Kt = "2.1.2", Pt = "build/d3-flextree.js", Ut = "index", Gt = {
|
|
297
301
|
name: "Chris Maloney",
|
|
298
302
|
url: "http://chrismaloney.org"
|
|
299
303
|
}, Zt = "Flexible tree layout algorithm that allows for variable node sizes.", qt = [
|
|
@@ -342,7 +346,7 @@ const Vt = "d3-flextree", Kt = "2.1.2", Pt = "build/d3-flextree.js", Ut = "index
|
|
|
342
346
|
"rollup-plugin-uglify": "^3.0.0",
|
|
343
347
|
"uglify-es": "^3.3.9"
|
|
344
348
|
}, re = {
|
|
345
|
-
name:
|
|
349
|
+
name: Yt,
|
|
346
350
|
version: Kt,
|
|
347
351
|
main: Pt,
|
|
348
352
|
module: Ut,
|
|
@@ -607,7 +611,7 @@ function W(e) {
|
|
|
607
611
|
const t = e.data;
|
|
608
612
|
return Math.max(4 - 2 * t.state.depth, 1.5);
|
|
609
613
|
}
|
|
610
|
-
function
|
|
614
|
+
function V(e, t) {
|
|
611
615
|
const n = ft(e, t);
|
|
612
616
|
return e[n];
|
|
613
617
|
}
|
|
@@ -658,7 +662,7 @@ class et {
|
|
|
658
662
|
toggleNode(t, n = !1) {
|
|
659
663
|
var o, a;
|
|
660
664
|
const i = (o = t.payload) != null && o.fold ? 0 : 1;
|
|
661
|
-
n ?
|
|
665
|
+
n ? M(t, (c, s) => {
|
|
662
666
|
c.payload = {
|
|
663
667
|
...c.payload,
|
|
664
668
|
fold: i
|
|
@@ -679,7 +683,7 @@ class et {
|
|
|
679
683
|
document.body.append(l, p);
|
|
680
684
|
const h = a ? `--markmap-max-width: ${a}px` : "";
|
|
681
685
|
let u = 0, g = 0;
|
|
682
|
-
|
|
686
|
+
M(t, (m, y, f) => {
|
|
683
687
|
var b, w, z;
|
|
684
688
|
g += 1, m.children = (b = m.children) == null ? void 0 : b.map((E) => ({ ...E })), n += 1;
|
|
685
689
|
const k = O(
|
|
@@ -707,7 +711,7 @@ class et {
|
|
|
707
711
|
this._checkImages(l), x.forEach((m) => {
|
|
708
712
|
var y;
|
|
709
713
|
(y = m.parentNode) == null || y.append(m.cloneNode(!0));
|
|
710
|
-
}),
|
|
714
|
+
}), M(t, (m, y, f) => {
|
|
711
715
|
var b;
|
|
712
716
|
const k = m.state, v = k.el.getBoundingClientRect();
|
|
713
717
|
m.content = k.el.innerHTML, k.size = [
|
|
@@ -753,7 +757,7 @@ class et {
|
|
|
753
757
|
return [S, d + (d ? i * 2 : 0) + n];
|
|
754
758
|
}).spacing((r, d) => r.parent === d.parent ? o : o * 2), l = s.hierarchy(this.state.data);
|
|
755
759
|
s(l);
|
|
756
|
-
const p = l.descendants().reverse(), h = l.links(), u = pt(), g =
|
|
760
|
+
const p = l.descendants().reverse(), h = l.links(), u = pt(), g = H(p, (r) => r.x - r.xSize / 2), x = I(p, (r) => r.x + r.xSize / 2), m = H(p, (r) => r.y), y = I(p, (r) => r.y + r.ySize - n);
|
|
757
761
|
Object.assign(this.state, {
|
|
758
762
|
minX: g,
|
|
759
763
|
maxX: x,
|
|
@@ -880,7 +884,7 @@ class et {
|
|
|
880
884
|
(i - h * g) / 2 - l * g,
|
|
881
885
|
(o - u * g) / 2 - c * g
|
|
882
886
|
).scale(g);
|
|
883
|
-
return this.transition(this.svg).call(this.zoom.transform, x).end().catch(
|
|
887
|
+
return this.transition(this.svg).call(this.zoom.transform, x).end().catch(T);
|
|
884
888
|
}
|
|
885
889
|
findElement(t) {
|
|
886
890
|
let n;
|
|
@@ -913,10 +917,10 @@ class et {
|
|
|
913
917
|
top: 0,
|
|
914
918
|
bottom: 0,
|
|
915
919
|
...n
|
|
916
|
-
}, x = [g.left - l, c.width - g.right - p], m = [g.top - h, c.height - g.bottom - u], y = x[0] * x[1] > 0 ?
|
|
920
|
+
}, x = [g.left - l, c.width - g.right - p], m = [g.top - h, c.height - g.bottom - u], y = x[0] * x[1] > 0 ? V(x, Math.abs) / s.k : 0, f = m[0] * m[1] > 0 ? V(m, Math.abs) / s.k : 0;
|
|
917
921
|
if (y || f) {
|
|
918
922
|
const v = s.translate(y, f);
|
|
919
|
-
return this.transition(this.svg).call(this.zoom.transform, v).end().catch(
|
|
923
|
+
return this.transition(this.svg).call(this.zoom.transform, v).end().catch(T);
|
|
920
924
|
}
|
|
921
925
|
}
|
|
922
926
|
/**
|
|
@@ -927,7 +931,7 @@ class et {
|
|
|
927
931
|
(a - s.x) * (1 - t) / s.k,
|
|
928
932
|
(c - s.y) * (1 - t) / s.k
|
|
929
933
|
).scale(t);
|
|
930
|
-
return this.transition(this.svg).call(this.zoom.transform, l).end().catch(
|
|
934
|
+
return this.transition(this.svg).call(this.zoom.transform, l).end().catch(T);
|
|
931
935
|
}
|
|
932
936
|
destroy() {
|
|
933
937
|
this.svg.on(".zoom", null), this.svg.html(null), this.revokers.forEach((t) => {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { INode } from 'markmap-common';
|
|
2
1
|
import { FlextreeNode } from 'd3-flextree';
|
|
2
|
+
import { INode } from 'markmap-common';
|
|
3
3
|
export interface IMarkmapState {
|
|
4
4
|
id: string;
|
|
5
5
|
data?: INode;
|
|
@@ -8,17 +8,23 @@ export interface IMarkmapState {
|
|
|
8
8
|
minY: number;
|
|
9
9
|
maxY: number;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
12
|
-
color
|
|
13
|
-
colorFreezeLevel
|
|
14
|
-
duration
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
export type IMarkmapJSONOptions = Partial<{
|
|
12
|
+
color: string[];
|
|
13
|
+
colorFreezeLevel: number;
|
|
14
|
+
duration: number;
|
|
15
|
+
extraCss: string[];
|
|
16
|
+
extraJs: string[];
|
|
17
|
+
fitRatio: number;
|
|
18
|
+
initialExpandLevel: number;
|
|
19
|
+
maxInitialScale: number;
|
|
20
|
+
maxWidth: number;
|
|
21
|
+
nodeMinHeight: number;
|
|
22
|
+
paddingX: number;
|
|
23
|
+
pan: boolean;
|
|
24
|
+
spacingHorizontal: number;
|
|
25
|
+
spacingVertical: number;
|
|
26
|
+
zoom: boolean;
|
|
27
|
+
}>;
|
|
22
28
|
export interface IPadding {
|
|
23
29
|
left: number;
|
|
24
30
|
right: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-view",
|
|
3
|
-
"version": "0.17.1
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "View markmaps in browser",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/d3-flextree": "^2.1.1",
|
|
49
|
-
"markmap-common": "0.17.1
|
|
49
|
+
"markmap-common": "0.17.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"markmap-common": "*"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "628f06a60d0c06f4d2f70b6df786ecb8b4124241"
|
|
55
55
|
}
|