diff options
-rw-r--r-- | src/editor.mjs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/editor.mjs b/src/editor.mjs index 6f046e6..6f529ed 100644 --- a/src/editor.mjs +++ b/src/editor.mjs | |||
@@ -285,7 +285,6 @@ menu.style.display = 'none'; | |||
285 | menu.onclick = () => (menu.style.display = 'none'); | 285 | menu.onclick = () => (menu.style.display = 'none'); |
286 | new MutationObserver(() => { | 286 | new MutationObserver(() => { |
287 | if (menu.style.display === 'none') { | 287 | if (menu.style.display === 'none') { |
288 | menu.style.cssText = ''; | ||
289 | menu.replaceChildren(); | 288 | menu.replaceChildren(); |
290 | } | 289 | } |
291 | }).observe(menu, { | 290 | }).observe(menu, { |
@@ -566,7 +565,7 @@ cm.on('cursorActivity', _ => { | |||
566 | }); | 565 | }); |
567 | cm.on('blur', () => { | 566 | cm.on('blur', () => { |
568 | if (menu.checkVisibility()) { | 567 | if (menu.checkVisibility()) { |
569 | cm.focus() && cm.setCursor(anchor); | 568 | cm.focus() |
570 | } else { | 569 | } else { |
571 | cm.getWrapperElement().classList.remove('focus'); | 570 | cm.getWrapperElement().classList.remove('focus'); |
572 | HtmlContainer.classList.add('focus'); | 571 | HtmlContainer.classList.add('focus'); |
@@ -600,7 +599,6 @@ cm.on('keydown', (_, e) => { | |||
600 | const focusSuggestion = e.shiftKey ? previousSuggestion : nextSuggestion; | 599 | const focusSuggestion = e.shiftKey ? previousSuggestion : nextSuggestion; |
601 | 600 | ||
602 | // Current editor selection state | 601 | // Current editor selection state |
603 | const anchor = cm.getCursor(); | ||
604 | switch (e.key) { | 602 | switch (e.key) { |
605 | case 'Tab': | 603 | case 'Tab': |
606 | Array.from(menu.children).forEach(s => s.classList.remove('focus')); | 604 | Array.from(menu.children).forEach(s => s.classList.remove('focus')); |
@@ -612,7 +610,7 @@ cm.on('keydown', (_, e) => { | |||
612 | break; | 610 | break; |
613 | case 'Escape': | 611 | case 'Escape': |
614 | if (!menu.checkVisibility()) break; | 612 | if (!menu.checkVisibility()) break; |
615 | // Focus editor again | 613 | // HACK delay menu display change for blur event, mark cm focus should keep |
616 | setTimeout(() => (menu.style.display = 'none'), 50); | 614 | setTimeout(() => (menu.style.display = 'none'), 50); |
617 | break; | 615 | break; |
618 | } | 616 | } |