2024-08-07 02:11:38 +08:00
|
|
|
import { clientStore, editor } from "@silverbulletmd/silverbullet/syscalls";
|
2023-05-24 02:53:53 +08:00
|
|
|
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) {
|
2023-05-24 02:53:53 +08:00
|
|
|
await updateMarkdownPreview();
|
2022-04-04 21:25:07 +08:00
|
|
|
} else {
|
2022-04-13 20:46:52 +08:00
|
|
|
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() {
|
2024-08-02 22:47:36 +08:00
|
|
|
await editor.hidePanel("rhs");
|
2022-04-04 21:25:07 +08:00
|
|
|
}
|