Tree focus

This commit is contained in:
Magnus Åhall 2026-05-20 18:28:16 +02:00
parent 5a0340c226
commit 45cbd49345
4 changed files with 68 additions and 9 deletions

View file

@ -22,7 +22,7 @@ export class N2NodeUI extends CustomHTMLElement {
<div data-el="name"></div>
<textarea data-el="node-content" required rows=1></textarea>
<div data-el="node-markdown"></div>
<div data-el="node-markdown" tabindex=1></div>
<div data-el="functions">
<img data-el="icon-markdown">
@ -55,7 +55,7 @@ export class N2NodeUI extends CustomHTMLElement {
})
_mbus.subscribe('MARKDOWN_TOGGLE', () => this.showMarkdown(!this.showMarkdown()))
_mbus.subscribe('MARKDOWN_EDIT', ({detail}) => this.editMarkdown(detail.data))
_mbus.subscribe('MARKDOWN_EDIT', ({ detail }) => this.editMarkdown(detail.data))
this.elNodeContent.addEventListener('input', event => this.contentChanged(event))
this.elIconMarkdown.addEventListener('click', () => this.showMarkdown(!this.showMarkdown()))
@ -68,7 +68,12 @@ export class N2NodeUI extends CustomHTMLElement {
this.elNodeMarkdown.innerHTML = this.marked.parse(this.elNodeContent.value)
}// }}}
takeFocus() {// {{{
this.elNodeContent.focus()
console.log('taking focus', this.showMarkdown())
if (this.showMarkdown()) {
this.elNodeMarkdown.focus()
console.log(this.elNodeMarkdown)
} else
this.elNodeContent.focus()
}// }}}
contentChanged(event) {//{{{