markmap-view 0.14.5-alpha.18 → 0.14.5-alpha.21
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 +97 -31
- package/dist/index.js +116 -57
- package/package.json +12 -11
- package/types/view.d.ts +1 -1
- package/dist/index.mjs +0 -1218
package/dist/browser/index.js
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
/*! markmap-view v0.14.5-alpha.
|
|
1
|
+
/*! markmap-view v0.14.5-alpha.21+fb81f2c | MIT License */
|
|
2
2
|
(function (exports, d3) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
var n = Object.create(null);
|
|
7
|
-
if (e) {
|
|
8
|
-
for (var k in e) {
|
|
9
|
-
n[k] = e[k];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
n.default = e;
|
|
13
|
-
return Object.freeze(n);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
var d3__namespace = /*#__PURE__*/_interopNamespaceDefault(d3);
|
|
17
|
-
|
|
18
|
-
/*! markmap-common v0.14.5-alpha.18+44c9639 | MIT License */
|
|
5
|
+
/*! markmap-common v0.14.5-alpha.21+fb81f2c | MIT License */
|
|
19
6
|
class Hook {
|
|
20
7
|
constructor() {
|
|
21
8
|
this.listeners = [];
|
|
@@ -548,8 +535,87 @@ Node$1.prototype = hierarchy.prototype = {
|
|
|
548
535
|
copy: node_copy
|
|
549
536
|
};
|
|
550
537
|
|
|
551
|
-
var
|
|
538
|
+
var name = "d3-flextree";
|
|
539
|
+
var version$1 = "2.1.2";
|
|
540
|
+
var main = "build/d3-flextree.js";
|
|
541
|
+
var module = "index";
|
|
542
|
+
var author = {
|
|
543
|
+
name: "Chris Maloney",
|
|
544
|
+
url: "http://chrismaloney.org"
|
|
545
|
+
};
|
|
546
|
+
var description = "Flexible tree layout algorithm that allows for variable node sizes.";
|
|
547
|
+
var keywords = [
|
|
548
|
+
"d3",
|
|
549
|
+
"d3-module",
|
|
550
|
+
"layout",
|
|
551
|
+
"tree",
|
|
552
|
+
"hierarchy",
|
|
553
|
+
"d3-hierarchy",
|
|
554
|
+
"plugin",
|
|
555
|
+
"d3-plugin",
|
|
556
|
+
"infovis",
|
|
557
|
+
"visualization",
|
|
558
|
+
"2d"
|
|
559
|
+
];
|
|
560
|
+
var homepage = "https://github.com/klortho/d3-flextree";
|
|
561
|
+
var license = "WTFPL";
|
|
562
|
+
var repository = {
|
|
563
|
+
type: "git",
|
|
564
|
+
url: "https://github.com/klortho/d3-flextree.git"
|
|
565
|
+
};
|
|
566
|
+
var scripts = {
|
|
567
|
+
clean: "rm -rf build demo test",
|
|
568
|
+
"build:demo": "rollup -c --environment BUILD:demo",
|
|
569
|
+
"build:dev": "rollup -c --environment BUILD:dev",
|
|
570
|
+
"build:prod": "rollup -c --environment BUILD:prod",
|
|
571
|
+
"build:test": "rollup -c --environment BUILD:test",
|
|
572
|
+
build: "rollup -c",
|
|
573
|
+
lint: "eslint index.js src",
|
|
574
|
+
"test:main": "node test/bundle.js",
|
|
575
|
+
"test:browser": "node test/browser-tests.js",
|
|
576
|
+
test: "npm-run-all test:*",
|
|
577
|
+
prepare: "npm-run-all clean build lint test"
|
|
578
|
+
};
|
|
579
|
+
var dependencies = {
|
|
580
|
+
"d3-hierarchy": "^1.1.5"
|
|
581
|
+
};
|
|
582
|
+
var devDependencies = {
|
|
583
|
+
"babel-plugin-external-helpers": "^6.22.0",
|
|
584
|
+
"babel-preset-es2015-rollup": "^3.0.0",
|
|
585
|
+
d3: "^4.13.0",
|
|
586
|
+
"d3-selection-multi": "^1.0.1",
|
|
587
|
+
eslint: "^4.19.1",
|
|
588
|
+
jsdom: "^11.6.2",
|
|
589
|
+
"npm-run-all": "^4.1.2",
|
|
590
|
+
rollup: "^0.55.3",
|
|
591
|
+
"rollup-plugin-babel": "^2.7.1",
|
|
592
|
+
"rollup-plugin-commonjs": "^8.0.2",
|
|
593
|
+
"rollup-plugin-copy": "^0.2.3",
|
|
594
|
+
"rollup-plugin-json": "^2.3.0",
|
|
595
|
+
"rollup-plugin-node-resolve": "^3.0.2",
|
|
596
|
+
"rollup-plugin-uglify": "^3.0.0",
|
|
597
|
+
"uglify-es": "^3.3.9"
|
|
598
|
+
};
|
|
599
|
+
var packageInfo = {
|
|
600
|
+
name: name,
|
|
601
|
+
version: version$1,
|
|
602
|
+
main: main,
|
|
603
|
+
module: module,
|
|
604
|
+
"jsnext:main": "index",
|
|
605
|
+
author: author,
|
|
606
|
+
description: description,
|
|
607
|
+
keywords: keywords,
|
|
608
|
+
homepage: homepage,
|
|
609
|
+
license: license,
|
|
610
|
+
repository: repository,
|
|
611
|
+
scripts: scripts,
|
|
612
|
+
dependencies: dependencies,
|
|
613
|
+
devDependencies: devDependencies
|
|
614
|
+
};
|
|
552
615
|
|
|
616
|
+
const {
|
|
617
|
+
version
|
|
618
|
+
} = packageInfo;
|
|
553
619
|
const defaults = Object.freeze({
|
|
554
620
|
children: data => data.children,
|
|
555
621
|
nodeSize: node => node.data.size,
|
|
@@ -1065,7 +1131,7 @@ function mountDom(vnode) {
|
|
|
1065
1131
|
return mount(vnode);
|
|
1066
1132
|
}
|
|
1067
1133
|
|
|
1068
|
-
var css_248z$1 = ".markmap{font:300 16px/20px sans-serif}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign a{color:#0097e6}.markmap-foreign a:hover{color:#00a8ff}.markmap-foreign code{background-color:#f0f0f0;border-radius:2px;color:#555;font-size:calc(1em - 2px)}.markmap-foreign :
|
|
1134
|
+
var css_248z$1 = ".markmap{font:300 16px/20px sans-serif}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign a{color:#0097e6}.markmap-foreign a:hover{color:#00a8ff}.markmap-foreign code{background-color:#f0f0f0;border-radius:2px;color:#555;font-size:calc(1em - 2px);padding:.25em}.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:#ffeaa7}";
|
|
1069
1135
|
|
|
1070
1136
|
var css_248z = ".markmap-container{height:0;left:-100px;overflow:hidden;position:absolute;top:-100px;width:0}.markmap-container>.markmap-foreign{display:inline-block}.markmap-container>.markmap-foreign>div:last-child{white-space:nowrap}";
|
|
1071
1137
|
|
|
@@ -1075,7 +1141,7 @@ function linkWidth(nodeData) {
|
|
|
1075
1141
|
return Math.max(4 - 2 * data.depth, 1.5);
|
|
1076
1142
|
}
|
|
1077
1143
|
function minBy(numbers, by) {
|
|
1078
|
-
const index =
|
|
1144
|
+
const index = d3.minIndex(numbers, by);
|
|
1079
1145
|
return numbers[index];
|
|
1080
1146
|
}
|
|
1081
1147
|
function stopPropagation(e) {
|
|
@@ -1091,7 +1157,7 @@ function createViewHooks() {
|
|
|
1091
1157
|
* A global hook to refresh all markmaps when called.
|
|
1092
1158
|
*/
|
|
1093
1159
|
const refreshHook = new Hook();
|
|
1094
|
-
const defaultColorFn =
|
|
1160
|
+
const defaultColorFn = d3.scaleOrdinal(d3.schemeCategory10);
|
|
1095
1161
|
const isMacintosh = typeof navigator !== 'undefined' && navigator.userAgent.includes('Macintosh');
|
|
1096
1162
|
class Markmap {
|
|
1097
1163
|
constructor(svg, opts) {
|
|
@@ -1105,7 +1171,7 @@ class Markmap {
|
|
|
1105
1171
|
};
|
|
1106
1172
|
this.handlePan = e => {
|
|
1107
1173
|
e.preventDefault();
|
|
1108
|
-
const transform =
|
|
1174
|
+
const transform = d3.zoomTransform(this.svg.node());
|
|
1109
1175
|
const newTransform = transform.translate(-e.deltaX / transform.k, -e.deltaY / transform.k);
|
|
1110
1176
|
this.svg.call(this.zoom.transform, newTransform);
|
|
1111
1177
|
};
|
|
@@ -1115,9 +1181,9 @@ class Markmap {
|
|
|
1115
1181
|
this.toggleNode(d.data, recursive);
|
|
1116
1182
|
};
|
|
1117
1183
|
this.viewHooks = createViewHooks();
|
|
1118
|
-
this.svg = svg.datum ? svg :
|
|
1184
|
+
this.svg = svg.datum ? svg : d3.select(svg);
|
|
1119
1185
|
this.styleNode = this.svg.append('style');
|
|
1120
|
-
this.zoom =
|
|
1186
|
+
this.zoom = d3.zoom().filter(event => {
|
|
1121
1187
|
if (this.options.scrollForPan) {
|
|
1122
1188
|
// Pan with wheels, zoom with ctrl+wheels
|
|
1123
1189
|
if (event.type === 'wheel') return event.ctrlKey && !event.button;
|
|
@@ -1291,11 +1357,11 @@ class Markmap {
|
|
|
1291
1357
|
layout(tree);
|
|
1292
1358
|
const descendants = tree.descendants().reverse();
|
|
1293
1359
|
const links = tree.links();
|
|
1294
|
-
const linkShape =
|
|
1295
|
-
const minX =
|
|
1296
|
-
const maxX =
|
|
1297
|
-
const minY =
|
|
1298
|
-
const maxY =
|
|
1360
|
+
const linkShape = d3.linkHorizontal();
|
|
1361
|
+
const minX = d3.min(descendants, d => d.x - d.xSize / 2);
|
|
1362
|
+
const maxX = d3.max(descendants, d => d.x + d.xSize / 2);
|
|
1363
|
+
const minY = d3.min(descendants, d => d.y);
|
|
1364
|
+
const maxY = d3.max(descendants, d => d.y + d.ySize - spacingHorizontal);
|
|
1299
1365
|
Object.assign(this.state, {
|
|
1300
1366
|
minX,
|
|
1301
1367
|
maxX,
|
|
@@ -1405,7 +1471,7 @@ class Markmap {
|
|
|
1405
1471
|
const naturalWidth = maxY - minY;
|
|
1406
1472
|
const naturalHeight = maxX - minX;
|
|
1407
1473
|
const scale = Math.min(offsetWidth / naturalWidth * fitRatio, offsetHeight / naturalHeight * fitRatio, 2);
|
|
1408
|
-
const initialZoom =
|
|
1474
|
+
const initialZoom = d3.zoomIdentity.translate((offsetWidth - naturalWidth * scale) / 2 - minY * scale, (offsetHeight - naturalHeight * scale) / 2 - minX * scale).scale(scale);
|
|
1409
1475
|
return this.transition(this.svg).call(this.zoom.transform, initialZoom).end().catch(noop);
|
|
1410
1476
|
}
|
|
1411
1477
|
|
|
@@ -1425,7 +1491,7 @@ class Markmap {
|
|
|
1425
1491
|
spacingHorizontal
|
|
1426
1492
|
} = this.options;
|
|
1427
1493
|
const relRect = svgNode.getBoundingClientRect();
|
|
1428
|
-
const transform =
|
|
1494
|
+
const transform = d3.zoomTransform(svgNode);
|
|
1429
1495
|
const [left, right] = [itemData.y, itemData.y + itemData.ySize - spacingHorizontal + 2].map(x => x * transform.k + transform.x);
|
|
1430
1496
|
const [top, bottom] = [itemData.x - itemData.xSize / 2, itemData.x + itemData.xSize / 2].map(y => y * transform.k + transform.y);
|
|
1431
1497
|
// Skip if the node includes or is included in the container.
|
|
@@ -1456,7 +1522,7 @@ class Markmap {
|
|
|
1456
1522
|
} = svgNode.getBoundingClientRect();
|
|
1457
1523
|
const halfWidth = offsetWidth / 2;
|
|
1458
1524
|
const halfHeight = offsetHeight / 2;
|
|
1459
|
-
const transform =
|
|
1525
|
+
const transform = d3.zoomTransform(svgNode);
|
|
1460
1526
|
const newTransform = transform.translate((halfWidth - transform.x) * (1 - scale) / transform.k, (halfHeight - transform.y) * (1 - scale) / transform.k).scale(scale);
|
|
1461
1527
|
return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(noop);
|
|
1462
1528
|
}
|
|
@@ -1508,7 +1574,7 @@ function deriveOptions(jsonOptions) {
|
|
|
1508
1574
|
const solidColor = color[0];
|
|
1509
1575
|
derivedOptions.color = () => solidColor;
|
|
1510
1576
|
} else if (color != null && color.length) {
|
|
1511
|
-
const colorFn =
|
|
1577
|
+
const colorFn = d3.scaleOrdinal(color);
|
|
1512
1578
|
derivedOptions.color = node => colorFn(`${node.state.path}`);
|
|
1513
1579
|
}
|
|
1514
1580
|
if (colorFreezeLevel) {
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
/*! markmap-view v0.14.5-alpha.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var d3 = require('d3');
|
|
6
|
-
|
|
7
|
-
function _interopNamespaceDefault(e) {
|
|
8
|
-
var n = Object.create(null);
|
|
9
|
-
if (e) {
|
|
10
|
-
for (var k in e) {
|
|
11
|
-
n[k] = e[k];
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
n.default = e;
|
|
15
|
-
return Object.freeze(n);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
var d3__namespace = /*#__PURE__*/_interopNamespaceDefault(d3);
|
|
1
|
+
/*! markmap-view v0.14.5-alpha.21+fb81f2c | MIT License */
|
|
2
|
+
import { Hook, getId, addClass, walkTree, childSelector, noop } from 'markmap-common';
|
|
3
|
+
export { loadCSS, loadJS } from 'markmap-common';
|
|
4
|
+
import { scaleOrdinal, schemeCategory10, zoomTransform, select, zoom, linkHorizontal, min, max, zoomIdentity, minIndex } from 'd3';
|
|
19
5
|
|
|
20
6
|
function _extends() {
|
|
21
7
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -242,8 +228,87 @@ Node$1.prototype = hierarchy.prototype = {
|
|
|
242
228
|
copy: node_copy
|
|
243
229
|
};
|
|
244
230
|
|
|
245
|
-
var
|
|
231
|
+
var name = "d3-flextree";
|
|
232
|
+
var version$1 = "2.1.2";
|
|
233
|
+
var main = "build/d3-flextree.js";
|
|
234
|
+
var module = "index";
|
|
235
|
+
var author = {
|
|
236
|
+
name: "Chris Maloney",
|
|
237
|
+
url: "http://chrismaloney.org"
|
|
238
|
+
};
|
|
239
|
+
var description = "Flexible tree layout algorithm that allows for variable node sizes.";
|
|
240
|
+
var keywords = [
|
|
241
|
+
"d3",
|
|
242
|
+
"d3-module",
|
|
243
|
+
"layout",
|
|
244
|
+
"tree",
|
|
245
|
+
"hierarchy",
|
|
246
|
+
"d3-hierarchy",
|
|
247
|
+
"plugin",
|
|
248
|
+
"d3-plugin",
|
|
249
|
+
"infovis",
|
|
250
|
+
"visualization",
|
|
251
|
+
"2d"
|
|
252
|
+
];
|
|
253
|
+
var homepage = "https://github.com/klortho/d3-flextree";
|
|
254
|
+
var license = "WTFPL";
|
|
255
|
+
var repository = {
|
|
256
|
+
type: "git",
|
|
257
|
+
url: "https://github.com/klortho/d3-flextree.git"
|
|
258
|
+
};
|
|
259
|
+
var scripts = {
|
|
260
|
+
clean: "rm -rf build demo test",
|
|
261
|
+
"build:demo": "rollup -c --environment BUILD:demo",
|
|
262
|
+
"build:dev": "rollup -c --environment BUILD:dev",
|
|
263
|
+
"build:prod": "rollup -c --environment BUILD:prod",
|
|
264
|
+
"build:test": "rollup -c --environment BUILD:test",
|
|
265
|
+
build: "rollup -c",
|
|
266
|
+
lint: "eslint index.js src",
|
|
267
|
+
"test:main": "node test/bundle.js",
|
|
268
|
+
"test:browser": "node test/browser-tests.js",
|
|
269
|
+
test: "npm-run-all test:*",
|
|
270
|
+
prepare: "npm-run-all clean build lint test"
|
|
271
|
+
};
|
|
272
|
+
var dependencies = {
|
|
273
|
+
"d3-hierarchy": "^1.1.5"
|
|
274
|
+
};
|
|
275
|
+
var devDependencies = {
|
|
276
|
+
"babel-plugin-external-helpers": "^6.22.0",
|
|
277
|
+
"babel-preset-es2015-rollup": "^3.0.0",
|
|
278
|
+
d3: "^4.13.0",
|
|
279
|
+
"d3-selection-multi": "^1.0.1",
|
|
280
|
+
eslint: "^4.19.1",
|
|
281
|
+
jsdom: "^11.6.2",
|
|
282
|
+
"npm-run-all": "^4.1.2",
|
|
283
|
+
rollup: "^0.55.3",
|
|
284
|
+
"rollup-plugin-babel": "^2.7.1",
|
|
285
|
+
"rollup-plugin-commonjs": "^8.0.2",
|
|
286
|
+
"rollup-plugin-copy": "^0.2.3",
|
|
287
|
+
"rollup-plugin-json": "^2.3.0",
|
|
288
|
+
"rollup-plugin-node-resolve": "^3.0.2",
|
|
289
|
+
"rollup-plugin-uglify": "^3.0.0",
|
|
290
|
+
"uglify-es": "^3.3.9"
|
|
291
|
+
};
|
|
292
|
+
var packageInfo = {
|
|
293
|
+
name: name,
|
|
294
|
+
version: version$1,
|
|
295
|
+
main: main,
|
|
296
|
+
module: module,
|
|
297
|
+
"jsnext:main": "index",
|
|
298
|
+
author: author,
|
|
299
|
+
description: description,
|
|
300
|
+
keywords: keywords,
|
|
301
|
+
homepage: homepage,
|
|
302
|
+
license: license,
|
|
303
|
+
repository: repository,
|
|
304
|
+
scripts: scripts,
|
|
305
|
+
dependencies: dependencies,
|
|
306
|
+
devDependencies: devDependencies
|
|
307
|
+
};
|
|
246
308
|
|
|
309
|
+
const {
|
|
310
|
+
version
|
|
311
|
+
} = packageInfo;
|
|
247
312
|
const defaults = Object.freeze({
|
|
248
313
|
children: data => data.children,
|
|
249
314
|
nodeSize: node => node.data.size,
|
|
@@ -759,7 +824,7 @@ function mountDom(vnode) {
|
|
|
759
824
|
return mount(vnode);
|
|
760
825
|
}
|
|
761
826
|
|
|
762
|
-
var css_248z$1 = ".markmap{font:300 16px/20px sans-serif}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign a{color:#0097e6}.markmap-foreign a:hover{color:#00a8ff}.markmap-foreign code{background-color:#f0f0f0;border-radius:2px;color:#555;font-size:calc(1em - 2px)}.markmap-foreign :
|
|
827
|
+
var css_248z$1 = ".markmap{font:300 16px/20px sans-serif}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign a{color:#0097e6}.markmap-foreign a:hover{color:#00a8ff}.markmap-foreign code{background-color:#f0f0f0;border-radius:2px;color:#555;font-size:calc(1em - 2px);padding:.25em}.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:#ffeaa7}";
|
|
763
828
|
|
|
764
829
|
var css_248z = ".markmap-container{height:0;left:-100px;overflow:hidden;position:absolute;top:-100px;width:0}.markmap-container>.markmap-foreign{display:inline-block}.markmap-container>.markmap-foreign>div:last-child{white-space:nowrap}";
|
|
765
830
|
|
|
@@ -769,7 +834,7 @@ function linkWidth(nodeData) {
|
|
|
769
834
|
return Math.max(4 - 2 * data.depth, 1.5);
|
|
770
835
|
}
|
|
771
836
|
function minBy(numbers, by) {
|
|
772
|
-
const index =
|
|
837
|
+
const index = minIndex(numbers, by);
|
|
773
838
|
return numbers[index];
|
|
774
839
|
}
|
|
775
840
|
function stopPropagation(e) {
|
|
@@ -777,15 +842,15 @@ function stopPropagation(e) {
|
|
|
777
842
|
}
|
|
778
843
|
function createViewHooks() {
|
|
779
844
|
return {
|
|
780
|
-
transformHtml: new
|
|
845
|
+
transformHtml: new Hook()
|
|
781
846
|
};
|
|
782
847
|
}
|
|
783
848
|
|
|
784
849
|
/**
|
|
785
850
|
* A global hook to refresh all markmaps when called.
|
|
786
851
|
*/
|
|
787
|
-
const refreshHook = new
|
|
788
|
-
const defaultColorFn =
|
|
852
|
+
const refreshHook = new Hook();
|
|
853
|
+
const defaultColorFn = scaleOrdinal(schemeCategory10);
|
|
789
854
|
const isMacintosh = typeof navigator !== 'undefined' && navigator.userAgent.includes('Macintosh');
|
|
790
855
|
class Markmap {
|
|
791
856
|
constructor(svg, opts) {
|
|
@@ -799,7 +864,7 @@ class Markmap {
|
|
|
799
864
|
};
|
|
800
865
|
this.handlePan = e => {
|
|
801
866
|
e.preventDefault();
|
|
802
|
-
const transform =
|
|
867
|
+
const transform = zoomTransform(this.svg.node());
|
|
803
868
|
const newTransform = transform.translate(-e.deltaX / transform.k, -e.deltaY / transform.k);
|
|
804
869
|
this.svg.call(this.zoom.transform, newTransform);
|
|
805
870
|
};
|
|
@@ -809,9 +874,9 @@ class Markmap {
|
|
|
809
874
|
this.toggleNode(d.data, recursive);
|
|
810
875
|
};
|
|
811
876
|
this.viewHooks = createViewHooks();
|
|
812
|
-
this.svg = svg.datum ? svg :
|
|
877
|
+
this.svg = svg.datum ? svg : select(svg);
|
|
813
878
|
this.styleNode = this.svg.append('style');
|
|
814
|
-
this.zoom =
|
|
879
|
+
this.zoom = zoom().filter(event => {
|
|
815
880
|
if (this.options.scrollForPan) {
|
|
816
881
|
// Pan with wheels, zoom with ctrl+wheels
|
|
817
882
|
if (event.type === 'wheel') return event.ctrlKey && !event.button;
|
|
@@ -820,7 +885,7 @@ class Markmap {
|
|
|
820
885
|
}).on('zoom', this.handleZoom);
|
|
821
886
|
this.setOptions(opts);
|
|
822
887
|
this.state = {
|
|
823
|
-
id: this.options.id || this.svg.attr('id') ||
|
|
888
|
+
id: this.options.id || this.svg.attr('id') || getId(),
|
|
824
889
|
minX: 0,
|
|
825
890
|
maxX: 0,
|
|
826
891
|
minY: 0,
|
|
@@ -842,7 +907,7 @@ class Markmap {
|
|
|
842
907
|
return [this.options.embedGlobalCSS && css_248z$1, styleText].filter(Boolean).join('\n');
|
|
843
908
|
}
|
|
844
909
|
updateStyle() {
|
|
845
|
-
this.svg.attr('class',
|
|
910
|
+
this.svg.attr('class', addClass(this.svg.attr('class'), 'markmap', this.state.id));
|
|
846
911
|
const style = this.getStyleContent();
|
|
847
912
|
this.styleNode.text(style);
|
|
848
913
|
}
|
|
@@ -851,7 +916,7 @@ class Markmap {
|
|
|
851
916
|
const fold = (_data$payload = data.payload) != null && _data$payload.fold ? 0 : 1;
|
|
852
917
|
if (recursive) {
|
|
853
918
|
// recursively
|
|
854
|
-
|
|
919
|
+
walkTree(data, (item, next) => {
|
|
855
920
|
item.payload = _extends({}, item.payload, {
|
|
856
921
|
fold
|
|
857
922
|
});
|
|
@@ -885,7 +950,7 @@ class Markmap {
|
|
|
885
950
|
document.body.append(container, style);
|
|
886
951
|
const groupStyle = maxWidth ? `max-width: ${maxWidth}px` : '';
|
|
887
952
|
let foldRecursively = 0;
|
|
888
|
-
|
|
953
|
+
walkTree(node, (item, next, parent) => {
|
|
889
954
|
var _item$children, _parent$state, _item$payload;
|
|
890
955
|
item.children = (_item$children = item.children) == null ? void 0 : _item$children.map(child => _extends({}, child));
|
|
891
956
|
nodeId += 1;
|
|
@@ -927,7 +992,7 @@ class Markmap {
|
|
|
927
992
|
var _node$parentNode;
|
|
928
993
|
(_node$parentNode = node.parentNode) == null ? void 0 : _node$parentNode.append(node.cloneNode(true));
|
|
929
994
|
});
|
|
930
|
-
|
|
995
|
+
walkTree(node, (item, next, parent) => {
|
|
931
996
|
var _parent$state2;
|
|
932
997
|
const state = item.state;
|
|
933
998
|
const rect = state.el.getBoundingClientRect();
|
|
@@ -985,11 +1050,11 @@ class Markmap {
|
|
|
985
1050
|
layout(tree);
|
|
986
1051
|
const descendants = tree.descendants().reverse();
|
|
987
1052
|
const links = tree.links();
|
|
988
|
-
const linkShape =
|
|
989
|
-
const minX =
|
|
990
|
-
const maxX =
|
|
991
|
-
const minY =
|
|
992
|
-
const maxY =
|
|
1053
|
+
const linkShape = linkHorizontal();
|
|
1054
|
+
const minX = min(descendants, d => d.x - d.xSize / 2);
|
|
1055
|
+
const maxX = max(descendants, d => d.x + d.xSize / 2);
|
|
1056
|
+
const minY = min(descendants, d => d.y);
|
|
1057
|
+
const maxY = max(descendants, d => d.y + d.ySize - spacingHorizontal);
|
|
993
1058
|
Object.assign(this.state, {
|
|
994
1059
|
minX,
|
|
995
1060
|
maxX,
|
|
@@ -1002,7 +1067,7 @@ class Markmap {
|
|
|
1002
1067
|
const y0 = (_origin$data$state$y = origin.data.state.y0) != null ? _origin$data$state$y : origin.y;
|
|
1003
1068
|
|
|
1004
1069
|
// Update the nodes
|
|
1005
|
-
const node = this.g.selectAll(
|
|
1070
|
+
const node = this.g.selectAll(childSelector('g')).data(descendants, d => d.data.state.key);
|
|
1006
1071
|
const nodeEnter = node.enter().append('g').attr('data-depth', d => d.data.depth).attr('data-path', d => d.data.state.path).attr('transform', d => `translate(${y0 + origin.ySize - d.ySize},${x0 + origin.xSize / 2 - d.xSize})`);
|
|
1007
1072
|
const nodeExit = this.transition(node.exit());
|
|
1008
1073
|
nodeExit.select('line').attr('x1', d => d.ySize - spacingHorizontal).attr('x2', d => d.ySize - spacingHorizontal);
|
|
@@ -1015,13 +1080,13 @@ class Markmap {
|
|
|
1015
1080
|
this.transition(nodeMerge).attr('transform', d => `translate(${d.y},${d.x - d.xSize / 2})`);
|
|
1016
1081
|
|
|
1017
1082
|
// Update lines under the content
|
|
1018
|
-
const line = nodeMerge.selectAll(
|
|
1083
|
+
const line = nodeMerge.selectAll(childSelector('line')).data(d => [d], d => d.data.state.key).join(enter => {
|
|
1019
1084
|
return enter.append('line').attr('x1', d => d.ySize - spacingHorizontal).attr('x2', d => d.ySize - spacingHorizontal);
|
|
1020
1085
|
}, update => update, exit => exit.remove());
|
|
1021
1086
|
this.transition(line).attr('x1', -1).attr('x2', d => d.ySize - spacingHorizontal + 2).attr('y1', d => d.xSize).attr('y2', d => d.xSize).attr('stroke', d => color(d.data)).attr('stroke-width', linkWidth);
|
|
1022
1087
|
|
|
1023
1088
|
// Circle to link to children of the node
|
|
1024
|
-
const circle = nodeMerge.selectAll(
|
|
1089
|
+
const circle = nodeMerge.selectAll(childSelector('circle')).data(d => {
|
|
1025
1090
|
var _d$data$children;
|
|
1026
1091
|
return (_d$data$children = d.data.children) != null && _d$data$children.length ? [d] : [];
|
|
1027
1092
|
}, d => d.data.state.key).join(enter => {
|
|
@@ -1031,7 +1096,7 @@ class Markmap {
|
|
|
1031
1096
|
var _d$data$payload2;
|
|
1032
1097
|
return (_d$data$payload2 = d.data.payload) != null && _d$data$payload2.fold && d.data.children ? color(d.data) : '#fff';
|
|
1033
1098
|
});
|
|
1034
|
-
const foreignObject = nodeMerge.selectAll(
|
|
1099
|
+
const foreignObject = nodeMerge.selectAll(childSelector('foreignObject')).data(d => [d], d => d.data.state.key).join(enter => {
|
|
1035
1100
|
const fo = enter.append('foreignObject').attr('class', 'markmap-foreign').attr('x', paddingX).attr('y', 0).style('opacity', 0).on('mousedown', stopPropagation).on('dblclick', stopPropagation);
|
|
1036
1101
|
fo.append('xhtml:div').select(function select(d) {
|
|
1037
1102
|
const clone = d.data.state.el.cloneNode(true);
|
|
@@ -1043,7 +1108,7 @@ class Markmap {
|
|
|
1043
1108
|
this.transition(foreignObject).style('opacity', 1);
|
|
1044
1109
|
|
|
1045
1110
|
// Update the links
|
|
1046
|
-
const path = this.g.selectAll(
|
|
1111
|
+
const path = this.g.selectAll(childSelector('path')).data(links, d => d.target.data.state.key).join(enter => {
|
|
1047
1112
|
const source = [y0 + origin.ySize - spacingHorizontal, x0 + origin.xSize / 2];
|
|
1048
1113
|
return enter.insert('path', 'g').attr('class', 'markmap-link').attr('data-depth', d => d.target.data.depth).attr('data-path', d => d.target.data.state.path).attr('d', linkShape({
|
|
1049
1114
|
source,
|
|
@@ -1099,8 +1164,8 @@ class Markmap {
|
|
|
1099
1164
|
const naturalWidth = maxY - minY;
|
|
1100
1165
|
const naturalHeight = maxX - minX;
|
|
1101
1166
|
const scale = Math.min(offsetWidth / naturalWidth * fitRatio, offsetHeight / naturalHeight * fitRatio, 2);
|
|
1102
|
-
const initialZoom =
|
|
1103
|
-
return this.transition(this.svg).call(this.zoom.transform, initialZoom).end().catch(
|
|
1167
|
+
const initialZoom = zoomIdentity.translate((offsetWidth - naturalWidth * scale) / 2 - minY * scale, (offsetHeight - naturalHeight * scale) / 2 - minX * scale).scale(scale);
|
|
1168
|
+
return this.transition(this.svg).call(this.zoom.transform, initialZoom).end().catch(noop);
|
|
1104
1169
|
}
|
|
1105
1170
|
|
|
1106
1171
|
/**
|
|
@@ -1108,7 +1173,7 @@ class Markmap {
|
|
|
1108
1173
|
*/
|
|
1109
1174
|
async ensureView(node, padding) {
|
|
1110
1175
|
let itemData;
|
|
1111
|
-
this.g.selectAll(
|
|
1176
|
+
this.g.selectAll(childSelector('g')).each(function walk(d) {
|
|
1112
1177
|
if (d.data === node) {
|
|
1113
1178
|
itemData = d;
|
|
1114
1179
|
}
|
|
@@ -1119,7 +1184,7 @@ class Markmap {
|
|
|
1119
1184
|
spacingHorizontal
|
|
1120
1185
|
} = this.options;
|
|
1121
1186
|
const relRect = svgNode.getBoundingClientRect();
|
|
1122
|
-
const transform =
|
|
1187
|
+
const transform = zoomTransform(svgNode);
|
|
1123
1188
|
const [left, right] = [itemData.y, itemData.y + itemData.ySize - spacingHorizontal + 2].map(x => x * transform.k + transform.x);
|
|
1124
1189
|
const [top, bottom] = [itemData.x - itemData.xSize / 2, itemData.x + itemData.xSize / 2].map(y => y * transform.k + transform.y);
|
|
1125
1190
|
// Skip if the node includes or is included in the container.
|
|
@@ -1135,7 +1200,7 @@ class Markmap {
|
|
|
1135
1200
|
const dy = dys[0] * dys[1] > 0 ? minBy(dys, Math.abs) / transform.k : 0;
|
|
1136
1201
|
if (dx || dy) {
|
|
1137
1202
|
const newTransform = transform.translate(dx, dy);
|
|
1138
|
-
return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(
|
|
1203
|
+
return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(noop);
|
|
1139
1204
|
}
|
|
1140
1205
|
}
|
|
1141
1206
|
|
|
@@ -1150,9 +1215,9 @@ class Markmap {
|
|
|
1150
1215
|
} = svgNode.getBoundingClientRect();
|
|
1151
1216
|
const halfWidth = offsetWidth / 2;
|
|
1152
1217
|
const halfHeight = offsetHeight / 2;
|
|
1153
|
-
const transform =
|
|
1218
|
+
const transform = zoomTransform(svgNode);
|
|
1154
1219
|
const newTransform = transform.translate((halfWidth - transform.x) * (1 - scale) / transform.k, (halfHeight - transform.y) * (1 - scale) / transform.k).scale(scale);
|
|
1155
|
-
return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(
|
|
1220
|
+
return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(noop);
|
|
1156
1221
|
}
|
|
1157
1222
|
destroy() {
|
|
1158
1223
|
this.svg.on('.zoom', null);
|
|
@@ -1202,7 +1267,7 @@ function deriveOptions(jsonOptions) {
|
|
|
1202
1267
|
const solidColor = color[0];
|
|
1203
1268
|
derivedOptions.color = () => solidColor;
|
|
1204
1269
|
} else if (color != null && color.length) {
|
|
1205
|
-
const colorFn =
|
|
1270
|
+
const colorFn = scaleOrdinal(color);
|
|
1206
1271
|
derivedOptions.color = node => colorFn(`${node.state.path}`);
|
|
1207
1272
|
}
|
|
1208
1273
|
if (colorFreezeLevel) {
|
|
@@ -1229,10 +1294,4 @@ function deriveOptions(jsonOptions) {
|
|
|
1229
1294
|
return derivedOptions;
|
|
1230
1295
|
}
|
|
1231
1296
|
|
|
1232
|
-
|
|
1233
|
-
exports.loadJS = markmapCommon.loadJS;
|
|
1234
|
-
exports.Markmap = Markmap;
|
|
1235
|
-
exports.defaultColorFn = defaultColorFn;
|
|
1236
|
-
exports.deriveOptions = deriveOptions;
|
|
1237
|
-
exports.globalCSS = globalCSS;
|
|
1238
|
-
exports.refreshHook = refreshHook;
|
|
1297
|
+
export { Markmap, defaultColorFn, deriveOptions, globalCSS, refreshHook };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-view",
|
|
3
|
-
"version": "0.14.5-alpha.
|
|
3
|
+
"version": "0.14.5-alpha.21+fb81f2c",
|
|
4
4
|
"description": "View markmaps in browser",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,16 +19,17 @@
|
|
|
19
19
|
"url": "git+https://github.com/markmap/markmap.git"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"dev": "rollup -wc
|
|
22
|
+
"dev": "rollup -wc",
|
|
23
23
|
"clean": "del-cli dist types",
|
|
24
|
-
"build:js": "rollup -c
|
|
24
|
+
"build:js": "rollup -c",
|
|
25
25
|
"build:types": "tsc"
|
|
26
26
|
},
|
|
27
27
|
"bugs": {
|
|
28
28
|
"url": "https://github.com/markmap/markmap/issues"
|
|
29
29
|
},
|
|
30
|
+
"type": "module",
|
|
30
31
|
"main": "dist/index.js",
|
|
31
|
-
"module": "dist/index.
|
|
32
|
+
"module": "dist/index.js",
|
|
32
33
|
"unpkg": "dist/browser/index.js",
|
|
33
34
|
"jsdelivr": "dist/browser/index.js",
|
|
34
35
|
"files": [
|
|
@@ -37,18 +38,18 @@
|
|
|
37
38
|
],
|
|
38
39
|
"typings": "types/index.d.ts",
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"@babel/runtime": "^7.
|
|
41
|
-
"@
|
|
42
|
-
"d3": "^
|
|
43
|
-
"d3
|
|
41
|
+
"@babel/runtime": "^7.22.6",
|
|
42
|
+
"@gera2ld/jsx-dom": "^2.2.2",
|
|
43
|
+
"@types/d3": "^7.4.0",
|
|
44
|
+
"d3": "^7.8.5",
|
|
45
|
+
"d3-flextree": "^2.1.2"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
46
|
-
"@gera2ld/jsx-dom": "^2.2.2",
|
|
47
48
|
"@types/d3-flextree": "^2.1.1",
|
|
48
|
-
"markmap-common": "0.14.5-alpha.
|
|
49
|
+
"markmap-common": "0.14.5-alpha.21+fb81f2c"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
52
|
"markmap-common": "*"
|
|
52
53
|
},
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "fb81f2cb688f400f17f911774539267219f639ce"
|
|
54
55
|
}
|
package/types/view.d.ts
CHANGED