2023-08-28 15:12:15 +00:00
|
|
|
import { clientStore, editor } from "$sb/syscalls.ts";
|
2022-09-16 12:26:47 +00:00
|
|
|
|
2022-12-16 11:44:04 +00:00
|
|
|
// Run on "editor:init"
|
|
|
|
export async function setEditorMode() {
|
2023-08-26 06:31:51 +00:00
|
|
|
if (await clientStore.get("vimMode")) {
|
2022-12-21 13:55:24 +00:00
|
|
|
await editor.setUiOption("vimMode", true);
|
|
|
|
}
|
2023-08-26 06:31:51 +00:00
|
|
|
if (await clientStore.get("darkMode")) {
|
2022-12-21 13:55:24 +00:00
|
|
|
await editor.setUiOption("darkMode", true);
|
2022-12-16 11:44:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-20 18:16:07 +00:00
|
|
|
export function openCommandPalette() {
|
|
|
|
return editor.openCommandPalette();
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function openPageNavigator() {
|
|
|
|
await editor.openPageNavigator("page");
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function openTemplateNavigator() {
|
|
|
|
await editor.openPageNavigator("template");
|
|
|
|
}
|
|
|
|
|
2022-12-21 13:55:24 +00:00
|
|
|
export async function toggleDarkMode() {
|
2023-08-26 06:31:51 +00:00
|
|
|
let darkMode = await clientStore.get("darkMode");
|
2022-12-21 13:55:24 +00:00
|
|
|
darkMode = !darkMode;
|
2023-08-26 06:31:51 +00:00
|
|
|
await clientStore.set("darkMode", darkMode);
|
2023-10-29 11:26:57 +00:00
|
|
|
await editor.reloadUI();
|
2022-12-21 13:55:24 +00:00
|
|
|
}
|
2023-06-14 17:27:18 +00:00
|
|
|
|
2023-07-24 09:27:46 +00:00
|
|
|
export async function centerCursorCommand() {
|
|
|
|
const pos = await editor.getCursor();
|
|
|
|
await editor.moveCursor(pos, true);
|
|
|
|
}
|
2023-07-27 15:02:53 +00:00
|
|
|
|
|
|
|
export async function moveToPosCommand() {
|
|
|
|
const posString = await editor.prompt("Move to position:");
|
|
|
|
if (!posString) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const pos = +posString;
|
|
|
|
await editor.moveCursor(pos);
|
|
|
|
}
|
2023-11-25 17:57:00 +00:00
|
|
|
|
2024-01-15 15:43:12 +00:00
|
|
|
export async function customFlashMessage(_def: any, message: string) {
|
2023-11-25 17:57:00 +00:00
|
|
|
await editor.flashNotification(message);
|
|
|
|
}
|
2024-01-20 18:16:07 +00:00
|
|
|
|
|
|
|
export async function reloadSettingsAndCommands() {
|
|
|
|
await editor.reloadSettingsAndCommands();
|
|
|
|
await editor.flashNotification("Reloaded settings and commands");
|
|
|
|
}
|