Compare commits

...

4 commits

Author SHA1 Message Date
Magnus Åhall
dc7e70b3f2 Bumped to v17 2026-06-08 21:44:07 +02:00
Magnus Åhall
cdccbc9306 Fixed showing node 2026-06-08 21:43:52 +02:00
Magnus Åhall
92287e2076 Removed old debugging code 2026-06-08 21:39:51 +02:00
Magnus Åhall
48ac1a8044 Removed old debugging code 2026-06-08 21:33:36 +02:00
4 changed files with 11 additions and 21 deletions

View file

@ -23,7 +23,7 @@ import (
"text/template" "text/template"
) )
const VERSION = "v16" const VERSION = "v17"
const CONTEXT_USER = 1 const CONTEXT_USER = 1
const SYNC_PAGINATION = 200 const SYNC_PAGINATION = 200

View file

@ -10,25 +10,23 @@ export class App {
this.crumbs = new N2Crumbs() this.crumbs = new N2Crumbs()
this.crumbsElement = document.getElementById('crumbs') this.crumbsElement = document.getElementById('crumbs')
this.nodeUI = document.getElementById('note') this.nodeUI = document.getElementById('note')
this.showNodeEventSequence = new ShowNodeEventSequence() // discard all GO_TO_NODE events
this.sidebar.render().then(sidebar => { this.sidebar.render().then(sidebar => {
document.getElementById('tree').append(sidebar) document.getElementById('tree').append(sidebar)
document.getElementById('tree-nodes')?.focus() document.getElementById('tree-nodes')?.focus()
}) })
_mbus.subscribe('TREE_TRUNK_FETCHED', async () => { _mbus.subscribe('TREE_RENDERED', async () => {
// Subscribing to the start node existing after the tree trunk is // Subscribing to the start node existing after the tree trunk is
// fetched since the NODE_COMPONENT_EXIST message isn't sent for the // fetched since the NODE_COMPONENT_EXIST message isn't sent for the
// root node itself, and the root node should be selected in the tree // root node itself, and the root node should be selected in the tree
// after it is rendered when the site is shown without UUID in the URL. // after it is rendered when the site is shown without UUID in the URL.
const startNode = await this.getStartNode() const startNode = await this.getStartNode()
document.getElementById('tree').append(await this.sidebar.render())
document.getElementById('tree-nodes')?.focus()
if (startNode.UUID == ROOT_NODE) if (startNode.UUID == ROOT_NODE)
this.goToNode(startNode.UUID, false, false) this.goToNode(startNode.UUID, false, false)
else
this.goToNode(startNode.UUID, false, false)
}) })
_mbus.subscribe('TREE_NODE_SELECTED', event => { _mbus.subscribe('TREE_NODE_SELECTED', event => {
@ -198,7 +196,7 @@ export class App {
await this.sidebar.makeVisible(node, ancestors, dontExpand) await this.sidebar.makeVisible(node, ancestors, dontExpand)
_mbus.dispatch('CRUMBS_SET', ancestors, () => this.crumbsElement.replaceChildren(this.crumbs.render())) _mbus.dispatch('CRUMBS_SET', ancestors, () => this.crumbsElement.replaceChildren(this.crumbs.render()))
_mbus.dispatch('NODE_UI_OPEN', { node, eventSequence: this.showNodeEventSequence.next() }) _mbus.dispatch('NODE_UI_OPEN', node)
_mbus.dispatch('TREE_EXPANSION', { expand: false, when: 'narrow' }) _mbus.dispatch('TREE_EXPANSION', { expand: false, when: 'narrow' })
_mbus.dispatch('NODE_UNMODIFIED') _mbus.dispatch('NODE_UNMODIFIED')
}//}}} }//}}}
@ -208,18 +206,6 @@ export class App {
}// }}} }// }}}
} }
class ShowNodeEventSequence {
constructor() {
this.seq = 0
}
next() {
return ++this.seq
}
current() {
return this.seq
}
}
class N2Crumbs extends CustomHTMLElement { class N2Crumbs extends CustomHTMLElement {
static {// {{{ static {// {{{
this.tmpl = document.createElement('template') this.tmpl = document.createElement('template')

View file

@ -42,8 +42,7 @@ export class N2PageNodeUI extends CustomHTMLElement {
this.marked = new MarkedPosition() this.marked = new MarkedPosition()
_mbus.subscribe('NODE_UI_OPEN', event => { _mbus.subscribe('NODE_UI_OPEN', event => {
console.log(event.detail.data.eventSequence, _app.showNodeEventSequence.current()) this.node = event.detail.data
this.node = event.detail.data.node
this.showMarkdown(true) this.showMarkdown(true)
this.render() this.render()
}) })

View file

@ -160,6 +160,11 @@ export class N2Sidebar extends CustomHTMLElement {
this.treeNodeComponents[startnode.UUID] = starttreenode this.treeNodeComponents[startnode.UUID] = starttreenode
this.elTreenodes.appendChild(await starttreenode.render()) this.elTreenodes.appendChild(await starttreenode.render())
// Notify the application that the initial tree is rendered (with children)
// and that initial node selection can take place. App will check URL to
// select the correct one.
_mbus.dispatch('TREE_RENDERED')
this.rendered = true this.rendered = true
return this return this
}// }}} }// }}}