From 84181858c8384a5f99b0c7283036c6b50e81b9e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20=C3=85hall?= Date: Wed, 20 May 2026 18:49:43 +0200 Subject: [PATCH] Show markdown only when there is content --- static/js/node.mjs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/static/js/node.mjs b/static/js/node.mjs index 4d5e83d..339016d 100644 --- a/static/js/node.mjs +++ b/static/js/node.mjs @@ -41,6 +41,7 @@ export class N2NodeUI extends CustomHTMLElement { _mbus.subscribe('NODE_UI_OPEN', event => { this.node = event.detail.data + this.showMarkdown(true) this.render() }) @@ -68,10 +69,8 @@ export class N2NodeUI extends CustomHTMLElement { this.elNodeMarkdown.innerHTML = this.marked.parse(this.elNodeContent.value) }// }}} takeFocus() {// {{{ - console.log('taking focus', this.showMarkdown()) if (this.showMarkdown()) { this.elNodeMarkdown.focus() - console.log(this.elNodeMarkdown) } else this.elNodeContent.focus() }// }}} @@ -83,7 +82,12 @@ export class N2NodeUI extends CustomHTMLElement { return this.node?.isModified() }// }}} showMarkdown(state) {// {{{ - switch (state) { + // No point in showing markdown if there is no data. + // If there is no data, it will show a blank page regardless, and the user will most + // likely want to edit content, which can't be done in markdown. + const show = this.node.content().trim() !== '' && state + + switch (show) { case true: this.elNodeMarkdown.innerHTML = this.marked.parse(this.elNodeContent.value) this.elIconMarkdown.src = `/images/${_VERSION}/icon_markdown.svg`