`
let div = document.createElement('div')
div.innerHTML = html
@@ -96,6 +103,7 @@ function createTextNode() {
let textStyle = this.style.getTextFontStyle()
let textArr = this.nodeData.data.text.split(/\n/gim)
let maxWidth = this.mindMap.opt.textAutoWrapWidth
+ let isMultiLine = false
textArr.forEach((item, index) => {
let arr = item.split('')
let lines = []
@@ -113,6 +121,9 @@ function createTextNode() {
if (line.length > 0) {
lines.push(line.join(''))
}
+ if (lines.length > 1) {
+ isMultiLine = true
+ }
textArr[index] = lines.join('\n')
})
textArr = textArr.join('\n').split(/\n/gim)
@@ -127,6 +138,7 @@ function createTextNode() {
height = Math.ceil(height)
g.attr('data-width', width)
g.attr('data-height', height)
+ g.attr('data-ismultiLine', isMultiLine || textArr.length > 1)
return {
node: g,
width,
diff --git a/web/src/lang/en_us.js b/web/src/lang/en_us.js
index 0d1d1c6d..f66a24ea 100644
--- a/web/src/lang/en_us.js
+++ b/web/src/lang/en_us.js
@@ -90,7 +90,7 @@ export default {
pdfFile: 'pdf file',
markdownFile: 'markdown file',
tips: 'tips: .smm and .json file can be import',
- domToImage: 'Whether to convert rich text nodes in svg into pictures',
+ isTransparent: 'Background is transparent',
pngTips: 'tips: Exporting pictures in rich text mode is time-consuming. It is recommended to export to svg format',
svgTips: 'tips: Exporting pictures in rich text mode is time-consuming',
transformingDomToImages: 'Converting nodes: ',
diff --git a/web/src/lang/zh_cn.js b/web/src/lang/zh_cn.js
index 74477611..407866ef 100644
--- a/web/src/lang/zh_cn.js
+++ b/web/src/lang/zh_cn.js
@@ -90,7 +90,7 @@ export default {
pdfFile: 'pdf文件',
markdownFile: 'markdown文件',
tips: 'tips:.smm和.json文件可用于导入',
- domToImage: '是否将svg中富文本节点转换成图片',
+ isTransparent: '背景是否透明',
pngTips: 'tips:富文本模式导出图片非常耗时,建议导出为svg格式',
svgTips: 'tips:富文本模式导出图片非常耗时',
transformingDomToImages: '正在转换节点:',
diff --git a/web/src/pages/Doc/en/changelog/index.md b/web/src/pages/Doc/en/changelog/index.md
index 15b6fa44..2661b738 100644
--- a/web/src/pages/Doc/en/changelog/index.md
+++ b/web/src/pages/Doc/en/changelog/index.md
@@ -1,5 +1,13 @@
# Changelog
+## 0.5.7
+
+Breaking change:In rich text mode, exporting png has been changed to using html2canvas to convert the entire svg, greatly improving the export speed. However, html2canvas has a bug where the text color inline with the dom node in the foreignObject element cannot be recognized. Therefore, the text color of the exported node is fixed. However, compared to the previously unavailable state of the export, it can at least be exported quickly and smoothly.
+
+optimization: Optimize the rich text node editing experience.
+
+New: In rich text mode, importing data, initializing data, and switching theme scene node styles support following theme changes.
+
## 0.5.6
Fix: 1.Fix the issue of node position disorder during fast and multiple renderings in a short period of time. 2.Fix the issue of dragging the canvas while the node is being edited, causing the edit box and node to separate.
diff --git a/web/src/pages/Doc/en/changelog/index.vue b/web/src/pages/Doc/en/changelog/index.vue
index 8fc39958..268c57cf 100644
--- a/web/src/pages/Doc/en/changelog/index.vue
+++ b/web/src/pages/Doc/en/changelog/index.vue
@@ -1,6 +1,10 @@
Changelog
+
0.5.7
+
Breaking change:In rich text mode, exporting png has been changed to using html2canvas to convert the entire svg, greatly improving the export speed. However, html2canvas has a bug where the text color inline with the dom node in the foreignObject element cannot be recognized. Therefore, the text color of the exported node is fixed. However, compared to the previously unavailable state of the export, it can at least be exported quickly and smoothly.
+
optimization: Optimize the rich text node editing experience.
+
New: In rich text mode, importing data, initializing data, and switching theme scene node styles support following theme changes.
0.5.6
Fix: 1.Fix the issue of node position disorder during fast and multiple renderings in a short period of time. 2.Fix the issue of dragging the canvas while the node is being edited, causing the edit box and node to separate.
New: 1.Add a maximum history limit.
diff --git a/web/src/pages/Doc/en/constructor/index.md b/web/src/pages/Doc/en/constructor/index.md
index 3a3ea03e..d28693f1 100644
--- a/web/src/pages/Doc/en/constructor/index.md
+++ b/web/src/pages/Doc/en/constructor/index.md
@@ -355,6 +355,18 @@ smm (essentially also json)
`fileName`: (v0.1.6+) the name of the exported file, default is `思维导图` (mind
map).
+If it is exported as `png`, the fourth parameter can be passed:
+
+`transparent`: v0.5.7+, `Boolean`, default is `false`, Specify whether the background of the exported image is transparent
+
+If it is exported as `svg`, the fourth parameter can be passed:
+
+`plusCssText`: Additional `CSS` style. If there is a `dom` node in `svg`, you can pass in some styles specific to the node through this parameter
+
+If it is exported as `json` or `smm`, the fourth parameter can be passed:
+
+`withConfig`: `Boolean`, default is `true`, Specify whether the exported data includes configuration data, otherwise only pure node tree data will be exported
+
### toPos(x, y)
> v0.1.5+
diff --git a/web/src/pages/Doc/en/constructor/index.vue b/web/src/pages/Doc/en/constructor/index.vue
index c5bfb63f..57b8d446 100644
--- a/web/src/pages/Doc/en/constructor/index.vue
+++ b/web/src/pages/Doc/en/constructor/index.vue
@@ -814,6 +814,12 @@ smm (essentially also json)
false
fileName: (v0.1.6+) the name of the exported file, default is 思维导图 (mind
map).
+
If it is exported as png, the fourth parameter can be passed:
+
transparent: v0.5.7+, Boolean, default is false, Specify whether the background of the exported image is transparent
+
If it is exported as svg, the fourth parameter can be passed:
+
plusCssText: Additional CSS style. If there is a dom node in svg, you can pass in some styles specific to the node through this parameter
+
If it is exported as json or smm, the fourth parameter can be passed:
+
withConfig: Boolean, default is true, Specify whether the exported data includes configuration data, otherwise only pure node tree data will be exported
toPos(x, y)
v0.1.5+
diff --git a/web/src/pages/Doc/en/doExport/index.md b/web/src/pages/Doc/en/doExport/index.md
index c7bd5fec..03617a03 100644
--- a/web/src/pages/Doc/en/doExport/index.md
+++ b/web/src/pages/Doc/en/doExport/index.md
@@ -15,17 +15,19 @@ After registration and instantiation of `MindMap`, the instance can be obtained
## Methods
-### png()
+### png(name, transparent = false)
+
+- `name`: Name, optional
+
+- `transparent`: v0.5.7+, Specify whether the background of the exported image is transparent
Exports as `png`, an async method that returns image data, `data:url` data which
can be downloaded or displayed.
-### svg(name, domToImage = false, plusCssText)
+### svg(name, 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
@@ -43,9 +45,7 @@ svg(
Exports as `svg`, an async method that returns `svg` data, `data:url` data which
can be downloaded or displayed.
-### 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.
+### getSvgData()
Gets `svg` data, an async method that returns an object:
@@ -71,4 +71,10 @@ Export as `pdf`
`withConfig``:Boolean`, default `true`, Whether the data contains configuration, otherwise it is pure mind map node data
-Return `json` data, `data:url` type, you can download it yourself
\ No newline at end of file
+Return `json` data, `data:url` type, you can download it yourself
+
+### md()
+
+> v0.4.7+
+
+Export as `markdown` file, Return `json` data, `data:url` type, you can download it yourself
\ No newline at end of file
diff --git a/web/src/pages/Doc/en/doExport/index.vue b/web/src/pages/Doc/en/doExport/index.vue
index 708023ea..3801e299 100644
--- a/web/src/pages/Doc/en/doExport/index.vue
+++ b/web/src/pages/Doc/en/doExport/index.vue
@@ -10,18 +10,23 @@ MindMap.usePlugin(Export)
After registration and instantiation of MindMap, the instance can be obtained through mindMap.doExport.
Methods
-
png()
+
png(name, transparent = false)
+
+
+
name: Name, optional
+
+
+
transparent: v0.5.7+, Specify whether the background of the exported image is transparent
+
+
Exports as png, an async method that returns image data, data:url data which
can be downloaded or displayed.
-
svg(name, domToImage = false, plusCssText)
+
svg(name, 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:
@@ -37,10 +42,7 @@ can be downloaded or displayed.
Exports as svg, an async method that returns svg data, data:url data which
can be downloaded or displayed.
-
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.
-
+
getSvgData()
Gets svg data, an async method that returns an object:
{
node; // svg object
@@ -58,6 +60,11 @@ can be downloaded or displayed.
name:It is temporarily useless, just pass an empty string
withConfig``:Boolean, default true, Whether the data contains configuration, otherwise it is pure mind map node data
Return json data, data:url type, you can download it yourself
+
md()
+
+
v0.4.7+
+
+
Export as markdown file, Return json data, data:url type, you can download it yourself
diff --git a/web/src/pages/Doc/en/richText/index.md b/web/src/pages/Doc/en/richText/index.md
index e087f031..e4f09294 100644
--- a/web/src/pages/Doc/en/richText/index.md
+++ b/web/src/pages/Doc/en/richText/index.md
@@ -10,9 +10,11 @@ By default, node editing can only uniformly apply styles to all text in the node
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.
+> The following prompts exist in versions prior to v0.5.6:
+>
+> 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.
+The version of `v0.5.7+` directly uses `html2canvas` to convert the entire `svg`, 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.
## Register
diff --git a/web/src/pages/Doc/en/richText/index.vue b/web/src/pages/Doc/en/richText/index.vue
index 8b9258f8..43db5c80 100644
--- a/web/src/pages/Doc/en/richText/index.vue
+++ b/web/src/pages/Doc/en/richText/index.vue
@@ -10,8 +10,11 @@
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, color, and backgroundColor. 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.
+
+
The following prompts exist in versions prior to v0.5.6:
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.
-
If you have a better way, please leave a message.
+
+
The version of v0.5.7+ directly uses html2canvas to convert the entire svg, 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.