3545d00d46
Replaces most editing components with CM components, enabling vim mode and completions everywhere Fixes #205 Fixes #221 Fixes #222 Fixes #223
20 lines
529 B
TypeScript
20 lines
529 B
TypeScript
import { system } from "$sb/silverbullet-syscall/mod.ts";
|
|
import { CompleteEvent } from "../../plug-api/app_event.ts";
|
|
|
|
export async function commandComplete(completeEvent: CompleteEvent) {
|
|
const match = /\{\[([^\]]*)$/.exec(completeEvent.linePrefix);
|
|
|
|
if (!match) {
|
|
return null;
|
|
}
|
|
const allCommands = await system.listCommands();
|
|
|
|
return {
|
|
from: completeEvent.pos - match[1].length,
|
|
options: Object.keys(allCommands).map((commandName) => ({
|
|
label: commandName,
|
|
type: "command",
|
|
})),
|
|
};
|
|
}
|