1
0
silverbullet/packages/plugs/markdown/markdown.ts

22 lines
823 B
TypeScript
Raw Normal View History

import { hideRhs, hideLhs } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
2022-04-25 09:24:13 +00:00
import { invokeFunction } from "@silverbulletmd/plugos-silverbullet-syscall/system";
import * as clientStore from "@silverbulletmd/plugos-silverbullet-syscall/clientStore";
import { readSettings, writeSettings } from "@silverbulletmd/plugs/lib/settings_page";;
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) {
await invokeFunction("client", "preview");
2022-04-04 13:25:07 +00:00
} else {
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() {
const setting = await readSettings({previewOnRHS: true});
const hide = setting.previewOnRHS ? hideRhs : hideLhs;
await hide();
2022-04-04 13:25:07 +00:00
}