From 7087b43d390dc369a7519c2089b0800a9de970eb Mon Sep 17 00:00:00 2001
From: wanglin2 <1013335014@qq.com>
Date: Wed, 8 Mar 2023 09:38:46 +0800
Subject: [PATCH 1/3] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=89=8D?=
=?UTF-8?q?=E8=BF=9B=E5=90=8E=E9=80=80=E6=B2=A1=E6=9C=89=E8=A7=A6=E5=8F=91?=
=?UTF-8?q?data=5Fchange=E4=BA=8B=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98?=
=?UTF-8?q?=EF=BC=9BFeature=EF=BC=9A=E9=BC=A0=E6=A0=87=E6=BB=9A=E8=BD=AE?=
=?UTF-8?q?=E4=BA=8B=E4=BB=B6=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
simple-mind-map/index.js | 9 ++++-
simple-mind-map/src/Command.js | 8 +++--
simple-mind-map/src/View.js | 23 ++++++++++---
web/src/lang/en_us.js | 5 ++-
web/src/lang/zh_cn.js | 5 ++-
web/src/pages/Edit/components/BaseStyle.vue | 37 ++++++++++++++++++---
6 files changed, 73 insertions(+), 14 deletions(-)
diff --git a/simple-mind-map/index.js b/simple-mind-map/index.js
index 1505df69..5e0bed02 100644
--- a/simple-mind-map/index.js
+++ b/simple-mind-map/index.js
@@ -61,7 +61,14 @@ const defaultOpt = {
}
},
// 达到该宽度文本自动换行
- textAutoWrapWidth: 500
+ textAutoWrapWidth: 500,
+ // 自定义鼠标滚轮事件处理
+ // 可以传一个函数,回调参数为事件对象
+ customHandleMousewheel: null,
+ // 鼠标滚动的行为,如果customHandleMousewheel传了自定义函数,这个属性不生效
+ mousewheelAction: 'zoom',// zoom(放大缩小)、move(上下移动)
+ // 当mousewheelAction设为move时,可以通过该属性控制鼠标滚动一下视图移动的步长,单位px
+ mousewheelMoveStep: 100
}
// 思维导图
diff --git a/simple-mind-map/src/Command.js b/simple-mind-map/src/Command.js
index f7d85b15..25ad3f33 100644
--- a/simple-mind-map/src/Command.js
+++ b/simple-mind-map/src/Command.js
@@ -98,7 +98,9 @@ class Command {
this.activeHistoryIndex,
this.history.length
)
- return simpleDeepClone(this.history[this.activeHistoryIndex])
+ let data = simpleDeepClone(this.history[this.activeHistoryIndex])
+ this.mindMap.emit('data_change', data)
+ return data
}
}
@@ -111,7 +113,9 @@ class Command {
if (this.activeHistoryIndex + step <= len - 1) {
this.activeHistoryIndex += step
this.mindMap.emit('back_forward', this.activeHistoryIndex)
- return simpleDeepClone(this.history[this.activeHistoryIndex])
+ let data = simpleDeepClone(this.history[this.activeHistoryIndex])
+ this.mindMap.emit('data_change', data)
+ return data
}
}
diff --git a/simple-mind-map/src/View.js b/simple-mind-map/src/View.js
index 244293a4..d2110c79 100644
--- a/simple-mind-map/src/View.js
+++ b/simple-mind-map/src/View.js
@@ -55,12 +55,25 @@ class View {
})
// 放大缩小视图
this.mindMap.event.on('mousewheel', (e, dir) => {
- // // 放大
- if (dir === 'down') {
- this.enlarge()
+ if (this.mindMap.opt.customHandleMousewheel && typeof this.mindMap.opt.customHandleMousewheel === 'function') {
+ return this.mindMap.opt.customHandleMousewheel(e)
+ }
+ if (this.mindMap.opt.mousewheelAction === 'zoom') {
+ // 放大
+ if (dir === 'down') {
+ this.enlarge()
+ } else {
+ // 缩小
+ this.narrow()
+ }
} else {
- // 缩小
- this.narrow()
+ // 上移
+ if (dir === 'down') {
+ this.translateY(-this.mindMap.opt.mousewheelMoveStep)
+ } else {
+ // 下移
+ this.translateY(this.mindMap.opt.mousewheelMoveStep)
+ }
}
})
}
diff --git a/web/src/lang/en_us.js b/web/src/lang/en_us.js
index fe0f116f..5c3427f2 100644
--- a/web/src/lang/en_us.js
+++ b/web/src/lang/en_us.js
@@ -35,7 +35,10 @@ export default {
watermarkAngle: 'Angle',
watermarkTextOpacity: 'Text opacity',
watermarkTextFontSize: 'Font size',
- isEnableNodeRichText: 'Enable node rich text editing'
+ isEnableNodeRichText: 'Enable node rich text editing',
+ mousewheelAction: 'Mouse wheel behavior',
+ zoomView: 'Zoom view',
+ moveViewUpDown: 'Move view up and down'
},
color: {
moreColor: 'More color'
diff --git a/web/src/lang/zh_cn.js b/web/src/lang/zh_cn.js
index 9596aefb..cbd64437 100644
--- a/web/src/lang/zh_cn.js
+++ b/web/src/lang/zh_cn.js
@@ -35,7 +35,10 @@ export default {
watermarkAngle: '旋转角度',
watermarkTextOpacity: '文字透明度',
watermarkTextFontSize: '文字字号',
- isEnableNodeRichText: '是否开启节点富文本编辑'
+ isEnableNodeRichText: '是否开启节点富文本编辑',
+ mousewheelAction: '鼠标滚轮行为',
+ zoomView: '缩放视图',
+ moveViewUpDown: '上下移动视图'
},
color: {
moreColor: '更多颜色'
diff --git a/web/src/pages/Edit/components/BaseStyle.vue b/web/src/pages/Edit/components/BaseStyle.vue
index 7177a3f8..4156585e 100644
--- a/web/src/pages/Edit/components/BaseStyle.vue
+++ b/web/src/pages/Edit/components/BaseStyle.vue
@@ -431,7 +431,26 @@
- {{ this.$t('baseStyle.isEnableNodeRichText') }}
+ {{ $t('baseStyle.isEnableNodeRichText') }}
+
+
+
+
+ {{ $t('baseStyle.mousewheelAction') }}
+ {
+ updateOtherConfig('mousewheelAction', value)
+ }
+ "
+ >
+
+
+
@@ -493,7 +512,8 @@ export default {
nodeUseLineStyle: false
},
config: {
- enableFreeDrag: false
+ enableFreeDrag: false,
+ mousewheelAction: 'zoom'
},
watermarkConfig: {
show: false,
@@ -541,6 +561,7 @@ export default {
},
created () {
this.enableNodeRichText = this.localConfig.openNodeRichText
+ this.mousewheelAction = this.localConfig.mousewheelAction
},
methods: {
...mapMutations(['setLocalConfig']),
@@ -579,7 +600,7 @@ export default {
// 初始化其他配置
initConfig() {
- ;['enableFreeDrag'].forEach(key => {
+ ;['enableFreeDrag', 'mousewheelAction'].forEach(key => {
this.config[key] = this.mindMap.getConfig(key)
})
},
@@ -686,7 +707,15 @@ export default {
this.setLocalConfig({
openNodeRichText: e
})
- }
+ },
+
+ // 切换鼠标滚轮的行为
+ mousewheelActionChange(e) {
+ this.setLocalConfig({
+ mousewheelAction: e
+ })
+ this.mindMap.updateConfig
+ },
}
}
From 00f9258a4d84989d309e30dd249de2cae380d6c3 Mon Sep 17 00:00:00 2001
From: wanglin2 <1013335014@qq.com>
Date: Wed, 8 Mar 2023 09:39:05 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
simple-mind-map/package.json | 2 +-
web/src/pages/Doc/en/changelog/index.md | 6 ++++++
web/src/pages/Doc/en/changelog/index.vue | 3 +++
web/src/pages/Doc/en/constructor/index.md | 3 +++
web/src/pages/Doc/en/constructor/index.vue | 21 +++++++++++++++++++++
web/src/pages/Doc/zh/changelog/index.md | 6 ++++++
web/src/pages/Doc/zh/changelog/index.vue | 3 +++
web/src/pages/Doc/zh/constructor/index.md | 3 +++
web/src/pages/Doc/zh/constructor/index.vue | 21 +++++++++++++++++++++
9 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/simple-mind-map/package.json b/simple-mind-map/package.json
index a7a6bd20..d6a21847 100644
--- a/simple-mind-map/package.json
+++ b/simple-mind-map/package.json
@@ -1,6 +1,6 @@
{
"name": "simple-mind-map",
- "version": "0.4.2",
+ "version": "0.4.3",
"description": "一个简单的web在线思维导图",
"authors": [
{
diff --git a/web/src/pages/Doc/en/changelog/index.md b/web/src/pages/Doc/en/changelog/index.md
index ce47c0c0..7e476b91 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.4.3
+
+Fix: No trigger after forward and backward `data_ Change` event.
+
+New: Support user-defined mouse wheel events; The mouse wheel is adjusted to support zooming and moving the view up and down.
+
## 0.4.2
New: The `setText` method of the Node class adds a second parameter to support setting rich text content.
diff --git a/web/src/pages/Doc/en/changelog/index.vue b/web/src/pages/Doc/en/changelog/index.vue
index 23f48957..0f9ee935 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.4.3
+
Fix: No trigger after forward and backward data_ Change event.
+
New: Support user-defined mouse wheel events; The mouse wheel is adjusted to support zooming and moving the view up and down.
0.4.2
New: The setText method of the Node class adds a second parameter to support setting rich text content.
0.4.1
diff --git a/web/src/pages/Doc/en/constructor/index.md b/web/src/pages/Doc/en/constructor/index.md
index 60621e58..bd0cead0 100644
--- a/web/src/pages/Doc/en/constructor/index.md
+++ b/web/src/pages/Doc/en/constructor/index.md
@@ -41,6 +41,9 @@ const mindMap = new MindMap({
| enableFreeDrag(v0.2.4+) | Boolean | false | Enable node free drag | |
| watermarkConfig(v0.2.4+) | Object | | Watermark config, Please refer to the table 【Watermark config】 below for detailed configuration | |
| textAutoWrapWidth(v0.3.4+) | Number | 500 | Each line of text in the node will wrap automatically when it reaches the width | |
+| customHandleMousewheel(v0.4.3+) | Function | null | User-defined mouse wheel event processing can pass a function, and the callback parameter is the event object | |
+| mousewheelAction(v0.4.3+) | String | zoom | The behavior of the mouse wheel, `zoom`(Zoom in and out)、`move`(Move up and down). If `customHandleMousewheel` passes a custom function, this property will not take effect | |
+| mousewheelMoveStep(v0.4.3+) | Number | 100 | When the `mousewheelAction` is set to `move`, you can use this attribute to control the step length of the view movement when the mouse scrolls. The unit is `px` | |
### Watermark config
diff --git a/web/src/pages/Doc/en/constructor/index.vue b/web/src/pages/Doc/en/constructor/index.vue
index 14df481d..2636449e 100644
--- a/web/src/pages/Doc/en/constructor/index.vue
+++ b/web/src/pages/Doc/en/constructor/index.vue
@@ -147,6 +147,27 @@
Each line of text in the node will wrap automatically when it reaches the width
+
+customHandleMousewheel(v0.4.3+)
+Function
+null
+User-defined mouse wheel event processing can pass a function, and the callback parameter is the event object
+
+
+
+mousewheelAction(v0.4.3+)
+String
+zoom
+The behavior of the mouse wheel, zoom(Zoom in and out)、move(Move up and down). If customHandleMousewheel passes a custom function, this property will not take effect
+
+
+
+mousewheelMoveStep(v0.4.3+)
+Number
+100
+When the mousewheelAction is set to move, you can use this attribute to control the step length of the view movement when the mouse scrolls. The unit is px
+
+
Watermark config
diff --git a/web/src/pages/Doc/zh/changelog/index.md b/web/src/pages/Doc/zh/changelog/index.md
index 5b85076a..0748ce2f 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.4.3
+
+修复:前进回退后没有触发`data_change`事件的问题。
+
+新增:支持自定义鼠标滚轮事件;鼠标滚轮调整为支持缩放视图和上下移动视图。
+
## 0.4.2
新增:`Node`类的`setText`方法增加第二个参数,以支持设置富文本内容。
diff --git a/web/src/pages/Doc/zh/changelog/index.vue b/web/src/pages/Doc/zh/changelog/index.vue
index 523eec29..20e4d540 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.4.3
+
修复:前进回退后没有触发data_change事件的问题。
+
新增:支持自定义鼠标滚轮事件;鼠标滚轮调整为支持缩放视图和上下移动视图。
0.4.2
新增:Node类的setText方法增加第二个参数,以支持设置富文本内容。
0.4.1
diff --git a/web/src/pages/Doc/zh/constructor/index.md b/web/src/pages/Doc/zh/constructor/index.md
index a9c873c1..97aa5adf 100644
--- a/web/src/pages/Doc/zh/constructor/index.md
+++ b/web/src/pages/Doc/zh/constructor/index.md
@@ -41,6 +41,9 @@ const mindMap = new MindMap({
| enableFreeDrag(v0.2.4+) | Boolean | false | 是否开启节点自由拖拽 | |
| watermarkConfig(v0.2.4+) | Object | | 水印配置,详细配置请参考下方表格【水印配置】 | |
| textAutoWrapWidth(v0.3.4+) | Number | 500 | 节点内每行文本达到该宽度后自动换行 | |
+| customHandleMousewheel(v0.4.3+) | Function | null | 自定义鼠标滚轮事件处理,可以传一个函数,回调参数为事件对象 | |
+| mousewheelAction(v0.4.3+) | String | zoom | 鼠标滚轮的行为,`zoom`(放大缩小)、`move`(上下移动)。如果`customHandleMousewheel`传了自定义函数,这个属性不生效 | |
+| mousewheelMoveStep(v0.4.3+) | Number | 100 | 当`mousewheelAction`设为`move`时,可以通过该属性控制鼠标滚动一下视图移动的步长,单位`px` | |
### 水印配置
diff --git a/web/src/pages/Doc/zh/constructor/index.vue b/web/src/pages/Doc/zh/constructor/index.vue
index 7778b81f..7412c20e 100644
--- a/web/src/pages/Doc/zh/constructor/index.vue
+++ b/web/src/pages/Doc/zh/constructor/index.vue
@@ -147,6 +147,27 @@
节点内每行文本达到该宽度后自动换行
+
+customHandleMousewheel(v0.4.3+)
+Function
+null
+自定义鼠标滚轮事件处理,可以传一个函数,回调参数为事件对象
+
+
+
+mousewheelAction(v0.4.3+)
+String
+zoom
+鼠标滚轮的行为,zoom(放大缩小)、move(上下移动)。如果customHandleMousewheel传了自定义函数,这个属性不生效
+
+
+
+mousewheelMoveStep(v0.4.3+)
+Number
+100
+当mousewheelAction设为move时,可以通过该属性控制鼠标滚动一下视图移动的步长,单位px
+
+
水印配置
From 63d73a73aa7b8b9bcafbff6073f521f5a200f447 Mon Sep 17 00:00:00 2001
From: wanglin2 <1013335014@qq.com>
Date: Wed, 8 Mar 2023 09:43:11 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E6=89=93=E5=8C=850.4.3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.html b/index.html
index fb941603..0c4e2eb5 100644
--- a/index.html
+++ b/index.html
@@ -1 +1 @@
-
一个简单的web思维导图实现 We're sorry but thoughts doesn't work properly without JavaScript enabled. Please enable it to continue.
\ No newline at end of file
+
一个简单的web思维导图实现 We're sorry but thoughts doesn't work properly without JavaScript enabled. Please enable it to continue.
\ No newline at end of file