From bef7a2aba70462309d509008f432082809a0ee06 Mon Sep 17 00:00:00 2001 From: ssshooter Date: Sun, 8 Oct 2023 18:19:18 +0800 Subject: [PATCH] feat: add shortcuts --- package.json | 2 +- readme.md | 16 ++++++++-------- src/index.ts | 2 +- src/plugin/keypress.ts | 23 +++++++++++++++++------ 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 7c22e1ce..28ad70d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mind-elixir", - "version": "3.2.2", + "version": "3.2.3", "type": "module", "description": "Mind elixir is a free open source mind map core.", "keywords": [ diff --git a/readme.md b/readme.md index 4c3b43c7..770d1df4 100644 --- a/readme.md +++ b/readme.md @@ -325,14 +325,14 @@ Be aware that Mind Elixir will not observe the change of `prefers-color-scheme`. | Tab | Insert Child Node | | F1 | Center the Map | | F2 | Begin Editing the Current Node | -| Up Arrow | Select the Previous Sibling Node | -| Down Arrow | Select the Next Sibling Node | -| Left/Right Arrow | Select Parent or First Child | -| PageUp | Move Up Node | -| PageDown | Move Down Node | -| Ctrl + Up Arrow | Change Layout Pattern to Side | -| Ctrl + Left Arrow | Change Layout Pattern to Left | -| Ctrl + Right Arrow | Change Layout Pattern to Right | +| ↑ | Select the Previous Sibling Node | +| ↓ | Select the Next Sibling Node | +| ← / → | Select Parent or First Child | +| PageUp / Alt + ↑ | Move Up Node | +| PageDown / Alt + ↓ | Move Down Node | +| Ctrl + ↑ | Change Layout Pattern to Side | +| Ctrl + ← | Change Layout Pattern to Left | +| Ctrl + → | Change Layout Pattern to Right | | Ctrl + C | Copy the Current Node | | Ctrl + V | Paste the Copied Node | | Ctrl + "+" | Zoom In Mind Map | diff --git a/src/index.ts b/src/index.ts index 07236046..664e86d3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -126,7 +126,7 @@ MindElixir.DARK_THEME = DARK_THEME * @memberof MindElixir * @static */ -MindElixir.version = '3.2.2' +MindElixir.version = '3.2.3' /** * @function * @memberof MindElixir diff --git a/src/plugin/keypress.ts b/src/plugin/keypress.ts index 6b821e92..5bb6adad 100644 --- a/src/plugin/keypress.ts +++ b/src/plugin/keypress.ts @@ -15,9 +15,13 @@ const selectRoot = (mei: MindElixirInstance) => { export default function (mind: MindElixirInstance) { const key2func: Record void> = { - 13: () => { + 13: e => { // enter - mind.insertSibling() + if (e.shiftKey) { + mind.insertBefore() + } else { + mind.insertSibling() + } }, 9: () => { // tab @@ -33,14 +37,21 @@ export default function (mind: MindElixirInstance) { }, 38: e => { // up - if (e.metaKey || e.ctrlKey) { + if (e.altKey) { + mind.moveUpNode() + } else if (e.metaKey || e.ctrlKey) { return mind.initSide() + } else { + mind.selectPrevSibling() } - mind.selectPrevSibling() }, - 40: () => { + 40: e => { // down - mind.selectNextSibling() + if (e.altKey) { + mind.moveDownNode() + } else { + mind.selectNextSibling() + } }, 37: e => { // left