Quorafind / Obsidian-Float-Search

A plugin for searching text by using Obsidian default search view.
GNU General Public License v3.0
155 stars 5 forks source link

[HELP] How to Target ViewState.type= "search" #16

Closed FelipeRearden closed 1 year ago

FelipeRearden commented 1 year ago

Feature Requested

Hello @Quorafind !!!

Forgive me for bothering you with this question but you are my last hope to try to get this working.

This is about the new feature that lets us the Search in a Tab.

My Issue

For a Templater script, I need to target the Search Tab when it is the Active Note

I have tried something like this ...

<%*
const activeLeaf = app.workspace.activeLeaf;
const viewState = activeLeaf.getViewState();
if ( viewState.type === "search" ) {
new Notice("lorem", 5000);
} else {
New Notice("ipsum", 5000);
} 
%>

But I get nothing :(

Would you mind helping to return search when the Search Tab is the Active Note?

I dont know Obsidian API and I was extremely confident that this was the right method :(


Thanks for reading this 🙏

Relevant Screenshot

No response

Checklist

FelipeRearden commented 1 year ago

I found the issue.

Templater cant run scripts that are outside markdown files. That's why it is not working.