Lots of tweaks

This commit is contained in:
Zef Hemel
2022-05-09 14:59:12 +02:00
parent 35dc75d94e
commit f6758dbbaf
25 changed files with 336 additions and 62 deletions
+17 -6
View File
@@ -67,9 +67,6 @@ functions:
name: "Page: Rename"
mac: Cmd-Alt-r
key: Ctrl-Alt-r
button:
label: "📝"
tooltip: "Rename page"
pageComplete:
path: "./page.ts:pageComplete"
events:
@@ -93,15 +90,27 @@ functions:
slashCommand:
name: tomorrow
parseServerCommand:
path: ./page.ts:parseServerPageCommand
path: ./debug.ts:parseServerPageCommand
command:
name: "Debug: Parse Document on Server"
parsePage:
path: ./page.ts:parsePage
path: ./debug.ts:parsePage
parseCommand:
path: ./page.ts:parsePageCommand
path: ./debug.ts:parsePageCommand
command:
name: "Debug: Parse Document"
showLogsCommand:
path: ./debug.ts:showLogsCommand
command:
name: "Debug: Show Logs"
key: "Ctrl-Alt-l"
mac: "Cmd-Alt-l"
hideBhsCommand:
path: ./debug.ts:hideBhsCommand
command:
name: "UI: Hide BHS"
key: "Ctrl-Alt-b"
mac: "Cmd-Alt-b"
insertPageMeta:
path: "./page.ts:insertPageMeta"
slashCommand:
@@ -111,6 +120,8 @@ functions:
command:
name: "Template: Quick Note"
key: "Alt-Shift-n"
button:
label: "🗒"
quickTaskCommand:
path: ./template.ts:quickTaskCommand
command:
+82
View File
@@ -0,0 +1,82 @@
import { getLogs } from "@plugos/plugos-syscall/sandbox";
import { LogEntry } from "@plugos/plugos/sandbox";
import {
getText,
hideBhs,
showBhs,
} from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
import { getServerLogs } from "@silverbulletmd/plugos-silverbullet-syscall/sandbox";
import { invokeFunction } from "@silverbulletmd/plugos-silverbullet-syscall/system";
export async function parseServerPageCommand() {
console.log(await invokeFunction("server", "parsePage", await getText()));
}
export async function parsePageCommand() {
parsePage(await getText());
}
export async function parsePage(text: string) {
console.log("AST", JSON.stringify(await parseMarkdown(text), null, 2));
}
export async function showLogsCommand() {
let clientLogs = await getLogs();
let serverLogs = await getServerLogs();
await showBhs(
`
<style>
#client-log-header {
position: absolute;
left: 0;
top: 5px;
}
#server-log-header {
position: absolute;
right: 0;
top: 5px;
width: 50%;
}
#client-log {
position: absolute;
left: 0;
top: 30px;
bottom: 0;
width: 50%;
overflow: scroll;
}
#server-log {
position: absolute;
right: 0;
top: 30px;
bottom: 0;
width: 50%;
overflow: scroll;
}
</style>
<div id="client-log-header">Client logs (max 100)</div>
<div id="client-log">
<pre>${clientLogs
.map((le) => `[${le.level}] ${le.message}`)
.join("\n")}</pre>
</div>
<div id="server-log-header">Server logs (max 100)</div>
<div id="server-log">
<pre>${serverLogs
.map((le) => `[${le.level}] ${le.message}`)
.join("\n")}</pre>
</div>`,
`
var clientDiv = document.getElementById("client-log");
clientDiv.scrollTop = clientDiv.scrollHeight;
var serverDiv = document.getElementById("server-log");
serverDiv.scrollTop = serverDiv.scrollHeight;
`
);
}
export async function hideBhsCommand() {
await hideBhs();
}
-12
View File
@@ -239,18 +239,6 @@ export async function parseIndexTextRepublish({ name, text }: IndexEvent) {
});
}
export async function parseServerPageCommand() {
console.log(await invokeFunction("server", "parsePage", await getText()));
}
export async function parsePageCommand() {
parsePage(await getText());
}
export async function parsePage(text: string) {
console.log("AST", JSON.stringify(await parseMarkdown(text), null, 2));
}
export async function insertPageMeta() {
let cursorPos = await getCursor();
await insertAtCursor("```meta\n\n```");