Update editor, themes, menus, backgrounds, and release tooling

This commit is contained in:
Knotty Wyvern
2026-10-14 16:19:51 -07:00
parent f6eaa52949
commit edef2520af
113 changed files with 5722 additions and 386 deletions
+8 -4
View File
@@ -1,6 +1,6 @@
import { markdownLanguage } from "@codemirror/lang-markdown";
export type DocumentLink = { from: number; to: number; kind: "md" | "wiki"; target: string };
export type DocumentLink = { from: number; to: number; targetFrom: number; targetTo: number; kind: "md" | "wiki"; target: string };
/** Source ranges survive the change from formatted text to editable Markdown. */
export function documentLinks(source: string): DocumentLink[] {
@@ -15,13 +15,17 @@ export function documentLinks(source: string): DocumentLink[] {
const url = node.node.getChild("URL");
if (!url) return;
const target = source.slice(url.from, url.to).replace(/^<|>$/g, "").replace(/\\([\\()])/g, "$1");
links.push({ from: node.from, to: node.to, kind: "md", target });
const angled = source[url.from] === "<";
links.push({ from: node.from, to: node.to, targetFrom: url.from + Number(angled), targetTo: url.to - Number(angled), kind: "md", target });
return false;
} });
const occupied = (from: number, to: number) => [...literal, ...links].some(range => from < range.to && to > range.from);
for (const match of source.matchAll(/\[\[([^\]\n]+)\]\]/g)) {
if (occupied(match.index, match.index + match[0].length)) continue;
links.push({ from: match.index, to: match.index + match[0].length, kind: "wiki", target: match[1].split("|")[0].trim() });
if (source[match.index - 1] === "!") continue;
const raw = match[1].split(/\\?\|/)[0], target = raw.trim();
const targetFrom = match.index + 2 + raw.length - raw.trimStart().length;
links.push({ from: match.index, to: match.index + match[0].length, targetFrom, targetTo: targetFrom + target.length, kind: "wiki", target });
}
for (const match of source.matchAll(/(?:https?:\/\/|mailto:)[^\s<>]+/g)) {
if (occupied(match.index, match.index + match[0].length)) continue;
@@ -29,7 +33,7 @@ export function documentLinks(source: string): DocumentLink[] {
const open = (match[0].match(/\(/g) || []).length, close = (match[0].match(/\)/g) || []).length;
return suffix.slice(0, Math.max(0, suffix.length - Math.max(0, close - open)));
});
links.push({ from: match.index, to: match.index + target.length, kind: "md", target });
links.push({ from: match.index, to: match.index + target.length, targetFrom: match.index, targetTo: match.index + target.length, kind: "md", target });
}
return links.sort((a, b) => a.from - b.from);
}