New:Automatic line wrapping function is added to node text.
Fix: 1.Fix the problem of deletion exceptions if there are root nodes in the batch deleted nodes. 2.Fix the problem that high node height will overlap with other nodes in the case of bottom edge style.
diff --git a/web/src/pages/Doc/en/constructor/index.md b/web/src/pages/Doc/en/constructor/index.md
index 719b321c..cab290fd 100644
--- a/web/src/pages/Doc/en/constructor/index.md
+++ b/web/src/pages/Doc/en/constructor/index.md
@@ -82,14 +82,23 @@ mindMap.setTheme('Theme name')
For all configurations of theme, please refer to [Default Topic](https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/src/themes/default.js). The `defineTheme`method will merge the configuration you passed in with the default configuration. Most of the themes do not need custom many parts. For a typical customized theme configuration, please refer to [blueSky](https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/src/themes/blueSky.js).
-### usePlugin(plugin)
+### usePlugin(plugin, opt = {})
> v0.3.0+
+- `opt`:v0.4.0+,Plugin options. If a plugin supports custom options, it can be passed in through this parameter.
+
If you need to use some non-core functions, such as mini map, watermark, etc, you can register plugin through this method. Can be called in chain.
Note: The plugin needs to be registered before instantiating `MindMap`.
+### hasPlugin(plugin)
+
+> v0.4.0+
+
+Get whether a plugin is registered, The index of the plugin in the registered plugin list is returned, If it is `-1`, it means that the plugin is not registered.
+
+
## Static props
### pluginList
@@ -177,6 +186,8 @@ Listen to an event. Event list:
| scale | Zoom event | scale (zoom ratio) |
| node_img_dblclick(v0.2.15+) | Node image double-click event | this (node instance), e (event object) |
| node_tree_render_end(v0.2.16+) | Node tree render end event | |
+| rich_text_selection_change(v0.4.0+) | Available when the `RichText` plugin is registered. Triggered when the text selection area changes when the node is edited | hasRange(Whether there is a selection)、rectInfo(Size and location information of the selected area)、formatInfo(Text formatting information of the selected area) |
+| transforming-dom-to-images(v0.4.0+) | Available when the `RichText` plugin is registered. When there is a `DOM` node in `svg`, the `DOM` node will be converted to an image when exporting to an image. This event will be triggered during the conversion process. You can use this event to prompt the user about the node to which you are currently converting | index(Index of the node currently converted to)、len(Total number of nodes to be converted) |
### emit(event, ...args)
@@ -324,4 +335,16 @@ map).
> v0.1.5+
Convert the coordinates of the browser's visible window to coordinates relative
-to the canvas.
\ No newline at end of file
+to the canvas.
+
+### addPlugin(plugin, opt)
+
+> v0.4.0+
+
+Register plugin, Use `MindMap.usePlugin` to register plugin only before instantiation, The registered plugin will not take effect after instantiation, So if you want to register the plugin after instantiation, you can use the `addPlugin` method of the instance.
+
+### removePlugin(plugin)
+
+> v0.4.0+
+
+Remove registered plugin, Plugins registered through the `usePlugin` or `addPlugin` methods can be removed.
\ No newline at end of file
diff --git a/web/src/pages/Doc/en/constructor/index.vue b/web/src/pages/Doc/en/constructor/index.vue
index e66acf0c..37cf5c16 100644
--- a/web/src/pages/Doc/en/constructor/index.vue
+++ b/web/src/pages/Doc/en/constructor/index.vue
@@ -214,12 +214,20 @@ MindMap.defineTheme('Theme name', {})
mindMap.setTheme('Theme name')
For all configurations of theme, please refer to Default Topic. The defineThememethod will merge the configuration you passed in with the default configuration. Most of the themes do not need custom many parts. For a typical customized theme configuration, please refer to blueSky.
-
usePlugin(plugin)
+
usePlugin(plugin, opt = {})
v0.3.0+
+
+
opt:v0.4.0+,Plugin options. If a plugin supports custom options, it can be passed in through this parameter.
+
If you need to use some non-core functions, such as mini map, watermark, etc, you can register plugin through this method. Can be called in chain.
Note: The plugin needs to be registered before instantiating MindMap.
+
hasPlugin(plugin)
+
+
v0.4.0+
+
+
Get whether a plugin is registered, The index of the plugin in the registered plugin list is returned, If it is -1, it means that the plugin is not registered.
Static props
pluginList
@@ -398,6 +406,16 @@ poor performance and should be used sparingly.
Node tree render end event
+
+
rich_text_selection_change(v0.4.0+)
+
Available when the RichText plugin is registered. Triggered when the text selection area changes when the node is edited
+
hasRange(Whether there is a selection)、rectInfo(Size and location information of the selected area)、formatInfo(Text formatting information of the selected area)
+
+
+
transforming-dom-to-images(v0.4.0+)
+
Available when the RichText plugin is registered. When there is a DOM node in svg, the DOM node will be converted to an image when exporting to an image. This event will be triggered during the conversion process. You can use this event to prompt the user about the node to which you are currently converting
+
index(Index of the node currently converted to)、len(Total number of nodes to be converted)
+
emit(event, ...args)
@@ -641,6 +659,16 @@ map).
Convert the coordinates of the browser's visible window to coordinates relative
to the canvas.
+
addPlugin(plugin, opt)
+
+
v0.4.0+
+
+
Register plugin, Use MindMap.usePlugin to register plugin only before instantiation, The registered plugin will not take effect after instantiation, So if you want to register the plugin after instantiation, you can use the addPlugin method of the instance.
+
removePlugin(plugin)
+
+
v0.4.0+
+
+
Remove registered plugin, Plugins registered through the usePlugin or addPlugin methods can be removed.
diff --git a/web/src/pages/Doc/en/doExport/index.md b/web/src/pages/Doc/en/doExport/index.md
index a2593306..c7bd5fec 100644
--- a/web/src/pages/Doc/en/doExport/index.md
+++ b/web/src/pages/Doc/en/doExport/index.md
@@ -20,19 +20,40 @@ After registration and instantiation of `MindMap`, the instance can be obtained
Exports as `png`, an async method that returns image data, `data:url` data which
can be downloaded or displayed.
-### svg()
+### svg(name, domToImage = false, plusCssText)
+
+- `name`:`svg` title
+
+- `domToImage`:v0.4.0+, When node rich text editing is enabled, you can use this parameter to specify whether to convert the `dom` node in the `svg` into a picture
+
+- `plusCssText`:v0.4.0+, When node rich text editing is enabled and `domToImage` passes `false`, additional `css` styles can be added. If there is a `dom` node in `svg`, you can set some styles for the node through this parameter, such as:
+
+```js
+svg(
+ '',
+ false,
+ `* {
+ margin: 0;
+ padding: 0;
+ box-sizing: border-box;
+ }`
+)
+```
Exports as `svg`, an async method that returns `svg` data, `data:url` data which
can be downloaded or displayed.
-### getSvgData()
+### getSvgData(domToImage)
+
+- `domToImage`:v0.4.0+, If node rich text is enabled, you can use this parameter to specify whether to convert the `DOM` node embedded in `svg` into a picture.
Gets `svg` data, an async method that returns an object:
```js
{
node; // svg object
- str; // svg string
+ str; // svg string, if rich text editing is enabled and domToImage is set to true, the dom node in the svg character returned by this value will be converted into the form of an image
+ nodeWithDomToImg// v0.4.0+,The svg object after the DOM node is converted to an image has a value only when rich text editing is enabled and domToImage is set to true, otherwise null
}
```
diff --git a/web/src/pages/Doc/en/doExport/index.vue b/web/src/pages/Doc/en/doExport/index.vue
index 21e8be1f..708023ea 100644
--- a/web/src/pages/Doc/en/doExport/index.vue
+++ b/web/src/pages/Doc/en/doExport/index.vue
@@ -13,14 +13,39 @@ MindMap.usePlugin(Export)
png()
Exports as png, an async method that returns image data, data:url data which
can be downloaded or displayed.
-
svg()
+
svg(name, domToImage = false, plusCssText)
+
+
+
name:svg title
+
+
+
domToImage:v0.4.0+, When node rich text editing is enabled, you can use this parameter to specify whether to convert the dom node in the svg into a picture
+
+
+
plusCssText:v0.4.0+, When node rich text editing is enabled and domToImage passes false, additional css styles can be added. If there is a dom node in svg, you can set some styles for the node through this parameter, such as:
Exports as svg, an async method that returns svg data, data:url data which
can be downloaded or displayed.
-
getSvgData()
+
getSvgData(domToImage)
+
+
domToImage:v0.4.0+, If node rich text is enabled, you can use this parameter to specify whether to convert the DOM node embedded in svg into a picture.
+
Gets svg data, an async method that returns an object:
{
node; // svg object
- str; // svg string
+ str; // svg string, if rich text editing is enabled and domToImage is set to true, the dom node in the svg character returned by this value will be converted into the form of an image
+ nodeWithDomToImg// v0.4.0+,The svg object after the DOM node is converted to an image has a value only when rich text editing is enabled and domToImage is set to true, otherwise null
}
simple-mind-map is a simple and powerful web mind map library, not dependent on any specific framework.
Features
-
-
+
+
organizational structure diagrams, and directory organization diagrams
-
-
-
+
+
+
summaries
-
-
-
-
-
-
-
+
+
+
+
+
+
+
Table of Contents
1.simple-mind-map
@@ -27,16 +27,16 @@ frameworks such as Vue and React, or without a framework.
This is an online mind map built using the simple-mind-map library and based
on Vue2.x and ElementUI. Features include:
-
+
images, icons, hyperlinks, notes, tags, and summaries
-
+
outline, theme selection, and structure selection
-
+
storage by default, but it also supports creating, opening, and editing
local files on the computer directly
-
+
and organizing layout
-
+
between edit and read-only modes, zooming in and out, and switching to
full screen, support mini map
diff --git a/web/src/pages/Doc/en/richText/index.md b/web/src/pages/Doc/en/richText/index.md
new file mode 100644
index 00000000..e9a9b43f
--- /dev/null
+++ b/web/src/pages/Doc/en/richText/index.md
@@ -0,0 +1,147 @@
+# RichText plugin
+
+> v0.4.0+
+
+> Note: This is a testing nature and imperfect function
+
+This plugin provides the ability to edit rich text of nodes, and takes effect after registration.
+
+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, and color. Underline and line height are not supported.
+
+The principle of this plugin is to use [Quill](https://github.com/quilljs/quill) editor implements rich text editing, and then uses the edited `DOM` node directly as the text data of the node, and embeds the `DOM` node through the `svg` `foreignObject` tag during rendering.
+
+This also caused a problem, that is, the function of exporting as a picture was affected, The original principle of exporting `svg` as an image is very simple, Get the `svg` string, and then create the `blob` data of the `type=image/svg+xml` type. Then use the `URL.createObjectURL` method to generate the `data:url` data. Then create a `Image` tag, use the `data:url` as the `src` of the image, and finally draw the image on the `canvas` object for export, However, after testing, when the `DOM` node is embedded in the `svg`, 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 `foreignObject` node in `svg`, using [html2canvas](https://github.com/niklasvh/html2canvas) Convert the `DOM` node in the `foreignObject` node into an image and then replace the `foreignObject` node. This method can work, but it is very time-consuming. Because the `html2canvas` 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.
+
+If you have a better way, please leave a message.
+
+## Register
+
+```js
+import MindMap from 'simple-mind-map'
+import RichText from 'simple-mind-map/src/RichText.js'
+
+MindMap.usePlugin(RichText, opt?)
+```
+
+After registration and instantiation of `MindMap`, the instance can be obtained through `mindMap.richText`.
+
+### Register options
+
+The `opt` option can pass the following parameters:
+
+- `opt.fontFamilyList`
+
+Replace the built-in font list during rich text editing. The built-in list is:
+
+```js
+[
+ '宋体, SimSun, Songti SC',
+ '微软雅黑, Microsoft YaHei',
+ '楷体, 楷体_GB2312, SimKai, STKaiti',
+ '黑体, SimHei, Heiti SC',
+ '隶书, SimLi',
+ 'andale mono',
+ 'arial, helvetica, sans-serif',
+ 'arial black, avant garde',
+ 'comic sans ms',
+ 'impact, chicago',
+ 'times new roman',
+ 'sans-serif',
+ 'serif'
+]
+```
+
+- `opt.fontSizeList`
+
+Replace the built-in font size list during rich text editing. The built-in list is:
+
+```js
+[1, 2, 3, ...100]
+```
+
+## Method
+
+### selectAll()
+
+Select All. When the node is being edited, you can select all the text in the node through this method.
+
+### formatText(config = {})
+
+- `config`:Object. The key is the style attribute and the value is the style value. The complete configuration is as follows:
+
+```js
+{
+ font: '字体',
+ size: '12px,' // font size
+ bold: true, // Bold or not, true/false
+ italic: true, // Italic or not, true/false
+ underline: true, // Show underline or not, true/false
+ strike: true, // Whether to display strikethrough, true/false
+ color: '#333' // color
+}
+```
+
+Formats the currently selected text.
+
+### formatRangeText(range, config = {})
+
+- `range`:The range object of `Quill`, has the following format:
+
+```js
+{
+ index,
+ length
+}
+```
+
+- `config`:Same as `formatText` method
+
+Formats the text of the specified range.
+
+### formatAllText(config = {})
+
+- `config`:Same as `formatText` method
+
+Formats all text of the current edit node.
+
+### normalStyleToRichTextStyle(style)
+
+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:
+
+```js
+{
+ fontFamily: 'xxx'
+}
+
+// After conversion
+
+{
+ font: 'xxx'
+}
+```
+
+### richTextStyleToNormalStyle(config)
+
+Converts rich text style objects to normal node style objects. For example:
+
+```js
+{
+ size: '16px'
+}
+
+// After conversion
+
+{
+ fontSize: 16
+}
+```
+
+### handleSvgDomElements(svg)
+
+- `svg`: `svg` node
+
+Convert the `dom` element embedded in the `svg` into a picture and return a `Promise`.
+
+### transformAllNodesToNormalNode()
+
+Convert all nodes to non-rich text nodes.
\ No newline at end of file
diff --git a/web/src/pages/Doc/en/richText/index.vue b/web/src/pages/Doc/en/richText/index.vue
new file mode 100644
index 00000000..92415426
--- /dev/null
+++ b/web/src/pages/Doc/en/richText/index.vue
@@ -0,0 +1,129 @@
+
+
+
RichText plugin
+
+
v0.4.0+
+
+
+
Note: This is a testing nature and imperfect function
+
+
This plugin provides the ability to edit rich text of nodes, and takes effect after registration.
+
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, and color. Underline and line height are not supported.
+
The principle of this plugin is to use Quill editor implements rich text editing, and then uses the edited DOM node directly as the text data of the node, and embeds the DOM node through the svgforeignObject tag during rendering.
+
This also caused a problem, that is, the function of exporting as a picture was affected, The original principle of exporting svg as an image is very simple, Get the svg string, and then create the blob data of the type=image/svg+xml type. Then use the URL.createObjectURL method to generate the data:url data. Then create a Image tag, use the data:url as the src of the image, and finally draw the image on the canvas object for export, However, after testing, when the DOM node is embedded in the svg, 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 foreignObject node in svg, using html2canvas Convert the DOM node in the foreignObject node into an image and then replace the foreignObject node. This method can work, but it is very time-consuming. Because the html2canvas 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.
Replace the built-in font size list during rich text editing. The built-in list is:
+
[1, 2, 3, ...100]
+
+
Method
+
selectAll()
+
Select All. When the node is being edited, you can select all the text in the node through this method.
+
formatText(config = {})
+
+
config:Object. The key is the style attribute and the value is the style value. The complete configuration is as follows:
+
+
{
+ font: '字体',
+ size: '12px,'// font size
+ bold: true, // Bold or not, true/false
+ italic: true, // Italic or not, true/false
+ underline: true, // Show underline or not, true/false
+ strike: true, // Whether to display strikethrough, true/false
+ color: '#333'// color
+}
+
+
Formats the currently selected text.
+
formatRangeText(range, config = {})
+
+
range:The range object of Quill, has the following format:
+
+
{
+ index,
+ length
+}
+
+
+
config:Same as formatText method
+
+
Formats the text of the specified range.
+
formatAllText(config = {})
+
+
config:Same as formatText method
+
+
Formats all text of the current edit node.
+
normalStyleToRichTextStyle(style)
+
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: