Major mini editor refactoring (#225)

Replaces most editing components with CM components, enabling vim mode and completions everywhere

Fixes #205 
Fixes #221 
Fixes #222 
Fixes #223
This commit is contained in:
Zef Hemel
2022-12-21 14:55:24 +01:00
committed by GitHub
parent 6897111cf9
commit 3545d00d46
31 changed files with 1158 additions and 745 deletions
+7 -5
View File
@@ -1,14 +1,16 @@
import { editor, system } from "$sb/silverbullet-syscall/mod.ts";
import { system } from "$sb/silverbullet-syscall/mod.ts";
import { CompleteEvent } from "../../plug-api/app_event.ts";
export async function commandComplete() {
const prefix = await editor.matchBefore("\\{\\[[^\\]]*");
if (!prefix) {
export async function commandComplete(completeEvent: CompleteEvent) {
const match = /\{\[([^\]]*)$/.exec(completeEvent.linePrefix);
if (!match) {
return null;
}
const allCommands = await system.listCommands();
return {
from: prefix.from + 2,
from: completeEvent.pos - match[1].length,
options: Object.keys(allCommands).map((commandName) => ({
label: commandName,
type: "command",