diff options
Diffstat (limited to 'src/editor.mjs')
-rw-r--r-- | src/editor.mjs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/editor.mjs b/src/editor.mjs index 760e2e1..a7bdd77 100644 --- a/src/editor.mjs +++ b/src/editor.mjs | |||
@@ -11,7 +11,10 @@ const textArea = document.querySelector('.editor textarea'); | |||
11 | let dumbymap; | 11 | let dumbymap; |
12 | 12 | ||
13 | new MutationObserver(() => { | 13 | new MutationObserver(() => { |
14 | if (document.body.getAttribute('data-mode') === 'editing') { | 14 | if ( |
15 | document.body.getAttribute('data-mode') === 'editing' && | ||
16 | HtmlContainer.getAttribute('data-layout') !== 'normal' | ||
17 | ) { | ||
15 | HtmlContainer.setAttribute('data-layout', 'normal'); | 18 | HtmlContainer.setAttribute('data-layout', 'normal'); |
16 | } | 19 | } |
17 | }).observe(document.body, { | 20 | }).observe(document.body, { |
@@ -276,7 +279,7 @@ window.onhashchange = () => { | |||
276 | // Completion in Code Blok {{{ | 279 | // Completion in Code Blok {{{ |
277 | // Elements about suggestions {{{ | 280 | // Elements about suggestions {{{ |
278 | const menu = document.createElement('div'); | 281 | const menu = document.createElement('div'); |
279 | menu.id = 'menu'; | 282 | menu.className = 'menu'; |
280 | menu.onclick = () => (menu.style.display = 'none'); | 283 | menu.onclick = () => (menu.style.display = 'none'); |
281 | new MutationObserver(() => { | 284 | new MutationObserver(() => { |
282 | if (menu.style.display === 'none') { | 285 | if (menu.style.display === 'none') { |
@@ -648,14 +651,13 @@ document.onkeydown = e => { | |||
648 | // }}} | 651 | // }}} |
649 | // }}} | 652 | // }}} |
650 | // Layout Switch {{{ | 653 | // Layout Switch {{{ |
651 | const layoutObserver = new MutationObserver(() => { | 654 | new MutationObserver(mutaions => { |
655 | const mutation = mutaions.at(-1); | ||
652 | const layout = HtmlContainer.getAttribute('data-layout'); | 656 | const layout = HtmlContainer.getAttribute('data-layout'); |
653 | if (layout !== 'normal') { | 657 | if (layout !== 'normal' || mutation.oldValue === 'normal') { |
654 | document.body.removeAttribute('data-mode'); | 658 | document.body.setAttribute('data-mode', ''); |
655 | } | 659 | } |
656 | }); | 660 | }).observe(HtmlContainer, { |
657 | |||
658 | layoutObserver.observe(HtmlContainer, { | ||
659 | attributes: true, | 661 | attributes: true, |
660 | attributeFilter: ['data-layout'], | 662 | attributeFilter: ['data-layout'], |
661 | attributeOldValue: true, | 663 | attributeOldValue: true, |