Tweaking... WIP

pull/119/head
Zef Hemel 2022-11-12 17:28:35 +01:00
parent ad596d4a65
commit d8859cb10b
6 changed files with 15 additions and 10 deletions

View File

@ -1,6 +1,7 @@
import { Tag } from "./deps.ts";
export const CommandLinkTag = Tag.define();
export const CommandLinkNameTag = Tag.define();
export const WikiLinkTag = Tag.define();
export const WikiLinkPageTag = Tag.define();
export const CodeInfoTag = Tag.define();

View File

@ -56,11 +56,8 @@ const commandLinkRegex = /^\{\[([^\]]+)\]\}/;
const CommandLink: MarkdownConfig = {
defineNodes: [
{
name: "CommandLink",
style: { "CommandLink/...": ct.CommandLinkTag },
},
"CommandLinkName",
{ name: "CommandLink", style: { "CommandLink/...": ct.CommandLinkTag } },
{ name: "CommandLinkName", style: ct.CommandLinkNameTag },
{
name: "CommandLinkMark",
style: t.processingInstruction,
@ -225,6 +222,8 @@ export default function buildMarkdown(mdExtensions: MDExt[]): Language {
styleTags({
WikiLink: ct.WikiLinkTag,
WikiLinkPage: ct.WikiLinkPageTag,
// CommandLink: ct.CommandLinkTag,
// CommandLinkName: ct.CommandLinkNameTag,
Task: ct.TaskTag,
TaskMarker: ct.TaskMarkerTag,
Comment: ct.CommentTag,

View File

@ -47,9 +47,7 @@ async function actionClickOrActionEnter(
break;
}
case "CommandLink": {
const command = mdTree
.children![0].text!.substring(2, mdTree.children![0].text!.length - 2)
.trim();
const command = mdTree.children![1].text!;
console.log("Got command link", command);
await system.invokeCommand(command);
break;

View File

@ -257,11 +257,13 @@ class HideHeaderMarkPlugin {
const cursorOverlaps = ranges.some(({ from, to }) =>
checkRangeOverlap([from, to], [line.from, line.to])
);
if (cursorOverlaps) {
if (cursorOverlaps && type.name === "HeaderMark") {
widgets.push(
Decoration.line({ class: "sb-header-inside" }).range(from),
);
return;
} else if (cursorOverlaps) {
return;
}
if (
type.name === "HeaderMark" &&

View File

@ -17,6 +17,7 @@ export default function highlightStyles(mdExtension: MDExt[]) {
{ tag: ct.WikiLinkTag, class: "sb-wiki-link" },
{ tag: ct.WikiLinkPageTag, class: "sb-wiki-link-page" },
{ tag: ct.CommandLinkTag, class: "sb-command-link" },
{ tag: ct.CommandLinkNameTag, class: "sb-command-link-name" },
{ tag: ct.TaskTag, class: "sb-task" },
{ tag: ct.TaskMarkerTag, class: "sb-task-marker" },
{ tag: ct.CodeInfoTag, class: "sb-code-info" },

View File

@ -187,7 +187,11 @@
color: #959595;
}
.sb-command-link {
.sb-command-link.sb-meta {
color: #959595;
}
.sb-command-link-name {
background-color: #e3dfdf;
cursor: pointer;
border-top: 1px solid silver;