From 1ddf1b8c54fcda9fe89e6c4531739f76d7652f52 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Sun, 22 Sep 2024 11:19:38 +0800 Subject: refactor: rename data attribute for editor data-layout -> data-mode This prevents confusing with data-layout in dumbymap --- src/css/index.css | 2 +- src/editor.mjs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/css/index.css b/src/css/index.css index 3b8a51f..dc4c2e8 100644 --- a/src/css/index.css +++ b/src/css/index.css @@ -11,7 +11,7 @@ body { width: 100%; height: 100vh; - &[data-layout="editing"] { + &[data-mode="editing"] { display: flex; align-items: stretch; gap: 0.5em; diff --git a/src/editor.mjs b/src/editor.mjs index 6d13816..897a0d1 100644 --- a/src/editor.mjs +++ b/src/editor.mjs @@ -10,10 +10,10 @@ const HtmlContainer = document.querySelector(".DumbyMap") const textArea = document.querySelector(".editor textarea") const toggleEditing = () => { - if (document.body.getAttribute("data-layout") === "editing") { - document.body.removeAttribute("data-layout") + if (document.body.getAttribute("data-mode") === "editing") { + document.body.removeAttribute("data-mode") } else { - document.body.setAttribute("data-layout", "editing") + document.body.setAttribute("data-mode", "editing") } HtmlContainer.setAttribute("data-layout", "normal") } @@ -560,7 +560,7 @@ document.onkeydown = (e) => { const layoutObserver = new MutationObserver(() => { const layout = HtmlContainer.getAttribute('data-layout') if (layout !== 'normal') { - document.body.removeAttribute('data-layout') + document.body.removeAttribute('data-mode') } }) -- cgit v1.2.3-70-g09d2