mind-map/dist/js/chunk-2d217907.js
街角小林 06c4809b7b update
2023-12-07 09:45:22 +08:00

1 line
8.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d217907"],{c6ec:function(e,s,t){"use strict";t.r(s);var a=function(){var e=this;e._self._c;return e._m(0)},n=[function(){var e=this,s=e._self._c;return s("div",[s("h1",[e._v("Export plugin")]),s("p",[e._v("The "),s("code",[e._v("Export")]),e._v(" plugin provides the export function.")]),s("h2",[e._v("Register")]),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"),s("span",{staticClass:"hljs-keyword"},[e._v("import")]),e._v(" Export "),s("span",{staticClass:"hljs-keyword"},[e._v("from")]),e._v(" "),s("span",{staticClass:"hljs-string"},[e._v("'simple-mind-map/src/plugins/Export.js'")]),e._v("\n"),s("span",{staticClass:"hljs-comment"},[e._v("// import Export from 'simple-mind-map/src/Export.js' Use this path for versions below v0.6.0")]),e._v("\n\nMindMap.usePlugin(Export)\n")])]),s("p",[e._v("After registration and instantiation of "),s("code",[e._v("MindMap")]),e._v(", the instance can be obtained through "),s("code",[e._v("mindMap.doExport")]),e._v(".")]),s("h2",[e._v("Methods")]),s("p",[e._v("All exported methods are asynchronous and return an instance of "),s("code",[e._v("Promise")]),e._v(". You can use the "),s("code",[e._v("then")]),e._v(" method to obtain data, or use the "),s("code",[e._v("async await")]),e._v(" function to obtain:")]),s("pre",{staticClass:"hljs"},[s("code",[e._v("mindMap.doExport.png().then("),s("span",{staticClass:"hljs-function"},[e._v("("),s("span",{staticClass:"hljs-params"},[e._v("data")]),e._v(") =>")]),e._v(" {\n "),s("span",{staticClass:"hljs-comment"},[e._v("// ...")]),e._v("\n})\n\n"),s("span",{staticClass:"hljs-keyword"},[e._v("const")]),e._v(" "),s("span",{staticClass:"hljs-keyword"},[e._v("export")]),e._v(" = "),s("span",{staticClass:"hljs-keyword"},[e._v("async")]),e._v(" () => {\n "),s("span",{staticClass:"hljs-keyword"},[e._v("let")]),e._v(" data = "),s("span",{staticClass:"hljs-keyword"},[e._v("await")]),e._v(" mindMap.doExport.png()\n "),s("span",{staticClass:"hljs-comment"},[e._v("// ...")]),e._v("\n}\n")])]),s("p",[e._v("The returned data is in the format of "),s("code",[e._v("data:URL")]),e._v(". You can create an "),s("code",[e._v("a")]),e._v(" tag to trigger the download:")]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-keyword"},[e._v("let")]),e._v(" a = "),s("span",{staticClass:"hljs-built_in"},[e._v("document")]),e._v(".createElement("),s("span",{staticClass:"hljs-string"},[e._v("'a'")]),e._v(")\na.href = "),s("span",{staticClass:"hljs-string"},[e._v("'xxx.png'")]),s("span",{staticClass:"hljs-comment"},[e._v("// .png、.svg、.pdf、.md、.json、.smm")]),e._v("\na.download = "),s("span",{staticClass:"hljs-string"},[e._v("'xxx'")]),e._v("\na.click()\n")])]),s("h3",[e._v("png(name, transparent = false, checkRotate, compress)")]),s("blockquote",[s("p",[e._v("Versions below v0.7.0 are: png(name, transparent = false, rotateWhenWidthLongerThenHeight)")])]),s("ul",[s("li",[s("p",[s("code",[e._v("name")]),e._v(": Name, optional")])]),s("li",[s("p",[s("code",[e._v("transparent")]),e._v(": v0.5.7+, Specify whether the background of the exported image is transparent")])]),s("li",[s("p",[s("code",[e._v("rotateWhenWidthLongerThenHeight")]),e._v(": v0.6.15+, V0.7.0+abandoned, Boolean, false, Automatically rotate 90 degrees when the image has a width to height ratio")])]),s("li",[s("p",[s("code",[e._v("checkRotate")]),e._v(": v0.7.0+, Function, You can pass a function that takes two parameters, the width and height of the image, and returns true or false. True represents that the image needs to be rotated by 90 degrees")])]),s("li",[s("p",[s("code",[e._v("compress")]),e._v("v0.8.1+null | { width, height }, The parameter for compressing images. In some cases, the length and width of the exported image may be very large. If you want to reduce it, you can use this parameter to control it. Only one width or height can be provided, and it will be scaled proportionally")])])]),s("p",[e._v("Exports as "),s("code",[e._v("png")]),e._v(".")]),s("h3",[e._v("svg(name, plusCssText)")]),s("ul",[s("li",[s("p",[s("code",[e._v("name")]),e._v(""),s("code",[e._v("svg")]),e._v(" title")])]),s("li",[s("p",[s("code",[e._v("plusCssText")]),e._v("v0.4.0+, v0.6.16+This parameter has been removed and instead passed in through the "),s("code",[e._v("resetCss")]),e._v(" configuration during instantiation, When node rich text editing is enabled and "),s("code",[e._v("domToImage")]),e._v(" passes "),s("code",[e._v("false")]),e._v(", additional "),s("code",[e._v("css")]),e._v(" styles can be added. If there is a "),s("code",[e._v("dom")]),e._v(" node in "),s("code",[e._v("svg")]),e._v(", you can set some styles for the node through this parameter, such as:")])])]),s("pre",{staticClass:"hljs"},[s("code",[e._v("svg(\n "),s("span",{staticClass:"hljs-string"},[e._v("''")]),e._v(", \n "),s("span",{staticClass:"hljs-literal"},[e._v("false")]),e._v(", \n "),s("span",{staticClass:"hljs-string"},[e._v("`* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }`")]),e._v("\n)\n")])]),s("p",[e._v("Exports as "),s("code",[e._v("svg")]),e._v(".")]),s("h3",[e._v("pdf(name, useMultiPageExport, maxImageWidth)")]),s("blockquote",[s("p",[e._v("v0.2.1+")])]),s("ul",[s("li",[s("p",[s("code",[e._v("name")]),e._v("File name")])]),s("li",[s("p",[s("code",[e._v("useMultiPageExport")]),e._v(": v0.6.15+, Boolean, false, Whether to export multiple pages, default to single page")])]),s("li",[s("p",[s("code",[e._v("maxImageWidth")]),e._v("v0.8.1+null | NumberThe default is twice the width of A4 paper, which is a parameter for compressing images. In some cases, the length and width of the image may be very large, resulting in a very large PDF volume. Therefore, if you want to reduce the volume, you can use this parameter to control the maximum width of the image")])])]),s("p",[e._v("Export as "),s("code",[e._v("pdf")]),e._v(". Unlike other export methods, this method does not return data and directly triggers the download.")]),s("blockquote",[s("p",[e._v("After v0.6.0, an additional ExportPDF plugin needs to be registered")])]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-keyword"},[e._v("import")]),e._v(" ExportPDF "),s("span",{staticClass:"hljs-keyword"},[e._v("from")]),e._v(" "),s("span",{staticClass:"hljs-string"},[e._v("'simple-mind-map/src/plugins/ExportPDF.js'")]),e._v("\nMindMap.usePlugin(ExportPDF)\n")])]),s("h3",[e._v("json(name, withConfig)")]),s("p",[s("code",[e._v("name")]),e._v("It is temporarily useless, just pass an empty string")]),s("p",[s("code",[e._v("withConfig``Boolean")]),e._v(", default "),s("code",[e._v("true")]),e._v(", Whether the data contains configuration, otherwise it is pure mind map node data")]),s("p",[e._v("Return "),s("code",[e._v("json")]),e._v(" data.")]),s("h3",[e._v("md()")]),s("blockquote",[s("p",[e._v("v0.4.7+")])]),s("p",[e._v("Export as "),s("code",[e._v("markdown")]),e._v(" file.")]),s("h3",[e._v("getSvgData()")]),s("p",[e._v("Gets "),s("code",[e._v("svg")]),e._v(" data, an async method that returns an object:")]),s("pre",{staticClass:"hljs"},[s("code",[e._v("{\n node "),s("span",{staticClass:"hljs-comment"},[e._v("// svg node")]),e._v("\n str "),s("span",{staticClass:"hljs-comment"},[e._v("// svg string")]),e._v("\n}\n")])]),s("h3",[e._v("xmind(name)")]),s("blockquote",[s("p",[e._v("v0.6.6+, an additional ExportXMind plugin needs to be registered")])]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-keyword"},[e._v("import")]),e._v(" ExportXMind "),s("span",{staticClass:"hljs-keyword"},[e._v("from")]),e._v(" "),s("span",{staticClass:"hljs-string"},[e._v("'simple-mind-map/src/plugins/ExportXMind.js'")]),e._v("\nMindMap.usePlugin(ExportXMind)\n")])]),s("p",[e._v("Export as an "),s("code",[e._v("xmind")]),e._v(" file type, asynchronous method, returns a "),s("code",[e._v("Promise")]),e._v(" instance, and the returned data is the "),s("code",[e._v("data:url")]),e._v(" data of a "),s("code",[e._v("zip")]),e._v(" compressed package, which can be directly downloaded.")])])}],o={},i=o,r=t("2877"),v=Object(r["a"])(i,a,n,!1,null,null,null);s["default"]=v.exports}}]);