diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f2b775d..7fbee68 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,9 @@ -name: Build/release +name: Build and Release -on: push +on: + push: + branches: + - main jobs: release: @@ -8,24 +11,30 @@ jobs: strategy: matrix: - os: [macos-latest, ubuntu-latest, windows-latest] + os: [macos-latest, windows-latest, ubuntu-latest] steps: - - name: Check out Git repository - uses: actions/checkout@v1 + - name: Check out source code + uses: actions/checkout@v2 - - name: Install Node.js, NPM and Yarn - uses: actions/setup-node@v1 + - name: Install Node.js + uses: actions/setup-node@v2 with: - node-version: 16 + node-version: 14 - - name: Build/release Electron app - uses: samuelmeuli/action-electron-builder@v1 + - name: Install dependencies + run: npm ci + + - name: Build application + run: npm run build + + - name: Test application + run: npm test + + - name: Set up electron-builder + uses: samuelmeuli/action-electron-builder@v2 with: - # GitHub token, automatically provided to the action - # (No need to define this secret in the repo settings) - github_token: ${{ secrets.github_token }} + github_token: ${{ secrets.GITHUB_TOKEN }} - # If the commit is tagged with a version (e.g. "v1.0.0"), - # release the app after building - release: ${{ startsWith(github.ref, 'refs/tags/v') }} + - name: Publish application + run: npm run release \ No newline at end of file diff --git a/app/public/mind/index.html b/app/public/mind/index.html new file mode 100644 index 0000000..b93b5c8 --- /dev/null +++ b/app/public/mind/index.html @@ -0,0 +1,34 @@ + + + + + + + +
+ + + + diff --git a/app/public/mind/jsmind.css b/app/public/mind/jsmind.css new file mode 100644 index 0000000..2c126c6 --- /dev/null +++ b/app/public/mind/jsmind.css @@ -0,0 +1,408 @@ +/** + * @license BSD + * @copyright 2014-2023 hizzgdev@163.com + * + * Project Home: + * https://github.com/hizzgdev/jsmind/ + */ + +/* important section */ +.jsmind-inner { + position: relative; + overflow: auto; + width: 100%; + height: 100%; + outline: none; +} /*box-shadow:0 0 2px #000;*/ +.jsmind-inner { + moz-user-select: -moz-none; + -moz-user-select: none; + -o-user-select: none; + -khtml-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.jsmind-inner canvas { + position: absolute; +} + +/* z-index:1 */ +svg.jsmind { + position: absolute; + z-index: 1; +} +canvas.jsmind { + position: absolute; + z-index: 1; +} + +/* z-index:2 */ +jmnodes { + position: absolute; + z-index: 2; + background-color: rgba(0, 0, 0, 0); +} /*background color is necessary*/ +jmnode { + position: absolute; + cursor: default; + max-width: 400px; +} +jmexpander { + position: absolute; + width: 11px; + height: 11px; + display: block; + overflow: hidden; + line-height: 12px; + font-size: 12px; + text-align: center; + border-radius: 6px; + border-width: 1px; + border-style: solid; + cursor: pointer; +} + +.jmnode-overflow-wrap jmnodes { + min-width: 420px; +} + +.jmnode-overflow-hidden jmnode { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +/* default theme */ +jmnode { + padding: 10px; + background-color: #fff; + color: #333; + border-radius: 5px; + box-shadow: 1px 1px 1px #666; + font: 16px/1.125 Verdana, Arial, Helvetica, sans-serif; +} +jmnode:hover { + box-shadow: 2px 2px 8px #000; + background-color: #ebebeb; + color: #333; +} +jmnode.selected { + background-color: #11f; + color: #fff; + box-shadow: 2px 2px 8px #000; +} +jmnode.root { + font-size: 24px; +} +jmexpander { + border-color: gray; +} +jmexpander:hover { + border-color: #000; +} + +@media screen and (max-device-width: 1024px) { + jmnode { + padding: 5px; + border-radius: 3px; + font-size: 14px; + } + jmnode.root { + font-size: 21px; + } +} +/* primary theme */ +jmnodes.theme-primary jmnode { + background-color: #428bca; + color: #fff; + border-color: #357ebd; +} +jmnodes.theme-primary jmnode:hover { + background-color: #3276b1; + border-color: #285e8e; +} +jmnodes.theme-primary jmnode.selected { + background-color: #f1c40f; + color: #fff; +} +jmnodes.theme-primary jmnode.root { +} +jmnodes.theme-primary jmexpander { +} +jmnodes.theme-primary jmexpander:hover { +} + +/* warning theme */ +jmnodes.theme-warning jmnode { + background-color: #f0ad4e; + border-color: #eea236; + color: #fff; +} +jmnodes.theme-warning jmnode:hover { + background-color: #ed9c28; + border-color: #d58512; +} +jmnodes.theme-warning jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-warning jmnode.root { +} +jmnodes.theme-warning jmexpander { +} +jmnodes.theme-warning jmexpander:hover { +} + +/* danger theme */ +jmnodes.theme-danger jmnode { + background-color: #d9534f; + border-color: #d43f3a; + color: #fff; +} +jmnodes.theme-danger jmnode:hover { + background-color: #d2322d; + border-color: #ac2925; +} +jmnodes.theme-danger jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-danger jmnode.root { +} +jmnodes.theme-danger jmexpander { +} +jmnodes.theme-danger jmexpander:hover { +} + +/* success theme */ +jmnodes.theme-success jmnode { + background-color: #5cb85c; + border-color: #4cae4c; + color: #fff; +} +jmnodes.theme-success jmnode:hover { + background-color: #47a447; + border-color: #398439; +} +jmnodes.theme-success jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-success jmnode.root { +} +jmnodes.theme-success jmexpander { +} +jmnodes.theme-success jmexpander:hover { +} + +/* info theme */ +jmnodes.theme-info jmnode { + background-color: #5dc0de; + border-color: #46b8da; + color: #fff; +} +jmnodes.theme-info jmnode:hover { + background-color: #39b3d7; + border-color: #269abc; +} +jmnodes.theme-info jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-info jmnode.root { +} +jmnodes.theme-info jmexpander { +} +jmnodes.theme-info jmexpander:hover { +} + +/* greensea theme */ +jmnodes.theme-greensea jmnode { + background-color: #1abc9c; + color: #fff; +} +jmnodes.theme-greensea jmnode:hover { + background-color: #16a085; +} +jmnodes.theme-greensea jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-greensea jmnode.root { +} +jmnodes.theme-greensea jmexpander { +} +jmnodes.theme-greensea jmexpander:hover { +} + +/* nephrite theme */ +jmnodes.theme-nephrite jmnode { + background-color: #2ecc71; + color: #fff; +} +jmnodes.theme-nephrite jmnode:hover { + background-color: #27ae60; +} +jmnodes.theme-nephrite jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-nephrite jmnode.root { +} +jmnodes.theme-nephrite jmexpander { +} +jmnodes.theme-nephrite jmexpander:hover { +} + +/* belizehole theme */ +jmnodes.theme-belizehole jmnode { + background-color: #3498db; + color: #fff; +} +jmnodes.theme-belizehole jmnode:hover { + background-color: #2980b9; +} +jmnodes.theme-belizehole jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-belizehole jmnode.root { +} +jmnodes.theme-belizehole jmexpander { +} +jmnodes.theme-belizehole jmexpander:hover { +} + +/* wisteria theme */ +jmnodes.theme-wisteria jmnode { + background-color: #9b59b6; + color: #fff; +} +jmnodes.theme-wisteria jmnode:hover { + background-color: #8e44ad; +} +jmnodes.theme-wisteria jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-wisteria jmnode.root { +} +jmnodes.theme-wisteria jmexpander { +} +jmnodes.theme-wisteria jmexpander:hover { +} + +/* asphalt theme */ +jmnodes.theme-asphalt jmnode { + background-color: #34495e; + color: #fff; +} +jmnodes.theme-asphalt jmnode:hover { + background-color: #2c3e50; +} +jmnodes.theme-asphalt jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-asphalt jmnode.root { +} +jmnodes.theme-asphalt jmexpander { +} +jmnodes.theme-asphalt jmexpander:hover { +} + +/* orange theme */ +jmnodes.theme-orange jmnode { + background-color: #f1c40f; + color: #fff; +} +jmnodes.theme-orange jmnode:hover { + background-color: #f39c12; +} +jmnodes.theme-orange jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-orange jmnode.root { +} +jmnodes.theme-orange jmexpander { +} +jmnodes.theme-orange jmexpander:hover { +} + +/* pumpkin theme */ +jmnodes.theme-pumpkin jmnode { + background-color: #e67e22; + color: #fff; +} +jmnodes.theme-pumpkin jmnode:hover { + background-color: #d35400; +} +jmnodes.theme-pumpkin jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-pumpkin jmnode.root { +} +jmnodes.theme-pumpkin jmexpander { +} +jmnodes.theme-pumpkin jmexpander:hover { +} + +/* pomegranate theme */ +jmnodes.theme-pomegranate jmnode { + background-color: #e74c3c; + color: #fff; +} +jmnodes.theme-pomegranate jmnode:hover { + background-color: #c0392b; +} +jmnodes.theme-pomegranate jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-pomegranate jmnode.root { +} +jmnodes.theme-pomegranate jmexpander { +} +jmnodes.theme-pomegranate jmexpander:hover { +} + +/* clouds theme */ +jmnodes.theme-clouds jmnode { + background-color: #ecf0f1; + color: #333; +} +jmnodes.theme-clouds jmnode:hover { + background-color: #bdc3c7; +} +jmnodes.theme-clouds jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-clouds jmnode.root { +} +jmnodes.theme-clouds jmexpander { +} +jmnodes.theme-clouds jmexpander:hover { +} + +/* asbestos theme */ +jmnodes.theme-asbestos jmnode { + background-color: #95a5a6; + color: #fff; +} +jmnodes.theme-asbestos jmnode:hover { + background-color: #7f8c8d; +} +jmnodes.theme-asbestos jmnode.selected { + background-color: #11f; + color: #fff; +} +jmnodes.theme-asbestos jmnode.root { +} +jmnodes.theme-asbestos jmexpander { +} +jmnodes.theme-asbestos jmexpander:hover { +} diff --git a/app/public/mind/jsmind.js b/app/public/mind/jsmind.js new file mode 100644 index 0000000..95f764c --- /dev/null +++ b/app/public/mind/jsmind.js @@ -0,0 +1,9 @@ +/** +* @license BSD-3-Clause +* @copyright 2014-2023 hizzgdev@163.com +* +* Project Home: +* https://github.com/hizzgdev/jsmind/ +*/ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).jsMind=t()}(this,(function(){"use strict";const e="0.6.0",t="hizzgdev@163.com";"function"!=typeof String.prototype.startsWith&&(String.prototype.startsWith=function(e){return this.slice(0,e.length)===e});const i={left:-1,center:0,right:1,of:function(e){return e&&-1!==e&&0!==e&&1!==e?"-1"===e||"0"===e||"1"===e?parseInt(e):"left"===e.toLowerCase()?this.left:"right"===e.toLowerCase()?this.right:"center"===e.toLowerCase()?this.center:void 0:e}},n={show:1,resize:2,edit:3,select:4},o={debug:1,info:2,warn:3,error:4,disable:9};var s=function(){};let a="undefined"==typeof console?{level:s,log:s,debug:s,info:s,warn:s,error:s}:{level:function(e){a.debug=e>o.debug?s:console.debug;a.info=e>o.info?s:console.info;a.warn=e>o.warn?s:console.warn;a.error=e>o.error?s:console.error},log:console.log,debug:console.debug,info:console.info,warn:console.warn,error:console.error};const r=new class{constructor(e){this.w=e,this.d=e.document,this.g=function(e){return this.d.getElementById(e)},this.c=function(e){return this.d.createElement(e)},this.t=function(e,t){e.hasChildNodes()?e.firstChild.nodeValue=t:e.appendChild(this.d.createTextNode(t))},this.h=function(e,t){t instanceof HTMLElement?(e.innerHTML="",e.appendChild(t)):e.innerHTML=t},this.i=function(e){return!!e&&"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument},this.on=function(e,t,i){e.addEventListener?e.addEventListener(t,i,!1):e.attachEvent("on"+t,i)}}}(window),d={ajax:{request:function(e,t,i,n,o){var s=Object.keys(t).map((e=>encodeURIComponent(e)+"="+encodeURIComponent(t[e]))).join("&"),r=new XMLHttpRequest;r&&(r.onreadystatechange=function(){if(4==r.readyState)if(200==r.status||0==r.status){if("function"==typeof n){var e=d.json.string2json(r.responseText);n(null!=e?e:r.responseText)}}else"function"==typeof o?o(r):a.error("xhr request failed.",r)},i=i||"GET",r.open(i,e,!0),r.setRequestHeader("If-Modified-Since","0"),"POST"==i?(r.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),r.send(s)):r.send())},get:function(e,t){return d.ajax.request(e,{},"GET",t)},post:function(e,t,i){return d.ajax.request(e,t,"POST",i)}},file:{read:function(e,t){var i=new FileReader;i.onload=function(){"function"==typeof t&&t(this.result,e.name)},i.readAsText(e)},save:function(e,t,i){var n;if("function"==typeof r.w.Blob)n=new Blob([e],{type:t});else{var o=new(r.w.BlobBuilder||r.w.MozBlobBuilder||r.w.WebKitBlobBuilder||r.w.MSBlobBuilder);o.append(e),n=o.getBlob(t)}if(navigator.msSaveBlob)navigator.msSaveBlob(n,i);else{var s=(r.w.URL||r.w.webkitURL).createObjectURL(n),a=r.c("a");if("download"in a){a.style.visibility="hidden",a.href=s,a.download=i,r.d.body.appendChild(a);var d=r.d.createEvent("MouseEvents");d.initEvent("click",!0,!0),a.dispatchEvent(d),r.d.body.removeChild(a)}else location.href=s}}},json:{json2string:function(e){return JSON.stringify(e)},string2json:function(e){return JSON.parse(e)},merge:function(e,t){for(var i in t)i in e?"object"!=typeof e[i]||"[object object]"!=Object.prototype.toString.call(e[i]).toLowerCase()||e[i].length?e[i]=t[i]:d.json.merge(e[i],t[i]):e[i]=t[i];return e}},uuid:{newid:function(){return((new Date).getTime().toString(16)+Math.random().toString(16).substring(2)).substring(2,18)}},text:{is_empty:function(e){return!e||0==e.replace(/\s*/,"").length}}},l={container:"",editable:!1,theme:null,mode:"full",support_html:!0,log_level:"info",view:{engine:"canvas",hmargin:100,vmargin:50,line_width:2,line_color:"#555",draggable:!1,hide_scrollbars_when_draggable:!1,node_overflow:"hidden"},layout:{hspace:30,vspace:20,pspace:13,cousin_space:0},default_event_handle:{enable_mousedown_handle:!0,enable_click_handle:!0,enable_dblclick_handle:!0,enable_mousewheel_handle:!0},shortcut:{enable:!0,handles:{},mapping:{addchild:[45,4109],addbrother:13,editnode:113,delnode:46,toggle:32,left:37,up:38,right:39,down:40}}};class h{constructor(e,t,i,n,o,s,r,d){e?"number"==typeof t?(void 0===d&&(d=!0),this.id=e,this.index=t,this.topic=i,this.data=n||{},this.isroot=o,this.parent=s,this.direction=r,this.expanded=!!d,this.children=[],this._data={}):a.error("invalid node index"):a.error("invalid node id")}get_location(){var e=this._data.view;return{x:e.abs_x,y:e.abs_y}}get_size(){var e=this._data.view;return{w:e.width,h:e.height}}static compare(e,t){var i=e.index,n=t.index;return i>=0&&n>=0?i-n:-1==i&&-1==n?0:-1==i?1:-1==n?-1:0}static inherited(e,t){if(e&&t){if(e.id===t.id)return!0;if(e.isroot)return!0;for(var i=e.id,n=t;!n.isroot;)if((n=n.parent).id===i)return!0}return!1}static is_node(e){return!!e&&e instanceof h}}class _{constructor(){this.name=null,this.author=null,this.version=null,this.root=null,this.selected=null,this.nodes={}}get_node(e){return e in this.nodes?this.nodes[e]:(a.warn("the node[id="+e+"] can not be found"),null)}set_root(e,t,i){return null==this.root?(this.root=new h(e,0,t,i,!0),this._put_node(this.root),this.root):(a.error("root node is already exist"),null)}add_node(e,t,n,o,s,r,d){if(!h.is_node(e))return a.error("the parent_node "+e+" is not a node."),null;var l=new h(t,d||-1,n,o,!1,e,e.direction,r);return e.isroot&&(l.direction=s||i.right),this._put_node(l)?(e.children.push(l),this._update_index(e)):(a.error("fail, the node id '"+l.id+"' has been already exist."),l=null),l}insert_node_before(e,t,i,n,o){if(!h.is_node(e))return a.error("the node_before "+e+" is not a node."),null;var s=e.index-.5;return this.add_node(e.parent,t,i,n,o,!0,s)}get_node_before(e){if(!h.is_node(e)){var t=this.get_node(e);return t?this.get_node_before(t):(a.error("the node[id="+e+"] can not be found."),null)}if(e.isroot)return null;var i=e.index-2;return i>=0?e.parent.children[i]:null}insert_node_after(e,t,i,n,o){if(!h.is_node(e))return a.error("the node_after "+e+" is not a node."),null;var s=e.index+.5;return this.add_node(e.parent,t,i,n,o,!0,s)}get_node_after(e){if(!h.is_node(e)){var t=this.get_node(e);return t?this.get_node_after(t):(a.error("the node[id="+e+"] can not be found."),null)}if(e.isroot)return null;var i=e.index;return e.parent.children.length>i?e.parent.children[i]:null}move_node(e,t,i,n){return h.is_node(e)?(i||(i=e.parent.id),this._move_node(e,t,i,n)):(a.error("the parameter node "+e+" is not a node."),null)}_flow_node_direction(e,t){void 0===t?t=e.direction:e.direction=t;for(var i=e.children.length;i--;)this._flow_node_direction(e.children[i],t)}_move_node_internal(e,t){if(e&&t)if("_last_"==t)e.index=-1,this._update_index(e.parent);else if("_first_"==t)e.index=0,this._update_index(e.parent);else{var i=t?this.get_node(t):null;null!=i&&null!=i.parent&&i.parent.id==e.parent.id&&(e.index=i.index-.5,this._update_index(e.parent))}return e}_move_node(e,t,n,o){if(e&&n){var s=this.get_node(n);if(h.inherited(e,s))return a.error("can not move a node to its children"),null;if(e.parent.id!=n){for(var r=e.parent.children,d=r.length;d--;)if(r[d].id==e.id){r.splice(d,1);break}e.parent=s,s.children.push(e)}e.parent.isroot?o==i.left?e.direction=o:e.direction=i.right:e.direction=e.parent.direction,this._move_node_internal(e,t),this._flow_node_direction(e)}return e}remove_node(e){if(!h.is_node(e))return a.error("the parameter node "+e+" is not a node."),!1;if(e.isroot)return a.error("fail, can not remove root node"),!1;null!=this.selected&&this.selected.id==e.id&&(this.selected=null);for(var t=e.children,i=t.length;i--;)this.remove_node(t[i]);t.length=0;for(var n=e.parent.children,o=n.length;o--;)if(n[o].id==e.id){n.splice(o,1);break}for(var s in delete this.nodes[e.id],e)delete e[s];return e=null,!0}_put_node(e){return e.id in this.nodes?(a.warn("the node_id '"+e.id+"' has been already exist."),!1):(this.nodes[e.id]=e,!0)}_update_index(e){if(e instanceof h){e.children.sort(h.compare);for(var t=0;t0){n.children=[];for(var r=0;r0&&(s=n.length,d+=c)}return d},_extract_data:function(e){var t={};for(var i in e)"id"!=i&&"topic"!=i&&"parentid"!=i&&"isroot"!=i&&"direction"!=i&&"expanded"!=i&&(t[i]=e[i]);return t},_array:function(e,t){u.node_array._array_node(e.root,t)},_array_node:function(e,t){var n=u.node_array;if(e instanceof h){var o={id:e.id,topic:e.topic,expanded:e.expanded};if(e.parent&&(o.parentid=e.parent.id),e.isroot&&(o.isroot=!0),e.parent&&e.parent.isroot&&(o.direction=e.direction==i.left?"left":"right"),null!=e.data){var s=e.data;for(var a in s)o[a]=s[a]}t.push(o);for(var r=e.children.length,d=0;d'},get_mind:function(e){var t=u.freemind,i=new _;i.name=e.meta.name,i.author=e.meta.author,i.version=e.meta.version;var n=e.data,o=t._parse_xml(n),s=t._find_root(o);return t._load_node(i,null,s),i},get_data:function(e){var t=u.freemind,i={};i.meta={name:e.name,author:e.author,version:e.version},i.format="freemind";var n=[];return n.push(''),t._build_map(e.root,n),n.push(""),i.data=n.join(" "),i},_parse_xml:function(e){var t=null;window.DOMParser?t=(new DOMParser).parseFromString(e,"text/xml"):((t=new ActiveXObject("Microsoft.XMLDOM")).async=!1,t.loadXML(e));return t},_find_root:function(e){for(var t=e.childNodes,i=null,n=null,o=0;o'),t.push('');var s=e.data;if(null!=s)for(var a in s)t.push('');for(var r=e.children,d=0;d")}},text:{example:{meta:{name:"jsMind text example",author:t,version:e},format:"text",data:"Text Example\n node1\n node1-sub\n node1-sub\n node2"},_line_regex:/\s*/,get_mind:function(e){var t=u.text,i=new _;i.name=e.meta.name,i.author=e.meta.author,i.version=e.meta.version;var n=e.data.split(/\n|\r/);return t._fill_nodes(i,n,0,0),i},_fill_nodes:function(e,t){let i=[],n=0;for(;n0)return void log.error("more than 1 root node was found: "+a);if(s>i.length)return void log.error("a suspended node was found: "+a);let r=i.length-s;for(;r--;)i.pop();if(0==s&&0==i.length){let t=e.set_root(d.uuid.newid(),a);i.push(t)}else{let t=e.add_node(i[s-1],d.uuid.newid(),a,{},null);i.push(t)}n++}i.length=0},get_data:function(e){var t=u.text,i={};i.meta={name:e.name,author:e.author,version:e.version},i.format="text";let n=[];return t._build_lines(n,[e.root],0),i.data=n.join("\n"),i},_build_lines:function(e,t,i){let n=new Array(i+1).join(" ");for(let o of t)e.push(n+o.topic),o.children&&u.text._build_lines(e,o.children,i+1)}}};class c{constructor(e){this.jm=e}init(){a.debug("data.init")}reset(){a.debug("data.reset")}load(e){var t=null,i=null;return"node_array"==(t="object"==typeof e?e.format?e.format:"node_tree":"freemind")?i=u.node_array.get_mind(e):"node_tree"==t?i=u.node_tree.get_mind(e):"freemind"==t?i=u.freemind.get_mind(e):"text"==t?i=u.text.get_mind(e):a.warn("unsupported format"),i}get_data(e){var t=null;return"node_array"==e?t=u.node_array.get_data(this.jm.mind):"node_tree"==e?t=u.node_tree.get_data(this.jm.mind):"freemind"==e?t=u.freemind.get_data(this.jm.mind):"text"==e?t=u.text.get_data(this.jm.mind):a.error("unsupported "+e+" format"),t}}class v{constructor(e,t){this.opts=t,this.jm=e,this.isside="side"==this.opts.mode,this.bounds=null,this.cache_valid=!1}init(){a.debug("layout.init")}reset(){a.debug("layout.reset"),this.bounds={n:0,s:0,w:0,e:0}}calculate_next_child_direction(e){if(this.isside)return i.right;for(var t=e.children||[],n=t.length,o=0,s=0;s1&&o>0?i.left:i.right}layout(){a.debug("layout.layout"),this.layout_direction(),this.layout_offset()}layout_direction(){this._layout_direction_root()}_layout_direction_root(){var e=this.jm.mind.root,t=null;"layout"in e._data?t=e._data.layout:(t={},e._data.layout=t);var n=e.children,o=n.length;if(t.direction=i.center,t.side_index=0,this.isside)for(var s=o;s--;)this._layout_direction_side(n[s],i.right,s);else{s=o;for(var a=null;s--;)(a=n[s]).direction==i.left?this._layout_direction_side(a,i.left,s):this._layout_direction_side(a,i.right,s)}}_layout_direction_side(e,t,i){var n=null;"layout"in e._data?n=e._data.layout:(n={},e._data.layout=n);var o=e.children,s=o.length;n.direction=t,n.side_index=i;for(var a=s;a--;)this._layout_direction_side(o[a],t,a)}layout_offset(){var e=this.jm.mind.root,t=e._data.layout;t.offset_x=0,t.offset_y=0,t.outer_height=0;for(var n=e.children,o=n.length,s=[],a=[],r=null;o--;)(r=n[o])._data.layout.direction==i.right?a.unshift(r):s.unshift(r);t.left_nodes=s,t.right_nodes=a,t.outer_height_left=this._layout_offset_subnodes(s),t.outer_height_right=this._layout_offset_subnodes(a),this.bounds.e=e._data.view.width/2,this.bounds.w=0-this.bounds.e,this.bounds.n=0,this.bounds.s=Math.max(t.outer_height_left,t.outer_height_right)}_layout_offset_subnodes(e){for(var t=0,i=e.length,n=i,o=null,s=0,a=null,r=0,d=null;n--;)a=(o=e[n])._data.layout,null==d&&(d=o.parent._data),s=this._layout_offset_subnodes(o.children),o.expanded||(s=0,this.set_visible(o.children,!1)),s=Math.max(o._data.view.height,s),o.children.length>1&&(s+=this.opts.cousin_space),a.outer_height=s,a.offset_y=r-s/2,a.offset_x=this.opts.hspace*a.direction+d.view.width*(d.layout.direction+a.direction)/2,o.parent.isroot||(a.offset_x+=this.opts.pspace*a.direction),r=r-s-this.opts.vspace,t+=s;i>1&&(t+=this.opts.vspace*(i-1)),n=i;for(var l=t/2;n--;)(o=e[n])._data.layout.offset_y+=l;return t}_layout_offset_subnodes_height(e){for(var t=0,i=e.length,n=i,o=null,s=0,a=null,r=0,d=null;n--;)a=(o=e[n])._data.layout,null==d&&(d=o.parent._data),s=this._layout_offset_subnodes_height(o.children),o.expanded||(s=0),s=Math.max(o._data.view.height,s),o.children.length>1&&(s+=this.opts.cousin_space),a.outer_height=s,a.offset_y=r-s/2,r=r-s-this.opts.vspace,t+=s;i>1&&(t+=this.opts.vspace*(i-1)),n=i;for(var l=t/2;n--;)(o=e[n])._data.layout.offset_y+=l;return t}get_node_offset(e){var t=e._data.layout,i=null;if("_offset_"in t&&this.cache_valid?i=t._offset_:(i={x:-1,y:-1},t._offset_=i),-1==i.x||-1==i.y){var n=t.offset_x,o=t.offset_y;if(!e.isroot){var s=this.get_node_offset(e.parent);n+=s.x,o+=s.y}i.x=n,i.y=o}return i}get_node_point(e){var t=e._data.view,i=this.get_node_offset(e),n={};return n.x=i.x+t.width*(e._data.layout.direction-1)/2,n.y=i.y-t.height/2,n}get_node_point_in(e){return this.get_node_offset(e)}get_node_point_out(e){var t=e._data.layout,i=null;if("_pout_"in t&&this.cache_valid?i=t._pout_:(i={x:-1,y:-1},t._pout_=i),-1==i.x||-1==i.y)if(e.isroot)i.x=0,i.y=0;else{var n=e._data.view,o=this.get_node_offset(e);i.x=o.x+(n.width+this.opts.pspace)*e._data.layout.direction,i.y=o.y}return i}get_expander_point(e){var t=this.get_node_point_out(e),n={};return e._data.layout.direction==i.right?n.x=t.x-this.opts.pspace:n.x=t.x,n.y=t.y-Math.ceil(this.opts.pspace/2),n}get_min_size(){var e=this.jm.mind.nodes,t=null,i=null;for(var n in e)t=e[n],(i=this.get_node_point_out(t)).x>this.bounds.e&&(this.bounds.e=i.x),i.x0){var o=this.jm.mind.root;this.part_layout(o),this.set_visible(o.children,!0)}}collapse_all(){var e,t=this.jm.mind.nodes,i=0;for(var n in t)(e=t[n]).expanded&&!e.isroot&&(e.expanded=!1,i++);if(i>0){var o=this.jm.mind.root;this.part_layout(o),this.set_visible(o.children,!0)}}expand_to_depth(e,t,i){if(!(e<1))for(var n=t||this.jm.mind.root.children,o=i||1,s=n.length,a=null;s--;)a=n[s],othis.maxZoom)return!1;this.actualZoom=e;for(var t=0;te){var i=this.get_view_offset();this.e_panel.scrollLeft=i.x*this.actualZoom-e/2}this.size.h>t&&(this.e_panel.scrollTop=(this.size.h*this.actualZoom-t)/2)}show(e){a.debug("view.show"),this.expand_size(),this._show(),e&&this._center_root()}relayout(){this.expand_size(),this._show()}save_location(e){var t=e._data.view;t._saved_location={x:parseInt(t.element.style.left)-this.e_panel.scrollLeft,y:parseInt(t.element.style.top)-this.e_panel.scrollTop}}restore_location(e){var t=e._data.view;this.e_panel.scrollLeft=parseInt(t.element.style.left)-t._saved_location.x,this.e_panel.scrollTop=parseInt(t.element.style.top)-t._saved_location.y}clear_nodes(){var e=this.jm.mind;if(null!=e){var t=e.nodes,i=null;for(var n in t)(i=t[n])._data.view.element=null,i._data.view.expander=null;this.e_nodes.innerHTML=""}}show_nodes(){var e=this.jm.mind.nodes,t=null,i=null,n=null,o=null,s=null,a="-",d=null,l=this.get_view_offset();for(var h in e)i=(d=(t=e[h])._data.view).element,n=d.expander,this.layout.is_visible(t)?(this.reset_node_custom_style(t),o=this.layout.get_node_point(t),d.abs_x=l.x+o.x,d.abs_y=l.y+o.y,i.style.left=l.x+o.x+"px",i.style.top=l.y+o.y+"px",i.style.display="",i.style.visibility="visible",!t.isroot&&t.children.length>0&&(a=t.expanded?"-":"+",s=this.layout.get_expander_point(t),n.style.left=l.x+s.x+"px",n.style.top=l.y+s.y+"px",n.style.display="",n.style.visibility="visible",r.t(n,a)),t.isroot||0!=t.children.length||(n.style.display="none",n.style.visibility="hidden")):(i.style.display="none",n.style.display="none")}reset_node_custom_style(e){this._reset_node_custom_style(e._data.view.element,e.data)}_reset_node_custom_style(e,t){if("background-color"in t&&(e.style.backgroundColor=t["background-color"]),"foreground-color"in t&&(e.style.color=t["foreground-color"]),"width"in t&&(e.style.width=t.width+"px"),"height"in t&&(e.style.height=t.height+"px"),"font-size"in t&&(e.style.fontSize=t["font-size"]+"px"),"font-weight"in t&&(e.style.fontWeight=t["font-weight"]),"font-style"in t&&(e.style.fontStyle=t["font-style"]),"background-image"in t){var i=t["background-image"];if(i.startsWith("data")&&t.width&&t.height){var n=new Image;n.onload=function(){var t=r.c("canvas");t.width=e.clientWidth,t.height=e.clientHeight;if(t.getContext){t.getContext("2d").drawImage(this,2,2,e.clientWidth,e.clientHeight);var i=t.toDataURL();e.style.backgroundImage="url("+i+")"}},n.src=i}else e.style.backgroundImage="url("+i+")";e.style.backgroundSize="99%","background-rotation"in t&&(e.style.transform="rotate("+t["background-rotation"]+"deg)")}}restore_selected_node_custom_style(e){var t=e._data.view.element,i=e.data;"background-color"in i&&(t.style.backgroundColor=i["background-color"]),"foreground-color"in i&&(t.style.color=i["foreground-color"])}clear_selected_node_custom_style(e){var t=e._data.view.element;t.style.backgroundColor="",t.style.color=""}clear_lines(){this.graph.clear()}show_lines(){this.clear_lines();var e=this.jm.mind.nodes,t=null,i=null,n=null,o=null,s=this.get_view_offset();for(var a in e)(t=e[a]).isroot||"visible"in t._data.layout&&!t._data.layout.visible||(i=this.layout.get_node_point_in(t),n=this.layout.get_node_point_out(t.parent),o=t.data["leading-line-color"],this.graph.draw_line(n,i,s,o))}setup_canvas_draggable(e){if(this.opts.draggable=e,!this._initialized){let e,t,i=!1;this.opts.hide_scrollbars_when_draggable&&(this.e_panel.style="overflow: hidden"),r.on(this.container,"mousedown",(n=>{this.opts.draggable&&(i=!0,e=n.clientX,t=n.clientY)})),r.on(this.container,"mouseup",(()=>{i=!1})),r.on(this.container,"mousemove",(n=>{this.opts.draggable&&i&&(this.e_panel.scrollBy(e-n.clientX,t-n.clientY),e=n.clientX,t=n.clientY)}))}}}class m{constructor(e,t){this.jm=e,this.opts=t,this.mapping=t.mapping,this.handles=t.handles,this._newid=null,this._mapping={}}init(){for(var e in r.on(this.jm.view.e_panel,"keydown",this.handler.bind(this)),this.handles.addchild=this.handle_addchild,this.handles.addbrother=this.handle_addbrother,this.handles.editnode=this.handle_editnode,this.handles.delnode=this.handle_delnode,this.handles.toggle=this.handle_toggle,this.handles.up=this.handle_up,this.handles.down=this.handle_down,this.handles.left=this.handle_left,this.handles.right=this.handle_right,this.mapping)if(this.mapping[e]&&e in this.handles){let t=this.mapping[e];Array.isArray(t)||(t=[t]);for(let i of t)this._mapping[i]=this.handles[e]}"function"==typeof this.opts.id_generator?this._newid=this.opts.id_generator:this._newid=d.uuid.newid}enable_shortcut(){this.opts.enable=!0}disable_shortcut(){this.opts.enable=!1}handler(e){if(9==e.which&&e.preventDefault(),!this.jm.view.is_editing()){var t=e||event;if(!this.opts.enable)return!0;var i=t.keyCode+(t.metaKey<<13)+(t.ctrlKey<<12)+(t.altKey<<11)+(t.shiftKey<<10);i in this._mapping&&this._mapping[i].call(this,this.jm,e)}}handle_addchild(e,t){var i=e.get_selected_node();if(i){var n=this._newid();e.add_node(i,n,"New Node")&&(e.select_node(n),e.begin_edit(n))}}handle_addbrother(e,t){var i=e.get_selected_node();if(i&&!i.isroot){var n=this._newid();e.insert_node_after(i,n,"New Node")&&(e.select_node(n),e.begin_edit(n))}}handle_editnode(e,t){var i=e.get_selected_node();i&&e.begin_edit(i)}handle_delnode(e,t){var i=e.get_selected_node();i&&!i.isroot&&(e.select_node(i.parent),e.remove_node(i))}handle_toggle(e,t){var i=t||event,n=e.get_selected_node();n&&(e.toggle_node(n.id),i.stopPropagation(),i.preventDefault())}handle_up(e,t){var i=t||event,n=e.get_selected_node();if(n){var o=e.find_node_before(n);if(!o){var s=e.find_node_before(n.parent);s&&s.children.length>0&&(o=s.children[s.children.length-1])}o&&e.select_node(o),i.stopPropagation(),i.preventDefault()}}handle_down(e,t){var i=t||event,n=e.get_selected_node();if(n){var o=e.find_node_after(n);if(!o){var s=e.find_node_after(n.parent);s&&s.children.length>0&&(o=s.children[0])}o&&e.select_node(o),i.stopPropagation(),i.preventDefault()}}handle_left(e,t){this._handle_direction(e,t,i.left)}handle_right(e,t){this._handle_direction(e,t,i.right)}_handle_direction(e,t,i){var n=t||event,o=e.get_selected_node(),s=null;if(o){if(o.isroot){for(var a=o.children,r=[],d=0;d0&&(s=r[Math.floor((l-1)/2)])}else s=o.parent;s&&e.select_node(s),n.stopPropagation(),n.preventDefault()}}}const w={plugins:[]};function y(e){if(!e instanceof x)throw new Error("plugin "+e+" is not a supported plugin");w.plugins.push(e)}function b(e){r.w.setTimeout((function(){!function(e){for(var t=w.plugins.length,i=null,n=0;n