mind-elixir 0.19.0 → 0.19.1

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.
@@ -30,7 +30,7 @@
30
30
  L ${i} ${e}
31
31
  L ${i} ${b+$}
32
32
  A ${$} ${$} 0 0 1 ${i+$},${b}
33
- L ${n} ${b}`);const v=u.children[1];if(v&&(v.style.top=(u.offsetHeight-v.offsetHeight)/2+"px","lhs"===g?v.style.left="-10px":"rhs"===g&&(v.style.left=u.offsetWidth-10+"px"),v.expanded)){const x=p.children[1].children;0<x.length&&r(x,u)}}})(N.children[1].children,v,!(O="")),k.appendChild(function(e){const t=M.createElementNS(j,"path");return t.setAttribute("d",e),t.setAttribute("stroke","#555"),t.setAttribute("fill","none"),t.setAttribute("stroke-linecap","square"),t.setAttribute("stroke-width","1"),t.setAttribute("transform","translate(0.5,-0.5)"),t}(O))}}this.linkSvgGroup.innerHTML="";for(const w in this.linkData){var e=this.linkData[w];"string"==typeof e.from?this.createLink(E(e.from),E(e.to),!0,e):this.createLink(E(e.from.nodeObj.id),E(e.to.nodeObj.id),!0,e)}},createInputDiv:function(i){if(i){let n=s.createElement("div");const o=i.childNodes[0].textContent;i.appendChild(n),n.innerText=o,n.contentEditable="true",n.spellcheck=!1,n.style.cssText=`min-width:${i.offsetWidth-8}px;`,0===this.direction&&(n.style.right="0"),n.focus(),function(e){const t=s.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}(n),this.inputDiv=n,this.bus.fire("operation",{name:"beginEdit",obj:i.nodeObj}),n.addEventListener("keydown",e=>{e.stopPropagation();var t=e.key;"Enter"!==t&&"Tab"!==t||e.shiftKey||(e.preventDefault(),this.inputDiv.blur(),this.map.focus())}),n.addEventListener("blur",()=>{if(n){const t=i.nodeObj;var e=n.textContent.trim();t.topic=""===e?o:e,n.remove(),this.inputDiv=n=null,this.bus.fire("operation",{name:"finishEdit",obj:t,origin:o}),e!==o&&(i.childNodes[0].textContent=t.topic,this.linkDiv())}})}},createChildren:function(t,e,n){let i;i=e||s.createElement("children");for(let e=0;e<t.length;e++){var o=t[e];const r=s.createElement("GRP");0===n?r.className="lhs":1===n?r.className="rhs":2===n&&(0===o.direction?r.className="lhs":1===o.direction&&(r.className="rhs"));const a=this.createTop(o);o.children&&0<o.children.length?(a.appendChild(p(o.expanded)),r.appendChild(a),!1!==o.expanded&&(o=this.createChildren(o.children),r.appendChild(o))):r.appendChild(a),i.appendChild(r)}return i},createGroup:function(e){const t=s.createElement("GRP"),n=this.createTop(e);return t.appendChild(n),e.children&&0<e.children.length&&(n.appendChild(p(e.expanded)),!1!==e.expanded&&(e=this.createChildren(e.children),t.appendChild(e))),{grp:t,top:n}},createTop:function(e){const t=s.createElement("t");var n=this.createTopic(e);return r(n,e),t.appendChild(n),t},createTopic:function(e){const t=s.createElement("tpc");return t.nodeObj=e,t.dataset.nodeid="me"+e.id,t.draggable=this.draggable,t},selectNode:function(e,t){if(e){if("string"==typeof e)return this.selectNode(E(e));this.currentNode&&(this.currentNode.className=""),e.className="selected",this.currentNode=e,t?this.bus.fire("selectNewNode",e.nodeObj):this.bus.fire("selectNode",e.nodeObj)}},unselectNode:function(){this.currentNode&&(this.currentNode.className=""),this.currentNode=null,this.bus.fire("unselectNode")},selectNextSibling:function(){if(this.currentNode&&"meroot"!==this.currentNode.dataset.nodeid){var t=this.currentNode.parentElement.parentElement.nextSibling;let e;var n=this.currentNode.parentElement.parentElement;if("rhs"===n.className||"lhs"===n.className){var i=this.mindElixirBox.querySelectorAll("."+n.className),n=Array.from(i).indexOf(n);if(!(n+1<i.length))return!1;e=i[n+1].firstChild.firstChild}else{if(!t)return!1;e=t.firstChild.firstChild}return this.selectNode(e),!0}},selectPrevSibling:function(){if(this.currentNode&&"meroot"!==this.currentNode.dataset.nodeid){var t=this.currentNode.parentElement.parentElement.previousSibling;let e;var n=this.currentNode.parentElement.parentElement;if("rhs"===n.className||"lhs"===n.className){var i=this.mindElixirBox.querySelectorAll("."+n.className),n=Array.from(i).indexOf(n);if(!(0<=n-1))return!1;e=i[n-1].firstChild.firstChild}else{if(!t)return!1;e=t.firstChild.firstChild}return this.selectNode(e),!0}},selectFirstChild:function(){var e;!this.currentNode||(e=this.currentNode.parentElement.nextSibling)&&e.firstChild&&(e=e.firstChild.firstChild.firstChild,this.selectNode(e))},selectParent:function(){var e;!this.currentNode||"meroot"===this.currentNode.dataset.nodeid||(e=this.currentNode.parentElement.parentElement.parentElement.previousSibling)&&(e=e.firstChild,this.selectNode(e))},getAllDataString:function(){var e={nodeData:n(this),linkData:this.linkData};return JSON.stringify(e,(e,t)=>{if("parent"!==e)return"from"===e||"to"===e?t.nodeObj.id:t})},getAllData:function(){var e={nodeData:n(this),linkData:this.linkData};return JSON.parse(JSON.stringify(e,(e,t)=>{if("parent"!==e)return"from"===e||"to"===e?t.nodeObj.id:t}))},getAllDataMd:function(){var e=n(this);let o="# "+e.topic+"\n\n";return function t(n,i){for(let e=0;e<n.length;e++)o+=i<=6?"".padStart(i,"#")+" "+n[e].topic+"\n\n":"".padStart(i-7,"\t")+"- "+n[e].topic+"\n",n[e].children&&t(n[e].children,i+1)}(e.children,2),o},scale:function(e){this.scaleVal=e,this.map.style.transform="scale("+e+")"},toCenter:function(){this.container.scrollTo(1e4-this.container.offsetWidth/2,1e4-this.container.offsetHeight/2)},focusNode:function(e){e.nodeObj.root||(null===this.tempDirection&&(this.tempDirection=this.direction),this.isFocusMode||(this.nodeDataBackup=this.nodeData,this.isFocusMode=!0),this.nodeData=e.nodeObj,this.nodeData.root=!0,this.initRight())},cancelFocus:function(){this.isFocusMode=!1,null!==this.tempDirection&&(delete this.nodeData.root,this.nodeData=this.nodeDataBackup,this.direction=this.tempDirection,this.tempDirection=null,this.init())},initLeft:function(){this.direction=0,this.init()},initRight:function(){this.direction=1,this.init()},initSide:function(){this.direction=2,this.init()},setLocale:function(e){this.locale=e,this.init()},enableEdit:function(){this.editable=!0},disableEdit:function(){this.editable=!1},expandNode:function(e,t){const n=e.nodeObj;"boolean"==typeof t?n.expanded=t:!1!==n.expanded?n.expanded=!1:n.expanded=!0,this.layout(),this.linkDiv()},refresh:function(){this.addParentLink(this.nodeData),this.layout(),this.linkDiv()},init:function(){var t;d(this.nodeData),this.mindElixirBox.className+=" mind-elixir",this.mindElixirBox.innerHTML="",this.container=I.createElement("div"),this.container.className="map-container",this.overflowHidden&&(this.container.style.overflow="hidden"),this.map=I.createElement("div"),this.map.className="map-canvas",this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.mindElixirBox.appendChild(this.container),this.root=I.createElement("root"),this.box=I.createElement("children"),this.box.className="box",this.svg2nd=S("svg2nd"),this.linkController=S("linkcontroller"),this.P2=I.createElement("div"),this.P3=I.createElement("div"),this.P2.className=this.P3.className="circle",this.line1=e(0,0,0,0),this.line2=e(0,0,0,0),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=S("topiclinks"),this.map.appendChild(this.root),this.map.appendChild(this.box),this.map.appendChild(this.svg2nd),this.map.appendChild(this.linkController),this.map.appendChild(this.linkSvgGroup),this.map.appendChild(this.P2),this.map.appendChild(this.P3),this.toolBar&&b(this),this.nodeMenu&&function(i){var e=v[i.locale]?i.locale:"en";let o;const t=x("nm-style"),n=x("nm-tag"),r=x("nm-icon");t.innerHTML=`
33
+ L ${n} ${b}`);const v=u.children[1];if(v&&(v.style.top=(u.offsetHeight-v.offsetHeight)/2+"px","lhs"===g?v.style.left="-10px":"rhs"===g&&(v.style.left=u.offsetWidth-10+"px"),v.expanded)){const x=p.children[1].children;0<x.length&&r(x,u)}}})(N.children[1].children,v,!(O="")),k.appendChild(function(e){const t=M.createElementNS(j,"path");return t.setAttribute("d",e),t.setAttribute("stroke","#555"),t.setAttribute("fill","none"),t.setAttribute("stroke-linecap","square"),t.setAttribute("stroke-width","1"),t.setAttribute("transform","translate(0.5,-0.5)"),t}(O))}}this.linkSvgGroup.innerHTML="";for(const w in this.linkData){var e=this.linkData[w];"string"==typeof e.from?this.createLink(E(e.from),E(e.to),!0,e):this.createLink(E(e.from.nodeObj.id),E(e.to.nodeObj.id),!0,e)}},createInputDiv:function(i){if(i){let n=s.createElement("div");const o=i.childNodes[0].textContent;i.appendChild(n),n.innerText=o,n.contentEditable="true",n.spellcheck=!1,n.style.cssText=`min-width:${i.offsetWidth-8}px;`,0===this.direction&&(n.style.right="0"),n.focus(),function(e){const t=s.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}(n),this.inputDiv=n,this.bus.fire("operation",{name:"beginEdit",obj:i.nodeObj}),n.addEventListener("keydown",e=>{e.stopPropagation();var t=e.key;"Enter"!==t&&"Tab"!==t||e.shiftKey||(e.preventDefault(),this.inputDiv.blur(),this.map.focus())}),n.addEventListener("blur",()=>{if(n){const t=i.nodeObj;var e=n.textContent.trim();t.topic=""===e?o:e,n.remove(),this.inputDiv=n=null,this.bus.fire("operation",{name:"finishEdit",obj:t,origin:o}),e!==o&&(i.childNodes[0].textContent=t.topic,this.linkDiv())}})}},createChildren:function(t,e,n){let i;i=e||s.createElement("children");for(let e=0;e<t.length;e++){var o=t[e];const r=s.createElement("GRP");0===n?r.className="lhs":1===n?r.className="rhs":2===n&&(0===o.direction?r.className="lhs":1===o.direction&&(r.className="rhs"));const a=this.createTop(o);o.children&&0<o.children.length?(a.appendChild(p(o.expanded)),r.appendChild(a),!1!==o.expanded&&(o=this.createChildren(o.children),r.appendChild(o))):r.appendChild(a),i.appendChild(r)}return i},createGroup:function(e){const t=s.createElement("GRP"),n=this.createTop(e);return t.appendChild(n),e.children&&0<e.children.length&&(n.appendChild(p(e.expanded)),!1!==e.expanded&&(e=this.createChildren(e.children),t.appendChild(e))),{grp:t,top:n}},createTop:function(e){const t=s.createElement("t");var n=this.createTopic(e);return r(n,e),t.appendChild(n),t},createTopic:function(e){const t=s.createElement("tpc");return t.nodeObj=e,t.dataset.nodeid="me"+e.id,t.draggable=this.draggable,t},selectNode:function(e,t){if(e){if("string"==typeof e)return this.selectNode(E(e));this.currentNode&&(this.currentNode.className=""),e.className="selected",this.currentNode=e,t?this.bus.fire("selectNewNode",e.nodeObj):this.bus.fire("selectNode",e.nodeObj)}},unselectNode:function(){this.currentNode&&(this.currentNode.className=""),this.currentNode=null,this.bus.fire("unselectNode")},selectNextSibling:function(){if(this.currentNode&&"meroot"!==this.currentNode.dataset.nodeid){var t=this.currentNode.parentElement.parentElement.nextSibling;let e;var n=this.currentNode.parentElement.parentElement;if("rhs"===n.className||"lhs"===n.className){var i=this.mindElixirBox.querySelectorAll("."+n.className),n=Array.from(i).indexOf(n);if(!(n+1<i.length))return!1;e=i[n+1].firstChild.firstChild}else{if(!t)return!1;e=t.firstChild.firstChild}return this.selectNode(e),!0}},selectPrevSibling:function(){if(this.currentNode&&"meroot"!==this.currentNode.dataset.nodeid){var t=this.currentNode.parentElement.parentElement.previousSibling;let e;var n=this.currentNode.parentElement.parentElement;if("rhs"===n.className||"lhs"===n.className){var i=this.mindElixirBox.querySelectorAll("."+n.className),n=Array.from(i).indexOf(n);if(!(0<=n-1))return!1;e=i[n-1].firstChild.firstChild}else{if(!t)return!1;e=t.firstChild.firstChild}return this.selectNode(e),!0}},selectFirstChild:function(){var e;!this.currentNode||(e=this.currentNode.parentElement.nextSibling)&&e.firstChild&&(e=e.firstChild.firstChild.firstChild,this.selectNode(e))},selectParent:function(){var e;!this.currentNode||"meroot"===this.currentNode.dataset.nodeid||(e=this.currentNode.parentElement.parentElement.parentElement.previousSibling)&&(e=e.firstChild,this.selectNode(e))},getAllDataString:function(){var e={nodeData:n(this),linkData:this.linkData};return JSON.stringify(e,(e,t)=>{if("parent"!==e)return"from"===e||"to"===e?t.nodeObj.id:t})},getAllData:function(){var e={nodeData:n(this),linkData:this.linkData};return JSON.parse(JSON.stringify(e,(e,t)=>{if("parent"!==e)return"from"===e||"to"===e?t.nodeObj.id:t}))},getAllDataMd:function(){var e=n(this);let o="# "+e.topic+"\n\n";return function t(n,i){for(let e=0;e<n.length;e++)o+=i<=6?"".padStart(i,"#")+" "+n[e].topic+"\n\n":"".padStart(i-7,"\t")+"- "+n[e].topic+"\n",n[e].children&&t(n[e].children,i+1)}(e.children,2),o},scale:function(e){this.scaleVal=e,this.map.style.transform="scale("+e+")"},toCenter:function(){this.container.scrollTo(1e4-this.container.offsetWidth/2,1e4-this.container.offsetHeight/2)},focusNode:function(e){e.nodeObj.root||(null===this.tempDirection&&(this.tempDirection=this.direction),this.isFocusMode||(this.nodeDataBackup=this.nodeData,this.isFocusMode=!0),this.nodeData=e.nodeObj,this.nodeData.root=!0,this.initRight())},cancelFocus:function(){this.isFocusMode=!1,null!==this.tempDirection&&(delete this.nodeData.root,this.nodeData=this.nodeDataBackup,this.direction=this.tempDirection,this.tempDirection=null,this.init())},initLeft:function(){this.direction=0,this.init()},initRight:function(){this.direction=1,this.init()},initSide:function(){this.direction=2,this.init()},setLocale:function(e){this.locale=e,this.init()},enableEdit:function(){this.editable=!0},disableEdit:function(){this.editable=!1},expandNode:function(e,t){const n=e.nodeObj;"boolean"==typeof t?n.expanded=t:!1!==n.expanded?n.expanded=!1:n.expanded=!0,this.layout(),this.linkDiv(),this.bus.fire("expandNode",n)},refresh:function(){this.addParentLink(this.nodeData),this.layout(),this.linkDiv()},init:function(){var t;d(this.nodeData),this.mindElixirBox.className+=" mind-elixir",this.mindElixirBox.innerHTML="",this.container=I.createElement("div"),this.container.className="map-container",this.overflowHidden&&(this.container.style.overflow="hidden"),this.map=I.createElement("div"),this.map.className="map-canvas",this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.mindElixirBox.appendChild(this.container),this.root=I.createElement("root"),this.box=I.createElement("children"),this.box.className="box",this.svg2nd=S("svg2nd"),this.linkController=S("linkcontroller"),this.P2=I.createElement("div"),this.P3=I.createElement("div"),this.P2.className=this.P3.className="circle",this.line1=e(0,0,0,0),this.line2=e(0,0,0,0),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=S("topiclinks"),this.map.appendChild(this.root),this.map.appendChild(this.box),this.map.appendChild(this.svg2nd),this.map.appendChild(this.linkController),this.map.appendChild(this.linkSvgGroup),this.map.appendChild(this.P2),this.map.appendChild(this.P3),this.toolBar&&b(this),this.nodeMenu&&function(i){var e=v[i.locale]?i.locale:"en";let o;const t=x("nm-style"),n=x("nm-tag"),r=x("nm-icon");t.innerHTML=`
34
34
  <div class="nm-fontsize-container">
