diff --git a/packages/plugs/core/core.plug.yaml b/packages/plugs/core/core.plug.yaml index bbad1a58..20867533 100644 --- a/packages/plugs/core/core.plug.yaml +++ b/packages/plugs/core/core.plug.yaml @@ -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" diff --git a/packages/plugs/core/navigate.ts b/packages/plugs/core/navigate.ts index 9e52f7c5..2f6f5239 100644 --- a/packages/plugs/core/navigate.ts +++ b/packages/plugs/core/navigate.ts @@ -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; } }