[Library] Silverware-toolbar

A toolbar for formatting text, on desktop and on a phone, inspired by the one in Notion.

Select some text and a small toolbar shows next to it. You can make the text bold, italic, code or a link, or turn the selected lines into a list, a heading, a quote or a code block, and back. Every change is an ordinary edit of the markdown, so undo works and the page doesn't depend on the library.

What it does so far:

  • bold, italic, underline, strikethrough, highlight, code, links, wiki links and tags, all as toggles (Bold on bold text takes it off)
  • Turn into: paragraph, headings, bullet, numbered and task lists, quote, code block
  • a searchable list of every action, including all SilverBullet commands (Ctrl-Shift-q, also without a selection)
  • with nothing selected, the word at the cursor counts as selected (Bold makes that word bold)
  • :star: a fully customizable toolbar: you choose which actions it shows, in what order and in how many rows, each as an icon or with a label, with your own icon and label if you like, buttons pinned to either end, and a separate setup for desktop and for touch, all from the settings dialog
  • :mobile_phone: gesture buttons on touch: tap for one action, swipe up or down for two more (Bold / Italic / Highlight in one button)
  • text snippets: your own button that inserts a text, with placeholders for the selection and the cursor
  • an emoji picker
  • placement: next to the selection, or docked at the top or bottom of the editor, set separately for desktop and touch
  • your own formats and actions, defined from Space Lua

Most of it can be turned off in the settings, module by module.

To install, add the repository with Library: Add Repository:
https://github.com/damesene/silverware-libraries/blob/main/REPO.md
Then install Silverware Toolbar from the list.

Examples:

i was thinking of adding another row on top solely for formatting when cursor is up, since most of the time using mobile is for reference instead of writing and with too many rows scrolling can be a pain so the bottom row can be docked permanently with shortcuts i use all the time like homepage, open tree, open page (the buttons are up there but phones are too large), silversearch, undo redo etc

just a suggestion!

edit: another one i think would be nice is that the docked toolbar stays permanently up. Currently if i clicked something say configuration (the >_Conf button), press cancel then the toolbar will disappear until i click anywhere to edit., which doesn't happen for the native toolbar

Thank you for the suggestion! It's not a priority for me right now, but I'll look into it when I have some spare time. I originally thought the gesture buttons would be enough. Have you tried them?

yea i did try the gesture but mobile screen are too tiny especially swiping down, with android it will just go into one handed mode

Multi-row docked toolbar and multiple toolbars

A bigger update to the toolbar, mostly for people who use it on a phone, but also on desktop.

Docked toolbar with multiple rows

The docked toolbar can now have more than one row. Each row is its own line, and each line has its own pinned items on the left and right. Lines are separated by a thin line, and the ends fade out with a light shadow while there's more to scroll. The scroll position also stays put when you tap into the text.

Multiple toolbars

You can now have several toolbars and switch between them easily. Each one has a name, its rows, where it shows (next to the selection, docked at the bottom or docked at the top) and when it shows. Each toolbar is used for Click (mouse), Touch (finger), both, or neither, so you can keep one around and switch to it later.

So if you want a floating toolbar on your phone for a while, you just give Touch a different toolbar. You don't have to rebuild the rows every time.

By default there are two: Float (desktop, next to the selection) and Docked (phone, at the bottom, always visible).

Your old settings are migrated automatically on first start, including where and when the toolbar showed.

Settings

The Favorites tab is now Toolbars. Pinned items sit in boxes at the top of each row (only for docked toolbars), an item's settings open right under it, and on a phone you hold an item for a moment to drag it, so normal scrolling still works. If a toolbar is missing … (every action), there's now a button to add it back.

Other

  • New Slash commands action that opens SilverBullet's / menu at the cursor. In the default phone toolbar it's on a swipe up on ….
  • A gesture button's tap or swipe can now hold a text snippet, not just an action.

Plus a bunch of smaller fixes and polish around the settings dialog and the docked toolbar.

@LostInLua you might be interested.

lmao you are on a roll with the plugins

Head's up, partially inspired by this I'll likely find a way to also enable SB core's currently mobile-only keyboardBar also on desktop (optional of course). It's clear it's quite nice to have such buttons available on desktop too, if even just for discovery.

nice!

@zef Yes, from my point of view it's great to have that option in desktop mode too.

@LostInLua Looking at the toolbar, I think I should add some generic monochrome icons so custom actions look cleaner.

If you still feel you need to fit more buttons on the screen but don't want to add another row, I have another option for you:

Switch between your toolbars

Since the last update you can have several toolbars, but each way of working (mouse or touch) was stuck with the one set in the settings. Now you can switch on the fly.

There's a new action, Toolbar. Put it in your toolbar (or on a swipe of the gesture button), tap it, pick another toolbar from the list, and it shows right away. The choice is saved to your CONFIG, so it's still there after a reload.

You don't need a button for it, either: type "toolbar" in the … search and your toolbars show up there. There's also a command, Silverware Toolbar: Switch toolbar.

A button for one specific toolbar

If you always jump between the same two toolbars, you can skip the list. Open the Toolbar item in the settings and set its Toolbar field. The button then switches straight to that toolbar.

If you rename a toolbar in the settings, buttons pointing to it keep working.

Parameters for your own actions

That Toolbar field isn't a one-off: any action can now take parameters, including your custom ones. Declare them with params, and the settings show a field for each one in the item's panel. In CONFIG they end up as args = { ... } on the item.

{
  name: "template",
  label: "Template",
  params: [{ key: "name", label: "Template", choices: ["Meeting", "Daily note"] }],
  describe: (args) => args.name,
  perform: (context, editor, args) => editor.invokeCommand(`Template: ${args.name ?? "Pick"}`),
}

So one action can sit in your toolbar several times, each copy doing something slightly different. Details are on the library page.

@LostInLua You can now enjoy monochrome icons!