diff --git a/common/deps.ts b/common/deps.ts index e76277b7..fd7f8e77 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 6db188e4..f7601953 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 e287e26b..1d4d4440 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 2317016b..59b22a3d 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 8f2e8ef8..a8ce0b4a 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!); },