35
35
  ${["15","24","32"].map(e=>`<div class="size" data-size="${e}">
36
36
  <svg class="icon" style="width: ${e}px;height: ${e}px" aria-hidden="true">
@@ -30,6 +30,6 @@
30
30
  L ${i} ${e}
31
31
  L ${i} ${g+C}
32
32
  A ${C} ${C} 0 0 1 ${i+C},${g}
33
- L ${n} ${g}`);const v=u.children[1];if(v&&(v.style.top=(u.offsetHeight-v.offsetHeight)/2+"px","lhs"===b?v.style.left="-10px":"rhs"===b&&(v.style.left=u.offsetWidth-10+"px"),v.expanded)){const x=p.children[1].children;0<x.length&&a(x,u)}}})(k.children[1].children,v,!(T="")),N.appendChild(function(e){const t=E.createElementNS(S,"path");return t.setAttribute("d",e),t.setAttribute("stroke","#555"),t.setAttribute("fill","none"),t.setAttribute("stroke-linecap","square"),t.setAttribute("stroke-width","1"),t.setAttribute("transform","translate(0.5,-0.5)"),t}(T))}}this.linkSvgGroup.innerHTML="";for(const w in this.linkData){var e=this.linkData[w];"string"==typeof e.from?this.createLink(L(e.from),L(e.to),!0,e):this.createLink(L(e.from.nodeObj.id),L(e.to.nodeObj.id),!0,e)}},createChildren:function(t,e,n){let i;i=e||s.createElement("children");for(let e=0;e<t.length;e++){var o=t[e];const a=s.createElement("GRP");0===n?a.className="lhs":1===n?a.className="rhs":2===n&&(0===o.direction?a.className="lhs":1===o.direction&&(a.className="rhs"));const r=this.createTop(o);o.children&&0<o.children.length?(r.appendChild(l(o.expanded)),a.appendChild(r),!1!==o.expanded&&(o=this.createChildren(o.children),a.appendChild(o))):a.appendChild(r),i.appendChild(a)}return i},createGroup:function(e){const t=s.createElement("GRP"),n=this.createTop(e);return t.appendChild(n),e.children&&0<e.children.length&&(n.appendChild(l(e.expanded)),!1!==e.expanded&&(e=this.createChildren(e.children),t.appendChild(e))),{grp:t,top:n}},createTop:function(e){const t=s.createElement("t");var n=this.createTopic(e);return a(n,e),t.appendChild(n),t},createTopic:function(e){const t=s.createElement("tpc");return t.nodeObj=e,t.dataset.nodeid="me"+e.id,t.draggable=this.draggable,t},selectNode:function(e,t){if(e){if("string"==typeof e)return this.selectNode(L(e));this.currentNode&&(this.currentNode.className=""),e.className="selected",this.currentNode=e,t?this.bus.fire("selectNewNode",e.nodeObj):this.bus.fire("selectNode",e.nodeObj)}},unselectNode:function(){this.currentNode&&(this.currentNode.className=""),this.currentNode=null,this.bus.fire("unselectNode")},selectNextSibling:function(){if(this.currentNode&&"meroot"!==this.currentNode.dataset.nodeid){var t=this.currentNode.parentElement.parentElement.nextSibling;let e;var n=this.currentNode.parentElement.parentElement;if("rhs"===n.className||"lhs"===n.className){var i=this.mindElixirBox.querySelectorAll("."+n.className),n=Array.from(i).indexOf(n);if(!(n+1<i.length))return!1;e=i[n+1].firstChild.firstChild}else{if(!t)return!1;e=t.firstChild.firstChild}return this.selectNode(e),!0}},selectPrevSibling:function(){if(this.currentNode&&"meroot"!==this.currentNode.dataset.nodeid){var t=this.currentNode.parentElement.parentElement.previousSibling;let e;var n=this.currentNode.parentElement.parentElement;if("rhs"===n.className||"lhs"===n.className){var i=this.mindElixirBox.querySelectorAll("."+n.className),n=Array.from(i).indexOf(n);if(!(0<=n-1))return!1;e=i[n-1].firstChild.firstChild}else{if(!t)return!1;e=t.firstChild.firstChild}return this.selectNode(e),!0}},selectFirstChild:function(){var e;!this.currentNode||(e=this.currentNode.parentElement.nextSibling)&&e.firstChild&&(e=e.firstChild.firstChild.firstChild,this.selectNode(e))},selectParent:function(){var e;!this.currentNode||"meroot"===this.currentNode.dataset.nodeid||(e=this.currentNode.parentElement.parentElement.parentElement.previousSibling)&&(e=e.firstChild,this.selectNode(e))},getAllDataString:function(){var e={nodeData:t(this),linkData:this.linkData};return JSON.stringify(e,(e,t)=>{if("parent"!==e)return"from"===e||"to"===e?t.nodeObj.id:t})},getAllData:function(){var e={nodeData:t(this),linkData:this.linkData};return JSON.parse(JSON.stringify(e,(e,t)=>{if("parent"!==e)return"from"===e||"to"===e?t.nodeObj.id:t}))},getAllDataMd:function(){var e=t(this);let o="# "+e.topic+"\n\n";return function t(n,i){for(let e=0;e<n.length;e++)o+=i<=6?"".padStart(i,"#")+" "+n[e].topic+"\n\n":"".padStart(i-7,"\t")+"- "+n[e].topic+"\n",n[e].children&&t(n[e].children,i+1)}(e.children,2),o},scale:function(e){this.scaleVal=e,this.map.style.transform="scale("+e+")"},toCenter:function(){this.container.scrollTo(1e4-this.container.offsetWidth/2,1e4-this.container.offsetHeight/2)},focusNode:function(e){e.nodeObj.root||(null===this.tempDirection&&(this.tempDirection=this.direction),this.isFocusMode||(this.nodeDataBackup=this.nodeData,this.isFocusMode=!0),this.nodeData=e.nodeObj,this.nodeData.root=!0,this.initRight())},cancelFocus:function(){this.isFocusMode=!1,null!==this.tempDirection&&(delete this.nodeData.root,this.nodeData=this.nodeDataBackup,this.direction=this.tempDirection,this.tempDirection=null,this.init())},initLeft:function(){this.direction=0,this.init()},initRight:function(){this.direction=1,this.init()},initSide:function(){this.direction=2,this.init()},setLocale:function(e){this.locale=e,this.init()},expandNode:function(e,t){const n=e.nodeObj;"boolean"==typeof t?n.expanded=t:!1!==n.expanded?n.expanded=!1:n.expanded=!0,this.layout(),this.linkDiv()},init:function(){var t;n(this.nodeData),this.mindElixirBox.className+=" mind-elixir",this.mindElixirBox.innerHTML="",this.container=f.createElement("div"),this.container.className="map-container",this.overflowHidden&&(this.container.style.overflow="hidden"),this.map=f.createElement("div"),this.map.className="map-canvas",this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.mindElixirBox.appendChild(this.container),this.root=f.createElement("root"),this.box=f.createElement("children"),this.box.className="box",this.svg2nd=M("svg2nd"),this.linkController=M("linkcontroller"),this.P2=f.createElement("div"),this.P3=f.createElement("div"),this.P2.className=this.P3.className="circle",this.line1=e(0,0,0,0),this.line2=e(0,0,0,0),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=M("topiclinks"),this.map.appendChild(this.root),this.map.appendChild(this.box),this.map.appendChild(this.svg2nd),this.map.appendChild(this.linkController),this.map.appendChild(this.linkSvgGroup),this.map.appendChild(this.P2),this.map.appendChild(this.P3),this.toolBar&&p(this),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&this.mobileMenu?function(t,n){var i=(e,t)=>{const n=document.createElement("div");return n.id=e,n.innerHTML=`<svg class="icon" aria-hidden="true">
33
+ L ${n} ${g}`);const v=u.children[1];if(v&&(v.style.top=(u.offsetHeight-v.offsetHeight)/2+"px","lhs"===b?v.style.left="-10px":"rhs"===b&&(v.style.left=u.offsetWidth-10+"px"),v.expanded)){const x=p.children[1].children;0<x.length&&a(x,u)}}})(k.children[1].children,v,!(T="")),N.appendChild(function(e){const t=E.createElementNS(S,"path");return t.setAttribute("d",e),t.setAttribute("stroke","#555"),t.setAttribute("fill","none"),t.setAttribute("stroke-linecap","square"),t.setAttribute("stroke-width","1"),t.setAttribute("transform","translate(0.5,-0.5)"),t}(T))}}this.linkSvgGroup.innerHTML="";for(const w in this.linkData){var e=this.linkData[w];"string"==typeof e.from?this.createLink(L(e.from),L(e.to),!0,e):this.createLink(L(e.from.nodeObj.id),L(e.to.nodeObj.id),!0,e)}},createChildren:function(t,e,n){let i;i=e||s.createElement("children");for(let e=0;e<t.length;e++){var o=t[e];const a=s.createElement("GRP");0===n?a.className="lhs":1===n?a.className="rhs":2===n&&(0===o.direction?a.className="lhs":1===o.direction&&(a.className="rhs"));const r=this.createTop(o);o.children&&0<o.children.length?(r.appendChild(l(o.expanded)),a.appendChild(r),!1!==o.expanded&&(o=this.createChildren(o.children),a.appendChild(o))):a.appendChild(r),i.appendChild(a)}return i},createGroup:function(e){const t=s.createElement("GRP"),n=this.createTop(e);return t.appendChild(n),e.children&&0<e.children.length&&(n.appendChild(l(e.expanded)),!1!==e.expanded&&(e=this.createChildren(e.children),t.appendChild(e))),{grp:t,top:n}},createTop:function(e){const t=s.createElement("t");var n=this.createTopic(e);return a(n,e),t.appendChild(n),t},createTopic:function(e){const t=s.createElement("tpc");return t.nodeObj=e,t.dataset.nodeid="me"+e.id,t.draggable=this.draggable,t},selectNode:function(e,t){if(e){if("string"==typeof e)return this.selectNode(L(e));this.currentNode&&(this.currentNode.className=""),e.className="selected",this.currentNode=e,t?this.bus.fire("selectNewNode",e.nodeObj):this.bus.fire("selectNode",e.nodeObj)}},unselectNode:function(){this.currentNode&&(this.currentNode.className=""),this.currentNode=null,this.bus.fire("unselectNode")},selectNextSibling:function(){if(this.currentNode&&"meroot"!==this.currentNode.dataset.nodeid){var t=this.currentNode.parentElement.parentElement.nextSibling;let e;var n=this.currentNode.parentElement.parentElement;if("rhs"===n.className||"lhs"===n.className){var i=this.mindElixirBox.querySelectorAll("."+n.className),n=Array.from(i).indexOf(n);if(!(n+1<i.length))return!1;e=i[n+1].firstChild.firstChild}else{if(!t)return!1;e=t.firstChild.firstChild}return this.selectNode(e),!0}},selectPrevSibling:function(){if(this.currentNode&&"meroot"!==this.currentNode.dataset.nodeid){var t=this.currentNode.parentElement.parentElement.previousSibling;let e;var n=this.currentNode.parentElement.parentElement;if("rhs"===n.className||"lhs"===n.className){var i=this.mindElixirBox.querySelectorAll("."+n.className),n=Array.from(i).indexOf(n);if(!(0<=n-1))return!1;e=i[n-1].firstChild.firstChild}else{if(!t)return!1;e=t.firstChild.firstChild}return this.selectNode(e),!0}},selectFirstChild:function(){var e;!this.currentNode||(e=this.currentNode.parentElement.nextSibling)&&e.firstChild&&(e=e.firstChild.firstChild.firstChild,this.selectNode(e))},selectParent:function(){var e;!this.currentNode||"meroot"===this.currentNode.dataset.nodeid||(e=this.currentNode.parentElement.parentElement.parentElement.previousSibling)&&(e=e.firstChild,this.selectNode(e))},getAllDataString:function(){var e={nodeData:t(this),linkData:this.linkData};return JSON.stringify(e,(e,t)=>{if("parent"!==e)return"from"===e||"to"===e?t.nodeObj.id:t})},getAllData:function(){var e={nodeData:t(this),linkData:this.linkData};return JSON.parse(JSON.stringify(e,(e,t)=>{if("parent"!==e)return"from"===e||"to"===e?t.nodeObj.id:t}))},getAllDataMd:function(){var e=t(this);let o="# "+e.topic+"\n\n";return function t(n,i){for(let e=0;e<n.length;e++)o+=i<=6?"".padStart(i,"#")+" "+n[e].topic+"\n\n":"".padStart(i-7,"\t")+"- "+n[e].topic+"\n",n[e].children&&t(n[e].children,i+1)}(e.children,2),o},scale:function(e){this.scaleVal=e,this.map.style.transform="scale("+e+")"},toCenter:function(){this.container.scrollTo(1e4-this.container.offsetWidth/2,1e4-this.container.offsetHeight/2)},focusNode:function(e){e.nodeObj.root||(null===this.tempDirection&&(this.tempDirection=this.direction),this.isFocusMode||(this.nodeDataBackup=this.nodeData,this.isFocusMode=!0),this.nodeData=e.nodeObj,this.nodeData.root=!0,this.initRight())},cancelFocus:function(){this.isFocusMode=!1,null!==this.tempDirection&&(delete this.nodeData.root,this.nodeData=this.nodeDataBackup,this.direction=this.tempDirection,this.tempDirection=null,this.init())},initLeft:function(){this.direction=0,this.init()},initRight:function(){this.direction=1,this.init()},initSide:function(){this.direction=2,this.init()},setLocale:function(e){this.locale=e,this.init()},expandNode:function(e,t){const n=e.nodeObj;"boolean"==typeof t?n.expanded=t:!1!==n.expanded?n.expanded=!1:n.expanded=!0,this.layout(),this.linkDiv(),this.bus.fire("expandNode",n)},init:function(){var t;n(this.nodeData),this.mindElixirBox.className+=" mind-elixir",this.mindElixirBox.innerHTML="",this.container=f.createElement("div"),this.container.className="map-container",this.overflowHidden&&(this.container.style.overflow="hidden"),this.map=f.createElement("div"),this.map.className="map-canvas",this.map.setAttribute("tabindex","0"),this.container.appendChild(this.map),this.mindElixirBox.appendChild(this.container),this.root=f.createElement("root"),this.box=f.createElement("children"),this.box.className="box",this.svg2nd=M("svg2nd"),this.linkController=M("linkcontroller"),this.P2=f.createElement("div"),this.P3=f.createElement("div"),this.P2.className=this.P3.className="circle",this.line1=e(0,0,0,0),this.line2=e(0,0,0,0),this.linkController.appendChild(this.line1),this.linkController.appendChild(this.line2),this.linkSvgGroup=M("topiclinks"),this.map.appendChild(this.root),this.map.appendChild(this.box),this.map.appendChild(this.svg2nd),this.map.appendChild(this.linkController),this.map.appendChild(this.linkSvgGroup),this.map.appendChild(this.P2),this.map.appendChild(this.P3),this.toolBar&&p(this),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&this.mobileMenu?function(t,n){var i=(e,t)=>{const n=document.createElement("div");return n.id=e,n.innerHTML=`<svg class="icon" aria-hidden="true">
34
34
  <use xlink:href="#icon-${t}"></use>
35
35
  </svg>`,n};const e=i("cm-add_child","zijiedian"),o=i("cm-add_sibling","tongjijiedian-"),a=i("cm-remove_child","shanchu2"),r=i("cm-up","rising"),s=i("cm-down","falling"),l=i("cm-edit","edit"),c=document.createElement("ul");if(c.className="menu-list",n&&n.extend)for(let e=0;e<n.extend.length;e++){const p=n.extend[e],u=i(p.name,p.name);c.appendChild(u),u.onclick=e=>{p.onclick(e)}}const d=document.createElement("mmenu");d.appendChild(e),d.appendChild(o),d.appendChild(a),d.appendChild(r),d.appendChild(s),d.appendChild(l),d.hidden=!0,t.container.append(d);let h=!0;t.bus.addListener("unselectNode",function(){d.hidden=!0}),t.bus.addListener("selectNode",function(e){d.hidden=!1,h=!!e.root}),d.onclick=e=>{e.target===d&&(d.hidden=!0)},e.onclick=e=>{t.addChild()},o.onclick=e=>{h||t.insertSibling()},a.onclick=e=>{h||t.removeNode()},r.onclick=e=>{h||t.moveUpNode()},s.onclick=e=>{h||t.moveDownNode()},l.onclick=e=>{t.beginEdit()}}(this):this.contextMenu&&d(this,this.contextMenuOption),this.toCenter(),this.layout(),this.linkDiv(),this.overflowHidden||((t=this).map.addEventListener("click",e=>{"EPD"===e.target.nodeName?t.expandNode(e.target.previousSibling):"T"===e.target.parentElement.nodeName||"ROOT"===e.target.parentElement.nodeName?t.selectNode(e.target):"path"===e.target.nodeName?"g"===e.target.parentElement.nodeName&&t.selectLink(e.target.parentElement):"circle"===e.target.className||(t.unselectNode(),t.hideLinkController())}),t.map.addEventListener("dblclick",e=>{e.preventDefault(),t.editable&&("T"!==e.target.parentElement.nodeName&&"ROOT"!==e.target.parentElement.nodeName||t.beginEdit(e.target))}),t.map.addEventListener("mousemove",e=>{"true"!==e.target.contentEditable&&i.onMove(e,t.container)}),t.map.addEventListener("mousedown",e=>{"true"!==e.target.contentEditable&&(i.afterMoving=!1,i.mousedown=!0)}),t.map.addEventListener("mouseleave",e=>{i.clear()}),t.map.addEventListener("mouseup",e=>{i.clear()}))}},m.LEFT=0,m.RIGHT=1,m.SIDE=2,m.version="0.17.0",m.E=L;const g=m})(),y.default})()});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mind-elixir",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "description": "Mind elixir is a free open source mind map core.",
5
5
  "main": "dist/MindElixir.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -152,9 +152,14 @@ mind.bus.addListener('operation', operation => {
152
152
  // name: moveNode
153
153
  // obj: {from:target1,to:target2}
154
154
  })
155
+
155
156
  mind.bus.addListener('selectNode', node => {
156
157
  console.log(node)
157
158
  })
159
+
160
+ mind.bus.addListener('expandNode', node => {
161
+ console.log('expandNode: ', node)
162
+ })
158
163
  ```
159
164
 
160
165
  ### Data Export
@@ -167,6 +172,8 @@ mind.getAllDataMd() // markdown
167
172
 
168
173
  ### Export as image
169
174
 
175
+ **WIP**
176
+
170
177
  ```javascript
171
178
  import painter from 'mind-elixir/dist/painter'
172
179
  painter.exportSvg()