Action button prototype
This commit is contained in:
@@ -42,14 +42,14 @@ functions:
|
||||
path: ./page.ts:linkQueryProvider
|
||||
events:
|
||||
- query:link
|
||||
indexItems:
|
||||
path: "./item.ts:indexItems"
|
||||
events:
|
||||
- page:index
|
||||
itemQueryProvider:
|
||||
path: ./item.ts:queryProvider
|
||||
events:
|
||||
- query:item
|
||||
# indexItems:
|
||||
# path: "./item.ts:indexItems"
|
||||
# events:
|
||||
# - page:index
|
||||
# itemQueryProvider:
|
||||
# path: ./item.ts:queryProvider
|
||||
# events:
|
||||
# - query:item
|
||||
deletePage:
|
||||
path: "./page.ts:deletePage"
|
||||
command:
|
||||
@@ -67,6 +67,9 @@ functions:
|
||||
name: "Page: Rename"
|
||||
mac: Cmd-Alt-r
|
||||
key: Ctrl-Alt-r
|
||||
button:
|
||||
label: "📝"
|
||||
tooltip: "Rename page"
|
||||
pageComplete:
|
||||
path: "./page.ts:pageComplete"
|
||||
events:
|
||||
@@ -99,7 +102,20 @@ functions:
|
||||
path: ./page.ts:parsePageCommand
|
||||
command:
|
||||
name: "Debug: Parse Document"
|
||||
|
||||
insertPageMeta:
|
||||
path: "./page.ts:insertPageMeta"
|
||||
slashCommand:
|
||||
name: meta
|
||||
quickNoteCommand:
|
||||
path: ./template.ts:quickNoteCommand
|
||||
command:
|
||||
name: "Template: Quick Note"
|
||||
key: "Alt-Shift-n"
|
||||
quickTaskCommand:
|
||||
path: ./template.ts:quickTaskCommand
|
||||
command:
|
||||
name: "Template: Quick Task"
|
||||
key: "Alt-Shift-t"
|
||||
instantiateTemplateCommand:
|
||||
path: ./template.ts:instantiateTemplateCommand
|
||||
command:
|
||||
|
||||
@@ -9,8 +9,11 @@ import {
|
||||
import {
|
||||
flashNotification,
|
||||
getCurrentPage,
|
||||
getCursor,
|
||||
getText,
|
||||
insertAtCursor,
|
||||
matchBefore,
|
||||
moveCursor,
|
||||
navigate,
|
||||
prompt,
|
||||
} from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
@@ -247,3 +250,9 @@ export async function parsePageCommand() {
|
||||
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```");
|
||||
await moveCursor(cursorPos + 8);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
} from "@silverbulletmd/plugos-silverbullet-syscall/space";
|
||||
import {
|
||||
filterBox,
|
||||
moveCursor,
|
||||
navigate,
|
||||
prompt,
|
||||
} from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
@@ -35,7 +36,7 @@ export async function instantiateTemplateCommand() {
|
||||
let { text } = await readPage(selectedTemplate.name);
|
||||
|
||||
let parseTree = await parseMarkdown(text);
|
||||
let additionalPageMeta = extractMeta(parseTree, true);
|
||||
let additionalPageMeta = extractMeta(parseTree, ["name"]);
|
||||
console.log("Page meta", additionalPageMeta);
|
||||
|
||||
let pageName = await prompt("Name of new page", additionalPageMeta.name);
|
||||
@@ -47,6 +48,7 @@ export async function instantiateTemplateCommand() {
|
||||
await navigate(pageName);
|
||||
}
|
||||
|
||||
// TODO: This should probably be replaced with handlebards somehow?
|
||||
export function replaceTemplateVars(s: string, pageName: string): string {
|
||||
return s.replaceAll(/\{\{([^\}]+)\}\}/g, (match, v) => {
|
||||
switch (v) {
|
||||
@@ -64,3 +66,22 @@ export function replaceTemplateVars(s: string, pageName: string): string {
|
||||
return match;
|
||||
});
|
||||
}
|
||||
|
||||
export async function quickNoteCommand() {
|
||||
let isoDate = new Date().toISOString();
|
||||
let [date, time] = isoDate.split("T");
|
||||
time = time.split(".")[0];
|
||||
let pageName = `📥 ${date} ${time}`;
|
||||
await writePage(pageName, "");
|
||||
await navigate(pageName);
|
||||
}
|
||||
|
||||
export async function quickTaskCommand() {
|
||||
let isoDate = new Date().toISOString();
|
||||
let [date, time] = isoDate.split("T");
|
||||
time = time.split(".")[0];
|
||||
let pageName = `✅ ${date} ${time}`;
|
||||
await writePage(pageName, "* [ ] ");
|
||||
await navigate(pageName);
|
||||
await moveCursor(6);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user