mind-elixir
Version:
Mind elixir is a free open source mind map core.
2 lines (1 loc) • 2.85 kB
JavaScript
var LayoutSsr=function(p){"use strict";var d=(n=>(n.LHS="lhs",n.RHS="rhs",n))(d||{});const T=n=>`<div class="map-container"><div>${n}</div></div>`,L=function(n,c={}){const{direction:a=2}=c,o=e=>{const r={id:e.id,topic:e.topic,direction:e.direction,style:e.style,tags:e.tags,icons:e.icons,hyperLink:e.hyperLink,expanded:e.expanded,image:e.image,branchColor:e.branchColor,dangerouslySetInnerHTML:e.dangerouslySetInnerHTML,note:e.note};return e.children&&e.children.length>0&&(r.children=e.children.map(o)),r},g=o(n),u=n.children||[],m=[],h=[];if(a===2){let e=0,r=0;u.forEach(t=>{const s=o(t);t.direction===0?(s.direction=0,m.push(s),e+=1):t.direction===1?(s.direction=1,h.push(s),r+=1):e<=r?(s.direction=0,m.push(s),e+=1):(s.direction=1,h.push(s),r+=1)})}else a===0?u.forEach(e=>{const r=o(e);r.direction=0,m.push(r)}):u.forEach(e=>{const r=o(e);r.direction=1,h.push(r)});return{root:g,leftNodes:m,rightNodes:h,direction:a}},v=function(n,c={}){const{className:a=""}=c,o=(t,s=!1)=>{const N=`me${t.id}`,R="me-tpc";let $="";if(t.style){const i=[];t.style.color&&i.push(`color: ${t.style.color}`),t.style.background&&i.push(`background: ${t.style.background}`),t.style.fontSize&&i.push(`font-size: ${t.style.fontSize}px`),t.style.fontWeight&&i.push(`font-weight: ${t.style.fontWeight}`),i.length>0&&($=` style="${i.join("; ")}"`)}let f="";if(t.dangerouslySetInnerHTML)f=t.dangerouslySetInnerHTML;else{if(f=S(t.topic),t.tags&&t.tags.length>0){const i=t.tags.map(l=>`<span class="me-tag">${S(l)}</span>`).join("");f+=i}if(t.icons&&t.icons.length>0){const i=t.icons.map(l=>`<span class="me-icon">${l}</span>`).join("");f+=i}if(t.image){const{url:i,width:l,height:b,fit:j="cover"}=t.image;f+=`<img src="${S(i)}" width="${l}" height="${b}" style="object-fit: ${j}" alt="" />`}}const H=`<me-tpc class="${R}" data-nodeid="${N}"${$}>${f}</me-tpc>`;if(s)return`<me-root>${H}</me-root>`;let y="";return t.children&&t.children.length>0&&t.expanded!==!1&&(y=`<me-children>${t.children.map(l=>g(l)).join("")}</me-children>`),`<me-wrapper>${`<me-parent>${H}</me-parent>`}${y}</me-wrapper>`},g=t=>o(t,!1),u=o(n.root,!0),m=n.leftNodes.map(t=>g(t)).join(""),h=n.rightNodes.map(t=>g(t)).join(""),e=`<me-main class="${d.LHS}">${m}</me-main>`,r=`<me-main class="${d.RHS}">${h}</me-main>`;return T(`<div class="${a}">${e}${u}${r}</div>`)};function S(n){const c=typeof document<"u"?document.createElement("div"):null;return c?(c.textContent=n,c.innerHTML):n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const E=function(n){return JSON.stringify(n,null,2)},I=function(n,c,a={}){return{nodeData:n,layoutResult:c,options:{direction:c.direction,...a},timestamp:Date.now()}};return p.getHydrationData=I,p.getSSRData=E,p.layoutSSR=L,p.renderSSRHTML=v,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"}),p}({});