diff --git a/.gitignore b/.gitignore index bf1c383cb..cf78998bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ node_modules .DS_Store -package-lock.json \ No newline at end of file +dist_electron \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..318ebe89e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2021-2023 The MindMap Team + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 1099dc1e0..03e075a58 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,233 @@ -# web思维导图的简单实现 +
+
+
+
+
+
+ Think
+
+
+
+ 志斌
+
+
+
+ 小土渣的宇宙
+
+
+
+ qp
+
+
+
+ ZXR
+
+
+
+ 花儿朵朵
+
+
+
+ suka
+
+
+
+ Chris
+
+
+
+ 水车
+
+
+
+ 仓鼠
+
+
+
+ 千帆
+
+
+
+ 才镇
+
+
+
+ 小米bbᯤ²ᴳ
+
+
+
+ *棐
+
+
+
+ Luke
+
+
+
+ 布林
+
+
+
+ 南风
+
+
+
+ 蜉蝣撼大叔
+
+
+
+ 乙
+
+
+
+ 敏
+
+
+
+ 沐风牧草
+
+
+
+ 有希
+
+
+
+ 樊笼
+
+
+
+ 达仁科技
+
+
+
+ 小逗比
+
+
+
+ 天清如愿
+
+
+
+ 敬明朗
+
+
+
+ 飞箭
+
+
+
+ 戚永峰
+
+
+
+ moom
+
+
+
+ 张扬
+
+
${ce(e)}
`).join("")},K=(e,t)=>{const n={};return Object.keys(t).forEach(i=>{const a=e[i],o=t[i];if(M(a)===M(o)){if("Object"===M(a)){if(JSON.stringify(a)!==JSON.stringify(o))return void(n[i]=o)}else if(a!==o)return void(n[i]=o)}else n[i]=o}),n},Q=e=>!/^_/.test(e)&&!a["i"].includes(e),J=e=>e.reduce((e,t)=>{const n=e.find(e=>e.type===t.type);return n?t.list.forEach(e=>{const t=n.list.find(t=>t.name===e.name);t?t.icon=e.icon:n.list.push(e)}):e.push({...t}),e},[]),V=e=>{let t=[];return e.forEach(n=>{e.find(e=>e.uid!==n.uid&&e.isAncestor(n))||t.push(n)}),t},X=e=>{const t={},n={};e.forEach(e=>{const i=e.parent;if(i){const a=i.uid;n[a]=i;const o=e.getIndexInBrothers(),r={node:e,index:o};t[a]?t[a].find(e=>e.index===r.index)||t[a].push(r):t[a]=[r]}});const i=[];return Object.keys(t).forEach(e=>{if(t[e].length>1){const a=t[e].map(e=>e.index).sort((e,t)=>e-t);i.push({node:n[e],range:[a[0],a[a.length-1]]})}else i.push({node:t[e][0].node})}),i},q=(e,t,n,i,a,o,r,l)=>t>a&&o>e&&i>r&&l>n,ee=e=>{let t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),n.collapse(),t.removeAllRanges(),t.addRange(n)},te=e=>{let t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)},ne=(e,t={})=>{const n=e=>{e.forEach(e=>{e.data={...e.data,...t},e.children&&e.children.length>0&&n(e.children)})};return n(e),e},ie=(e,t=!1)=>{const n=e=>{e.forEach(e=>{e.data||(e.data={}),(t||_(e.data.uid))&&(e.data.uid=L()),e.children&&e.children.length>0&&n(e.children)})};return n(e),e},ae=e=>e?Array.isArray(e)?e:[e]:[],oe=e=>e.parent?e.parent.nodeData.children.findIndex(t=>t.data.uid===e.uid):0,re=(e,t)=>t.findIndex(t=>t.uid===e.uid),le=e=>{let t=0;for(let a=0;a")]),e._v(" into text wrapped in "),t("code",[e._v("\\n")]),e._v(".")]),t("h4",[e._v("textToNodeRichTextWithWrap(html)")]),t("blockquote",[t("p",[e._v("v0.6.12+")])]),t("p",[e._v("Convert the wrapped text of "),t("code",[e._v("
")]),e._v(" into node rich text content in the form of "),t("code",[e._v("
")]),e._v(".")]),t("h4",[e._v("isMobile()")]),t("blockquote",[t("p",[e._v("v0.6.13+")])]),t("p",[e._v("Determine if it is a mobile environment.")]),t("h4",[e._v("getTopAncestorsFomNodeList(list)")]),t("blockquote",[t("p",[e._v("v0.7.2+")])]),t("ul",[t("li",[t("code",[e._v("list")]),e._v(": Arrray, Node instance list.")])]),t("p",[e._v("Find the top-level node list from the node instance list.")]),t("h4",[e._v("checkTwoRectIsOverlap(minx1, maxx1, miny1, maxy1, minx2, maxx2, miny2, maxy2)")]),t("blockquote",[t("p",[e._v("v0.7.2+")])]),t("p",[e._v("The parameter is the position of two rectangles.")]),t("p",[e._v("Determine if two rectangles overlap.")]),t("h4",[e._v("focusInput(el)")]),t("blockquote",[t("p",[e._v("v0.7.2+")])]),t("ul",[t("li",[t("code",[e._v("el")]),e._v(": DOM nodes, elements that can be focused, typically input box elements.")])]),t("p",[e._v("Focus on the specified input box.")]),t("h4",[e._v("selectAllInput(el)")]),t("blockquote",[t("p",[e._v("v0.7.2+")])]),t("ul",[t("li",[t("code",[e._v("el")]),e._v(": DOM nodes, elements that can be focused, typically input box elements.")])]),t("p",[e._v("Focus and select all specified input boxes.")]),t("h4",[e._v("addDataToAppointNodes(appointNodes, data = {})")]),t("blockquote",[t("p",[e._v("v0.7.2+")])]),t("ul",[t("li",[t("p",[t("code",[e._v("appointNodes")]),e._v(":Node instance list, array type.")])]),t("li",[t("p",[t("code",[e._v("data")]),e._v(":The data to be attached to all nodes in the specified node instance list tree.")])])]),t("p",[e._v("Adding additional data to the specified node list tree data will modify the original data.")]),t("h4",[e._v("createUidForAppointNodes(appointNodes, createNewId)")]),t("blockquote",[t("p",[e._v("v0.7.2+")])]),t("ul",[t("li",[t("p",[t("code",[e._v("appointNodes")]),e._v(":Node instance list, array type.")])]),t("li",[t("p",[t("code",[e._v("createNewId")]),e._v(":v0.7.3-fix.1+, "),t("code",[e._v("Boolean")]),e._v(", default is "),t("code",[e._v("false")]),e._v(", If the node does not have a 'uid', a new 'uid' will be created. If 'true' is passed, a new 'uid' will be created regardless of whether the node data originally exists or not`")])])]),t("p",[e._v("Adding a uid to the specified node list tree data (if the uid does not exist) will modify the original data.")]),t("h4",[e._v("getNodeIndex(node)")]),t("blockquote",[t("p",[e._v("v0.7.2+")])]),t("ul",[t("li",[t("code",[e._v("node")]),e._v(":Node instance.")])]),t("p",[e._v("Gets the position index of a node within its peers.")]),t("h4",[e._v("mergerIconList(list)")]),t("blockquote",[t("p",[e._v("v0.7.2+")])]),t("ul",[t("li",[t("code",[e._v("list")]),e._v(":The array of node icons to be merged into the library.")])]),t("pre",{staticClass:"hljs"},[t("code",[t("span",{staticClass:"hljs-comment"},[e._v("// const data = [")]),e._v("\n"),t("span",{staticClass:"hljs-comment"},[e._v("// { type: 'priority', name: '优先级图标', list: [{ name: '1', icon: 'a' }, { name: 2, icon: 'b' }] },")]),e._v("\n"),t("span",{staticClass:"hljs-comment"},[e._v("// { type: 'priority', name: '优先级图标', list: [{ name: '2', icon: 'c' }, { name: 3, icon: 'd' }] },")]),e._v("\n"),t("span",{staticClass:"hljs-comment"},[e._v("// ];")]),e._v("\n\n"),t("span",{staticClass:"hljs-comment"},[e._v("// mergerIconList(data) result:")]),e._v("\n\n"),t("span",{staticClass:"hljs-comment"},[e._v("// [")]),e._v("\n"),t("span",{staticClass:"hljs-comment"},[e._v("// { type: 'priority', name: '优先级图标', list: [{ name: '1', icon: 'a' }, { name: 2, icon: 'c' }, { name: 3, icon: 'd' }] },")]),e._v("\n"),t("span",{staticClass:"hljs-comment"},[e._v("// ]")]),e._v("\n")])]),t("p",[e._v("Merge icon arrays.")]),t("h4",[e._v("htmlEscape(str)")]),t("blockquote",[t("p",[e._v("v0.7.2+")])]),t("ul",[t("li",[t("code",[e._v("str")]),e._v(":String.")])]),t("p",[e._v("Escape the incoming string, currently escaping the following three characters:")]),t("pre",{staticClass:"hljs"},[t("code",[e._v("& -> &\n< -> <\n> -> >\n")])]),t("h4",[e._v("generateColorByContent(str)")]),t("blockquote",[t("p",[e._v("v0.7.2+")])]),t("ul",[t("li",[t("code",[e._v("str")]),e._v(":String.")])]),t("p",[e._v("Generate colors based on incoming content, and the same content will generate the same color.")]),t("h4",[e._v("isSameObject(a, b)")]),t("blockquote",[t("p",[e._v("v0.7.3+")])]),t("ul",[t("li",[t("code",[e._v("a")]),e._v("、"),t("code",[e._v("b")]),e._v(": Object | Array, Two objects to compare")])]),t("p",[e._v("Determine whether two objects are the same, only handling objects or arrays.")]),t("h4",[e._v("getNodeDataIndex(node)")]),t("blockquote",[t("p",[e._v("v0.8.0+")])]),t("p",[e._v("Gets the position index of a node within its sibling nodes.")]),t("h4",[e._v("getNodeIndexInNodeList(node, nodeList)")]),t("blockquote",[t("p",[e._v("v0.8.0+")])]),t("p",[e._v("Find the index of a node from a list of nodes.")]),t("h4",[e._v("setDataToClipboard(data)")]),t("blockquote",[t("p",[e._v("v0.8.0+")])]),t("ul",[t("li",[t("code",[e._v("data")]),e._v(":Object | Array")])]),t("p",[e._v("Set data to the user clipboard.")]),t("h4",[e._v("getDataFromClipboard()")]),t("blockquote",[t("p",[e._v("v0.8.0+")])]),t("p",[e._v("Reading text and images from the user's clipboard returns:")]),t("pre",{staticClass:"hljs"},[t("code",[e._v("{\n text,\n img\n}\n")])]),t("h4",[e._v("removeFromParentNodeData(node)")]),t("blockquote",[t("p",[e._v("v0.8.0+")])]),t("p",[e._v("Remove the data of a node from its parent node's "),t("code",[e._v("nodeData.children")]),e._v(" list.")]),t("h4",[e._v("checkHasSupSubRelation()")]),t("blockquote",[t("p",[e._v("v0.8.1+")])]),t("p",[e._v("Determine whether there is a hierarchical relationship from the given node instance list.")]),t("h4",[e._v("handleSelfCloseTags(str)")]),t("blockquote",[t("p",[e._v("v0.9.1+")])]),t("ul",[t("li",[t("code",[e._v("str")]),e._v(": html string")])]),t("p",[e._v("Add a closed state to HTML self closing tags, "),t("code",[e._v('
")]),v._v("形式的节点富文本内容转换成"),e("code",[v._v("\\n")]),v._v("换行的文本。")]),e("h4",[v._v("textToNodeRichTextWithWrap(html)")]),e("blockquote",[e("p",[v._v("v0.6.12+")])]),e("p",[v._v("将"),e("code",[v._v("
")]),v._v("换行的文本转换成"),e("code",[v._v("
")]),v._v("形式的节点富文本内容。")]),e("h4",[v._v("isMobile()")]),e("blockquote",[e("p",[v._v("v0.6.13+")])]),e("p",[v._v("判断是否是移动端环境。")]),e("h4",[v._v("getTopAncestorsFomNodeList(list)")]),e("blockquote",[e("p",[v._v("v0.7.2+")])]),e("ul",[e("li",[e("code",[v._v("list")]),v._v(":Arrray,节点实例列表。")])]),e("p",[v._v("从节点实例列表里找出最顶层的节点列表。")]),e("h4",[v._v("checkTwoRectIsOverlap(minx1, maxx1, miny1, maxy1, minx2, maxx2, miny2, maxy2)")]),e("blockquote",[e("p",[v._v("v0.7.2+")])]),e("p",[v._v("参数为两个矩形的位置。")]),e("p",[v._v("判断两个矩形是否重叠。")]),e("h4",[v._v("focusInput(el)")]),e("blockquote",[e("p",[v._v("v0.7.2+")])]),e("ul",[e("li",[e("code",[v._v("el")]),v._v(":DOM节点,可聚焦的元素,一般为输入框元素。")])]),e("p",[v._v("聚焦指定输入框。")]),e("h4",[v._v("selectAllInput(el)")]),e("blockquote",[e("p",[v._v("v0.7.2+")])]),e("ul",[e("li",[e("code",[v._v("el")]),v._v(":DOM节点,可聚焦的元素,一般为输入框元素。")])]),e("p",[v._v("聚焦并全选指定输入框。")]),e("h4",[v._v("addDataToAppointNodes(appointNodes, data = {})")]),e("blockquote",[e("p",[v._v("v0.7.2+")])]),e("ul",[e("li",[e("p",[e("code",[v._v("appointNodes")]),v._v(":节点实例列表,数组类型。")])]),e("li",[e("p",[e("code",[v._v("data")]),v._v(":要附加到指定节点实例列表树中所有节点的数据中的数据。")])])]),e("p",[v._v("给指定的节点列表树数据添加附加数据,会修改原数据。")]),e("h4",[v._v("createUidForAppointNodes(appointNodes, createNewId)")]),e("blockquote",[e("p",[v._v("v0.7.2+")])]),e("ul",[e("li",[e("p",[e("code",[v._v("appointNodes")]),v._v(":节点实例列表,数组类型。")])]),e("li",[e("p",[e("code",[v._v("createNewId")]),v._v(":v0.7.3-fix.1+,"),e("code",[v._v("Boolean")]),v._v(",默认为"),e("code",[v._v("false")]),v._v(",即如果节点不存在"),e("code",[v._v("uid")]),v._v("的话,会创建新的"),e("code",[v._v("uid")]),v._v("。如果传"),e("code",[v._v("true")]),v._v(",那么无论节点数据原来是否存在"),e("code",[v._v("uid")]),v._v(",都会创建新的"),e("code",[v._v("uid")])])])]),e("p",[v._v("给指定的节点列表树数据添加uid(如果uid不存在的话),会修改原数据。")]),e("h4",[v._v("getNodeIndex(node)")]),e("blockquote",[e("p",[v._v("v0.7.2+")])]),e("ul",[e("li",[e("code",[v._v("node")]),v._v(":节点实例。")])]),e("p",[v._v("获取节点在同级里的位置索引。")]),e("h4",[v._v("mergerIconList(list)")]),e("blockquote",[e("p",[v._v("v0.7.2+")])]),e("ul",[e("li",[e("code",[v._v("list")]),v._v(":要合并到库内部的节点图标数组。")])]),e("pre",{staticClass:"hljs"},[e("code",[e("span",{staticClass:"hljs-comment"},[v._v("// const data = [")]),v._v("\n"),e("span",{staticClass:"hljs-comment"},[v._v("// { type: 'priority', name: '优先级图标', list: [{ name: '1', icon: 'a' }, { name: 2, icon: 'b' }] },")]),v._v("\n"),e("span",{staticClass:"hljs-comment"},[v._v("// { type: 'priority', name: '优先级图标', list: [{ name: '2', icon: 'c' }, { name: 3, icon: 'd' }] },")]),v._v("\n"),e("span",{staticClass:"hljs-comment"},[v._v("// ];")]),v._v("\n\n"),e("span",{staticClass:"hljs-comment"},[v._v("// mergerIconList(data) 结果")]),v._v("\n\n"),e("span",{staticClass:"hljs-comment"},[v._v("// [")]),v._v("\n"),e("span",{staticClass:"hljs-comment"},[v._v("// { type: 'priority', name: '优先级图标', list: [{ name: '1', icon: 'a' }, { name: 2, icon: 'c' }, { name: 3, icon: 'd' }] },")]),v._v("\n"),e("span",{staticClass:"hljs-comment"},[v._v("// ]")]),v._v("\n")])]),e("p",[v._v("合并图标数组。")]),e("h4",[v._v("generateColorByContent(str)")]),e("blockquote",[e("p",[v._v("v0.7.2+")])]),e("ul",[e("li",[e("code",[v._v("str")]),v._v(":字符串。")])]),e("p",[v._v("根据传入的内容生成颜色,同样的内容会生成同样的颜色。")]),e("h4",[v._v("htmlEscape(str)")]),e("blockquote",[e("p",[v._v("v0.7.2+")])]),e("ul",[e("li",[e("code",[v._v("str")]),v._v(":字符串。")])]),e("p",[v._v("转义传入的字符串,目前会转义如下三个字符:")]),e("pre",{staticClass:"hljs"},[e("code",[v._v("& -> &\n< -> <\n> -> >\n")])]),e("h4",[v._v("isSameObject(a, b)")]),e("blockquote",[e("p",[v._v("v0.7.3+")])]),e("ul",[e("li",[e("code",[v._v("a")]),v._v("、"),e("code",[v._v("b")]),v._v(":Object | Array, 要进行对比的两个对象")])]),e("p",[v._v("判断两个对象是否相同,只处理对象或数组。")]),e("h4",[v._v("getNodeDataIndex(node)")]),e("blockquote",[e("p",[v._v("v0.8.0+")])]),e("p",[v._v("获取节点在兄弟节点中的位置索引。")]),e("h4",[v._v("getNodeIndexInNodeList(node, nodeList)")]),e("blockquote",[e("p",[v._v("v0.8.0+")])]),e("p",[v._v("从一个节点列表里找出某个节点的索引。")]),e("h4",[v._v("setDataToClipboard(data)")]),e("blockquote",[e("p",[v._v("v0.8.0+")])]),e("ul",[e("li",[e("code",[v._v("data")]),v._v(":Object | Array")])]),e("p",[v._v("将数据设置到用户剪切板中。")]),e("h4",[v._v("getDataFromClipboard()")]),e("blockquote",[e("p",[v._v("v0.8.0+")])]),e("p",[v._v("从用户剪贴板中读取文字和图片,返回:")]),e("pre",{staticClass:"hljs"},[e("code",[v._v("{\n text,\n img\n}\n")])]),e("h4",[v._v("removeFromParentNodeData(node)")]),e("blockquote",[e("p",[v._v("v0.8.0+")])]),e("p",[v._v("从节点的父节点的"),e("code",[v._v("nodeData.children")]),v._v("列表中移除该节点的数据。")]),e("h4",[v._v("checkHasSupSubRelation()")]),e("blockquote",[e("p",[v._v("v0.8.1+")])]),e("p",[v._v("从给定的节点实例列表里判断是否存在上下级关系。")]),e("h4",[v._v("handleSelfCloseTags(str)")]),e("blockquote",[e("p",[v._v("v0.9.1+")])]),e("ul",[e("li",[e("code",[v._v("str")]),v._v(":html字符串")])]),e("p",[v._v("给html自闭合标签添加闭合状态,"),e("code",[v._v('