aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/editor.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/editor.mjs')
-rw-r--r--src/editor.mjs18
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');
11let dumbymap; 11let dumbymap;
12 12
13new MutationObserver(() => { 13new 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 {{{
278const menu = document.createElement('div'); 281const menu = document.createElement('div');
279menu.id = 'menu'; 282menu.className = 'menu';
280menu.onclick = () => (menu.style.display = 'none'); 283menu.onclick = () => (menu.style.display = 'none');
281new MutationObserver(() => { 284new 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 {{{
651const layoutObserver = new MutationObserver(() => { 654new 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
658layoutObserver.observe(HtmlContainer, {
659 attributes: true, 661 attributes: true,
660 attributeFilter: ['data-layout'], 662 attributeFilter: ['data-layout'],
661 attributeOldValue: true, 663 attributeOldValue: true,