From eefd8a5245da674ffcf35ce63b3ec3f7dbb55a9e Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Sat, 17 Jun 2023 09:01:32 +0200 Subject: [PATCH] Add Fold: Toggle Fold command --- common/deps.ts | 1 + plug-api/silverbullet-syscall/editor.ts | 4 ++++ plugs/core/core.plug.yaml | 6 ++++++ plugs/core/editor.ts | 4 ++++ web/syscalls/editor.ts | 4 ++++ 5 files changed, 19 insertions(+) diff --git a/common/deps.ts b/common/deps.ts index e76277b..fd7f8e7 100644 --- a/common/deps.ts +++ b/common/deps.ts @@ -94,6 +94,7 @@ export { StreamLanguage, syntaxHighlighting, syntaxTree, + toggleFold, unfoldAll, unfoldCode, } from "@codemirror/language"; diff --git a/plug-api/silverbullet-syscall/editor.ts b/plug-api/silverbullet-syscall/editor.ts index 6db188e..f760195 100644 --- a/plug-api/silverbullet-syscall/editor.ts +++ b/plug-api/silverbullet-syscall/editor.ts @@ -139,6 +139,10 @@ export function unfold() { return syscall("editor.unfold"); } +export function toggleFold() { + return syscall("editor.toggleFold"); +} + export function foldAll() { return syscall("editor.foldAll"); } diff --git a/plugs/core/core.plug.yaml b/plugs/core/core.plug.yaml index e287e26..1d4d444 100644 --- a/plugs/core/core.plug.yaml +++ b/plugs/core/core.plug.yaml @@ -382,6 +382,12 @@ functions: name: "Fold: Unfold" mac: "Cmd-Alt-]" key: "Ctrl-Shift-]" + toggleFoldCommand: + path: ./editor.ts:toggleFoldCommand + command: + name: "Fold: Toggle Fold" + mac: "Cmd-Alt-f" + key: "Ctrl-Shift-f" foldAllCommand: path: ./editor.ts:foldAllCommand command: diff --git a/plugs/core/editor.ts b/plugs/core/editor.ts index 2317016..59b22a3 100644 --- a/plugs/core/editor.ts +++ b/plugs/core/editor.ts @@ -26,6 +26,10 @@ export async function unfoldCommand() { await editor.unfold(); } +export async function toggleFoldCommand() { + await editor.toggleFold(); +} + export async function foldAllCommand() { await editor.foldAll(); } diff --git a/web/syscalls/editor.ts b/web/syscalls/editor.ts index 8f2e8ef..a8ce0b4 100644 --- a/web/syscalls/editor.ts +++ b/web/syscalls/editor.ts @@ -3,6 +3,7 @@ import { EditorView, foldAll, foldCode, + toggleFold, Transaction, unfoldAll, unfoldCode, @@ -188,6 +189,9 @@ export function editorSyscalls(editor: Editor): SysCallMapping { "editor.unfold": () => { unfoldCode(editor.editorView!); }, + "editor.toggleFold": () => { + toggleFold(editor.editorView!); + }, "editor.foldAll": () => { foldAll(editor.editorView!); },