Add inline command links {[Command Name]} syntax
parent
d5ebab0358
commit
928ef59190
|
@ -14,6 +14,20 @@ syntax:
|
|||
color: "#0330cb"
|
||||
textDecoration: underline
|
||||
cursor: pointer
|
||||
CommandLink:
|
||||
firstCharacters:
|
||||
- "{"
|
||||
regex: "\\{\\[[^\\]]+\\]\\}"
|
||||
styles:
|
||||
#color: "#1e62a0"
|
||||
backgroundColor: "#e3dfdf"
|
||||
cursor: pointer
|
||||
borderTop: 1px solid silver
|
||||
borderLeft: 1px solid silver
|
||||
borderBottom: 1px solid gray
|
||||
borderRight: 1px solid gray
|
||||
borderRadius: 4px
|
||||
padding: 0 4px
|
||||
functions:
|
||||
clearPageIndex:
|
||||
path: "./page.ts:clearPageIndex"
|
||||
|
|
|
@ -7,6 +7,7 @@ import {
|
|||
} from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import { parseMarkdown } from "@silverbulletmd/plugos-silverbullet-syscall/markdown";
|
||||
import { nodeAtPos, ParseTree } from "@silverbulletmd/common/tree";
|
||||
import { invokeCommand } from "@silverbulletmd/plugos-silverbullet-syscall/system";
|
||||
|
||||
async function actionClickOrActionEnter(mdTree: ParseTree | null) {
|
||||
if (!mdTree) {
|
||||
|
@ -29,6 +30,13 @@ async function actionClickOrActionEnter(mdTree: ParseTree | null) {
|
|||
case "Link":
|
||||
await openUrl(mdTree.children![4].children![0].text!);
|
||||
break;
|
||||
case "CommandLink":
|
||||
let command = mdTree
|
||||
.children![0].text!.substring(2, mdTree.children![0].text!.length - 2)
|
||||
.trim();
|
||||
console.log("Got command link", command);
|
||||
await invokeCommand(command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue