Compare commits

...

26 Commits
0.9.8 ... 0.9.9

Author SHA1 Message Date
街角小林
d36ff55335 打包0.9.9 2024-03-28 19:47:37 +08:00
街角小林
1ca6a34edf Doc: update 2024-03-28 19:31:49 +08:00
街角小林
c6f8f38648 Demo:导出png、pdf、svg支持设置底部自定义文字 2024-03-28 19:06:10 +08:00
街角小林
614aa1ec30 Feat:addContentToHeader方法支持返回空数据 2024-03-28 18:55:40 +08:00
街角小林
f0c08c7953 Feat:新增导出图片时添加自定义内容的实例化选项 2024-03-28 13:48:08 +08:00
街角小林
b2d5a626c7 Doc: update 2024-03-27 19:16:00 +08:00
街角小林
102cbeb821 Demo:新增源码编辑模式 2024-03-27 19:13:59 +08:00
街角小林
bff683cb5c Doc: update 2024-03-26 14:00:48 +08:00
街角小林
bf9cb99441 Fix:修复第一次创建关联线时,箭头颜色不正确的问题 2024-03-26 13:40:33 +08:00
街角小林
e966e5d57c Demo:update 2024-03-26 12:11:47 +08:00
街角小林
740c898bb1 Feat:实例化及setData方法支持传入空的data,画布空白显示 2024-03-26 12:08:20 +08:00
街角小林
3243e366b0 Doc: update 2024-03-26 10:43:26 +08:00
街角小林
7c6b67e8fb Feat:协同编辑时的人员头像增加鼠标事件 2024-03-25 18:08:59 +08:00
街角小林
3b4195acc5 Feat:节点实例新增getAncestorNodes方法用于获取祖先节点列表 2024-03-25 15:38:19 +08:00
街角小林
8b68b1fc48 Feat:节点中的图标添加鼠标移入和移出事件 2024-03-25 15:13:28 +08:00
街角小林
4614a87bdd Demo:支持配置彩虹线条 2024-03-25 15:03:53 +08:00
街角小林
c87c169dab Feat:新增彩虹线条插件 2024-03-25 15:03:38 +08:00
街角小林
bc6bf2f8f9 Feat:思维导图实例增加增量更新画布数据的方法 2024-03-22 09:30:37 +08:00
街角小林
2e5d17de16 update 2024-03-22 09:03:00 +08:00
街角小林
a12e72117e Doc: update 2024-03-22 08:58:15 +08:00
街角小林
b3d16a60b8 Doc: update 2024-03-21 09:29:08 +08:00
街角小林
2f91ea7199 Feat:增加beforeShortcutRun实例化选项用于拦截快捷键操作 2024-03-13 15:31:50 +08:00
街角小林
1085473463 Feat:支持insert键插入下级节点 2024-03-13 15:17:35 +08:00
街角小林
4c7dafe94e Doc: update 2024-03-13 15:10:17 +08:00
街角小林
f52e39eb16 打包demo 2024-03-12 18:01:10 +08:00
街角小林
27d3e977db 更新项目依赖 2024-03-12 18:00:58 +08:00
101 changed files with 7990 additions and 4577 deletions

View File

