1
0
silverbullet/plugs/core/editor.ts
2023-01-03 16:23:38 +01:00

26 lines
751 B
TypeScript

import { clientStore, editor } from "$sb/silverbullet-syscall/mod.ts";
// Run on "editor:init"
export async function setEditorMode() {
if (await clientStore.get("vimMode")) {
await editor.setUiOption("vimMode", true);
}
if (await clientStore.get("darkMode")) {
await editor.setUiOption("darkMode", true);
}
}
export async function toggleVimMode() {
let vimMode = await clientStore.get("vimMode");
vimMode = !vimMode;
await editor.setUiOption("vimMode", vimMode);
await clientStore.set("vimMode", vimMode);
}
export async function toggleDarkMode() {
let darkMode = await clientStore.get("darkMode");
darkMode = !darkMode;
await editor.setUiOption("darkMode", darkMode);
await clientStore.set("darkMode", darkMode);
}