markmap-lib
Advanced tools
Comparing version 0.6.2 to 0.6.3
@@ -1,2 +0,2 @@ | ||
/*! markmap-lib v0.6.2 | MIT License */ | ||
/*! markmap-lib v0.6.3 | MIT License */ | ||
'use strict'; | ||
@@ -164,2 +164,4 @@ | ||
current.v = `${current.v || ''}${extractInline(token)}`; | ||
} else if (token.type === 'fence') { | ||
current.v = `<pre><code class="language-${token.params}">${util.escapeHtml(token.content)}</code></pre>`; | ||
} | ||
@@ -166,0 +168,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/*! markmap-lib v0.6.2 | MIT License */ | ||
/*! markmap-lib v0.6.3 | MIT License */ | ||
'use strict'; | ||
@@ -12,3 +12,3 @@ | ||
}, { | ||
src: 'https://cdn.jsdelivr.net/npm/markmap-lib@0.6.2/dist/view.min.js' | ||
src: 'https://cdn.jsdelivr.net/npm/markmap-lib@0.6.3/dist/view.min.js' | ||
}]; | ||
@@ -15,0 +15,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! markmap-lib v0.6.2 | MIT License */ | ||
/*! markmap-lib v0.6.3 | MIT License */ | ||
'use strict'; | ||
@@ -157,2 +157,4 @@ | ||
current.v = `${current.v || ''}${extractInline(token)}`; | ||
} else if (token.type === 'fence') { | ||
current.v = `<pre><code class="language-${token.params}">${util.escapeHtml(token.content)}</code></pre>`; | ||
} | ||
@@ -159,0 +161,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/*! markmap-lib v0.6.2 | MIT License */ | ||
/*! markmap-lib v0.6.3 | MIT License */ | ||
'use strict'; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! markmap-lib v0.6.2 | MIT License */ | ||
/*! markmap-lib v0.6.3 | MIT License */ | ||
'use strict'; | ||
@@ -112,3 +112,3 @@ | ||
} = options; | ||
const styleText = style ? style(state.id) : `\ | ||
const styleText = `\ | ||
.${state.id} a { color: #0097e6; } | ||
@@ -118,7 +118,9 @@ .${state.id} a:hover { color: #00a8ff; } | ||
.${state.id}-fo > div { font: ${options.nodeFont}; white-space: nowrap; } | ||
.${state.id}-fo > div > code { padding: .2em .4em; font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; } | ||
.${state.id}-fo > div > del { text-decoration: line-through; } | ||
.${state.id}-fo > div > em { font-style: italic; } | ||
.${state.id}-fo > div > strong { font-weight: 500; } | ||
.${state.id}-fo code { padding: .2em .4em; font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; } | ||
.${state.id}-fo del { text-decoration: line-through; } | ||
.${state.id}-fo em { font-style: italic; } | ||
.${state.id}-fo strong { font-weight: 500; } | ||
.${state.id}-fo pre { margin: 0; } | ||
.${state.id}-g > g { cursor: pointer; } | ||
${style ? style(state.id) : ''} | ||
`; | ||
@@ -166,5 +168,3 @@ return styleText; | ||
document.body.append(style, container); | ||
walkTree(node, (item, next, parent) => { | ||
var _parent$p; | ||
walkTree(node, (item, next) => { | ||
i += 1; | ||
@@ -182,7 +182,3 @@ options.color(`${c}`); // preload colors | ||
el | ||
}, item.p, { | ||
// TODO keep keys for unchanged objects | ||
// unique key, should be based on content | ||
k: `${(parent == null ? void 0 : (_parent$p = parent.p) == null ? void 0 : _parent$p.i) || ''}.${i}:${item.v}` | ||
}); | ||
}, item.p); | ||
next(); | ||
@@ -192,5 +188,11 @@ if (!colorDepth || item.d === colorDepth) c += 1; | ||
if (options.processHtml) options.processHtml(arrayFrom(container.childNodes)); | ||
walkTree(node, (item, next) => { | ||
walkTree(node, (item, next, parent) => { | ||
var _parent$p; | ||
const rect = item.p.el.getBoundingClientRect(); | ||
item.p.s = [Math.ceil(rect.width), Math.max(Math.ceil(rect.height), options.nodeMinHeight)]; | ||
item.v = item.p.el.innerHTML; | ||
item.p.s = [Math.ceil(rect.width), Math.max(Math.ceil(rect.height), options.nodeMinHeight)]; // TODO keep keys for unchanged objects | ||
// unique key, should be based on content | ||
item.p.k = `${(parent == null ? void 0 : (_parent$p = parent.p) == null ? void 0 : _parent$p.i) || ''}.${item.p.i}:${item.v}`; | ||
next(); | ||
@@ -197,0 +199,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
/*! markmap-lib v0.6.2 | MIT License */ | ||
/*! markmap-lib v0.6.3 | MIT License */ | ||
(function (exports, d3) { | ||
@@ -665,3 +665,3 @@ 'use strict'; | ||
} = options; | ||
const styleText = style ? style(state.id) : `\ | ||
const styleText = `\ | ||
.${state.id} a { color: #0097e6; } | ||
@@ -671,7 +671,9 @@ .${state.id} a:hover { color: #00a8ff; } | ||
.${state.id}-fo > div { font: ${options.nodeFont}; white-space: nowrap; } | ||
.${state.id}-fo > div > code { padding: .2em .4em; font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; } | ||
.${state.id}-fo > div > del { text-decoration: line-through; } | ||
.${state.id}-fo > div > em { font-style: italic; } | ||
.${state.id}-fo > div > strong { font-weight: 500; } | ||
.${state.id}-fo code { padding: .2em .4em; font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; } | ||
.${state.id}-fo del { text-decoration: line-through; } | ||
.${state.id}-fo em { font-style: italic; } | ||
.${state.id}-fo strong { font-weight: 500; } | ||
.${state.id}-fo pre { margin: 0; } | ||
.${state.id}-g > g { cursor: pointer; } | ||
${style ? style(state.id) : ''} | ||
`; | ||
@@ -719,5 +721,3 @@ return styleText; | ||
document.body.append(style, container); | ||
walkTree(node, (item, next, parent) => { | ||
var _parent$p; | ||
walkTree(node, (item, next) => { | ||
i += 1; | ||
@@ -735,7 +735,3 @@ options.color(`${c}`); // preload colors | ||
el | ||
}, item.p, { | ||
// TODO keep keys for unchanged objects | ||
// unique key, should be based on content | ||
k: `${(parent == null ? void 0 : (_parent$p = parent.p) == null ? void 0 : _parent$p.i) || ''}.${i}:${item.v}` | ||
}); | ||
}, item.p); | ||
next(); | ||
@@ -745,5 +741,11 @@ if (!colorDepth || item.d === colorDepth) c += 1; | ||
if (options.processHtml) options.processHtml(arrayFrom(container.childNodes)); | ||
walkTree(node, (item, next) => { | ||
walkTree(node, (item, next, parent) => { | ||
var _parent$p; | ||
const rect = item.p.el.getBoundingClientRect(); | ||
item.p.s = [Math.ceil(rect.width), Math.max(Math.ceil(rect.height), options.nodeMinHeight)]; | ||
item.v = item.p.el.innerHTML; | ||
item.p.s = [Math.ceil(rect.width), Math.max(Math.ceil(rect.height), options.nodeMinHeight)]; // TODO keep keys for unchanged objects | ||
// unique key, should be based on content | ||
item.p.k = `${(parent == null ? void 0 : (_parent$p = parent.p) == null ? void 0 : _parent$p.i) || ''}.${item.p.i}:${item.v}`; | ||
next(); | ||
@@ -750,0 +752,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
/*! markmap-lib v0.6.2 | MIT License */ | ||
!function(t,e){"use strict";function n(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function r(t,e){var n,r,a,l,c,h=new s(t),d=+t.value&&(h.value=t.value),u=[h];for(null==e&&(e=i);n=u.pop();)if(d&&(n.value=+n.data.value),(a=e(n.data))&&(c=a.length))for(n.children=new Array(c),l=c-1;l>=0;--l)u.push(r=n.children[l]=new s(a[l])),r.parent=n,r.depth=n.depth+1;return h.eachBefore(o)}function i(t){return t.children}function a(t){t.data=t.data.data}function o(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function s(t){this.data=t,this.depth=this.height=0,this.parent=null}s.prototype=r.prototype={constructor:s,count:function(){return this.eachAfter(n)},each:function(t){var e,n,r,i,a=this,o=[a];do{for(e=o.reverse(),o=[];a=e.pop();)if(t(a),n=a.children)for(r=0,i=n.length;r<i;++r)o.push(n[r])}while(o.length);return this},eachAfter:function(t){for(var e,n,r,i=this,a=[i],o=[];i=a.pop();)if(o.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)a.push(e[n]);for(;i=o.pop();)t(i);return this},eachBefore:function(t){for(var e,n,r=this,i=[r];r=i.pop();)if(t(r),e=r.children)for(n=e.length-1;n>=0;--n)i.push(e[n]);return this},sum:function(t){return this.eachAfter((function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t)}))},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){var t=[];return this.each((function(e){t.push(e)})),t},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e)})),t},links:function(){var t=this,e=[];return t.each((function(n){n!==t&&e.push({source:n.parent,target:n})})),e},copy:function(){return r(this).eachBefore(a)}};const l=Object.freeze({children:t=>t.children,nodeSize:t=>t.data.size,spacing:0});function c(t){const e=Object.assign({},l,t);function n(t){const n=e[t];return"function"==typeof n?n:()=>n}function i(t){const e=o(function(){const t=a(),e=n("nodeSize"),r=n("spacing");return class extends t{constructor(t){super(t),Object.assign(this,{x:0,y:0,relX:0,prelim:0,shift:0,change:0,lExt:this,lExtRelX:0,lThr:null,rExt:this,rExtRelX:0,rThr:null})}get size(){return e(this.data)}spacing(t){return r(this.data,t.data)}get x(){return this.data.x}set x(t){this.data.x=t}get y(){return this.data.y}set y(t){this.data.y=t}update(){return h(this),d(this),this}}}(),t,t=>t.children);return e.update(),e.data}function a(){const t=n("nodeSize"),e=n("spacing");return class n extends r.prototype.constructor{constructor(t){super(t)}copy(){const t=o(this.constructor,this,t=>t.children);return t.each(t=>t.data=t.data.data),t}get size(){return t(this)}spacing(t){return e(this,t)}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(){const t=this.ancestors();return t[t.length-1]}get numChildren(){return this.hasChildren?this.children.length:0}get hasChildren(){return!this.noChildren}get noChildren(){return null===this.children}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((t,e)=>n.maxExtents(t,e.extents),this.nodeExtents)}get nodeExtents(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}static maxExtents(t,e){return{top:Math.min(t.top,e.top),bottom:Math.max(t.bottom,e.bottom),left:Math.min(t.left,e.left),right:Math.max(t.right,e.right)}}}}function o(t,e,n){const r=(e,i)=>{const a=new t(e);Object.assign(a,{parent:i,depth:null===i?0:i.depth+1,height:0,length:1});const o=n(e)||[];return a.children=0===o.length?null:o.map(t=>r(t,a)),a.children&&Object.assign(a,a.children.reduce((t,e)=>({height:Math.max(t.height,e.height+1),length:t.length+e.length}),a)),a};return r(e,null)}return Object.assign(i,{nodeSize(t){return arguments.length?(e.nodeSize=t,i):e.nodeSize},spacing(t){return arguments.length?(e.spacing=t,i):e.spacing},children(t){return arguments.length?(e.children=t,i):e.children},hierarchy(t,n){const r=void 0===n?e.children:n;return o(a(),t,r)},dump(t){const e=n("nodeSize"),r=t=>n=>{const i=t+" ",a=t+" ",{x:o,y:s}=n,l=e(n),c=n.children||[],h=0===c.length?" ":`,${i}children: [${a}${c.map(r(a)).join(a)}${i}],${t}`;return`{ size: [${l.join(", ")}],${i}x: ${o}, y: ${s}${h}},`};return r("\n")(t)}}),i}c.version="2.1.1";const h=(t,e=0)=>(t.y=e,(t.children||[]).reduce((e,n)=>{const[r,i]=e;h(n,t.y+t.ySize);const a=(0===r?n.lExt:n.rExt).bottom;return 0!==r&&p(t,r,i),[r+1,S(a,r,i)]},[0,null]),u(t),v(t),t),d=(t,e,n)=>{void 0===e&&(e=-t.relX-t.prelim,n=0);const r=e+t.relX;return t.relX=r+t.prelim-n,t.prelim=0,t.x=n+t.relX,(t.children||[]).forEach(e=>d(e,r,t.x)),t},u=t=>{(t.children||[]).reduce((t,e)=>{const[n,r]=t,i=n+e.shift,a=r+i+e.change;return e.relX+=a,[i,a]},[0,0])},p=(t,e,n)=>{const r=t.children[e-1],i=t.children[e];let a=r,o=r.relX,s=i,l=i.relX,c=!0;for(;a&&s;){a.bottom>n.lowY&&(n=n.next);const r=o+a.prelim-(l+s.prelim)+a.xSize/2+s.xSize/2+a.spacing(s);(r>0||r<0&&c)&&(l+=r,f(i,r),g(t,e,n.index,r)),c=!1;const h=a.bottom,d=s.bottom;h<=d&&(a=m(a),a&&(o+=a.relX)),h>=d&&(s=x(s),s&&(l+=s.relX))}!a&&s?y(t,e,s,l):a&&!s&&z(t,e,a,o)},f=(t,e)=>{t.relX+=e,t.lExtRelX+=e,t.rExtRelX+=e},g=(t,e,n,r)=>{const i=t.children[e],a=e-n;if(a>1){const e=r/a;t.children[n+1].shift+=e,i.shift-=e,i.change-=r-e}},x=t=>t.hasChildren?t.firstChild:t.lThr,m=t=>t.hasChildren?t.lastChild:t.rThr,y=(t,e,n,r)=>{const i=t.firstChild,a=i.lExt,o=t.children[e];a.lThr=n;const s=r-n.relX-i.lExtRelX;a.relX+=s,a.prelim-=s,i.lExt=o.lExt,i.lExtRelX=o.lExtRelX},z=(t,e,n,r)=>{const i=t.children[e],a=i.rExt,o=t.children[e-1];a.rThr=n;const s=r-n.relX-i.rExtRelX;a.relX+=s,a.prelim-=s,i.rExt=o.rExt,i.rExtRelX=o.rExtRelX},v=t=>{if(t.hasChildren){const e=t.firstChild,n=t.lastChild,r=(e.prelim+e.relX-e.xSize/2+n.relX+n.prelim+n.xSize/2)/2;Object.assign(t,{prelim:r,lExt:e.lExt,lExtRelX:e.lExtRelX,rExt:n.rExt,rExtRelX:n.rExtRelX})}},S=(t,e,n)=>{for(;null!==n&&t>=n.lowY;)n=n.next;return{lowY:t,index:e,next:n}},$=Math.random().toString(36).slice(2,8);let E=0;function X(t,e,n="c"){const r=(t,i)=>e(t,()=>{var e;null==(e=t[n])||e.forEach(e=>{r(e,t)})},i);r(t)}function b(t){const e=t.data;return Math.max(6-2*e.d,1.5)}function w(t){const e=[];for(let n=0;n<t.length;n+=1)e.push(t[n]);return e}function C(t){if("string"==typeof t){const e=t;t=t=>t.tagName===e}const e=t;return function(){let t=w(this.childNodes);return e&&(t=t.filter(t=>e(t))),t}}function j(t,...e){const n=(t||"").split(" ").filter(Boolean);return e.forEach(t=>{t&&n.indexOf(t)<0&&n.push(t)}),n.join(" ")}t.markmap=function(t,n,r){const i=(t=t.datum?t:e.select(t)).append("style"),a=e.zoom().on("zoom",(function(){const{transform:t}=e.event;h.attr("transform",t)})),o=t.node(),s=Object.assign({duration:500,nodeFont:"300 16px/20px sans-serif",nodeMinHeight:16,spacingVertical:5,spacingHorizontal:80,autoFit:!1,fitRatio:.95,color:e.scaleOrdinal(e.schemeCategory10),colorDepth:0,paddingX:8},r),l={id:s.id||(E+=1,`mm-${$}-${E}`)},h=t.append("g").attr("class",`${l.id}-g`);return t.attr("class",j(t.attr("class"),l.id)),i.text(d()),n&&(p(n),g()),t.call(a),{setData:p,setOptions:u,fit:g};function d(){const{style:t}=s;return t?t(l.id):`.${l.id} a { color: #0097e6; }\n.${l.id} a:hover { color: #00a8ff; }\n.${l.id}-g > path { fill: none; }\n.${l.id}-fo > div { font: ${s.nodeFont}; white-space: nowrap; }\n.${l.id}-fo > div > code { padding: .2em .4em; font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; }\n.${l.id}-fo > div > del { text-decoration: line-through; }\n.${l.id}-fo > div > em { font-style: italic; }\n.${l.id}-fo > div > strong { font-weight: 500; }\n.${l.id}-g > g { cursor: pointer; }\n`}function u(t){Object.assign(s,t)}function p(t,e){!function(t){let e=0,n=0;const{colorDepth:r}=s,i=document.createElement("div"),a=`${l.id}-container`;i.className=j(i.className,`${l.id}-fo`,a);const o=document.createElement("style");o.textContent=`\n${d()}\n.${a} {\n position: absolute;\n width: 0;\n height: 0;\n top: -100px;\n left: -100px;\n overflow: hidden;\n font: ${s.nodeFont};\n}\n.${a} > div {\n display: inline-block;\n}\n`,document.body.append(o,i),X(t,(t,a,o)=>{var l;e+=1,s.color(`${n}`);const c=document.createElement("div");c.innerHTML=t.v,i.append(c),t.p=Object.assign({i:e,c:n,el:c},t.p,{k:`${(null==o||null==(l=o.p)?void 0:l.i)||""}.${e}:${t.v}`}),a(),r&&t.d!==r||(n+=1)}),s.processHtml&&s.processHtml(w(i.childNodes)),X(t,(t,e)=>{const n=t.p.el.getBoundingClientRect();t.p.s=[Math.ceil(n.width),Math.max(Math.ceil(n.height),s.nodeMinHeight)],e()}),i.remove(),o.remove()}(t),l.data=t,e&&u(e),m(t)}function f(t){return s.duration?t.transition().duration(s.duration):t}function g(){const{width:n,height:r}=o.getBoundingClientRect(),{minX:i,maxX:c,minY:h,maxY:d}=l,u=d-h,p=c-i,g=Math.min(n/u*s.fitRatio,r/p*s.fitRatio,2),x=e.zoomIdentity.translate((n-u*g)/2-h*g,(r-p*g)/2-i*g).scale(g);f(t).call(a.transform,x)}function x(t){var e;const{data:n}=t;n.p=Object.assign({},n.p,{f:!(null==(e=n.p)?void 0:e.f)}),m(t.data)}function m(t){var n,r;if(!l.data)return;const{spacingHorizontal:i}=s,a=c().children(t=>{var e;return!(null==(e=t.p)?void 0:e.f)&&t.c}).nodeSize(t=>{const[e,n]=t.data.p.s;return[n,e+(e?2*s.paddingX:0)+i]}).spacing((t,e)=>t.parent===e.parent?s.spacingVertical:2*s.spacingVertical),o=a.hierarchy(l.data);a(o),function(t,e){X(t,(t,n)=>{t.ySizeInner=t.ySize-e,t.y+=e,n()},"children")}(o,i);const d=o.descendants().reverse(),u=o.links(),p=e.linkHorizontal(),m=e.min(d,t=>t.x-t.xSize/2),y=e.max(d,t=>t.x+t.xSize/2),z=e.min(d,t=>t.y),v=e.max(d,t=>t.y+t.ySizeInner);l.minX=m,l.maxX=y,l.minY=z,l.maxY=v,s.autoFit&&g();const S=t?d.find(e=>e.data===t):o,$=null!=(n=S.data.x0)?n:S.x,E=null!=(r=S.data.y0)?r:S.y,w=h.selectAll(C("g")).data(d,t=>t.data.p.k),j=w.enter().append("g").attr("transform",t=>`translate(${E+S.ySizeInner-t.ySizeInner},${$+S.xSize/2-t.xSize})`).on("click",x),k=f(w.exit());k.select("rect").attr("width",0).attr("x",t=>t.ySizeInner),k.select("foreignObject").style("opacity",0),k.attr("transform",t=>`translate(${S.y+S.ySizeInner-t.ySizeInner},${S.x+S.xSize/2-t.xSize})`).remove();const R=w.merge(j);f(R).attr("transform",t=>`translate(${t.y},${t.x-t.xSize/2})`),f(R.selectAll(C("rect")).data(t=>[t],t=>t.data.p.k).join(t=>t.append("rect").attr("x",t=>t.ySizeInner).attr("y",t=>t.xSize-b(t)/2).attr("width",0).attr("height",b),t=>t,t=>t.remove())).attr("x",-1).attr("width",t=>t.ySizeInner+2).attr("fill",t=>s.color(t.data.p.c)),f(R.selectAll(C("circle")).data(t=>t.data.c?[t]:[],t=>t.data.p.k).join(t=>t.append("circle").attr("stroke-width","1.5").attr("cx",t=>t.ySizeInner).attr("cy",t=>t.xSize).attr("r",0),t=>t,t=>t.remove())).attr("r",6).attr("stroke",t=>s.color(t.data.p.c)).attr("fill",t=>{var e;return(null==(e=t.data.p)?void 0:e.f)?s.color(t.data.p.c):"#fff"}),f(R.selectAll(C("foreignObject")).data(t=>[t],t=>t.data.p.k).join(t=>{const e=t.append("foreignObject").attr("class",`${l.id}-fo`).attr("x",s.paddingX).attr("y",0).style("opacity",0).attr("height",t=>t.xSize);return e.append("xhtml:div").select((function(t){const e=t.data.p.el.cloneNode(!0);return this.replaceWith(e),e})).attr("xmlns","http://www.w3.org/1999/xhtml"),e},t=>t,t=>t.remove()).attr("width",t=>Math.max(0,t.ySizeInner-2*s.paddingX))).style("opacity",1);const O=h.selectAll(C("path")).data(u,t=>t.target.data.p.k).join(t=>{const e=[E+S.ySizeInner,$+S.xSize/2];return t.insert("path","g").attr("d",p({source:e,target:e}))},t=>t,t=>{const e=[S.y+S.ySizeInner,S.x+S.xSize/2];return f(t).attr("d",p({source:e,target:e})).remove()});f(O).attr("stroke",t=>s.color(t.target.data.p.c)).attr("stroke-width",t=>b(t.target)).attr("d",t=>{const e=[t.source.y+t.source.ySizeInner,t.source.x+t.source.xSize/2],n=[t.target.y,t.target.x+t.target.xSize/2];return p({source:e,target:n})}),d.forEach(t=>{t.data.x0=t.x,t.data.y0=t.y})}}}(this.markmap=this.markmap||{},d3); | ||
/*! markmap-lib v0.6.3 | MIT License */ | ||
!function(t,e){"use strict";function n(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function r(t,e){var n,r,a,l,c,h=new s(t),d=+t.value&&(h.value=t.value),u=[h];for(null==e&&(e=i);n=u.pop();)if(d&&(n.value=+n.data.value),(a=e(n.data))&&(c=a.length))for(n.children=new Array(c),l=c-1;l>=0;--l)u.push(r=n.children[l]=new s(a[l])),r.parent=n,r.depth=n.depth+1;return h.eachBefore(o)}function i(t){return t.children}function a(t){t.data=t.data.data}function o(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function s(t){this.data=t,this.depth=this.height=0,this.parent=null}s.prototype=r.prototype={constructor:s,count:function(){return this.eachAfter(n)},each:function(t){var e,n,r,i,a=this,o=[a];do{for(e=o.reverse(),o=[];a=e.pop();)if(t(a),n=a.children)for(r=0,i=n.length;r<i;++r)o.push(n[r])}while(o.length);return this},eachAfter:function(t){for(var e,n,r,i=this,a=[i],o=[];i=a.pop();)if(o.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)a.push(e[n]);for(;i=o.pop();)t(i);return this},eachBefore:function(t){for(var e,n,r=this,i=[r];r=i.pop();)if(t(r),e=r.children)for(n=e.length-1;n>=0;--n)i.push(e[n]);return this},sum:function(t){return this.eachAfter((function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t)}))},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){var t=[];return this.each((function(e){t.push(e)})),t},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e)})),t},links:function(){var t=this,e=[];return t.each((function(n){n!==t&&e.push({source:n.parent,target:n})})),e},copy:function(){return r(this).eachBefore(a)}};const l=Object.freeze({children:t=>t.children,nodeSize:t=>t.data.size,spacing:0});function c(t){const e=Object.assign({},l,t);function n(t){const n=e[t];return"function"==typeof n?n:()=>n}function i(t){const e=o(function(){const t=a(),e=n("nodeSize"),r=n("spacing");return class extends t{constructor(t){super(t),Object.assign(this,{x:0,y:0,relX:0,prelim:0,shift:0,change:0,lExt:this,lExtRelX:0,lThr:null,rExt:this,rExtRelX:0,rThr:null})}get size(){return e(this.data)}spacing(t){return r(this.data,t.data)}get x(){return this.data.x}set x(t){this.data.x=t}get y(){return this.data.y}set y(t){this.data.y=t}update(){return h(this),d(this),this}}}(),t,t=>t.children);return e.update(),e.data}function a(){const t=n("nodeSize"),e=n("spacing");return class n extends r.prototype.constructor{constructor(t){super(t)}copy(){const t=o(this.constructor,this,t=>t.children);return t.each(t=>t.data=t.data.data),t}get size(){return t(this)}spacing(t){return e(this,t)}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(){const t=this.ancestors();return t[t.length-1]}get numChildren(){return this.hasChildren?this.children.length:0}get hasChildren(){return!this.noChildren}get noChildren(){return null===this.children}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((t,e)=>n.maxExtents(t,e.extents),this.nodeExtents)}get nodeExtents(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}static maxExtents(t,e){return{top:Math.min(t.top,e.top),bottom:Math.max(t.bottom,e.bottom),left:Math.min(t.left,e.left),right:Math.max(t.right,e.right)}}}}function o(t,e,n){const r=(e,i)=>{const a=new t(e);Object.assign(a,{parent:i,depth:null===i?0:i.depth+1,height:0,length:1});const o=n(e)||[];return a.children=0===o.length?null:o.map(t=>r(t,a)),a.children&&Object.assign(a,a.children.reduce((t,e)=>({height:Math.max(t.height,e.height+1),length:t.length+e.length}),a)),a};return r(e,null)}return Object.assign(i,{nodeSize(t){return arguments.length?(e.nodeSize=t,i):e.nodeSize},spacing(t){return arguments.length?(e.spacing=t,i):e.spacing},children(t){return arguments.length?(e.children=t,i):e.children},hierarchy(t,n){const r=void 0===n?e.children:n;return o(a(),t,r)},dump(t){const e=n("nodeSize"),r=t=>n=>{const i=t+" ",a=t+" ",{x:o,y:s}=n,l=e(n),c=n.children||[],h=0===c.length?" ":`,${i}children: [${a}${c.map(r(a)).join(a)}${i}],${t}`;return`{ size: [${l.join(", ")}],${i}x: ${o}, y: ${s}${h}},`};return r("\n")(t)}}),i}c.version="2.1.1";const h=(t,e=0)=>(t.y=e,(t.children||[]).reduce((e,n)=>{const[r,i]=e;h(n,t.y+t.ySize);const a=(0===r?n.lExt:n.rExt).bottom;return 0!==r&&p(t,r,i),[r+1,S(a,r,i)]},[0,null]),u(t),v(t),t),d=(t,e,n)=>{void 0===e&&(e=-t.relX-t.prelim,n=0);const r=e+t.relX;return t.relX=r+t.prelim-n,t.prelim=0,t.x=n+t.relX,(t.children||[]).forEach(e=>d(e,r,t.x)),t},u=t=>{(t.children||[]).reduce((t,e)=>{const[n,r]=t,i=n+e.shift,a=r+i+e.change;return e.relX+=a,[i,a]},[0,0])},p=(t,e,n)=>{const r=t.children[e-1],i=t.children[e];let a=r,o=r.relX,s=i,l=i.relX,c=!0;for(;a&&s;){a.bottom>n.lowY&&(n=n.next);const r=o+a.prelim-(l+s.prelim)+a.xSize/2+s.xSize/2+a.spacing(s);(r>0||r<0&&c)&&(l+=r,f(i,r),g(t,e,n.index,r)),c=!1;const h=a.bottom,d=s.bottom;h<=d&&(a=m(a),a&&(o+=a.relX)),h>=d&&(s=x(s),s&&(l+=s.relX))}!a&&s?y(t,e,s,l):a&&!s&&z(t,e,a,o)},f=(t,e)=>{t.relX+=e,t.lExtRelX+=e,t.rExtRelX+=e},g=(t,e,n,r)=>{const i=t.children[e],a=e-n;if(a>1){const e=r/a;t.children[n+1].shift+=e,i.shift-=e,i.change-=r-e}},x=t=>t.hasChildren?t.firstChild:t.lThr,m=t=>t.hasChildren?t.lastChild:t.rThr,y=(t,e,n,r)=>{const i=t.firstChild,a=i.lExt,o=t.children[e];a.lThr=n;const s=r-n.relX-i.lExtRelX;a.relX+=s,a.prelim-=s,i.lExt=o.lExt,i.lExtRelX=o.lExtRelX},z=(t,e,n,r)=>{const i=t.children[e],a=i.rExt,o=t.children[e-1];a.rThr=n;const s=r-n.relX-i.rExtRelX;a.relX+=s,a.prelim-=s,i.rExt=o.rExt,i.rExtRelX=o.rExtRelX},v=t=>{if(t.hasChildren){const e=t.firstChild,n=t.lastChild,r=(e.prelim+e.relX-e.xSize/2+n.relX+n.prelim+n.xSize/2)/2;Object.assign(t,{prelim:r,lExt:e.lExt,lExtRelX:e.lExtRelX,rExt:n.rExt,rExtRelX:n.rExtRelX})}},S=(t,e,n)=>{for(;null!==n&&t>=n.lowY;)n=n.next;return{lowY:t,index:e,next:n}},$=Math.random().toString(36).slice(2,8);let E=0;function X(t,e,n="c"){const r=(t,i)=>e(t,()=>{var e;null==(e=t[n])||e.forEach(e=>{r(e,t)})},i);r(t)}function b(t){const e=t.data;return Math.max(6-2*e.d,1.5)}function w(t){const e=[];for(let n=0;n<t.length;n+=1)e.push(t[n]);return e}function C(t){if("string"==typeof t){const e=t;t=t=>t.tagName===e}const e=t;return function(){let t=w(this.childNodes);return e&&(t=t.filter(t=>e(t))),t}}function j(t,...e){const n=(t||"").split(" ").filter(Boolean);return e.forEach(t=>{t&&n.indexOf(t)<0&&n.push(t)}),n.join(" ")}t.markmap=function(t,n,r){const i=(t=t.datum?t:e.select(t)).append("style"),a=e.zoom().on("zoom",(function(){const{transform:t}=e.event;h.attr("transform",t)})),o=t.node(),s=Object.assign({duration:500,nodeFont:"300 16px/20px sans-serif",nodeMinHeight:16,spacingVertical:5,spacingHorizontal:80,autoFit:!1,fitRatio:.95,color:e.scaleOrdinal(e.schemeCategory10),colorDepth:0,paddingX:8},r),l={id:s.id||(E+=1,`mm-${$}-${E}`)},h=t.append("g").attr("class",`${l.id}-g`);return t.attr("class",j(t.attr("class"),l.id)),i.text(d()),n&&(p(n),g()),t.call(a),{setData:p,setOptions:u,fit:g};function d(){const{style:t}=s;return`.${l.id} a { color: #0097e6; }\n.${l.id} a:hover { color: #00a8ff; }\n.${l.id}-g > path { fill: none; }\n.${l.id}-fo > div { font: ${s.nodeFont}; white-space: nowrap; }\n.${l.id}-fo code { padding: .2em .4em; font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; }\n.${l.id}-fo del { text-decoration: line-through; }\n.${l.id}-fo em { font-style: italic; }\n.${l.id}-fo strong { font-weight: 500; }\n.${l.id}-fo pre { margin: 0; }\n.${l.id}-g > g { cursor: pointer; }\n${t?t(l.id):""}\n`}function u(t){Object.assign(s,t)}function p(t,e){!function(t){let e=0,n=0;const{colorDepth:r}=s,i=document.createElement("div"),a=`${l.id}-container`;i.className=j(i.className,`${l.id}-fo`,a);const o=document.createElement("style");o.textContent=`\n${d()}\n.${a} {\n position: absolute;\n width: 0;\n height: 0;\n top: -100px;\n left: -100px;\n overflow: hidden;\n font: ${s.nodeFont};\n}\n.${a} > div {\n display: inline-block;\n}\n`,document.body.append(o,i),X(t,(t,a)=>{e+=1,s.color(`${n}`);const o=document.createElement("div");o.innerHTML=t.v,i.append(o),t.p=Object.assign({i:e,c:n,el:o},t.p),a(),r&&t.d!==r||(n+=1)}),s.processHtml&&s.processHtml(w(i.childNodes)),X(t,(t,e,n)=>{var r;const i=t.p.el.getBoundingClientRect();t.v=t.p.el.innerHTML,t.p.s=[Math.ceil(i.width),Math.max(Math.ceil(i.height),s.nodeMinHeight)],t.p.k=`${(null==n||null==(r=n.p)?void 0:r.i)||""}.${t.p.i}:${t.v}`,e()}),i.remove(),o.remove()}(t),l.data=t,e&&u(e),m(t)}function f(t){return s.duration?t.transition().duration(s.duration):t}function g(){const{width:n,height:r}=o.getBoundingClientRect(),{minX:i,maxX:c,minY:h,maxY:d}=l,u=d-h,p=c-i,g=Math.min(n/u*s.fitRatio,r/p*s.fitRatio,2),x=e.zoomIdentity.translate((n-u*g)/2-h*g,(r-p*g)/2-i*g).scale(g);f(t).call(a.transform,x)}function x(t){var e;const{data:n}=t;n.p=Object.assign({},n.p,{f:!(null==(e=n.p)?void 0:e.f)}),m(t.data)}function m(t){var n,r;if(!l.data)return;const{spacingHorizontal:i}=s,a=c().children(t=>{var e;return!(null==(e=t.p)?void 0:e.f)&&t.c}).nodeSize(t=>{const[e,n]=t.data.p.s;return[n,e+(e?2*s.paddingX:0)+i]}).spacing((t,e)=>t.parent===e.parent?s.spacingVertical:2*s.spacingVertical),o=a.hierarchy(l.data);a(o),function(t,e){X(t,(t,n)=>{t.ySizeInner=t.ySize-e,t.y+=e,n()},"children")}(o,i);const d=o.descendants().reverse(),u=o.links(),p=e.linkHorizontal(),m=e.min(d,t=>t.x-t.xSize/2),y=e.max(d,t=>t.x+t.xSize/2),z=e.min(d,t=>t.y),v=e.max(d,t=>t.y+t.ySizeInner);l.minX=m,l.maxX=y,l.minY=z,l.maxY=v,s.autoFit&&g();const S=t?d.find(e=>e.data===t):o,$=null!=(n=S.data.x0)?n:S.x,E=null!=(r=S.data.y0)?r:S.y,w=h.selectAll(C("g")).data(d,t=>t.data.p.k),j=w.enter().append("g").attr("transform",t=>`translate(${E+S.ySizeInner-t.ySizeInner},${$+S.xSize/2-t.xSize})`).on("click",x),k=f(w.exit());k.select("rect").attr("width",0).attr("x",t=>t.ySizeInner),k.select("foreignObject").style("opacity",0),k.attr("transform",t=>`translate(${S.y+S.ySizeInner-t.ySizeInner},${S.x+S.xSize/2-t.xSize})`).remove();const R=w.merge(j);f(R).attr("transform",t=>`translate(${t.y},${t.x-t.xSize/2})`),f(R.selectAll(C("rect")).data(t=>[t],t=>t.data.p.k).join(t=>t.append("rect").attr("x",t=>t.ySizeInner).attr("y",t=>t.xSize-b(t)/2).attr("width",0).attr("height",b),t=>t,t=>t.remove())).attr("x",-1).attr("width",t=>t.ySizeInner+2).attr("fill",t=>s.color(t.data.p.c)),f(R.selectAll(C("circle")).data(t=>t.data.c?[t]:[],t=>t.data.p.k).join(t=>t.append("circle").attr("stroke-width","1.5").attr("cx",t=>t.ySizeInner).attr("cy",t=>t.xSize).attr("r",0),t=>t,t=>t.remove())).attr("r",6).attr("stroke",t=>s.color(t.data.p.c)).attr("fill",t=>{var e;return(null==(e=t.data.p)?void 0:e.f)?s.color(t.data.p.c):"#fff"}),f(R.selectAll(C("foreignObject")).data(t=>[t],t=>t.data.p.k).join(t=>{const e=t.append("foreignObject").attr("class",`${l.id}-fo`).attr("x",s.paddingX).attr("y",0).style("opacity",0).attr("height",t=>t.xSize);return e.append("xhtml:div").select((function(t){const e=t.data.p.el.cloneNode(!0);return this.replaceWith(e),e})).attr("xmlns","http://www.w3.org/1999/xhtml"),e},t=>t,t=>t.remove()).attr("width",t=>Math.max(0,t.ySizeInner-2*s.paddingX))).style("opacity",1);const O=h.selectAll(C("path")).data(u,t=>t.target.data.p.k).join(t=>{const e=[E+S.ySizeInner,$+S.xSize/2];return t.insert("path","g").attr("d",p({source:e,target:e}))},t=>t,t=>{const e=[S.y+S.ySizeInner,S.x+S.xSize/2];return f(t).attr("d",p({source:e,target:e})).remove()});f(O).attr("stroke",t=>s.color(t.target.data.p.c)).attr("stroke-width",t=>b(t.target)).attr("d",t=>{const e=[t.source.y+t.source.ySizeInner,t.source.x+t.source.xSize/2],n=[t.target.y,t.target.x+t.target.xSize/2];return p({source:e,target:n})}),d.forEach(t=>{t.data.x0=t.x,t.data.y0=t.y})}}}(this.markmap=this.markmap||{},d3); |
{ | ||
"name": "markmap-lib", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "Visualize your Markdown as mindmaps with Markmap", | ||
@@ -5,0 +5,0 @@ "author": "Gerald <i@gerald.top>", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
326307
8485