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

Anybody using this plugin can’t get it to work with 1.7.1 on desktop?

It’s working for me in the Backlinks tab using v1.7.1.

Screenshot 2024-09-13 075420

Embedded queries look alright as well:

Screenshot 2024-09-13 090815

What part(s) aren’t working for you?

Yeah I tried it in a sandbox vault and found that it works as intended. It turns out it’s not related to the version, just that query control seems to depend on the Backlinks core plugin, which I have recently turned off.
Thanks a lot for the reply!

the part in search pane does not work, where:

  1. the search result will not be rendered
  2. the render result option is missing

Ah yes. QC in the Search tab hasn’t worked in a long time – I had forgotten it did at one point.

the plugin try to find the parent object where all the settings in the search pane locate, so that it can insert the render setting.

it works for 1.6.x

but I thing the 1.7.x change the object definition
related to the search pane.

after updated to 1.7.3, I find that this plug-in is not able to load.

The error message in Obsidian Develop Tools is:

app.js:1 Plugin failure: obsidian-query-control TypeError: t.onCopyResultsClick is not a function
    at q.getSearchExport (plugin:obsidian-query-control:36:4283)
    at q.eval (plugin:obsidian-query-control:36:2469)
    at Generator.next (<anonymous>)
    at r (plugin:obsidian-query-control:6:649)

@NothingIsLost could you please have a look at of this issue?

1 Like

Query control lives on!

v0.7.10 working with Obsidian v1.7.4.

5 Likes

Finally!
Thank you for this information!

BTW, how do you install this plug-in? I find no main.js? Do i needs to compile them myself?

I have compiled them.

Thanks!

GLight, it seems like you got it but for others, the necessary files are on the Releases page:

Installing via BRAT should be fine as well.

Thank you for showing the release link, :smiley: ! It saves a lot of time.

It seems that the BRAT repository link is linked back to “nothingislost/obsidian-embedded-query-control”, which was still at v0.6.x in the last week when I use BRAT to update this plugin.