(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0c20be"],{4947:function(t,e,s){"use strict";s.r(e);var a=function(){var t=this;t._self._c;return t._m(0)},n=[function(){var t=this,e=t._self._c;return e("div",[e("h1",[t._v("RichText plugin")]),e("blockquote",[e("p",[t._v("v0.4.0+")])]),e("p",[t._v("This plugin provides the ability to edit rich text of nodes, and takes effect after registration.")]),e("p",[t._v("By default, node editing can only uniformly apply styles to all text in the node. This plugin can support rich text editing effects. Currently, it supports bold, italic, underline, strikethrough, font, font size, color, and backgroundColor. Underline and line height are not supported.")]),e("p",[t._v("The principle of this plugin is to use "),e("a",{attrs:{href:"https://github.com/quilljs/quill"}},[t._v("Quill")]),t._v(" editor implements rich text editing, and then uses the edited "),e("code",[t._v("DOM")]),t._v(" node directly as the text data of the node, and embeds the "),e("code",[t._v("DOM")]),t._v(" node through the "),e("code",[t._v("svg")]),t._v(" "),e("code",[t._v("foreignObject")]),t._v(" tag during rendering.")]),e("blockquote",[e("p",[t._v("The following prompts exist in versions prior to v0.5.6:")]),e("p",[t._v("This also caused a problem, that is, the function of exporting as a picture was affected, The original principle of exporting "),e("code",[t._v("svg")]),t._v(" as an image is very simple, Get the "),e("code",[t._v("svg")]),t._v(" string, and then create the "),e("code",[t._v("blob")]),t._v(" data of the "),e("code",[t._v("type=image/svg+xml")]),t._v(" type. Then use the "),e("code",[t._v("URL.createObjectURL")]),t._v(" method to generate the "),e("code",[t._v("data:url")]),t._v(" data. Then create a "),e("code",[t._v("Image")]),t._v(" tag, use the "),e("code",[t._v("data:url")]),t._v(" as the "),e("code",[t._v("src")]),t._v(" of the image, and finally draw the image on the "),e("code",[t._v("canvas")]),t._v(" object for export, However, after testing, when the "),e("code",[t._v("DOM")]),t._v(" node is embedded in the "),e("code",[t._v("svg")]),t._v(", this method of export will cause errors, and after trying many ways, the perfect export effect cannot be achieved, The current method is to traverse the "),e("code",[t._v("foreignObject")]),t._v(" node in "),e("code",[t._v("svg")]),t._v(", using "),e("a",{attrs:{href:"https://github.com/niklasvh/html2canvas"}},[t._v("html2canvas")]),t._v(" Convert the "),e("code",[t._v("DOM")]),t._v(" node in the "),e("code",[t._v("foreignObject")]),t._v(" node into an image and then replace the "),e("code",[t._v("foreignObject")]),t._v(" node. This method can work, but it is very time-consuming. Because the "),e("code",[t._v("html2canvas")]),t._v(" conversion takes a long time, it takes about 2 seconds to convert a node. This leads to the more nodes, the slower the conversion time. Therefore, it is recommended not to use this plugin if you cannot tolerate the long time of export.")])]),e("blockquote",[e("p",[t._v("The version of "),e("code",[t._v("v0.5.7+")]),t._v(" directly uses "),e("code",[t._v("html2canvas")]),t._v(" to convert the entire "),e("code",[t._v("svg")]),t._v(", which is no longer an issue with speed. However, there is currently a bug where the color of the node does not take effect after export.")])]),e("p",[e("code",[t._v("V0.6.13+")]),t._v(" version uses "),e("a",{attrs:{href:"https://github.com/1904labs/dom-to-image-more"}},[t._v("dom-to-image-more")]),t._v(" Replaced 'html2canvas' to address the issue of ineffective color export for nodes.")]),e("blockquote",[e("p",[t._v("The compatibility of dom to image more is relatively poor, and exported images are empty on many browsers, so you can replace them with html2canvas according to your own needs.")])]),e("p",[t._v("After version "),e("code",[t._v("0.6.16+")]),t._v(", third-party libraries such as 'dom-to-image-more' and 'html2canvas' will no longer be used for export, Compatibility and export are no longer issues.")]),e("h2",[t._v("Register")]),e("pre",{staticClass:"hljs"},[e("code",[e("span",{staticClass:"hljs-keyword"},[t._v("import")]),t._v(" MindMap "),e("span",{staticClass:"hljs-keyword"},[t._v("from")]),t._v(" "),e("span",{staticClass:"hljs-string"},[t._v("'simple-mind-map'")]),t._v("\n"),e("span",{staticClass:"hljs-keyword"},[t._v("import")]),t._v(" RichText "),e("span",{staticClass:"hljs-keyword"},[t._v("from")]),t._v(" "),e("span",{staticClass:"hljs-string"},[t._v("'simple-mind-map/src/plugins/RichText.js'")]),t._v("\n"),e("span",{staticClass:"hljs-comment"},[t._v("// import RichText from 'simple-mind-map/src/RichText.js' Use this path for versions below v0.6.0")]),t._v("\n\nMindMap.usePlugin(RichText, opt?)\n")])]),e("p",[t._v("After registration and instantiation of "),e("code",[t._v("MindMap")]),t._v(", the instance can be obtained through "),e("code",[t._v("mindMap.richText")]),t._v(".")]),e("h3",[t._v("Register options")]),e("p",[t._v("The "),e("code",[t._v("opt")]),t._v(" option can pass the following parameters:")]),e("ul",[e("li",[e("code",[t._v("opt.fontFamilyList")])])]),e("p",[t._v("Replace the built-in font list during rich text editing. The built-in list is:")]),e("pre",{staticClass:"hljs"},[e("code",[t._v("[\n "),e("span",{staticClass:"hljs-string"},[t._v("'宋体, SimSun, Songti SC'")]),t._v(",\n "),e("span",{staticClass:"hljs-string"},[t._v("'微软雅黑, Microsoft YaHei'")]),t._v(",\n "),e("span",{staticClass:"hljs-string"},[t._v("'楷体, 楷体_GB2312, SimKai, STKaiti'")]),t._v(",\n "),e("span",{staticClass:"hljs-string"},[t._v("'黑体, SimHei, Heiti SC'")]),t._v(",\n "),e("span",{staticClass:"hljs-string"},[t._v("'隶书, SimLi'")]),t._v(",\n "),e("span",{staticClass:"hljs-string"},[t._v("'andale mono'")]),t._v(",\n "),e("span",{staticClass:"hljs-string"},[t._v("'arial, helvetica, sans-serif'")]),t._v(",\n "),e("span",{staticClass:"hljs-string"},[t._v("'arial black, avant garde'")]),t._v(",\n "),e("span",{staticClass:"hljs-string"},[t._v("'comic sans ms'")]),t._v(",\n "),e("span",{staticClass:"hljs-string"},[t._v("'impact, chicago'")]),t._v(",\n "),e("span",{staticClass:"hljs-string"},[t._v("'times new roman'")]),t._v(",\n "),e("span",{staticClass:"hljs-string"},[t._v("'sans-serif'")]),t._v(",\n "),e("span",{staticClass:"hljs-string"},[t._v("'serif'")]),t._v("\n]\n")])]),e("ul",[e("li",[e("code",[t._v("opt.fontSizeList")])])]),e("p",[t._v("Replace the built-in font size list during rich text editing. The built-in list is:")]),e("pre",{staticClass:"hljs"},[e("code",[t._v("["),e("span",{staticClass:"hljs-number"},[t._v("1")]),t._v(", "),e("span",{staticClass:"hljs-number"},[t._v("2")]),t._v(", "),e("span",{staticClass:"hljs-number"},[t._v("3")]),t._v(", .."),e("span",{staticClass:"hljs-number"},[t._v(".100")]),t._v("]\n")])]),e("h2",[t._v("Method")]),e("h3",[t._v("setNotActiveNodeStyle(node, style)")]),e("blockquote",[e("p",[t._v("v0.8.0+")])]),e("ul",[e("li",[e("code",[t._v("style")]),t._v(":Object, style object.")])]),e("p",[t._v("Set rich text style for inactive nodes.")]),e("h3",[t._v("selectAll()")]),e("p",[t._v("Select All. When the node is being edited, you can select all the text in the node through this method.")]),e("h3",[t._v("focus()")]),e("blockquote",[e("p",[t._v("v0.4.7+")])]),e("p",[t._v("Focus.")]),e("h3",[t._v("formatText(config = {}, clear = false, pure = false)")]),e("ul",[e("li",[e("code",[t._v("config")]),t._v(":Object. The key is the style attribute and the value is the style value. The complete configuration is as follows:")])]),e("pre",{staticClass:"hljs"},[e("code",[t._v("{\n "),e("span",{staticClass:"hljs-attr"},[t._v("font")]),t._v(": "),e("span",{staticClass:"hljs-string"},[t._v("'字体'")]),t._v(",\n "),e("span",{staticClass:"hljs-attr"},[t._v("size")]),t._v(": "),e("span",{staticClass:"hljs-string"},[t._v("'12px,'")]),t._v(" "),e("span",{staticClass:"hljs-comment"},[t._v("// font size")]),t._v("\n "),e("span",{staticClass:"hljs-attr"},[t._v("bold")]),t._v(": "),e("span",{staticClass:"hljs-literal"},[t._v("true")]),t._v(", "),e("span",{staticClass:"hljs-comment"},[t._v("// Bold or not, true/false ")]),t._v("\n "),e("span",{staticClass:"hljs-attr"},[t._v("italic")]),t._v(": "),e("span",{staticClass:"hljs-literal"},[t._v("true")]),t._v(", "),e("span",{staticClass:"hljs-comment"},[t._v("// Italic or not, true/false ")]),t._v("\n "),e("span",{staticClass:"hljs-attr"},[t._v("underline")]),t._v(": "),e("span",{staticClass:"hljs-literal"},[t._v("true")]),t._v(", "),e("span",{staticClass:"hljs-comment"},[t._v("// Show underline or not, true/false ")]),t._v("\n "),e("span",{staticClass:"hljs-attr"},[t._v("strike")]),t._v(": "),e("span",{staticClass:"hljs-literal"},[t._v("true")]),t._v(", "),e("span",{staticClass:"hljs-comment"},[t._v("// Whether to display strikethrough, true/false ")]),t._v("\n "),e("span",{staticClass:"hljs-attr"},[t._v("color")]),t._v(": "),e("span",{staticClass:"hljs-string"},[t._v("'#333'")]),t._v(" "),e("span",{staticClass:"hljs-comment"},[t._v("// color")]),t._v("\n}\n")])]),e("ul",[e("li",[e("p",[e("code",[t._v("clear")]),t._v(":Is clear style")])]),e("li",[e("p",[e("code",[t._v("pure")]),t._v(":v0.9.4+, If set to true, only the text style will be formatted and will not be synchronized to the node's data")])])]),e("p",[t._v("Formats the currently selected text. The style settings will be synchronized to the data of the node.")]),e("h3",[t._v("formatRangeText(range, config = {})")]),e("ul",[e("li",[e("code",[t._v("range")]),t._v(":The range object of "),e("code",[t._v("Quill")]),t._v(", has the following format:")])]),e("pre",{staticClass:"hljs"},[e("code",[t._v("{\n index,\n length\n}\n")])]),e("ul",[e("li",[e("code",[t._v("config")]),t._v(":Same as "),e("code",[t._v("formatText")]),t._v(" method")])]),e("p",[t._v("Formats the text of the specified range.")]),e("h3",[t._v("formatAllText(config = {})")]),e("ul",[e("li",[e("code",[t._v("config")]),t._v(":Same as "),e("code",[t._v("formatText")]),t._v(" method")])]),e("p",[t._v("Formats all text of the current edit node.")]),e("h3",[t._v("removeFormat()")]),e("blockquote",[e("p",[t._v("v0.4.1+")])]),e("p",[t._v("Clears the style of the currently selected text.")]),e("h3",[t._v("normalStyleToRichTextStyle(style)")]),e("p",[t._v("Converts a normal node style object to a rich text style object. Because there are differences between node style attributes and rich text style attributes during non-rich text editing, a conversion operation is required. For example:")]),e("pre",{staticClass:"hljs"},[e("code",[t._v("{\n "),e("span",{staticClass:"hljs-attr"},[t._v("fontFamily")]),t._v(": "),e("span",{staticClass:"hljs-string"},[t._v("'xxx'")]),t._v("\n}\n\n"),e("span",{staticClass:"hljs-comment"},[t._v("// After conversion")]),t._v("\n\n{\n "),e("span",{staticClass:"hljs-attr"},[t._v("font")]),t._v(": "),e("span",{staticClass:"hljs-string"},[t._v("'xxx'")]),t._v("\n}\n")])]),e("h3",[t._v("richTextStyleToNormalStyle(config)")]),e("p",[t._v("Converts rich text style objects to normal node style objects. For example:")]),e("pre",{staticClass:"hljs"},[e("code",[t._v("{\n "),e("span",{staticClass:"hljs-attr"},[t._v("size")]),t._v(": "),e("span",{staticClass:"hljs-string"},[t._v("'16px'")]),t._v("\n}\n\n"),e("span",{staticClass:"hljs-comment"},[t._v("// After conversion")]),t._v("\n\n{\n "),e("span",{staticClass:"hljs-attr"},[t._v("fontSize")]),t._v(": "),e("span",{staticClass:"hljs-number"},[t._v("16")]),t._v("\n}\n")])]),e("h3",[t._v("handleSvgDomElements(svg)")]),e("ul",[e("li",[e("code",[t._v("svg")]),t._v(": "),e("code",[t._v("svg")]),t._v(" node")])]),e("p",[t._v("Convert the "),e("code",[t._v("dom")]),t._v(" element embedded in the "),e("code",[t._v("svg")]),t._v(" into a picture and return a "),e("code",[t._v("Promise")]),t._v(".")]),e("h3",[t._v("transformAllNodesToNormalNode()")]),e("p",[t._v("Convert all nodes to non-rich text nodes.")])])}],o={},i=o,l=s("2877"),v=Object(l["a"])(i,a,n,!1,null,null,null);e["default"]=v.exports}}]);