Is there a way to filter based on the links in a tiddler with the Locator plugin?
Hi,
I developed this some weeks ago. I am depending on having time to package it adequately as a plugin, do the documentation tutorial and try to do some improvements.
Meanwhile, I can have some free time to do it, I will share it here so it can solve your necessity and maybe someone else.
$_macros.arb_localSearch.js.json|attachment (4.9 KB)
It is a JavaScript macro. It is autodocumented inside the macro, but I will also explain it here.
<<localSearch.js customSearchInput_ID tocContainer_ID listItemType>>
For example:
<input type="search"
placeholder="Search..."
class="tc-search-input"
id="customSearchInputTiddlyHelp">
<<localSearch customSearchInputTiddlyHelp tocContainerTiddlyHelp toc-item>>
<div id="tocContainerTiddlyHelp" class="tc-table-of-contents">
<<toc'Tiddly Help Indice' 'sort[title]'>>
</div>
Explanation:
1. Define the input text box used to enter the search term, configuring a unique ID
2. Call the processing code with the parameters
3. Define a container for the list on which it will search, configuring a unique ID
listItemType values:
tc-menu-list-item -> to search on list tagged lists
toc-item -> to search on toc lists
I use it to search in toc content lists that I have as an index of tiddlers. When the index became bigger, I figured out to develop this, a faster way than searching with eyes
I am also using it to search on the list os snippets, the stamp button on the edit tiddler mode, using the listItemType to choose which search function to use. To use it in snippets, I have had to modify the core template: $:/core/ui/EditorToolbar/stamp-dropdown
This is the first improvement, try to do it without the need to modify a core template, but for the moment, I can’t figure out how to be able to do it, maybe someone knows how to do it.
The second improvement I have pending is to move the input and div elements to the macro, so it can be added to a tiddler, only adding one line.
Currently, if you use it a lot, you can add it as a snippet.
When I create a snippet, I use to add a comment on how to use it, to autodocument which variables I have to change. For example, for this, the snippet can be:
<!-- <<localSearch.js customSearchInput_ID tocContainer_ID listItemType>>
Explanation:
1. Define the input text box used to enter the search term, configuring a unique ID
2. Call the processing code with the parameters
3. Define a container for the list on which it will search, configuring a unique ID
listItemType values:
tc-menu-list-item -> to search on list tagged lists
toc-item -> to search on toc lists
-->
<input type="search"
placeholder="Search..."
class="tc-search-input"
id="customSearchInputTiddlyHelp">
<<localSearch customSearchInputTiddlyHelp tocContainerTiddlyHelp toc-item>>
<div id="tocContainerTiddlyHelp" class="tc-table-of-contents">
<<toc'Tiddly Help Indice' 'sort[title]'>>
</div>
When I finish the configuration of one instance of the snippet, I remove the comment