markmap-view
Advanced tools
Comparing version 0.14.2-alpha.4 to 0.14.2
@@ -1,2 +0,2 @@ | ||
/*! markmap-view v0.14.2-alpha.4+569dd11 | MIT License */ | ||
/*! markmap-view v0.14.2 | MIT License */ | ||
'use strict'; | ||
@@ -1168,5 +1168,5 @@ | ||
id: nodeId, | ||
el: group.firstChild, | ||
path: [parent == null ? void 0 : (_parent$state = parent.state) == null ? void 0 : _parent$state.path, item.state.id].filter(Boolean).join('.') | ||
el: group.firstChild | ||
}); | ||
item.state.path = [parent == null ? void 0 : (_parent$state = parent.state) == null ? void 0 : _parent$state.path, item.state.id].filter(Boolean).join('.'); | ||
color(item); // preload colors | ||
@@ -1483,3 +1483,3 @@ | ||
state: _extends({}, node.state, { | ||
path: node.state.path.split('.').slice(0, colorFreezeLevel + 1).join('.') | ||
path: node.state.path.split('.').slice(0, colorFreezeLevel).join('.') | ||
}) | ||
@@ -1486,0 +1486,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
/*! markmap-view v0.14.2-alpha.4+569dd11 | MIT License */ | ||
/*! markmap-view v0.14.2 | MIT License */ | ||
import { Hook, getId, addClass, walkTree, arrayFrom, childSelector, noop } from 'markmap-common'; | ||
@@ -1153,5 +1153,5 @@ export { loadCSS, loadJS } from 'markmap-common'; | ||
id: nodeId, | ||
el: group.firstChild, | ||
path: [parent == null ? void 0 : (_parent$state = parent.state) == null ? void 0 : _parent$state.path, item.state.id].filter(Boolean).join('.') | ||
el: group.firstChild | ||
}); | ||
item.state.path = [parent == null ? void 0 : (_parent$state = parent.state) == null ? void 0 : _parent$state.path, item.state.id].filter(Boolean).join('.'); | ||
color(item); // preload colors | ||
@@ -1468,3 +1468,3 @@ | ||
state: _extends({}, node.state, { | ||
path: node.state.path.split('.').slice(0, colorFreezeLevel + 1).join('.') | ||
path: node.state.path.split('.').slice(0, colorFreezeLevel).join('.') | ||
}) | ||
@@ -1471,0 +1471,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
/*! markmap-view v0.14.2-alpha.4+569dd11 | MIT License */ | ||
/*! markmap-view v0.14.2 | MIT License */ | ||
(function (exports, markmapCommon, d3) { | ||
@@ -1166,5 +1166,5 @@ 'use strict'; | ||
id: nodeId, | ||
el: group.firstChild, | ||
path: [parent == null ? void 0 : (_parent$state = parent.state) == null ? void 0 : _parent$state.path, item.state.id].filter(Boolean).join('.') | ||
el: group.firstChild | ||
}); | ||
item.state.path = [parent == null ? void 0 : (_parent$state = parent.state) == null ? void 0 : _parent$state.path, item.state.id].filter(Boolean).join('.'); | ||
color(item); // preload colors | ||
@@ -1481,3 +1481,3 @@ | ||
state: _extends({}, node.state, { | ||
path: node.state.path.split('.').slice(0, colorFreezeLevel + 1).join('.') | ||
path: node.state.path.split('.').slice(0, colorFreezeLevel).join('.') | ||
}) | ||
@@ -1484,0 +1484,0 @@ }); |
@@ -1,4 +0,4 @@ | ||
/*! markmap-view v0.14.2-alpha.4+569dd11 | MIT License */ | ||
/*! markmap-view v0.14.2 | MIT License */ | ||
!function(t,e,n){"use strict";function r(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 i=r(n);function a(){return a=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},a.apply(this,arguments)}function o(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 s(t,e){var n,r,i,a,o,s=new d(t),h=+t.value&&(s.value=t.value),p=[s];for(null==e&&(e=l);n=p.pop();)if(h&&(n.value=+n.data.value),(i=e(n.data))&&(o=i.length))for(n.children=new Array(o),a=o-1;a>=0;--a)p.push(r=n.children[a]=new d(i[a])),r.parent=n,r.depth=n.depth+1;return s.eachBefore(c)}function l(t){return t.children}function h(t){t.data=t.data.data}function c(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function d(t){this.data=t,this.depth=this.height=0,this.parent=null}d.prototype=s.prototype={constructor:d,count:function(){return this.eachAfter(o)},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 s(this).eachBefore(h)}};var p={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}=p,f=Object.freeze({children:t=>t.children,nodeSize:t=>t.data.size,spacing:0});function m(t){const e=Object.assign({},f,t);function n(t){const n=e[t];return"function"==typeof n?n:()=>n}function r(t){const e=a(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),y(this),this}}}(),t,(t=>t.children));return e.update(),e.data}function i(){const t=n("nodeSize"),e=n("spacing");return class n extends s.prototype.constructor{constructor(t){super(t)}copy(){const t=a(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 a(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(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 a(i(),t,r)},dump(t){const e=n("nodeSize"),r=t=>n=>{const i=t+" ",a=t+" ",{x:o,y:s}=n,l=e(n),h=n.children||[],c=0===h.length?" ":`,${i}children: [${a}${h.map(r(a)).join(a)}${i}],${t}`;return`{ size: [${l.join(", ")}],${i}x: ${o}, y: ${s}${c}},`};return r("\n")(t)}}),r}m.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 a=(0===r?n.lExt:n.rExt).bottom;0!==r&&v(t,r,i);return[r+1,j(a,r,i)]}),[0,null]),x(t),C(t),t),y=(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=>y(e,r,t.x))),t},x=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])},v=(t,e,n)=>{const r=t.children[e-1],i=t.children[e];let a=r,o=r.relX,s=i,l=i.relX,h=!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&&h)&&(l+=r,k(i,r),z(t,e,n.index,r)),h=!1;const c=a.bottom,d=s.bottom;c<=d&&(a=b(a),a&&(o+=a.relX)),c>=d&&(s=S(s),s&&(l+=s.relX))}!a&&s?w(t,e,s,l):a&&!s&&E(t,e,a,o)},k=(t,e)=>{t.relX+=e,t.lExtRelX+=e,t.rExtRelX+=e},z=(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}},S=t=>t.hasChildren?t.firstChild:t.lThr,b=t=>t.hasChildren?t.lastChild:t.rThr,w=(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},E=(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},C=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})}},j=(t,e,n)=>{for(;null!==n&&t>=n.lowY;)n=n.next;return{lowY:t,index:e,next:n}}; | ||
/*! @gera2ld/jsx-dom v2.1.1 | ISC License */ | ||
var X="http://www.w3.org/1999/xlink",I={show:X,actuate:X,href:X};function O(t,e){var n;if("string"==typeof t)n=1;else{if("function"!=typeof t)throw new Error("Invalid VNode type");n=2}return{vtype:n,type:t,props:e}}function M(t){return t.children}var A={isSvg:!1};function R(t,e){if(1===e.type)null!=e.node&&t.append(e.node);else{if(4!==e.type)throw new Error("Unkown ref type "+JSON.stringify(e));e.children.forEach((function(e){R(t,e)}))}}var T={className:"class",labelFor:"for"};function $(t,e,n,r){if(e=T[e]||e,!0===n)t.setAttribute(e,"");else if(!1===n)t.removeAttribute(e);else{var i=r?I[e]:void 0;void 0!==i?t.setAttributeNS(i,e,n):t.setAttribute(e,n)}}function B(t,e){if(void 0===e&&(e=A),null==t||"boolean"==typeof t)return{type:1,node:null};if(t instanceof Node)return{type:1,node:t};if(2===(null==(o=t)?void 0:o.vtype)){var n=t,r=n.type,i=n.props;if(r===M){var a=document.createDocumentFragment();if(i.children)R(a,B(i.children,e));return{type:1,node:a}}return B(r(i),e)}var o;if(function(t){return"string"==typeof t||"number"==typeof t}(t))return{type:1,node:document.createTextNode(""+t)};if(function(t){return 1===(null==t?void 0:t.vtype)}(t)){var s,l,h=t,c=h.type,d=h.props;if(e.isSvg||"svg"!==c||(e=Object.assign({},e,{isSvg:!0})),function(t,e,n){for(var r in e)"key"!==r&&"children"!==r&&"ref"!==r&&("dangerouslySetInnerHTML"===r?t.innerHTML=e[r].__html:"innerHTML"===r||"textContent"===r||"innerText"===r?t[r]=e[r]:r.startsWith("on")?t[r.toLowerCase()]=e[r]:$(t,r,e[r],n.isSvg))}(s=e.isSvg?document.createElementNS("http://www.w3.org/2000/svg",c):document.createElement(c),d,e),d.children){var p=e;e.isSvg&&"foreignObject"===c&&(p=Object.assign({},p,{isSvg:!1})),l=B(d.children,p)}null!=l&&R(s,l);var u=d.ref;return"function"==typeof u&&u(s),{type:1,node:s}}if(Array.isArray(t))return{type:4,children:t.map((function(t){return B(t,e)}))};throw new Error("mount: Invalid Vnode!")}function H(t){for(var e=[],n=0;n<t.length;n+=1){var r=t[n];Array.isArray(r)?e=e.concat(H(r)):null!=r&&e.push(r)}return e}function D(t){return 1===t.type?t.node:t.children.map(D)}function L(t){return Array.isArray(t)?H(t.map(L)):D(B(t))}var N=".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}",F=".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}";function P(t){const e=t.data;return Math.max(4-2*e.depth,1.5)}function Y(t,e){return t[i.minIndex(t,e)]}function W(t){t.stopPropagation()}const _=new e.Hook,U=i.scaleOrdinal(i.schemeCategory10),V="undefined"!=typeof navigator&&navigator.userAgent.includes("Macintosh");class J{constructor(t,n){this.revokers=[],["handleZoom","handleClick","handlePan"].forEach((t=>{this[t]=this[t].bind(this)})),this.viewHooks={transformHtml:new e.Hook},this.svg=t.datum?t:i.select(t),this.styleNode=this.svg.append("style"),this.zoom=i.zoom().filter((t=>this.options.scrollForPan&&"wheel"===t.type?t.ctrlKey&&!t.button:!(t.ctrlKey&&"wheel"!==t.type||t.button))).on("zoom",this.handleZoom),this.setOptions(n),this.state={id:this.options.id||this.svg.attr("id")||e.getId()},this.g=this.svg.append("g"),this.updateStyle(),this.revokers.push(_.tap((()=>{this.setData()})))}getStyleContent(){const{style:t}=this.options,{id:e}=this.state,n="function"==typeof t?t(e):"";return[this.options.embedGlobalCSS&&N,n].filter(Boolean).join("\n")}updateStyle(){this.svg.attr("class",e.addClass(this.svg.attr("class"),"markmap",this.state.id));const t=this.getStyleContent();this.styleNode.text(t)}handleZoom(t){const{transform:e}=t;this.g.attr("transform",e)}handlePan(t){t.preventDefault();const e=i.zoomTransform(this.svg.node()),n=e.translate(-t.deltaX/e.k,-t.deltaY/e.k);this.svg.call(this.zoom.transform,n)}handleClick(t,e){var n;const{data:r}=e;r.payload=a({},r.payload,{fold:null!=(n=r.payload)&&n.fold?0:1}),this.renderData(e.data)}initializeData(t){let n=0;const{color:r,nodeMinHeight:i,maxWidth:o,initialExpandLevel:s}=this.options,{id:l}=this.state,h=L(O("div",{className:`markmap-container markmap ${l}-g`})),c=L(O("style",{children:[this.getStyleContent(),F].join("\n")}));document.body.append(h,c);const d=o?`max-width: ${o}px`:"";let p=0;e.walkTree(t,((t,e,i)=>{var o,l,c;t.children=null==(o=t.children)?void 0:o.map((t=>a({},t))),n+=1;const u=L(O("div",{className:"markmap-foreign",style:d,children:O("div",{dangerouslySetInnerHTML:{__html:t.content}})}));h.append(u),t.state=a({},t.state,{id:n,el:u.firstChild,path:[null==i||null==(l=i.state)?void 0:l.path,t.state.id].filter(Boolean).join(".")}),r(t);const f=2===(null==(c=t.payload)?void 0:c.fold);f?p+=1:(p||s>=0&&t.depth>=s)&&(t.payload=a({},t.payload,{fold:1})),e(),f&&(p-=1)}));const u=e.arrayFrom(h.childNodes).map((t=>t.firstChild));this.viewHooks.transformHtml.call(this,u),u.forEach((t=>{t.parentNode.append(t.cloneNode(!0))})),e.walkTree(t,((t,e,n)=>{var r;const a=t.state.el.getBoundingClientRect();t.content=t.state.el.innerHTML,t.state.size=[Math.ceil(a.width)+1,Math.max(Math.ceil(a.height),i)],t.state.key=[null==n||null==(r=n.state)?void 0:r.id,t.state.id].filter(Boolean).join(".")+t.content,e()})),h.remove(),c.remove()}setOptions(t){this.options=a({},J.defaultOptions,t),this.options.zoom?this.svg.call(this.zoom):this.svg.on(".zoom",null),this.svg.on("wheel",this.options.pan?this.handlePan:null)}setData(t,e){t&&(this.state.data=t),e&&this.setOptions(e),this.initializeData(this.state.data),this.renderData()}renderData(t){var n,r;if(!this.state.data)return;const{spacingHorizontal:a,paddingX:o,spacingVertical:s,autoFit:l,color:h}=this.options,c=m().children((t=>{var e;return!(null!=(e=t.payload)&&e.fold)&&t.children})).nodeSize((t=>{const[e,n]=t.data.state.size;return[n,e+(e?2*o:0)+a]})).spacing(((t,e)=>t.parent===e.parent?s:2*s)),d=c.hierarchy(this.state.data);c(d),function(t,n){e.walkTree(t,((t,e)=>{t.ySizeInner=t.ySize-n,t.y+=n,e()}),"children")}(d,a);const p=d.descendants().reverse(),u=d.links(),f=i.linkHorizontal(),g=i.min(p,(t=>t.x-t.xSize/2)),y=i.max(p,(t=>t.x+t.xSize/2)),x=i.min(p,(t=>t.y)),v=i.max(p,(t=>t.y+t.ySizeInner));Object.assign(this.state,{minX:g,maxX:y,minY:x,maxY:v}),l&&this.fit();const k=t&&p.find((e=>e.data===t))||d,z=null!=(n=k.data.state.x0)?n:k.x,S=null!=(r=k.data.state.y0)?r:k.y,b=this.g.selectAll(e.childSelector("g")).data(p,(t=>t.data.state.key)),w=b.enter().append("g").attr("data-depth",(t=>t.data.depth)).attr("data-path",(t=>t.data.state.path)).attr("transform",(t=>`translate(${S+k.ySizeInner-t.ySizeInner},${z+k.xSize/2-t.xSize})`)),E=this.transition(b.exit());E.select("line").attr("x1",(t=>t.ySizeInner)).attr("x2",(t=>t.ySizeInner)),E.select("foreignObject").style("opacity",0),E.attr("transform",(t=>`translate(${k.y+k.ySizeInner-t.ySizeInner},${k.x+k.xSize/2-t.xSize})`)).remove();const C=b.merge(w).attr("class",(t=>{var e;return["markmap-node",(null==(e=t.data.payload)?void 0:e.fold)&&"markmap-fold"].filter(Boolean).join(" ")}));this.transition(C).attr("transform",(t=>`translate(${t.y},${t.x-t.xSize/2})`));const j=C.selectAll(e.childSelector("line")).data((t=>[t]),(t=>t.data.state.key)).join((t=>t.append("line").attr("x1",(t=>t.ySizeInner)).attr("x2",(t=>t.ySizeInner))),(t=>t),(t=>t.remove()));this.transition(j).attr("x1",-1).attr("x2",(t=>t.ySizeInner+2)).attr("y1",(t=>t.xSize)).attr("y2",(t=>t.xSize)).attr("stroke",(t=>h(t.data))).attr("stroke-width",P);const X=C.selectAll(e.childSelector("circle")).data((t=>t.data.children?[t]:[]),(t=>t.data.state.key)).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",((t,e)=>this.handleClick(t,e)))),(t=>t),(t=>t.remove()));this.transition(X).attr("r",6).attr("cx",(t=>t.ySizeInner)).attr("cy",(t=>t.xSize)).attr("stroke",(t=>h(t.data))).attr("fill",(t=>{var e;return null!=(e=t.data.payload)&&e.fold&&t.data.children?h(t.data):"#fff"}));const I=C.selectAll(e.childSelector("foreignObject")).data((t=>[t]),(t=>t.data.state.key)).join((t=>{const e=t.append("foreignObject").attr("class","markmap-foreign").attr("x",o).attr("y",0).style("opacity",0).on("mousedown",W).on("dblclick",W);return e.append("xhtml:div").select((function(t){const e=t.data.state.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*o))).attr("height",(t=>t.xSize));this.transition(I).style("opacity",1);const O=this.g.selectAll(e.childSelector("path")).data(u,(t=>t.target.data.state.key)).join((t=>{const e=[S+k.ySizeInner,z+k.xSize/2];return t.insert("path","g").attr("class","markmap-link").attr("data-depth",(t=>t.target.data.depth)).attr("data-path",(t=>t.target.data.state.path)).attr("d",f({source:e,target:e}))}),(t=>t),(t=>{const e=[k.y+k.ySizeInner,k.x+k.xSize/2];return this.transition(t).attr("d",f({source:e,target:e})).remove()}));this.transition(O).attr("stroke",(t=>h(t.target.data))).attr("stroke-width",(t=>P(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 f({source:e,target:n})})),p.forEach((t=>{t.data.state.x0=t.x,t.data.state.y0=t.y}))}transition(t){const{duration:e}=this.options;return t.transition().duration(e)}async fit(){const t=this.svg.node(),{width:n,height:r}=t.getBoundingClientRect(),{fitRatio:a}=this.options,{minX:o,maxX:s,minY:l,maxY:h}=this.state,c=h-l,d=s-o,p=Math.min(n/c*a,r/d*a,2),u=i.zoomIdentity.translate((n-c*p)/2-l*p,(r-d*p)/2-o*p).scale(p);return this.transition(this.svg).call(this.zoom.transform,u).end().catch(e.noop)}async ensureView(t,n){let r,o;if(this.g.selectAll(e.childSelector("g")).each((function(e){e.data===t&&(r=this,o=e)})),!r||!o)return;const s=this.svg.node(),l=s.getBoundingClientRect(),h=i.zoomTransform(s),[c,d]=[o.y,o.y+o.ySizeInner+2].map((t=>t*h.k+h.x)),[p,u]=[o.x-o.xSize/2,o.x+o.xSize/2].map((t=>t*h.k+h.y)),f=a({left:0,right:0,top:0,bottom:0},n),m=[f.left-c,l.width-f.right-d],g=[f.top-p,l.height-f.bottom-u],y=m[0]*m[1]>0?Y(m,Math.abs)/h.k:0,x=g[0]*g[1]>0?Y(g,Math.abs)/h.k:0;if(y||x){const t=h.translate(y,x);return this.transition(this.svg).call(this.zoom.transform,t).end().catch(e.noop)}}async rescale(t){const n=this.svg.node(),{width:r,height:a}=n.getBoundingClientRect(),o=r/2,s=a/2,l=i.zoomTransform(n),h=l.translate((o-l.x)*(1-t)/l.k,(s-l.y)*(1-t)/l.k).scale(t);return this.transition(this.svg).call(this.zoom.transform,h).end().catch(e.noop)}destroy(){this.svg.on(".zoom",null),this.svg.html(null),this.revokers.forEach((t=>{t()}))}static create(t,e,n){const r=new J(t,e);return n&&(r.setData(n),r.fit()),r}}J.defaultOptions={autoFit:!1,color:t=>U(`${t.state.path}`),duration:500,embedGlobalCSS:!0,fitRatio:.95,maxWidth:0,nodeMinHeight:16,paddingX:8,scrollForPan:V,spacingHorizontal:80,spacingVertical:5,initialExpandLevel:-1,zoom:!0,pan:!0},t.loadCSS=e.loadCSS,t.loadJS=e.loadJS,t.Markmap=J,t.defaultColorFn=U,t.deriveOptions=function(t){const e={};t||(t={});const{color:n,colorFreezeLevel:r}=t;if(1===(null==n?void 0:n.length)){const t=n[0];e.color=()=>t}else if(null!=n&&n.length){const t=i.scaleOrdinal(n);e.color=e=>t(`${e.state.path}`)}if(r){const t=e.color||J.defaultOptions.color;e.color=e=>(e=a({},e,{state:a({},e.state,{path:e.state.path.split(".").slice(0,r+1).join(".")})}),t(e))}return["duration","maxWidth","initialExpandLevel"].forEach((n=>{const r=t[n];"number"==typeof r&&(e[n]=r)})),["zoom","pan"].forEach((n=>{const r=t[n];null!=r&&(e[n]=!!r)})),e},t.globalCSS=".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}",t.refreshHook=_}(this.markmap=this.markmap||{},markmapCommon,d3); | ||
var X="http://www.w3.org/1999/xlink",I={show:X,actuate:X,href:X};function O(t,e){var n;if("string"==typeof t)n=1;else{if("function"!=typeof t)throw new Error("Invalid VNode type");n=2}return{vtype:n,type:t,props:e}}function M(t){return t.children}var A={isSvg:!1};function R(t,e){if(1===e.type)null!=e.node&&t.append(e.node);else{if(4!==e.type)throw new Error("Unkown ref type "+JSON.stringify(e));e.children.forEach((function(e){R(t,e)}))}}var T={className:"class",labelFor:"for"};function $(t,e,n,r){if(e=T[e]||e,!0===n)t.setAttribute(e,"");else if(!1===n)t.removeAttribute(e);else{var i=r?I[e]:void 0;void 0!==i?t.setAttributeNS(i,e,n):t.setAttribute(e,n)}}function B(t,e){if(void 0===e&&(e=A),null==t||"boolean"==typeof t)return{type:1,node:null};if(t instanceof Node)return{type:1,node:t};if(2===(null==(o=t)?void 0:o.vtype)){var n=t,r=n.type,i=n.props;if(r===M){var a=document.createDocumentFragment();if(i.children)R(a,B(i.children,e));return{type:1,node:a}}return B(r(i),e)}var o;if(function(t){return"string"==typeof t||"number"==typeof t}(t))return{type:1,node:document.createTextNode(""+t)};if(function(t){return 1===(null==t?void 0:t.vtype)}(t)){var s,l,h=t,c=h.type,d=h.props;if(e.isSvg||"svg"!==c||(e=Object.assign({},e,{isSvg:!0})),function(t,e,n){for(var r in e)"key"!==r&&"children"!==r&&"ref"!==r&&("dangerouslySetInnerHTML"===r?t.innerHTML=e[r].__html:"innerHTML"===r||"textContent"===r||"innerText"===r?t[r]=e[r]:r.startsWith("on")?t[r.toLowerCase()]=e[r]:$(t,r,e[r],n.isSvg))}(s=e.isSvg?document.createElementNS("http://www.w3.org/2000/svg",c):document.createElement(c),d,e),d.children){var p=e;e.isSvg&&"foreignObject"===c&&(p=Object.assign({},p,{isSvg:!1})),l=B(d.children,p)}null!=l&&R(s,l);var u=d.ref;return"function"==typeof u&&u(s),{type:1,node:s}}if(Array.isArray(t))return{type:4,children:t.map((function(t){return B(t,e)}))};throw new Error("mount: Invalid Vnode!")}function H(t){for(var e=[],n=0;n<t.length;n+=1){var r=t[n];Array.isArray(r)?e=e.concat(H(r)):null!=r&&e.push(r)}return e}function D(t){return 1===t.type?t.node:t.children.map(D)}function L(t){return Array.isArray(t)?H(t.map(L)):D(B(t))}var N=".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}",F=".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}";function P(t){const e=t.data;return Math.max(4-2*e.depth,1.5)}function Y(t,e){return t[i.minIndex(t,e)]}function W(t){t.stopPropagation()}const _=new e.Hook,U=i.scaleOrdinal(i.schemeCategory10),V="undefined"!=typeof navigator&&navigator.userAgent.includes("Macintosh");class J{constructor(t,n){this.revokers=[],["handleZoom","handleClick","handlePan"].forEach((t=>{this[t]=this[t].bind(this)})),this.viewHooks={transformHtml:new e.Hook},this.svg=t.datum?t:i.select(t),this.styleNode=this.svg.append("style"),this.zoom=i.zoom().filter((t=>this.options.scrollForPan&&"wheel"===t.type?t.ctrlKey&&!t.button:!(t.ctrlKey&&"wheel"!==t.type||t.button))).on("zoom",this.handleZoom),this.setOptions(n),this.state={id:this.options.id||this.svg.attr("id")||e.getId()},this.g=this.svg.append("g"),this.updateStyle(),this.revokers.push(_.tap((()=>{this.setData()})))}getStyleContent(){const{style:t}=this.options,{id:e}=this.state,n="function"==typeof t?t(e):"";return[this.options.embedGlobalCSS&&N,n].filter(Boolean).join("\n")}updateStyle(){this.svg.attr("class",e.addClass(this.svg.attr("class"),"markmap",this.state.id));const t=this.getStyleContent();this.styleNode.text(t)}handleZoom(t){const{transform:e}=t;this.g.attr("transform",e)}handlePan(t){t.preventDefault();const e=i.zoomTransform(this.svg.node()),n=e.translate(-t.deltaX/e.k,-t.deltaY/e.k);this.svg.call(this.zoom.transform,n)}handleClick(t,e){var n;const{data:r}=e;r.payload=a({},r.payload,{fold:null!=(n=r.payload)&&n.fold?0:1}),this.renderData(e.data)}initializeData(t){let n=0;const{color:r,nodeMinHeight:i,maxWidth:o,initialExpandLevel:s}=this.options,{id:l}=this.state,h=L(O("div",{className:`markmap-container markmap ${l}-g`})),c=L(O("style",{children:[this.getStyleContent(),F].join("\n")}));document.body.append(h,c);const d=o?`max-width: ${o}px`:"";let p=0;e.walkTree(t,((t,e,i)=>{var o,l,c;t.children=null==(o=t.children)?void 0:o.map((t=>a({},t))),n+=1;const u=L(O("div",{className:"markmap-foreign",style:d,children:O("div",{dangerouslySetInnerHTML:{__html:t.content}})}));h.append(u),t.state=a({},t.state,{id:n,el:u.firstChild}),t.state.path=[null==i||null==(l=i.state)?void 0:l.path,t.state.id].filter(Boolean).join("."),r(t);const f=2===(null==(c=t.payload)?void 0:c.fold);f?p+=1:(p||s>=0&&t.depth>=s)&&(t.payload=a({},t.payload,{fold:1})),e(),f&&(p-=1)}));const u=e.arrayFrom(h.childNodes).map((t=>t.firstChild));this.viewHooks.transformHtml.call(this,u),u.forEach((t=>{t.parentNode.append(t.cloneNode(!0))})),e.walkTree(t,((t,e,n)=>{var r;const a=t.state.el.getBoundingClientRect();t.content=t.state.el.innerHTML,t.state.size=[Math.ceil(a.width)+1,Math.max(Math.ceil(a.height),i)],t.state.key=[null==n||null==(r=n.state)?void 0:r.id,t.state.id].filter(Boolean).join(".")+t.content,e()})),h.remove(),c.remove()}setOptions(t){this.options=a({},J.defaultOptions,t),this.options.zoom?this.svg.call(this.zoom):this.svg.on(".zoom",null),this.svg.on("wheel",this.options.pan?this.handlePan:null)}setData(t,e){t&&(this.state.data=t),e&&this.setOptions(e),this.initializeData(this.state.data),this.renderData()}renderData(t){var n,r;if(!this.state.data)return;const{spacingHorizontal:a,paddingX:o,spacingVertical:s,autoFit:l,color:h}=this.options,c=m().children((t=>{var e;return!(null!=(e=t.payload)&&e.fold)&&t.children})).nodeSize((t=>{const[e,n]=t.data.state.size;return[n,e+(e?2*o:0)+a]})).spacing(((t,e)=>t.parent===e.parent?s:2*s)),d=c.hierarchy(this.state.data);c(d),function(t,n){e.walkTree(t,((t,e)=>{t.ySizeInner=t.ySize-n,t.y+=n,e()}),"children")}(d,a);const p=d.descendants().reverse(),u=d.links(),f=i.linkHorizontal(),g=i.min(p,(t=>t.x-t.xSize/2)),y=i.max(p,(t=>t.x+t.xSize/2)),x=i.min(p,(t=>t.y)),v=i.max(p,(t=>t.y+t.ySizeInner));Object.assign(this.state,{minX:g,maxX:y,minY:x,maxY:v}),l&&this.fit();const k=t&&p.find((e=>e.data===t))||d,z=null!=(n=k.data.state.x0)?n:k.x,S=null!=(r=k.data.state.y0)?r:k.y,b=this.g.selectAll(e.childSelector("g")).data(p,(t=>t.data.state.key)),w=b.enter().append("g").attr("data-depth",(t=>t.data.depth)).attr("data-path",(t=>t.data.state.path)).attr("transform",(t=>`translate(${S+k.ySizeInner-t.ySizeInner},${z+k.xSize/2-t.xSize})`)),E=this.transition(b.exit());E.select("line").attr("x1",(t=>t.ySizeInner)).attr("x2",(t=>t.ySizeInner)),E.select("foreignObject").style("opacity",0),E.attr("transform",(t=>`translate(${k.y+k.ySizeInner-t.ySizeInner},${k.x+k.xSize/2-t.xSize})`)).remove();const C=b.merge(w).attr("class",(t=>{var e;return["markmap-node",(null==(e=t.data.payload)?void 0:e.fold)&&"markmap-fold"].filter(Boolean).join(" ")}));this.transition(C).attr("transform",(t=>`translate(${t.y},${t.x-t.xSize/2})`));const j=C.selectAll(e.childSelector("line")).data((t=>[t]),(t=>t.data.state.key)).join((t=>t.append("line").attr("x1",(t=>t.ySizeInner)).attr("x2",(t=>t.ySizeInner))),(t=>t),(t=>t.remove()));this.transition(j).attr("x1",-1).attr("x2",(t=>t.ySizeInner+2)).attr("y1",(t=>t.xSize)).attr("y2",(t=>t.xSize)).attr("stroke",(t=>h(t.data))).attr("stroke-width",P);const X=C.selectAll(e.childSelector("circle")).data((t=>t.data.children?[t]:[]),(t=>t.data.state.key)).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",((t,e)=>this.handleClick(t,e)))),(t=>t),(t=>t.remove()));this.transition(X).attr("r",6).attr("cx",(t=>t.ySizeInner)).attr("cy",(t=>t.xSize)).attr("stroke",(t=>h(t.data))).attr("fill",(t=>{var e;return null!=(e=t.data.payload)&&e.fold&&t.data.children?h(t.data):"#fff"}));const I=C.selectAll(e.childSelector("foreignObject")).data((t=>[t]),(t=>t.data.state.key)).join((t=>{const e=t.append("foreignObject").attr("class","markmap-foreign").attr("x",o).attr("y",0).style("opacity",0).on("mousedown",W).on("dblclick",W);return e.append("xhtml:div").select((function(t){const e=t.data.state.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*o))).attr("height",(t=>t.xSize));this.transition(I).style("opacity",1);const O=this.g.selectAll(e.childSelector("path")).data(u,(t=>t.target.data.state.key)).join((t=>{const e=[S+k.ySizeInner,z+k.xSize/2];return t.insert("path","g").attr("class","markmap-link").attr("data-depth",(t=>t.target.data.depth)).attr("data-path",(t=>t.target.data.state.path)).attr("d",f({source:e,target:e}))}),(t=>t),(t=>{const e=[k.y+k.ySizeInner,k.x+k.xSize/2];return this.transition(t).attr("d",f({source:e,target:e})).remove()}));this.transition(O).attr("stroke",(t=>h(t.target.data))).attr("stroke-width",(t=>P(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 f({source:e,target:n})})),p.forEach((t=>{t.data.state.x0=t.x,t.data.state.y0=t.y}))}transition(t){const{duration:e}=this.options;return t.transition().duration(e)}async fit(){const t=this.svg.node(),{width:n,height:r}=t.getBoundingClientRect(),{fitRatio:a}=this.options,{minX:o,maxX:s,minY:l,maxY:h}=this.state,c=h-l,d=s-o,p=Math.min(n/c*a,r/d*a,2),u=i.zoomIdentity.translate((n-c*p)/2-l*p,(r-d*p)/2-o*p).scale(p);return this.transition(this.svg).call(this.zoom.transform,u).end().catch(e.noop)}async ensureView(t,n){let r,o;if(this.g.selectAll(e.childSelector("g")).each((function(e){e.data===t&&(r=this,o=e)})),!r||!o)return;const s=this.svg.node(),l=s.getBoundingClientRect(),h=i.zoomTransform(s),[c,d]=[o.y,o.y+o.ySizeInner+2].map((t=>t*h.k+h.x)),[p,u]=[o.x-o.xSize/2,o.x+o.xSize/2].map((t=>t*h.k+h.y)),f=a({left:0,right:0,top:0,bottom:0},n),m=[f.left-c,l.width-f.right-d],g=[f.top-p,l.height-f.bottom-u],y=m[0]*m[1]>0?Y(m,Math.abs)/h.k:0,x=g[0]*g[1]>0?Y(g,Math.abs)/h.k:0;if(y||x){const t=h.translate(y,x);return this.transition(this.svg).call(this.zoom.transform,t).end().catch(e.noop)}}async rescale(t){const n=this.svg.node(),{width:r,height:a}=n.getBoundingClientRect(),o=r/2,s=a/2,l=i.zoomTransform(n),h=l.translate((o-l.x)*(1-t)/l.k,(s-l.y)*(1-t)/l.k).scale(t);return this.transition(this.svg).call(this.zoom.transform,h).end().catch(e.noop)}destroy(){this.svg.on(".zoom",null),this.svg.html(null),this.revokers.forEach((t=>{t()}))}static create(t,e,n){const r=new J(t,e);return n&&(r.setData(n),r.fit()),r}}J.defaultOptions={autoFit:!1,color:t=>U(`${t.state.path}`),duration:500,embedGlobalCSS:!0,fitRatio:.95,maxWidth:0,nodeMinHeight:16,paddingX:8,scrollForPan:V,spacingHorizontal:80,spacingVertical:5,initialExpandLevel:-1,zoom:!0,pan:!0},t.loadCSS=e.loadCSS,t.loadJS=e.loadJS,t.Markmap=J,t.defaultColorFn=U,t.deriveOptions=function(t){const e={};t||(t={});const{color:n,colorFreezeLevel:r}=t;if(1===(null==n?void 0:n.length)){const t=n[0];e.color=()=>t}else if(null!=n&&n.length){const t=i.scaleOrdinal(n);e.color=e=>t(`${e.state.path}`)}if(r){const t=e.color||J.defaultOptions.color;e.color=e=>(e=a({},e,{state:a({},e.state,{path:e.state.path.split(".").slice(0,r).join(".")})}),t(e))}return["duration","maxWidth","initialExpandLevel"].forEach((n=>{const r=t[n];"number"==typeof r&&(e[n]=r)})),["zoom","pan"].forEach((n=>{const r=t[n];null!=r&&(e[n]=!!r)})),e},t.globalCSS=".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}",t.refreshHook=_}(this.markmap=this.markmap||{},markmapCommon,d3); |
{ | ||
"name": "markmap-view", | ||
"version": "0.14.2-alpha.4+569dd11", | ||
"version": "0.14.2", | ||
"description": "View markmaps in browser", | ||
@@ -46,3 +46,3 @@ "author": "Gerald <gera2ld@live.com>", | ||
"devDependencies": { | ||
"markmap-common": "^0.14.0" | ||
"markmap-common": "^0.14.2" | ||
}, | ||
@@ -55,3 +55,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "569dd1128d16297708b4fb3789dbc43b082c2ee9" | ||
"gitHead": "91e58839b99837eaaa9e151cda18814d11ceebe0" | ||
} |
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
0
151575