2022-10-10 12:50:21 +00:00
|
|
|
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";
|
2022-03-28 13:25:05 +00:00
|
|
|
|
2022-04-04 13:25:07 +00:00
|
|
|
export async function togglePreview() {
|
|
|
|
let currentValue = !!(await clientStore.get("enableMarkdownPreview"));
|
|
|
|
await clientStore.set("enableMarkdownPreview", !currentValue);
|
|
|
|
if (!currentValue) {
|
2022-04-13 12:46:52 +00:00
|
|
|
await invokeFunction("client", "preview");
|
2022-04-04 13:25:07 +00:00
|
|
|
} else {
|
2022-04-13 12:46:52 +00:00
|
|
|
await hideMarkdownPreview();
|
2022-04-09 12:57:59 +00:00
|
|
|
}
|
2022-03-28 13:25:05 +00:00
|
|
|
}
|
2022-04-04 13:25:07 +00:00
|
|
|
|
|
|
|
async function hideMarkdownPreview() {
|
2022-10-10 12:50:21 +00:00
|
|
|
const setting = await readSettings({ previewOnRHS: true });
|
2022-07-23 17:18:03 +00:00
|
|
|
const hide = setting.previewOnRHS ? hideRhs : hideLhs;
|
|
|
|
await hide();
|
2022-04-04 13:25:07 +00:00
|
|
|
}
|