Rename system.invokeCommand syscall to editor.invokeCommand
This commit is contained in:
@@ -263,21 +263,21 @@ config.set {
|
||||
icon = "home",
|
||||
description = "Go to the index page",
|
||||
run = function()
|
||||
system.invokeCommand("Navigate: Home")
|
||||
editor.invokeCommand("Navigate: Home")
|
||||
end
|
||||
},
|
||||
{
|
||||
icon = "book",
|
||||
description = "Open page",
|
||||
run = function()
|
||||
system.invokeCommand("Navigate: Page Picker")
|
||||
editor.invokeCommand("Navigate: Page Picker")
|
||||
end
|
||||
},
|
||||
{
|
||||
icon = "terminal",
|
||||
description = "Run command",
|
||||
run = function()
|
||||
system.invokeCommand "Open Command Palette"
|
||||
editor.invokeCommand "Open Command Palette"
|
||||
end,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -26,7 +26,7 @@ function widgets.commandButton(text, commandName, args)
|
||||
end
|
||||
return widget.html(dom.button {
|
||||
onclick = function()
|
||||
system.invokeCommand(commandName, args)
|
||||
editor.invokeCommand(commandName, args)
|
||||
end,
|
||||
text
|
||||
})
|
||||
|
||||
@@ -93,6 +93,16 @@ export function setSelection(from: number, to: number): Promise<void> {
|
||||
return syscall("editor.setSelection", from, to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke a client command by name
|
||||
* Note: only available on the client
|
||||
* @param name name of the command
|
||||
* @param args arguments to pass to the command
|
||||
*/
|
||||
export function invokeCommand(name: string, args?: string[]): Promise<any> {
|
||||
return syscall("editor.invokeCommand", name, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces a save of the current page
|
||||
*/
|
||||
|
||||
@@ -117,6 +117,9 @@ export function editorSyscalls(client: Client): SysCallMapping {
|
||||
[],
|
||||
);
|
||||
},
|
||||
"editor.invokeCommand": (_ctx, name: string, args?: string[]) => {
|
||||
return client.runCommandByName(name, args);
|
||||
},
|
||||
"editor.openUrl": (_ctx, url: string, existingWindow = false) => {
|
||||
client.openUrl(url, existingWindow);
|
||||
},
|
||||
|
||||
@@ -45,9 +45,7 @@ export function systemSyscalls(
|
||||
return client.clientSystem.localSyscall(name, args);
|
||||
},
|
||||
"system.invokeCommand": (_ctx, name: string, args?: string[]) => {
|
||||
if (!client) {
|
||||
throw new Error("Not supported");
|
||||
}
|
||||
console.warn("Deprecated, use editor.invokeCommand instead");
|
||||
return client.runCommandByName(name, args);
|
||||
},
|
||||
"system.listCommands": (): { [key: string]: CommandDef } => {
|
||||
|
||||
@@ -116,6 +116,14 @@ Example:
|
||||
editor.moveCursorToLine(1, 1, true) -- Move to start of first line
|
||||
```
|
||||
|
||||
### editor.invokeCommand(name, args?)
|
||||
Invokes a client command by name.
|
||||
|
||||
Example:
|
||||
```lua
|
||||
editor.invokeCommand("Stats: Show")
|
||||
```
|
||||
|
||||
### editor.save()
|
||||
Force saves the current page.
|
||||
|
||||
|
||||
@@ -13,14 +13,6 @@ Example:
|
||||
system.invokeFunction("myplug.processData", "input", 123)
|
||||
```
|
||||
|
||||
### system.invokeCommand(name, args)
|
||||
Invokes a client command by name.
|
||||
|
||||
Example:
|
||||
```lua
|
||||
system.invokeCommand("editor.save", {})
|
||||
```
|
||||
|
||||
## System Information
|
||||
|
||||
### system.listCommands()
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@ config.set {
|
||||
icon = "home",
|
||||
description = "Go to the index page",
|
||||
run = function()
|
||||
system.invokeCommand("Navigate: Home")
|
||||
editor.invokeCommand("Navigate: Home")
|
||||
end
|
||||
},
|
||||
{
|
||||
@@ -33,14 +33,14 @@ config.set {
|
||||
icon = "book",
|
||||
description = "Open page",
|
||||
run = function()
|
||||
system.invokeCommand("Navigate: Page Picker")
|
||||
editor.invokeCommand("Navigate: Page Picker")
|
||||
end
|
||||
},
|
||||
{
|
||||
icon = "terminal",
|
||||
description = "Run command",
|
||||
run = function()
|
||||
system.invokeCommand "Open Command Palette"
|
||||
editor.invokeCommand "Open Command Palette"
|
||||
end,
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user