Feat:支持控制节点是否允许编辑

This commit is contained in:
wanglin2 2023-06-09 17:18:02 +08:00
parent e3d31f69bf
commit 834bdf37c3
10 changed files with 33 additions and 6 deletions

View File

@ -128,7 +128,9 @@ const defaultOpt = {
// 是否开启按住ctrl键多选节点功能
enableCtrlKeyNodeSelection: true,
// 设置为左键多选节点,右键拖动画布
useLeftKeySelectionRightKeyDrag: false
useLeftKeySelectionRightKeyDrag: false,
// 节点即将进入编辑前的回调方法如果该方法返回true以外的值那么将取消编辑函数可以返回一个值或一个Promise回调参数为节点实例
beforeTextEdit: null
}
// 思维导图

View File

@ -65,7 +65,16 @@ export default class TextEdit {
}
// 显示文本编辑框
show(node) {
async show(node) {
if (typeof this.mindMap.opt.beforeTextEdit === 'function') {
let isShow = false
try {
isShow = await this.mindMap.opt.beforeTextEdit(node)
} catch (error) {
isShow = false
}
if (!isShow) return
}
this.currentNode = node
let { offsetLeft, offsetTop } = checkNodeOuter(this.mindMap, node)
this.mindMap.view.translateXY(offsetLeft, offsetTop)

View File

@ -4,7 +4,7 @@
Breaking change: Adjusted the directory structure of the simple-mind-map source code, Main impact: 1. The introduction path of the plugin needs to be modified. The constant file path needs to be modified.
New: 1.Supports one click zoom to fit the canvas function. 2.Press and hold the Ctrl key to activate the multi selection function on demand through configuration. 3.Support setting to left click to select multiple nodes and right click to drag the canvas.
New: 1.Supports one click zoom to fit the canvas function. 2.Press and hold the Ctrl key to activate the multi selection function on demand through configuration. 3.Support setting to left click to select multiple nodes and right click to drag the canvas. 4. Support controlling whether nodes are allowed to be edited.
Fix: 1.Fix the issue where holding down the Ctrl key to select multiple nodes does not trigger the click event for the node.

View File

@ -3,7 +3,7 @@
<h1>Changelog</h1>
<h2>0.6.0</h2>
<p>Breaking change: Adjusted the directory structure of the simple-mind-map source code, Main impact: 1. The introduction path of the plugin needs to be modified. The constant file path needs to be modified.</p>
<p>New: 1.Supports one click zoom to fit the canvas function. 2.Press and hold the Ctrl key to activate the multi selection function on demand through configuration. 3.Support setting to left click to select multiple nodes and right click to drag the canvas.</p>
<p>New: 1.Supports one click zoom to fit the canvas function. 2.Press and hold the Ctrl key to activate the multi selection function on demand through configuration. 3.Support setting to left click to select multiple nodes and right click to drag the canvas. 4. Support controlling whether nodes are allowed to be edited.</p>
<p>Fix: 1.Fix the issue where holding down the Ctrl key to select multiple nodes does not trigger the click event for the node.</p>
<h2>0.5.11</h2>
<p>New: Supports associative text editing.</p>

View File

@ -66,6 +66,7 @@ const mindMap = new MindMap({
| fitPaddingv0.6.0+ | Number | 50 | The padding of mind mapping when adapting to canvas size, Unit: px | |
| enableCtrlKeyNodeSelectionv0.6.0+ | Boolean | true | Whether to enable the function of holding down the Ctrl key to select multiple nodes | |
| useLeftKeySelectionRightKeyDragv0.6.0+ | Boolean | false | Setting to left click to select multiple nodes and right click to drag the canvas. | |
| beforeTextEditv0.6.0+ | Function/null | null | The callback method before the node is about to enter editing. If the method returns a value other than true, the editing will be canceled. The function can return a value or a promise, and the callback parameter is the node instance | |
### Watermark config

View File

@ -322,6 +322,13 @@
<td>Setting to left click to select multiple nodes and right click to drag the canvas.</td>
<td></td>
</tr>
<tr>
<td>beforeTextEditv0.6.0+</td>
<td>Function/null</td>
<td>null</td>
<td>The callback method before the node is about to enter editing. If the method returns a value other than true, the editing will be canceled. The function can return a value or a promise, and the callback parameter is the node instance</td>
<td></td>
</tr>
</tbody>
</table>
<h3>Watermark config</h3>

View File

@ -4,7 +4,7 @@
破坏性更新调整了simple-mind-map源码的目录结构主要影响1.插件的引入路径需要修改。2.constant文件路径需要修改。
新增1.支持一键缩放至适应画布功能。 2.按住Ctrl键多选功能可通过配置按需开启。 3.支持设置为左键多选节点,右键拖动画布。
新增1.支持一键缩放至适应画布功能。 2.按住Ctrl键多选功能可通过配置按需开启。 3.支持设置为左键多选节点,右键拖动画布。 4.支持控制节点是否允许编辑。
修复1.修复按住ctrl键多选节点时不会触发节点的click事件的问题。

View File

@ -3,7 +3,7 @@
<h1>Changelog</h1>
<h2>0.6.0</h2>
<p>破坏性更新调整了simple-mind-map源码的目录结构主要影响1.插件的引入路径需要修改2.constant文件路径需要修改</p>
<p>新增1.支持一键缩放至适应画布功能 2.按住Ctrl键多选功能可通过配置按需开启 3.支持设置为左键多选节点右键拖动画布</p>
<p>新增1.支持一键缩放至适应画布功能 2.按住Ctrl键多选功能可通过配置按需开启 3.支持设置为左键多选节点右键拖动画布 4.支持控制节点是否允许编辑</p>
<p>修复1.修复按住ctrl键多选节点时不会触发节点的click事件的问题</p>
<h2>0.5.11</h2>
<p>新增支持关联性文本编辑</p>

View File

@ -66,6 +66,7 @@ const mindMap = new MindMap({
| fitPaddingv0.6.0+ | Number | 50 | 思维导图适应画布大小时的内边距单位px | |
| enableCtrlKeyNodeSelectionv0.6.0+ | Boolean | true | 是否开启按住ctrl键多选节点的功能 | |
| useLeftKeySelectionRightKeyDragv0.6.0+ | Boolean | false | 设置为左键多选节点,右键拖动画布 | |
| beforeTextEditv0.6.0+ | Function/null | null | 节点即将进入编辑前的回调方法如果该方法返回true以外的值那么将取消编辑函数可以返回一个值或一个Promise回调参数为节点实例 | |
### 水印配置

View File

@ -322,6 +322,13 @@
<td>设置为左键多选节点右键拖动画布</td>
<td></td>
</tr>
<tr>
<td>beforeTextEditv0.6.0+</td>
<td>Function/null</td>
<td>null</td>
<td>节点即将进入编辑前的回调方法如果该方法返回true以外的值那么将取消编辑函数可以返回一个值或一个Promise回调参数为节点实例</td>
<td></td>
</tr>
</tbody>
</table>
<h3>水印配置</h3>