1
0
silverbullet/plugs/markdown/markdown.ts
2022-10-14 15:53:51 +02:00

18 lines
612 B
TypeScript

import { clientStore, editor, system } from "$sb/silverbullet-syscall/mod.ts";
import { readSettings } from "$sb/lib/settings_page.ts";
export async function togglePreview() {
const currentValue = !!(await clientStore.get("enableMarkdownPreview"));
await clientStore.set("enableMarkdownPreview", !currentValue);
if (!currentValue) {
await system.invokeFunction("client", "preview");
} else {
await hideMarkdownPreview();
}
}
async function hideMarkdownPreview() {
const setting = await readSettings({ previewOnRHS: true });
await editor.hidePanel(setting.previewOnRHS ? "rhs" : "lhs");
}