diff options
Diffstat (limited to 'src/editor.mjs')
-rw-r--r-- | src/editor.mjs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/editor.mjs b/src/editor.mjs index 897a0d1..4d8dbe8 100644 --- a/src/editor.mjs +++ b/src/editor.mjs | |||
@@ -8,6 +8,7 @@ import { createDocLinks } from './dumbymap.mjs' | |||
8 | 8 | ||
9 | const HtmlContainer = document.querySelector(".DumbyMap") | 9 | const HtmlContainer = document.querySelector(".DumbyMap") |
10 | const textArea = document.querySelector(".editor textarea") | 10 | const textArea = document.querySelector(".editor textarea") |
11 | let dumbymap | ||
11 | 12 | ||
12 | const toggleEditing = () => { | 13 | const toggleEditing = () => { |
13 | if (document.body.getAttribute("data-mode") === "editing") { | 14 | if (document.body.getAttribute("data-mode") === "editing") { |
@@ -152,7 +153,7 @@ const debounceForMap = (() => { | |||
152 | return function(...args) { | 153 | return function(...args) { |
153 | clearTimeout(timer); | 154 | clearTimeout(timer); |
154 | timer = setTimeout(() => { | 155 | timer = setTimeout(() => { |
155 | generateMaps.apply(this, args) | 156 | dumbymap = generateMaps.apply(this, args) |
156 | }, 1000); | 157 | }, 1000); |
157 | } | 158 | } |
158 | })() | 159 | })() |
@@ -548,10 +549,16 @@ document.onkeydown = (e) => { | |||
548 | e.preventDefault() | 549 | e.preventDefault() |
549 | return null | 550 | return null |
550 | } | 551 | } |
551 | if (cm.hasFocus()) { | 552 | if (!cm.hasFocus()) { |
552 | return null | 553 | e.preventDefault() |
553 | } else { | 554 | if (!dumbymap) return |
554 | return e | 555 | |
556 | if (e.key === 'Tab') { | ||
557 | dumbymap.utils.focusNextMap(e.shiftKey) | ||
558 | } | ||
559 | if (e.key === 'x') { | ||
560 | dumbymap.utils.switchToNextLayout() | ||
561 | } | ||
555 | } | 562 | } |
556 | } | 563 | } |
557 | 564 | ||