Open bepuzzled opened 3 years ago
Hello, thanks for the suggestion, and sorry for the delay. If I understood correctly:
Let's say we want to recreate the "See Shadow Tiddlers" search, have a symbol for it (we're going to use ~
here, ie ~name
should search for shadow tiddlers containing name
) and have a global keyboard shortcut for it
First, we create a tiddler tagged $:/tags/CommandPaletteCommand
with our query as content:
[all[shadows]search[]]
and the following fields:
command-palette-caret: 20
command-palette-name: See Shadows Tiddlers
command-palette-type: prompt-basic
(Note we need to specify where the search terms go in the query with the caret
field)
Starting from v0.0.7, we can now add a 'prefix' field:
command-palette-prefix:~
The command palette will automatically search shadow tiddlers when the input starts with ~
Bonus: the symbol will show up in the help (help show up if you type ?
)
Creating the shortcut is a native TW feature.
We need to create a tiddler tagged $:/tags/KeyboardShortcut
with an arbitrary key
field, here we use 'cp-shadow':
key: ((cp-shadow))
and the following content
<$action-sendmessage $message="open-command-palette" $param="~"/>
(Note we pass our prefix ~
as $param
)
Final step is to add a description of the shortcut.
We create a tiddler named $:/config/ShortcutInfo/cp-shadow
with a description as content. Here we use
Open the command palette and search for shadow tiddlers
Voila ! That should work. Let me know what you think :)
Hi, and thanks for the response. Greatly appreciated.
The prefix is a good improvement, and very close to what I was after. The only downside with this approach is that I lose the richness of the multiple filter steps that is available with the regular search option. Do you have a recommended way to define multiple search steps for a custom search prefix?
(regarding the shortcut solution, agreed. However, I was primarily interested in a single-key shortcut (e.g. /) and that does not work well with the usual TW shortcut method because it fires even within text fields - not ideal. That is why I rely on the mousetrap plugin for those)
Hello, I absolutely love the TiddlyWiki command palette. The customizable search steps are invaluable and very cleverly programmed. I wanted to take it to the next level and allow different search types invoked with different keyboard shortcuts or prefixes. This lets the user customize the search filters used, based on the shortcut used (openPalette parameter).
This modified $:/core/modules/widgets/commandpalettewidget.js tiddler achieves this goal, for your consideration; sample search step dictionary included in the comment.
happy to submit a pull request if desired.
in my case, I use the mousetrap plugin for single key (plus modifier) to invoke one of the three defined search types, very fast and convenient