@@ -11,19 +11,17 @@
本项目包含两部分:
1.一个 js 思维导图库,不依赖任何框架,可以使用它来快速完成 Web 思维导图产品的开发。
1.一个 js 思维导图库,不依赖任何框架,可以使用它来快速完成 Web 思维导图产品的开发。
开发文档:[https://wanglin2.github.io/mind-map/#/doc/zh/](https://wanglin2.github.io/mind-map/#/doc/zh/)。
2.一个 Web 思维导图基于思维导图库、Vue2.x、ElementUI 开发,可以操作电脑本地文件,所以你可以直接把它当做一个在线版思维导图应用使用,如果觉得 github 的响应速度慢,你也可以部署到你的服务器上
2.一个 Web 思维导图基于思维导图库、Vue2.x、ElementUI 开发,可以操作电脑本地文件,可以当做一个在线版思维导图应用使用,也可以部署和二次开发
在线地址:[https://wanglin2.github.io/mind-map/](https://wanglin2.github.io/mind-map/)。
外也提供了客户端可供下载使用,支持`Windows``Mac``Linux`,下载地址:
外也提供了客户端可供下载使用,支持`Windows``Mac``Linux`,下载地址:
Github[releases](https://github.com/wanglin2/mind-map/releases)。
百度云盘:[地址](https://pan.baidu.com/s/1huasEbKsGNH2Af68dvWiOg?pwd=3bp3)。
Github[releases](https://github.com/wanglin2/mind-map/releases)。百度云盘:[地址](https://pan.baidu.com/s/1huasEbKsGNH2Af68dvWiOg?pwd=3bp3)。
> 客户端版本会落后于在线版本,尝试最新功能请优先使用在线版。
@@ -86,9 +84,7 @@ const mindMap = new MindMap({
# License
[MIT](./LICENSE)
保留`mind-map`版权声明的情况下可随意商用。
[MIT](./LICENSE)。保留`mind-map`版权声明的情况下可随意商用。
# 微信交流群
@@ -104,8 +100,6 @@ const mindMap = new MindMap({
开源不易,如果本项目有帮助到你的话,可以考虑请作者喝杯咖啡~
> 厚椰乳一盒 + 纯牛奶半盒 + 冰块 + 咖啡液 = 生椰拿铁 yyds
> 推荐使用支付宝,微信获取不到头像。转账请备注【思维导图】。
<p>
@@ -298,4 +292,28 @@ const mindMap = new MindMap({
<img src="./web/src/assets/avatar/pluvet.jpg" style="width: 50px;height: 50px;" />
<span>pluvet</span>
</span>
<span>
<img src="./web/src/assets/avatar/皇登攀.jpg" style="width: 50px;height: 50px;" />
<span>皇登攀</span>
</span>
<span>
<img src="./web/src/assets/avatar/风格.jpg" style="width: 50px;height: 50px;" />
<span>风格</span>
</span>
<span>
<img src="./web/src/assets/avatar/default.png" style="width: 50px;height: 50px;" />
<span>SR</span>
</span>
<span>
<img src="./web/src/assets/avatar/逆水行舟.jpg" style="width: 50px;height: 50px;" />
<span>逆水行舟</span>
</span>
<span>
<img src="./web/src/assets/avatar/default.png" style="width: 50px;height: 50px;" />
<span>LiuJL</span>
</span>
<span>
<img src="./web/src/assets/avatar/L.jpg" style="width: 50px;height: 50px;" />
<span>L</span>
</span>
</p>

2
dist/css/app.css vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
dist/img/L.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
dist/img/皇登攀.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
dist/img/逆水行舟.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
dist/img/风格.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

2
dist/js/app.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
dist/js/chunk-2d0b1be7.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
dist/js/chunk-2d0c213a.js vendored Normal file
View File

@@ -0,0 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0c213a"],{4987:function(s,n,a){"use strict";a.r(n);var i=function(){var s=this;s._self._c;return s._m(0)},t=[function(){var s=this,n=s._self._c;return n("div",[n("h1",[s._v("RainbowLines插件")]),n("blockquote",[n("p",[s._v("v0.9.9+")])]),n("p",[s._v("该插件用于实现彩虹线条。")]),n("p",[s._v("开启彩虹线条及自定义颜色可以通过实例化选项"),n("code",[s._v("rainbowLinesConfig")]),s._v("设置。")]),n("p",[s._v("默认的颜色列表如下:")]),n("pre",{staticClass:"hljs"},[n("code",[s._v("[\n 'rgb(255, 213, 73)',\n 'rgb(255, 136, 126)',\n 'rgb(107, 225, 141)',\n 'rgb(151, 171, 255)',\n 'rgb(129, 220, 242)',\n 'rgb(255, 163, 125)',\n 'rgb(152, 132, 234)'\n]\n")])]),n("h2",[s._v("注册")]),n("pre",{staticClass:"hljs"},[n("code",[n("span",{staticClass:"hljs-keyword"},[s._v("import")]),s._v(" MindMap "),n("span",{staticClass:"hljs-keyword"},[s._v("from")]),s._v(" "),n("span",{staticClass:"hljs-string"},[s._v("'simple-mind-map'")]),s._v("\n"),n("span",{staticClass:"hljs-keyword"},[s._v("import")]),s._v(" RainbowLines "),n("span",{staticClass:"hljs-keyword"},[s._v("from")]),s._v(" "),n("span",{staticClass:"hljs-string"},[s._v("'simple-mind-map/src/plugins/RainbowLines.js'")]),s._v("\nMindMap.usePlugin(RainbowLines)\n")])]),n("p",[s._v("注册完且实例化"),n("code",[s._v("MindMap")]),s._v("后可通过"),n("code",[s._v("mindMap.rainbowLines")]),s._v("获取到该实例。")]),n("h2",[s._v("方法")]),n("h3",[s._v("updateRainLinesConfig(config = {})")]),n("p",[s._v("如果你在通过实例化选项"),n("code",[s._v("rainbowLinesConfig")]),s._v("设置了彩虹线条后想修改,那么可以使用该方法,参数"),n("code",[s._v("config")]),s._v("同"),n("code",[s._v("rainbowLinesConfig")]),s._v("。")]),n("pre",{staticClass:"hljs"},[n("code",[s._v("{\n "),n("span",{staticClass:"hljs-attr"},[s._v("open")]),s._v(": "),n("span",{staticClass:"hljs-literal"},[s._v("false")]),s._v(","),n("span",{staticClass:"hljs-comment"},[s._v("// 是否开启彩虹线条")]),s._v("\n "),n("span",{staticClass:"hljs-attr"},[s._v("colorsList")]),s._v(": []"),n("span",{staticClass:"hljs-comment"},[s._v("// 自定义彩虹线条的颜色列表,如果不设置,会使用默认颜色列表")]),s._v("\n}\n")])]),n("h3",[s._v("getColorsList()")]),n("p",[s._v("获取当前使用的彩虹线条颜色列表。")]),n("h3",[s._v("getNodeColor(node)")]),n("p",[s._v("获取指定的节点实例对应的彩虹线条颜色。")]),n("h3",[s._v("getSecondLayerAncestor(node)")]),n("p",[s._v("获取一个节点实例的第二层级的祖先节点实例。")])])}],v={},_=v,o=a("2877"),e=Object(o["a"])(_,i,t,!1,null,null,null);n["default"]=e.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
dist/js/chunk-2d0dd7d2.js vendored Normal file
View File

@@ -0,0 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0dd7d2"],{8235:function(n,s,t){"use strict";t.r(s);var i=function(){var n=this;n._self._c;return n._m(0)},e=[function(){var n=this,s=n._self._c;return s("div",[s("h1",[n._v("RainbowLines plugin")]),s("blockquote",[s("p",[n._v("v0.9.9+")])]),s("p",[n._v("This plugin is used to implement rainbow lines.")]),s("p",[n._v("Enabling rainbow lines and custom colors can be set through the instantiation option 'rainbowLinesConfig'.")]),s("p",[n._v("The default color list is as follows:")]),s("pre",{staticClass:"hljs"},[s("code",[n._v("[\n 'rgb(255, 213, 73)',\n 'rgb(255, 136, 126)',\n 'rgb(107, 225, 141)',\n 'rgb(151, 171, 255)',\n 'rgb(129, 220, 242)',\n 'rgb(255, 163, 125)',\n 'rgb(152, 132, 234)'\n]\n")])]),s("h2",[n._v("Register")]),s("pre",{staticClass:"hljs"},[s("code",[s("span",{staticClass:"hljs-keyword"},[n._v("import")]),n._v(" MindMap "),s("span",{staticClass:"hljs-keyword"},[n._v("from")]),n._v(" "),s("span",{staticClass:"hljs-string"},[n._v("'simple-mind-map'")]),n._v("\n"),s("span",{staticClass:"hljs-keyword"},[n._v("import")]),n._v(" RainbowLines "),s("span",{staticClass:"hljs-keyword"},[n._v("from")]),n._v(" "),s("span",{staticClass:"hljs-string"},[n._v("'simple-mind-map/src/plugins/RainbowLines.js'")]),n._v("\nMindMap.usePlugin(RainbowLines)\n")])]),s("p",[n._v("After registration and instantiation of "),s("code",[n._v("MindMap")]),n._v(", the instance can be obtained through "),s("code",[n._v("mindMap.rainbowLines")]),n._v(".")]),s("h2",[n._v("Method")]),s("h3",[n._v("updateRainLinesConfig(config = {})")]),s("p",[n._v("If you want to modify the rainbow lines after setting them through the instantiation option 'rainbowLinesConfig', you can use this method, option "),s("code",[n._v("config")]),n._v(" is same with "),s("code",[n._v("rainbowLinesConfig")]),n._v("。")]),s("pre",{staticClass:"hljs"},[s("code",[n._v("{\n "),s("span",{staticClass:"hljs-attr"},[n._v("open")]),n._v(": "),s("span",{staticClass:"hljs-literal"},[n._v("false")]),n._v(","),s("span",{staticClass:"hljs-comment"},[n._v("// Is turn on rainbow lines")]),n._v("\n "),s("span",{staticClass:"hljs-attr"},[n._v("colorsList")]),n._v(": []"),s("span",{staticClass:"hljs-comment"},[n._v("// Customize the color list for rainbow lines. If not set, the default color list will be used")]),n._v("\n}\n")])]),s("h3",[n._v("getColorsList()")]),s("p",[n._v("Get a list of currently used rainbow line colors.")]),s("h3",[n._v("getNodeColor(node)")]),s("p",[n._v("Retrieve the rainbow line color corresponding to the specified node instance.")]),s("h3",[n._v("getSecondLayerAncestor(node)")]),s("p",[n._v("Retrieve the second level ancestor node instance of a node instance.")])])}],o={},a=o,l=t("2877"),r=Object(l["a"])(a,i,e,!1,null,null,null);s["default"]=r.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
dist/js/chunk-4c82605f.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
dist/js/chunk-66b27c16.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

76
dist/js/chunk-cae1ba8a.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1"><link rel="icon" href="dist/logo.ico"><title>思绪思维导图</title><script>// 自定义静态资源的路径
window.externalPublicPath = './dist/'
// 接管应用
window.takeOverApp = false</script><link href="dist/css/chunk-vendors.css?97072371e55f8bd6a3b4" rel="stylesheet"><link href="dist/css/app.css?97072371e55f8bd6a3b4" rel="stylesheet"></head><body><noscript><strong>We're sorry but thoughts doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script>const getDataFromBackend = () => {
window.takeOverApp = false</script><link href="dist/css/chunk-vendors.css?fda56af9523032588417" rel="stylesheet"><link href="dist/css/app.css?fda56af9523032588417" rel="stylesheet"></head><body><noscript><strong>We're sorry but thoughts doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script>const getDataFromBackend = () => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve({
@@ -66,4 +66,4 @@
// 可以通过window.$bus.$on()来监听应用的一些事件
// 实例化页面
window.initApp()
}</script><script src="dist/js/chunk-vendors.js?97072371e55f8bd6a3b4"></script><script src="dist/js/app.js?97072371e55f8bd6a3b4"></script></body></html>
}</script><script src="dist/js/chunk-vendors.js?fda56af9523032588417"></script><script src="dist/js/app.js?fda56af9523032588417"></script></body></html>

View File

@@ -15,6 +15,7 @@ import Search from './src/plugins/Search.js'
import Painter from './src/plugins/Painter.js'
import Scrollbar from './src/plugins/Scrollbar.js'
import Formula from './src/plugins/Formula.js'
import RainbowLines from './src/plugins/RainbowLines.js'
import xmind from './src/parse/xmind.js'
import markdown from './src/parse/markdown.js'
import icons from './src/svg/icons.js'
@@ -28,7 +29,7 @@ MindMap.iconList = icons.nodeIconList
MindMap.constants = constants
MindMap.themes = themes
MindMap.defaultTheme = defaultTheme
MindMap.version = '0.9.8'
MindMap.version = '0.9.9'
MindMap.usePlugin(MiniMap)
.usePlugin(Watermark)
@@ -46,5 +47,6 @@ MindMap.usePlugin(MiniMap)
.usePlugin(Painter)
.usePlugin(Scrollbar)
.usePlugin(Formula)
.usePlugin(RainbowLines)
export default MindMap

View File

@@ -15,7 +15,13 @@ import {
cssContent
} from './src/constants/constant'
import { SVG } from '@svgdotjs/svg.js'
import { simpleDeepClone, getType, getObjectChangedProps } from './src/utils'
import {
simpleDeepClone,
getType,
getObjectChangedProps,
isUndef,
handleGetSvgDataExtraContent
} from './src/utils'
import defaultTheme, {
checkIsNodeSizeIndependenceConfig
} from './src/themes/default'
@@ -94,7 +100,7 @@ class MindMap {
// 初始渲染
this.render(this.opt.fit ? () => this.view.fit() : () => {})
setTimeout(() => {
this.command.addHistory()
if (this.opt.data) this.command.addHistory()
}, 0)
}
@@ -111,6 +117,7 @@ class MindMap {
// 预处理节点数据
handleData(data) {
if (isUndef(data) || Object.keys(data).length <= 0) return null
data = simpleDeepClone(data || {})
// 根节点不能收起
if (data.data && !data.data.expand) {
@@ -316,6 +323,13 @@ class MindMap {
this.command.exec(...args)
}
// 更新画布数据,如果新的数据是在当前画布节点数据基础上增删改查后形成的,那么可以使用该方法来更新画布数据
updateData(data) {
this.renderer.setData(data)
this.render()
this.command.addHistory()
}
// 动态设置思维导图数据,纯节点数据
setData(data) {
data = this.handleData(data)
@@ -401,7 +415,18 @@ class MindMap {
}
// 获取svg数据
getSvgData({ paddingX = 0, paddingY = 0, ignoreWatermark = false } = {}) {
getSvgData({
paddingX = 0,
paddingY = 0,
ignoreWatermark = false,
addContentToHeader,
addContentToFooter
} = {}) {
const { cssTextList, header, headerHeight, footer, footerHeight } =
handleGetSvgDataExtraContent({
addContentToHeader,
addContentToFooter
})
const svg = this.svg
const draw = this.draw
// 保存原始信息
@@ -414,8 +439,9 @@ class MindMap {
// 获取变换后的位置尺寸信息其实是getBoundingClientRect方法的包装方法
const rect = draw.rbox()
// 内边距
const fixHeight = 0
rect.width += paddingX * 2
rect.height += paddingY * 2
rect.height += paddingY * 2 + fixHeight + headerHeight + footerHeight
draw.translate(paddingX, paddingY)
// 将svg设置为实际内容的宽高
svg.size(rect.width, rect.height)
@@ -453,7 +479,21 @@ class MindMap {
this.watermark.isInExport = false
}
// 添加必要的样式
clone.add(SVG(`<style>${cssContent}</style>`))
;[cssContent, ...cssTextList].forEach(s => {
clone.add(SVG(`<style>${s}</style>`))
})
// 附加内容
if (header && headerHeight > 0) {
clone.findOne('.smm-container').translate(0, headerHeight)
header.width(rect.width)
header.y(paddingY)
clone.add(header, 0)
}
if (footer && footerHeight > 0) {
footer.width(rect.width)
footer.y(rect.height - paddingY - footerHeight)
clone.add(footer)
}
// 修正defs里定义的元素的id因为clone时defs里的元素的id会继续递增导致和内容中引用的id对不上
const defs = svg.find('defs')
const defs2 = clone.find('defs')

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "simple-mind-map",
"version": "0.9.8",
"version": "0.9.9",
"description": "一个简单的web在线思维导图",
"authors": [
{
@@ -38,6 +38,7 @@
"quill": "^1.3.6",
"tern": "^0.24.3",
"uuid": "^9.0.0",
"ws": "^7.5.9",
"xml-js": "^1.6.11",
"y-webrtc": "^10.2.5",
"yjs": "^13.6.8"

View File

@@ -288,5 +288,35 @@ export const defaultOpt = {
data: 1.当type=createOrUpdate时代表被创建或被更新的节点数据即将同步到其他客户端所以你可以修改该数据2.当type=delete时代表被删除的节点数据
}
*/
beforeCooperateUpdate: null
beforeCooperateUpdate: null,
// 快捷键操作即将执行前的生命周期函数返回true可以阻止操作执行
// 函数接收两个参数key快捷键、activeNodeList当前激活的节点列表
beforeShortcutRun: null,
// 彩虹线条配置需要先注册RainbowLines插件
rainbowLinesConfig: {
open: false, // 是否开启彩虹线条
colorsList: [] // 自定义彩虹线条的颜色列表,如果不设置,会使用默认颜色列表
/*
[
'rgb(255, 213, 73)',
'rgb(255, 136, 126)',
'rgb(107, 225, 141)',
'rgb(151, 171, 255)',
'rgb(129, 220, 242)',
'rgb(255, 163, 125)',
'rgb(152, 132, 234)'
]
*/
},
// 导出png、svg、pdf时在头部和尾部添加自定义内容
// 可传递一个函数这个函数可以返回null代表不添加内容也可以返回如下数据
/*
{
el,// 要追加的自定义DOM节点样式可内联
cssText,// 可选如果样式不想内联可以传递该值一个css字符串
height: 50// 返回的DOM节点的高度必须传递
}
*/
addContentToHeader: null,
addContentToFooter: null
}

View File

@@ -95,6 +95,7 @@ class Command {
this.history.length > 0 ? this.history[this.history.length - 1] : null
const data = this.getCopyData()
// 此次数据和上次一样则不重复添加
if (lastData === data) return
if (lastData && JSON.stringify(lastData) === JSON.stringify(data)) {
return
}
@@ -158,6 +159,7 @@ class Command {
// 获取渲染树数据副本
getCopyData() {
if (!this.mindMap.renderer.renderTree) return null
return copyRenderTree({}, this.mindMap.renderer.renderTree, true)
}

View File

@@ -67,9 +67,10 @@ export default class KeyCommand {
// 按键事件
onKeydown(e) {
const { enableShortcutOnlyWhenMouseInSvg, beforeShortcutRun } = this.mindMap.opt
if (
this.isPause ||
(this.mindMap.opt.enableShortcutOnlyWhenMouseInSvg && !this.isInSvg)
(enableShortcutOnlyWhenMouseInSvg && !this.isInSvg)
) {
return
}
@@ -80,6 +81,10 @@ export default class KeyCommand {
e.stopPropagation()
e.preventDefault()
}
if (typeof beforeShortcutRun === 'function') {
const isStop = beforeShortcutRun(key, [...this.mindMap.renderer.activeNodeList])
if (isStop) return
}
this.shortcutMap[key].forEach(fn => {
fn()
})

View File

@@ -65,7 +65,7 @@ class Render {
this.mindMap = opt.mindMap
this.themeConfig = this.mindMap.themeConfig
// 渲染树,操作过程中修改的都是这里的数据
this.renderTree = merge({}, this.mindMap.opt.data || {})
this.renderTree = this.mindMap.opt.data ? merge({}, this.mindMap.opt.data) : null
// 是否重新渲染
this.reRender = false
// 是否正在渲染中
@@ -117,7 +117,7 @@ class Render {
// 重新设置思维导图数据
setData(data) {
if (this.mindMap.richText) {
this.renderTree = this.mindMap.richText.handleSetData(data)
this.renderTree = data ? this.mindMap.richText.handleSetData(data) : null
} else {
this.renderTree = data
}
@@ -290,6 +290,10 @@ class Render {
this.mindMap.keyCommand.addShortcut('Tab', () => {
this.mindMap.execCommand('INSERT_CHILD_NODE')
})
// 插入下级节点
this.mindMap.keyCommand.addShortcut('Insert', () => {
this.mindMap.execCommand('INSERT_CHILD_NODE')
})
// 插入同级节点
this.mindMap.keyCommand.addShortcut('Enter', () => {
this.mindMap.execCommand('INSERT_NODE')
@@ -432,6 +436,12 @@ class Render {
if (this.reRender) {
this.clearActiveNodeList()
}
// 如果没有节点数据
if (!this.renderTree) {
this.isRendering = false
this.mindMap.emit('node_tree_render_end')
return
}
// 计算布局
this.layout.doLayout(root => {
// 删除本次渲染时不再需要的节点
@@ -476,6 +486,7 @@ class Render {
// 给当前被收起来的节点数据添加文本复位标志
resetUnExpandNodeStyle() {
if (!this.renderTree) return
walk(this.renderTree, null, node => {
if (!node.data.expand) {
walk(node, null, node2 => {
@@ -965,6 +976,7 @@ class Render {
})
} else {
// 否则遍历整棵树
if (!this.renderTree) return
walk(this.renderTree, null, node => {
const _hasCustomStyles = this._handleRemoveCustomStyles(node.data)
if (_hasCustomStyles) hasCustomStyles = true
@@ -1458,6 +1470,7 @@ class Render {
// 展开所有
expandAllNode() {
if (!this.renderTree) return
walk(
this.renderTree,
null,
@@ -1476,6 +1489,7 @@ class Render {
// 收起所有
unexpandAllNode() {
if (!this.renderTree) return
walk(
this.renderTree,
null,
@@ -1496,6 +1510,7 @@ class Render {
// 展开到指定层级
expandToLevel(level) {
if (!this.renderTree) return
walk(
this.renderTree,
null,
@@ -1767,6 +1782,10 @@ class Render {
// 展开到指定uid的节点
expandToNodeUid(uid, callback = () => {}) {
if (!this.renderTree) {
callback()
return
}
let parentsList = []
const cache = {}
bfsWalk(this.renderTree, (node, parent) => {

View File

@@ -916,6 +916,7 @@ class Node {
childNode.getStyle('lineWidth', true)
const color =
childNode.getSelfInhertStyle('lineColor') ||
this.getRainbowLineColor(childNode) ||
childNode.getStyle('lineColor', true)
const dasharray =
childNode.getSelfInhertStyle('lineDasharray') ||
@@ -932,6 +933,13 @@ class Node {
)
}
// 获取彩虹线条颜色
getRainbowLineColor(node) {
return this.mindMap.rainbowLines
? this.mindMap.rainbowLines.getNodeColor(node)
: ''
}
// 移除连线
removeLine() {
this._lines.forEach(line => {
@@ -1039,6 +1047,17 @@ class Node {
return copyNodeTree({}, this, removeActiveState, removeId)
}
// 获取祖先节点列表
getAncestorNodes() {
const list = []
let parent = this.parent
while (parent) {
list.unshift(parent)
parent = parent.parent
}
return list
}
// 是否存在自定义样式
hasCustomStyle() {
return this.style.hasCustomStyle()

View File

@@ -67,6 +67,15 @@ function updateUserListNode() {
} else {
node = this.createTextAvatar(item)
}
node.on('click', (e) => {
this.mindMap.emit('node_cooperate_avatar_click', item, this, node, e)
})
node.on('mouseenter', (e) => {
this.mindMap.emit('node_cooperate_avatar_mouseenter', item, this, node, e)
})
node.on('mouseleave', (e) => {
this.mindMap.emit('node_cooperate_avatar_mouseleave', item, this, node, e)
})
node.x(index * avatarSize).cy(-avatarSize / 2)
this._userListGroup.add(node)
})

View File

@@ -92,7 +92,13 @@ function createIconNode() {
}
node.size(iconSize, iconSize)
node.on('click', e => {
this.mindMap.emit('node_icon_click', this, item, e)
this.mindMap.emit('node_icon_click', this, item, e, node)
})
node.on('mouseenter', e => {
this.mindMap.emit('node_icon_mouseenter', this, item, e, node)
})
node.on('mouseleave', e => {
this.mindMap.emit('node_icon_mouseleave', this, item, e, node)
})
return {
node,

View File

@@ -339,6 +339,10 @@ class AssociativeLine {
dasharray: [6, 4]
})
.fill({ color: 'none' })
// 箭头
this.markerPath
.stroke({ color: associativeLineColor })
.fill({ color: associativeLineColor })
this.creatingLine.marker('end', this.marker)
}

View File

@@ -120,9 +120,7 @@ class Cooperate {
const res = transformObjectToTreeData(data)
if (!res) return
// 更新思维导图画布
this.mindMap.renderer.setData(res)
this.mindMap.render()
this.mindMap.command.addHistory()
this.mindMap.updateData(res)
}
// 当前思维导图改变后的处理,触发同步

View File

@@ -48,11 +48,13 @@ class Export {
// 获取svg数据
async getSvgData() {
let { exportPaddingX, exportPaddingY, errorHandler, resetCss } =
let { exportPaddingX, exportPaddingY, errorHandler, resetCss, addContentToHeader, addContentToFooter } =
this.mindMap.opt
let { svg, svgHTML } = this.mindMap.getSvgData({
paddingX: exportPaddingX,
paddingY: exportPaddingY
paddingY: exportPaddingY,
addContentToHeader,
addContentToFooter
})
// svg的image标签把图片的url转换成data:url类型否则导出会丢失图片
const task1 = this.createTransformImgTaskList(

View File

@@ -0,0 +1,89 @@
import { walk, getNodeDataIndex } from '../utils/index'
const defaultColorsList = [
'rgb(255, 213, 73)',
'rgb(255, 136, 126)',
'rgb(107, 225, 141)',
'rgb(151, 171, 255)',
'rgb(129, 220, 242)',
'rgb(255, 163, 125)',
'rgb(152, 132, 234)'
]
// 彩虹线条插件
class RainbowLines {
constructor({ mindMap }) {
this.mindMap = mindMap
}
// 更新彩虹线条配置
updateRainLinesConfig(config = {}) {
const newConfig = this.mindMap.opt.rainbowLinesConfig || {}
newConfig.open = !!config.open
newConfig.colorsList = Array.isArray(config.colorsList)
? config.colorsList
: []
// 如果开启彩虹线条,那么先移除所有节点的自定义连线颜色配置
if (this.mindMap.opt.rainbowLinesConfig.open) {
this.removeNodeLineColor()
}
this.mindMap.render()
}
// 删除所有节点的连线颜色
removeNodeLineColor() {
const tree = this.mindMap.renderer.renderTree
if (!tree) return
walk(
tree,
null,
cur => {
delete cur.data.lineColor
},
null,
true
)
this.mindMap.command.addHistory()
}
// 获取一个节点的第二层级的祖先节点
getSecondLayerAncestor(node) {
if (node.layerIndex === 1) {
return node
} else {
let res = null
let parent = node.parent
while (parent) {
if (parent.layerIndex === 1) {
return parent
}
parent = parent.parent
}
return res
}
}
// 获取颜色列表
getColorsList() {
const { rainbowLinesConfig } = this.mindMap.opt
return rainbowLinesConfig &&
Array.isArray(rainbowLinesConfig.colorsList) &&
rainbowLinesConfig.colorsList.length > 0
? rainbowLinesConfig.colorsList
: [...defaultColorsList]
}
// 获取一个节点的彩虹线条颜色
getNodeColor(node) {
const { rainbowLinesConfig } = this.mindMap.opt
if (!rainbowLinesConfig || !rainbowLinesConfig.open) return ''
const ancestor = this.getSecondLayerAncestor(node)
const index = getNodeDataIndex(ancestor)
const colorsList = this.getColorsList()
return colorsList[index % colorsList.length]
}
}
RainbowLines.instanceName = 'rainbowLines'
export default RainbowLines

View File

@@ -641,6 +641,7 @@ class RichText {
// 将所有节点转换成非富文本节点
transformAllNodesToNormalNode() {
if (!this.mindMap.renderer.renderTree) return
walk(
this.mindMap.renderer.renderTree,
null,

View File

@@ -89,6 +89,7 @@ class Search {
const tree = isOnlySearchCurrentRenderNodes
? this.mindMap.renderer.root
: this.mindMap.renderer.renderTree
if (tree) return
bfsWalk(tree, node => {
let { richText, text } = isOnlySearchCurrentRenderNodes
? node.getData()

View File

@@ -4,6 +4,7 @@ import {
selfCloseTagList
} from '../constants/constant'
import MersenneTwister from './mersenneTwister'
import { ForeignObject } from '@svgdotjs/svg.js'
// 深度优先遍历树
export const walk = (
@@ -1315,3 +1316,48 @@ export const getRectRelativePosition = (rect1, rect2) => {
return 'overlap'
}
}
// 处理获取svg内容时添加额外内容
export const handleGetSvgDataExtraContent = ({
addContentToHeader,
addContentToFooter
}) => {
// 追加内容
const cssTextList = []
let header = null
let headerHeight = 0
let footer = null
let footerHeight = 0
const handle = (fn, callback) => {
if (typeof fn === 'function') {
const res = fn()
if (!res) return
const { el, cssText, height } = res
if (el instanceof HTMLElement) {
el.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml')
const foreignObject = new ForeignObject()
foreignObject.height(height)
foreignObject.add(el)
callback(foreignObject, height)
}
if (cssText) {
cssTextList.push(cssText)
}
}
}
handle(addContentToHeader, (foreignObject, height) => {
header = foreignObject
headerHeight = height
})
handle(addContentToFooter, (foreignObject, height) => {
footer = foreignObject
footerHeight = height
})
return {
cssTextList,
header,
headerHeight,
footer,
footerHeight
}
}

8545
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -14,9 +14,11 @@
},
"dependencies": {
"@toast-ui/editor": "^3.1.5",
"codemirror": "^5.65.16",
"core-js": "^3.6.5",
"element-ui": "^2.15.1",
"highlight.js": "^10.7.3",
"katex": "^0.16.9",
"v-viewer": "^1.6.4",
"vue": "^2.6.11",
"vue-i18n": "^8.27.2",

View File

@@ -14,6 +14,7 @@ let mindMapData = null
* @Desc: 克隆思维导图数据,去除激活状态
*/
const copyMindMapTreeData = (tree, root) => {
if (!root) return null
tree.data = simpleDeepClone(root.data)
// tree.data.isActive = false
tree.children = []

BIN
web/src/assets/avatar/L.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -1,8 +1,8 @@
@font-face {
font-family: "iconfont"; /* Project id 2479351 */
src: url('iconfont.woff2?t=1709781789605') format('woff2'),
url('iconfont.woff?t=1709781789605') format('woff'),
url('iconfont.ttf?t=1709781789605') format('truetype');
src: url('iconfont.woff2?t=1711536835850') format('woff2'),
url('iconfont.woff?t=1711536835850') format('woff'),
url('iconfont.ttf?t=1711536835850') format('truetype');
}
.iconfont {
@@ -13,6 +13,22 @@
-moz-osx-font-smoothing: grayscale;
}
.icongeshihua:before {
content: "\e7a3";
}
.iconyuanma:before {
content: "\e658";
}
.icongundongtiao:before {
content: "\e670";
}
.iconxietongwendang:before {
content: "\e60d";
}
.iconTXT:before {
content: "\e6e1";
}

View File

@@ -57,7 +57,7 @@ export const themeMap = {
dark4: require('../assets/img/themes/dark4.jpg'),
cactus: require('../assets/img/themes/cactus.jpg'),
classic6: require('../assets/img/themes/classic6.jpg'),
classic7: require('../assets/img/themes/classic7.jpg'),
classic7: require('../assets/img/themes/classic7.jpg')
}
// 公式列表
@@ -111,3 +111,82 @@ export const supportRootLineKeepSameInCurveLayouts = [
'logicalStructure',
'mindMap'
]
// 彩虹线条配置
export const rainbowLinesOptions = [
{
value: 'close'
},
{
value: 'colors1',
list: [
'rgb(255, 213, 73)',
'rgb(255, 136, 126)',
'rgb(107, 225, 141)',
'rgb(151, 171, 255)',
'rgb(129, 220, 242)',
'rgb(255, 163, 125)',
'rgb(152, 132, 234)'
]
},
{
value: 'colors2',
list: [
'rgb(248, 93, 93)',
'rgb(255, 151, 84)',
'rgb(255, 214, 69)',
'rgb(73, 205, 140)',
'rgb(64, 192, 255)',
'rgb(84, 110, 214)',
'rgb(164, 93, 220)'
]
},
{
value: 'colors3',
list: [
'rgb(140, 240, 231)',
'rgb(74, 210, 255)',
'rgb(65, 168, 243)',
'rgb(49, 128, 205)',
'rgb(188, 226, 132)',
'rgb(113, 215, 123)',
'rgb(120, 191, 109)'
]
},
{
value: 'colors4',
list: [
'rgb(169, 98, 99)',
'rgb(245, 125, 123)',
'rgb(254, 183, 168)',
'rgb(251, 218, 171)',
'rgb(138, 163, 181)',
'rgb(131, 127, 161)',
'rgb(84, 83, 140)'
]
},
{
value: 'colors5',
list: [
'rgb(255, 229, 142)',
'rgb(254, 158, 41)',
'rgb(248, 119, 44)',
'rgb(232, 82, 80)',
'rgb(182, 66, 98)',
'rgb(99, 54, 99)',
'rgb(65, 40, 82)'
]
},
{
value: 'colors6',
list: [
'rgb(171, 227, 209)',
'rgb(107, 201, 196)',
'rgb(55, 170, 169)',
'rgb(18, 135, 131)',
'rgb(74, 139, 166)',
'rgb(75, 105, 150)',
'rgb(57, 75, 133)'
]
}
]

View File

@@ -425,7 +425,7 @@ export const shortcutKeyList = [
icon: 'icondodeparent',
name: '上移一个层级',
value: 'Shift + Tab'
},
}
]
}
]
@@ -582,4 +582,4 @@ export const downTypeList = [
icon: 'iconTXT',
desc: '纯文本文件'
}
]
]

View File

@@ -62,7 +62,9 @@ export default {
isUseHandDrawnLikeStyle: 'Is use hand drawn like style',
rootLineStartPos: 'Root line start pos',
center: 'Center',
right: 'Right'
right: 'Right',
rainbowLines: 'Rainbow lines',
notUseRainbowLines: 'Not use rainbow lines'
},
color: {
moreColor: 'More color'
@@ -128,7 +130,9 @@ export default {
paddingX: 'Padding x',
paddingY: 'Padding y',
useMultiPageExport: 'Export multi page',
defaultFileName: 'Mind map'
defaultFileName: 'Mind map',
addFooterTextPlaceholder: 'For example: From simple-mind-map',
addFooterText: 'Add text at the footer'
},
fullscreen: {
fullscreenShow: 'Full screen show',
@@ -150,7 +154,8 @@ export default {
closeMiniMap: 'Close mini map',
readonly: 'Change to eadonly',
edit: 'Change to edit',
backToRoot: 'Back to root node'
backToRoot: 'Back to root node',
changeSourceCodeEdit: 'Switch to source code editing mode'
},
nodeHyperlink: {
title: 'Link',
@@ -275,7 +280,8 @@ export default {
splitByWrap: 'Is automatically split nodes based on line breaks?',
tip: 'Tip',
yes: 'Yes',
no: 'No'
no: 'No',
exportError: 'Export failed'
},
mouseAction: {
tip1:
@@ -315,5 +321,15 @@ export default {
},
other: {
loading: 'Loading, please wait...'
},
sourceCodeEdit: {
sourceCodeTip: 'It is not recommended to modify the style in rich text mode because it requires synchronous modification of data and HTML structure.',
format: 'Format',
copy: 'Copy',
confirm: 'Complete',
close: 'Close',
formatErrorTip: 'The JSON format is incorrect. Please check and try again',
copyTip: 'Copied to clipboard',
formatTip: 'Format complete'
}
}

View File

@@ -62,7 +62,9 @@ export default {
isUseHandDrawnLikeStyle: '是否开启手绘风格',
rootLineStartPos: '根节点连线起始位置',
center: '中心',
right: '右侧'
right: '右侧',
rainbowLines: '彩虹线条',
notUseRainbowLines: '不使用彩虹线条'
},
color: {
moreColor: '更多颜色'
@@ -126,7 +128,9 @@ export default {
paddingX: '水平内边距',
paddingY: '垂直内边距',
useMultiPageExport: '是否多页导出',
defaultFileName: '思维导图'
defaultFileName: '思维导图',
addFooterText: '底部添加文字',
addFooterTextPlaceholder: '比如来自simple-mind-map'
},
fullscreen: {
fullscreenShow: '全屏查看',
@@ -148,7 +152,8 @@ export default {
closeMiniMap: '关闭小地图',
readonly: '切换为只读模式',
edit: '切换为编辑模式',
backToRoot: '回到根节点'
backToRoot: '回到根节点',
changeSourceCodeEdit: '切换为源码编辑模式'
},
nodeHyperlink: {
title: '超链接',
@@ -271,7 +276,8 @@ export default {
splitByWrap: '是否按换行自动分割节点?',
tip: '提示',
yes: '是',
no: '否'
no: '否',
exportError: '导出失败'
},
mouseAction: {
tip1: '当前:左键拖动画布,右键框选节点',
@@ -309,5 +315,15 @@ export default {
},
other: {
loading: '正在加载,请稍后...'
},
sourceCodeEdit: {
sourceCodeTip: '富文本模式下不建议修改样式因为需要同步修改数据及html结构。',
format: '格式化',
copy: '复制',
confirm: '完成',
close: '关闭',
formatErrorTip: 'JSON格式有误请检查后再试',
copyTip: '已复制到剪贴板',
formatTip: '格式化完成'
}
}

View File

@@ -11,7 +11,7 @@ let langList = [
}
]
let StartList = ['introduction', 'start', 'deploy', 'client', 'translate', 'changelog']
let CourseList = new Array(25).fill(0).map((_, index) => {
let CourseList = new Array(26).fill(0).map((_, index) => {
return 'course' + (index + 1)
})
let APIList = [
@@ -38,6 +38,7 @@ let APIList = [
'scrollbar',
'formula',
'cooperate',
'rainbowLines',
'handDrawnLikeStyle',
'xmind',
'markdown',

View File

@@ -1,5 +1,47 @@
# Changelog
## 0.9.9
Fix:
> 1.Fix the issue of incorrect arrow color when creating association lines for the first time;
New:
> 1.Support inserting child nodes with the insert key;
>
> 2.Add the beforeShortcutRun instantiation option to intercept shortcut key operations;
>
> 3.The method of incrementally updating canvas data by adding root instances, updateData;
>
> 4.Add a rainbow line plugin;
>
> 5.Add mouse in and out events to icons in nodes;
>
> 6.Add the getAncestorNodes method to the node instance to obtain the list of ancestor nodes;
>
> 7.Adding mouse events to personnel avatars during collaborative editing;
>
> 8.Instantiation and setData methods support passing in empty data;
>
> 9.Add an instantiation option for adding custom content when exporting images;
Demo:
> 1.Support configuration of rainbow lines;
>
> 2.Add source code editing mode;
>
> 3.Exporting PNG, PDF, and SVG supports setting custom text at the bottom;
Client:
> 1.Double click the file to open the application without opening the workbench page;
>
> 2.Fix the issue of multiple editing windows opening when repeatedly opening the same file;
>
> 3.Prompt for modifying and deleting files being edited;
## 0.9.8
Fix:

View File

@@ -1,6 +1,35 @@
<template>
<div>
<h1>Changelog</h1>
<h2>0.9.9</h2>
<p>Fix:</p>
<blockquote>
<p>1.Fix the issue of incorrect arrow color when creating association lines for the first time;</p>
</blockquote>
<p>New:</p>
<blockquote>
<p>1.Support inserting child nodes with the insert key;</p>
<p>2.Add the beforeShortcutRun instantiation option to intercept shortcut key operations;</p>
<p>3.The method of incrementally updating canvas data by adding root instances, updateData;</p>
<p>4.Add a rainbow line plugin;</p>
<p>5.Add mouse in and out events to icons in nodes;</p>
<p>6.Add the getAncestorNodes method to the node instance to obtain the list of ancestor nodes;</p>
<p>7.Adding mouse events to personnel avatars during collaborative editing;</p>
<p>8.Instantiation and setData methods support passing in empty data;</p>
<p>9.Add an instantiation option for adding custom content when exporting images;</p>
</blockquote>
<p>Demo:</p>
<blockquote>
<p>1.Support configuration of rainbow lines;</p>
<p>2.Add source code editing mode;</p>
<p>3.Exporting PNG, PDF, and SVG supports setting custom text at the bottom;</p>
</blockquote>
<p>Client:</p>
<blockquote>
<p>1.Double click the file to open the application without opening the workbench page;</p>
<p>2.Fix the issue of multiple editing windows opening when repeatedly opening the same file;</p>
<p>3.Prompt for modifying and deleting files being edited;</p>
</blockquote>
<h2>0.9.8</h2>
<p>Fix:</p>
<blockquote>

View File

@@ -25,7 +25,7 @@ const mindMap = new MindMap({
| Field Name | Type | Default Value | Description | Required |
| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | -------- |
| el | Element | | Container element, must be a DOM element | Yes |
| data | Object | {} | Mind map data, Please refer to the introduction of 【Data structure】 below | |
| data | Object 、null | | Mind map data, Please refer to the introduction of 【Data structure】 below. V0.9.9+supports passing empty objects or null, and the canvas will display blank space | |
| layout | String | logicalStructure | Layout type, options: logicalStructure (logical structure diagram), mindMap (mind map), catalogOrganization (catalog organization diagram), organizationStructure (organization structure diagram)、timelinev0.5.4+, timeline、timeline2v0.5.4+, up down alternating timeline、fishbonev0.5.4+, fishbone diagram | |
| fishboneDegv0.5.4+ | Number | 45 | Set the diagonal angle of the fishbone structure diagram | |
| theme | String | default | Theme, options: default, classic, minions, pinkGrape, mint, gold, vitalityOrange, greenLeaf, dark2, skyGreen, classic2, classic3, classic4(v0.2.0+), classicGreen, classicBlue, blueSky, brainImpairedPink, dark, earthYellow, freshGreen, freshRed, romanticPurple, simpleBlack(v0.5.4+), courseGreen(v0.5.4+), coffee(v0.5.4+), redSpirit(v0.5.4+), blackHumour(v0.5.4+), lateNightOffice(v0.5.4+), blackGold(v0.5.4+)、、avocado(v.5.10-fix.2+)、autumn(v.5.10-fix.2+)、orangeJuice(v.5.10-fix.2+) | |
@@ -114,6 +114,10 @@ const mindMap = new MindMap({
| isOnlySearchCurrentRenderNodesv0.9.8+ | Boolean | false | Is it necessary to only search for the current rendered node, and nodes that have been collapsed will not be searched for | |
| onlyOneEnableActiveNodeOnCooperatev0.9.8+ | Boolean | false | During collaborative editing, the same node cannot be selected by multiple people at the same time | |
| beforeCooperateUpdatev0.9.8+ | Function、null | null | During collaborative editing, node operations are about to be updated to the lifecycle functions of other clients. The function takes an object as a parameter:{ type: 【createOrUpdateCreate or update nodes、deleteDelete node】, list: 【Array type, 1.When type=createOrUpdate, it represents the node data that has been created or updated, which will be synchronized to other clients, so you can modify the data; 2.When type=delete, represents the deleted node data】 } | |
| beforeShortcutRunv0.9.9+ | Function、null | null | The lifecycle function before the shortcut operation is about to be executed, returning true can prevent the operation from executing. The function takes two parameters: keyShortcut key、activeNodeListList of currently activated nodes | |
| rainbowLinesConfigv0.9.9+ | Object | { open: false, colorsList: [] } | Rainbow line configuration requires registering the RainbowLines plugin first. Object type, Structure: { open: false【Is turn on rainbow lines】, colorsList: []【Customize the color list for rainbow lines. If not set, the default color list will be used】 } | |
| addContentToHeaderv0.9.9+ | Function、null | null | Add custom content to the header when exporting PNG, SVG, and PDF. Can pass a function that can return null to indicate no content is added, or it can return an object, For a detailed introduction, please refer to section 【How to add custom content when exporting】 below | |
| addContentToFooterv0.9.9+ | Function、null | null | The basic definition is the same as addContentToHeader, adding custom content at the end | |
### Data structure
@@ -175,6 +179,41 @@ If you want to add custom fields, you can add them to the same level as 'data' a
| type | String | | Values for icon grouping |
| list | Array | | A list of icons under grouping, with each item in the array being an object, `{ name: '', icon: '' }``name`represents the name of the icon, `icon`represents the icon, Can be an `svg` icon, such as `<svg ...><path></path></svg>`, also can be a image `url`, or `base64` icon, such as `data:image/png;base64,...` |
### How to add custom content when exporting
The two instantiation options `addContentToHeader` and `addContentToFooter` can be used to add custom content at the beginning and end when exporting `png``svg``pdf`, The default value is `null`, which means no configuration. A function can be passed and can return `null`, which means no content will be added. If you want to add content, you need to return the following structure:
```
{
el,// Custom DOM node to be added, styles can be inline
cssText,// Optional, if the style does not want to be inlined, you can pass this value as a CSS string
height: 50// The height of the returned DOM node must be passed
}
```
A simple example:
```js
new MindMap({
addContentToFooter: () => {
const el = document.createElement('div')
el.className = 'footer'
el.innerHTML = 'From: simple-mind-map'
const cssText = `
.footer {
width: 100%;
height: 30px;
}
`
return {
el,
cssText,
height: 30
}
}
})
```
## Static methods
### defineTheme(name, config)
@@ -314,6 +353,12 @@ Current Theme Configuration.
## Instance methods
### updateData(data)
> v0.9.9+
Update canvas data. If the new data is formed by adding, deleting, modifying, and querying based on the current canvas node data, this method can be used to update the canvas data. The performance will be better, and not all nodes will be recreated, but rather reused as much as possible.
### clearDraw()
> v0.8.0+
@@ -326,7 +371,7 @@ Clear `lineDraw`、`associativeLineDraw`、`nodeDraw`、`otherDraw` containers.
Destroy mind maps. It will remove registered plugins, remove listening events, and delete all nodes on the canvas.
### getSvgData({ paddingX = 0, paddingY = 0, ignoreWatermark = false })
### getSvgData({ paddingX = 0, paddingY = 0, ignoreWatermark = false, addContentToHeader, addContentToFooter })
> v0.3.0+
@@ -336,6 +381,10 @@ Destroy mind maps. It will remove registered plugins, remove listening events, a
`ignoreWatermark`v0.8.0+, Do not draw watermarks. If you do not need to draw watermarks, you can pass 'true' because drawing watermarks is very slow
`addContentToHeader`v0.9.9+, Function, You can return the custom content to be added to the header, as detailed in the configuration in 【Instantiation options】
`addContentToFooter`v0.9.9+, Function, You can return the custom content to be added to the tail, as detailed in the configuration in 【Instantiation options】
Get the `svg` data and return an object. The detailed structure is as follows:
```js
@@ -419,7 +468,9 @@ Listen to an event. Event list:
| associative_line_clickv0.4.5+ | Triggered when an associated line is clicked | path(Connector node)、clickPath(Invisible click line node)、node(Start node)、toNode(Target node) |
| svg_mouseenterv0.5.1+ | Triggered when the mouse moves into the SVG canvas | eevent object |
| svg_mouseleavev0.5.1+ | Triggered when the mouse moves out of the SVG canvas | eevent object |
| node_icon_clickv0.6.10+ | Triggered when clicking on an icon within a node | thisnode instance、itemClick on the icon name、eevent object |
| node_icon_clickv0.6.10+ | Triggered when clicking on an icon within a node | thisnode instance、itemClick on the icon name、eevent object、node(Icon node, v0.9.9+) |
| node_icon_mouseenterv0.9.9+ | Triggered when the mouse moves into an icon within a node | thisnode instance、itemClick on the icon name、eevent object、node(Icon node) |
| node_icon_mouseleavev0.9.9+ | Triggered when the mouse moves out of the icon within the node | thisnode instance、itemClick on the icon name、eevent object、node(Icon node) |
| view_theme_changev0.6.12+ | Triggered after calling the setTheme method to set the theme | themetheme name |
| set_datav0.7.3+ | Triggered when the setData method is called to dynamically set mind map data | dataNew Mind Map Data |
| resizev0.8.0+ | Triggered after the container size changes, actually when the 'resize' method of the mind map instance is called | |
@@ -428,6 +479,9 @@ Listen to an event. Event list:
| body_click | Click event of document.body | eevent object |
| data_change_detailv0.9.3+ | The detailed changes in rendering tree data will return an array, with each item representing an update point and each item being an object, There is a 'type' attribute that represents the type of detail, Including 'create' (create node), 'update' (update node), 'delete' (delete node), There is a 'data' attribute that represents the current updated node data. If it is of the 'update' type, there will also be an 'oldData' attribute that saves the data of the node before the update | arrDetail data |
| layout_changev0.9.4+ | Triggered when modifying the structure, i.e. when the mindMap.setLayout() method is called | layoutNew layout |
| node_cooperate_avatar_clickv0.9.9+ | Triggered when the mouse clicks on a person's avatar during collaborative editing | userInfo(User info)、 this(Current node instance)、 node(Avatar node)、 e(Event Object) |
| node_cooperate_avatar_mouseenterv0.9.9+ | Triggered when the mouse moves over a person's avatar during collaborative editing | userInfo(User info)、 this(Current node instance)、 node(Avatar node)、 e(Event Object) |
| node_cooperate_avatar_mouseleavev0.9.9+ | Triggered when removing personnel avatars with the mouse during collaborative editing | userInfo(User info)、 this(Current node instance)、 node(Avatar node)、 e(Event Object) |
### emit(event, ...args)
@@ -550,7 +604,7 @@ redo. All commands are as follows:
Dynamic setting of mind map data, pure node data
`data`: mind map structure data
`data`: mind map structure data. V0.9.9+ supports passing empty objects or null, and the canvas will display blank space.
### setFullData(_data_)

View File

@@ -37,9 +37,9 @@
</tr>
<tr>
<td>data</td>
<td>Object</td>
<td>{}</td>
<td>Mind map data, Please refer to the introduction of Data structure below</td>
<td>Object null</td>
<td></td>
<td>Mind map data, Please refer to the introduction of Data structure below. V0.9.9+supports passing empty objects or null, and the canvas will display blank space</td>
<td></td>
</tr>
<tr>
@@ -658,6 +658,34 @@
<td>During collaborative editing, node operations are about to be updated to the lifecycle functions of other clients. The function takes an object as a parameter:{ type: 【createOrUpdateCreate or update nodes、deleteDelete node】, list: 【Array type, 1.When type=createOrUpdate, it represents the node data that has been created or updated, which will be synchronized to other clients, so you can modify the data; 2.When type=delete, represents the deleted node data】 }</td>
<td></td>
</tr>
<tr>
<td>beforeShortcutRunv0.9.9+</td>
<td>Function、null</td>
<td>null</td>
<td>The lifecycle function before the shortcut operation is about to be executed, returning true can prevent the operation from executing. The function takes two parameters: keyShortcut key、activeNodeListList of currently activated nodes</td>
<td></td>
</tr>
<tr>
<td>rainbowLinesConfigv0.9.9+</td>
<td>Object</td>
<td>{ open: false, colorsList: [] }</td>
<td>Rainbow line configuration requires registering the RainbowLines plugin first. Object type, Structure: { open: false【Is turn on rainbow lines】, colorsList: []【Customize the color list for rainbow lines. If not set, the default color list will be used】 }</td>
<td></td>
</tr>
<tr>
<td>addContentToHeaderv0.9.9+</td>
<td>Function、null</td>
<td>null</td>
<td>Add custom content to the header when exporting PNG, SVG, and PDF. Can pass a function that can return null to indicate no content is added, or it can return an object, For a detailed introduction, please refer to section 【How to add custom content when exporting】 below</td>
<td></td>
</tr>
<tr>
<td>addContentToFooterv0.9.9+</td>
<td>Function、null</td>
<td>null</td>
<td>The basic definition is the same as addContentToHeader, adding custom content at the end</td>
<td></td>
</tr>
</tbody>
</table>
<h3>Data structure</h3>
@@ -776,6 +804,34 @@
</tr>
</tbody>
</table>
<h3>How to add custom content when exporting</h3>
<p>The two instantiation options <code>addContentToHeader</code> and <code>addContentToFooter</code> can be used to add custom content at the beginning and end when exporting <code>png</code>、<code>svg</code>、<code>pdf</code>, The default value is <code>null</code>, which means no configuration. A function can be passed and can return <code>null</code>, which means no content will be added. If you want to add content, you need to return the following structure:</p>
<pre class="hljs"><code>{
el,// Custom DOM node to be added, styles can be inline
cssText,// Optional, if the style does not want to be inlined, you can pass this value as a CSS string
height: 50// The height of the returned DOM node must be passed
}
</code></pre>
<p>A simple example:</p>
<pre class="hljs"><code><span class="hljs-keyword">new</span> MindMap({
<span class="hljs-attr">addContentToFooter</span>: <span class="hljs-function">() =&gt;</span> {
<span class="hljs-keyword">const</span> el = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&#x27;div&#x27;</span>)
el.className = <span class="hljs-string">&#x27;footer&#x27;</span>
el.innerHTML = <span class="hljs-string">&#x27;From: simple-mind-map&#x27;</span>
<span class="hljs-keyword">const</span> cssText = <span class="hljs-string">`
.footer {
width: 100%;
height: 30px;
}
`</span>
<span class="hljs-keyword">return</span> {
el,
cssText,
<span class="hljs-attr">height</span>: <span class="hljs-number">30</span>
}
}
})
</code></pre>
<h2>Static methods</h2>
<h3>defineTheme(name, config)</h3>
<blockquote>
@@ -872,6 +928,11 @@ mindMap.setTheme(<span class="hljs-string">&#x27;Theme name&#x27;</span>)
<h3>themeConfig</h3>
<p>Current Theme Configuration.</p>
<h2>Instance methods</h2>
<h3>updateData(data)</h3>
<blockquote>
<p>v0.9.9+</p>
</blockquote>
<p>Update canvas data. If the new data is formed by adding, deleting, modifying, and querying based on the current canvas node data, this method can be used to update the canvas data. The performance will be better, and not all nodes will be recreated, but rather reused as much as possible.</p>
<h3>clearDraw()</h3>
<blockquote>
<p>v0.8.0+</p>
@@ -882,13 +943,15 @@ mindMap.setTheme(<span class="hljs-string">&#x27;Theme name&#x27;</span>)
<p>v0.6.0+</p>
</blockquote>
<p>Destroy mind maps. It will remove registered plugins, remove listening events, and delete all nodes on the canvas.</p>
<h3>getSvgData({ paddingX = 0, paddingY = 0, ignoreWatermark = false })</h3>
<h3>getSvgData({ paddingX = 0, paddingY = 0, ignoreWatermark = false, addContentToHeader, addContentToFooter })</h3>
<blockquote>
<p>v0.3.0+</p>
</blockquote>
<p><code>paddingX</code>: Padding x</p>
<p><code>paddingY</code>: Padding y</p>
<p><code>ignoreWatermark</code>v0.8.0+, Do not draw watermarks. If you do not need to draw watermarks, you can pass 'true' because drawing watermarks is very slow</p>
<p><code>addContentToHeader</code>v0.9.9+, Function, You can return the custom content to be added to the header, as detailed in the configuration in 【Instantiation options】</p>
<p><code>addContentToFooter</code>v0.9.9+, Function, You can return the custom content to be added to the tail, as detailed in the configuration in 【Instantiation options】</p>
<p>Get the <code>svg</code> data and return an object. The detailed structure is as follows:</p>
<pre class="hljs"><code>{
svg, <span class="hljs-comment">// Element, the overall svg element of the mind map graphics, including: svg (canvas container), g (actual mind map group)</span>
@@ -1119,7 +1182,17 @@ poor performance and should be used sparingly.</p>
<tr>
<td>node_icon_clickv0.6.10+</td>
<td>Triggered when clicking on an icon within a node</td>
<td>thisnode instance、itemClick on the icon name、eevent object</td>
<td>thisnode instance、itemClick on the icon name、eevent object、node(Icon node, v0.9.9+)</td>
</tr>
<tr>
<td>node_icon_mouseenterv0.9.9+</td>
<td>Triggered when the mouse moves into an icon within a node</td>
<td>thisnode instance、itemClick on the icon name、eevent object、node(Icon node)</td>
</tr>
<tr>
<td>node_icon_mouseleavev0.9.9+</td>
<td>Triggered when the mouse moves out of the icon within the node</td>
<td>thisnode instance、itemClick on the icon name、eevent object、node(Icon node)</td>
</tr>
<tr>
<td>view_theme_changev0.6.12+</td>
@@ -1161,6 +1234,21 @@ poor performance and should be used sparingly.</p>
<td>Triggered when modifying the structure, i.e. when the mindMap.setLayout() method is called</td>
<td>layoutNew layout</td>
</tr>
<tr>
<td>node_cooperate_avatar_clickv0.9.9+</td>
<td>Triggered when the mouse clicks on a person's avatar during collaborative editing</td>
<td>userInfo(User info) this(Current node instance) node(Avatar node) e(Event Object)</td>
</tr>
<tr>
<td>node_cooperate_avatar_mouseenterv0.9.9+</td>
<td>Triggered when the mouse moves over a person's avatar during collaborative editing</td>
<td>userInfo(User info)、 this(Current node instance)、 node(Avatar node)、 e(Event Object)</td>
</tr>
<tr>
<td>node_cooperate_avatar_mouseleavev0.9.9+</td>
<td>Triggered when removing personnel avatars with the mouse during collaborative editing</td>
<td>userInfo(User info)、 this(Current node instance)、 node(Avatar node)、 e(Event Object)</td>
</tr>
</tbody>
</table>
<h3>emit(event, ...args)</h3>
@@ -1430,7 +1518,7 @@ redo. All commands are as follows:</p>
</table>
<h3>setData(data)</h3>
<p>Dynamic setting of mind map data, pure node data</p>
<p><code>data</code>: mind map structure data</p>
<p><code>data</code>: mind map structure data. V0.9.9+ supports passing empty objects or null, and the canvas will display blank space.</p>
<h3>setFullData(<em>data</em>)</h3>
<blockquote>
<p>v0.2.7+</p>

View File

@@ -327,4 +327,28 @@ Open source is not easy. If this project is helpful to you, you can invite the a
<img src="../../../../assets/avatar/pluvet.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>pluvet</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/皇登攀.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>皇登攀</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/风格.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>风格</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>SR</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/逆水行舟.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>逆水行舟</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>LiuJL</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/L.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>L</p>
</div>
</div>

View File

@@ -8,17 +8,17 @@
</blockquote>
<h2>Features</h2>
<ul>
<li><input type="checkbox" id="checkbox80" checked="true" /><label for="checkbox80">Pluggable architecture, in addition to core functions, other functions are provided as plugins, which can be used as needed to reduce packaging volume</label></li>
<li><input type="checkbox" id="checkbox81" checked="true" /><label for="checkbox81">Support logical structure chart, mind map, Organizational chart, directory organization chart, timeline (horizontal and vertical), fishbone chart and other structures</label></li>
<li><input type="checkbox" id="checkbox82" checked="true" /><label for="checkbox82">Built-in multiple themes, allowing for highly customizable styles, and supporting registration of new themes</label></li>
<li><input type="checkbox" id="checkbox83" checked="true" /><label for="checkbox83">Node content supports text (regular text, rich text), images, icons, hyperlinks, notes, labels, summaries, and math formulas</label></li>
<li><input type="checkbox" id="checkbox84" checked="true" /><label for="checkbox84">Nodes support drag and drop (drag and move, freely adjust), multiple node shapes, and fully customize node content using DDM</label></li>
<li><input type="checkbox" id="checkbox85" checked="true" /><label for="checkbox85">Support canvas dragging and scaling</label></li>
<li><input type="checkbox" id="checkbox86" checked="true" /><label for="checkbox86">Supports two multi node selection methods: mouse button drag selection and Ctrl+left button selection</label></li>
<li><input type="checkbox" id="checkbox87" checked="true" /><label for="checkbox87">Supoorts to export as </label><code>json</code><code>png</code><code>svg</code><code>pdf</code><code>markdown</code><code>xmind</code>, support import from <code>json</code><code>xmind</code><code>markdown</code></li>
<li><input type="checkbox" id="checkbox88" checked="true" /><label for="checkbox88">Support shortcut keys, forward and backward, correlation lines, search and replacement, small maps, watermarks, and scrollbar</label></li>
<li><input type="checkbox" id="checkbox89" checked="true" /><label for="checkbox89">Provide rich configurations to meet various scenarios and usage habits</label></li>
<li><input type="checkbox" id="checkbox90" checked="true" /><label for="checkbox90">Support collaborative editing</label></li>
<li><input type="checkbox" id="checkbox48" checked="true" /><label for="checkbox48">Pluggable architecture, in addition to core functions, other functions are provided as plugins, which can be used as needed to reduce packaging volume</label></li>
<li><input type="checkbox" id="checkbox49" checked="true" /><label for="checkbox49">Support logical structure chart, mind map, Organizational chart, directory organization chart, timeline (horizontal and vertical), fishbone chart and other structures</label></li>
<li><input type="checkbox" id="checkbox50" checked="true" /><label for="checkbox50">Built-in multiple themes, allowing for highly customizable styles, and supporting registration of new themes</label></li>
<li><input type="checkbox" id="checkbox51" checked="true" /><label for="checkbox51">Node content supports text (regular text, rich text), images, icons, hyperlinks, notes, labels, summaries, and math formulas</label></li>
<li><input type="checkbox" id="checkbox52" checked="true" /><label for="checkbox52">Nodes support drag and drop (drag and move, freely adjust), multiple node shapes, and fully customize node content using DDM</label></li>
<li><input type="checkbox" id="checkbox53" checked="true" /><label for="checkbox53">Support canvas dragging and scaling</label></li>
<li><input type="checkbox" id="checkbox54" checked="true" /><label for="checkbox54">Supports two multi node selection methods: mouse button drag selection and Ctrl+left button selection</label></li>
<li><input type="checkbox" id="checkbox55" checked="true" /><label for="checkbox55">Supoorts to export as </label><code>json</code><code>png</code><code>svg</code><code>pdf</code><code>markdown</code><code>xmind</code>, support import from <code>json</code><code>xmind</code><code>markdown</code></li>
<li><input type="checkbox" id="checkbox56" checked="true" /><label for="checkbox56">Support shortcut keys, forward and backward, correlation lines, search and replacement, small maps, watermarks, and scrollbar</label></li>
<li><input type="checkbox" id="checkbox57" checked="true" /><label for="checkbox57">Provide rich configurations to meet various scenarios and usage habits</label></li>
<li><input type="checkbox" id="checkbox58" checked="true" /><label for="checkbox58">Support collaborative editing</label></li>
</ul>
<blockquote>
<p>Features that will not be implemented:</p>
@@ -34,16 +34,16 @@ frameworks such as Vue and React, or without a framework.</p>
<p>This is an online mind map built using the <code>simple-mind-map</code> library and based
on <code>Vue2.x</code> and <code>ElementUI</code>. Features include:</p>
<ul>
<li><input type="checkbox" id="checkbox91" checked="true" /><label for="checkbox91">Toolbar, which supports inserting and deleting nodes, and editing node</label>
<li><input type="checkbox" id="checkbox59" checked="true" /><label for="checkbox59">Toolbar, which supports inserting and deleting nodes, and editing node</label>
images, icons, hyperlinks, notes, tags, and summaries</li>
<li><input type="checkbox" id="checkbox92" checked="true" /><label for="checkbox92">Sidebar, with panels for basic style settings, node style settings,</label>
<li><input type="checkbox" id="checkbox60" checked="true" /><label for="checkbox60">Sidebar, with panels for basic style settings, node style settings,</label>
outline, theme selection, and structure selection</li>
<li><input type="checkbox" id="checkbox93" checked="true" /><label for="checkbox93">Import and export functionality; data is saved in the browser's local</label>
<li><input type="checkbox" id="checkbox61" checked="true" /><label for="checkbox61">Import and export functionality; data is saved in the browser's local</label>
storage by default, but it also supports creating, opening, and editing
local files on the computer directly</li>
<li><input type="checkbox" id="checkbox94" checked="true" /><label for="checkbox94">Right-click menu, which supports operations such as expanding, collapsing,</label>
<li><input type="checkbox" id="checkbox62" checked="true" /><label for="checkbox62">Right-click menu, which supports operations such as expanding, collapsing,</label>
and organizing layout</li>
<li><input type="checkbox" id="checkbox95" checked="true" /><label for="checkbox95">Bottom bar, which supports node and word count statistics, switching</label>
<li><input type="checkbox" id="checkbox63" checked="true" /><label for="checkbox63">Bottom bar, which supports node and word count statistics, switching</label>
between edit and read-only modes, zooming in and out, and switching to
full screen, support mini map</li>
</ul>
@@ -281,6 +281,30 @@ full screen, support mini map</li>
<img src="../../../../assets/avatar/pluvet.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>pluvet</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/皇登攀.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>皇登攀</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/风格.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>风格</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>SR</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/逆水行舟.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>逆水行舟</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>LiuJL</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/L.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>L</p>
</div>
</div>
</div>
</template>

View File

@@ -56,6 +56,12 @@ Whether the node is currently being dragged
## Methods
### getAncestorNodes()
> v0.9.9+
Obtain a list of ancestor node instances.
### highlight()
> v0.9.8+

View File

@@ -31,6 +31,11 @@
</blockquote>
<p>Whether the node is currently being dragged</p>
<h2>Methods</h2>
<h3>getAncestorNodes()</h3>
<blockquote>
<p>v0.9.9+</p>
</blockquote>
<p>Obtain a list of ancestor node instances.</p>
<h3>highlight()</h3>
<blockquote>
<p>v0.9.8+</p>

View File

@@ -0,0 +1,56 @@
# RainbowLines plugin
> v0.9.9+
This plugin is used to implement rainbow lines.
Enabling rainbow lines and custom colors can be set through the instantiation option 'rainbowLinesConfig'.
The default color list is as follows:
```
[
'rgb(255, 213, 73)',
'rgb(255, 136, 126)',
'rgb(107, 225, 141)',
'rgb(151, 171, 255)',
'rgb(129, 220, 242)',
'rgb(255, 163, 125)',
'rgb(152, 132, 234)'
]
```
## Register
```js
import MindMap from 'simple-mind-map'
import RainbowLines from 'simple-mind-map/src/plugins/RainbowLines.js'
MindMap.usePlugin(RainbowLines)
```
After registration and instantiation of `MindMap`, the instance can be obtained through `mindMap.rainbowLines`.
## Method
### updateRainLinesConfig(config = {})
If you want to modify the rainbow lines after setting them through the instantiation option 'rainbowLinesConfig', you can use this method, option `config` is same with `rainbowLinesConfig`
```js
{
open: false,// Is turn on rainbow lines
colorsList: []// Customize the color list for rainbow lines. If not set, the default color list will be used
}
```
### getColorsList()
Get a list of currently used rainbow line colors.
### getNodeColor(node)
Retrieve the rainbow line color corresponding to the specified node instance.
### getSecondLayerAncestor(node)
Retrieve the second level ancestor node instance of a node instance.

View File

@@ -0,0 +1,52 @@
<template>
<div>
<h1>RainbowLines plugin</h1>
<blockquote>
<p>v0.9.9+</p>
</blockquote>
<p>This plugin is used to implement rainbow lines.</p>
<p>Enabling rainbow lines and custom colors can be set through the instantiation option 'rainbowLinesConfig'.</p>
<p>The default color list is as follows:</p>
<pre class="hljs"><code>[
'rgb(255, 213, 73)',
'rgb(255, 136, 126)',
'rgb(107, 225, 141)',
'rgb(151, 171, 255)',
'rgb(129, 220, 242)',
'rgb(255, 163, 125)',
'rgb(152, 132, 234)'
]
</code></pre>
<h2>Register</h2>
<pre class="hljs"><code><span class="hljs-keyword">import</span> MindMap <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;simple-mind-map&#x27;</span>
<span class="hljs-keyword">import</span> RainbowLines <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;simple-mind-map/src/plugins/RainbowLines.js&#x27;</span>
MindMap.usePlugin(RainbowLines)
</code></pre>
<p>After registration and instantiation of <code>MindMap</code>, the instance can be obtained through <code>mindMap.rainbowLines</code>.</p>
<h2>Method</h2>
<h3>updateRainLinesConfig(config = {})</h3>
<p>If you want to modify the rainbow lines after setting them through the instantiation option 'rainbowLinesConfig', you can use this method, option <code>config</code> is same with <code>rainbowLinesConfig</code></p>
<pre class="hljs"><code>{
<span class="hljs-attr">open</span>: <span class="hljs-literal">false</span>,<span class="hljs-comment">// Is turn on rainbow lines</span>
<span class="hljs-attr">colorsList</span>: []<span class="hljs-comment">// Customize the color list for rainbow lines. If not set, the default color list will be used</span>
}
</code></pre>
<h3>getColorsList()</h3>
<p>Get a list of currently used rainbow line colors.</p>
<h3>getNodeColor(node)</h3>
<p>Retrieve the rainbow line color corresponding to the specified node instance.</p>
<h3>getSecondLayerAncestor(node)</h3>
<p>Retrieve the second level ancestor node instance of a node instance.</p>
</div>
</template>
<script>
export default {
}
</script>
<style>
</style>

View File

@@ -32,6 +32,7 @@ export default [
{ path: 'course23', title: '如何渲染滚动条' },
{ path: 'course24', title: '如何开发一个插件' },
{ path: 'course25', title: '关于概要' },
{ path: 'course26', title: '如何实现AI生成节点内容' },
{ path: 'doExport', title: 'Export 插件' },
{ path: 'drag', title: 'Drag插件' },
{ path: 'introduction', title: '简介' },
@@ -60,6 +61,7 @@ export default [
{ path: 'scrollbar', title: 'Scrollbar插件' },
{ path: 'formula', title: 'Formula插件' },
{ path: 'cooperate', title: 'Cooperate插件' },
{ path: 'rainbowLines', title: 'RainbowLines插件' },
{ path: 'handDrawnLikeStyle', title: 'HandDrawnLikeStyle收费插件' },
{ path: 'help1', title: '概要/关联线' },
{ path: 'help2', title: '客户端' },
@@ -102,6 +104,7 @@ export default [
{ path: 'scrollbar', title: 'Scrollbar plugin' },
{ path: 'formula', title: 'Formula plugin' },
{ path: 'cooperate', title: 'Cooperate plugin' },
{ path: 'rainbowLines', title: 'RainbowLines plugin' },
{ path: 'handDrawnLikeStyle', title: 'HandDrawnLikeStyle chargeable plugin' },
{ path: 'client', title: 'Client' }
]

View File

@@ -1,5 +1,47 @@
# Changelog
## 0.9.9
修复:
> 1.修复第一次创建关联线时,箭头颜色不正确的问题;
新增:
> 1.支持insert键插入下级节点
>
> 2.增加beforeShortcutRun实例化选项用于拦截快捷键操作
>
> 3.根实例增加增量更新画布数据的方法updateData
>
> 4.新增彩虹线条插件;
>
> 5.节点中的图标添加鼠标移入和移出事件;
>
> 6.节点实例新增getAncestorNodes方法用于获取祖先节点列表
>
> 7.协同编辑时的人员头像增加鼠标事件;
>
> 8.实例化及setData方法支持传入空的data
>
> 9.新增导出图片时添加自定义内容的实例化选项;
Demo
> 1.支持配置彩虹线条;
>
> 2.新增源码编辑模式;
>
> 3.导出png、pdf、svg支持设置底部自定义文字
客户端:
> 1.双击文件打开应用时不打开工作台页面;
>
> 2.修复重复打开同一个文件会打开多个编辑窗口的问题;
>
> 3.修改删除正在编辑的文件的提示;
## 0.9.8
修复:

View File

@@ -1,6 +1,35 @@
<template>
<div>
<h1>Changelog</h1>
<h2>0.9.9</h2>
<p>修复</p>
<blockquote>
<p>1.修复第一次创建关联线时箭头颜色不正确的问题</p>
</blockquote>
<p>新增</p>
<blockquote>
<p>1.支持insert键插入下级节点</p>
<p>2.增加beforeShortcutRun实例化选项用于拦截快捷键操作</p>
<p>3.根实例增加增量更新画布数据的方法updateData</p>
<p>4.新增彩虹线条插件</p>
<p>5.节点中的图标添加鼠标移入和移出事件</p>
<p>6.节点实例新增getAncestorNodes方法用于获取祖先节点列表</p>
<p>7.协同编辑时的人员头像增加鼠标事件</p>
<p>8.实例化及setData方法支持传入空的data</p>
<p>9.新增导出图片时添加自定义内容的实例化选项</p>
</blockquote>
<p>Demo</p>
<blockquote>
<p>1.支持配置彩虹线条</p>
<p>2.新增源码编辑模式</p>
<p>3.导出pngpdfsvg支持设置底部自定义文字</p>
</blockquote>
<p>客户端:</p>
<blockquote>
<p>1.双击文件打开应用时不打开工作台页面</p>
<p>2.修复重复打开同一个文件会打开多个编辑窗口的问题</p>
<p>3.修改删除正在编辑的文件的提示</p>
</blockquote>
<h2>0.9.8</h2>
<p>修复</p>
<blockquote>

View File

@@ -25,7 +25,7 @@ const mindMap = new MindMap({
| 字段名称 | 类型 | 默认值 | 描述 |
| -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ |
| el | Element | | 容器元素必传必须为DOM元素 |
| data | Object | {} | 思维导图数据,可参考下方【数据结构】介绍 |
| data | Object 、 null | | 思维导图数据,可参考下方【数据结构】介绍。v0.9.9+支持传空对象或者null画布会显示空白 |
| layout | String | logicalStructure | 布局类型可选列表logicalStructure逻辑结构图、mindMap思维导图、catalogOrganization目录组织图、organizationStructure组织结构图、timelinev0.5.4+时间轴、timeline2v0.5.4+上下交替型时间轴、fishbonev0.5.4+,鱼骨图) |
| fishboneDegv0.5.4+ | Number | 45 | 设置鱼骨结构图的斜线角度 |
| theme | String | default | 主题可选列表default默认、classic脑图经典、minions小黄人、pinkGrape粉红葡萄、mint薄荷、gold金色vip、vitalityOrange活力橙、greenLeaf绿叶、dark2暗色2、skyGreen天清绿、classic2脑图经典2、classic3脑图经典3、classic4脑图经典4v0.2.0+、classicGreen经典绿、classicBlue经典蓝、blueSky天空蓝、brainImpairedPink脑残粉、dark暗色、earthYellow泥土黄、freshGreen清新绿、freshRed清新红、romanticPurple浪漫紫、simpleBlackv0.5.4+简约黑、courseGreenv0.5.4+课程绿、coffeev0.5.4+咖啡、redSpiritv0.5.4+红色精神、blackHumourv0.5.4+黑色幽默、lateNightOfficev0.5.4+深夜办公室、blackGoldv0.5.4+黑金、avocadov.5.10-fix.2+牛油果、autumnv.5.10-fix.2+秋天、orangeJuicev.5.10-fix.2+橙汁) |
@@ -113,6 +113,11 @@ const mindMap = new MindMap({
| isOnlySearchCurrentRenderNodesv0.9.8+ | Boolean | false | 是否仅搜索当前渲染的节点,被收起的节点不会被搜索到 |
| onlyOneEnableActiveNodeOnCooperatev0.9.8+ | Boolean | false | 协同编辑时,同一个节点不能同时被多人选中 |
| beforeCooperateUpdatev0.9.8+ | Function、null | null | 协同编辑时,节点操作即将更新到其他客户端前的生命周期函数。函数接收一个对象作为参数:{ type: 【createOrUpdate创建节点或更新节点、delete删除节点】, list: 【数组类型1.当type=createOrUpdate时代表被创建或被更新的节点数据即将同步到其他客户端所以你可以修改该数据2.当type=delete时代表被删除的节点数据】 } |
| beforeShortcutRunv0.9.9+ | Function、null | null | 快捷键操作即将执行前的生命周期函数返回true可以阻止操作执行。函数接收两个参数key快捷键、activeNodeList当前激活的节点列表 |
| rainbowLinesConfigv0.9.9+ | Object | { open: false, colorsList: [] } | 彩虹线条配置需要先注册RainbowLines插件。对象类型结构{ open: false【是否开启彩虹线条】, colorsList: []【自定义彩虹线条的颜色列表,如果不设置,会使用默认颜色列表】 } |
| addContentToHeaderv0.9.9+ | Function、null | null | 导出png、svg、pdf时在头部添加自定义内容。可传递一个函数这个函数可以返回null代表不添加内容也可以返回一个对象详细介绍请参考下方【导出时如何添加自定义内容】 |
| addContentToFooterv0.9.9+ | Function、null | null | 基本释义同addContentToHeader在尾部添加自定义内容 |
### 数据结构
@@ -174,6 +179,41 @@ const mindMap = new MindMap({
| type | String | | 图标分组的值 |
| list | Array | | 分组下的图标列表,数组的每一项为一个对象,`{ name: '', icon: '' }``name`代表图标的名称,`icon`代表图标,可以是`svg`图标,比如`<svg ...><path></path></svg>`,也可以是图片`url`,或者是`base64`图标,比如`data:image/png;base64,...` |
### 导出时如何添加自定义内容
`addContentToHeader``addContentToFooter`两个实例化选项可以用于在导出`png``svg``pdf`时在头部和尾部添加自定义的内容,默认为`null`,代表不配置,可以传递一个函数,函数可以返回`null`,代表不添加内容,如果要添加内容那么需要返回如下的结构:
```
{
el,// 要追加的自定义DOM节点样式可内联
cssText,// 可选如果样式不想内联可以传递该值一个css字符串
height: 50// 返回的DOM节点的高度必须传递
}
```
一个简单的示例:
```js
new MindMap({
addContentToFooter: () => {
const el = document.createElement('div')
el.className = 'footer'
el.innerHTML = '来自simple-mind-map'
const cssText = `
.footer {
width: 100%;
height: 30px;
}
`
return {
el,
cssText,
height: 30
}
}
})
```
## 静态方法
### defineTheme(name, config)
@@ -313,6 +353,12 @@ mindMap.setTheme('主题名称')
## 实例方法
### updateData(data)
> v0.9.9+
更新画布数据,如果新的数据是在当前画布节点数据基础上增删改查后形成的,那么可以使用该方法来更新画布数据。性能会更好,不会重新创建所有节点,而是会尽可能的复用。
### clearDraw()
> v0.8.0+
@@ -325,7 +371,7 @@ mindMap.setTheme('主题名称')
销毁思维导图。会移除注册的插件、移除监听的事件、删除画布的所有节点。
### getSvgData({ paddingX = 0, paddingY = 0, ignoreWatermark = false })
### getSvgData({ paddingX = 0, paddingY = 0, ignoreWatermark = false, addContentToHeader, addContentToFooter })
> v0.3.0+
@@ -335,6 +381,10 @@ mindMap.setTheme('主题名称')
`ignoreWatermark`v0.8.0+,不要绘制水印,如果不需要绘制水印的场景可以传`true`,因为绘制水印非常慢
`addContentToHeader`v0.9.9+Function可以返回要追加到头部的自定义内容详细介绍见【实例化选项】中的该配置
`addContentToFooter`v0.9.9+Function可以返回要追加到尾部的自定义内容详细介绍见【实例化选项】中的该配置
获取`svg`数据,返回一个对象,详细结构如下:
```js
@@ -415,7 +465,9 @@ mindMap.setTheme('主题名称')
| associative_line_clickv0.4.5+ | 点击某条关联线时触发 | path连接线节点、clickPath不可见的点击线节点、node起始节点、toNode目标节点 |
| svg_mouseenterv0.5.1+ | 鼠标移入svg画布时触发 | e事件对象 |
| svg_mouseleavev0.5.1+ | 鼠标移出svg画布时触发 | e事件对象 |
| node_icon_clickv0.6.10+ | 点击节点内的图标时触发 | this节点实例、item点击的图标名称、e事件对象 |
| node_icon_clickv0.6.10+ | 点击节点内的图标时触发 | this节点实例、item点击的图标名称、e事件对象、node(图标节点v0.9.9+) |
| node_icon_mouseenterv0.9.9+ | 鼠标移入节点内的图标时触发 | this节点实例、item点击的图标名称、e事件对象、node(图标节点) |
| node_icon_mouseleavev0.9.9+ | 鼠标移出节点内的图标时触发 | this节点实例、item点击的图标名称、e事件对象、node(图标节点) |
| view_theme_changev0.6.12+ | 调用了setTheme方法设置主题后触发 | theme设置的新主题名称 |
| set_datav0.7.3+ | 调用了setData方法动态设置思维导图数据时触发 | data新的思维导图数据 |
| resizev0.8.0+ | 容器尺寸改变后触发,实际上是当思维导图实例的`resize`方法被调用后触发 | |
@@ -424,6 +476,9 @@ mindMap.setTheme('主题名称')
| body_click | document.body的点击事件 | e事件对象 |
| data_change_detailv0.9.3+ | 渲染树数据变化的明细,会返回一个数组,每一项代表一个更新点,每一项都是一个对象,存在一个`type`属性,代表明细的类型,包含`create`(创建节点)、`update`(更新节点)、`delete`(删除节点),存在一个`data`属性,代表当前更新的节点数据,如果是`update`类型,还会存在一个`oldData`属性,保存了更新前该节点的数据 | arr明细数据 |
| layout_changev0.9.4+ | 修改结构时触发即调用了mindMap.setLayout()方法时触发 | layout新的结构 |
| node_cooperate_avatar_clickv0.9.9+ | 协同编辑时,鼠标点击人员头像时触发 | userInfo(人员信息)、 this(当前节点实例)、 node(头像节点)、 e(事件对象) |
| node_cooperate_avatar_mouseenterv0.9.9+ | 协同编辑时,鼠标移入人员头像时触发 | userInfo(人员信息)、 this(当前节点实例)、 node(头像节点)、 e(事件对象) |
| node_cooperate_avatar_mouseleavev0.9.9+ | 协同编辑时,鼠标移除人员头像时触发 | userInfo(人员信息)、 this(当前节点实例)、 node(头像节点)、 e(事件对象) |
### emit(event, ...args)
@@ -544,7 +599,7 @@ mindMap.updateConfig({
动态设置思维导图数据,纯节点数据
`data`:思维导图结构数据
`data`:思维导图结构数据。v0.9.9+支持传空对象或者null画布会显示空白。
### setFullData(*data*)

View File

@@ -35,9 +35,9 @@
</tr>
<tr>
<td>data</td>
<td>Object</td>
<td>{}</td>
<td>思维导图数据可参考下方数据结构介绍</td>
<td>Object null</td>
<td></td>
<td>思维导图数据可参考下方数据结构介绍v0.9.9+支持传空对象或者null画布会显示空白</td>
</tr>
<tr>
<td>layout</td>
@@ -561,6 +561,30 @@
<td>null</td>
<td>协同编辑时节点操作即将更新到其他客户端前的生命周期函数函数接收一个对象作为参数{ type: createOrUpdate创建节点或更新节点delete删除节点, list: 数组类型1.当type=createOrUpdate时代表被创建或被更新的节点数据即将同步到其他客户端所以你可以修改该数据2.当type=delete时代表被删除的节点数据 }</td>
</tr>
<tr>
<td>beforeShortcutRunv0.9.9+</td>
<td>Functionnull</td>
<td>null</td>
<td>快捷键操作即将执行前的生命周期函数返回true可以阻止操作执行函数接收两个参数key快捷键activeNodeList当前激活的节点列表</td>
</tr>
<tr>
<td>rainbowLinesConfigv0.9.9+</td>
<td>Object</td>
<td>{ open: false, colorsList: [] }</td>
<td>彩虹线条配置需要先注册RainbowLines插件对象类型结构{ open: false是否开启彩虹线条, colorsList: []自定义彩虹线条的颜色列表如果不设置会使用默认颜色列表 }</td>
</tr>
<tr>
<td>addContentToHeaderv0.9.9+</td>
<td>Functionnull</td>
<td>null</td>
<td>导出pngsvgpdf时在头部添加自定义内容可传递一个函数这个函数可以返回null代表不添加内容也可以返回一个对象详细介绍请参考下方导出时如何添加自定义内容</td>
</tr>
<tr>
<td>addContentToFooterv0.9.9+</td>
<td>Functionnull</td>
<td>null</td>
<td>基本释义同addContentToHeader在尾部添加自定义内容</td>
</tr>
</tbody>
</table>
<h3>数据结构</h3>
@@ -679,6 +703,34 @@
</tr>
</tbody>
</table>
<h3>导出时如何添加自定义内容</h3>
<p><code>addContentToHeader</code><code>addContentToFooter</code>两个实例化选项可以用于在导出<code>png</code><code>svg</code><code>pdf</code>时在头部和尾部添加自定义的内容默认为<code>null</code>代表不配置可以传递一个函数函数可以返回<code>null</code>代表不添加内容如果要添加内容那么需要返回如下的结构</p>
<pre class="hljs"><code>{
el,// 要追加的自定义DOM节点样式可内联
cssText,// 可选如果样式不想内联可以传递该值一个css字符串
height: 50// 返回的DOM节点的高度必须传递
}
</code></pre>
<p>一个简单的示例</p>
<pre class="hljs"><code><span class="hljs-keyword">new</span> MindMap({
<span class="hljs-attr">addContentToFooter</span>: <span class="hljs-function">() =&gt;</span> {
<span class="hljs-keyword">const</span> el = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">&#x27;div&#x27;</span>)
el.className = <span class="hljs-string">&#x27;footer&#x27;</span>
el.innerHTML = <span class="hljs-string">&#x27;来自simple-mind-map&#x27;</span>
<span class="hljs-keyword">const</span> cssText = <span class="hljs-string">`
.footer {
width: 100%;
height: 30px;
}
`</span>
<span class="hljs-keyword">return</span> {
el,
cssText,
<span class="hljs-attr">height</span>: <span class="hljs-number">30</span>
}
}
})
</code></pre>
<h2>静态方法</h2>
<h3>defineTheme(name, config)</h3>
<blockquote>
@@ -775,6 +827,11 @@ mindMap.setTheme(<span class="hljs-string">&#x27;主题名称&#x27;</span>)
<h3>themeConfig</h3>
<p>当前主题配置</p>
<h2>实例方法</h2>
<h3>updateData(data)</h3>
<blockquote>
<p>v0.9.9+</p>
</blockquote>
<p>更新画布数据如果新的数据是在当前画布节点数据基础上增删改查后形成的那么可以使用该方法来更新画布数据性能会更好不会重新创建所有节点而是会尽可能的复用</p>
<h3>clearDraw()</h3>
<blockquote>
<p>v0.8.0+</p>
@@ -785,13 +842,15 @@ mindMap.setTheme(<span class="hljs-string">&#x27;主题名称&#x27;</span>)
<p>v0.6.0+</p>
</blockquote>
<p>销毁思维导图会移除注册的插件移除监听的事件删除画布的所有节点</p>
<h3>getSvgData({ paddingX = 0, paddingY = 0, ignoreWatermark = false })</h3>
<h3>getSvgData({ paddingX = 0, paddingY = 0, ignoreWatermark = false, addContentToHeader, addContentToFooter })</h3>
<blockquote>
<p>v0.3.0+</p>
</blockquote>
<p><code>paddingX</code>水平内边距</p>
<p><code>paddingY</code>垂直内边距</p>
<p><code>ignoreWatermark</code>v0.8.0+不要绘制水印如果不需要绘制水印的场景可以传<code>true</code>因为绘制水印非常慢</p>
<p><code>addContentToHeader</code>v0.9.9+Function可以返回要追加到头部的自定义内容详细介绍见实例化选项中的该配置</p>
<p><code>addContentToFooter</code>v0.9.9+Function可以返回要追加到尾部的自定义内容详细介绍见实例化选项中的该配置</p>
<p>获取<code>svg</code>数据返回一个对象详细结构如下</p>
<pre class="hljs"><code>{
svg, <span class="hljs-comment">// Element思维导图图形的整体svg元素包括svg画布容器、g实际的思维导图组</span>
@@ -1015,7 +1074,17 @@ mindMap.setTheme(<span class="hljs-string">&#x27;主题名称&#x27;</span>)
<tr>
<td>node_icon_clickv0.6.10+</td>
<td>点击节点内的图标时触发</td>
<td>this节点实例item点击的图标名称e事件对象</td>
<td>this节点实例item点击的图标名称e事件对象node(图标节点v0.9.9+)</td>
</tr>
<tr>
<td>node_icon_mouseenterv0.9.9+</td>
<td>鼠标移入节点内的图标时触发</td>
<td>this节点实例item点击的图标名称e事件对象node(图标节点)</td>
</tr>
<tr>
<td>node_icon_mouseleavev0.9.9+</td>
<td>鼠标移出节点内的图标时触发</td>
<td>this节点实例item点击的图标名称e事件对象node(图标节点)</td>
</tr>
<tr>
<td>view_theme_changev0.6.12+</td>
@@ -1057,6 +1126,21 @@ mindMap.setTheme(<span class="hljs-string">&#x27;主题名称&#x27;</span>)
<td>修改结构时触发即调用了mindMap.setLayout()方法时触发</td>
<td>layout新的结构</td>
</tr>
<tr>
<td>node_cooperate_avatar_clickv0.9.9+</td>
<td>协同编辑时鼠标点击人员头像时触发</td>
<td>userInfo(人员信息) this(当前节点实例) node(头像节点) e(事件对象)</td>
</tr>
<tr>
<td>node_cooperate_avatar_mouseenterv0.9.9+</td>
<td>协同编辑时鼠标移入人员头像时触发</td>
<td>userInfo(人员信息) this(当前节点实例) node(头像节点) e(事件对象)</td>
</tr>
<tr>
<td>node_cooperate_avatar_mouseleavev0.9.9+</td>
<td>协同编辑时鼠标移除人员头像时触发</td>
<td>userInfo(人员信息) this(当前节点实例) node(头像节点) e(事件对象)</td>
</tr>
</tbody>
</table>
<h3>emit(event, ...args)</h3>
@@ -1328,7 +1412,7 @@ mindMap.setTheme(<span class="hljs-string">&#x27;主题名称&#x27;</span>)
</table>
<h3>setData(data)</h3>
<p>动态设置思维导图数据纯节点数据</p>
<p><code>data</code>思维导图结构数据</p>
<p><code>data</code>思维导图结构数据v0.9.9+支持传空对象或者null画布会显示空白</p>
<h3>setFullData(<em>data</em>)</h3>
<blockquote>
<p>v0.2.7+</p>

View File

@@ -0,0 +1,255 @@
# 如何实现AI生成节点内容
目前AI能力非常流行每个应用都给自己加上了AI的能力提高竞争力那么在使用了`simple-mind-map`的情况下如何添加AI的能力呢本教程会详细的教你如何实现。
首先要说明的是本教程并不会真的实现一个可用的AI能力只是在假设你要实现该功能的前提下来教你如何调用对应的API来实现你想要的效果。
其次AI返回的数据结构不尽相同你都需要自行转换成`simple-mind-map`的结构类型。
## 自动生成整个思维导图
### 一次生成
通过AI生成整个思维导图并且一次直接生成这个其实就是普通的回显功能那么你可以在实例化时通过`data`传入生成的数据:
```js
const mindMap = new MindMap({
el,
data: {
data: {
text: '我是自动生成的节点'
},
children: [
{
data: {
text: '子节点'
},
children: []
}
]
}
})
```
也可以在实例化之后使用`setData`方法设置:
```js
mindMap.setData({
data: {
text: '我是自动生成的节点'
},
children: [
{
data: {
text: '子节点'
},
children: []
}
]
})
```
### 依次生成节点
如果你想像ChatGPT一样依次生成节点那么推荐使用`updateData`方法增量更新节点数据,而不是手动获取到之前插入的节点实例,再调用命令来插入下级节点,这样会复杂很多,当然,如果你能轻松的知道当前创建到哪里了,并且下一个节点在哪个节点下创建,可以忽略。
> updateData方法是v0.9.9+的方法,之前的版本可以使用下面的方法:
```js
const updateData = (data) => {
mindMap.renderer.setData(data)
mindMap.render()
mindMap.command.addHistory()
}
```
增量更新的前提是之前生成的节点都存在`uid`,并且不会变化,这样调用`updateData`方法渲染时会根据`uid`来复用之前的节点,只创建新的节点,达到依次生成的目的。
比如第一次返回的数据:
```js
const data = {
data: {
text: '根节点',
uid: '1'
},
children: []
}
mindMap.setData(data)
```
第二次返回的数据:
```js
const data = {
data: {
text: '根节点',
uid: '1'
},
children: [
{
data: {
text: '二级节点',
uid: '2'
},
children: []
}
]
}
mindMap.updateData(data)
```
以此类推,这样虽然是整个数据更新,但是因为复用的原因画布呈现的是依次生成新节点的效果。
当生成的节点多了会有个问题,就是新生成的节点在画布外看不见了,所以我们要将新生成的节点移动到画布中心,首先可以监听`data_change_detail`事件来获取到详细的更新数据,找出其中新创建的节点数据,然后使用`findNodeByUid`方法找出对应的节点实例,最后调用`moveNodeToCenter`方法将该节点移动到画布中心即可。
```js
mindMap.on('data_change_detail', (list) => {
// 找出新创建节点中的最后一个
const lastCreate = list.filter((item) => {
return item.action === 'create'
})[0]
if (lastCreate) {
const uid = lastCreate.data.data.uid
const node = mindMap.renderer.findNodeByUid(uid)
if (node) {
mindMap.renderer.moveNodeToCenter(node)
}
}
})
```
当节点数据多了,可能`data_change_detail`事件触发时节点树还没渲染完毕,导致获取不到节点,解决这个问题可以通过监听`node_tree_render_end`事件:
```js
let waitUid = ''
mindMap.on('data_change_detail', (list) => {
// ...
if (lastCreate) {
// ...
if (node) {
mindMap.renderer.moveNodeToCenter(node)
} else {
waitUid = uid
}
}
})
mindMap.on('node_tree_render_end', () =>{
if (waitUid) {
waitUid = ''
const node = mindMap.renderer.findNodeByUid(waitUid)
if (node) {
mindMap.renderer.moveNodeToCenter(node)
}
}
})
```
当在`data_change_detail`事件中没有获取到节点实例就将该`uid`保存起来,然后在`node_tree_render_end`事件里判断是否有保存的`uid`,是的话就获取该节点实例并移动到画布中心。
最后,当自动生成节点中最好禁止用户操作,否则可能会产生异常。
### 完整示例
<iframe style="width: 100%; height: 455px; border: none;" src="https://wanglin2.github.io/playground/#eNrtV19rHDcQ/ypiS9m95rx3bvN0vTOJnUILdVtC+uQNZr2ru1OqlZZdrc+HOQih0DT0IYUWSkto+9QSWvKSByct+TT2XT5GR7uS9t/ZxNBAoTHYXmlmfvObGWkkHVvX49g9zLA1sIZpkJBYoBSLLN7yGIlingh0jBI87iLOdnnGBA67KJ36lPLZTTxGCzROeIRsQLCNxS5h4a4fFyLPSmGa4o0IZjciP/YsjyHkMYoFknNSc4RYRqnHPBZwlgpwFuCdBPsCX6cUpE4HjbbQsTRUJi6wvOEL38knEQrhe1BoyB+Bj8QA2cv73y5/ePLyq8dnD35ffffz8v7D1Y9fvnxwb3XvGdCViotu8T+YEhommA3QnsYwYC30ioezPx/W8KqYDdzberaUX87Fu5fxUXzk40XHYzAuk4u355+y8xJcKEk6HxP4GOmEGGotpjrZvzxTqahwy0gIok3DvOTdZq1lr9FTqV7L9JrkG2enz79ZPf+t7a/0Wa1LvTLra2Oqo+rzv4q8ovMvEnnvTQkujrxu2nB2Docqj5Ovz+VRcrla49Lmc341ahWpVOW/vWTkv/xbnmVwLuEjaJf9sokmGav3VoTIGDmF5tbINFmXYjYR0w6ctCJLoFHnHHKIIEsAQivu5abKfQk1GoHbTpmJ5hkJIHAEFDJJdeYT8TkJAdg2SdA2nDm2dLcfTH02wfshFj6hdhc5FAhUQylJUj8VxWkCkFLNHRMqcOI4ROCoaYNUmEgKXT8QhEOaIAQ7yDGqp1xnr18pgIy49FUJuKQCtZUcjJIrYyn+gKitz3goSevooeYhTnACAbDwE5BtzyFRDpiaBGoi0rJBocyiwYn4IZY4t/gOhttTUpjVVh7CNMVNoLJEDdqVXWI+5QHfrqL0tC8SjPcLNvvwV9ZR1qPiTcaivDXCWbdMLps5jfzasndBOpqZ7fWMhyyGJYFbm6NFoL2DPFFXclrzAY8in4WuH4Yfwl7gyVzrKIYAeotEmGfCqfUGyIzczleu6CH0D2PaRZv9fj8f5TBKlt/rzN28ile5W+OZvpPr6zKmAxTyIIsgre4Eiw8olp/b849Cx1aWO5zB1mc4sTuqOTYarmfJCc9q9GDPkj1YTsNVP7/s1xusZ+n2KnWalz/CiLjJuZBl/4ynRHYH0LIpHgtYvXaQLwT7dq6+6LwPKYA0DHvF4wWeLTCAvhJTqC+MEBqG5BAF0BHSkWep0G7giHtWLlYKJCylJnBQGfZAWlXUSIJzeuBLFR3X8CATAlrZtYCS4AtQqb1iQPH05O7yj1+Ld8jy+6enJ4+Xdx+t/np69uTvs59eDHuF/UV4jYu7xHzx6NUxy2D017BXyRUMUzGnRdquqcecZ7m94gWnlpCL08gN0tSzIPfyIYeQW0mrXgszEorpQC7at3M9hGJTzQSDR3KIc0G+muXvW830a6jS0D9IOc1EYSjPsjGc9X01EjwuB233U0wmU1C/2u/HR9rzer/vaM+Rn0wI+NWoMexpwiZ6wlB31Wp4RcabmoEibcYACCs5r4HVtYoKyDezeyflDJ7oObynBFABs/M8C17gxZZze/DpQnsQ0GNksTYOEj5LoZndAQu1y9a8ygvbdqmlleK2sBb/AOBR7ZA=" />
## 在某个节点下自动生成新节点
在某个节点下自动生成新节点,如果也要依次生成,那么可以使用前面的增量更新数据的方式。如果一次生成,那么可以简单的调用插入新节点的命令即可。
### 一次生成下级节点
```js
// 插入一个子节点
mindMap.execCommand('INSERT_CHILD_NODE',
false,
node,
{
data: {
text: '三级节点'
},
children: []
},
[
{
data: {
text: '三级节点的子节点'
},
children: []
}
]
)
// 插入多个子节点
mindMap.execCommand('INSERT_MULTI_CHILD_NODE', node, [
{
data: {
text: '三级节点'
},
children: []
},
{
data: {
text: '三级节点'
},
children: []
}
])
```
### 一次生成兄弟节点
```js
// 插入一个兄弟节点
mindMap.execCommand('INSERT_NODE',
false,
node,
{
data: {
text: '二级节点'
},
children: []
},
[
{
data: {
text: '二级节点的子节点'
},
children: []
}
]
)
// 插入多个兄弟节点
mindMap.execCommand('INSERT_MULTI_NODE', node, [
{
data: {
text: '二级节点'
},
children: []
},
{
data: {
text: '二级节点'
},
children: []
}
])
```
这样新创建的节点默认会被激活但不进入编辑,如果你连激活都不想要的话,那么可以通过将实例化选项`createNewNodeBehavior`设置为`notActive`
当自动生成结束后你又想恢复创建新节点时自动进入编辑状态,那么可以通过`updateConfig`方法修改`createNewNodeBehavior`
```js
mindMap.updateConfig({
createNewNodeBehavior: 'default'
})
```
### 完整示例
<iframe style="width: 100%; height: 455px; border: none;" src="https://wanglin2.github.io/playground/#eNrtV19rG0cQ/yrLliK5yCcl9EmVQ2LZUEPkFDd5yppwvhtJm97tHnd7lo0RlJDSNu1DoH0KFLdQaAntu/Pn40hWPkZmb3dPfw35Q/ySHBzszs78Zm5+M7t7J/RGkniHOdAmbWVByhNFMlB5co0JHicyVeSEpNCtESk6MhcKwhrJ+n4UycEedMmQdFMZkwoiVEqLDhdhx0/MEqMZiiNYj1G6HvsJo0wQwkQEimiZ1twgIo8iJpgIpMgUOgugnYKv4JaAdp9HYQoCtaprZOMaOdEARlHIEFBucTzUCiGF1OuiYBfXNo/v8LB6dU1bOCU4gqAt49gXYbWys/vt9t7te+2vd25u3du9tbVdqWFsBJ+uH2VQM2Ptxg4L5+YJfeU3ZwX6UXCkmqQyOvt58vyfV48eTB48w8y41aFF0U9gv6tJ7u4bqVu9O1VaQF/p8gK3kycPx/8/XgphMYzVoRRaZogSzB9Oltnp5JHil8FP587N2zvzLBWcuFRdBisf1AcT+xclGVtgM5WqD+mHzPCn2n+X2r8EYkzpfxxFjzmaT6VLTJ6gd2hL0eW9qg0hKGjYhUGRTej7h1ymGEsIXR+5wTCGDr08vKrL2PrwgYE7tBw4RE0SyiCPQSivB2o7Aj3cPN5BZqwlhqN8LiCtrNnvXEgRo1rA6FzWGNU500JGz/98ZnLG6EymGM15qBWuONk0j4y6PGqFi5plpeNF56Pnv5aczfmfi+HqrHy+dxZiWe6eon9m7bjgak9KpRn7RmZccanroRJBV2F1VwJMMaZz36pfxLCQ6kag+KG+cyD42leG6lbd3GDw7oITBXjtQHOcEdIK+SEJIj/LNhi19G1BLBktlq0CD6erJbmo0qrj6qyiQ1JSRge+VnEf3DrIlZKCXA8iHnyHKiuvMmgwOvv+/L+/Jr+fnv/0GMejs6ejs19KPlp1g/MmuHOH8ALy+O8n74E8PXlWBjz+4eH45ek7Brwa2MT7dsC4aSDKqx+fjh/9a1AmL347/+N0wXJKohu16jM1gtNMHUemXK7bmyyjXt1cX+324EEWe0GWMYo1p2+xhHgz5eTabcBD1cf+bTQ+L/QIScpqTwE9Yu0WC0Wj6PezxbJzUFND/yCTUa6MISG6Z5qkYWdKJtPJsvs+8F4f1b9sNJIj53m13y+c59hPexz9OtTED0Muek5Qhu7ZLnjDiK+4CGzQ5RwBsYMLDmiNGgb0D4N3P5MC/08KeGYXkIFyc2MUfz/MnubVceiluNfzGDRZ6wepHGR47N5HC7utrPglMbbLVGsrG9uQDl8Db1FoOA==" />

View File

@@ -0,0 +1,223 @@
<template>
<div>
<h1>如何实现AI生成节点内容</h1>
<p>目前AI能力非常流行每个应用都给自己加上了AI的能力提高竞争力那么在使用了<code>simple-mind-map</code>的情况下如何添加AI的能力呢本教程会详细的教你如何实现</p>
<p>首先要说明的是本教程并不会真的实现一个可用的AI能力只是在假设你要实现该功能的前提下来教你如何调用对应的API来实现你想要的效果</p>
<p>其次AI返回的数据结构不尽相同你都需要自行转换成<code>simple-mind-map</code>的结构类型</p>
<h2>自动生成整个思维导图</h2>
<h3>一次生成</h3>
<p>通过AI生成整个思维导图并且一次直接生成这个其实就是普通的回显功能那么你可以在实例化时通过<code>data</code>传入生成的数据</p>
<pre class="hljs"><code><span class="hljs-keyword">const</span> mindMap = <span class="hljs-keyword">new</span> MindMap({
el,
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;我是自动生成的节点&#x27;</span>
},
<span class="hljs-attr">children</span>: [
{
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;子节点&#x27;</span>
},
<span class="hljs-attr">children</span>: []
}
]
}
})
</code></pre>
<p>也可以在实例化之后使用<code>setData</code>方法设置</p>
<pre class="hljs"><code>mindMap.setData({
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;我是自动生成的节点&#x27;</span>
},
<span class="hljs-attr">children</span>: [
{
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;子节点&#x27;</span>
},
<span class="hljs-attr">children</span>: []
}
]
})
</code></pre>
<h3>依次生成节点</h3>
<p>如果你想像ChatGPT一样依次生成节点那么推荐使用<code>updateData</code>方法增量更新节点数据而不是手动获取到之前插入的节点实例再调用命令来插入下级节点这样会复杂很多当然如果你能轻松的知道当前创建到哪里了并且下一个节点在哪个节点下创建可以忽略</p>
<blockquote>
<p>updateData方法是v0.9.9+的方法之前的版本可以使用下面的方法</p>
</blockquote>
<pre class="hljs"><code><span class="hljs-keyword">const</span> updateData = <span class="hljs-function">(<span class="hljs-params">data</span>) =&gt;</span> {
mindMap.renderer.setData(data)
mindMap.render()
mindMap.command.addHistory()
}
</code></pre>
<p>增量更新的前提是之前生成的节点都存在<code>uid</code>并且不会变化这样调用<code>updateData</code>方法渲染时会根据<code>uid</code>来复用之前的节点只创建新的节点达到依次生成的目的</p>
<p>比如第一次返回的数据</p>
<pre class="hljs"><code><span class="hljs-keyword">const</span> data = {
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;根节点&#x27;</span>,
<span class="hljs-attr">uid</span>: <span class="hljs-string">&#x27;1&#x27;</span>
},
<span class="hljs-attr">children</span>: []
}
mindMap.setData(data)
</code></pre>
<p>第二次返回的数据</p>
<pre class="hljs"><code><span class="hljs-keyword">const</span> data = {
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;根节点&#x27;</span>,
<span class="hljs-attr">uid</span>: <span class="hljs-string">&#x27;1&#x27;</span>
},
<span class="hljs-attr">children</span>: [
{
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;二级节点&#x27;</span>,
<span class="hljs-attr">uid</span>: <span class="hljs-string">&#x27;2&#x27;</span>
},
<span class="hljs-attr">children</span>: []
}
]
}
mindMap.updateData(data)
</code></pre>
<p>以此类推这样虽然是整个数据更新但是因为复用的原因画布呈现的是依次生成新节点的效果</p>
<p>当生成的节点多了会有个问题就是新生成的节点在画布外看不见了所以我们要将新生成的节点移动到画布中心首先可以监听<code>data_change_detail</code>事件来获取到详细的更新数据找出其中新创建的节点数据然后使用<code>findNodeByUid</code>方法找出对应的节点实例最后调用<code>moveNodeToCenter</code>方法将该节点移动到画布中心即可</p>
<pre class="hljs"><code>mindMap.on(<span class="hljs-string">&#x27;data_change_detail&#x27;</span>, <span class="hljs-function">(<span class="hljs-params">list</span>) =&gt;</span> {
<span class="hljs-comment">// 找出新创建节点中的最后一个</span>
<span class="hljs-keyword">const</span> lastCreate = list.filter(<span class="hljs-function">(<span class="hljs-params">item</span>) =&gt;</span> {
<span class="hljs-keyword">return</span> item.action === <span class="hljs-string">&#x27;create&#x27;</span>
})[<span class="hljs-number">0</span>]
<span class="hljs-keyword">if</span> (lastCreate) {
<span class="hljs-keyword">const</span> uid = lastCreate.data.data.uid
<span class="hljs-keyword">const</span> node = mindMap.renderer.findNodeByUid(uid)
<span class="hljs-keyword">if</span> (node) {
mindMap.renderer.moveNodeToCenter(node)
}
}
})
</code></pre>
<p>当节点数据多了可能<code>data_change_detail</code>事件触发时节点树还没渲染完毕导致获取不到节点解决这个问题可以通过监听<code>node_tree_render_end</code>事件</p>
<pre class="hljs"><code><span class="hljs-keyword">let</span> waitUid = <span class="hljs-string">&#x27;&#x27;</span>
mindMap.on(<span class="hljs-string">&#x27;data_change_detail&#x27;</span>, <span class="hljs-function">(<span class="hljs-params">list</span>) =&gt;</span> {
<span class="hljs-comment">// ...</span>
<span class="hljs-keyword">if</span> (lastCreate) {
<span class="hljs-comment">// ...</span>
<span class="hljs-keyword">if</span> (node) {
mindMap.renderer.moveNodeToCenter(node)
} <span class="hljs-keyword">else</span> {
waitUid = uid
}
}
})
mindMap.on(<span class="hljs-string">&#x27;node_tree_render_end&#x27;</span>, <span class="hljs-function">() =&gt;</span>{
<span class="hljs-keyword">if</span> (waitUid) {
waitUid = <span class="hljs-string">&#x27;&#x27;</span>
<span class="hljs-keyword">const</span> node = mindMap.renderer.findNodeByUid(waitUid)
<span class="hljs-keyword">if</span> (node) {
mindMap.renderer.moveNodeToCenter(node)
}
}
})
</code></pre>
<p>当在<code>data_change_detail</code>事件中没有获取到节点实例就将该<code>uid</code>保存起来然后在<code>node_tree_render_end</code>事件里判断是否有保存的<code>uid</code>是的话就获取该节点实例并移动到画布中心</p>
<p>最后当自动生成节点中最好禁止用户操作否则可能会产生异常</p>
<h3>完整示例</h3>
<iframe style="width: 100%; height: 455px; border: none;" src="https://wanglin2.github.io/playground/#eNrtV19rHDcQ/ypiS9m95rx3bvN0vTOJnUILdVtC+uQNZr2ru1OqlZZdrc+HOQih0DT0IYUWSkto+9QSWvKSByct+TT2XT5GR7uS9t/ZxNBAoTHYXmlmfvObGWkkHVvX49g9zLA1sIZpkJBYoBSLLN7yGIlingh0jBI87iLOdnnGBA67KJ36lPLZTTxGCzROeIRsQLCNxS5h4a4fFyLPSmGa4o0IZjciP/YsjyHkMYoFknNSc4RYRqnHPBZwlgpwFuCdBPsCX6cUpE4HjbbQsTRUJi6wvOEL38knEQrhe1BoyB+Bj8QA2cv73y5/ePLyq8dnD35ffffz8v7D1Y9fvnxwb3XvGdCViotu8T+YEhommA3QnsYwYC30ioezPx/W8KqYDdzberaUX87Fu5fxUXzk40XHYzAuk4u355+y8xJcKEk6HxP4GOmEGGotpjrZvzxTqahwy0gIok3DvOTdZq1lr9FTqV7L9JrkG2enz79ZPf+t7a/0Wa1LvTLra2Oqo+rzv4q8ovMvEnnvTQkujrxu2nB2Docqj5Ovz+VRcrla49Lmc341ahWpVOW/vWTkv/xbnmVwLuEjaJf9sokmGav3VoTIGDmF5tbINFmXYjYR0w6ctCJLoFHnHHKIIEsAQivu5abKfQk1GoHbTpmJ5hkJIHAEFDJJdeYT8TkJAdg2SdA2nDm2dLcfTH02wfshFj6hdhc5FAhUQylJUj8VxWkCkFLNHRMqcOI4ROCoaYNUmEgKXT8QhEOaIAQ7yDGqp1xnr18pgIy49FUJuKQCtZUcjJIrYyn+gKitz3goSevooeYhTnACAbDwE5BtzyFRDpiaBGoi0rJBocyiwYn4IZY4t/gOhttTUpjVVh7CNMVNoLJEDdqVXWI+5QHfrqL0tC8SjPcLNvvwV9ZR1qPiTcaivDXCWbdMLps5jfzasndBOpqZ7fWMhyyGJYFbm6NFoL2DPFFXclrzAY8in4WuH4Yfwl7gyVzrKIYAeotEmGfCqfUGyIzczleu6CH0D2PaRZv9fj8f5TBKlt/rzN28ile5W+OZvpPr6zKmAxTyIIsgre4Eiw8olp/b849Cx1aWO5zB1mc4sTuqOTYarmfJCc9q9GDPkj1YTsNVP7/s1xusZ+n2KnWalz/CiLjJuZBl/4ynRHYH0LIpHgtYvXaQLwT7dq6+6LwPKYA0DHvF4wWeLTCAvhJTqC+MEBqG5BAF0BHSkWep0G7giHtWLlYKJCylJnBQGfZAWlXUSIJzeuBLFR3X8CATAlrZtYCS4AtQqb1iQPH05O7yj1+Ld8jy+6enJ4+Xdx+t/np69uTvs59eDHuF/UV4jYu7xHzx6NUxy2D017BXyRUMUzGnRdquqcecZ7m94gWnlpCL08gN0tSzIPfyIYeQW0mrXgszEorpQC7at3M9hGJTzQSDR3KIc0G+muXvW830a6jS0D9IOc1EYSjPsjGc9X01EjwuB233U0wmU1C/2u/HR9rzer/vaM+Rn0wI+NWoMexpwiZ6wlB31Wp4RcabmoEibcYACCs5r4HVtYoKyDezeyflDJ7oObynBFABs/M8C17gxZZze/DpQnsQ0GNksTYOEj5LoZndAQu1y9a8ygvbdqmlleK2sBb/AOBR7ZA=" />
<h2>在某个节点下自动生成新节点</h2>
<p>在某个节点下自动生成新节点如果也要依次生成那么可以使用前面的增量更新数据的方式如果一次生成那么可以简单的调用插入新节点的命令即可</p>
<h3>一次生成下级节点</h3>
<pre class="hljs"><code><span class="hljs-comment">// 插入一个子节点</span>
mindMap.execCommand(<span class="hljs-string">&#x27;INSERT_CHILD_NODE&#x27;</span>,
<span class="hljs-literal">false</span>,
node,
{
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;三级节点&#x27;</span>
},
<span class="hljs-attr">children</span>: []
},
[
{
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;三级节点的子节点&#x27;</span>
},
<span class="hljs-attr">children</span>: []
}
]
)
<span class="hljs-comment">// 插入多个子节点</span>
mindMap.execCommand(<span class="hljs-string">&#x27;INSERT_MULTI_CHILD_NODE&#x27;</span>, node, [
{
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;三级节点&#x27;</span>
},
<span class="hljs-attr">children</span>: []
},
{
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;三级节点&#x27;</span>
},
<span class="hljs-attr">children</span>: []
}
])
</code></pre>
<h3>一次生成兄弟节点</h3>
<pre class="hljs"><code><span class="hljs-comment">// 插入一个兄弟节点</span>
mindMap.execCommand(<span class="hljs-string">&#x27;INSERT_NODE&#x27;</span>,
<span class="hljs-literal">false</span>,
node,
{
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;二级节点&#x27;</span>
},
<span class="hljs-attr">children</span>: []
},
[
{
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;二级节点的子节点&#x27;</span>
},
<span class="hljs-attr">children</span>: []
}
]
)
<span class="hljs-comment">// 插入多个兄弟节点</span>
mindMap.execCommand(<span class="hljs-string">&#x27;INSERT_MULTI_NODE&#x27;</span>, node, [
{
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;二级节点&#x27;</span>
},
<span class="hljs-attr">children</span>: []
},
{
<span class="hljs-attr">data</span>: {
<span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;二级节点&#x27;</span>
},
<span class="hljs-attr">children</span>: []
}
])
</code></pre>
<p>这样新创建的节点默认会被激活但不进入编辑如果你连激活都不想要的话那么可以通过将实例化选项<code>createNewNodeBehavior</code>设置为<code>notActive</code></p>
<p>当自动生成结束后你又想恢复创建新节点时自动进入编辑状态那么可以通过<code>updateConfig</code>方法修改<code>createNewNodeBehavior</code></p>
<pre class="hljs"><code>mindMap.updateConfig({
<span class="hljs-attr">createNewNodeBehavior</span>: <span class="hljs-string">&#x27;default&#x27;</span>
})
</code></pre>
<h3>完整示例</h3>
<iframe style="width: 100%; height: 455px; border: none;" src="https://wanglin2.github.io/playground/#eNrtV19rG0cQ/yrLliK5yCcl9EmVQ2LZUEPkFDd5yppwvhtJm97tHnd7lo0RlJDSNu1DoH0KFLdQaAntu/Pn40hWPkZmb3dPfw35Q/ySHBzszs78Zm5+M7t7J/RGkniHOdAmbWVByhNFMlB5co0JHicyVeSEpNCtESk6MhcKwhrJ+n4UycEedMmQdFMZkwoiVEqLDhdhx0/MEqMZiiNYj1G6HvsJo0wQwkQEimiZ1twgIo8iJpgIpMgUOgugnYKv4JaAdp9HYQoCtaprZOMaOdEARlHIEFBucTzUCiGF1OuiYBfXNo/v8LB6dU1bOCU4gqAt49gXYbWys/vt9t7te+2vd25u3du9tbVdqWFsBJ+uH2VQM2Ptxg4L5+YJfeU3ZwX6UXCkmqQyOvt58vyfV48eTB48w8y41aFF0U9gv6tJ7u4bqVu9O1VaQF/p8gK3kycPx/8/XgphMYzVoRRaZogSzB9Oltnp5JHil8FP587N2zvzLBWcuFRdBisf1AcT+xclGVtgM5WqD+mHzPCn2n+X2r8EYkzpfxxFjzmaT6VLTJ6gd2hL0eW9qg0hKGjYhUGRTej7h1ymGEsIXR+5wTCGDr08vKrL2PrwgYE7tBw4RE0SyiCPQSivB2o7Aj3cPN5BZqwlhqN8LiCtrNnvXEgRo1rA6FzWGNU500JGz/98ZnLG6EymGM15qBWuONk0j4y6PGqFi5plpeNF56Pnv5aczfmfi+HqrHy+dxZiWe6eon9m7bjgak9KpRn7RmZccanroRJBV2F1VwJMMaZz36pfxLCQ6kag+KG+cyD42leG6lbd3GDw7oITBXjtQHOcEdIK+SEJIj/LNhi19G1BLBktlq0CD6erJbmo0qrj6qyiQ1JSRge+VnEf3DrIlZKCXA8iHnyHKiuvMmgwOvv+/L+/Jr+fnv/0GMejs6ejs19KPlp1g/MmuHOH8ALy+O8n74E8PXlWBjz+4eH45ek7Brwa2MT7dsC4aSDKqx+fjh/9a1AmL347/+N0wXJKohu16jM1gtNMHUemXK7bmyyjXt1cX+324EEWe0GWMYo1p2+xhHgz5eTabcBD1cf+bTQ+L/QIScpqTwE9Yu0WC0Wj6PezxbJzUFND/yCTUa6MISG6Z5qkYWdKJtPJsvs+8F4f1b9sNJIj53m13y+c59hPexz9OtTED0Muek5Qhu7ZLnjDiK+4CGzQ5RwBsYMLDmiNGgb0D4N3P5MC/08KeGYXkIFyc2MUfz/MnubVceiluNfzGDRZ6wepHGR47N5HC7utrPglMbbLVGsrG9uQDl8Db1FoOA==" />
</div>
</template>
<script>
export default {
}
</script>
<style>
</style>

View File

@@ -320,4 +320,28 @@
<img src="../../../../assets/avatar/pluvet.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>pluvet</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/皇登攀.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>皇登攀</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/风格.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>风格</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>SR</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/逆水行舟.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>逆水行舟</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>LiuJL</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/L.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>L</p>
</div>
</div>

View File

@@ -8,17 +8,17 @@
</blockquote>
<h2>特性</h2>
<ul>
<li><input type="checkbox" id="checkbox64" checked="true" /><label for="checkbox64">插件化架构除核心功能外其他功能作为插件提供按需使用减小打包体积</label></li>
<li><input type="checkbox" id="checkbox65" checked="true" /><label for="checkbox65">支持逻辑结构图思维导图组织结构图目录组织图时间轴横向竖向鱼骨图等结构</label></li>
<li><input type="checkbox" id="checkbox66" checked="true" /><label for="checkbox66">内置多种主题允许高度自定义样式支持注册新主题</label></li>
<li><input type="checkbox" id="checkbox67" checked="true" /><label for="checkbox67">节点内容支持文本普通文本富文本图片图标超链接备注标签概要数学公式</label></li>
<li><input type="checkbox" id="checkbox68" checked="true" /><label for="checkbox68">节点支持拖拽拖拽移动自由调整多种节点形状支持使用 DDM 完全自定义节点内容</label></li>
<li><input type="checkbox" id="checkbox69" checked="true" /><label for="checkbox69">支持画布拖动缩放</label></li>
<li><input type="checkbox" id="checkbox70" checked="true" /><label for="checkbox70">支持鼠标按键拖动选择和Ctrl+左键两种多选节点方式</label></li>
<li><input type="checkbox" id="checkbox71" checked="true" /><label for="checkbox71">支持导出为</label><code>json</code><code>png</code><code>svg</code><code>pdf</code><code>markdown</code><code>xmind</code>支持从<code>json</code><code>xmind</code><code>markdown</code>导入</li>
<li><input type="checkbox" id="checkbox72" checked="true" /><label for="checkbox72">支持快捷键前进后退关联线搜索替换小地图水印滚动条</label></li>
<li><input type="checkbox" id="checkbox73" checked="true" /><label for="checkbox73">提供丰富的配置满足各种场景各种使用习惯</label></li>
<li><input type="checkbox" id="checkbox74" checked="true" /><label for="checkbox74">支持协同编辑</label></li>
<li><input type="checkbox" id="checkbox32" checked="true" /><label for="checkbox32">插件化架构除核心功能外其他功能作为插件提供按需使用减小打包体积</label></li>
<li><input type="checkbox" id="checkbox33" checked="true" /><label for="checkbox33">支持逻辑结构图思维导图组织结构图目录组织图时间轴横向竖向鱼骨图等结构</label></li>
<li><input type="checkbox" id="checkbox34" checked="true" /><label for="checkbox34">内置多种主题允许高度自定义样式支持注册新主题</label></li>
<li><input type="checkbox" id="checkbox35" checked="true" /><label for="checkbox35">节点内容支持文本普通文本富文本图片图标超链接备注标签概要数学公式</label></li>
<li><input type="checkbox" id="checkbox36" checked="true" /><label for="checkbox36">节点支持拖拽拖拽移动自由调整多种节点形状支持使用 DDM 完全自定义节点内容</label></li>
<li><input type="checkbox" id="checkbox37" checked="true" /><label for="checkbox37">支持画布拖动缩放</label></li>
<li><input type="checkbox" id="checkbox38" checked="true" /><label for="checkbox38">支持鼠标按键拖动选择和Ctrl+左键两种多选节点方式</label></li>
<li><input type="checkbox" id="checkbox39" checked="true" /><label for="checkbox39">支持导出为</label><code>json</code><code>png</code><code>svg</code><code>pdf</code><code>markdown</code><code>xmind</code>支持从<code>json</code><code>xmind</code><code>markdown</code>导入</li>
<li><input type="checkbox" id="checkbox40" checked="true" /><label for="checkbox40">支持快捷键前进后退关联线搜索替换小地图水印滚动条</label></li>
<li><input type="checkbox" id="checkbox41" checked="true" /><label for="checkbox41">提供丰富的配置满足各种场景各种使用习惯</label></li>
<li><input type="checkbox" id="checkbox42" checked="true" /><label for="checkbox42">支持协同编辑</label></li>
</ul>
<blockquote>
<p>不会实现的特性</p>
@@ -32,11 +32,11 @@
<p>2.<code>web</code></p>
<p>使用<code>simple-mind-map</code>基于<code>vue2.x</code><code>ElementUI</code>搭建的在线思维导图特性</p>
<ul>
<li><input type="checkbox" id="checkbox75" checked="true" /><label for="checkbox75">工具栏支持插入节点删除节点编辑节点图片图标超链接备注标签概要</label></li>
<li><input type="checkbox" id="checkbox76" checked="true" /><label for="checkbox76">侧边栏基础样式设置面板节点样式设置面板大纲面板主题选择面板结构选择面板</label></li>
<li><input type="checkbox" id="checkbox77" checked="true" /><label for="checkbox77">导入导出功能数据默认保存在浏览器本地存储也支持直接创建打开编辑电脑本地文件</label></li>
<li><input type="checkbox" id="checkbox78" checked="true" /><label for="checkbox78">右键菜单支持展开收起整理布局等操作</label></li>
<li><input type="checkbox" id="checkbox79" checked="true" /><label for="checkbox79">底部栏支持节点数量字数统计支持切换编辑和只读模式支持放大缩小支持全屏切换支持小地图</label></li>
<li><input type="checkbox" id="checkbox43" checked="true" /><label for="checkbox43">工具栏支持插入节点删除节点编辑节点图片图标超链接备注标签概要</label></li>
<li><input type="checkbox" id="checkbox44" checked="true" /><label for="checkbox44">侧边栏基础样式设置面板节点样式设置面板大纲面板主题选择面板结构选择面板</label></li>
<li><input type="checkbox" id="checkbox45" checked="true" /><label for="checkbox45">导入导出功能数据默认保存在浏览器本地存储也支持直接创建打开编辑电脑本地文件</label></li>
<li><input type="checkbox" id="checkbox46" checked="true" /><label for="checkbox46">右键菜单支持展开收起整理布局等操作</label></li>
<li><input type="checkbox" id="checkbox47" checked="true" /><label for="checkbox47">底部栏支持节点数量字数统计支持切换编辑和只读模式支持放大缩小支持全屏切换支持小地图</label></li>
</ul>
<p>提供文档页面服务</p>
<p>3.<code>dist</code></p>
@@ -275,6 +275,30 @@
<img src="../../../../assets/avatar/pluvet.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>pluvet</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/皇登攀.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>皇登攀</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/风格.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>风格</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>SR</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/逆水行舟.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>逆水行舟</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/default.png" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>LiuJL</p>
</div>
<div style="display: flex; flex-direction: column; align-items: center; width: fit-content; margin: 5px;">
<img src="../../../../assets/avatar/L.jpg" style="width: 50px;height: 50px;object-fit: cover;border-radius: 50%;" />
<p>L</p>
</div>
</div>
</div>
</template>

View File

@@ -56,6 +56,12 @@
## 方法
### getAncestorNodes()
> v0.9.9+
获取祖先节点实例列表。
### highlight()
> v0.9.8+

View File

@@ -31,6 +31,11 @@
</blockquote>
<p>节点是否正在拖拽中</p>
<h2>方法</h2>
<h3>getAncestorNodes()</h3>
<blockquote>
<p>v0.9.9+</p>
</blockquote>
<p>获取祖先节点实例列表</p>
<h3>highlight()</h3>
<blockquote>
<p>v0.9.8+</p>

View File

@@ -0,0 +1,56 @@
# RainbowLines插件
> v0.9.9+
该插件用于实现彩虹线条。
开启彩虹线条及自定义颜色可以通过实例化选项`rainbowLinesConfig`设置。
默认的颜色列表如下:
```
[
'rgb(255, 213, 73)',
'rgb(255, 136, 126)',
'rgb(107, 225, 141)',
'rgb(151, 171, 255)',
'rgb(129, 220, 242)',
'rgb(255, 163, 125)',
'rgb(152, 132, 234)'
]
```
## 注册
```js
import MindMap from 'simple-mind-map'
import RainbowLines from 'simple-mind-map/src/plugins/RainbowLines.js'
MindMap.usePlugin(RainbowLines)
```
注册完且实例化`MindMap`后可通过`mindMap.rainbowLines`获取到该实例。
## 方法
### updateRainLinesConfig(config = {})
如果你在通过实例化选项`rainbowLinesConfig`设置了彩虹线条后想修改,那么可以使用该方法,参数`config``rainbowLinesConfig`
```js
{
open: false,// 是否开启彩虹线条
colorsList: []// 自定义彩虹线条的颜色列表,如果不设置,会使用默认颜色列表
}
```
### getColorsList()
获取当前使用的彩虹线条颜色列表。
### getNodeColor(node)
获取指定的节点实例对应的彩虹线条颜色。
### getSecondLayerAncestor(node)
获取一个节点实例的第二层级的祖先节点实例。

View File

@@ -0,0 +1,52 @@
<template>
<div>
<h1>RainbowLines插件</h1>
<blockquote>
<p>v0.9.9+</p>
</blockquote>
<p>该插件用于实现彩虹线条</p>
<p>开启彩虹线条及自定义颜色可以通过实例化选项<code>rainbowLinesConfig</code>设置</p>
<p>默认的颜色列表如下</p>
<pre class="hljs"><code>[
'rgb(255, 213, 73)',
'rgb(255, 136, 126)',
'rgb(107, 225, 141)',
'rgb(151, 171, 255)',
'rgb(129, 220, 242)',
'rgb(255, 163, 125)',
'rgb(152, 132, 234)'
]
</code></pre>
<h2>注册</h2>
<pre class="hljs"><code><span class="hljs-keyword">import</span> MindMap <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;simple-mind-map&#x27;</span>
<span class="hljs-keyword">import</span> RainbowLines <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;simple-mind-map/src/plugins/RainbowLines.js&#x27;</span>
MindMap.usePlugin(RainbowLines)
</code></pre>
<p>注册完且实例化<code>MindMap</code>后可通过<code>mindMap.rainbowLines</code>获取到该实例</p>
<h2>方法</h2>
<h3>updateRainLinesConfig(config = {})</h3>
<p>如果你在通过实例化选项<code>rainbowLinesConfig</code>设置了彩虹线条后想修改那么可以使用该方法参数<code>config</code><code>rainbowLinesConfig</code></p>
<pre class="hljs"><code>{
<span class="hljs-attr">open</span>: <span class="hljs-literal">false</span>,<span class="hljs-comment">// 是否开启彩虹线条</span>
<span class="hljs-attr">colorsList</span>: []<span class="hljs-comment">// 自定义彩虹线条的颜色列表,如果不设置,会使用默认颜色列表</span>
}
</code></pre>
<h3>getColorsList()</h3>
<p>获取当前使用的彩虹线条颜色列表</p>
<h3>getNodeColor(node)</h3>
<p>获取指定的节点实例对应的彩虹线条颜色</p>
<h3>getSecondLayerAncestor(node)</h3>
<p>获取一个节点实例的第二层级的祖先节点实例</p>
</div>
</template>
<script>
export default {
}
</script>
<style>
</style>

View File

@@ -273,6 +273,50 @@
>
</div>
</div>
<!-- 彩虹线条 -->
<div class="title noTop">{{ $t('baseStyle.rainbowLines') }}</div>
<div class="row">
<div class="rowItem">
<el-popover
placement="right"
trigger="click"
v-model="rainbowLinesPopoverVisible"
>
<div class="rainbowLinesOptionsBox" :class="{ isDark: isDark }">
<div
class="optionItem"
v-for="item in rainbowLinesOptions"
:key="item.value"
>
<div
class="colorsBar"
v-if="item.list"
@click="updateRainbowLinesConfig(item)"
>
<span
class="colorItem"
v-for="color in item.list"
:style="{ backgroundColor: color }"
></span>
</div>
<span v-else @click="updateRainbowLinesConfig(item)">{{
$t('baseStyle.notUseRainbowLines')
}}</span>
</div>
</div>
<div slot="reference" class="curRainbowLine">
<div class="colorsBar" v-if="curRainbowLineColorList">
<span
class="colorItem"
v-for="color in curRainbowLineColorList"
:style="{ backgroundColor: color }"
></span>
</div>
<span v-else>{{ $t('baseStyle.notUseRainbowLines') }}</span>
</div>
</el-popover>
</div>
</div>
<!-- 概要连线 -->
<div class="title noTop">{{ $t('baseStyle.lineOfOutline') }}</div>
<div class="row">
@@ -914,7 +958,8 @@ import {
supportLineStyleLayoutsMap,
supportLineRadiusLayouts,
supportNodeUseLineStyleLayouts,
supportRootLineKeepSameInCurveLayouts
supportRootLineKeepSameInCurveLayouts,
rainbowLinesOptions
} from '@/config/constant'
/**
@@ -940,6 +985,7 @@ export default {
},
data() {
return {
rainbowLinesOptions,
lineWidthList,
fontSizeList,
activeTab: 'color',
@@ -994,6 +1040,8 @@ export default {
fontSize: 1
}
},
rainbowLinesPopoverVisible: false,
curRainbowLineColorList: null,
updateWatermarkTimer: null,
enableNodeRichText: true,
localConfigs: {
@@ -1069,6 +1117,7 @@ export default {
this.initStyle()
this.initConfig()
this.initWatermark()
this.initRainbowLines()
this.currentLayout = this.mindMap.getLayout()
} else {
this.$refs.sidebar.show = false
@@ -1180,6 +1229,16 @@ export default {
this.watermarkConfig.textStyle = { ...config.textStyle }
},
// 初始化彩虹线条配置
initRainbowLines() {
const config = this.mindMap.getConfig('rainbowLinesConfig') || {}
this.curRainbowLineColorList = config.open
? this.mindMap.rainbowLines
? this.mindMap.rainbowLines.getColorsList()
: null
: null
},
/**
* @Author: 王林
* @Date: 2021-07-03 22:27:32
@@ -1245,6 +1304,29 @@ export default {
}, 300)
},
// 更新彩虹线条配置
updateRainbowLinesConfig(item) {
this.rainbowLinesPopoverVisible = false
this.curRainbowLineColorList = item.list || null
this.data.config = this.data.config || {}
let newConfig = null
if (item.list) {
newConfig = {
open: true,
colorsList: item.list
}
} else {
newConfig = {
open: false
}
}
this.data.config.rainbowLinesConfig = newConfig
this.mindMap.rainbowLines.updateRainLinesConfig(newConfig)
storeConfig({
config: this.data.config
})
},
// 设置margin
updateMargin(type, value) {
this.style[type] = value
@@ -1303,7 +1385,8 @@ export default {
.row {
.rowItem {
.name {
.name,
.curRainbowLine {
color: hsla(0, 0%, 100%, 0.6);
}
}
@@ -1365,6 +1448,17 @@ export default {
border-radius: 4px;
cursor: pointer;
}
.curRainbowLine {
height: 24px;
border: 1px solid #dcdfe6;
font-size: 12px;
width: 240px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
}
.styleBtn {
@@ -1437,4 +1531,43 @@ export default {
}
}
}
.rainbowLinesOptionsBox {
width: 200px;
&.isDark {
.optionItem {
color: hsla(0, 0%, 100%, 0.6);
&:hover {
background-color: hsla(0, 0%, 100%, 0.05);
}
}
}
.optionItem {
width: 100%;
height: 30px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
&:hover {
background-color: #f5f7fa;
}
}
}
.colorsBar {
display: flex;
width: 100%;
height: 100%;
align-items: center;
.colorItem {
flex: 1;
height: 15px;
}
}
</style>

View File

@@ -70,6 +70,7 @@ export default {
* @Desc: 遍历
*/
walk(data) {
if (!data) return
this.num++
this.textStr += String(data.data.text) || ''
if (data.children && data.children.length > 0) {

View File

@@ -24,6 +24,7 @@
<OutlineEdit v-if="mindMap" :mindMap="mindMap"></OutlineEdit>
<Scrollbar v-if="isShowScrollbar && mindMap" :mindMap="mindMap"></Scrollbar>
<FormulaSidebar v-if="mindMap" :mindMap="mindMap"></FormulaSidebar>
<SourceCodeEdit v-if="mindMap" :mindMap="mindMap"></SourceCodeEdit>
</div>
</template>
@@ -45,7 +46,10 @@ import SearchPlugin from 'simple-mind-map/src/plugins/Search.js'
import Painter from 'simple-mind-map/src/plugins/Painter.js'
import ScrollbarPlugin from 'simple-mind-map/src/plugins/Scrollbar.js'
import Formula from 'simple-mind-map/src/plugins/Formula.js'
import Cooperate from 'simple-mind-map/src/plugins/Cooperate.js'
import RainbowLines from 'simple-mind-map/src/plugins/RainbowLines.js'
// 协同编辑插件
// import Cooperate from 'simple-mind-map/src/plugins/Cooperate.js'
// 手绘风格插件,该插件为付费插件,详情请查看开发文档
// import HandDrawnLikeStyle from 'simple-mind-map-plugin-handdrawnlikestyle'
import OutlineSidebar from './OutlineSidebar'
import Style from './Style'
@@ -80,6 +84,7 @@ import handleClipboardText from '@/utils/handleClipboardText'
import Scrollbar from './Scrollbar.vue'
import exampleData from 'simple-mind-map/example/exampleData'
import FormulaSidebar from './FormulaSidebar.vue'
import SourceCodeEdit from './SourceCodeEdit.vue'
// 注册插件
MindMap.usePlugin(MiniMap)
@@ -96,6 +101,7 @@ MindMap.usePlugin(MiniMap)
.usePlugin(SearchPlugin)
.usePlugin(Painter)
.usePlugin(Formula)
.usePlugin(RainbowLines)
// .usePlugin(Cooperate) // 协同插件
// 注册自定义主题
@@ -130,7 +136,8 @@ export default {
NodeIconToolbar,
OutlineEdit,
Scrollbar,
FormulaSidebar
FormulaSidebar,
SourceCodeEdit
},
data() {
return {
@@ -149,7 +156,8 @@ export default {
useLeftKeySelectionRightKeyDrag: state =>
state.localConfig.useLeftKeySelectionRightKeyDrag,
isUseHandDrawnLikeStyle: state =>
state.localConfig.isUseHandDrawnLikeStyle
state.localConfig.isUseHandDrawnLikeStyle,
extraTextOnExport: state => state.extraTextOnExport
})
},
watch: {
@@ -341,12 +349,62 @@ export default {
console.error(err)
switch (code) {
case 'export_error':
this.$message.error('导出失败')
this.$message.error(this.$t('edit.exportError'))
break
default:
break
}
},
addContentToFooter: () => {
const text = this.extraTextOnExport.trim()
if (!text) return null
const el = document.createElement('div')
el.className = 'footer'
el.innerHTML = text
const cssText = `
.footer {
width: 100%;
height: 30px;
display: flex;
justify-content: center;
align-items: center;
font-size: 12px;
color: #979797;
}
`
return {
el,
cssText,
height: 30
}
}
// addContentToHeader: () => {
// const el = document.createElement('div')
// el.className = 'footer'
// el.innerHTML = '理想青年实验室'
// const cssText = `
// .header {
// width: 100%;
// height: 50px;
// background: #f5f5f5;
// display: flex;
// justify-content: center;
// align-items: center
// }
// `
// return {
// el,
// cssText,
// height: 50
// }
// },
// beforeShortcutRun: (key, activeNodeList) => {
// console.log(key, activeNodeList)
// // 阻止删除快捷键行为
// if (key === 'Backspace') {
// return true
// }
// }
// handleNodePasteImg: img => {
// console.log(img)
// return new Promise(resolve => {
@@ -701,7 +759,7 @@ export default {
if (this.mindMap.cooperate && this.$route.query.userName) {
this.mindMap.cooperate.setProvider(null, {
roomName: 'demo-room',
signalingList: ['ws://10.16.83.11:4444']
signalingList: ['ws://10.16.83.118:4444']
})
this.mindMap.cooperate.setUserInfo({
id: Math.random(),

View File

@@ -50,6 +50,16 @@
@keydown.native.stop
></el-input>
</div>
<div class="paddingInputGroup">
<span class="name">{{ this.$t('export.addFooterText') }}</span>
<el-input
style="width: 200px"
v-model="extraText"
size="mini"
:placeholder="$t('export.addFooterTextPlaceholder')"
@keydown.native.stop
></el-input>
</div>
<div class="paddingInputGroup">
<el-checkbox
v-show="['png', 'pdf'].includes(exportType)"
@@ -85,7 +95,7 @@
</template>
<script>
import { mapState } from 'vuex'
import { mapState, mapMutations } from 'vuex'
import { downTypeList } from '@/config'
import { isMobile } from 'simple-mind-map/src/utils/index'
@@ -107,6 +117,7 @@ export default {
loadingText: '',
paddingX: 10,
paddingY: 10,
extraText: '',
isMobile: isMobile()
}
},
@@ -127,6 +138,8 @@ export default {
this.$bus.$off('showExport', this.handleShowExport)
},
methods: {
...mapMutations(['setExtraTextOnExport']),
handleShowExport() {
this.dialogVisible = true
},
@@ -153,6 +166,7 @@ export default {
* @Desc: 确定
*/
confirm() {
this.setExtraTextOnExport(this.extraText)
if (this.exportType === 'svg') {
this.$bus.$emit(
'export',

View File

@@ -34,7 +34,7 @@
import Sidebar from './Sidebar'
import { mapState, mapMutations } from 'vuex'
import { formulaList } from '@/config/constant'
import 'simple-mind-map/node_modules/katex/dist/katex.min.css'
import 'katex/dist/katex.min.css'
export default {
name: 'FormulaSidebar',

View File

@@ -80,6 +80,15 @@
@click="toggleDark"
></div>
</div>
<div class="item">
<el-tooltip
effect="dark"
:content="$t('navigatorToolbar.changeSourceCodeEdit')"
placement="top"
>
<div class="btn iconfont iconyuanma" @click="openSourceCodeEdit"></div>
</el-tooltip>
</div>
<div class="item">
<el-dropdown @command="handleCommand">
<div class="btn iconfont iconbangzhu"></div>
@@ -141,7 +150,7 @@ export default {
this.lang = getLang()
},
methods: {
...mapMutations(['setLocalConfig', 'setIsReadonly']),
...mapMutations(['setLocalConfig', 'setIsReadonly', 'setIsOutlineEdit']),
readonlyChange() {
this.setIsReadonly(!this.isReadonly)
@@ -198,6 +207,10 @@ export default {
backToRoot() {
this.mindMap.renderer.setRootNodeCenter()
},
openSourceCodeEdit() {
this.setIsOutlineEdit(true)
}
}
}

View File

@@ -35,7 +35,6 @@ export default {
computed: {
...mapState({
isDark: state => state.localConfig.isDark,
isOutlineEdit: state => state.isOutlineEdit,
activeSidebar: state => state.activeSidebar
})
},

View File

@@ -0,0 +1,216 @@
<template>
<div
class="sourceCodeEditContainer"
:class="{ isDark: isDark }"
ref="sourceCodeEditContainer"
v-if="isSourceCodeEdit"
>
<div class="closeBtn">
<el-tooltip
effect="dark"
:content="$t('sourceCodeEdit.copy')"
placement="top"
>
<span
class="icon iconfont iconfuzhi"
style="font-size: 26px"
@click="copy"
></span>
</el-tooltip>
<el-tooltip
effect="dark"
:content="$t('sourceCodeEdit.format')"
placement="top"
>
<span
class="icon iconfont icongeshihua"
style="font-size: 24px"
@click="format"
></span>
</el-tooltip>
<el-tooltip
effect="dark"
:content="$t('sourceCodeEdit.sourceCodeTip')"
placement="top"
>
<span class="icon el-icon-info"></span>
</el-tooltip>
<el-tooltip
effect="dark"
:content="$t('sourceCodeEdit.confirm')"
placement="top"
>
<span class="icon el-icon-circle-check" @click="onConfirm"></span>
</el-tooltip>
<el-tooltip
effect="dark"
:content="$t('sourceCodeEdit.close')"
placement="top"
>
<span class="icon iconfont iconguanbi" @click="onClose"></span>
</el-tooltip>
</div>
<div class="sourceCodeEditBox">
<div class="outlineEdit" ref="outlineEditRef" @keydown.stop></div>
</div>
</div>
</template>
<script>
import { mapState, mapMutations } from 'vuex'
import { storeData } from '@/api'
import CodeMirror from 'codemirror'
import 'codemirror/mode/javascript/javascript'
import 'codemirror/lib/codemirror.css'
import { copy } from '@/utils/index'
let editor = null
// 源码编辑
export default {
name: 'SourceCodeEdit',
props: {
mindMap: {
type: Object
}
},
data() {
return {}
},
computed: {
...mapState({
isReadonly: state => state.isReadonly,
isDark: state => state.localConfig.isDark,
isSourceCodeEdit: state => state.isSourceCodeEdit
})
},
watch: {
isSourceCodeEdit(val) {
if (val) {
this.$nextTick(() => {
document.body.appendChild(this.$refs.sourceCodeEditContainer)
this.initEditor()
this.initData()
})
}
}
},
methods: {
...mapMutations(['setIsOutlineEdit']),
// 初始化编辑器
initEditor() {
editor = CodeMirror(this.$refs.outlineEditRef, {
mode: { name: 'javascript', json: true },
lineWrapping: true,
lineNumbers: true
})
},
// 初始化数据
initData() {
editor.setValue(JSON.stringify(this.mindMap.getData(), null, 2))
},
// 完成
onConfirm() {
try {
const content = editor.getValue()
const data = JSON.parse(content)
this.setIsOutlineEdit(false)
this.$bus.$emit('setData', data)
} catch (error) {
console.log(error)
this.$message.error(this.$t('sourceCodeEdit.formatErrorTip'))
}
},
// 关闭
onClose() {
this.setIsOutlineEdit(false)
},
// 复制
copy() {
const content = editor.getValue()
copy(content)
this.$message.success(this.$t('sourceCodeEdit.copyTip'))
},
// 格式化
format() {
try {
const content = editor.getValue()
const data = JSON.parse(content)
editor.setValue(JSON.stringify(data, null, 2))
this.$message.success(this.$t('sourceCodeEdit.formatTip'))
} catch (error) {
console.log(error)
this.$message.error(this.$t('sourceCodeEdit.formatErrorTip'))
}
}
}
}
</script>
<style lang="less" scoped>
.sourceCodeEditContainer {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 1999;
background-color: #f5f5f5;
overflow: hidden;
&.isDark {
background-color: #262a2e;
.closeBtn {
.icon {
color: #fff;
}
}
}
.closeBtn {
position: absolute;
right: 40px;
top: 20px;
cursor: pointer;
display: flex;
align-items: center;
.icon {
font-size: 28px;
margin-left: 10px;
}
}
.sourceCodeEditBox {
width: 100%;
height: 100%;
overflow: hidden;
padding: 50px 0;
.outlineEdit {
width: 1000px;
height: 100%;
margin: 0 auto;
font-size: 17px;
background-color: #fff;
font-family: Menlo, Monaco, Consolas, Andale Mono, Ubuntu Mono,
Courier New, monospace;
padding: 12px;
border-radius: 5px;
/deep/ .CodeMirror {
height: 100%;
font-family: Menlo, Monaco, Consolas, Andale Mono, Ubuntu Mono,
Courier New, monospace;
}
}
}
}
</style>

View File

@@ -179,7 +179,7 @@ export default {
data() {
return {
activeNodes: [],
backEnd: false,
backEnd: true,
forwardEnd: true,
readonly: false,
isFullDataFile: false,

View File

@@ -42,11 +42,11 @@ export default {
dataList: [
{
icon: 'iconstar',
value: 'Github star数量2000+'
value: 'Github star数量3000+'
},
{
icon: 'iconfork',
value: 'Github fork数量250+'
value: 'Github fork数量400+'
},
{
icon: 'iconxiazai',
@@ -54,7 +54,7 @@ export default {
},
{
icon: 'iconteamwork',
value: '代码贡献者14+'
value: '代码贡献者16+'
}
],
functionList: [
@@ -149,6 +149,21 @@ export default {
icon: 'iconshezhi',
name: '丰富的设置',
value: '提供了丰富的功能设置,可以选择合适你的操作行为。'
},
{
icon: 'iconxietongwendang',
name: '协同编辑',
value: '支持协同编辑,方便多人同时编辑同一个文件。'
},
{
icon: 'icongongshi',
name: '数学公式',
value: '支持传入数学公式,省去截图的麻烦。'
},
{
icon: 'icongundongtiao',
name: '滚动条',
value: '支持显示滚动条,轻松拖动画布到指定位置。'
}
]
}

View File

@@ -25,7 +25,9 @@ const store = new Vuex.Store({
},
activeSidebar: '', // 当前显示的侧边栏
isOutlineEdit: false, // 是否是大纲编辑模式
isReadonly: false // 是否只读
isReadonly: false, // 是否只读
isSourceCodeEdit: false, // 是否是源码编辑模式
extraTextOnExport: ''// 导出时底部添加的文字
},
mutations: {
// 设置思维导图数据
@@ -60,6 +62,16 @@ const store = new Vuex.Store({
// 设置是否只读
setIsReadonly(state, data) {
state.isReadonly = data
},
// 设置源码编辑模式
setIsOutlineEdit(state, data) {
state.isSourceCodeEdit = data
},
// 设置导出时底部添加的文字
setExtraTextOnExport(state, data) {
state.extraTextOnExport = data
}
},
actions: {

View File

@@ -47,3 +47,13 @@ export const fileToBuffer = file => {
reader.readAsArrayBuffer(file)
})
}
// 复制文本到剪贴板
export const copy = (text) => {
const input = document.createElement('input')
input.setAttribute('value', text)
document.body.appendChild(input)
input.select()
document.execCommand('copy')
document.body.removeChild(input)
}

Some files were not shown because too many files have changed in this diff Show More