diff --git a/plugs/query/template.ts b/plugs/query/template.ts index 7bea41bb..72a3a67e 100644 --- a/plugs/query/template.ts +++ b/plugs/query/template.ts @@ -1,7 +1,6 @@ -import { WidgetContent } from "$sb/app_event.ts"; -import { markdown, space, system, YAML } from "$sb/syscalls.ts"; +import { markdown, space,, YAML } from "$sb/syscalls.ts"; import { loadPageObject, replaceTemplateVars } from "../template/template.ts"; -import { PageMeta } from "$sb/types.ts"; +import { CodeWidgetContent, PageMeta } from "$sb/types.ts"; import { renderTemplate } from "../template/plug_api.ts"; import { renderToText } from "$sb/lib/tree.ts"; import { rewritePageRefs, rewritePageRefsInString } from "$sb/lib/resolve.ts"; @@ -20,7 +19,7 @@ type TemplateConfig = { export async function widget( bodyText: string, pageName: string, -): Promise { +): Promise { const pageMeta: PageMeta = await loadPageObject(pageName); try { @@ -59,7 +58,20 @@ export async function widget( rendered = renderToText(parsedMarkdown); } - return { markdown: rendered }; + return { + markdown: rendered, + buttons: [{ + description: "Edit", + svg: + ``, + invokeFunction: "query.editButton", + }, { + description: "Reload", + svg: + ``, + invokeFunction: "query.refreshAllWidgets", + }], + }; } catch (e: any) { return { markdown: `**Error:** ${e.message}`, diff --git a/plugs/template/template.ts b/plugs/template/template.ts index bd52fea3..7b25e480 100644 --- a/plugs/template/template.ts +++ b/plugs/template/template.ts @@ -1,4 +1,4 @@ -import { editor, handlebars, markdown, space, YAML } from "$sb/syscalls.ts"; +import { editor, handlebars, space } from "$sb/syscalls.ts"; import { niceDate, niceTime } from "$sb/lib/dates.ts"; import { readSettings } from "$sb/lib/settings_page.ts"; import { cleanPageRef } from "$sb/lib/resolve.ts"; diff --git a/web/cm_plugins/markdown_widget.ts b/web/cm_plugins/markdown_widget.ts index 2932182c..ad19e0d7 100644 --- a/web/cm_plugins/markdown_widget.ts +++ b/web/cm_plugins/markdown_widget.ts @@ -162,6 +162,7 @@ export class MarkdownWidget extends WidgetType { div.querySelector(`button[data-button="${i}"]`)!.addEventListener( "click", () => { + console.log("Button clicked:", button.description); this.client.system.localSyscall("system.invokeFunction", [ button.invokeFunction, this.from,