mind-elixir 4.3.1 → 4.3.2
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/MindElixir.iife.js +4 -4
- package/dist/MindElixir.js +176 -176
- package/dist/MindElixirLite.iife.js +1 -1
- package/dist/MindElixirLite.js +3 -3
- package/package.json +1 -1
|
@@ -13,4 +13,4 @@ var MindElixirLite=function(){"use strict";const Dt="";(function(e){var t,n,o,s,
|
|
|
13
13
|
|
|
14
14
|
`:t+="".padStart(s-7," ")+"- "+o[i].topic+`
|
|
15
15
|
`,o[i].children&&n(o[i].children||[],s+1)}return n(e.children||[],2),t},getDataString:function(){const e=be(this);return JSON.stringify(e,(t,n)=>{if(!(t==="parent"&&typeof n!="string"))return n})},initLeft:function(){this.direction=0,this.refresh()},initRight:function(){this.direction=1,this.refresh()},initSide:function(){this.direction=2,this.refresh()},install:function(e){e(this)},refresh:function(e){e&&(e=JSON.parse(JSON.stringify(e)),this.nodeData=e.nodeData,this.arrows=e.arrows||[],this.summaries=e.summaries||[]),Z(this.nodeData),this.layout(),this.linkDiv()},scale:function(e){this.scaleVal=e,this.map.style.transform="scale("+e+")",this.bus.fire("scale",e)},selectNode:function(e,t,n){if(e){if(this.clearSelection(),typeof e=="string"){const o=L(e);return o?this.selectNode(o):void 0}e.className="selected",e.scrollIntoView({block:"nearest",inline:"nearest"}),this.currentNode=e,t?this.bus.fire("selectNewNode",e.nodeObj):this.bus.fire("selectNode",e.nodeObj,n)}},selectNodes:function(e){this.clearSelection();for(const t of e)t.className="selected";this.currentNodes=e,this.bus.fire("selectNodes",e.map(t=>t.nodeObj))},setLocale:function(e){this.locale=e,this.refresh()},toCenter:function(){this.container.scrollTo(1e4-this.container.offsetWidth/2,1e4-this.container.offsetHeight/2)},unselectNode:function(){this.currentNode&&(this.currentNode.className=""),this.currentNode=null,this.bus.fire("unselectNode")},unselectNodes:function(){if(this.currentNodes)for(const e of this.currentNodes)e.classList.remove("selected");this.currentNodes=null,this.bus.fire("unselectNodes")}},Symbol.toStringTag,{value:"Module"})),xe={create:function(e){return{dom:e,moved:!1,mousedown:!1,handleMouseMove(t){this.mousedown&&(this.moved=!0,this.cb&&this.cb(t.movementX,t.movementY))},handleMouseDown(t){t.button===0&&(this.mousedown=!0)},handleClear(t){this.mousedown=!1},cb:null,init(t,n){this.cb=n,this.handleClear=this.handleClear.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),t.addEventListener("mousemove",this.handleMouseMove),t.addEventListener("mouseleave",this.handleClear),t.addEventListener("mouseup",this.handleClear),this.dom.addEventListener("mousedown",this.handleMouseDown)},destory(t){t.removeEventListener("mousemove",this.handleMouseMove),t.removeEventListener("mouseleave",this.handleClear),t.removeEventListener("mouseup",this.handleClear),this.dom.removeEventListener("mousedown",this.handleMouseDown)},clear(){this.moved=!1,this.mousedown=!1}}}};function X(e,t,n){const{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=t.offsetWidth,r=t.offsetHeight,l=o+i/2,c=s+r/2,d=l+n.x,h=c+n.y;return{w:i,h:r,cx:l,cy:c,ctrlX:d,ctrlY:h}}function j(e){let t,n;const o=(e.cy-e.ctrlY)/(e.ctrlX-e.cx);return o>e.h/e.w||o<-e.h/e.w?e.cy-e.ctrlY<0?(t=e.cx-e.h/2/o,n=e.cy+e.h/2):(t=e.cx+e.h/2/o,n=e.cy-e.h/2):e.cx-e.ctrlX<0?(t=e.cx+e.w/2,n=e.cy-e.w*o/2):(t=e.cx-e.w/2,n=e.cy+e.w*o/2),{x:t,y:n}}const st=function(e,t,n,o){const s=document.createElementNS("http://www.w3.org/2000/svg","text");return x(s,{"text-anchor":"middle",x:t+"",y:n+"",fill:o||"#666"}),s.dataset.type="custom-link",s.innerHTML=e,s},we=function(e,t,n,o,s){if(!t||!n)return;performance.now();const i=X(e,t,o.delta1),r=X(e,n,o.delta2),{x:l,y:c}=j(i),{ctrlX:d,ctrlY:h}=i,{ctrlX:a,ctrlY:f}=r,{x:g,y:u}=j(r),p=se(a,f,g,u),m=Ve(`M ${l} ${c} C ${d} ${h} ${a} ${f} ${g} ${u}`,`M ${p.x1} ${p.y1} L ${g} ${u} L ${p.x2} ${p.y2}`),y=l/8+d*3/8+a*3/8+g/8,v=c/8+h*3/8+f*3/8+u/8,w=st(o.label,y,v,e.theme.cssVar["--color"]);m.appendChild(w),m.arrowObj=o,m.dataset.linkid=o.id,e.linkSvgGroup.appendChild(m),s||(e.arrows.push(o),e.currentArrow=m,Ee(e,o,i,r)),performance.now()},it=function(e,t){const n={id:ee(),label:"Custom Link",from:e.nodeObj.id,to:t.nodeObj.id,delta1:{x:0,y:-200},delta2:{x:0,y:-200}};we(this,e,t,n),this.bus.fire("operation",{name:"createArrow",obj:n})},rt=function(e){let t;if(e?t=e:t=this.currentArrow,!t)return;_e(this);const n=t.arrowObj.id;this.arrows=this.arrows.filter(o=>o.id!==n),t.remove(),this.bus.fire("operation",{name:"removeArrow",obj:{id:n}})},lt=function(e){this.currentArrow=e;const t=e.arrowObj,n=L(t.from),o=L(t.to),s=X(this,n,t.delta1),i=X(this,o,t.delta2);Ee(this,t,s,i)},ct=function(){this.currentArrow=null,_e(this)},_e=function(e){e.linkController.style.display="none",e.P2.style.display="none",e.P3.style.display="none"},Ee=function(e,t,n,o){var f;e.linkController.style.display="initial",e.P2.style.display="initial",e.P3.style.display="initial",e.nodes.appendChild(e.linkController),e.nodes.appendChild(e.P2),e.nodes.appendChild(e.P3);let{x:s,y:i}=j(n),{ctrlX:r,ctrlY:l}=n,{ctrlX:c,ctrlY:d}=o,{x:h,y:a}=j(o);e.P2.style.cssText=`top:${l}px;left:${r}px;`,e.P3.style.cssText=`top:${d}px;left:${c}px;`,x(e.line1,{x1:s+"",y1:i+"",x2:r+"",y2:l+""}),x(e.line2,{x1:c+"",y1:d+"",x2:h+"",y2:a+""}),e.helper1&&(e.helper1.destory(e.map),(f=e.helper2)==null||f.destory(e.map)),e.helper1=xe.create(e.P2),e.helper2=xe.create(e.P3),e.helper1.init(e.map,(g,u)=>{var v;r=r+g/e.scaleVal,l=l+u/e.scaleVal;const p=j({...n,ctrlX:r,ctrlY:l});s=p.x,i=p.y;const m=s/8+r*3/8+c*3/8+h/8,y=i/8+l*3/8+d*3/8+a/8;e.P2.style.top=l+"px",e.P2.style.left=r+"px",(v=e.currentArrow)==null||v.children[0].setAttribute("d",`M ${s} ${i} C ${r} ${l} ${c} ${d} ${h} ${a}`),x(e.currentArrow.children[2],{x:m+"",y:y+""}),x(e.line1,{x1:s+"",y1:i+"",x2:r+"",y2:l+""}),t.delta1.x=r-n.cx,t.delta1.y=l-n.cy}),e.helper2.init(e.map,(g,u)=>{var w,_;c=c+g/e.scaleVal,d=d+u/e.scaleVal;const p=j({...o,ctrlX:c,ctrlY:d});h=p.x,a=p.y;const m=s/8+r*3/8+c*3/8+h/8,y=i/8+l*3/8+d*3/8+a/8,v=se(c,d,h,a);e.P3.style.top=d+"px",e.P3.style.left=c+"px",(w=e.currentArrow)==null||w.children[0].setAttribute("d",`M ${s} ${i} C ${r} ${l} ${c} ${d} ${h} ${a}`),(_=e.currentArrow)==null||_.children[1].setAttribute("d",`M ${v.x1} ${v.y1} L ${h} ${a} L ${v.x2} ${v.y2}`),x(e.currentArrow.children[2],{x:m+"",y:y+""}),x(e.line2,{x1:c+"",y1:d+"",x2:h+"",y2:a+""}),t.delta2.x=c-o.cx,t.delta2.y=d-o.cy})};function at(){this.linkSvgGroup.innerHTML="";for(let e=0;e<this.arrows.length;e++){const t=this.arrows[e];try{we(this,L(t.from),L(t.to),t,!0)}catch{}}this.nodes.appendChild(this.linkSvgGroup)}function ht(e){if(!e)return;const t=e.children[2];he(this,t,n=>{var i;const o=e.arrowObj,s=((i=n.textContent)==null?void 0:i.trim())||"";s===""?o.label=origin:o.label=s,n.remove(),s!==origin&&(t.innerHTML=o.label,this.linkDiv(),this.bus.fire("operation",{name:"finishEditArrowLabel",obj:o}))})}function dt(){this.arrows=this.arrows.filter(e=>I(e.from,this.nodeData)&&I(e.to,this.nodeData))}const ut=Object.freeze(Object.defineProperty({__proto__:null,createArrow:it,editArrowLabel:ht,removeArrow:rt,renderArrow:at,selectArrow:lt,tidyArrow:dt,unselectArrow:ct},Symbol.toStringTag,{value:"Module"})),ft=function(e){var c,d;if(e.length===0)throw new Error("No selected node.");if(e.length===1){const h=e[0].nodeObj,a=e[0].nodeObj.parent;if(!a)throw new Error("Can not select root node.");const f=a.children.findIndex(g=>h===g);return{parent:a.id,start:f,end:f}}let t=0;const n=e.map(h=>{let a=h.nodeObj;const f=[];for(;a.parent;){const g=a.parent,u=g.children,p=u==null?void 0:u.indexOf(a);a=g,f.unshift({node:a,index:p})}return f.length>t&&(t=f.length),f});let o=0;e:for(;o<t;o++){const h=(c=n[0][o])==null?void 0:c.node;for(let a=1;a<n.length;a++)if(((d=n[a][o])==null?void 0:d.node)!==h)break e}if(!o)throw new Error("Can not select root node.");const s=n.map(h=>h[o-1].index).sort(),i=s[0]||0,r=s[s.length-1]||0,l=n[0][o-1].node;if(!l.parent)throw new Error("Please select nodes in the same main topic.");return{parent:l.id,start:i,end:r}},pt=function(e){const t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.setAttribute("id",e),t},Se=function(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","path");return x(n,{d:e,stroke:t||"#666",fill:"none","stroke-linecap":"round","stroke-width":"2"}),n},Ce=function(e,t,n,o,s){const i=document.createElementNS("http://www.w3.org/2000/svg","text");return x(i,{"text-anchor":o,x:t+"",y:n+"",fill:s||"#666"}),i.innerHTML=e,i},mt=e=>L(e).parentElement.parentElement,gt=function({parent:e,start:t}){var i,r;const n=L(e),o=n.nodeObj;let s;return o.parent?s=(i=n.closest("me-main"))==null?void 0:i.className:s=(r=L(o.children[t].id).closest("me-main"))==null?void 0:r.className,s},Le=function(e,t){var Me;const{id:n,text:o,parent:s,start:i,end:r}=t,l=e.nodes,d=L(s).nodeObj,h=gt(t);let a=1/0,f=0,g=0,u=0;for(let V=i;V<=r;V++){const Te=(Me=d.children)==null?void 0:Me[V];if(!Te)return e.removeSummary(n),null;const K=mt(Te.id),{offsetLeft:U,offsetTop:Ne}=N(l,K);V===i&&(g=Ne+20),V===r&&(u=Ne+K.offsetHeight-20),U<a&&(a=U),K.offsetWidth+U>f&&(f=K.offsetWidth+U)}let p,m;const y=g+10,v=u+10,w=(y+v)/2,_=e.theme.cssVar["--color"];h==="lhs"?(p=Se(`M ${a+10} ${y} c -5 0 -10 5 -10 10 L ${a} ${v-10} c 0 5 5 10 10 10 M ${a} ${w} h -10`,_),m=Ce(o,a-20,w+6,"end",_)):(p=Se(`M ${f-10} ${y} c 5 0 10 5 10 10 L ${f} ${v-10} c 0 5 -5 10 -10 10 M ${f} ${w} h 10`,_),m=Ce(o,f+20,w+6,"start",_));const E=pt("s-"+n);return E.appendChild(p),E.appendChild(m),E.summaryObj=t,e.summarySvg.appendChild(E),E},vt=Object.freeze(Object.defineProperty({__proto__:null,createSummary:function(){let e=[];this.currentNode?e=[this.currentNode]:this.currentNodes&&(e=this.currentNodes);const{parent:t,start:n,end:o}=ft(e),s={id:ee(),parent:t,start:n,end:o,text:"summary"},i=Le(this,s);this.summaries.push(s),this.editSummary(i),this.bus.fire("operation",{name:"createSummary",obj:s})},editSummary:function(e){if(!e)return;const t=e.childNodes[1];he(this,t,n=>{var i;const o=e.summaryObj,s=((i=n.textContent)==null?void 0:i.trim())||"";s===""?o.text=origin:o.text=s,n.remove(),s!==origin&&(t.innerHTML=o.text,this.linkDiv(),this.bus.fire("operation",{name:"finishEditSummary",obj:o}))})},removeSummary:function(e){var n;const t=this.summaries.findIndex(o=>o.id===e);t>-1&&(this.summaries.splice(t,1),(n=document.querySelector("#s-"+e))==null||n.remove()),this.bus.fire("operation",{name:"removeSummary",obj:{id:e}})},renderSummary:function(){this.summarySvg.innerHTML="",this.summaries.forEach(e=>{try{Le(this,e)}catch{}}),this.nodes.insertAdjacentElement("beforeend",this.summarySvg)},selectSummary:function(e){const t=e.children[1].getBBox(),n=6,o=3,s=document.createElementNS("http://www.w3.org/2000/svg","rect");x(s,{x:t.x-n+"",y:t.y-n+"",width:t.width+n*2+"",height:t.height+n*2+"",rx:o+"",stroke:this.theme.cssVar["--selected"]||"#4dc4ff","stroke-width":"2",fill:"none"}),s.classList.add("selected"),e.appendChild(s),this.currentSummary=e},unselectSummary:function(){var e,t;(t=(e=this.currentSummary)==null?void 0:e.querySelector("rect"))==null||t.remove(),this.currentSummary=null}},Symbol.toStringTag,{value:"Module"})),C="http://www.w3.org/2000/svg";function yt(e,t){const n=document.createElementNS(C,"svg");return x(n,{version:"1.1",xmlns:C,height:e,width:t}),n}function bt(e,t){return(parseInt(e)-parseInt(t))/2}function xt(e,t,n,o){const s=document.createElementNS(C,"g");let i="";return e.text?i=e.text.textContent:i=e.childNodes[0].textContent,i.split(`
|
|
16
|
-
`).forEach((l,c)=>{const d=document.createElementNS(C,"text");x(d,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+bt(t.lineHeight,t.fontSize)*(c+1)+parseFloat(t.fontSize)*(c+1)+"","text-anchor":"start","font-family":t.fontFamily,"font-size":`${t.fontSize}`,"font-weight":`${t.fontWeight}`,fill:`${t.color}`}),d.innerHTML=l,s.appendChild(d)}),s}function wt(e,t,n,o){var l;let s="";(l=e.nodeObj)!=null&&l.dangerouslySetInnerHTML?s=e.nodeObj.dangerouslySetInnerHTML:e.text?s=e.text.textContent:s=e.childNodes[0].textContent;const i=document.createElementNS(C,"foreignObject");x(i,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+"",width:t.width,height:t.height});const r=document.createElement("div");return x(r,{xmlns:"http://www.w3.org/1999/xhtml",style:`font-family: ${t.fontFamily}; font-size: ${t.fontSize}; font-weight: ${t.fontWeight}; color: ${t.color}; white-space: pre-wrap;`}),r.innerHTML=s,i.appendChild(r),i}function _t(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=document.createElementNS(C,"rect");return x(i,{x:o+"",y:s+"",rx:n.borderRadius,ry:n.borderRadius,width:n.width,height:n.height,fill:n.backgroundColor,stroke:n.borderColor,"stroke-width":n.borderWidth}),i}function Y(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:s,offsetTop:i}=N(e.nodes,t),r=document.createElementNS(C,"rect");x(r,{x:s+"",y:i+"",rx:o.borderRadius,ry:o.borderRadius,width:o.width,height:o.height,fill:o.backgroundColor,stroke:o.borderColor,"stroke-width":o.borderWidth});const l=document.createElementNS(C,"g");l.appendChild(r);let c;return n?c=wt(t,o,s,i):c=xt(t,o,s,i),l.appendChild(c),l}function Et(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=document.createElementNS(C,"a"),r=document.createElementNS(C,"text");return x(r,{x:o+"",y:s+parseInt(n.fontSize)+"","text-anchor":"start","font-family":n.fontFamily,"font-size":`${n.fontSize}`,"font-weight":`${n.fontWeight}`,fill:`${n.color}`}),r.innerHTML=t.textContent,i.appendChild(r),i.setAttribute("href",t.href),i}function St(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=document.createElementNS(C,"image");return x(i,{x:o+"",y:s+"",width:n.width+"",height:n.height+"",href:t.src}),i}const G=100,Ct='<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',Lt=(e,t=!1)=>{var a,f,g;const n=e.nodes,o=n.offsetHeight+G*2,s=n.offsetWidth+G*2,i=yt(o+"px",s+"px"),r=document.createElementNS(C,"svg"),l=document.createElementNS(C,"rect");x(l,{x:"0",y:"0",width:`${s}`,height:`${o}`,fill:e.theme.cssVar["--bgcolor"]}),i.appendChild(l),n.querySelectorAll(".subLines").forEach(u=>{const p=u.cloneNode(!0),{offsetLeft:m,offsetTop:y}=N(n,u.parentElement);p.setAttribute("x",`${m}`),p.setAttribute("y",`${y}`),r.appendChild(p)});const c=(a=n.querySelector(".lines"))==null?void 0:a.cloneNode(!0);c&&r.appendChild(c);const d=(f=n.querySelector(".topiclinks"))==null?void 0:f.cloneNode(!0);d&&r.appendChild(d);const h=(g=n.querySelector(".summary"))==null?void 0:g.cloneNode(!0);return h&&r.appendChild(h),n.querySelectorAll("me-tpc").forEach(u=>{u.nodeObj.dangerouslySetInnerHTML?r.appendChild(Y(e,u,!t)):(r.appendChild(_t(e,u)),r.appendChild(Y(e,u.text,!t)))}),n.querySelectorAll(".tags > span").forEach(u=>{r.appendChild(Y(e,u))}),n.querySelectorAll(".icons > span").forEach(u=>{r.appendChild(Y(e,u))}),n.querySelectorAll(".hyper-link").forEach(u=>{r.appendChild(Et(e,u))}),n.querySelectorAll("img").forEach(u=>{r.appendChild(St(e,u))}),x(r,{x:G+"",y:G+"",overflow:"visible"}),i.appendChild(r),i},Mt=(e,t)=>(t&&e.insertAdjacentHTML("afterbegin","<style>"+t+"</style>"),Ct+e.outerHTML);function Tt(e){return new Promise((t,n)=>{const o=new FileReader;o.onload=s=>{t(s.target.result)},o.onerror=s=>{n(s)},o.readAsDataURL(e)})}const Nt={getObjById:I,generateNewObj:$e,layout:De,linkDiv:Ie,editTopic:Re,createWrapper:Pe,createParent:ze,createChildren:Oe,createTopic:je,findEle:L,changeTheme:tt,...ot,...{},...ut,...vt,...Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(e=!1,t){const n=this.exportSvg(e,t),o=await Tt(n);return new Promise((s,i)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const l=document.createElement("canvas");l.width=r.width,l.height=r.height,l.getContext("2d").drawImage(r,0,0),l.toBlob(s,"image/png",1)},r.src=o,r.onerror=i})},exportSvg:function(e=!1,t){const n=Lt(this,e),o=Mt(n,t);return new Blob([o],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"})),init(e){if(!e||!e.nodeData)return new Error("MindElixir: `data` is required");e.direction!==void 0&&(this.direction=e.direction),this.changeTheme(e.theme||this.theme,!1),this.nodeData=e.nodeData,Z(this.nodeData),this.arrows=e.arrows||[],this.summaries=e.summaries||[],this.tidyArrow(),this.toolBar&&Xe(this),this.toCenter(),this.layout(),this.linkDiv()},destroy(){var e
|
|
16
|
+
`).forEach((l,c)=>{const d=document.createElementNS(C,"text");x(d,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+bt(t.lineHeight,t.fontSize)*(c+1)+parseFloat(t.fontSize)*(c+1)+"","text-anchor":"start","font-family":t.fontFamily,"font-size":`${t.fontSize}`,"font-weight":`${t.fontWeight}`,fill:`${t.color}`}),d.innerHTML=l,s.appendChild(d)}),s}function wt(e,t,n,o){var l;let s="";(l=e.nodeObj)!=null&&l.dangerouslySetInnerHTML?s=e.nodeObj.dangerouslySetInnerHTML:e.text?s=e.text.textContent:s=e.childNodes[0].textContent;const i=document.createElementNS(C,"foreignObject");x(i,{x:n+parseInt(t.paddingLeft)+"",y:o+parseInt(t.paddingTop)+"",width:t.width,height:t.height});const r=document.createElement("div");return x(r,{xmlns:"http://www.w3.org/1999/xhtml",style:`font-family: ${t.fontFamily}; font-size: ${t.fontSize}; font-weight: ${t.fontWeight}; color: ${t.color}; white-space: pre-wrap;`}),r.innerHTML=s,i.appendChild(r),i}function _t(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=document.createElementNS(C,"rect");return x(i,{x:o+"",y:s+"",rx:n.borderRadius,ry:n.borderRadius,width:n.width,height:n.height,fill:n.backgroundColor,stroke:n.borderColor,"stroke-width":n.borderWidth}),i}function Y(e,t,n=!1){const o=getComputedStyle(t),{offsetLeft:s,offsetTop:i}=N(e.nodes,t),r=document.createElementNS(C,"rect");x(r,{x:s+"",y:i+"",rx:o.borderRadius,ry:o.borderRadius,width:o.width,height:o.height,fill:o.backgroundColor,stroke:o.borderColor,"stroke-width":o.borderWidth});const l=document.createElementNS(C,"g");l.appendChild(r);let c;return n?c=wt(t,o,s,i):c=xt(t,o,s,i),l.appendChild(c),l}function Et(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=document.createElementNS(C,"a"),r=document.createElementNS(C,"text");return x(r,{x:o+"",y:s+parseInt(n.fontSize)+"","text-anchor":"start","font-family":n.fontFamily,"font-size":`${n.fontSize}`,"font-weight":`${n.fontWeight}`,fill:`${n.color}`}),r.innerHTML=t.textContent,i.appendChild(r),i.setAttribute("href",t.href),i}function St(e,t){const n=getComputedStyle(t),{offsetLeft:o,offsetTop:s}=N(e.nodes,t),i=document.createElementNS(C,"image");return x(i,{x:o+"",y:s+"",width:n.width+"",height:n.height+"",href:t.src}),i}const G=100,Ct='<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',Lt=(e,t=!1)=>{var a,f,g;const n=e.nodes,o=n.offsetHeight+G*2,s=n.offsetWidth+G*2,i=yt(o+"px",s+"px"),r=document.createElementNS(C,"svg"),l=document.createElementNS(C,"rect");x(l,{x:"0",y:"0",width:`${s}`,height:`${o}`,fill:e.theme.cssVar["--bgcolor"]}),i.appendChild(l),n.querySelectorAll(".subLines").forEach(u=>{const p=u.cloneNode(!0),{offsetLeft:m,offsetTop:y}=N(n,u.parentElement);p.setAttribute("x",`${m}`),p.setAttribute("y",`${y}`),r.appendChild(p)});const c=(a=n.querySelector(".lines"))==null?void 0:a.cloneNode(!0);c&&r.appendChild(c);const d=(f=n.querySelector(".topiclinks"))==null?void 0:f.cloneNode(!0);d&&r.appendChild(d);const h=(g=n.querySelector(".summary"))==null?void 0:g.cloneNode(!0);return h&&r.appendChild(h),n.querySelectorAll("me-tpc").forEach(u=>{u.nodeObj.dangerouslySetInnerHTML?r.appendChild(Y(e,u,!t)):(r.appendChild(_t(e,u)),r.appendChild(Y(e,u.text,!t)))}),n.querySelectorAll(".tags > span").forEach(u=>{r.appendChild(Y(e,u))}),n.querySelectorAll(".icons > span").forEach(u=>{r.appendChild(Y(e,u))}),n.querySelectorAll(".hyper-link").forEach(u=>{r.appendChild(Et(e,u))}),n.querySelectorAll("img").forEach(u=>{r.appendChild(St(e,u))}),x(r,{x:G+"",y:G+"",overflow:"visible"}),i.appendChild(r),i},Mt=(e,t)=>(t&&e.insertAdjacentHTML("afterbegin","<style>"+t+"</style>"),Ct+e.outerHTML);function Tt(e){return new Promise((t,n)=>{const o=new FileReader;o.onload=s=>{t(s.target.result)},o.onerror=s=>{n(s)},o.readAsDataURL(e)})}const Nt={getObjById:I,generateNewObj:$e,layout:De,linkDiv:Ie,editTopic:Re,createWrapper:Pe,createParent:ze,createChildren:Oe,createTopic:je,findEle:L,changeTheme:tt,...ot,...{},...ut,...vt,...Object.freeze(Object.defineProperty({__proto__:null,exportPng:async function(e=!1,t){const n=this.exportSvg(e,t),o=await Tt(n);return new Promise((s,i)=>{const r=new Image;r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{const l=document.createElement("canvas");l.width=r.width,l.height=r.height,l.getContext("2d").drawImage(r,0,0),l.toBlob(s,"image/png",1)},r.src=o,r.onerror=i})},exportSvg:function(e=!1,t){const n=Lt(this,e),o=Mt(n,t);return new Blob([o],{type:"image/svg+xml"})}},Symbol.toStringTag,{value:"Module"})),init(e){if(!e||!e.nodeData)return new Error("MindElixir: `data` is required");e.direction!==void 0&&(this.direction=e.direction),this.changeTheme(e.theme||this.theme,!1),this.nodeData=e.nodeData,Z(this.nodeData),this.arrows=e.arrows||[],this.summaries=e.summaries||[],this.tidyArrow(),this.toolBar&&Xe(this),this.toCenter(),this.layout(),this.linkDiv()},destroy(){var e;this.disposable.forEach(t=>t()),this.mindElixirBox&&(this.mindElixirBox.innerHTML=""),this.mindElixirBox=void 0,this.nodeData=void 0,this.arrows=void 0,this.summaries=void 0,this.currentArrow=void 0,this.currentNode=void 0,this.currentNodes=void 0,this.currentSummary=void 0,this.waitCopy=void 0,this.theme=void 0,this.direction=void 0,this.bus=void 0,this.container=void 0,this.map=void 0,this.lines=void 0,this.linkController=void 0,this.linkSvgGroup=void 0,this.P2=void 0,this.P3=void 0,this.line1=void 0,this.line2=void 0,this.nodes=void 0,(e=this.selection)==null||e.destroy(),this.selection=void 0}};function $t({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,cW:r,cH:l,direction:c,containerHeight:d}){let h=t+n/2;const a=e+o/2;let f;c==="lhs"?f=i+r:f=i;const g=s+l/2,p=(1-Math.abs(g-a)/d)*.25*(n/2);return c==="lhs"?h=h-n/10-p:h=h+n/10+p,`M ${h} ${a} Q ${h} ${g} ${f} ${g}`}function At({pT:e,pL:t,pW:n,pH:o,cT:s,cL:i,cW:r,cH:l,direction:c,isFirst:d}){const h=parseInt(this.mindElixirBox.style.getPropertyValue("--gap"));let a=0,f=0;d?a=e+o/2:a=e+o;const g=s+l;let u=0,p=0,m=0;const y=Math.abs(a-g)/300*h;return c==="lhs"?(m=t,u=m+h,p=m-h,f=i+h,`M ${u} ${a} C ${m} ${a} ${m+y} ${g} ${p} ${g} H ${f}`):(m=t+n,u=m-h,p=m+h,f=i+r-h,`M ${u} ${a} C ${m} ${a} ${m-y} ${g} ${p} ${g} H ${f}`)}const kt="4.3.2",q=document;function T({el:e,direction:t,locale:n,draggable:o,editable:s,contextMenu:i,contextMenuOption:r,toolBar:l,keypress:c,mouseSelectionButton:d,selectionContainer:h,before:a,newTopicName:f,allowUndo:g,generateMainBranch:u,generateSubBranch:p,overflowHidden:m,theme:y}){let v=null;const w=Object.prototype.toString.call(e);if(w==="[object HTMLDivElement]"?v=e:w==="[object String]"&&(v=document.querySelector(e)),!v)throw new Error("MindElixir: el is not a valid element");v.className+=" mind-elixir",v.innerHTML="",this.mindElixirBox=v,this.disposable=[],this.before=a||{},this.locale=n||"en",this.contextMenuOption=r,this.contextMenu=i===void 0?!0:i,this.toolBar=l===void 0?!0:l,this.keypress=c===void 0?!0:c,this.mouseSelectionButton=d||0,this.direction=typeof t=="number"?t:1,this.draggable=o===void 0?!0:o,this.newTopicName=f||"new node",this.editable=s===void 0?!0:s,this.allowUndo=g===void 0?!1:g,this.currentNode=null,this.currentArrow=null,this.scaleVal=1,this.tempDirection=null,this.generateMainBranch=u||$t,this.generateSubBranch=p||At,this.overflowHidden=m||!1,this.bus=ke.create(),this.container=q.createElement("div"),this.selectionContainer=h||this.container,this.container.className="map-container";const _=window.matchMedia("(prefers-color-scheme: dark)");this.theme=y||(_.matches?ne:te);const E=q.createElement("div");E.className="map-canvas",this.map=E,this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.mindElixirBox.appendChild(this.container),this.nodes=q.createElement("me-nodes"),this.nodes.className="main-node-container",this.lines=R("lines"),this.summarySvg=R("summary"),this.linkController=R("linkcontroller"),this.P2=q.createElement("div"),this.P3=q.createElement("div"),this.P2.className=this.P3.className="circle",this.P2.style.display=this.P3.style.display="none",this.line1=ae(),this.line2=ae(),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=R("topiclinks"),this.map.appendChild(this.nodes),this.overflowHidden?this.container.style.overflow="hidden":Ae(this)}return T.prototype=Nt,T.LEFT=H,T.RIGHT=J,T.SIDE=Q,T.THEME=te,T.DARK_THEME=ne,T.version=kt,T.E=L,T}();
|
package/dist/MindElixirLite.js
CHANGED
|
@@ -1512,8 +1512,8 @@ const on = function(e = !1, t) {
|
|
|
1512
1512
|
e.direction !== void 0 && (this.direction = e.direction), this.changeTheme(e.theme || this.theme, !1), this.nodeData = e.nodeData, Z(this.nodeData), this.arrows = e.arrows || [], this.summaries = e.summaries || [], this.tidyArrow(), this.toolBar && Xe(this), this.toCenter(), this.layout(), this.linkDiv();
|
|
1513
1513
|
},
|
|
1514
1514
|
destroy() {
|
|
1515
|
-
var e
|
|
1516
|
-
this.disposable.forEach((
|
|
1515
|
+
var e;
|
|
1516
|
+
this.disposable.forEach((t) => t()), this.mindElixirBox && (this.mindElixirBox.innerHTML = ""), this.mindElixirBox = void 0, this.nodeData = void 0, this.arrows = void 0, this.summaries = void 0, this.currentArrow = void 0, this.currentNode = void 0, this.currentNodes = void 0, this.currentSummary = void 0, this.waitCopy = void 0, this.theme = void 0, this.direction = void 0, this.bus = void 0, this.container = void 0, this.map = void 0, this.lines = void 0, this.linkController = void 0, this.linkSvgGroup = void 0, this.P2 = void 0, this.P3 = void 0, this.line1 = void 0, this.line2 = void 0, this.nodes = void 0, (e = this.selection) == null || e.destroy(), this.selection = void 0;
|
|
1517
1517
|
}
|
|
1518
1518
|
};
|
|
1519
1519
|
function an({ pT: e, pL: t, pW: n, pH: o, cT: s, cL: i, cW: r, cH: l, direction: c, containerHeight: d }) {
|
|
@@ -1533,7 +1533,7 @@ function hn({ pT: e, pL: t, pW: n, pH: o, cT: s, cL: i, cW: r, cH: l, direction:
|
|
|
1533
1533
|
const y = Math.abs(a - g) / 300 * h;
|
|
1534
1534
|
return c === "lhs" ? (m = t, u = m + h, p = m - h, f = i + h, `M ${u} ${a} C ${m} ${a} ${m + y} ${g} ${p} ${g} H ${f}`) : (m = t + n, u = m - h, p = m + h, f = i + r - h, `M ${u} ${a} C ${m} ${a} ${m - y} ${g} ${p} ${g} H ${f}`);
|
|
1535
1535
|
}
|
|
1536
|
-
const dn = "4.3.
|
|
1536
|
+
const dn = "4.3.2", R = document;
|
|
1537
1537
|
function N({
|
|
1538
1538
|
el: e,
|
|
1539
1539
|
direction: t,
|