Headings chooser possible as a plugin?

Hey there,

I was thinking about digging into the plugin development or so, since I am missing a feature, I have in Sublime Text:

2024-11-22_12-36-27_head_chooser

What you can see is: there are certain headings, even with different depths. Now I press a shortcut, which will bring up the panel picker, which lists all headings in the document. If I choose one, the cursor will jump to this heading, thus also scroll to it.

Would such a thing technically be possible in Silverbullet?

1 Like

Yes it should be. Some pointers:

This is where the table of contents widget is implemented, which also shows how the header scan can be implemented: silverbullet/plugs/index/toc.ts at main · silverbulletmd/silverbullet · GitHub

Then, you can use the editor.filterBox syscall: editor.filterBox from syscalls - @silverbulletmd/silverbullet - JSR to make a pop-up box appear (similar in style as the page and command picker).

1 Like

I think I could do a basic filterbox.

But I’m wondering if it would be possible to have different action based on key presses?

My thoughts are:

Enter: moves cursor to heading
space: show/hide sub level of selected heading
Shift-space: show/hide all sub levels

The filter box API doesn’t currently support this

That’s what I thought. I’ll go the easy route then.

One filter box with main heading and a different one with all levels.

Hey there, sorry for the late reply. Thanks so much for the inputs and the direct source code links! Good to know that it might be possible. And cool to have ideas already on how to do this. I will see what I can do with these information and will share anything I come up with here, of course. (=