2022-10-10 12:50:21 +00:00
|
|
|
import { listEvents } from "$sb/plugos-syscall/event.ts";
|
|
|
|
import { matchBefore } from "$sb/silverbullet-syscall/editor.ts";
|
2022-07-04 13:07:27 +00:00
|
|
|
|
|
|
|
export async function queryComplete() {
|
2022-10-10 12:50:21 +00:00
|
|
|
const prefix = await matchBefore("#query [\\w\\-_]*");
|
2022-07-04 13:07:27 +00:00
|
|
|
|
|
|
|
if (prefix) {
|
2022-10-10 12:50:21 +00:00
|
|
|
const allEvents = await listEvents();
|
2022-07-04 13:07:27 +00:00
|
|
|
// console.log("All events", allEvents);
|
|
|
|
|
|
|
|
return {
|
|
|
|
from: prefix.from + "#query ".length,
|
|
|
|
options: allEvents
|
|
|
|
.filter((eventName) => eventName.startsWith("query:"))
|
|
|
|
.map((source) => ({
|
|
|
|
label: source.substring("query:".length),
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|