2022-10-14 13:11:33 +00:00
|
|
|
import { editor, system } from "$sb/silverbullet-syscall/mod.ts";
|
2022-09-06 12:36:06 +00:00
|
|
|
|
|
|
|
export async function commandComplete() {
|
2022-10-14 13:11:33 +00:00
|
|
|
const prefix = await editor.matchBefore("\\{\\[[^\\]]*");
|
2022-09-06 12:36:06 +00:00
|
|
|
if (!prefix) {
|
|
|
|
return null;
|
|
|
|
}
|
2022-10-14 13:11:33 +00:00
|
|
|
const allCommands = await system.listCommands();
|
2022-09-06 12:36:06 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
from: prefix.from + 2,
|
|
|
|
options: Object.keys(allCommands).map((commandName) => ({
|
|
|
|
label: commandName,
|
|
|
|
type: "command",
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
}
|