1
0
silverbullet/plugs/core/command.ts
2022-10-14 15:11:33 +02:00

18 lines
424 B
TypeScript

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