From ac008f54ea6d1ce3bf7b6ac3b8852106039abf9b Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 30 Sep 2022 16:59:57 +0200 Subject: [PATCH] Fixes #34: adding modal panel and refactored API --- .../plugos-silverbullet-syscall/editor.ts | 77 +++++++++++-------- packages/plugs/core/debug.ts | 5 +- packages/web/components/panel.tsx | 17 ++-- packages/web/editor.tsx | 50 ++++++------ packages/web/reducer.ts | 47 +++-------- packages/web/styles/main.scss | 17 ++++ packages/web/styles/theme.scss | 5 ++ packages/web/syscalls/editor.ts | 55 ++++++------- packages/web/types.ts | 42 +++++----- 9 files changed, 164 insertions(+), 151 deletions(-) diff --git a/packages/plugos-silverbullet-syscall/editor.ts b/packages/plugos-silverbullet-syscall/editor.ts index 740731c1..89b6f5ea 100644 --- a/packages/plugos-silverbullet-syscall/editor.ts +++ b/packages/plugos-silverbullet-syscall/editor.ts @@ -61,40 +61,17 @@ export function filterBox( return syscall("editor.filterBox", label, options, helpText, placeHolder); } -export function showRhs( +export function showPanel( + id: "lhs" | "rhs" | "bhs" | "modal", + mode: number, html: string, - script?: string, - flex = 1 + script: string ): Promise { - return syscall("editor.showRhs", html, script, flex); + return syscall("editor.showPanel", id, mode, html, script); } -export function hideRhs(): Promise { - return syscall("editor.hideRhs"); -} - -export function showLhs( - html: string, - script?: string, - flex = 1 -): Promise { - return syscall("editor.showLhs", html, script, flex); -} - -export function hideLhs(): Promise { - return syscall("editor.hideLhs"); -} - -export function showBhs( - html: string, - script?: string, - flex = 1 -): Promise { - return syscall("editor.showBhs", html, script, flex); -} - -export function hideBhs(): Promise { - return syscall("editor.hideBhs"); +export function hidePanel(id: "lhs" | "rhs" | "bhs" | "modal"): Promise { + return syscall("editor.hidePanel", id); } export function insertAtPos(text: string, pos: number): Promise { @@ -137,3 +114,43 @@ export function prompt( export function enableReadOnlyMode(enabled: boolean) { return syscall("editor.enableReadOnlyMode", enabled); } + +// DEPRECATED in favor of showPanel and hidePanel + +export function showRhs( + html: string, + script?: string, + flex = 1 +): Promise { + return syscall("editor.showRhs", html, script, flex); +} + +export function hideRhs(): Promise { + return syscall("editor.hideRhs"); +} + +export function showLhs( + html: string, + script?: string, + flex = 1 +): Promise { + return syscall("editor.showLhs", html, script, flex); +} + +export function hideLhs(): Promise { + return syscall("editor.hideLhs"); +} + +export function showBhs( + html: string, + script?: string, + flex = 1 +): Promise { + return syscall("editor.showBhs", html, script, flex); +} + +export function hideBhs(): Promise { + return syscall("editor.hideBhs"); +} + +// End deprecation diff --git a/packages/plugs/core/debug.ts b/packages/plugs/core/debug.ts index bb87fac6..6b5e9909 100644 --- a/packages/plugs/core/debug.ts +++ b/packages/plugs/core/debug.ts @@ -3,6 +3,7 @@ import { getText, hideBhs, showBhs, + showPanel, } from "@silverbulletmd/plugos-silverbullet-syscall/editor"; import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown"; import { getServerLogs } from "@silverbulletmd/plugos-silverbullet-syscall/sandbox"; @@ -19,7 +20,9 @@ export async function showLogsCommand() { let clientLogs = await getLogs(); let serverLogs = await getServerLogs(); - await showBhs( + await showPanel( + "modal", + 100, `