A patch for Obsidian-Qurey-Control plug-in for Obsidian 1.2.x

I’m a big fan of the Obsidian-Query-Control.

I use embedded search to collect the assignment and information which are related to different topics and different people generated during a meeting or in a discussion. And then I export the collection as a report which will be submitted or distributed later. The report needs to be in an easy-to-read manner, and for this purpose, a rendered markdown is preferred and the Obsidian-query-control is my choice.

A brief introduction of the Obsidian-Query-Control can be found in the following post.

However, after the Obsidian updated to 1.2.x, the Obsidian-Query-Control stops working. And unfortunately, the author of the plugin has no time(temporally, I hope) to deal with this issue, right now. I think currently there is no alternative for the Obsidian-Query-Control, especially on the aspect of rendering the dynamically generated embeded search result, so, I have to do something, for example, find a workaround, to save my workflow.

My first attempt is rolling back the Obsidian to its previous version. It works. And I was pretty comfortable about this workaround for about 1-2 weeks. However, as the Obsidian updates very frequently, I think I will eventually give up this workaround for some new features or big-bug-fixing that I concerned. So I guess I should do something more to ease the worry and began to read articles and posts about the TS and the Obsidian Plugin Debug. It’s a little bit complex and even magical at beginning, but comparing to developing C++ in the old days, everything is pretty much easier and friendly for the beginner. Let’s skip this part.

After some going back and forth among the lines, I found that the cause of this issue is that the SearchHeaderDOM is no longer available in the Obsidian. So that every line related to this class may cause an error.

I made a simple and straight forward patch which comments the affected code to fix this issue. The fixed main.js can be found here:

As this code actually scales down the original plugin, I’m not sure whether I should send a pull request to the author of the original plugin.

The good news is: now the plugin can work. This is the screenshot of the rendered embedded search result using patched Obsidian-Query-Control.

The bad news is: as you can see in the screenshot, the nice control buttons which was in the Embedded Search are gone. The additional buttons for the native search pane are gone, as well. But I think one can live on these:

For the Native Search, the sorting and folding search results are already supported by the native search, one can use the native search parameters control menu to perform these actions. The rendering of the markdown in native search result works. The only inconvenience is that it is now controlled by default behavior of the plugin which is configured in the plugin setting pane, and a reload of Obsidian is needed if one wants the new settings to work.

For the embedded query/search, the additional query commands works. And thanks for the robust code provided by the author, most of the query control can be performed by changing the query code itself. The only inconvenience is that the button for copying the embedded search results directly from the embedded query is no-longer available. But I think there is always a workaround such as using the native search panel as an alternative.

As I am not the expert on developing, I have not found a way to fix the buttons. So if you are experienced and also interest in this plugin, may be you can help to find a way to create a new UI for this plugin include but not limited to:

  1. a switch on the native search pane to toggle the function of rendering the markdown in the search result
  2. a UI, such as the menu in the native search pane or the buttons in the backlink pane, can control the embedded search by mouse clicking.

:smiley:

8 Likes

I think you should submit the pull request, if only so people who check the plugin can see it. If the developer doesn’t want to use it or doesn’t even have time to check and accept it, oh well.

To me the query commands are more important than the buttons anyway. I mostly just want to set the default view of an embedded search, not change it while I’m looking at it. And it’s still possible to change the sort, etc. without the buttons, tho it’s less easy.

2 Likes

Thank you for the suggestion!

Instead of trying to add all the controls back to the embedded search, I think I would (if possible) add a single button that sends the query to the regular search tab to take advantage of the existing controls.

3 Likes

GLight!

Thanks for your efforts in keeping the dream alive.

0.5.1 →

  • Merged fix from @zhao414 to get the plugin to at least not throw errors constantly.

0.5.2 → FYI for anyone interested: Embedded query controls are back!

:partying_face:

7 Likes

Whattttttt. NIL is back!!! Thanks a lot for the update! I’m so happy because I use many of their other plugins as well.

1 Like

Woot!

1 Like

Thank you very very much for the update !

1 Like