silverbullet/plug-api/syscalls/code_widget.ts

25 lines
678 B
TypeScript
Raw Normal View History

2024-02-29 22:23:05 +08:00
import type { CodeWidgetContent } from "../types.ts";
import { syscall } from "../syscall.ts";
2023-10-31 17:33:38 +08:00
2024-08-07 19:27:25 +08:00
/**
* Renders a code widget.
* @param lang the language of the fenced code block
* @param body the body of the code to render
* @param pageName the name of the page the code widget appears on
* @returns the rendered code widget content
*/
2023-10-31 17:33:38 +08:00
export function render(
lang: string,
body: string,
pageName: string,
): Promise<CodeWidgetContent | null> {
2023-10-31 17:33:38 +08:00
return syscall("codeWidget.render", lang, body, pageName);
}
2023-11-15 17:08:21 +08:00
2024-08-07 19:27:25 +08:00
/**
* Refreshes all code widgets on the page that support it.
*/
2024-07-30 23:24:17 +08:00
export function refreshAll(): Promise<void> {
2023-11-15 17:08:21 +08:00
return syscall("codeWidget.refreshAll");
}