Skip to content

Commit 30118eb

Browse files
committed
Fixes #1346
Adds back "args" option to shortcuts
1 parent 15657b6 commit 30118eb

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

Library/Std/Config.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#meta
22

3-
SilverBullet's configuration can be tweaked using the `config.set` Space Lua API. This page defines all built-in configurations available. Individual Plugs and Space Lua scripts may define their own.
3+
SilverBullet's configuration can be tweaked using the `config.set` Space Lua API. This page defines all built-in
4+
configurations available. Individual Plugs and Space Lua scripts may define their own.
45

56
# Built-in options
7+
68
This defines the [JSON schema](https://json-schema.org/) for built-in configuration.
79

810
```space-lua
@@ -45,6 +47,10 @@ config.define("shortcuts", {
4547
type = "string",
4648
description = "Command we're creating the shortcut for"
4749
},
50+
args = {
51+
type = "array",
52+
description = "Optional array of arguments for the command"
53+
},
4854
key = {
4955
type = "string",
5056
description = "(Re)bind to keyboard shortcut"

type/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export type PanelMode = number;
2020
export type Shortcut = {
2121
// Command we're creating the shortcut for
2222
command: string;
23+
// Optional arguments to pass to the shortcut
24+
args?: any[];
2325
// (Re)bind to keyboard shortcut
2426
key?: string;
2527
mac?: string;

web/editor_state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export function createCommandKeyBindings(client: Client): KeyBinding[] {
315315
key: shortcut.key,
316316
mac: shortcut.mac,
317317
run: (): boolean => {
318-
client.runCommandByName(shortcut.command).catch(
318+
client.runCommandByName(shortcut.command, shortcut.args).catch(
319319
(e: any) => {
320320
console.error(e);
321321
client.flashNotification(

web/hooks/slash_command.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ export class SlashCommandHook implements Hook<SlashCommandHookT> {
7373
name: shortcut.slashCommand,
7474
description: shortcut.command,
7575
},
76-
run: () => this.client.runCommandByName(shortcut.command),
76+
run: () =>
77+
this.client.runCommandByName(shortcut.command, shortcut.args),
7778
});
7879
}
7980
}

0 commit comments

Comments
 (0)