diff --git a/README.md b/README.md index 001334b2..29f08922 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ # 特性 - [x] 插件化架构,除核心功能外,其他功能作为插件提供,按需使用,减小打包体积 -- [x] 支持逻辑结构图、思维导图、组织结构图、目录组织图四种结构 +- [x] 支持逻辑结构图、思维导图、组织结构图、目录组织图、时间轴、鱼骨图六种结构 - [x] 内置多种主题,允许高度自定义样式,支持注册新主题 - [x] 支持快捷键 - [x] 节点内容支持图片、图标、超链接、备注、标签、概要 diff --git a/index.html b/index.html index dbc59c96..17221fbc 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -
New: 1.Add new themes.
+New: 1.Add new themes. 2.Added timeline and fishbone structure.
+Fix: 1.Fix the conflict issue between node right-click and canvas right-click. 2.Fix the bug that the line segment is not hidden when dragging nodes such as organizational chart and directory organization chart.
+optimization: 1.Optimize the layout of organizational chart. 2.Optimize the layout of the directory organization chart.
Fix: 1.Fixed the issue of setting the text style when multiple nodes were selected in rich text mode, which would change the text of all selected nodes to the text of the last selected node.
New: 1.Support setting the position of the initial central node.
diff --git a/web/src/pages/Doc/en/constructor/index.md b/web/src/pages/Doc/en/constructor/index.md index 0a84f272..05d38c83 100644 --- a/web/src/pages/Doc/en/constructor/index.md +++ b/web/src/pages/Doc/en/constructor/index.md @@ -26,7 +26,8 @@ const mindMap = new MindMap({ | -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | -------- | | el | Element | | Container element, must be a DOM element | Yes | | data | Object | {} | Mind map data, refer to: https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/example/exampleData.js | | -| layout | String | logicalStructure | Layout type, options: logicalStructure (logical structure diagram), mindMap (mind map), catalogOrganization (catalog organization diagram), organizationStructure (organization structure diagram) | | +| layout | String | logicalStructure | Layout type, options: logicalStructure (logical structure diagram), mindMap (mind map), catalogOrganization (catalog organization diagram), organizationStructure (organization structure diagram)、timeline(v0.5.4+, timeline)、timeline2(v0.5.4+, up down alternating timeline)、fishbone(v0.5.4+, fishbone diagram) | | +| fishboneDeg(v0.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+) | | | themeConfig | Object | {} | Theme configuration, will be merged with the selected theme, available fields refer to: https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/src/themes/default.js | | | scaleRatio | Number | 0.1 | The incremental scaling ratio | | diff --git a/web/src/pages/Doc/en/constructor/index.vue b/web/src/pages/Doc/en/constructor/index.vue index a407759d..b345d449 100644 --- a/web/src/pages/Doc/en/constructor/index.vue +++ b/web/src/pages/Doc/en/constructor/index.vue @@ -46,7 +46,14 @@新增:1.添加新主题。
+新增:1.添加新主题。 2.新增时间轴和鱼骨结构。
+修复:1.修复节点右键和画布右键的冲突问题。 2.修复组织结构图、目录组织图等节点拖拽时存在线段未隐藏的bug。
+优化:1.优化组织结构图布局。2.优化目录组织图布局。
修复:1.修复富文本模式下,如果选择了多个节点时设置文本样式,会将所有多选节点的文本改成最后一个多选节点的文本的问题。
新增:1.支持设置初始中心节点的位置。
diff --git a/web/src/pages/Doc/zh/constructor/index.md b/web/src/pages/Doc/zh/constructor/index.md index 4a6337b0..1c9d232a 100644 --- a/web/src/pages/Doc/zh/constructor/index.md +++ b/web/src/pages/Doc/zh/constructor/index.md @@ -26,7 +26,8 @@ const mindMap = new MindMap({ | -------------------------------- | ------- | ---------------- | ------------------------------------------------------------ | -------- | | el | Element | | 容器元素,必须为DOM元素 | 是 | | data | Object | {} | 思维导图数据,可参考:[https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/example/exampleData.js](https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/example/exampleData.js) | | -| layout | String | logicalStructure | 布局类型,可选列表:logicalStructure(逻辑结构图)、mindMap(思维导图)、catalogOrganization(目录组织图)、organizationStructure(组织结构图) | | +| layout | String | logicalStructure | 布局类型,可选列表:logicalStructure(逻辑结构图)、mindMap(思维导图)、catalogOrganization(目录组织图)、organizationStructure(组织结构图)、timeline(v0.5.4+,时间轴)、timeline2(v0.5.4+,上下交替型时间轴)、fishbone(v0.5.4+,鱼骨图) | | +| fishboneDeg(v0.5.4+) | Number | 45 | 设置鱼骨结构图的斜线角度 | | | theme | String | default | 主题,可选列表:default(默认)、classic(脑图经典)、minions(小黄人)、pinkGrape(粉红葡萄)、mint(薄荷)、gold(金色vip)、vitalityOrange(活力橙)、greenLeaf(绿叶)、dark2(暗色2)、skyGreen(天清绿)、classic2(脑图经典2)、classic3(脑图经典3)、classic4(脑图经典4,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+黑金) | | | themeConfig | Object | {} | 主题配置,会和所选择的主题进行合并,可用字段可参考:[https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/src/themes/default.js](https://github.com/wanglin2/mind-map/blob/main/simple-mind-map/src/themes/default.js) | | | scaleRatio | Number | 0.1 | 放大缩小的增量比例 | | diff --git a/web/src/pages/Doc/zh/constructor/index.vue b/web/src/pages/Doc/zh/constructor/index.vue index b39d2082..25864b6e 100644 --- a/web/src/pages/Doc/zh/constructor/index.vue +++ b/web/src/pages/Doc/zh/constructor/index.vue @@ -46,7 +46,14 @@编写中。。。
+右键菜单可以方便的完成一些功能,大体上分两种,一是在画布上点击右键,二是在节点上点击右键,两者的功能肯定是不一样的,甚至根节点和其他节点功能上也有些不同,比如根节点不能添加同级节点,也不能被删除等等。
+右键菜单的UI界面需要你自行开发,可以设置成绝对定位或固定定位,然后让它显示在鼠标右键点击的位置即可。
+首先监听node_contextmenu事件在右键点击节点时显示菜单:
// 当前右键点击的类型
+const type = ref('')
+// 如果点击的节点,那么代表被点击的节点
+const currentNode = shallowRef(null)
+// 菜单显示的位置
+const left = ref(0)
+const top = ref(0)
+// 是否显示菜单
+const show = ref(false)
+mindMap.on('node_contextmenu', (e, node) => {
+ type.value = 'node'
+ left.value = e.clientX + 10
+ top.value = e.clientY + 10
+ show.value = true
+ currentNode.value = node
+})
+
+你可以根据当前点击的节点来判断一些操作是否可用。比如根节点不能删除,不能插入同级节点,又比如同级第一个节点不能再被往上移,同级最后一个节点不能被往下移。
+对于画布的处理会比较麻烦,不能直接监听contextmenu事件,因为会和右键多选节点冲突,所以需要结合mousedown事件和mouseup事件来处理。
// 记录鼠标右键按下的位置
+const mousedownX = ref(0)
+const mousedownY = ref(0)
+const isMousedown = ref(false)
+
+mindMap.on('svg_mousedown', (e) => {
+ // 如果不是右键点击直接返回
+ if (e.which !== 3) {
+ return
+ }
+ mousedownX.value = e.clientX
+ mousedownY.value = e.clientY
+ isMousedown.value = true
+})
+
+mindMap.on('mouseup', (e) => {
+ if (!isMousedown.value) {
+ return
+ }
+ isMousedown.value = false
+ // 如果鼠标松开和按下的距离大于3,则不认为是点击事件
+ if (
+ Math.abs(mousedownX.value - e.clientX) > 3 ||
+ Math.abs(mousedownX.value - e.clientY) > 3
+ ) {
+ hide()
+ return
+ }
+ type.value = 'svg'
+ left.value = e.clientX + 10
+ top.value = e.clientY + 10
+ show.value = true
+})
+
+很简单,其实就是判断鼠标按下和松开的距离是否很小,是的话就认为是点击事件,否则应该是鼠标拖动。
+右键菜单显示了,肯定就需要隐藏,当左键点击了画布、左键点击了节点、左键点击了展开收起按钮时都需要隐藏右键菜单。
+const hide = () => {
+ show.value = false
+ left.value = 0
+ top.value = 0
+ type.value = ''
+}
+mindMap.on('node_click', hide)
+mindMap.on('draw_click', hide)
+mindMap.on('expand_btn_click', hide)
+
+接下来介绍一下复制、剪切、粘贴的实现。
+一般来说你的右键菜单中肯定也会添加这三个按钮,另外快捷键操作也是必不可少的,但是这三个快捷键是没有内置的,所以你需要自己注册一下:
+mindMap.keyCommand.addShortcut('Control+c', copy)
+mindMap.keyCommand.addShortcut('Control+v', paste)
+mindMap.keyCommand.addShortcut('Control+x', cut)
+
+如需删除调用removeShortcut方法即可。
接下来实现一下这三个方法:
+// 保存复制/剪切的节点的数据,后续可以原来粘贴
+let copyData = null
+
+const copy = () => {
+ copyData = mindMap.renderer.copyNode()
+}
+
+const cut = () => {
+ mindMap.execCommand('CUT_NODE', _copyData => {
+ copyData = _copyData
+ })
+}
+
+const paste = () => {
+ mindMap.execCommand('PASTE_NODE', copyData)
+}
+
+编写中。。。
++要支持节点富文本编辑需要使用富文本插件
+