561aa6891f
Big bang migration to Deno 🤯
21 lines
774 B
TypeScript
21 lines
774 B
TypeScript
import { hideLhs, hideRhs } from "../../syscall/silverbullet-syscall/editor.ts";
|
|
import { invokeFunction } from "../../syscall/silverbullet-syscall/system.ts";
|
|
import * as clientStore from "../../syscall/silverbullet-syscall/clientStore.ts";
|
|
import { readSettings } from "../lib/settings_page.ts";
|
|
|
|
export async function togglePreview() {
|
|
let currentValue = !!(await clientStore.get("enableMarkdownPreview"));
|
|
await clientStore.set("enableMarkdownPreview", !currentValue);
|
|
if (!currentValue) {
|
|
await invokeFunction("client", "preview");
|
|
} else {
|
|
await hideMarkdownPreview();
|
|
}
|
|
}
|
|
|
|
async function hideMarkdownPreview() {
|
|
const setting = await readSettings({ previewOnRHS: true });
|
|
const hide = setting.previewOnRHS ? hideRhs : hideLhs;
|
|
await hide();
|
|
}
|