markmap-view 0.17.3-alpha.3 → 0.17.3-alpha.4
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 +229 -436
- package/dist/constants.d.ts +1 -1
- package/dist/index.js +438 -614
- package/dist/types.d.ts +7 -6
- package/dist/util.d.ts +4 -0
- package/dist/view.d.ts +11 -14
- package/package.json +5 -5
package/dist/browser/index.js
CHANGED
|
@@ -103,28 +103,28 @@
|
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
/*! @gera2ld/jsx-dom v2.2.2 | ISC License */
|
|
106
|
-
const VTYPE_ELEMENT
|
|
107
|
-
const VTYPE_FUNCTION
|
|
108
|
-
const SVG_NS
|
|
109
|
-
const XLINK_NS
|
|
110
|
-
const NS_ATTRS
|
|
111
|
-
show: XLINK_NS
|
|
112
|
-
actuate: XLINK_NS
|
|
113
|
-
href: XLINK_NS
|
|
106
|
+
const VTYPE_ELEMENT = 1;
|
|
107
|
+
const VTYPE_FUNCTION = 2;
|
|
108
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
109
|
+
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
110
|
+
const NS_ATTRS = {
|
|
111
|
+
show: XLINK_NS,
|
|
112
|
+
actuate: XLINK_NS,
|
|
113
|
+
href: XLINK_NS
|
|
114
114
|
};
|
|
115
|
-
const isLeaf
|
|
116
|
-
const isElement
|
|
117
|
-
const isRenderFunction
|
|
115
|
+
const isLeaf = (c) => typeof c === "string" || typeof c === "number";
|
|
116
|
+
const isElement = (c) => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
|
|
117
|
+
const isRenderFunction = (c) => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
|
|
118
118
|
function h(type, props, ...children) {
|
|
119
119
|
props = Object.assign({}, props, {
|
|
120
120
|
children: children.length === 1 ? children[0] : children
|
|
121
121
|
});
|
|
122
|
-
return jsx
|
|
122
|
+
return jsx(type, props);
|
|
123
123
|
}
|
|
124
|
-
function jsx
|
|
124
|
+
function jsx(type, props) {
|
|
125
125
|
let vtype;
|
|
126
|
-
if (typeof type === "string") vtype = VTYPE_ELEMENT
|
|
127
|
-
else if (typeof type === "function") vtype = VTYPE_FUNCTION
|
|
126
|
+
if (typeof type === "string") vtype = VTYPE_ELEMENT;
|
|
127
|
+
else if (typeof type === "function") vtype = VTYPE_FUNCTION;
|
|
128
128
|
else throw new Error("Invalid VNode type");
|
|
129
129
|
return {
|
|
130
130
|
vtype,
|
|
@@ -132,18 +132,18 @@
|
|
|
132
132
|
props
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
|
-
function Fragment
|
|
135
|
+
function Fragment(props) {
|
|
136
136
|
return props.children;
|
|
137
137
|
}
|
|
138
|
-
const DEFAULT_ENV
|
|
138
|
+
const DEFAULT_ENV = {
|
|
139
139
|
isSvg: false
|
|
140
140
|
};
|
|
141
|
-
function insertDom
|
|
141
|
+
function insertDom(parent, nodes) {
|
|
142
142
|
if (!Array.isArray(nodes)) nodes = [nodes];
|
|
143
143
|
nodes = nodes.filter(Boolean);
|
|
144
144
|
if (nodes.length) parent.append(...nodes);
|
|
145
145
|
}
|
|
146
|
-
function mountAttributes
|
|
146
|
+
function mountAttributes(domElement, props, env) {
|
|
147
147
|
for (const key in props) {
|
|
148
148
|
if (key === "key" || key === "children" || key === "ref") continue;
|
|
149
149
|
if (key === "dangerouslySetInnerHTML") {
|
|
@@ -154,22 +154,22 @@
|
|
|
154
154
|
} else if (key.startsWith("on")) {
|
|
155
155
|
domElement[key.toLowerCase()] = props[key];
|
|
156
156
|
} else {
|
|
157
|
-
setDOMAttribute
|
|
157
|
+
setDOMAttribute(domElement, key, props[key], env.isSvg);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
const attrMap
|
|
161
|
+
const attrMap = {
|
|
162
162
|
className: "class",
|
|
163
163
|
labelFor: "for"
|
|
164
164
|
};
|
|
165
|
-
function setDOMAttribute
|
|
166
|
-
attr = attrMap
|
|
165
|
+
function setDOMAttribute(el, attr, value, isSVG) {
|
|
166
|
+
attr = attrMap[attr] || attr;
|
|
167
167
|
if (value === true) {
|
|
168
168
|
el.setAttribute(attr, "");
|
|
169
169
|
} else if (value === false) {
|
|
170
170
|
el.removeAttribute(attr);
|
|
171
171
|
} else {
|
|
172
|
-
const namespace = isSVG ? NS_ATTRS
|
|
172
|
+
const namespace = isSVG ? NS_ATTRS[attr] : void 0;
|
|
173
173
|
if (namespace !== void 0) {
|
|
174
174
|
el.setAttributeNS(namespace, attr, value);
|
|
175
175
|
} else {
|
|
@@ -177,39 +177,39 @@
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
function flatten
|
|
180
|
+
function flatten(arr) {
|
|
181
181
|
return arr.reduce((prev, item) => prev.concat(item), []);
|
|
182
182
|
}
|
|
183
|
-
function mountChildren
|
|
184
|
-
return Array.isArray(children) ? flatten
|
|
183
|
+
function mountChildren(children, env) {
|
|
184
|
+
return Array.isArray(children) ? flatten(children.map((child) => mountChildren(child, env))) : mount(children, env);
|
|
185
185
|
}
|
|
186
|
-
function mount
|
|
186
|
+
function mount(vnode, env = DEFAULT_ENV) {
|
|
187
187
|
if (vnode == null || typeof vnode === "boolean") {
|
|
188
188
|
return null;
|
|
189
189
|
}
|
|
190
190
|
if (vnode instanceof Node) {
|
|
191
191
|
return vnode;
|
|
192
192
|
}
|
|
193
|
-
if (isRenderFunction
|
|
193
|
+
if (isRenderFunction(vnode)) {
|
|
194
194
|
const {
|
|
195
195
|
type,
|
|
196
196
|
props
|
|
197
197
|
} = vnode;
|
|
198
|
-
if (type === Fragment
|
|
198
|
+
if (type === Fragment) {
|
|
199
199
|
const node = document.createDocumentFragment();
|
|
200
200
|
if (props.children) {
|
|
201
|
-
const children = mountChildren
|
|
202
|
-
insertDom
|
|
201
|
+
const children = mountChildren(props.children, env);
|
|
202
|
+
insertDom(node, children);
|
|
203
203
|
}
|
|
204
204
|
return node;
|
|
205
205
|
}
|
|
206
206
|
const childVNode = type(props);
|
|
207
|
-
return mount
|
|
207
|
+
return mount(childVNode, env);
|
|
208
208
|
}
|
|
209
|
-
if (isLeaf
|
|
209
|
+
if (isLeaf(vnode)) {
|
|
210
210
|
return document.createTextNode(`${vnode}`);
|
|
211
211
|
}
|
|
212
|
-
if (isElement
|
|
212
|
+
if (isElement(vnode)) {
|
|
213
213
|
let node;
|
|
214
214
|
const {
|
|
215
215
|
type,
|
|
@@ -223,9 +223,9 @@
|
|
|
223
223
|
if (!env.isSvg) {
|
|
224
224
|
node = document.createElement(type);
|
|
225
225
|
} else {
|
|
226
|
-
node = document.createElementNS(SVG_NS
|
|
226
|
+
node = document.createElementNS(SVG_NS, type);
|
|
227
227
|
}
|
|
228
|
-
mountAttributes
|
|
228
|
+
mountAttributes(node, props, env);
|
|
229
229
|
if (props.children) {
|
|
230
230
|
let childEnv = env;
|
|
231
231
|
if (env.isSvg && type === "foreignObject") {
|
|
@@ -233,8 +233,8 @@
|
|
|
233
233
|
isSvg: false
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
|
-
const children = mountChildren
|
|
237
|
-
if (children != null) insertDom
|
|
236
|
+
const children = mountChildren(props.children, childEnv);
|
|
237
|
+
if (children != null) insertDom(node, children);
|
|
238
238
|
}
|
|
239
239
|
const {
|
|
240
240
|
ref
|
|
@@ -244,11 +244,11 @@
|
|
|
244
244
|
}
|
|
245
245
|
throw new Error("mount: Invalid Vnode!");
|
|
246
246
|
}
|
|
247
|
-
function mountDom
|
|
248
|
-
return mount
|
|
247
|
+
function mountDom(vnode) {
|
|
248
|
+
return mount(vnode);
|
|
249
249
|
}
|
|
250
250
|
function hm(...args) {
|
|
251
|
-
return mountDom
|
|
251
|
+
return mountDom(h(...args));
|
|
252
252
|
}
|
|
253
253
|
const memoizedPreloadJS = memoize((url) => {
|
|
254
254
|
document.head.append(
|
|
@@ -406,144 +406,12 @@
|
|
|
406
406
|
});
|
|
407
407
|
return derivedOptions;
|
|
408
408
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
414
|
-
const NS_ATTRS = {
|
|
415
|
-
show: XLINK_NS,
|
|
416
|
-
actuate: XLINK_NS,
|
|
417
|
-
href: XLINK_NS
|
|
418
|
-
};
|
|
419
|
-
const isLeaf = (c) => typeof c === "string" || typeof c === "number";
|
|
420
|
-
const isElement = (c) => (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT;
|
|
421
|
-
const isRenderFunction = (c) => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
|
|
422
|
-
function jsx(type, props) {
|
|
423
|
-
let vtype;
|
|
424
|
-
if (typeof type === "string") vtype = VTYPE_ELEMENT;
|
|
425
|
-
else if (typeof type === "function") vtype = VTYPE_FUNCTION;
|
|
426
|
-
else throw new Error("Invalid VNode type");
|
|
427
|
-
return {
|
|
428
|
-
vtype,
|
|
429
|
-
type,
|
|
430
|
-
props
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
function Fragment(props) {
|
|
434
|
-
return props.children;
|
|
435
|
-
}
|
|
436
|
-
const DEFAULT_ENV = {
|
|
437
|
-
isSvg: false
|
|
438
|
-
};
|
|
439
|
-
function insertDom(parent, nodes) {
|
|
440
|
-
if (!Array.isArray(nodes)) nodes = [nodes];
|
|
441
|
-
nodes = nodes.filter(Boolean);
|
|
442
|
-
if (nodes.length) parent.append(...nodes);
|
|
443
|
-
}
|
|
444
|
-
function mountAttributes(domElement, props, env) {
|
|
445
|
-
for (const key in props) {
|
|
446
|
-
if (key === "key" || key === "children" || key === "ref") continue;
|
|
447
|
-
if (key === "dangerouslySetInnerHTML") {
|
|
448
|
-
domElement.innerHTML = props[key].__html;
|
|
449
|
-
} else if (key === "innerHTML" || key === "textContent" || key === "innerText" || key === "value" && ["textarea", "select"].includes(domElement.tagName)) {
|
|
450
|
-
const value = props[key];
|
|
451
|
-
if (value != null) domElement[key] = value;
|
|
452
|
-
} else if (key.startsWith("on")) {
|
|
453
|
-
domElement[key.toLowerCase()] = props[key];
|
|
454
|
-
} else {
|
|
455
|
-
setDOMAttribute(domElement, key, props[key], env.isSvg);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
const attrMap = {
|
|
460
|
-
className: "class",
|
|
461
|
-
labelFor: "for"
|
|
462
|
-
};
|
|
463
|
-
function setDOMAttribute(el, attr, value, isSVG) {
|
|
464
|
-
attr = attrMap[attr] || attr;
|
|
465
|
-
if (value === true) {
|
|
466
|
-
el.setAttribute(attr, "");
|
|
467
|
-
} else if (value === false) {
|
|
468
|
-
el.removeAttribute(attr);
|
|
469
|
-
} else {
|
|
470
|
-
const namespace = isSVG ? NS_ATTRS[attr] : void 0;
|
|
471
|
-
if (namespace !== void 0) {
|
|
472
|
-
el.setAttributeNS(namespace, attr, value);
|
|
473
|
-
} else {
|
|
474
|
-
el.setAttribute(attr, value);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
function flatten(arr) {
|
|
479
|
-
return arr.reduce((prev, item) => prev.concat(item), []);
|
|
480
|
-
}
|
|
481
|
-
function mountChildren(children, env) {
|
|
482
|
-
return Array.isArray(children) ? flatten(children.map((child) => mountChildren(child, env))) : mount(children, env);
|
|
483
|
-
}
|
|
484
|
-
function mount(vnode, env = DEFAULT_ENV) {
|
|
485
|
-
if (vnode == null || typeof vnode === "boolean") {
|
|
486
|
-
return null;
|
|
487
|
-
}
|
|
488
|
-
if (vnode instanceof Node) {
|
|
489
|
-
return vnode;
|
|
490
|
-
}
|
|
491
|
-
if (isRenderFunction(vnode)) {
|
|
492
|
-
const {
|
|
493
|
-
type,
|
|
494
|
-
props
|
|
495
|
-
} = vnode;
|
|
496
|
-
if (type === Fragment) {
|
|
497
|
-
const node = document.createDocumentFragment();
|
|
498
|
-
if (props.children) {
|
|
499
|
-
const children = mountChildren(props.children, env);
|
|
500
|
-
insertDom(node, children);
|
|
501
|
-
}
|
|
502
|
-
return node;
|
|
503
|
-
}
|
|
504
|
-
const childVNode = type(props);
|
|
505
|
-
return mount(childVNode, env);
|
|
409
|
+
function simpleHash(str) {
|
|
410
|
+
let hash = 0;
|
|
411
|
+
for (let i = 0; i < str.length; i++) {
|
|
412
|
+
hash = (hash << 5) - hash + str.charCodeAt(i) | 0;
|
|
506
413
|
}
|
|
507
|
-
|
|
508
|
-
return document.createTextNode(`${vnode}`);
|
|
509
|
-
}
|
|
510
|
-
if (isElement(vnode)) {
|
|
511
|
-
let node;
|
|
512
|
-
const {
|
|
513
|
-
type,
|
|
514
|
-
props
|
|
515
|
-
} = vnode;
|
|
516
|
-
if (!env.isSvg && type === "svg") {
|
|
517
|
-
env = Object.assign({}, env, {
|
|
518
|
-
isSvg: true
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
if (!env.isSvg) {
|
|
522
|
-
node = document.createElement(type);
|
|
523
|
-
} else {
|
|
524
|
-
node = document.createElementNS(SVG_NS, type);
|
|
525
|
-
}
|
|
526
|
-
mountAttributes(node, props, env);
|
|
527
|
-
if (props.children) {
|
|
528
|
-
let childEnv = env;
|
|
529
|
-
if (env.isSvg && type === "foreignObject") {
|
|
530
|
-
childEnv = Object.assign({}, childEnv, {
|
|
531
|
-
isSvg: false
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
const children = mountChildren(props.children, childEnv);
|
|
535
|
-
if (children != null) insertDom(node, children);
|
|
536
|
-
}
|
|
537
|
-
const {
|
|
538
|
-
ref
|
|
539
|
-
} = props;
|
|
540
|
-
if (typeof ref === "function") ref(node);
|
|
541
|
-
return node;
|
|
542
|
-
}
|
|
543
|
-
throw new Error("mount: Invalid Vnode!");
|
|
544
|
-
}
|
|
545
|
-
function mountDom(vnode) {
|
|
546
|
-
return mount(vnode);
|
|
414
|
+
return (hash >>> 0).toString(36);
|
|
547
415
|
}
|
|
548
416
|
function count(node) {
|
|
549
417
|
var sum = 0, children = node.children, i = children && children.length;
|
|
@@ -716,63 +584,15 @@
|
|
|
716
584
|
const version$1 = "2.1.2";
|
|
717
585
|
const main = "build/d3-flextree.js";
|
|
718
586
|
const module = "index";
|
|
719
|
-
const author = {
|
|
720
|
-
name: "Chris Maloney",
|
|
721
|
-
url: "http://chrismaloney.org"
|
|
722
|
-
};
|
|
587
|
+
const author = { "name": "Chris Maloney", "url": "http://chrismaloney.org" };
|
|
723
588
|
const description = "Flexible tree layout algorithm that allows for variable node sizes.";
|
|
724
|
-
const keywords = [
|
|
725
|
-
"d3",
|
|
726
|
-
"d3-module",
|
|
727
|
-
"layout",
|
|
728
|
-
"tree",
|
|
729
|
-
"hierarchy",
|
|
730
|
-
"d3-hierarchy",
|
|
731
|
-
"plugin",
|
|
732
|
-
"d3-plugin",
|
|
733
|
-
"infovis",
|
|
734
|
-
"visualization",
|
|
735
|
-
"2d"
|
|
736
|
-
];
|
|
589
|
+
const keywords = ["d3", "d3-module", "layout", "tree", "hierarchy", "d3-hierarchy", "plugin", "d3-plugin", "infovis", "visualization", "2d"];
|
|
737
590
|
const homepage = "https://github.com/klortho/d3-flextree";
|
|
738
591
|
const license = "WTFPL";
|
|
739
|
-
const repository = {
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
};
|
|
743
|
-
const scripts = {
|
|
744
|
-
clean: "rm -rf build demo test",
|
|
745
|
-
"build:demo": "rollup -c --environment BUILD:demo",
|
|
746
|
-
"build:dev": "rollup -c --environment BUILD:dev",
|
|
747
|
-
"build:prod": "rollup -c --environment BUILD:prod",
|
|
748
|
-
"build:test": "rollup -c --environment BUILD:test",
|
|
749
|
-
build: "rollup -c",
|
|
750
|
-
lint: "eslint index.js src",
|
|
751
|
-
"test:main": "node test/bundle.js",
|
|
752
|
-
"test:browser": "node test/browser-tests.js",
|
|
753
|
-
test: "npm-run-all test:*",
|
|
754
|
-
prepare: "npm-run-all clean build lint test"
|
|
755
|
-
};
|
|
756
|
-
const dependencies = {
|
|
757
|
-
"d3-hierarchy": "^1.1.5"
|
|
758
|
-
};
|
|
759
|
-
const devDependencies = {
|
|
760
|
-
"babel-plugin-external-helpers": "^6.22.0",
|
|
761
|
-
"babel-preset-es2015-rollup": "^3.0.0",
|
|
762
|
-
d3: "^4.13.0",
|
|
763
|
-
"d3-selection-multi": "^1.0.1",
|
|
764
|
-
eslint: "^4.19.1",
|
|
765
|
-
jsdom: "^11.6.2",
|
|
766
|
-
"npm-run-all": "^4.1.2",
|
|
767
|
-
rollup: "^0.55.3",
|
|
768
|
-
"rollup-plugin-babel": "^2.7.1",
|
|
769
|
-
"rollup-plugin-commonjs": "^8.0.2",
|
|
770
|
-
"rollup-plugin-copy": "^0.2.3",
|
|
771
|
-
"rollup-plugin-json": "^2.3.0",
|
|
772
|
-
"rollup-plugin-node-resolve": "^3.0.2",
|
|
773
|
-
"rollup-plugin-uglify": "^3.0.0",
|
|
774
|
-
"uglify-es": "^3.3.9"
|
|
775
|
-
};
|
|
592
|
+
const repository = { "type": "git", "url": "https://github.com/klortho/d3-flextree.git" };
|
|
593
|
+
const scripts = { "clean": "rm -rf build demo test", "build:demo": "rollup -c --environment BUILD:demo", "build:dev": "rollup -c --environment BUILD:dev", "build:prod": "rollup -c --environment BUILD:prod", "build:test": "rollup -c --environment BUILD:test", "build": "rollup -c", "lint": "eslint index.js src", "test:main": "node test/bundle.js", "test:browser": "node test/browser-tests.js", "test": "npm-run-all test:*", "prepare": "npm-run-all clean build lint test" };
|
|
594
|
+
const dependencies = { "d3-hierarchy": "^1.1.5" };
|
|
595
|
+
const devDependencies = { "babel-plugin-external-helpers": "^6.22.0", "babel-preset-es2015-rollup": "^3.0.0", "d3": "^4.13.0", "d3-selection-multi": "^1.0.1", "eslint": "^4.19.1", "jsdom": "^11.6.2", "npm-run-all": "^4.1.2", "rollup": "^0.55.3", "rollup-plugin-babel": "^2.7.1", "rollup-plugin-commonjs": "^8.0.2", "rollup-plugin-copy": "^0.2.3", "rollup-plugin-json": "^2.3.0", "rollup-plugin-node-resolve": "^3.0.2", "rollup-plugin-uglify": "^3.0.0", "uglify-es": "^3.3.9" };
|
|
776
596
|
const packageInfo = {
|
|
777
597
|
name,
|
|
778
598
|
version: version$1,
|
|
@@ -1122,11 +942,10 @@
|
|
|
1122
942
|
next: lastLows
|
|
1123
943
|
};
|
|
1124
944
|
};
|
|
1125
|
-
const
|
|
1126
|
-
const css = "/* Note: wrap with `& { ... }` to preserve the orders, otherwise ungrouped CSS will be put in the end */\n .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 .markmap-link {\n fill: none;\n }\n .markmap-node > circle {\n cursor: pointer;\n }\n .markmap-foreign {\n display: inline-block;\n }\n .markmap-foreign p {\n margin: 0;\n }\n .markmap-foreign a {\n color: var(--markmap-a-color);\n }\n .markmap-foreign a:hover {\n color: var(--markmap-a-hover-color);\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 .markmap-foreign pre {\n margin: 0;\n }\n .markmap-foreign pre > code {\n display: block;\n }\n .markmap-foreign del {\n text-decoration: line-through;\n }\n .markmap-foreign em {\n font-style: italic;\n }\n .markmap-foreign strong {\n font-weight: bold;\n }\n .markmap-foreign mark {\n background: var(--markmap-highlight-bg);\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 .markmap-foreign img {\n display: inline-block;\n }\n .markmap-foreign svg {\n fill: currentColor;\n }\n .markmap-foreign-testing-max {\n max-width: var(--markmap-max-width);\n }\n .markmap-foreign-testing-max img {\n max-width: var(--markmap-max-width);\n max-height: none;\n }\n @media (prefers-color-scheme: dark) {\n .markmap {\n --markmap-code-bg: #1a1b26;\n --markmap-code-color: #ddd;\n --markmap-circle-open-bg: #444;\n --markmap-text-color: #eee;\n }\n }\n";
|
|
945
|
+
const css = ".markmap {\n --markmap-max-width: 9999px;\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 > div {\n width: var(--markmap-max-width);\n }\n\n .markmap-foreign > div > div {\n display: inline-block;\n }\n\n.markmap-dark .markmap {\n --markmap-code-bg: #1a1b26;\n --markmap-code-color: #ddd;\n --markmap-circle-open-bg: #444;\n --markmap-text-color: #eee;\n}\n";
|
|
1127
946
|
const globalCSS = css;
|
|
1128
|
-
|
|
1129
|
-
|
|
947
|
+
const linkShape = d32.linkHorizontal();
|
|
948
|
+
function linkWidth(data) {
|
|
1130
949
|
return Math.max(4 - 2 * data.state.depth, 1.5);
|
|
1131
950
|
}
|
|
1132
951
|
function minBy(numbers, by) {
|
|
@@ -1141,7 +960,6 @@
|
|
|
1141
960
|
constructor(svg, opts) {
|
|
1142
961
|
this.options = defaultOptions;
|
|
1143
962
|
this.revokers = [];
|
|
1144
|
-
this.imgCache = {};
|
|
1145
963
|
this.handleZoom = (e) => {
|
|
1146
964
|
const { transform } = e;
|
|
1147
965
|
this.g.attr("transform", transform);
|
|
@@ -1158,7 +976,7 @@
|
|
|
1158
976
|
this.handleClick = (e, d) => {
|
|
1159
977
|
let recursive = this.options.toggleRecursively;
|
|
1160
978
|
if (isMacintosh ? e.metaKey : e.ctrlKey) recursive = !recursive;
|
|
1161
|
-
this.toggleNode(d
|
|
979
|
+
this.toggleNode(d, recursive);
|
|
1162
980
|
};
|
|
1163
981
|
this.svg = svg.datum ? svg : d32.select(svg);
|
|
1164
982
|
this.styleNode = this.svg.append("style");
|
|
@@ -1171,13 +989,14 @@
|
|
|
1171
989
|
this.setOptions(opts);
|
|
1172
990
|
this.state = {
|
|
1173
991
|
id: this.options.id || this.svg.attr("id") || getId(),
|
|
1174
|
-
|
|
1175
|
-
maxX: 0,
|
|
1176
|
-
minY: 0,
|
|
1177
|
-
maxY: 0
|
|
992
|
+
rect: { x1: 0, y1: 0, x2: 0, y2: 0 }
|
|
1178
993
|
};
|
|
1179
994
|
this.g = this.svg.append("g");
|
|
1180
|
-
this.
|
|
995
|
+
this.observer = new ResizeObserver(
|
|
996
|
+
debounce(() => {
|
|
997
|
+
this.renderData();
|
|
998
|
+
}, 100)
|
|
999
|
+
);
|
|
1181
1000
|
this.revokers.push(
|
|
1182
1001
|
refreshHook.tap(() => {
|
|
1183
1002
|
this.setData();
|
|
@@ -1198,7 +1017,7 @@
|
|
|
1198
1017
|
const style = this.getStyleContent();
|
|
1199
1018
|
this.styleNode.text(style);
|
|
1200
1019
|
}
|
|
1201
|
-
toggleNode(data, recursive = false) {
|
|
1020
|
+
async toggleNode(data, recursive = false) {
|
|
1202
1021
|
var _a, _b;
|
|
1203
1022
|
const fold = ((_a = data.payload) == null ? void 0 : _a.fold) ? 0 : 1;
|
|
1204
1023
|
if (recursive) {
|
|
@@ -1215,47 +1034,34 @@
|
|
|
1215
1034
|
fold: ((_b = data.payload) == null ? void 0 : _b.fold) ? 0 : 1
|
|
1216
1035
|
};
|
|
1217
1036
|
}
|
|
1218
|
-
this.renderData(data);
|
|
1037
|
+
await this.renderData(data);
|
|
1219
1038
|
}
|
|
1220
|
-
|
|
1039
|
+
_initializeData(node) {
|
|
1221
1040
|
let nodeId = 0;
|
|
1222
|
-
const { color,
|
|
1223
|
-
const { id } = this.state;
|
|
1224
|
-
const container = mountDom(
|
|
1225
|
-
/* @__PURE__ */ jsx("div", { className: `markmap-container markmap ${id}-g` })
|
|
1226
|
-
);
|
|
1227
|
-
const style = mountDom(
|
|
1228
|
-
/* @__PURE__ */ jsx("style", { children: [this.getStyleContent(), containerCSS].join("\n") })
|
|
1229
|
-
);
|
|
1230
|
-
document.body.append(container, style);
|
|
1231
|
-
const groupStyle = maxWidth ? `--markmap-max-width: ${maxWidth}px` : "";
|
|
1041
|
+
const { color, initialExpandLevel } = this.options;
|
|
1232
1042
|
let foldRecursively = 0;
|
|
1233
1043
|
let depth = 0;
|
|
1234
1044
|
walkTree(node, (item, next, parent) => {
|
|
1235
|
-
var _a, _b, _c;
|
|
1045
|
+
var _a, _b, _c, _d;
|
|
1236
1046
|
depth += 1;
|
|
1237
1047
|
item.children = (_a = item.children) == null ? void 0 : _a.map((child) => ({ ...child }));
|
|
1238
1048
|
nodeId += 1;
|
|
1239
|
-
const group = mountDom(
|
|
1240
|
-
/* @__PURE__ */ jsx(
|
|
1241
|
-
"div",
|
|
1242
|
-
{
|
|
1243
|
-
className: "markmap-foreign markmap-foreign-testing-max",
|
|
1244
|
-
style: groupStyle,
|
|
1245
|
-
children: /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: item.content } })
|
|
1246
|
-
}
|
|
1247
|
-
)
|
|
1248
|
-
);
|
|
1249
|
-
container.append(group);
|
|
1250
1049
|
item.state = {
|
|
1251
1050
|
...item.state,
|
|
1252
1051
|
depth,
|
|
1253
1052
|
id: nodeId,
|
|
1254
|
-
|
|
1053
|
+
rect: {
|
|
1054
|
+
x: 0,
|
|
1055
|
+
y: 0,
|
|
1056
|
+
width: 0,
|
|
1057
|
+
height: 0
|
|
1058
|
+
},
|
|
1059
|
+
size: [0, 0]
|
|
1255
1060
|
};
|
|
1256
|
-
item.state.
|
|
1061
|
+
item.state.key = [(_b = parent == null ? void 0 : parent.state) == null ? void 0 : _b.id, item.state.id].filter(Boolean).join(".") + simpleHash(item.content);
|
|
1062
|
+
item.state.path = [(_c = parent == null ? void 0 : parent.state) == null ? void 0 : _c.path, item.state.id].filter(Boolean).join(".");
|
|
1257
1063
|
color(item);
|
|
1258
|
-
const isFoldRecursively = ((
|
|
1064
|
+
const isFoldRecursively = ((_d = item.payload) == null ? void 0 : _d.fold) === 2;
|
|
1259
1065
|
if (isFoldRecursively) {
|
|
1260
1066
|
foldRecursively += 1;
|
|
1261
1067
|
} else if (foldRecursively || initialExpandLevel >= 0 && item.state.depth >= initialExpandLevel) {
|
|
@@ -1265,48 +1071,50 @@
|
|
|
1265
1071
|
if (isFoldRecursively) foldRecursively -= 1;
|
|
1266
1072
|
depth -= 1;
|
|
1267
1073
|
});
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
);
|
|
1271
|
-
this.
|
|
1272
|
-
|
|
1074
|
+
}
|
|
1075
|
+
_relayout() {
|
|
1076
|
+
if (!this.state.data) return;
|
|
1077
|
+
this.g.selectAll(childSelector("g")).selectAll(
|
|
1078
|
+
childSelector("foreignObject")
|
|
1079
|
+
).each(function(d) {
|
|
1273
1080
|
var _a;
|
|
1274
|
-
(_a =
|
|
1081
|
+
const el = (_a = this.firstChild) == null ? void 0 : _a.firstChild;
|
|
1082
|
+
const newSize = [el.scrollWidth, el.scrollHeight];
|
|
1083
|
+
d.state.size = newSize;
|
|
1275
1084
|
});
|
|
1276
|
-
|
|
1085
|
+
const { spacingHorizontal, paddingX, spacingVertical } = this.options;
|
|
1086
|
+
const layout = flextree({}).children((d) => {
|
|
1277
1087
|
var _a;
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
];
|
|
1285
|
-
state.key = [(_a = parent == null ? void 0 : parent.state) == null ? void 0 : _a.id, state.id].filter(Boolean).join(".") + // FIXME: find a way to check content hash
|
|
1286
|
-
item.content;
|
|
1287
|
-
next();
|
|
1088
|
+
if (!((_a = d.payload) == null ? void 0 : _a.fold)) return d.children;
|
|
1089
|
+
}).nodeSize((node) => {
|
|
1090
|
+
const [width, height] = node.data.state.size;
|
|
1091
|
+
return [height, width + (width ? paddingX * 2 : 0) + spacingHorizontal];
|
|
1092
|
+
}).spacing((a, b) => {
|
|
1093
|
+
return a.parent === b.parent ? spacingVertical : spacingVertical * 2;
|
|
1288
1094
|
});
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
}
|
|
1095
|
+
const tree = layout.hierarchy(this.state.data);
|
|
1096
|
+
layout(tree);
|
|
1097
|
+
const fnodes = tree.descendants();
|
|
1098
|
+
fnodes.forEach((fnode) => {
|
|
1099
|
+
const node = fnode.data;
|
|
1100
|
+
node.state.rect = {
|
|
1101
|
+
x: fnode.y,
|
|
1102
|
+
y: fnode.x,
|
|
1103
|
+
width: fnode.ySize - spacingHorizontal,
|
|
1104
|
+
height: fnode.xSize
|
|
1105
|
+
};
|
|
1301
1106
|
});
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1107
|
+
this.state.rect = {
|
|
1108
|
+
x1: d32.min(fnodes, (fnode) => fnode.data.state.rect.x) || 0,
|
|
1109
|
+
y1: d32.min(fnodes, (fnode) => fnode.data.state.rect.y) || 0,
|
|
1110
|
+
x2: d32.max(
|
|
1111
|
+
fnodes,
|
|
1112
|
+
(fnode) => fnode.data.state.rect.x + fnode.data.state.rect.width
|
|
1113
|
+
) || 0,
|
|
1114
|
+
y2: d32.max(
|
|
1115
|
+
fnodes,
|
|
1116
|
+
(fnode) => fnode.data.state.rect.y + fnode.data.state.rect.height
|
|
1117
|
+
) || 0
|
|
1310
1118
|
};
|
|
1311
1119
|
}
|
|
1312
1120
|
setOptions(opts) {
|
|
@@ -1325,161 +1133,147 @@
|
|
|
1325
1133
|
this.svg.on("wheel", null);
|
|
1326
1134
|
}
|
|
1327
1135
|
}
|
|
1328
|
-
setData(data, opts) {
|
|
1136
|
+
async setData(data, opts) {
|
|
1329
1137
|
if (opts) this.setOptions(opts);
|
|
1330
1138
|
if (data) this.state.data = data;
|
|
1331
1139
|
if (!this.state.data) return;
|
|
1332
|
-
this.
|
|
1140
|
+
this._initializeData(this.state.data);
|
|
1333
1141
|
this.updateStyle();
|
|
1334
|
-
this.renderData();
|
|
1142
|
+
await this.renderData();
|
|
1335
1143
|
}
|
|
1336
|
-
renderData(originData) {
|
|
1144
|
+
async renderData(originData) {
|
|
1145
|
+
const { paddingX, autoFit, color, maxWidth } = this.options;
|
|
1337
1146
|
if (!this.state.data) return;
|
|
1338
|
-
const
|
|
1339
|
-
|
|
1147
|
+
const nodes = [];
|
|
1148
|
+
walkTree(this.state.data, (item, next) => {
|
|
1340
1149
|
var _a;
|
|
1341
|
-
if (!((_a =
|
|
1342
|
-
|
|
1343
|
-
const [width, height] = node2.data.state.size;
|
|
1344
|
-
return [height, width + (width ? paddingX * 2 : 0) + spacingHorizontal];
|
|
1345
|
-
}).spacing((a, b) => {
|
|
1346
|
-
return a.parent === b.parent ? spacingVertical : spacingVertical * 2;
|
|
1347
|
-
});
|
|
1348
|
-
const tree = layout.hierarchy(this.state.data);
|
|
1349
|
-
layout(tree);
|
|
1350
|
-
const descendants = tree.descendants().reverse();
|
|
1351
|
-
const links = tree.links();
|
|
1352
|
-
const linkShape = d32.linkHorizontal();
|
|
1353
|
-
const minX = d32.min(descendants, (d) => d.x - d.xSize / 2);
|
|
1354
|
-
const maxX = d32.max(descendants, (d) => d.x + d.xSize / 2);
|
|
1355
|
-
const minY = d32.min(descendants, (d) => d.y);
|
|
1356
|
-
const maxY = d32.max(descendants, (d) => d.y + d.ySize - spacingHorizontal);
|
|
1357
|
-
Object.assign(this.state, {
|
|
1358
|
-
minX,
|
|
1359
|
-
maxX,
|
|
1360
|
-
minY,
|
|
1361
|
-
maxY
|
|
1150
|
+
if (!((_a = item.payload) == null ? void 0 : _a.fold)) next();
|
|
1151
|
+
nodes.push(item);
|
|
1362
1152
|
});
|
|
1363
|
-
|
|
1364
|
-
const
|
|
1365
|
-
const
|
|
1366
|
-
const
|
|
1367
|
-
const
|
|
1368
|
-
const
|
|
1369
|
-
"transform",
|
|
1370
|
-
(d) => `translate(${y0 + origin.ySize - d.ySize},${x0 + origin.xSize / 2 - d.xSize})`
|
|
1371
|
-
);
|
|
1372
|
-
const nodeExit = this.transition(node.exit());
|
|
1373
|
-
nodeExit.select("line").attr("x1", (d) => d.ySize - spacingHorizontal).attr("x2", (d) => d.ySize - spacingHorizontal);
|
|
1374
|
-
nodeExit.select("foreignObject").style("opacity", 0);
|
|
1375
|
-
nodeExit.attr(
|
|
1376
|
-
"transform",
|
|
1377
|
-
(d) => `translate(${origin.y + origin.ySize - d.ySize},${origin.x + origin.xSize / 2 - d.xSize})`
|
|
1378
|
-
).remove();
|
|
1379
|
-
const nodeMerge = node.merge(nodeEnter).attr(
|
|
1153
|
+
const origin = originData || this.state.data;
|
|
1154
|
+
const originRect = origin.state.rect;
|
|
1155
|
+
const mmG = this.g.selectAll(childSelector("g")).data(nodes, (d) => d.state.key);
|
|
1156
|
+
const mmGEnter = mmG.enter().append("g").attr("data-depth", (d) => d.state.depth).attr("data-path", (d) => d.state.path);
|
|
1157
|
+
const mmGExit = mmG.exit();
|
|
1158
|
+
const mmGMerge = mmG.merge(mmGEnter).attr(
|
|
1380
1159
|
"class",
|
|
1381
1160
|
(d) => {
|
|
1382
1161
|
var _a;
|
|
1383
|
-
return ["markmap-node", ((_a = d.
|
|
1162
|
+
return ["markmap-node", ((_a = d.payload) == null ? void 0 : _a.fold) && "markmap-fold"].filter(Boolean).join(" ");
|
|
1384
1163
|
}
|
|
1385
1164
|
);
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
(d) =>
|
|
1165
|
+
const mmLine = mmGMerge.selectAll(childSelector("line")).data(
|
|
1166
|
+
(d) => [d],
|
|
1167
|
+
(d) => d.state.key
|
|
1389
1168
|
);
|
|
1390
|
-
const
|
|
1169
|
+
const mmLineEnter = mmLine.enter().append("line");
|
|
1170
|
+
const mmLineExit = mmGExit.selectAll(
|
|
1391
1171
|
childSelector("line")
|
|
1392
|
-
).data(
|
|
1393
|
-
(d) => [d],
|
|
1394
|
-
(d) => d.data.state.key
|
|
1395
|
-
).join(
|
|
1396
|
-
(enter) => {
|
|
1397
|
-
return enter.append("line").attr("x1", (d) => d.ySize - spacingHorizontal).attr("x2", (d) => d.ySize - spacingHorizontal);
|
|
1398
|
-
},
|
|
1399
|
-
(update) => update,
|
|
1400
|
-
(exit) => exit.remove()
|
|
1401
1172
|
);
|
|
1402
|
-
|
|
1403
|
-
const
|
|
1173
|
+
const mmLineMerge = mmLine.merge(mmLineEnter);
|
|
1174
|
+
const mmCircle = mmGMerge.selectAll(
|
|
1404
1175
|
childSelector("circle")
|
|
1405
1176
|
).data(
|
|
1406
1177
|
(d) => {
|
|
1407
1178
|
var _a;
|
|
1408
|
-
return ((_a = d.
|
|
1179
|
+
return ((_a = d.children) == null ? void 0 : _a.length) ? [d] : [];
|
|
1409
1180
|
},
|
|
1410
|
-
(d) => d.
|
|
1181
|
+
(d) => d.state.key
|
|
1411
1182
|
).join(
|
|
1412
1183
|
(enter) => {
|
|
1413
|
-
return enter.append("circle").attr("stroke-width", "1.5").attr("
|
|
1184
|
+
return enter.append("circle").attr("stroke-width", "1.5").attr("r", 0).on("click", (e, d) => this.handleClick(e, d)).on("mousedown", stopPropagation);
|
|
1414
1185
|
},
|
|
1415
1186
|
(update) => update,
|
|
1416
1187
|
(exit) => exit.remove()
|
|
1417
1188
|
);
|
|
1418
|
-
|
|
1189
|
+
const observer = this.observer;
|
|
1190
|
+
const mmFo = mmGMerge.selectAll(childSelector("foreignObject")).data(
|
|
1191
|
+
(d) => [d],
|
|
1192
|
+
(d) => d.state.key
|
|
1193
|
+
);
|
|
1194
|
+
const mmFoEnter = mmFo.enter().append("foreignObject").attr("class", "markmap-foreign").attr("x", paddingX).attr("y", 0).style("opacity", 0).on("mousedown", stopPropagation).on("dblclick", stopPropagation);
|
|
1195
|
+
mmFoEnter.append("xhtml:div").append("xhtml:div").html((d) => d.content).attr("xmlns", "http://www.w3.org/1999/xhtml");
|
|
1196
|
+
mmFoEnter.each(function() {
|
|
1197
|
+
var _a;
|
|
1198
|
+
const el = (_a = this.firstChild) == null ? void 0 : _a.firstChild;
|
|
1199
|
+
observer.observe(el);
|
|
1200
|
+
});
|
|
1201
|
+
const mmFoExit = mmGExit.selectAll(
|
|
1202
|
+
childSelector("foreignObject")
|
|
1203
|
+
);
|
|
1204
|
+
mmFoExit.each(function() {
|
|
1205
|
+
var _a;
|
|
1206
|
+
const el = (_a = this.firstChild) == null ? void 0 : _a.firstChild;
|
|
1207
|
+
observer.unobserve(el);
|
|
1208
|
+
});
|
|
1209
|
+
const mmFoMerge = mmFoEnter.merge(mmFo);
|
|
1210
|
+
const links = nodes.flatMap(
|
|
1211
|
+
(node) => {
|
|
1212
|
+
var _a;
|
|
1213
|
+
return ((_a = node.payload) == null ? void 0 : _a.fold) ? [] : node.children.map((child) => ({ source: node, target: child }));
|
|
1214
|
+
}
|
|
1215
|
+
);
|
|
1216
|
+
const mmPath = this.g.selectAll(childSelector("path")).data(links, (d) => d.target.state.key);
|
|
1217
|
+
const mmPathExit = mmPath.exit();
|
|
1218
|
+
const mmPathEnter = mmPath.enter().insert("path", "g").attr("class", "markmap-link").attr("data-depth", (d) => d.target.state.depth).attr("data-path", (d) => d.target.state.path);
|
|
1219
|
+
const mmPathMerge = mmPathEnter.merge(mmPath);
|
|
1220
|
+
this.svg.style(
|
|
1221
|
+
"--markmap-max-width",
|
|
1222
|
+
maxWidth ? `${maxWidth}px` : null
|
|
1223
|
+
);
|
|
1224
|
+
await new Promise(requestAnimationFrame);
|
|
1225
|
+
this._relayout();
|
|
1226
|
+
this.transition(mmGExit).attr("transform", (d) => {
|
|
1227
|
+
const targetX = originRect.x + originRect.width - d.state.rect.width;
|
|
1228
|
+
const targetY = originRect.y + originRect.height / 2 - d.state.rect.height;
|
|
1229
|
+
return `translate(${targetX},${targetY})`;
|
|
1230
|
+
}).remove();
|
|
1231
|
+
mmGEnter.attr(
|
|
1232
|
+
"transform",
|
|
1233
|
+
(d) => `translate(${originRect.x + originRect.width - d.state.rect.width},${originRect.y + originRect.height / 2 - d.state.rect.height})`
|
|
1234
|
+
);
|
|
1235
|
+
this.transition(mmGMerge).attr(
|
|
1236
|
+
"transform",
|
|
1237
|
+
(d) => `translate(${d.state.rect.x},${d.state.rect.y - d.state.rect.height / 2})`
|
|
1238
|
+
);
|
|
1239
|
+
this.transition(mmLineExit).attr("x1", (d) => d.state.rect.width).attr("x2", (d) => d.state.rect.width);
|
|
1240
|
+
mmLineEnter.attr("x1", (d) => d.state.rect.width).attr("x2", (d) => d.state.rect.width);
|
|
1241
|
+
mmLineMerge.attr("y1", (d) => d.state.rect.height).attr("y2", (d) => d.state.rect.height).attr("stroke", (d) => color(d));
|
|
1242
|
+
this.transition(mmLineMerge).attr("x1", -1).attr("x2", (d) => d.state.rect.width + 2).attr("stroke-width", linkWidth);
|
|
1243
|
+
mmCircle.attr("cx", (d) => d.state.rect.width).attr("cy", (d) => d.state.rect.height).attr("stroke", (d) => color(d)).attr(
|
|
1419
1244
|
"fill",
|
|
1420
1245
|
(d) => {
|
|
1421
1246
|
var _a;
|
|
1422
|
-
return ((_a = d.
|
|
1247
|
+
return ((_a = d.payload) == null ? void 0 : _a.fold) && d.children ? color(d) : "var(--markmap-circle-open-bg)";
|
|
1423
1248
|
}
|
|
1424
1249
|
);
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
).
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
}).attr("xmlns", "http://www.w3.org/1999/xhtml");
|
|
1438
|
-
return fo;
|
|
1439
|
-
},
|
|
1440
|
-
(update) => update,
|
|
1441
|
-
(exit) => exit.remove()
|
|
1442
|
-
).attr(
|
|
1443
|
-
"width",
|
|
1444
|
-
(d) => Math.max(0, d.ySize - spacingHorizontal - paddingX * 2)
|
|
1445
|
-
).attr("height", (d) => d.xSize);
|
|
1446
|
-
this.transition(foreignObject).style("opacity", 1);
|
|
1447
|
-
const path = this.g.selectAll(
|
|
1448
|
-
childSelector("path")
|
|
1449
|
-
).data(links, (d) => d.target.data.state.key).join(
|
|
1450
|
-
(enter) => {
|
|
1451
|
-
const source = [
|
|
1452
|
-
y0 + origin.ySize - spacingHorizontal,
|
|
1453
|
-
x0 + origin.xSize / 2
|
|
1454
|
-
];
|
|
1455
|
-
return enter.insert("path", "g").attr("class", "markmap-link").attr("data-depth", (d) => d.target.data.state.depth).attr("data-path", (d) => d.target.data.state.path).attr("d", linkShape({ source, target: source }));
|
|
1456
|
-
},
|
|
1457
|
-
(update) => update,
|
|
1458
|
-
(exit) => {
|
|
1459
|
-
const source = [
|
|
1460
|
-
origin.y + origin.ySize - spacingHorizontal,
|
|
1461
|
-
origin.x + origin.xSize / 2
|
|
1462
|
-
];
|
|
1463
|
-
return this.transition(exit).attr("d", linkShape({ source, target: source })).remove();
|
|
1464
|
-
}
|
|
1250
|
+
this.transition(mmCircle).attr("r", 6);
|
|
1251
|
+
this.transition(mmFoExit).style("opacity", 0);
|
|
1252
|
+
mmFoMerge.attr("width", (d) => Math.max(0, d.state.rect.width - paddingX * 2)).attr("height", (d) => d.state.rect.height);
|
|
1253
|
+
this.transition(mmFoMerge).style("opacity", 1);
|
|
1254
|
+
const pathOrigin = [
|
|
1255
|
+
originRect.x + originRect.width,
|
|
1256
|
+
originRect.y + originRect.height / 2
|
|
1257
|
+
];
|
|
1258
|
+
this.transition(mmPathExit).attr("d", linkShape({ source: pathOrigin, target: pathOrigin })).remove();
|
|
1259
|
+
mmPathEnter.attr(
|
|
1260
|
+
"d",
|
|
1261
|
+
linkShape({ source: pathOrigin, target: pathOrigin })
|
|
1465
1262
|
);
|
|
1466
|
-
this.transition(
|
|
1263
|
+
this.transition(mmPathMerge).attr("stroke", (d) => color(d.target)).attr("stroke-width", (d) => linkWidth(d.target)).attr("d", (d) => {
|
|
1467
1264
|
const origSource = d.source;
|
|
1468
1265
|
const origTarget = d.target;
|
|
1469
1266
|
const source = [
|
|
1470
|
-
origSource.
|
|
1471
|
-
origSource.
|
|
1267
|
+
origSource.state.rect.x + origSource.state.rect.width,
|
|
1268
|
+
origSource.state.rect.y + origSource.state.rect.height / 2
|
|
1472
1269
|
];
|
|
1473
1270
|
const target = [
|
|
1474
|
-
origTarget.
|
|
1475
|
-
origTarget.
|
|
1271
|
+
origTarget.state.rect.x,
|
|
1272
|
+
origTarget.state.rect.y + origTarget.state.rect.height / 2
|
|
1476
1273
|
];
|
|
1477
1274
|
return linkShape({ source, target });
|
|
1478
1275
|
});
|
|
1479
|
-
|
|
1480
|
-
d.data.state.x0 = d.x;
|
|
1481
|
-
d.data.state.y0 = d.y;
|
|
1482
|
-
});
|
|
1276
|
+
if (autoFit) this.fit();
|
|
1483
1277
|
}
|
|
1484
1278
|
transition(sel) {
|
|
1485
1279
|
const { duration } = this.options;
|
|
@@ -1492,24 +1286,24 @@
|
|
|
1492
1286
|
const svgNode = this.svg.node();
|
|
1493
1287
|
const { width: offsetWidth, height: offsetHeight } = svgNode.getBoundingClientRect();
|
|
1494
1288
|
const { fitRatio } = this.options;
|
|
1495
|
-
const {
|
|
1496
|
-
const naturalWidth =
|
|
1497
|
-
const naturalHeight =
|
|
1289
|
+
const { x1, y1, x2, y2 } = this.state.rect;
|
|
1290
|
+
const naturalWidth = x2 - x1;
|
|
1291
|
+
const naturalHeight = y2 - y1;
|
|
1498
1292
|
const scale = Math.min(
|
|
1499
1293
|
offsetWidth / naturalWidth * fitRatio,
|
|
1500
1294
|
offsetHeight / naturalHeight * fitRatio,
|
|
1501
1295
|
maxScale
|
|
1502
1296
|
);
|
|
1503
1297
|
const initialZoom = d32.zoomIdentity.translate(
|
|
1504
|
-
(offsetWidth - naturalWidth * scale) / 2 -
|
|
1505
|
-
(offsetHeight - naturalHeight * scale) / 2 -
|
|
1298
|
+
(offsetWidth - naturalWidth * scale) / 2 - x1 * scale,
|
|
1299
|
+
(offsetHeight - naturalHeight * scale) / 2 - y1 * scale
|
|
1506
1300
|
).scale(scale);
|
|
1507
1301
|
return this.transition(this.svg).call(this.zoom.transform, initialZoom).end().catch(noop);
|
|
1508
1302
|
}
|
|
1509
1303
|
findElement(node) {
|
|
1510
1304
|
let result;
|
|
1511
1305
|
this.g.selectAll(childSelector("g")).each(function walk(d) {
|
|
1512
|
-
if (d
|
|
1306
|
+
if (d === node) {
|
|
1513
1307
|
result = {
|
|
1514
1308
|
data: d,
|
|
1515
1309
|
g: this
|
|
@@ -1526,16 +1320,15 @@
|
|
|
1526
1320
|
const itemData = (_a = this.findElement(node)) == null ? void 0 : _a.data;
|
|
1527
1321
|
if (!itemData) return;
|
|
1528
1322
|
const svgNode = this.svg.node();
|
|
1529
|
-
const { spacingHorizontal } = this.options;
|
|
1530
1323
|
const relRect = svgNode.getBoundingClientRect();
|
|
1531
1324
|
const transform = d32.zoomTransform(svgNode);
|
|
1532
1325
|
const [left, right] = [
|
|
1533
|
-
itemData.
|
|
1534
|
-
itemData.
|
|
1326
|
+
itemData.state.rect.x,
|
|
1327
|
+
itemData.state.rect.x + itemData.state.rect.width + 2
|
|
1535
1328
|
].map((x) => x * transform.k + transform.x);
|
|
1536
1329
|
const [top, bottom] = [
|
|
1537
|
-
itemData.
|
|
1538
|
-
itemData.
|
|
1330
|
+
itemData.state.rect.y - itemData.state.rect.height / 2,
|
|
1331
|
+
itemData.state.rect.y + itemData.state.rect.height / 2
|
|
1539
1332
|
].map((y) => y * transform.k + transform.y);
|
|
1540
1333
|
const pd = {
|
|
1541
1334
|
left: 0,
|
|
@@ -1578,8 +1371,7 @@
|
|
|
1578
1371
|
static create(svg, opts, data = null) {
|
|
1579
1372
|
const mm = new Markmap(svg, opts);
|
|
1580
1373
|
if (data) {
|
|
1581
|
-
mm.setData(data)
|
|
1582
|
-
requestAnimationFrame(() => {
|
|
1374
|
+
mm.setData(data).then(() => {
|
|
1583
1375
|
mm.fit();
|
|
1584
1376
|
});
|
|
1585
1377
|
}
|
|
@@ -1595,5 +1387,6 @@
|
|
|
1595
1387
|
exports.loadCSS = loadCSS;
|
|
1596
1388
|
exports.loadJS = loadJS;
|
|
1597
1389
|
exports.refreshHook = refreshHook;
|
|
1390
|
+
exports.simpleHash = simpleHash;
|
|
1598
1391
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1599
1392
|
})(this.markmap = this.markmap || {}, d3);
|