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, 11 insertions, 7 deletions
diff --git a/src/editor.mjs b/src/editor.mjs
index a8cccf2..ed63f9c 100644
--- a/src/editor.mjs
+++ b/src/editor.mjs
@@ -34,10 +34,10 @@ const appendRefLink = ({ cm, ref, link }) => {
34 * and the layout is not 'normal', it sets the layout to 'normal' and switch to editing mode 34 * and the layout is not 'normal', it sets the layout to 'normal' and switch to editing mode
35 */ 35 */
36new window.MutationObserver(() => { 36new window.MutationObserver(() => {
37 const mode = context.getAttribute('data-mode') 37 const mode = context.dataset.mode
38 const layout = dumbyContainer.getAttribute('data-layout') 38 const layout = dumbyContainer.dataset.layout
39 if (mode === 'editing' && layout !== 'normal') { 39 if (mode === 'editing' && layout !== 'normal') {
40 dumbyContainer.setAttribute('data-layout', 'normal') 40 dumbyContainer.dataset.layout = 'normal'
41 } 41 }
42}).observe(context, { 42}).observe(context, {
43 attributes: true, 43 attributes: true,
@@ -48,8 +48,12 @@ new window.MutationObserver(() => {
48 * toggleEditing: toggle editing mode 48 * toggleEditing: toggle editing mode
49 */ 49 */
50const toggleEditing = () => { 50const toggleEditing = () => {
51 const mode = context.getAttribute('data-mode') 51 const mode = context.dataset.mode
52 context.setAttribute('data-mode', mode === 'editing' ? '' : 'editing') 52 if (mode === 'editing') {
53 delete context.dataset.mode
54 } else {
55 context.dataset.mode = 'editing'
56 }
53} 57}
54// }}} 58// }}}
55// Set up EasyMDE {{{ 59// Set up EasyMDE {{{
@@ -949,9 +953,9 @@ document.onkeydown = e => {
949// Layout Switch {{{ 953// Layout Switch {{{
950new window.MutationObserver(mutaions => { 954new window.MutationObserver(mutaions => {
951 const mutation = mutaions.at(-1) 955 const mutation = mutaions.at(-1)
952 const layout = dumbyContainer.getAttribute('data-layout') 956 const layout = dumbyContainer.dataset.layout
953 if (layout !== 'normal' || mutation.oldValue === 'normal') { 957 if (layout !== 'normal' || mutation.oldValue === 'normal') {
954 context.setAttribute('data-mode', '') 958 delete context.dataset.mode
955 } 959 }
956}).observe(dumbyContainer, { 960}).observe(dumbyContainer, {
957 attributes: true, 961 attributes: true,