You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1 lines
14 KiB

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d20f68f"],{b407:function(e,s,t){"use strict";t.r(s);var n=function(){var e=this;e._self._c;return e._m(0)},a=[function(){var e=this,s=e._self._c;return s("div",[s("h1",[e._v("Start")]),s("h2",[e._v("Installation")]),s("blockquote",[s("p",[e._v("Things to note before version 0.2.0:")])]),s("pre",{staticClass:"hljs"},[s("code",[e._v("npm i simple-mind-map\n")])]),s("p",[s("code",[e._v("0.2.0")]),e._v(" Notes for previous versions:")]),s("blockquote",[s("p",[e._v("Note: This project is directly published in source code form and has not been packaged. If compilation fails, a Vue CLI-created project can add the following configuration to the vue.config.js file to allow babel-loader to compile this dependency:")]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-built_in"},[e._v("module")]),e._v(".exports = {\n "),s("span",{staticClass:"hljs-attr"},[e._v("transpileDependencies")]),e._v(": ["),s("span",{staticClass:"hljs-string"},[e._v('"simple-mind-map"')]),e._v("],\n};\n")])]),s("p",[e._v("Other projects should modify the packaging configuration as needed.")])]),s("h2",[e._v("Usage")]),s("blockquote",[s("p",[e._v("The "),s("code",[e._v("web")]),e._v(" directory of this repository provides a complete project based on "),s("code",[e._v("Vue2")]),e._v(". If you encounter any doubts about using it, you can refer to the implementation of this project.")])]),s("blockquote",[s("p",[e._v("To learn about its use in other frameworks, you can refer to the following unofficial implementations:")]),s("p",[e._v("1."),s("a",{attrs:{href:"https://github.com/huangyuanyin/hyy-vue3-mindMap"}},[e._v("https://github.com/huangyuanyin/hyy-vue3-mindMap")]),e._v(": A mind map based on Vue3.2+ElementPlus.")])]),s("p",[e._v("Firstly, provide a container element with a width and height not equal to 0:")]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-tag"},[e._v("<"),s("span",{staticClass:"hljs-name"},[e._v("div")]),e._v(" "),s("span",{staticClass:"hljs-attr"},[e._v("id")]),e._v("="),s("span",{staticClass:"hljs-string"},[e._v('"mindMapContainer"')]),e._v(">")]),s("span",{staticClass:"hljs-tag"},[e._v("</"),s("span",{staticClass:"hljs-name"},[e._v("div")]),e._v(">")]),e._v("\n")])]),s("p",[e._v("Also, set the "),s("code",[e._v("CSS")]),e._v(" style again:")]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-selector-id"},[e._v("#mindMapContainer")]),e._v(" * {\n "),s("span",{staticClass:"hljs-attribute"},[e._v("margin")]),e._v(": "),s("span",{staticClass:"hljs-number"},[e._v("0")]),e._v(";\n "),s("span",{staticClass:"hljs-attribute"},[e._v("padding")]),e._v(": "),s("span",{staticClass:"hljs-number"},[e._v("0")]),e._v(";\n}\n")])]),s("p",[e._v("Then introduce the "),s("code",[e._v("simple-mind-map")]),e._v(" library and create an instance:")]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-keyword"},[e._v("import")]),e._v(" MindMap "),s("span",{staticClass:"hljs-keyword"},[e._v("from")]),e._v(" "),s("span",{staticClass:"hljs-string"},[e._v('"simple-mind-map"')]),e._v(";\n\n"),s("span",{staticClass:"hljs-keyword"},[e._v("const")]),e._v(" mindMap = "),s("span",{staticClass:"hljs-keyword"},[e._v("new")]),e._v(" MindMap({\n "),s("span",{staticClass:"hljs-attr"},[e._v("el")]),e._v(": "),s("span",{staticClass:"hljs-built_in"},[e._v("document")]),e._v(".getElementById("),s("span",{staticClass:"hljs-string"},[e._v("'mindMapContainer'")]),e._v("),\n "),s("span",{staticClass:"hljs-attr"},[e._v("data")]),e._v(": {\n "),s("span",{staticClass:"hljs-string"},[e._v('"data"')]),e._v(": {\n "),s("span",{staticClass:"hljs-string"},[e._v('"text"')]),e._v(": "),s("span",{staticClass:"hljs-string"},[e._v('"Root Node"')]),e._v("\n },\n "),s("span",{staticClass:"hljs-string"},[e._v('"children"')]),e._v(": []\n }\n});\n")])]),s("p",[e._v("This will result in a mind map.")]),s("p",[e._v("If you want to implement a complete mind map, you usually need to develop some UI interfaces to achieve more functions through the interfaces provided by the "),s("code",[e._v("simple-mind-map")]),e._v(" library.")]),s("p",[s("code",[e._v("simple-mind-map")]),e._v(" supports rich configurations, events, commands, and some additional plugin extensions. Read the subsequent documentation to learn more.")]),s("p",[e._v("The non-packaged 'ES' module is introduced by default, and only contains core functions, not unregistered plugin content, which can effectively reduce the size. However, you need to configure the "),s("code",[e._v("babel")]),e._v(" compilation "),s("code",[e._v("simple mind-map")]),e._v(" in your project to prevent some newer "),s("code",[e._v("js")]),e._v(" syntax some browsers not supporting it.")]),s("p",[e._v("If you don't want to load all plugins from the beginning and want to load and register plugins asynchronously after instantiation, you can do this:")]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-keyword"},[e._v("import")]),e._v("("),s("span",{staticClass:"hljs-string"},[e._v("'simple-mind-map/src/plugins/Export.js'")]),e._v(").then("),s("span",{staticClass:"hljs-function"},[s("span",{staticClass:"hljs-params"},[e._v("res")]),e._v(" =>")]),e._v(" {\n mindMap.addPlugin(res.default)\n})\n")])]),s("p",[e._v("If you need a file in the format of "),s("code",[e._v("umd")]),e._v(" module, such as "),s("code",[e._v("CDN")]),e._v(" in the browser, Then you can find the "),s("code",[e._v("simpleMindMap.umd.min.js")]),e._v(" file and "),s("code",[e._v("simpleMindMap.css")]),e._v(" file in the "),s("code",[e._v("/simple-mind-map/dist/")]),e._v(" directory, copy it to your project, and then import it into the page:")]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-tag"},[e._v("<"),s("span",{staticClass:"hljs-name"},[e._v("link")]),e._v(" "),s("span",{staticClass:"hljs-attr"},[e._v("rel")]),e._v("="),s("span",{staticClass:"hljs-string"},[e._v('"stylesheet"')]),e._v(" "),s("span",{staticClass:"hljs-attr"},[e._v("href")]),e._v("="),s("span",{staticClass:"hljs-string"},[e._v('"simpleMindMap.css"')]),e._v(">")]),e._v("\n"),s("span",{staticClass:"hljs-tag"},[e._v("<"),s("span",{staticClass:"hljs-name"},[e._v("script")]),e._v(" "),s("span",{staticClass:"hljs-attr"},[e._v("scr")]),e._v("="),s("span",{staticClass:"hljs-string"},[e._v('"simpleMindMap.umd.min.js"')]),e._v(">")]),s("span",{staticClass:"hljs-tag"},[e._v("</"),s("span",{staticClass:"hljs-name"},[e._v("script")]),e._v(">")]),e._v("\n")])]),s("p",[e._v("A global variable "),s("code",[e._v("window.simpleMindMap")]),e._v(" will be created. you can get "),s("code",[e._v("MindMap")]),e._v(" constructor by "),s("code",[e._v("window.simpleMindMap.default")]),e._v(", for more detail info you can log "),s("code",[e._v("window.simpleMindMap")]),e._v(".")]),s("p",[e._v("The disadvantage of this method is that it will contain all the content, including the plugins you have not registered, so the overall volume will be relatively large.")]),s("p",[e._v("(v0.5.4+)If you want to use the "),s("code",[e._v("ES")]),e._v(" module directly on the browser side, you can find the "),s("code",[e._v("simpleMindMap.esm.js")]),e._v(" and "),s("code",[e._v("simpleMindMap.esm.css")]),e._v(" files in the "),s("code",[e._v("/simple-mind-map/dist/")]),e._v(" directory.")]),s("p",[e._v("Online CDN services can also be used, such as:")]),s("pre",{staticClass:"hljs"},[s("code",[e._v("https://unpkg.com/browse/simple-mind-map@0.9.2/dist/\n")])]),s("p",[e._v("You can find all the packaged files for a certain version.")]),s("h2",[e._v("Development")]),s("p",[e._v("If you only use library, you don't need to read this section.")]),s("h3",[e._v("Local Development")]),s("pre",{staticClass:"hljs"},[s("code",[e._v("git "),s("span",{staticClass:"hljs-built_in"},[e._v("clone")]),e._v(" https://github.com/wanglin2/mind-map.git\n"),s("span",{staticClass:"hljs-built_in"},[e._v("cd")]),e._v(" mind-map\n"),s("span",{staticClass:"hljs-built_in"},[e._v("cd")]),e._v(" simple-mind-map\nnpm i\nnpm link\n"),s("span",{staticClass:"hljs-built_in"},[e._v("cd")]),e._v(" ..\n"),s("span",{staticClass:"hljs-built_in"},[e._v("cd")]),e._v(" web\nnpm i\nnpm link simple-mind-map\nnpm run serve\n")])]),s("blockquote",[s("p",[e._v("If there is an installation dependency error, you can try adjusting the node version. The author is using version 14. x.")])]),s("h3",[e._v("Packaging the Library")]),s("p",[e._v("Since version "),s("code",[e._v("0.2.0")]),e._v(", we have added support for packaging the core library simple-mind-map. This uses the same packaging tool as the sample project web.")]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-built_in"},[e._v("cd")]),e._v(" web\nnpm run buildLibrary\n")])]),s("p",[e._v("The packaging entry is "),s("code",[e._v("simple-mind-map/full.js")]),e._v(", which will introduce all plugins by default. If you don't need all plugins, you can modify the file to only introduce the plugins you need, which can reduce the size of the packaged file.")]),s("p",[e._v("The "),s("code",[e._v("package.json")]),e._v(" file in the "),s("code",[e._v("simple-mind-map")]),e._v(" library provides two export fields:")]),s("pre",{staticClass:"hljs"},[s("code",[e._v("{\n "),s("span",{staticClass:"hljs-attr"},[e._v('"module"')]),e._v(": "),s("span",{staticClass:"hljs-string"},[e._v('"index.js"')]),e._v(",\n "),s("span",{staticClass:"hljs-attr"},[e._v('"main"')]),e._v(": "),s("span",{staticClass:"hljs-string"},[e._v('"./dist/simpleMindMap.umd.min.js"')]),e._v("\n}\n")])]),s("p",[e._v("Environments that support the "),s("code",[e._v("module")]),e._v(" field will use "),s("code",[e._v("index.js")]),e._v(" as the entry point, otherwise the packed "),s("code",[e._v("simpleMindMap.umd.min.js")]),e._v(" will be used as the entry point.")]),s("h4",[e._v("Generate TypeScript type files")]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-built_in"},[e._v("cd")]),e._v(" simple-mind-map\nnpm run types\n")])]),s("p",[e._v("You can obtain the type files in the 'simple-mind-map/types/' directory.")]),s("h3",[e._v("Compile the doc")]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-built_in"},[e._v("cd")]),e._v(" web \nnpm run buildDoc\n")])]),s("h3",[e._v("Packaging the Demo")]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-built_in"},[e._v("cd")]),e._v(" web\nnpm run build\n")])]),s("p",[e._v("The "),s("code",[e._v("index.html")]),e._v(" file will be automatically moved to the root directory.")]),s("h2",[e._v("Problems")]),s("h3",[e._v("Error when using in Vite, indicating xml-js dependency error")]),s("p",[e._v("Solution: use the following import method:")]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-keyword"},[e._v("import")]),e._v(" MindMap "),s("span",{staticClass:"hljs-keyword"},[e._v("from")]),e._v(" "),s("span",{staticClass:"hljs-string"},[e._v('"simple-mind-map/dist/simpleMindMap.umd.min"')]),e._v(";\n")])]),s("p",[e._v("The "),s("code",[e._v("simple-mind-map")]),e._v(" package provides the unpacked entry field "),s("code",[e._v("module")]),e._v(", and the "),s("code",[e._v("xml-js")]),e._v(" package dependency needs to import the package in the "),s("code",[e._v("node")]),e._v(" environment. Therefore, it cannot be obtained in "),s("code",[e._v("Vite")]),e._v(" and an error will be reported. Therefore, specify the import of the packed entry, and all relevant packages are packed into the product, so there will be no error.")]),s("p",[e._v("If you need to do further development, that is, you must use the unpacked code, and if you do not need to parse the "),s("code",[e._v("xmind")]),e._v(" file, you can remove the "),s("code",[e._v("xmind")]),e._v(" module. If you need it, you can try using other libraries to parse "),s("code",[e._v("xml")]),e._v(" to "),s("code",[e._v("json")]),e._v(".")]),s("h3",[e._v("Error "),s("code",[e._v("Getting bbox of element \"text\" is not possible: TypeError: Cannot read properties of undefined (reading 'apply')")])]),s("p",[e._v("The reason is that the installed version of "),s("code",[e._v("@svgdotjs/svg.js")]),e._v(" is too high. You can manually reduce it to the version of "),s("code",[e._v("3.0.16")]),e._v(".")]),s("h3",[e._v("TypeError: Cannot read properties of undefined (reading 'prototype') at sax.js:222:46")]),s("p",[e._v("The following configurations can be added to the packaging configuration file:")]),s("pre",{staticClass:"hljs"},[s("code",[e._v("resolve: { "),s("span",{staticClass:"hljs-attr"},[e._v("alias")]),e._v(": { "),s("span",{staticClass:"hljs-attr"},[e._v("stream")]),e._v(": "),s("span",{staticClass:"hljs-string"},[e._v('"stream-browserify"')]),e._v(" } }\n")])]),s("p",[e._v("Different packaging tools may have different specific configurations, with the principle of excluding 'stream' dependencies.")]),s("h3",[e._v("When clicking the [New], [Open], or [Save As] buttons, it will prompt that the browser does not support it or is not using the HTTPS protocol.")]),s("p",[e._v("The browser uses API "),s("a",{attrs:{href:"https://developer.mozilla.org/zh-CN/docs/Web/API/Window/showOpenFilePicker"}},[e._v("window.showOpenFilePicker")]),e._v(" to operate local files on the computer. If it is not supported, either the browser does not support this API or the page is not using the HTTPS protocol, You can press F12, or open the browser console through the right-click menu on the page and enter 'window.showOpenFilePicker' in the 'Console' tab. If it returns 'undefined', it means it is not supported. If it does not return this message and the page still prompts that the browser does not support it or is not using the HTTPS protocol, you can submit an issue or contact the author.")])])}],i={},o=i,l=t("2877"),p=Object(l["a"])(o,n,a,!1,null,null,null);s["default"]=p.exports}}]);