markmap-view
Advanced tools
Comparing version 0.14.4 to 0.14.5-alpha.13
@@ -1,7 +0,8 @@ | ||
/*! markmap-view v0.14.4 | MIT License */ | ||
(function (exports, d3) { | ||
/*! markmap-view v0.14.5-alpha.13+50ca560 | MIT License */ | ||
'use strict'; | ||
function _interopNamespace(e) { | ||
if (e && e.__esModule) return e; | ||
var markmapCommon = require('markmap-common'); | ||
var d3 = require('d3'); | ||
function _interopNamespaceDefault(e) { | ||
var n = Object.create(null); | ||
@@ -13,218 +14,12 @@ if (e) { | ||
} | ||
n["default"] = e; | ||
n.default = e; | ||
return Object.freeze(n); | ||
} | ||
var d3__namespace = /*#__PURE__*/_interopNamespace(d3); | ||
var d3__namespace = /*#__PURE__*/_interopNamespaceDefault(d3); | ||
/*! markmap-common v0.14.2 | MIT License */ | ||
class Hook { | ||
constructor() { | ||
this.listeners = []; | ||
} | ||
tap(fn) { | ||
this.listeners.push(fn); | ||
return () => this.revoke(fn); | ||
} | ||
revoke(fn) { | ||
const i = this.listeners.indexOf(fn); | ||
if (i >= 0) this.listeners.splice(i, 1); | ||
} | ||
revokeAll() { | ||
this.listeners.splice(0); | ||
} | ||
call(...args) { | ||
for (const fn of this.listeners) { | ||
fn(...args); | ||
} | ||
} | ||
} | ||
function _extends$1() { | ||
_extends$1 = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends$1.apply(this, arguments); | ||
} | ||
const uniqId = Math.random().toString(36).slice(2, 8); | ||
let globalIndex = 0; | ||
function getId() { | ||
globalIndex += 1; | ||
return `mm-${uniqId}-${globalIndex}`; | ||
} | ||
function noop() {// noop | ||
} | ||
function walkTree(tree, callback, key = 'children') { | ||
const walk = (item, parent) => callback(item, () => { | ||
var _item$key; | ||
(_item$key = item[key]) == null ? void 0 : _item$key.forEach(child => { | ||
walk(child, item); | ||
}); | ||
}, parent); | ||
walk(tree); | ||
} | ||
function arrayFrom(arrayLike) { | ||
if (Array.from) return Array.from(arrayLike); | ||
const array = []; | ||
for (let i = 0; i < arrayLike.length; i += 1) { | ||
array.push(arrayLike[i]); | ||
} | ||
return array; | ||
} | ||
function addClass(className, ...rest) { | ||
const classList = (className || '').split(' ').filter(Boolean); | ||
rest.forEach(item => { | ||
if (item && classList.indexOf(item) < 0) classList.push(item); | ||
}); | ||
return classList.join(' '); | ||
} | ||
function childSelector(filter) { | ||
if (typeof filter === 'string') { | ||
const tagName = filter; | ||
filter = el => el.tagName === tagName; | ||
} | ||
const filterFn = filter; | ||
return function selector() { | ||
let nodes = arrayFrom(this.childNodes); | ||
if (filterFn) nodes = nodes.filter(node => filterFn(node)); | ||
return nodes; | ||
}; | ||
} | ||
function memoize(fn) { | ||
const cache = {}; | ||
return function memoized(...args) { | ||
const key = `${args[0]}`; | ||
let data = cache[key]; | ||
if (!data) { | ||
data = { | ||
value: fn(...args) | ||
}; | ||
cache[key] = data; | ||
} | ||
return data.value; | ||
}; | ||
} | ||
function createElement(tagName, props, attrs) { | ||
const el = document.createElement(tagName); | ||
if (props) { | ||
Object.entries(props).forEach(([key, value]) => { | ||
el[key] = value; | ||
}); | ||
} | ||
if (attrs) { | ||
Object.entries(attrs).forEach(([key, value]) => { | ||
el.setAttribute(key, value); | ||
}); | ||
} | ||
return el; | ||
} | ||
const memoizedPreloadJS = memoize(url => { | ||
document.head.append(createElement('link', { | ||
rel: 'preload', | ||
as: 'script', | ||
href: url | ||
})); | ||
}); | ||
async function loadJSItem(item, context) { | ||
if (!item.loaded) { | ||
if (item.type === 'script') { | ||
item.loaded = new Promise((resolve, reject) => { | ||
var _item$data; | ||
document.head.append(createElement('script', _extends$1({}, item.data, { | ||
onload: resolve, | ||
onerror: reject | ||
}))); // Run inline script synchronously | ||
if (!((_item$data = item.data) != null && _item$data.src)) resolve(undefined); | ||
}).then(() => { | ||
item.loaded = true; | ||
}); | ||
} | ||
if (item.type === 'iife') { | ||
const { | ||
fn, | ||
getParams | ||
} = item.data; | ||
fn(...((getParams == null ? void 0 : getParams(context)) || [])); | ||
item.loaded = true; | ||
} | ||
} | ||
await item.loaded; | ||
} | ||
function loadCSSItem(item) { | ||
if (item.loaded) return; | ||
item.loaded = true; | ||
if (item.type === 'style') { | ||
document.head.append(createElement('style', { | ||
textContent: item.data | ||
})); | ||
} else if (item.type === 'stylesheet') { | ||
document.head.append(createElement('link', _extends$1({ | ||
rel: 'stylesheet' | ||
}, item.data))); | ||
} | ||
} | ||
async function loadJS(items, context) { | ||
const needPreload = items.filter(item => { | ||
var _item$data2; | ||
return item.type === 'script' && ((_item$data2 = item.data) == null ? void 0 : _item$data2.src); | ||
}); | ||
if (needPreload.length > 1) needPreload.forEach(item => memoizedPreloadJS(item.data.src)); | ||
context = _extends$1({ | ||
getMarkmap: () => window.markmap | ||
}, context); | ||
for (const item of items) { | ||
await loadJSItem(item, context); | ||
} | ||
} | ||
function loadCSS(items) { | ||
for (const item of items) { | ||
loadCSSItem(item); | ||
} | ||
} | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
@@ -236,6 +31,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -246,8 +39,7 @@ } | ||
var sum = 0, | ||
children = node.children, | ||
i = children && children.length; | ||
children = node.children, | ||
i = children && children.length; | ||
if (!i) sum = 1;else while (--i >= 0) sum += children[i].value; | ||
node.value = sum; | ||
} | ||
function node_count () { | ||
@@ -259,11 +51,9 @@ return this.eachAfter(count); | ||
var node = this, | ||
current, | ||
next = [node], | ||
children, | ||
i, | ||
n; | ||
current, | ||
next = [node], | ||
children, | ||
i, | ||
n; | ||
do { | ||
current = next.reverse(), next = []; | ||
while (node = current.pop()) { | ||
@@ -276,3 +66,2 @@ callback(node), children = node.children; | ||
} while (next.length); | ||
return this; | ||
@@ -283,6 +72,5 @@ } | ||
var node = this, | ||
nodes = [node], | ||
children, | ||
i; | ||
nodes = [node], | ||
children, | ||
i; | ||
while (node = nodes.pop()) { | ||
@@ -294,3 +82,2 @@ callback(node), children = node.children; | ||
} | ||
return this; | ||
@@ -301,8 +88,7 @@ } | ||
var node = this, | ||
nodes = [node], | ||
next = [], | ||
children, | ||
i, | ||
n; | ||
nodes = [node], | ||
next = [], | ||
children, | ||
i, | ||
n; | ||
while (node = nodes.pop()) { | ||
@@ -314,7 +100,5 @@ next.push(node), children = node.children; | ||
} | ||
while (node = next.pop()) { | ||
callback(node); | ||
} | ||
return this; | ||
@@ -326,7 +110,5 @@ } | ||
var sum = +value(node.data) || 0, | ||
children = node.children, | ||
i = children && children.length; | ||
children = node.children, | ||
i = children && children.length; | ||
while (--i >= 0) sum += children[i].value; | ||
node.value = sum; | ||
@@ -346,5 +128,4 @@ }); | ||
var start = this, | ||
ancestor = leastCommonAncestor(start, end), | ||
nodes = [start]; | ||
ancestor = leastCommonAncestor(start, end), | ||
nodes = [start]; | ||
while (start !== ancestor) { | ||
@@ -354,5 +135,3 @@ start = start.parent; | ||
} | ||
var k = nodes.length; | ||
while (end !== ancestor) { | ||
@@ -362,14 +141,11 @@ nodes.splice(k, 0, end); | ||
} | ||
return nodes; | ||
} | ||
function leastCommonAncestor(a, b) { | ||
if (a === b) return a; | ||
var aNodes = a.ancestors(), | ||
bNodes = b.ancestors(), | ||
c = null; | ||
bNodes = b.ancestors(), | ||
c = null; | ||
a = aNodes.pop(); | ||
b = bNodes.pop(); | ||
while (a === b) { | ||
@@ -380,3 +156,2 @@ c = a; | ||
} | ||
return c; | ||
@@ -387,8 +162,6 @@ } | ||
var node = this, | ||
nodes = [node]; | ||
nodes = [node]; | ||
while (node = node.parent) { | ||
nodes.push(node); | ||
} | ||
return nodes; | ||
@@ -417,3 +190,3 @@ } | ||
var root = this, | ||
links = []; | ||
links = []; | ||
root.each(function (node) { | ||
@@ -433,17 +206,14 @@ if (node !== root) { | ||
var root = new Node$1(data), | ||
valued = +data.value && (root.value = data.value), | ||
node, | ||
nodes = [root], | ||
child, | ||
childs, | ||
i, | ||
n; | ||
valued = +data.value && (root.value = data.value), | ||
node, | ||
nodes = [root], | ||
child, | ||
childs, | ||
i, | ||
n; | ||
if (children == null) children = defaultChildren; | ||
while (node = nodes.pop()) { | ||
if (valued) node.value = +node.data.value; | ||
if ((childs = children(node.data)) && (n = childs.length)) { | ||
node.children = new Array(n); | ||
for (i = n - 1; i >= 0; --i) { | ||
@@ -456,21 +226,15 @@ nodes.push(child = node.children[i] = new Node$1(childs[i])); | ||
} | ||
return root.eachBefore(computeHeight); | ||
} | ||
function node_copy() { | ||
return hierarchy(this).eachBefore(copyData); | ||
} | ||
function defaultChildren(d) { | ||
return d.children; | ||
} | ||
function copyData(node) { | ||
node.data = node.data.data; | ||
} | ||
function computeHeight(node) { | ||
var height = 0; | ||
do node.height = height; while ((node = node.parent) && node.height < ++height); | ||
@@ -499,83 +263,4 @@ } | ||
var name = "d3-flextree"; | ||
var version$1 = "2.1.2"; | ||
var main = "build/d3-flextree.js"; | ||
var module = "index"; | ||
var author = { | ||
name: "Chris Maloney", | ||
url: "http://chrismaloney.org" | ||
}; | ||
var description = "Flexible tree layout algorithm that allows for variable node sizes."; | ||
var keywords = [ | ||
"d3", | ||
"d3-module", | ||
"layout", | ||
"tree", | ||
"hierarchy", | ||
"d3-hierarchy", | ||
"plugin", | ||
"d3-plugin", | ||
"infovis", | ||
"visualization", | ||
"2d" | ||
]; | ||
var homepage = "https://github.com/klortho/d3-flextree"; | ||
var license = "WTFPL"; | ||
var repository = { | ||
type: "git", | ||
url: "https://github.com/klortho/d3-flextree.git" | ||
}; | ||
var 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" | ||
}; | ||
var dependencies = { | ||
"d3-hierarchy": "^1.1.5" | ||
}; | ||
var 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" | ||
}; | ||
var packageInfo = { | ||
name: name, | ||
version: version$1, | ||
main: main, | ||
module: module, | ||
"jsnext:main": "index", | ||
author: author, | ||
description: description, | ||
keywords: keywords, | ||
homepage: homepage, | ||
license: license, | ||
repository: repository, | ||
scripts: scripts, | ||
dependencies: dependencies, | ||
devDependencies: devDependencies | ||
}; | ||
var version = "2.1.1"; | ||
const { | ||
version | ||
} = packageInfo; | ||
const defaults = Object.freeze({ | ||
@@ -585,10 +270,10 @@ children: data => data.children, | ||
spacing: 0 | ||
}); // Create a layout function with customizable options. Per D3-style, the | ||
}); | ||
// Create a layout function with customizable options. Per D3-style, the | ||
// options can be set at any time using setter methods. The layout function | ||
// will compute the tree node positions based on the options in effect at the | ||
// time it is called. | ||
function flextree(options) { | ||
const opts = Object.assign({}, defaults, options); | ||
function accessor(name) { | ||
@@ -598,3 +283,2 @@ const opt = opts[name]; | ||
} | ||
function layout(tree) { | ||
@@ -605,3 +289,2 @@ const wtree = wrap(getWrapper(), tree, node => node.children); | ||
} | ||
function getFlexNode() { | ||
@@ -614,3 +297,2 @@ const nodeSize = accessor('nodeSize'); | ||
} | ||
copy() { | ||
@@ -621,39 +303,29 @@ const c = wrap(this.constructor, this, node => node.children); | ||
} | ||
get size() { | ||
return nodeSize(this); | ||
} | ||
spacing(oNode) { | ||
return spacing(this, oNode); | ||
} | ||
get nodes() { | ||
return this.descendants(); | ||
} | ||
get xSize() { | ||
return this.size[0]; | ||
} | ||
get ySize() { | ||
return this.size[1]; | ||
} | ||
get top() { | ||
return this.y; | ||
} | ||
get bottom() { | ||
return this.y + this.ySize; | ||
} | ||
get left() { | ||
return this.x - this.xSize / 2; | ||
} | ||
get right() { | ||
return this.x + this.xSize / 2; | ||
} | ||
get root() { | ||
@@ -663,27 +335,20 @@ const ancs = this.ancestors(); | ||
} | ||
get numChildren() { | ||
return this.hasChildren ? this.children.length : 0; | ||
} | ||
get hasChildren() { | ||
return !this.noChildren; | ||
} | ||
get noChildren() { | ||
return this.children === null; | ||
} | ||
get firstChild() { | ||
return this.hasChildren ? this.children[0] : null; | ||
} | ||
get lastChild() { | ||
return this.hasChildren ? this.children[this.numChildren - 1] : null; | ||
} | ||
get extents() { | ||
return (this.children || []).reduce((acc, kid) => FlexNode.maxExtents(acc, kid.extents), this.nodeExtents); | ||
} | ||
get nodeExtents() { | ||
@@ -697,3 +362,2 @@ return { | ||
} | ||
static maxExtents(e0, e1) { | ||
@@ -707,6 +371,4 @@ return { | ||
} | ||
}; | ||
} | ||
function getWrapper() { | ||
@@ -734,27 +396,20 @@ const FlexNode = getFlexNode(); | ||
} | ||
get size() { | ||
return nodeSize(this.data); | ||
} | ||
spacing(oNode) { | ||
return spacing(this.data, oNode.data); | ||
} | ||
get x() { | ||
return this.data.x; | ||
} | ||
set x(v) { | ||
this.data.x = v; | ||
} | ||
get y() { | ||
return this.data.y; | ||
} | ||
set y(v) { | ||
this.data.y = v; | ||
} | ||
update() { | ||
@@ -765,6 +420,4 @@ layoutChildren(this); | ||
} | ||
}; | ||
} | ||
function wrap(FlexClass, treeData, children) { | ||
@@ -781,3 +434,2 @@ const _wrap = (data, parent) => { | ||
node.children = kidsData.length === 0 ? null : kidsData.map(kd => _wrap(kd, node)); | ||
if (node.children) { | ||
@@ -789,9 +441,6 @@ Object.assign(node, node.children.reduce((hl, kid) => ({ | ||
} | ||
return node; | ||
}; | ||
return _wrap(treeData, null); | ||
} | ||
Object.assign(layout, { | ||
@@ -801,11 +450,8 @@ nodeSize(arg) { | ||
}, | ||
spacing(arg) { | ||
return arguments.length ? (opts.spacing = arg, layout) : opts.spacing; | ||
}, | ||
children(arg) { | ||
return arguments.length ? (opts.children = arg, layout) : opts.children; | ||
}, | ||
hierarchy(treeData, children) { | ||
@@ -815,6 +461,4 @@ const kids = typeof children === 'undefined' ? opts.children : children; | ||
}, | ||
dump(tree) { | ||
const nodeSize = accessor('nodeSize'); | ||
const _dump = i0 => node => { | ||
@@ -832,6 +476,4 @@ const i1 = i0 + ' '; | ||
}; | ||
return _dump('\n')(tree); | ||
} | ||
}); | ||
@@ -841,3 +483,2 @@ return layout; | ||
flextree.version = version; | ||
const layoutChildren = (w, y = 0) => { | ||
@@ -847,5 +488,5 @@ w.y = y; | ||
const [i, lastLows] = acc; | ||
layoutChildren(kid, w.y + w.ySize); // The lowest vertical coordinate while extreme nodes still point | ||
layoutChildren(kid, w.y + w.ySize); | ||
// The lowest vertical coordinate while extreme nodes still point | ||
// in current subtree. | ||
const lowY = (i === 0 ? kid.lExt : kid.rExt).bottom; | ||
@@ -859,8 +500,8 @@ if (i !== 0) separate(w, i, lastLows); | ||
return w; | ||
}; // Resolves the relative coordinate properties - relX and prelim -- | ||
}; | ||
// Resolves the relative coordinate properties - relX and prelim -- | ||
// to set the final, absolute x coordinate for each node. This also sets | ||
// `prelim` to 0, so that `relX` for each node is its x-coordinate relative | ||
// to its parent. | ||
const resolveX = (w, prevSum, parentX) => { | ||
@@ -873,3 +514,2 @@ // A call to resolveX without arguments is assumed to be for the root of | ||
} | ||
const sum = prevSum + w.relX; | ||
@@ -881,6 +521,6 @@ w.relX = sum + w.prelim - parentX; | ||
return w; | ||
}; // Process shift and change for all children, to add intermediate spacing to | ||
}; | ||
// Process shift and change for all children, to add intermediate spacing to | ||
// each child's modifier. | ||
const shiftChange = w => { | ||
@@ -894,7 +534,6 @@ (w.children || []).reduce((acc, child) => { | ||
}, [0, 0]); | ||
}; // Separates the latest child from its previous sibling | ||
}; | ||
// Separates the latest child from its previous sibling | ||
/* eslint-disable complexity */ | ||
const separate = (w, i, lows) => { | ||
@@ -908,22 +547,18 @@ const lSib = w.children[i - 1]; | ||
let isFirst = true; | ||
while (rContour && lContour) { | ||
if (rContour.bottom > lows.lowY) lows = lows.next; // How far to the left of the right side of rContour is the left side | ||
if (rContour.bottom > lows.lowY) lows = lows.next; | ||
// How far to the left of the right side of rContour is the left side | ||
// of lContour? First compute the center-to-center distance, then add | ||
// the "spacing" | ||
const dist = rSumMods + rContour.prelim - (lSumMods + lContour.prelim) + rContour.xSize / 2 + lContour.xSize / 2 + rContour.spacing(lContour); | ||
if (dist > 0 || dist < 0 && isFirst) { | ||
lSumMods += dist; // Move subtree by changing relX. | ||
lSumMods += dist; | ||
// Move subtree by changing relX. | ||
moveSubtree(curSubtree, dist); | ||
distributeExtra(w, i, lows.index, dist); | ||
} | ||
isFirst = false; // Advance highest node(s) and sum(s) of modifiers | ||
isFirst = false; | ||
// Advance highest node(s) and sum(s) of modifiers | ||
const rightBottom = rContour.bottom; | ||
const leftBottom = lContour.bottom; | ||
if (rightBottom <= leftBottom) { | ||
@@ -933,3 +568,2 @@ rContour = nextRContour(rContour); | ||
} | ||
if (rightBottom >= leftBottom) { | ||
@@ -939,13 +573,12 @@ lContour = nextLContour(lContour); | ||
} | ||
} // Set threads and update extreme nodes. In the first case, the | ||
} | ||
// Set threads and update extreme nodes. In the first case, the | ||
// current subtree is taller than the left siblings. | ||
if (!rContour && lContour) setLThr(w, i, lContour, lSumMods); // In the next case, the left siblings are taller than the current subtree | ||
if (!rContour && lContour) setLThr(w, i, lContour, lSumMods); | ||
// In the next case, the left siblings are taller than the current subtree | ||
else if (rContour && !lContour) setRThr(w, i, rContour, rSumMods); | ||
}; | ||
/* eslint-enable complexity */ | ||
// Move subtree by changing relX. | ||
const moveSubtree = (subtree, distance) => { | ||
@@ -956,7 +589,6 @@ subtree.relX += distance; | ||
}; | ||
const distributeExtra = (w, curSubtreeI, leftSibI, dist) => { | ||
const curSubtree = w.children[curSubtreeI]; | ||
const n = curSubtreeI - leftSibI; // Are there intermediate children? | ||
const n = curSubtreeI - leftSibI; | ||
// Are there intermediate children? | ||
if (n > 1) { | ||
@@ -969,11 +601,8 @@ const delta = dist / n; | ||
}; | ||
const nextLContour = w => { | ||
return w.hasChildren ? w.firstChild : w.lThr; | ||
}; | ||
const nextRContour = w => { | ||
return w.hasChildren ? w.lastChild : w.rThr; | ||
}; | ||
const setLThr = (w, i, lContour, lSumMods) => { | ||
@@ -983,14 +612,14 @@ const firstChild = w.firstChild; | ||
const curSubtree = w.children[i]; | ||
lExt.lThr = lContour; // Change relX so that the sum of modifier after following thread is correct. | ||
lExt.lThr = lContour; | ||
// Change relX so that the sum of modifier after following thread is correct. | ||
const diff = lSumMods - lContour.relX - firstChild.lExtRelX; | ||
lExt.relX += diff; // Change preliminary x coordinate so that the node does not move. | ||
lExt.prelim -= diff; // Update extreme node and its sum of modifiers. | ||
lExt.relX += diff; | ||
// Change preliminary x coordinate so that the node does not move. | ||
lExt.prelim -= diff; | ||
// Update extreme node and its sum of modifiers. | ||
firstChild.lExt = curSubtree.lExt; | ||
firstChild.lExtRelX = curSubtree.lExtRelX; | ||
}; // Mirror image of setLThr. | ||
}; | ||
// Mirror image of setLThr. | ||
const setRThr = (w, i, rContour, rSumMods) => { | ||
@@ -1006,5 +635,5 @@ const curSubtree = w.children[i]; | ||
curSubtree.rExtRelX = lSib.rExtRelX; | ||
}; // Position root between children, taking into account their modifiers | ||
}; | ||
// Position root between children, taking into account their modifiers | ||
const positionRoot = w => { | ||
@@ -1023,11 +652,10 @@ if (w.hasChildren) { | ||
} | ||
}; // Make/maintain a linked list of the indexes of left siblings and their | ||
}; | ||
// Make/maintain a linked list of the indexes of left siblings and their | ||
// lowest vertical coordinate. | ||
const updateLows = (lowY, index, lastLows) => { | ||
// Remove siblings that are hidden by the new subtree. | ||
while (lastLows !== null && lowY >= lastLows.lowY) lastLows = lastLows.next; // Prepend the new subtree. | ||
while (lastLows !== null && lowY >= lastLows.lowY) lastLows = lastLows.next; | ||
// Prepend the new subtree. | ||
return { | ||
@@ -1052,15 +680,11 @@ lowY, | ||
}; | ||
var isLeaf = function isLeaf(c) { | ||
return typeof c === 'string' || typeof c === 'number'; | ||
}; | ||
var isElement = function isElement(c) { | ||
return (c == null ? void 0 : c.vtype) === VTYPE_ELEMENT; | ||
}; | ||
var isRenderFunction = function isRenderFunction(c) { | ||
return (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION; | ||
}; | ||
function jsx(type, props) { | ||
@@ -1075,11 +699,8 @@ var vtype; | ||
} | ||
function Fragment(props) { | ||
return props.children; | ||
} | ||
var DEFAULT_ENV = { | ||
isSvg: false | ||
}; | ||
function insertDom(parent, ref) { | ||
@@ -1096,7 +717,5 @@ if (ref.type === MOUNT_SINGLE) { | ||
} | ||
function mountAttributes(domElement, props, env) { | ||
for (var key in props) { | ||
if (key === 'key' || key === 'children' || key === 'ref') continue; | ||
if (key === 'dangerouslySetInnerHTML') { | ||
@@ -1113,3 +732,2 @@ domElement.innerHTML = props[key].__html; | ||
} | ||
var attrMap = { | ||
@@ -1119,6 +737,4 @@ className: 'class', | ||
}; | ||
function setDOMAttribute(el, attr, value, isSVG) { | ||
attr = attrMap[attr] || attr; | ||
if (value === true) { | ||
@@ -1130,3 +746,2 @@ el.setAttribute(attr, ''); | ||
var namespace = isSVG ? NS_ATTRS[attr] : undefined; | ||
if (namespace !== undefined) { | ||
@@ -1139,3 +754,2 @@ el.setAttributeNS(namespace, attr, value); | ||
} | ||
function mount(vnode, env) { | ||
@@ -1145,3 +759,2 @@ if (env === void 0) { | ||
} | ||
if (vnode == null || typeof vnode === 'boolean') { | ||
@@ -1153,3 +766,2 @@ return { | ||
} | ||
if (vnode instanceof Node) { | ||
@@ -1161,11 +773,8 @@ return { | ||
} | ||
if (isRenderFunction(vnode)) { | ||
var _ref = vnode, | ||
type = _ref.type, | ||
props = _ref.props; | ||
type = _ref.type, | ||
props = _ref.props; | ||
if (type === Fragment) { | ||
var node = document.createDocumentFragment(); | ||
if (props.children) { | ||
@@ -1175,3 +784,2 @@ var childrenRef = mount(props.children, env); | ||
} | ||
return { | ||
@@ -1182,7 +790,5 @@ type: MOUNT_SINGLE, | ||
} | ||
var childVNode = type(props); | ||
return mount(childVNode, env); | ||
} | ||
if (isLeaf(vnode)) { | ||
@@ -1194,10 +800,7 @@ return { | ||
} | ||
if (isElement(vnode)) { | ||
var _node; | ||
var _ref2 = vnode, | ||
_type = _ref2.type, | ||
_props = _ref2.props; | ||
_type = _ref2.type, | ||
_props = _ref2.props; | ||
if (!env.isSvg && _type === 'svg') { | ||
@@ -1208,3 +811,2 @@ env = Object.assign({}, env, { | ||
} | ||
if (!env.isSvg) { | ||
@@ -1215,10 +817,6 @@ _node = document.createElement(_type); | ||
} | ||
mountAttributes(_node, _props, env); | ||
var _childrenRef; | ||
if (_props.children) { | ||
var childEnv = env; | ||
if (env.isSvg && _type === 'foreignObject') { | ||
@@ -1229,6 +827,4 @@ childEnv = Object.assign({}, childEnv, { | ||
} | ||
_childrenRef = mount(_props.children, childEnv); | ||
} | ||
if (_childrenRef != null) insertDom(_node, _childrenRef); | ||
@@ -1242,3 +838,2 @@ var ref = _props.ref; | ||
} | ||
if (Array.isArray(vnode)) { | ||
@@ -1252,9 +847,6 @@ return { | ||
} | ||
throw new Error('mount: Invalid Vnode!'); | ||
} | ||
function flattenWithoutNull(array) { | ||
var result = []; | ||
for (var i = 0; i < array.length; i += 1) { | ||
@@ -1264,6 +856,4 @@ var item = array[i]; | ||
} | ||
return result; | ||
} | ||
function asDom(result) { | ||
@@ -1273,3 +863,2 @@ if (result.type === MOUNT_SINGLE) { | ||
} | ||
return result.children.map(asDom); | ||
@@ -1281,3 +870,2 @@ } | ||
function mountDom(vnode) { | ||
@@ -1287,7 +875,6 @@ if (Array.isArray(vnode)) { | ||
} | ||
return asDom(mount(vnode)); | ||
} | ||
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 :not(pre)>code{padding:.2em .4em}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:bolder}.markmap-foreign mark{background:#ffeaa7}.markmap-foreign pre,.markmap-foreign pre[class*=language-]{margin:0;padding:.2em .4em}"; | ||
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 :not(pre)>code{padding:.2em .4em}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:#ffeaa7}.markmap-foreign pre,.markmap-foreign pre[class*=language-]{margin:0;padding:.2em .4em}"; | ||
@@ -1297,3 +884,2 @@ 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}"; | ||
const globalCSS = css_248z$1; | ||
function linkWidth(nodeData) { | ||
@@ -1303,5 +889,4 @@ const data = nodeData.data; | ||
} | ||
function adjustSpacing(tree, spacing) { | ||
walkTree(tree, (d, next) => { | ||
markmapCommon.walkTree(tree, (d, next) => { | ||
d.ySizeInner = d.ySize - spacing; | ||
@@ -1312,3 +897,2 @@ d.y += spacing; | ||
} | ||
function minBy(numbers, by) { | ||
@@ -1318,18 +902,15 @@ const index = d3__namespace.minIndex(numbers, by); | ||
} | ||
function stopPropagation(e) { | ||
e.stopPropagation(); | ||
} | ||
function createViewHooks() { | ||
return { | ||
transformHtml: new Hook() | ||
transformHtml: new markmapCommon.Hook() | ||
}; | ||
} | ||
/** | ||
* A global hook to refresh all markmaps when called. | ||
*/ | ||
const refreshHook = new Hook(); | ||
const refreshHook = new markmapCommon.Hook(); | ||
const defaultColorFn = d3__namespace.scaleOrdinal(d3__namespace.schemeCategory10); | ||
@@ -1351,3 +932,2 @@ const isMacintosh = typeof navigator !== 'undefined' && navigator.userAgent.includes('Macintosh'); | ||
} | ||
return (!event.ctrlKey || event.type === 'wheel') && !event.button; | ||
@@ -1357,3 +937,3 @@ }).on('zoom', this.handleZoom); | ||
this.state = { | ||
id: this.options.id || this.svg.attr('id') || getId() | ||
id: this.options.id || this.svg.attr('id') || markmapCommon.getId() | ||
}; | ||
@@ -1365,3 +945,2 @@ this.g = this.svg.append('g'); | ||
} | ||
getStyleContent() { | ||
@@ -1377,9 +956,7 @@ const { | ||
} | ||
updateStyle() { | ||
this.svg.attr('class', addClass(this.svg.attr('class'), 'markmap', this.state.id)); | ||
this.svg.attr('class', markmapCommon.addClass(this.svg.attr('class'), 'markmap', this.state.id)); | ||
const style = this.getStyleContent(); | ||
this.styleNode.text(style); | ||
} | ||
handleZoom(e) { | ||
@@ -1391,3 +968,2 @@ const { | ||
} | ||
handlePan(e) { | ||
@@ -1399,15 +975,26 @@ e.preventDefault(); | ||
} | ||
handleClick(_, d) { | ||
toggleNode(data, recursive = false) { | ||
var _data$payload; | ||
const { | ||
data | ||
} = d; | ||
data.payload = _extends({}, data.payload, { | ||
fold: (_data$payload = data.payload) != null && _data$payload.fold ? 0 : 1 | ||
}); | ||
this.renderData(d.data); | ||
const fold = (_data$payload = data.payload) != null && _data$payload.fold ? 0 : 1; | ||
if (recursive) { | ||
// recursively | ||
markmapCommon.walkTree(data, (item, next) => { | ||
item.payload = _extends({}, item.payload, { | ||
fold | ||
}); | ||
next(); | ||
}); | ||
} else { | ||
var _data$payload2; | ||
data.payload = _extends({}, data.payload, { | ||
fold: (_data$payload2 = data.payload) != null && _data$payload2.fold ? 0 : 1 | ||
}); | ||
} | ||
this.renderData(data); | ||
} | ||
handleClick(e, d) { | ||
let recursive = this.options.toggleRecursively; | ||
if (e.ctrlKey) recursive = !recursive; | ||
this.toggleNode(d.data, recursive); | ||
} | ||
initializeData(node) { | ||
@@ -1433,5 +1020,4 @@ let nodeId = 0; | ||
let foldRecursively = 0; | ||
walkTree(node, (item, next, parent) => { | ||
markmapCommon.walkTree(node, (item, next, parent) => { | ||
var _item$children, _parent$state, _item$payload; | ||
item.children = (_item$children = item.children) == null ? void 0 : _item$children.map(child => _extends({}, child)); | ||
@@ -1453,7 +1039,6 @@ nodeId += 1; | ||
}); | ||
item.state.path = [parent == null ? void 0 : (_parent$state = parent.state) == null ? void 0 : _parent$state.path, item.state.id].filter(Boolean).join('.'); | ||
item.state.path = [parent == null || (_parent$state = parent.state) == null ? void 0 : _parent$state.path, item.state.id].filter(Boolean).join('.'); | ||
color(item); // preload colors | ||
const isFoldRecursively = ((_item$payload = item.payload) == null ? void 0 : _item$payload.fold) === 2; | ||
if (isFoldRecursively) { | ||
@@ -1466,22 +1051,21 @@ foldRecursively += 1; | ||
} | ||
next(); | ||
if (isFoldRecursively) foldRecursively -= 1; | ||
}); | ||
const nodes = arrayFrom(container.childNodes).map(group => group.firstChild); | ||
this.viewHooks.transformHtml.call(this, nodes); // Clone the rendered HTML and set `white-space: nowrap` to it to detect its max-width. | ||
const nodes = Array.from(container.childNodes).map(group => group.firstChild); | ||
this.viewHooks.transformHtml.call(this, nodes); | ||
// Clone the rendered HTML and set `white-space: nowrap` to it to detect its max-width. | ||
// The parent node will have a width of the max-width and the original content without | ||
// `white-space: nowrap` gets re-layouted, then we will get the expected layout, with | ||
// content in one line as much as possible, and subjecting to the given max-width. | ||
nodes.forEach(node => { | ||
node.parentNode.append(node.cloneNode(true)); | ||
}); | ||
walkTree(node, (item, next, parent) => { | ||
markmapCommon.walkTree(node, (item, next, parent) => { | ||
var _parent$state2; | ||
const rect = item.state.el.getBoundingClientRect(); | ||
item.content = item.state.el.innerHTML; | ||
item.state.size = [Math.ceil(rect.width) + 1, Math.max(Math.ceil(rect.height), nodeMinHeight)]; | ||
item.state.key = [parent == null ? void 0 : (_parent$state2 = parent.state) == null ? void 0 : _parent$state2.id, item.state.id].filter(Boolean).join('.') + // FIXME: find a way to check content hash | ||
item.state.key = [parent == null || (_parent$state2 = parent.state) == null ? void 0 : _parent$state2.id, item.state.id].filter(Boolean).join('.') + | ||
// FIXME: find a way to check content hash | ||
item.content; | ||
@@ -1493,6 +1077,4 @@ next(); | ||
} | ||
setOptions(opts) { | ||
this.options = _extends({}, Markmap.defaultOptions, opts); | ||
if (this.options.zoom) { | ||
@@ -1503,6 +1085,4 @@ this.svg.call(this.zoom); | ||
} | ||
this.svg.on('wheel', this.options.pan ? this.handlePan : null); | ||
} | ||
setData(data, opts) { | ||
@@ -1515,6 +1095,4 @@ if (data) this.state.data = data; | ||
} | ||
renderData(originData) { | ||
var _origin$data$state$x, _origin$data$state$y; | ||
if (!this.state.data) return; | ||
@@ -1530,3 +1108,2 @@ const { | ||
var _d$payload; | ||
return !((_d$payload = d.payload) != null && _d$payload.fold) && d.children; | ||
@@ -1558,5 +1135,6 @@ }).nodeSize(d => { | ||
const x0 = (_origin$data$state$x = origin.data.state.x0) != null ? _origin$data$state$x : origin.x; | ||
const y0 = (_origin$data$state$y = origin.data.state.y0) != null ? _origin$data$state$y : origin.y; // Update the nodes | ||
const y0 = (_origin$data$state$y = origin.data.state.y0) != null ? _origin$data$state$y : origin.y; | ||
const node = this.g.selectAll(childSelector('g')).data(descendants, d => d.data.state.key); | ||
// Update the nodes | ||
const node = this.g.selectAll(markmapCommon.childSelector('g')).data(descendants, d => d.data.state.key); | ||
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.ySizeInner - d.ySizeInner},${x0 + origin.xSize / 2 - d.xSize})`); | ||
@@ -1569,21 +1147,21 @@ const nodeExit = this.transition(node.exit()); | ||
var _d$data$payload; | ||
return ['markmap-node', ((_d$data$payload = d.data.payload) == null ? void 0 : _d$data$payload.fold) && 'markmap-fold'].filter(Boolean).join(' '); | ||
}); | ||
this.transition(nodeMerge).attr('transform', d => `translate(${d.y},${d.x - d.xSize / 2})`); // Update lines under the content | ||
this.transition(nodeMerge).attr('transform', d => `translate(${d.y},${d.x - d.xSize / 2})`); | ||
const line = nodeMerge.selectAll(childSelector('line')).data(d => [d], d => d.data.state.key).join(enter => { | ||
// Update lines under the content | ||
const line = nodeMerge.selectAll(markmapCommon.childSelector('line')).data(d => [d], d => d.data.state.key).join(enter => { | ||
return enter.append('line').attr('x1', d => d.ySizeInner).attr('x2', d => d.ySizeInner); | ||
}, update => update, exit => exit.remove()); | ||
this.transition(line).attr('x1', -1).attr('x2', d => d.ySizeInner + 2).attr('y1', d => d.xSize).attr('y2', d => d.xSize).attr('stroke', d => color(d.data)).attr('stroke-width', linkWidth); // Circle to link to children of the node | ||
this.transition(line).attr('x1', -1).attr('x2', d => d.ySizeInner + 2).attr('y1', d => d.xSize).attr('y2', d => d.xSize).attr('stroke', d => color(d.data)).attr('stroke-width', linkWidth); | ||
const circle = nodeMerge.selectAll(childSelector('circle')).data(d => d.data.children ? [d] : [], d => d.data.state.key).join(enter => { | ||
return enter.append('circle').attr('stroke-width', '1.5').attr('cx', d => d.ySizeInner).attr('cy', d => d.xSize).attr('r', 0).on('click', (e, d) => this.handleClick(e, d)); | ||
// Circle to link to children of the node | ||
const circle = nodeMerge.selectAll(markmapCommon.childSelector('circle')).data(d => d.data.children ? [d] : [], d => d.data.state.key).join(enter => { | ||
return enter.append('circle').attr('stroke-width', '1.5').attr('cx', d => d.ySizeInner).attr('cy', d => d.xSize).attr('r', 0).on('click', (e, d) => this.handleClick(e, d)).on('mousedown', stopPropagation); | ||
}, update => update, exit => exit.remove()); | ||
this.transition(circle).attr('r', 6).attr('cx', d => d.ySizeInner).attr('cy', d => d.xSize).attr('stroke', d => color(d.data)).attr('fill', d => { | ||
var _d$data$payload2; | ||
return (_d$data$payload2 = d.data.payload) != null && _d$data$payload2.fold && d.data.children ? color(d.data) : '#fff'; | ||
}); | ||
const foreignObject = nodeMerge.selectAll(childSelector('foreignObject')).data(d => [d], d => d.data.state.key).join(enter => { | ||
const foreignObject = nodeMerge.selectAll(markmapCommon.childSelector('foreignObject')).data(d => [d], d => d.data.state.key).join(enter => { | ||
const fo = enter.append('foreignObject').attr('class', 'markmap-foreign').attr('x', paddingX).attr('y', 0).style('opacity', 0).on('mousedown', stopPropagation).on('dblclick', stopPropagation); | ||
@@ -1597,5 +1175,6 @@ fo.append('xhtml:div').select(function select(d) { | ||
}, update => update, exit => exit.remove()).attr('width', d => Math.max(0, d.ySizeInner - paddingX * 2)).attr('height', d => d.xSize); | ||
this.transition(foreignObject).style('opacity', 1); // Update the links | ||
this.transition(foreignObject).style('opacity', 1); | ||
const path = this.g.selectAll(childSelector('path')).data(links, d => d.target.data.state.key).join(enter => { | ||
// Update the links | ||
const path = this.g.selectAll(markmapCommon.childSelector('path')).data(links, d => d.target.data.state.key).join(enter => { | ||
const source = [y0 + origin.ySizeInner, x0 + origin.xSize / 2]; | ||
@@ -1626,3 +1205,2 @@ 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({ | ||
} | ||
transition(sel) { | ||
@@ -1634,7 +1212,6 @@ const { | ||
} | ||
/** | ||
* Fit the content to the viewport. | ||
*/ | ||
async fit() { | ||
@@ -1659,19 +1236,16 @@ const svgNode = this.svg.node(); | ||
const initialZoom = d3__namespace.zoomIdentity.translate((offsetWidth - naturalWidth * scale) / 2 - minY * scale, (offsetHeight - naturalHeight * scale) / 2 - minX * scale).scale(scale); | ||
return this.transition(this.svg).call(this.zoom.transform, initialZoom).end().catch(noop); | ||
return this.transition(this.svg).call(this.zoom.transform, initialZoom).end().catch(markmapCommon.noop); | ||
} | ||
/** | ||
* Pan the content to make the provided node visible in the viewport. | ||
*/ | ||
async ensureView(node, padding) { | ||
let g; | ||
let itemData; | ||
this.g.selectAll(childSelector('g')).each(function walk(d) { | ||
this.g.selectAll(markmapCommon.childSelector('g')).each(function walk(d) { | ||
if (d.data === node) { | ||
g = this; | ||
itemData = d; | ||
} | ||
}); | ||
if (!g || !itemData) return; | ||
if (!itemData) return; | ||
const svgNode = this.svg.node(); | ||
@@ -1681,4 +1255,4 @@ const relRect = svgNode.getBoundingClientRect(); | ||
const [left, right] = [itemData.y, itemData.y + itemData.ySizeInner + 2].map(x => x * transform.k + transform.x); | ||
const [top, bottom] = [itemData.x - itemData.xSize / 2, itemData.x + itemData.xSize / 2].map(y => y * transform.k + transform.y); // Skip if the node includes or is included in the container. | ||
const [top, bottom] = [itemData.x - itemData.xSize / 2, itemData.x + itemData.xSize / 2].map(y => y * transform.k + transform.y); | ||
// Skip if the node includes or is included in the container. | ||
const pd = _extends({ | ||
@@ -1690,3 +1264,2 @@ left: 0, | ||
}, padding); | ||
const dxs = [pd.left - left, relRect.width - pd.right - right]; | ||
@@ -1696,13 +1269,11 @@ const dys = [pd.top - top, relRect.height - pd.bottom - bottom]; | ||
const dy = dys[0] * dys[1] > 0 ? minBy(dys, Math.abs) / transform.k : 0; | ||
if (dx || dy) { | ||
const newTransform = transform.translate(dx, dy); | ||
return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(noop); | ||
return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(markmapCommon.noop); | ||
} | ||
} | ||
/** | ||
* Scale content with it pinned at the center of the viewport. | ||
*/ | ||
async rescale(scale) { | ||
@@ -1718,5 +1289,4 @@ const svgNode = this.svg.node(); | ||
const newTransform = transform.translate((halfWidth - transform.x) * (1 - scale) / transform.k, (halfHeight - transform.y) * (1 - scale) / transform.k).scale(scale); | ||
return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(noop); | ||
return this.transition(this.svg).call(this.zoom.transform, newTransform).end().catch(markmapCommon.noop); | ||
} | ||
destroy() { | ||
@@ -1729,6 +1299,4 @@ this.svg.on('.zoom', null); | ||
} | ||
static create(svg, opts, data) { | ||
const mm = new Markmap(svg, opts); | ||
if (data) { | ||
@@ -1741,3 +1309,2 @@ mm.setData(data); | ||
} | ||
} | ||
@@ -1758,3 +1325,4 @@ Markmap.defaultOptions = { | ||
zoom: true, | ||
pan: true | ||
pan: true, | ||
toggleRecursively: false | ||
}; | ||
@@ -1768,16 +1336,11 @@ function deriveOptions(jsonOptions) { | ||
} = jsonOptions; | ||
if ((color == null ? void 0 : color.length) === 1) { | ||
const solidColor = color[0]; | ||
opts.color = () => solidColor; | ||
} else if (color != null && color.length) { | ||
const colorFn = d3__namespace.scaleOrdinal(color); | ||
opts.color = node => colorFn(`${node.state.path}`); | ||
} | ||
if (colorFreezeLevel) { | ||
const color = opts.color || Markmap.defaultOptions.color; | ||
opts.color = node => { | ||
@@ -1792,3 +1355,2 @@ node = _extends({}, node, { | ||
} | ||
const numberKeys = ['duration', 'maxWidth', 'initialExpandLevel']; | ||
@@ -1807,2 +1369,4 @@ numberKeys.forEach(key => { | ||
exports.loadCSS = markmapCommon.loadCSS; | ||
exports.loadJS = markmapCommon.loadJS; | ||
exports.Markmap = Markmap; | ||
@@ -1812,6 +1376,2 @@ exports.defaultColorFn = defaultColorFn; | ||
exports.globalCSS = globalCSS; | ||
exports.loadCSS = loadCSS; | ||
exports.loadJS = loadJS; | ||
exports.refreshHook = refreshHook; | ||
})(this.markmap = this.markmap || {}, d3); |
{ | ||
"name": "markmap-view", | ||
"version": "0.14.4", | ||
"version": "0.14.5-alpha.13+50ca560", | ||
"description": "View markmaps in browser", | ||
@@ -12,3 +12,3 @@ "author": "Gerald <gera2ld@live.com>", | ||
], | ||
"homepage": "https://github.com/gera2ld/markmap/packages/markmap-view#readme", | ||
"homepage": "https://github.com/markmap/markmap/packages/markmap-view#readme", | ||
"publishConfig": { | ||
@@ -20,3 +20,3 @@ "access": "public", | ||
"type": "git", | ||
"url": "git+https://github.com/gera2ld/markmap.git" | ||
"url": "git+https://github.com/markmap/markmap.git" | ||
}, | ||
@@ -30,8 +30,8 @@ "scripts": { | ||
"bugs": { | ||
"url": "https://github.com/gera2ld/markmap/issues" | ||
"url": "https://github.com/markmap/markmap/issues" | ||
}, | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.esm.js", | ||
"unpkg": "dist/index.min.js", | ||
"jsdelivr": "dist/index.min.js", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"unpkg": "dist/browser/index.js", | ||
"jsdelivr": "dist/browser/index.js", | ||
"files": [ | ||
@@ -49,3 +49,4 @@ "dist", | ||
"devDependencies": { | ||
"markmap-common": "^0.14.2" | ||
"@gera2ld/jsx-dom": "^2.1.1", | ||
"markmap-common": "0.14.5-alpha.13+50ca560" | ||
}, | ||
@@ -55,6 +56,3 @@ "peerDependencies": { | ||
}, | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"gitHead": "8eb2fa223ab85d1a7699d2c9660fdb5fac24acd1" | ||
"gitHead": "50ca5603019498f93dba6485c96d0a5630b221e5" | ||
} |
@@ -11,3 +11,3 @@ import * as d3 from 'd3'; | ||
} | ||
declare type ID3SVGElement = d3.Selection<SVGElement, IMarkmapFlexTreeItem, HTMLElement, IMarkmapFlexTreeItem>; | ||
type ID3SVGElement = d3.Selection<SVGElement, IMarkmapFlexTreeItem, HTMLElement, IMarkmapFlexTreeItem>; | ||
declare function createViewHooks(): { | ||
@@ -36,3 +36,4 @@ transformHtml: Hook<[mm: Markmap, nodes: HTMLElement[]]>; | ||
handlePan(e: WheelEvent): void; | ||
handleClick(_: MouseEvent, d: IMarkmapFlexTreeItem): void; | ||
toggleNode(data: INode, recursive?: boolean): void; | ||
handleClick(e: MouseEvent, d: IMarkmapFlexTreeItem): void; | ||
initializeData(node: INode): void; | ||
@@ -39,0 +40,0 @@ setOptions(opts: Partial<IMarkmapOptions>): void; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
129530
2
9
3931
2