Plugins: API for search component

I'm also exploring ways to save search queries (Save search query in the left panel) in a plugin.

I really like the way @benji300 envisioned it, and for this to come out nicely I would need the sidebar APIs to be approved (Plugins: API for sidebar view).

BTW, the plugin API seems to lack integration with the search engine component.
I suggest to add it in joplin.workspace I would need something like

joplin.workspace.searchQuery to get the current query, if present, and a joplin.workspace.onSearchComplete event.

I suspect I could listen to some search commands, but I have not investigated this yet.

Thank you for any feedback!


For the UI, you could already use a view panel, although I agree actual integration with the sidebar would be nicer, and I'll probably add it at some point.

For the search event, one issue is that search queries are executed as the user types, so I'm not sure what would be a search query in your model. For example, if I search for "joplin", you might get the events "jo", "jop", "jopli" and finally "joplin".

I could easily add an "onSearchComplete" event in any case. I don't believe searchQuery would be useful though, since you could already get this info in the "onSearchComplete" event handler (which will get an "event" parameter with a "query" property).

1 Like

For the specific use case, the plan was to to add a button in the toolbar to save the current search query, using a note as a database, and render it as dynamic list of notebook in the sidebar, executing the search on click. Ence the "static" joplin.workspace.searchQuery for the button.

joplin.workspace.onSearchComplete was more for a search history thing, which I find less useful and has it's own problems (like you noted).

With only the latter, I need to costantly listen for it and save the last value. Doable, but maybe less elegant.

Anyway, can you also comment on my other proposal for the sidebar? Thanks!

Yeah :star_struck: I'm really looking forward to the first version of this plugin!!!
If you need a BETA tester, I will be glad to help you :wink:

But when I think longer about the plugin, I think more and more about "favorites".
That means that the user could "pin" any kind of entries there. So actually all kinds of content types:

  • Search queries
  • Notebooks
  • Tags
  • Notes/To-Dos

Whereby the last three could be added "simply" via the context menu ("Add to Favorites")
If the user then clicks on a notebook, it jumps there accordingly, and so on.

But this is just my vision of a plugin that would cover as many use cases as possible. What it would definitely do.
I also don't know if this would be possible with the current plugin API.

@laurent : Would it be possible to extend the global search by a further filter "due" (search for alarm/due date)?
For example, this would allow the user to search for "due:day" and save it as "today" via the plugin.

A global variable can be implemented, or use publish and subscribe for notification. This is very simple. There is no need for joplin to maintain this global variable. . .

In addition, I found that search can indeed be done better. For example, slack and github allow the use of keywords and visual selection (such as date range) for filtering. Of course, it is actually difficult for me to use vscode plugin at present. To achieve this operation

1 Like