Show markdown only when there is content
This commit is contained in:
parent
45cbd49345
commit
84181858c8
1 changed files with 7 additions and 3 deletions
|
|
@ -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`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue