mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 10:27:44 +08:00
Doc: update
This commit is contained in:
parent
43969af14b
commit
dc522cd0be
BIN
qrcode.jpg
BIN
qrcode.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
@ -36,6 +36,26 @@ mindMap.on('node_tree_render_end', () => {
|
||||
})
|
||||
```
|
||||
|
||||
如果你想获取到通过快捷键插入的节点,那么需要重写库默认的快捷键,比如以`Tab`键插入子节点为例:
|
||||
|
||||
首先在实例化完后移除默认快捷键:
|
||||
|
||||
```js
|
||||
mindMap.keyCommand.removeShortcut('Tab')
|
||||
```
|
||||
|
||||
然后添加快捷键:
|
||||
|
||||
```js
|
||||
mindMap.keyCommand.addShortcut('Tab', () => {
|
||||
mindMap.execCommand('INSERT_CHILD_NODE', false, [], {
|
||||
uid
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
此时你就可以指定快捷键添加节点时的uid了,那么按前面所述就可以获取到节点实例。
|
||||
|
||||
插入节点的命令也可以传入一定参数,比如创建新节点不想直接进入新节点的编辑模式,那么可以这样调用:
|
||||
|
||||
```js
|
||||
|
||||
@ -23,6 +23,18 @@ mindMap.execCommand(<span class="hljs-string">'INSERT_CHILD_NODE'</spa
|
||||
<span class="hljs-keyword">const</span> node = mindMap.renderer.findNodeByUid(uid)
|
||||
})
|
||||
</code></pre>
|
||||
<p>如果你想获取到通过快捷键插入的节点,那么需要重写库默认的快捷键,比如以<code>Tab</code>键插入子节点为例:</p>
|
||||
<p>首先在实例化完后移除默认快捷键:</p>
|
||||
<pre class="hljs"><code>mindMap.keyCommand.removeShortcut(<span class="hljs-string">'Tab'</span>)
|
||||
</code></pre>
|
||||
<p>然后添加快捷键:</p>
|
||||
<pre class="hljs"><code>mindMap.keyCommand.addShortcut(<span class="hljs-string">'Tab'</span>, <span class="hljs-function">() =></span> {
|
||||
mindMap.execCommand(<span class="hljs-string">'INSERT_CHILD_NODE'</span>, <span class="hljs-literal">false</span>, [], {
|
||||
uid
|
||||
})
|
||||
})
|
||||
</code></pre>
|
||||
<p>此时你就可以指定快捷键添加节点时的uid了,那么按前面所述就可以获取到节点实例。</p>
|
||||
<p>插入节点的命令也可以传入一定参数,比如创建新节点不想直接进入新节点的编辑模式,那么可以这样调用:</p>
|
||||
<pre class="hljs"><code>mindMap.execCommand(<span class="hljs-string">'INSERT_CHILD_NODE'</span>, <span class="hljs-literal">false</span>)
|
||||
</code></pre>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user