silverbullet/website/API/command.md

25 lines
719 B
Markdown
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

APIs related to editor commands
### command.define(commandDef)
Registers a command.
Available keys:
* `name`: Name of the command
* `run`: Callback function
* `contexts`: AST node context in which this command should be available
* `priority`: Command priority (how high it appears in the list)
* `key`: Windows/Linux key binding (and mac, if not separately defined)
* `mac`: Mac-specific key binding
* `hide`: Hide this command from the [[Command Palette]]
* `requireMode`: `rw` or `ro` only enable this command in a particular mode (read-write, or read-only)
Example:
```lua
command.define {
name = "My custom command",
run = function()
editor.flashNotification "Triggered my custom command"
end
}