markmap-view 0.2.3 → 0.2.7
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/index.cjs.js +299 -334
- package/dist/index.esm.js +296 -331
- package/dist/index.js +300 -335
- package/dist/index.min.js +4 -4
- package/package.json +5 -10
- package/types/index.d.ts +53 -53
- package/types/types.d.ts +36 -38
package/dist/index.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! markmap-view v0.2.
|
|
2
|
-
!function(t,e){"use strict";function n(t){if(t&&t.__esModule)return t;var e=Object.create(null);
|
|
3
|
-
/*! markmap-common v0.1.
|
|
4
|
-
class
|
|
1
|
+
/*! markmap-view v0.2.7 | MIT License */
|
|
2
|
+
!function(t,e){"use strict";function n(t){if(t&&t.__esModule)return t;var e=Object.create(null);if(t)for(var n in t)e[n]=t[n];return e.default=t,Object.freeze(e)}var r=n(e);function i(){return i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i.apply(this,arguments)}function s(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 o(t,e){var n,r,i,s,o,l=new h(t),d=+t.value&&(l.value=t.value),u=[l];for(null==e&&(e=a);n=u.pop();)if(d&&(n.value=+n.data.value),(i=e(n.data))&&(o=i.length))for(n.children=new Array(o),s=o-1;s>=0;--s)u.push(r=n.children[s]=new h(i[s])),r.parent=n,r.depth=n.depth+1;return l.eachBefore(c)}function a(t){return t.children}function l(t){t.data=t.data.data}function c(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function h(t){this.data=t,this.depth=this.height=0,this.parent=null}h.prototype=o.prototype={constructor:h,count:function(){return this.eachAfter(s)},each:function(t){var e,n,r,i,s=this,o=[s];do{for(e=o.reverse(),o=[];s=e.pop();)if(t(s),n=s.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,s=[i],o=[];i=s.pop();)if(o.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)s.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 o(this).eachBefore(l)}};var d={name:"d3-flextree",version:"2.1.2",main:"build/d3-flextree.js",module:"index","jsnext:main":"index",author:{name:"Chris Maloney",url:"http://chrismaloney.org"},description:"Flexible tree layout algorithm that allows for variable node sizes.",keywords:["d3","d3-module","layout","tree","hierarchy","d3-hierarchy","plugin","d3-plugin","infovis","visualization","2d"],homepage:"https://github.com/klortho/d3-flextree",license:"WTFPL",repository:{type:"git",url:"https://github.com/klortho/d3-flextree.git"},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"},dependencies:{"d3-hierarchy":"^1.1.5"},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"}};const{version:u}=d,p=Object.freeze({children:t=>t.children,nodeSize:t=>t.data.size,spacing:0});function f(t){const e=Object.assign({},p,t);function n(t){const n=e[t];return"function"==typeof n?n:()=>n}function r(t){const e=s(function(){const t=i(),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 g(this),m(this),this}}}(),t,(t=>t.children));return e.update(),e.data}function i(){const t=n("nodeSize"),e=n("spacing");return class n extends o.prototype.constructor{constructor(t){super(t)}copy(){const t=s(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 s(t,e,n){const r=(e,i)=>{const s=new t(e);Object.assign(s,{parent:i,depth:null===i?0:i.depth+1,height:0,length:1});const o=n(e)||[];return s.children=0===o.length?null:o.map((t=>r(t,s))),s.children&&Object.assign(s,s.children.reduce(((t,e)=>({height:Math.max(t.height,e.height+1),length:t.length+e.length})),s)),s};return r(e,null)}return Object.assign(r,{nodeSize(t){return arguments.length?(e.nodeSize=t,r):e.nodeSize},spacing(t){return arguments.length?(e.spacing=t,r):e.spacing},children(t){return arguments.length?(e.children=t,r):e.children},hierarchy(t,n){const r=void 0===n?e.children:n;return s(i(),t,r)},dump(t){const e=n("nodeSize"),r=t=>n=>{const i=t+" ",s=t+" ",{x:o,y:a}=n,l=e(n),c=n.children||[],h=0===c.length?" ":`,${i}children: [${s}${c.map(r(s)).join(s)}${i}],${t}`;return`{ size: [${l.join(", ")}],${i}x: ${o}, y: ${a}${h}},`};return r("\n")(t)}}),r}f.version=u;const g=(t,e=0)=>(t.y=e,(t.children||[]).reduce(((e,n)=>{const[r,i]=e;g(n,t.y+t.ySize);const s=(0===r?n.lExt:n.rExt).bottom;0!==r&&y(t,r,i);return[r+1,$(s,r,i)]}),[0,null]),x(t),E(t),t),m=(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=>m(e,r,t.x))),t},x=t=>{(t.children||[]).reduce(((t,e)=>{const[n,r]=t,i=n+e.shift,s=r+i+e.change;return e.relX+=s,[i,s]}),[0,0])},y=(t,e,n)=>{const r=t.children[e-1],i=t.children[e];let s=r,o=r.relX,a=i,l=i.relX,c=!0;for(;s&&a;){s.bottom>n.lowY&&(n=n.next);const r=o+s.prelim-(l+a.prelim)+s.xSize/2+a.xSize/2+s.spacing(a);(r>0||r<0&&c)&&(l+=r,v(i,r),z(t,e,n.index,r)),c=!1;const h=s.bottom,d=a.bottom;h<=d&&(s=S(s),s&&(o+=s.relX)),h>=d&&(a=b(a),a&&(l+=a.relX))}!s&&a?k(t,e,a,l):s&&!a&&w(t,e,s,o)},v=(t,e)=>{t.relX+=e,t.lExtRelX+=e,t.rExtRelX+=e},z=(t,e,n,r)=>{const i=t.children[e],s=e-n;if(s>1){const e=r/s;t.children[n+1].shift+=e,i.shift-=e,i.change-=r-e}},b=t=>t.hasChildren?t.firstChild:t.lThr,S=t=>t.hasChildren?t.lastChild:t.rThr,k=(t,e,n,r)=>{const i=t.firstChild,s=i.lExt,o=t.children[e];s.lThr=n;const a=r-n.relX-i.lExtRelX;s.relX+=a,s.prelim-=a,i.lExt=o.lExt,i.lExtRelX=o.lExtRelX},w=(t,e,n,r)=>{const i=t.children[e],s=i.rExt,o=t.children[e-1];s.rThr=n;const a=r-n.relX-i.rExtRelX;s.relX+=a,s.prelim-=a,i.rExt=o.rExt,i.rExtRelX=o.rExtRelX},E=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})}},$=(t,e,n)=>{for(;null!==n&&t>=n.lowY;)n=n.next;return{lowY:t,index:e,next:n}};
|
|
3
|
+
/*! markmap-common v0.1.6 | MIT License */
|
|
4
|
+
class X{constructor(){this.listeners=[]}tap(t){return this.listeners.push(t),()=>this.revoke(t)}revoke(t){const e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)}revokeAll(){this.listeners.splice(0)}call(...t){for(const e of this.listeners)e(...t)}}function j(){return j=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},j.apply(this,arguments)}const C=Math.random().toString(36).slice(2,8);let O=0;function M(){}function I(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 R(t){if(Array.from)return Array.from(t);const e=[];for(let n=0;n<t.length;n+=1)e.push(t[n]);return e}function A(t,...e){const n=(t||"").split(" ").filter(Boolean);return e.forEach((t=>{t&&n.indexOf(t)<0&&n.push(t)})),n.join(" ")}function B(t){if("string"==typeof t){const e=t;t=t=>t.tagName===e}const e=t;return function(){let t=R(this.childNodes);return e&&(t=t.filter((t=>e(t)))),t}}function D(t,e,n){const r=document.createElement(t);return e&&Object.entries(e).forEach((([t,e])=>{r[t]=e})),n&&Object.entries(n).forEach((([t,e])=>{r.setAttribute(t,e)})),r}const H=function(t){const e={};return function(...n){const r=`${n[0]}`;let i=e[r];return i||(i={value:t(...n)},e[r]=i),i.value}}((t=>{document.head.append(D("link",{rel:"preload",as:"script",href:t}))}));function T(t,e){if("script"===t.type)return new Promise(((e,n)=>{var r;document.head.append(D("script",j({},t.data,{onload:e,onerror:n}))),null!=(r=t.data)&&r.src||e()}));if("iife"===t.type){const{fn:n,getParams:r}=t.data;n(...(null==r?void 0:r(e))||[])}}function N(t){"style"===t.type?document.head.append(D("style",{textContent:t.data})):"stylesheet"===t.type&&document.head.append(D("link",j({rel:"stylesheet"},t.data)))}function F(t){const e=t.data;return Math.max(6-2*e.d,1.5)}function L(t,e){return t[r.minIndex(t,e)]}function Y(t){t.stopPropagation()}const P=new X;class U{constructor(t,e){this.revokers=[],["handleZoom","handleClick"].forEach((t=>{this[t]=this[t].bind(this)})),this.viewHooks={transformHtml:new X},this.svg=t.datum?t:r.select(t),this.styleNode=this.svg.append("style"),this.zoom=r.zoom().on("zoom",this.handleZoom),this.options=i({},U.defaultOptions,e),this.state={id:this.options.id||(O+=1,`mm-${C}-${O}`)},this.g=this.svg.append("g").attr("class",`${this.state.id}-g`),this.updateStyle(),this.svg.call(this.zoom),this.revokers.push(P.tap((()=>{this.setData()})))}getStyleContent(){const{style:t,nodeFont:e}=this.options,{id:n}=this.state;return`.${n} { line-height: 1; }\n.${n} a { color: #0097e6; }\n.${n} a:hover { color: #00a8ff; }\n.${n}-g > path { fill: none; }\n.${n}-g > g > circle { cursor: pointer; }\n.${n}-fo > div { display: inline-block; font: ${e}; white-space: nowrap; }\n.${n}-fo code { font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; }\n.${n}-fo :not(pre) > code { padding: .2em .4em; }\n.${n}-fo del { text-decoration: line-through; }\n.${n}-fo em { font-style: italic; }\n.${n}-fo strong { font-weight: bolder; }\n.${n}-fo pre { margin: 0; padding: .2em .4em; }\n${"function"==typeof t?t(n):""}\n`}updateStyle(){this.svg.attr("class",A(this.svg.attr("class"),this.state.id)),this.styleNode.text(this.getStyleContent())}handleZoom(t){const{transform:e}=t;this.g.attr("transform",e)}handleClick(t,e){var n;const{data:r}=e;r.p=i({},r.p,{f:!(null!=(n=r.p)&&n.f)}),this.renderData(e.data)}initializeData(t){let e=0;const{nodeFont:n,color:r,nodeMinHeight:s}=this.options,{id:o}=this.state,a=document.createElement("div"),l=`${o}-container`;a.className=A(a.className,`${o}-fo`,l);const c=document.createElement("style");c.textContent=`\n${this.getStyleContent()}\n.${l} {\n position: absolute;\n width: 0;\n height: 0;\n top: -100px;\n left: -100px;\n overflow: hidden;\n font: ${n};\n}\n.${l} > div {\n display: inline-block;\n}\n`,document.body.append(c,a),I(t,((t,n)=>{var s;t.c=null==(s=t.c)?void 0:s.map((t=>i({},t))),e+=1;const o=document.createElement("div");o.innerHTML=t.v,a.append(o),t.p=i({},t.p,{i:e,el:o}),r(t),n()}));const h=R(a.childNodes);this.viewHooks.transformHtml.call(this,h),I(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)],t.p.k=`${(null==n||null==(r=n.p)?void 0:r.i)||""}.${t.p.i}:${t.v}`,e()})),a.remove(),c.remove()}setOptions(t){Object.assign(this.options,t)}setData(t,e){t&&(this.state.data=t),this.initializeData(this.state.data),e&&this.setOptions(e),this.renderData()}renderData(t){var e,n;if(!this.state.data)return;const{spacingHorizontal:i,paddingX:s,spacingVertical:o,autoFit:a,color:l}=this.options,{id:c}=this.state,h=f().children((t=>{var e;return!(null!=(e=t.p)&&e.f)&&t.c})).nodeSize((t=>{const[e,n]=t.data.p.s;return[n,e+(e?2*s:0)+i]})).spacing(((t,e)=>t.parent===e.parent?o:2*o)),d=h.hierarchy(this.state.data);h(d),function(t,e){I(t,((t,n)=>{t.ySizeInner=t.ySize-e,t.y+=e,n()}),"children")}(d,i);const u=d.descendants().reverse(),p=d.links(),g=r.linkHorizontal(),m=r.min(u,(t=>t.x-t.xSize/2)),x=r.max(u,(t=>t.x+t.xSize/2)),y=r.min(u,(t=>t.y)),v=r.max(u,(t=>t.y+t.ySizeInner));Object.assign(this.state,{minX:m,maxX:x,minY:y,maxY:v}),a&&this.fit();const z=t&&u.find((e=>e.data===t))||d,b=null!=(e=z.data.p.x0)?e:z.x,S=null!=(n=z.data.p.y0)?n:z.y,k=this.g.selectAll(B("g")).data(u,(t=>t.data.p.k)),w=k.enter().append("g").attr("transform",(t=>`translate(${S+z.ySizeInner-t.ySizeInner},${b+z.xSize/2-t.xSize})`)),E=this.transition(k.exit());E.select("rect").attr("width",0).attr("x",(t=>t.ySizeInner)),E.select("foreignObject").style("opacity",0),E.attr("transform",(t=>`translate(${z.y+z.ySizeInner-t.ySizeInner},${z.x+z.xSize/2-t.xSize})`)).remove();const $=k.merge(w);this.transition($).attr("transform",(t=>`translate(${t.y},${t.x-t.xSize/2})`));const X=$.selectAll(B("rect")).data((t=>[t]),(t=>t.data.p.k)).join((t=>t.append("rect").attr("x",(t=>t.ySizeInner)).attr("y",(t=>t.xSize-F(t)/2)).attr("width",0).attr("height",F)),(t=>t),(t=>t.remove()));this.transition(X).attr("x",-1).attr("width",(t=>t.ySizeInner+2)).attr("fill",(t=>l(t.data)));const j=$.selectAll(B("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).on("click",this.handleClick)),(t=>t),(t=>t.remove()));this.transition(j).attr("r",6).attr("stroke",(t=>l(t.data))).attr("fill",(t=>{var e;return null!=(e=t.data.p)&&e.f&&t.data.c?l(t.data):"#fff"}));const C=$.selectAll(B("foreignObject")).data((t=>[t]),(t=>t.data.p.k)).join((t=>{const e=t.append("foreignObject").attr("class",`${c}-fo`).attr("x",s).attr("y",0).style("opacity",0).attr("height",(t=>t.xSize)).on("mousedown",Y).on("dblclick",Y);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)));this.transition(C).style("opacity",1);const O=this.g.selectAll(B("path")).data(p,(t=>t.target.data.p.k)).join((t=>{const e=[S+z.ySizeInner,b+z.xSize/2];return t.insert("path","g").attr("d",g({source:e,target:e}))}),(t=>t),(t=>{const e=[z.y+z.ySizeInner,z.x+z.xSize/2];return this.transition(t).attr("d",g({source:e,target:e})).remove()}));this.transition(O).attr("stroke",(t=>l(t.target.data))).attr("stroke-width",(t=>F(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 g({source:e,target:n})})),u.forEach((t=>{t.data.p.x0=t.x,t.data.p.y0=t.y}))}transition(t){const{duration:e}=this.options;return t.transition().duration(e)}async fit(){const t=this.svg.node(),{width:e,height:n}=t.getBoundingClientRect(),{fitRatio:i}=this.options,{minX:s,maxX:o,minY:a,maxY:l}=this.state,c=l-a,h=o-s,d=Math.min(e/c*i,n/h*i,2),u=r.zoomIdentity.translate((e-c*d)/2-a*d,(n-h*d)/2-s*d).scale(d);return this.transition(this.svg).call(this.zoom.transform,u).end().catch(M)}async ensureView(t,e){let n,s;if(this.g.selectAll(B("g")).each((function(e){e.data===t&&(n=this,s=e)})),!n||!s)return;const o=this.svg.node(),a=o.getBoundingClientRect(),l=r.zoomTransform(o),[c,h]=[s.y,s.y+s.ySizeInner+2].map((t=>t*l.k+l.x)),[d,u]=[s.x-s.xSize/2,s.x+s.xSize/2].map((t=>t*l.k+l.y)),p=i({left:0,right:0,top:0,bottom:0},e),f=[p.left-c,a.width-p.right-h],g=[p.top-d,a.height-p.bottom-u],m=f[0]*f[1]>0?L(f,Math.abs)/l.k:0,x=g[0]*g[1]>0?L(g,Math.abs)/l.k:0;if(m||x){const t=l.translate(m,x);return this.transition(this.svg).call(this.zoom.transform,t).end().catch(M)}}async rescale(t){const e=this.svg.node(),{width:n,height:i}=e.getBoundingClientRect(),s=n/2,o=i/2,a=r.zoomTransform(e),l=a.translate((s-a.x)*(1-t)/a.k,(o-a.y)*(1-t)/a.k).scale(t);return this.transition(this.svg).call(this.zoom.transform,l).end().catch(M)}destroy(){this.svg.remove(),this.revokers.forEach((t=>{t()}))}static create(t,e,n){const r=new U(t,e);return n&&(r.setData(n),r.fit()),r}}var V;U.defaultOptions={duration:500,nodeFont:"300 16px/20px sans-serif",nodeMinHeight:16,spacingVertical:5,spacingHorizontal:80,autoFit:!1,fitRatio:.95,color:(V=r.scaleOrdinal(r.schemeCategory10),t=>V(t.p.i)),paddingX:8},t.Markmap=U,t.loadCSS=function(t){for(const e of t)N(e)},t.loadJS=async function(t,e){const n=t.filter((t=>{var e;return"script"===t.type&&(null==(e=t.data)?void 0:e.src)}));n.length>1&&n.forEach((t=>H(t.data.src))),e=j({getMarkmap:()=>window.markmap},e);for(const n of t)await T(n,e)},t.refreshHook=P}(this.markmap=this.markmap||{},d3);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markmap-view",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "View markmaps in browser",
|
|
5
5
|
"author": "Gerald <gera2ld@live.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,14 +20,9 @@
|
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"dev": "rollup -wc rollup.conf.js",
|
|
23
|
-
"clean": "del-cli dist",
|
|
24
|
-
"prebuild": "run-s ci clean",
|
|
25
|
-
"prepublishOnly": "run-s build",
|
|
26
|
-
"ci": "run-s lint",
|
|
27
|
-
"lint": "eslint --ext .ts .",
|
|
23
|
+
"clean": "del-cli dist types",
|
|
28
24
|
"build:js": "rollup -c rollup.conf.js",
|
|
29
|
-
"build:types": "tsc"
|
|
30
|
-
"build": "run-s build:types build:js"
|
|
25
|
+
"build:types": "tsc"
|
|
31
26
|
},
|
|
32
27
|
"bugs": {
|
|
33
28
|
"url": "https://github.com/gera2ld/markmap/issues"
|
|
@@ -46,10 +41,10 @@
|
|
|
46
41
|
"@types/d3": "^6.0.0",
|
|
47
42
|
"d3": "^6.2.0",
|
|
48
43
|
"d3-flextree": "^2.1.1",
|
|
49
|
-
"markmap-common": "^0.1.
|
|
44
|
+
"markmap-common": "^0.1.6"
|
|
50
45
|
},
|
|
51
46
|
"engines": {
|
|
52
47
|
"node": ">=10"
|
|
53
48
|
},
|
|
54
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "fbec667e1706813f9f60bea6a971f3820858ca40"
|
|
55
50
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import * as d3 from 'd3';
|
|
2
|
-
import { INode, Hook, loadJS, loadCSS } from 'markmap-common';
|
|
3
|
-
import { IMarkmapOptions, IMarkmapState, IMarkmapFlexTreeItem } from './types';
|
|
4
|
-
export { loadJS, loadCSS };
|
|
5
|
-
interface IPadding {
|
|
6
|
-
left: number;
|
|
7
|
-
right: number;
|
|
8
|
-
top: number;
|
|
9
|
-
bottom: number;
|
|
10
|
-
}
|
|
11
|
-
declare type ID3SVGElement = d3.Selection<SVGElement, IMarkmapFlexTreeItem, HTMLElement, IMarkmapFlexTreeItem>;
|
|
12
|
-
declare function createViewHooks(): {
|
|
13
|
-
transformHtml: Hook<
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* A global hook to refresh all markmaps when called.
|
|
17
|
-
*/
|
|
18
|
-
export declare const refreshHook: Hook<
|
|
19
|
-
export declare class Markmap {
|
|
20
|
-
static defaultOptions: IMarkmapOptions;
|
|
21
|
-
options: IMarkmapOptions;
|
|
22
|
-
state: IMarkmapState;
|
|
23
|
-
svg: ID3SVGElement;
|
|
24
|
-
styleNode: d3.Selection<HTMLStyleElement, IMarkmapFlexTreeItem, HTMLElement, IMarkmapFlexTreeItem>;
|
|
25
|
-
g: d3.Selection<SVGGElement, IMarkmapFlexTreeItem, HTMLElement, IMarkmapFlexTreeItem>;
|
|
26
|
-
zoom: d3.ZoomBehavior<Element, unknown>;
|
|
27
|
-
viewHooks: ReturnType<typeof createViewHooks>;
|
|
28
|
-
revokers: (() => void)[];
|
|
29
|
-
constructor(svg: string | SVGElement | ID3SVGElement, opts?: IMarkmapOptions);
|
|
30
|
-
getStyleContent(): string;
|
|
31
|
-
updateStyle(): void;
|
|
32
|
-
handleZoom(e: any): void;
|
|
33
|
-
handleClick(e: any, d: IMarkmapFlexTreeItem): void;
|
|
34
|
-
initializeData(node: INode): void;
|
|
35
|
-
setOptions(opts: IMarkmapOptions): void;
|
|
36
|
-
setData(data?: INode, opts?: IMarkmapOptions): void;
|
|
37
|
-
renderData(originData?: INode): void;
|
|
38
|
-
transition<T extends d3.BaseType, U, P extends d3.BaseType, Q>(sel: d3.Selection<T, U, P, Q>): d3.Transition<T, U, P, Q>;
|
|
39
|
-
/**
|
|
40
|
-
* Fit the content to the viewport.
|
|
41
|
-
*/
|
|
42
|
-
fit(): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Pan the content to make the provided node visible in the viewport.
|
|
45
|
-
*/
|
|
46
|
-
ensureView(node: INode, padding: Partial<IPadding> | undefined): Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* Scale content with it pinned at the center of the viewport.
|
|
49
|
-
*/
|
|
50
|
-
rescale(scale: number): Promise<void>;
|
|
51
|
-
destroy(): void;
|
|
52
|
-
static create(svg: string | SVGElement | ID3SVGElement, opts?: IMarkmapOptions, data?: INode): Markmap;
|
|
53
|
-
}
|
|
1
|
+
import * as d3 from 'd3';
|
|
2
|
+
import { INode, Hook, loadJS, loadCSS } from 'markmap-common';
|
|
3
|
+
import { IMarkmapOptions, IMarkmapState, IMarkmapFlexTreeItem } from './types';
|
|
4
|
+
export { loadJS, loadCSS };
|
|
5
|
+
interface IPadding {
|
|
6
|
+
left: number;
|
|
7
|
+
right: number;
|
|
8
|
+
top: number;
|
|
9
|
+
bottom: number;
|
|
10
|
+
}
|
|
11
|
+
declare type ID3SVGElement = d3.Selection<SVGElement, IMarkmapFlexTreeItem, HTMLElement, IMarkmapFlexTreeItem>;
|
|
12
|
+
declare function createViewHooks(): {
|
|
13
|
+
transformHtml: Hook<[mm: Markmap, nodes: HTMLElement[]]>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A global hook to refresh all markmaps when called.
|
|
17
|
+
*/
|
|
18
|
+
export declare const refreshHook: Hook<[]>;
|
|
19
|
+
export declare class Markmap {
|
|
20
|
+
static defaultOptions: IMarkmapOptions;
|
|
21
|
+
options: IMarkmapOptions;
|
|
22
|
+
state: IMarkmapState;
|
|
23
|
+
svg: ID3SVGElement;
|
|
24
|
+
styleNode: d3.Selection<HTMLStyleElement, IMarkmapFlexTreeItem, HTMLElement, IMarkmapFlexTreeItem>;
|
|
25
|
+
g: d3.Selection<SVGGElement, IMarkmapFlexTreeItem, HTMLElement, IMarkmapFlexTreeItem>;
|
|
26
|
+
zoom: d3.ZoomBehavior<Element, unknown>;
|
|
27
|
+
viewHooks: ReturnType<typeof createViewHooks>;
|
|
28
|
+
revokers: (() => void)[];
|
|
29
|
+
constructor(svg: string | SVGElement | ID3SVGElement, opts?: IMarkmapOptions);
|
|
30
|
+
getStyleContent(): string;
|
|
31
|
+
updateStyle(): void;
|
|
32
|
+
handleZoom(e: any): void;
|
|
33
|
+
handleClick(e: any, d: IMarkmapFlexTreeItem): void;
|
|
34
|
+
initializeData(node: INode): void;
|
|
35
|
+
setOptions(opts: IMarkmapOptions): void;
|
|
36
|
+
setData(data?: INode, opts?: IMarkmapOptions): void;
|
|
37
|
+
renderData(originData?: INode): void;
|
|
38
|
+
transition<T extends d3.BaseType, U, P extends d3.BaseType, Q>(sel: d3.Selection<T, U, P, Q>): d3.Transition<T, U, P, Q>;
|
|
39
|
+
/**
|
|
40
|
+
* Fit the content to the viewport.
|
|
41
|
+
*/
|
|
42
|
+
fit(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Pan the content to make the provided node visible in the viewport.
|
|
45
|
+
*/
|
|
46
|
+
ensureView(node: INode, padding: Partial<IPadding> | undefined): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Scale content with it pinned at the center of the viewport.
|
|
49
|
+
*/
|
|
50
|
+
rescale(scale: number): Promise<void>;
|
|
51
|
+
destroy(): void;
|
|
52
|
+
static create(svg: string | SVGElement | ID3SVGElement, opts?: IMarkmapOptions, data?: INode): Markmap;
|
|
53
|
+
}
|
package/types/types.d.ts
CHANGED
|
@@ -1,38 +1,36 @@
|
|
|
1
|
-
import { INode } from 'markmap-common';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
target: IMarkmapFlexTreeItem;
|
|
38
|
-
}
|
|
1
|
+
import { INode } from 'markmap-common';
|
|
2
|
+
export interface IMarkmapOptions {
|
|
3
|
+
id?: string;
|
|
4
|
+
duration?: number;
|
|
5
|
+
nodeFont?: string;
|
|
6
|
+
nodeMinHeight?: number;
|
|
7
|
+
spacingVertical?: number;
|
|
8
|
+
spacingHorizontal?: number;
|
|
9
|
+
autoFit?: boolean;
|
|
10
|
+
fitRatio?: number;
|
|
11
|
+
color?: (node: INode) => string;
|
|
12
|
+
paddingX?: number;
|
|
13
|
+
style?: (id: string) => string;
|
|
14
|
+
}
|
|
15
|
+
export interface IMarkmapState {
|
|
16
|
+
id: string;
|
|
17
|
+
data?: INode;
|
|
18
|
+
minX?: number;
|
|
19
|
+
maxX?: number;
|
|
20
|
+
minY?: number;
|
|
21
|
+
maxY?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface IMarkmapFlexTreeItem {
|
|
24
|
+
parent: IMarkmapFlexTreeItem;
|
|
25
|
+
data: INode;
|
|
26
|
+
depth: number;
|
|
27
|
+
xSize: number;
|
|
28
|
+
ySize: number;
|
|
29
|
+
ySizeInner: number;
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
}
|
|
33
|
+
export interface IMarkmapLinkItem {
|
|
34
|
+
source: IMarkmapFlexTreeItem;
|
|
35
|
+
target: IMarkmapFlexTreeItem;
|
|
36
|
+
}
|