Code widget refactor

This commit is contained in:
Zef Hemel
2023-10-31 10:33:38 +01:00
parent 4ef857acf4
commit d8318c4ad7
13 changed files with 64 additions and 32 deletions
+6 -4
View File
@@ -1,13 +1,15 @@
import type { WidgetContent } from "$sb/app_event.ts";
import { editor, events, language, space, system } from "$sb/syscalls.ts";
import { events, language, space, system } from "$sb/syscalls.ts";
import { parseTreeToAST } from "$sb/lib/tree.ts";
import { astToKvQuery } from "$sb/lib/parse-query.ts";
import { jsonToMDTable, renderTemplate } from "../directive/util.ts";
import { replaceTemplateVars } from "../template/template.ts";
import { parse } from "../../common/markdown_parser/parse_tree.ts";
export async function widget(bodyText: string): Promise<WidgetContent> {
const pageMeta = await space.getPageMeta(await editor.getCurrentPage());
export async function widget(
bodyText: string,
pageName: string,
): Promise<WidgetContent> {
const pageMeta = await space.getPageMeta(pageName);
try {
const queryAST = parseTreeToAST(