Closed antoniotejada closed 2 years ago
Hi, I don't really understand the problem - the event being triggered means that something is happening with the split. Since user interacts only with one split at a time (with the active one), you see only events coming from the active split.
Hi @zadam, this is at application start time, so the split content was just loaded and the widget should have been called the same way the active one was called without no one interacting with it, just the split startup load.
This happens both when you start the application fresh and you already had two splits, or when you create a new split.
So, it's important to realize that NoteContextAwareWidget
is a class which eases access to the current notecontext (= split).
You can listen to events of other note contexts, but then you need to use "lower level" events, e.g. by defining a listener:
async noteSwitchedEvent({noteContext, notePath}) {
...
}
You can listen to note switches in all note contexts ...
(in this case you need to listen on noteSwitchedAndActivatedEvent
as well)
Ok, thanks, I'll play with those.
Trilium Version
0.50.3
What operating system are you using?
Windows
What is your setup?
Local (no sync)
Operating System Version
Windows 10
Description
I have a two-split layout with two notes (this happens no matter the notes are the same or different) and a NoteContextAwareWidget.
The current behavior could be a design/backwards compatibility decision, but under those conditions I would expect the NoteContextAwareWidget to get called for both splits even if one of them is inactive. The rationale is that the widget may want to show information about all the visible notes, not just the active one.
In my case, my widget wants to do highlighting on all visible CKEditors (which is another issue because currently you can only get the CKEditor for the active split). See https://github.com/antoniotejada/Trilium-SyntaxHighlightWidget
These are the calls for that layout from the start of the application until it's done rendering:
If I then activate the right split I do get the calls for that split