diff --git a/index.html b/index.html index 17f82518..0b8f00c0 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -
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. Fix: 1.Remove 修复:1.修复富文本模式下,如果选择了多个节点时设置文本样式,会将所有多选节点的文本改成最后一个多选节点的文本的问题。 新增:1.支持设置初始中心节点的位置。 修复:1.导出的
<\/p>$/, '')
- this.mindMap.renderer.activeNodeList.forEach(node => {
+ let list = nodes && nodes.length > 0 ? nodes : this.mindMap.renderer.activeNodeList
+ list.forEach(node => {
this.mindMap.execCommand('SET_NODE_TEXT', node, html, true)
if (node.isGeneralization) {
// 概要节点
@@ -170,7 +171,7 @@ class RichText {
this.mindMap.emit(
'hide_text_edit',
this.textEditNode,
- this.mindMap.renderer.activeNodeList
+ list
)
this.textEditNode.style.display = 'none'
this.showTextEdit = false
diff --git a/simple-mind-map/src/layouts/Base.js b/simple-mind-map/src/layouts/Base.js
index 0111c33a..dd6e1679 100644
--- a/simple-mind-map/src/layouts/Base.js
+++ b/simple-mind-map/src/layouts/Base.js
@@ -1,5 +1,5 @@
import Node from '../Node'
-import { CONSTANTS } from '../utils/constant'
+import { CONSTANTS, initRootNodePositionMap } from '../utils/constant'
// 布局基类
class Base {
@@ -122,10 +122,28 @@ class Base {
return newNode
}
+ // 格式化节点位置
+ formatPosition(value, size, nodeSize) {
+ if (typeof value === 'number') {
+ return value
+ } else if (initRootNodePositionMap[value] !== undefined) {
+ return size * initRootNodePositionMap[value]
+ } else if (/^\d\d*%$/.test(value)) {
+ return Number.parseFloat(value) / 100 * size
+ } else {
+ return (size - nodeSize) / 2
+ }
+ }
+
// 定位节点到画布中间
setNodeCenter(node) {
- node.left = (this.mindMap.width - node.width) / 2
- node.top = (this.mindMap.height - node.height) / 2
+ let { initRootNodePosition } = this.mindMap.opt
+ let { CENTER }= CONSTANTS.INIT_ROOT_NODE_POSITION
+ if (!initRootNodePosition || !Array.isArray(initRootNodePosition) || initRootNodePosition.length < 2) {
+ initRootNodePosition = [CENTER, CENTER]
+ }
+ node.left = this.formatPosition(initRootNodePosition[0], this.mindMap.width, node.width)
+ node.top = this.formatPosition(initRootNodePosition[1], this.mindMap.height, node.height)
}
// 更新子节点属性
diff --git a/simple-mind-map/src/utils/constant.js b/simple-mind-map/src/utils/constant.js
index 795fa79b..dc725247 100644
--- a/simple-mind-map/src/utils/constant.js
+++ b/simple-mind-map/src/utils/constant.js
@@ -154,9 +154,24 @@ export const CONSTANTS = {
MOUSE_WHEEL_ACTION: {
ZOOM: 'zoom',
MOVE: 'move'
+ },
+ INIT_ROOT_NODE_POSITION: {
+ LEFT: 'left',
+ TOP: 'top',
+ RIGHT: 'right',
+ BOTTOM: 'bottom',
+ CENTER: 'center'
}
}
+export const initRootNodePositionMap = {
+ [CONSTANTS.INIT_ROOT_NODE_POSITION.LEFT]: 0,
+ [CONSTANTS.INIT_ROOT_NODE_POSITION.TOP]: 0,
+ [CONSTANTS.INIT_ROOT_NODE_POSITION.RIGHT]: 1,
+ [CONSTANTS.INIT_ROOT_NODE_POSITION.BOTTOM]: 1,
+ [CONSTANTS.INIT_ROOT_NODE_POSITION.CENTER]: 0.5,
+}
+
// 布局结构列表
export const layoutList = [
{
diff --git a/web/src/pages/Doc/en/changelog/index.md b/web/src/pages/Doc/en/changelog/index.md
index 393e5764..a3cd9fd6 100644
--- a/web/src/pages/Doc/en/changelog/index.md
+++ b/web/src/pages/Doc/en/changelog/index.md
@@ -1,5 +1,11 @@
# Changelog
+## 0.5.3
+
+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.
+
## 0.5.2
Fix: 1.Remove `uid` from exported `JSON` data; 2.Clear the node cache pool when re rendering.
diff --git a/web/src/pages/Doc/en/changelog/index.vue b/web/src/pages/Doc/en/changelog/index.vue
index f4e01aed..83f89526 100644
--- a/web/src/pages/Doc/en/changelog/index.vue
+++ b/web/src/pages/Doc/en/changelog/index.vue
@@ -1,6 +1,9 @@
Changelog
+0.5.3
+0.5.2
uid from exported JSON data; 2.Clear the node cache pool when re rendering.0.5.1
diff --git a/web/src/pages/Doc/en/constructor/index.md b/web/src/pages/Doc/en/constructor/index.md
index 09eb4d29..82f66047 100644
--- a/web/src/pages/Doc/en/constructor/index.md
+++ b/web/src/pages/Doc/en/constructor/index.md
@@ -51,6 +51,7 @@ const mindMap = new MindMap({
| enableShortcutOnlyWhenMouseInSvg(v0.5.1+) | Boolean | true | Only respond to shortcut key events when the mouse is inside the canvas | |
| enableNodeTransitionMove(v0.5.1+) | Boolean | true | Whether to enable node animation transition | |
| nodeTransitionMoveDuration(v0.5.1+) | Number | 300 | If node animation transition is enabled, the transition time can be set using this attribute, in milliseconds | |
+| initRootNodePosition(v0.5.3+) | Array | ['center', 'center'] | The position of the initial root node can be passed as an array, default is `['center', 'center']`, Represents the root node at the center of the canvas, In addition to `center`, keywords can also be set to `left`, `top`, `right`, and `bottom`, In addition to passing keywords, each item in the array can also pass a number representing a specific pixel, Can pass a percentage string, such as `['40%', '60%']`, Represents a horizontal position at `40%` of the canvas width, and a vertical position at `60%` of the canvas height | |
### Watermark config
diff --git a/web/src/pages/Doc/en/constructor/index.vue b/web/src/pages/Doc/en/constructor/index.vue
index 281f9d7e..859de9e8 100644
--- a/web/src/pages/Doc/en/constructor/index.vue
+++ b/web/src/pages/Doc/en/constructor/index.vue
@@ -217,6 +217,13 @@
If node animation transition is enabled, the transition time can be set using this attribute, in milliseconds
+
+
initRootNodePosition(v0.5.3+)
+Array
+['center', 'center']
+The position of the initial root node can be passed as an array, default is
+['center', 'center'], Represents the root node at the center of the canvas, In addition to center, keywords can also be set to left, top, right, and bottom, In addition to passing keywords, each item in the array can also pass a number representing a specific pixel, Can pass a percentage string, such as ['40%', '60%'], Represents a horizontal position at 40% of the canvas width, and a vertical position at 60% of the canvas height
+ Watermark config
diff --git a/web/src/pages/Doc/zh/changelog/index.md b/web/src/pages/Doc/zh/changelog/index.md
index 2edda528..ee2db01a 100644
--- a/web/src/pages/Doc/zh/changelog/index.md
+++ b/web/src/pages/Doc/zh/changelog/index.md
@@ -1,5 +1,11 @@
# Changelog
+## 0.5.3
+
+修复:1.修复富文本模式下,如果选择了多个节点时设置文本样式,会将所有多选节点的文本改成最后一个多选节点的文本的问题。
+
+新增:1.支持设置初始中心节点的位置。
+
## 0.5.2
修复:1.导出的`json`数据中去除`uid`;2.重新渲染时清空节点缓存池。
diff --git a/web/src/pages/Doc/zh/changelog/index.vue b/web/src/pages/Doc/zh/changelog/index.vue
index 301e73fe..10667b26 100644
--- a/web/src/pages/Doc/zh/changelog/index.vue
+++ b/web/src/pages/Doc/zh/changelog/index.vue
@@ -1,6 +1,9 @@
Changelog
+0.5.3
+0.5.2
json数据中去除uid;2.重新渲染时清空节点缓存池。0.5.1
diff --git a/web/src/pages/Doc/zh/constructor/index.md b/web/src/pages/Doc/zh/constructor/index.md
index dd2bf38e..d3b69053 100644
--- a/web/src/pages/Doc/zh/constructor/index.md
+++ b/web/src/pages/Doc/zh/constructor/index.md
@@ -51,6 +51,7 @@ const mindMap = new MindMap({
| enableShortcutOnlyWhenMouseInSvg(v0.5.1+) | Boolean | true | 是否只有当鼠标在画布内才响应快捷键事件 | |
| enableNodeTransitionMove(v0.5.1+) | Boolean | true | 是否开启节点动画过渡 | |
| nodeTransitionMoveDuration(v0.5.1+) | Number | 300 | 如果开启节点动画过渡,可以通过该属性设置过渡的时间,单位ms | |
+| initRootNodePosition(v0.5.3+) | Array | ['center', 'center'] | 初始根节点的位置,可传一个数组,默认为`['center', 'center']`,代表根节点处于画布中心位置,除了`center`,关键词还可以设置`left`、`top`、`right`、`bottom`,除了可以传关键词,数组的每项还可以传递一个数字,代表具体的像素,可以传递一个百分比字符串,比如`['40%', '60%']`,代表水平位置在画布宽度的`40%`的位置,垂直位置在画布高度的`60%`的位置 | |
### 水印配置
diff --git a/web/src/pages/Doc/zh/constructor/index.vue b/web/src/pages/Doc/zh/constructor/index.vue
index 346da9d5..5048e4ee 100644
--- a/web/src/pages/Doc/zh/constructor/index.vue
+++ b/web/src/pages/Doc/zh/constructor/index.vue
@@ -217,6 +217,13 @@
如果开启节点动画过渡,可以通过该属性设置过渡的时间,单位ms
+
+
initRootNodePosition(v0.5.3+)
+Array
+['center', 'center']
+初始根节点的位置,可传一个数组,默认为
+['center', 'center'],代表根节点处于画布中心位置,除了center,关键词还可以设置left、top、right、bottom,除了可以传关键词,数组的每项还可以传递一个数字,代表具体的像素,可以传递一个百分比字符串,比如['40%', '60%'],代表水平位置在画布宽度的40%的位置,垂直位置在画布高度的60%的位置
+ 水印配置