silverbullet/plugs/markdown/markdown.ts

17 lines
495 B
TypeScript
Raw Permalink Normal View History

import { clientStore, editor } from "@silverbulletmd/silverbullet/syscalls";
import { updateMarkdownPreview } from "./preview.ts";
2022-03-28 21:25:05 +08:00
2022-04-04 21:25:07 +08:00
export async function togglePreview() {
2023-08-26 14:31:51 +08:00
const currentValue = !!(await clientStore.get("enableMarkdownPreview"));
await clientStore.set("enableMarkdownPreview", !currentValue);
2022-04-04 21:25:07 +08:00
if (!currentValue) {
await updateMarkdownPreview();
2022-04-04 21:25:07 +08:00
} else {
await hideMarkdownPreview();
2022-04-09 20:57:59 +08:00
}
2022-03-28 21:25:05 +08:00
}
2022-04-04 21:25:07 +08:00
async function hideMarkdownPreview() {
await editor.hidePanel("rhs");
2022-04-04 21:25:07 +08:00
}