Skip to content

Commit b56be20

Browse files
committed
feat: add shortcuts
1 parent c6bbc2a commit b56be20

File tree

4 files changed

+47
-5
lines changed

4 files changed

+47
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mind-elixir",
3-
"version": "3.1.3",
3+
"version": "3.1.4",
44
"type": "module",
55
"description": "Mind elixir is a free open source mind map core.",
66
"keywords": [

readme.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Mind elixir is a free open source mind map core.
5252
- [Operation Guards](#operation-guards)
5353
- [Methods](#methods)
5454
- [Theme](#theme)
55+
- [Shortcuts](#shortcuts)
5556
- [Not only core](#not-only-core)
5657
- [Development](#development)
5758
- [Thanks](#thanks)
@@ -295,6 +296,28 @@ mind.changeTheme({
295296

296297
Be aware that Mind Elixir will not observe the change of `prefers-color-scheme`. Please change the theme **manually** when the scheme changes.
297298

299+
## Shortcuts
300+
301+
| Shortcut | Function |
302+
| ------------------ | -------------------------------- |
303+
| Enter | Insert Sibling Node |
304+
| Tab | Insert Child Node |
305+
| F1 | Center the Map |
306+
| F2 | Begin Editing the Current Node |
307+
| Up Arrow | Select the Previous Sibling Node |
308+
| Down Arrow | Select the Next Sibling Node |
309+
| Left/Right Arrow | Select Parent or First Child |
310+
| PageUp | Move Up Node |
311+
| PageDown | Move Down Node |
312+
| Ctrl + Up Arrow | Change Layout Pattern to Side |
313+
| Ctrl + Left Arrow | Change Layout Pattern to Left |
314+
| Ctrl + Right Arrow | Change Layout Pattern to Right |
315+
| Ctrl + C | Copy the Current Node |
316+
| Ctrl + V | Paste the Copied Node |
317+
| Ctrl + "+" | Zoom In Mind Map |
318+
| Ctrl + "-" | Zoom Out Mind Map |
319+
| Ctrl + 0 | Reset Zoom Level |
320+
298321
## Not only core
299322

300323
- [@mind-elixir/node-menu](https://github.com/ssshooter/node-menu)

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ MindElixir.DARK_THEME = DARK_THEME
130130
* @memberof MindElixir
131131
* @static
132132
*/
133-
MindElixir.version = '3.1.3'
133+
MindElixir.version = '3.1.4'
134134
/**
135135
* @function
136136
* @memberof MindElixir

src/plugin/keypress.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,30 @@ export default function (mind: MindElixirInstance) {
2323
// tab
2424
mind.addChild()
2525
},
26+
112: () => {
27+
// f1
28+
mind.toCenter()
29+
},
2630
113: () => {
2731
// f2
2832
mind.beginEdit()
2933
},
30-
38: () => {
34+
38: e => {
3135
// up
36+
if (e.metaKey || e.ctrlKey) {
37+
return mind.initSide()
38+
}
3239
mind.selectPrevSibling()
3340
},
3441
40: () => {
3542
// down
3643
mind.selectNextSibling()
3744
},
38-
37: () => {
45+
37: e => {
3946
// left
47+
if (e.metaKey || e.ctrlKey) {
48+
return mind.initLeft()
49+
}
4050
if (!mind.currentNode) return
4151
const nodeObj = mind.currentNode.nodeObj
4252
const main = mind.currentNode.offsetParent.offsetParent.parentElement
@@ -52,8 +62,11 @@ export default function (mind: MindElixirInstance) {
5262
mind.selectFirstChild()
5363
}
5464
},
55-
39: () => {
65+
39: e => {
5666
// right
67+
if (e.metaKey || e.ctrlKey) {
68+
return mind.initRight()
69+
}
5770
if (!mind.currentNode) return
5871
const nodeObj = mind.currentNode.nodeObj
5972
const main = mind.currentNode.offsetParent.offsetParent.parentElement
@@ -105,6 +118,12 @@ export default function (mind: MindElixirInstance) {
105118
mind.scale((mind.scaleVal -= 0.2))
106119
}
107120
},
121+
// ctrl 0
122+
48: (e: KeyboardEvent) => {
123+
if (e.metaKey || e.ctrlKey) {
124+
mind.scale(1)
125+
}
126+
},
108127
}
109128
mind.map.onkeydown = e => {
110129
// console.log(e)

0 commit comments

Comments
 (0)