1
0
silverbullet/plugs/editor/editor.ts
Zef Hemel a2dbf7b3db
PlugOS refactor and other tweaks (#631)
* Prep for in-process plug loading (e.g. for CF workers, Deno Deploy)
* Prototype of fixed in-process loading plugs
* Fix: buttons not to scroll with content
* Better positioning of modal especially on mobile
* Move query caching outside query
* Fix annoying mouse behavior when filter box appears
* Page navigator search tweaks
2024-01-15 16:43:12 +01:00

37 lines
950 B
TypeScript

import { clientStore, editor } from "$sb/syscalls.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 toggleDarkMode() {
let darkMode = await clientStore.get("darkMode");
darkMode = !darkMode;
await clientStore.set("darkMode", darkMode);
await editor.reloadUI();
}
export async function centerCursorCommand() {
const pos = await editor.getCursor();
await editor.moveCursor(pos, true);
}
export async function moveToPosCommand() {
const posString = await editor.prompt("Move to position:");
if (!posString) {
return;
}
const pos = +posString;
await editor.moveCursor(pos);
}
export async function customFlashMessage(_def: any, message: string) {
await editor.flashNotification(message);
}