Add workspace links, restore tabs, and update project guides

This commit is contained in:
Knotty Wyvern
2026-10-21 21:05:48 -07:00
parent f741389418
commit 562ef87d24
46 changed files with 2999 additions and 1113 deletions
+15 -1
View File
@@ -8,6 +8,7 @@
import { isRemoteImage, resolveImageRel, markdownTitle } from "$lib/workspace/media";
import { imageControls } from "$lib/editor/imageControls";
import { readerHeadingFolding } from "$lib/editor/headingFolding";
import { documentHeadings } from "$lib/workspace/headingLinks";
import "$lib/editor/headingFolding.css";
import { readingMenu } from "$lib/editor/readingMenu";
@@ -16,6 +17,7 @@
type Props = {
noteRel: string;
contents: string;
focusLine?: number | null;
linkActions?: DocumentLinkActions;
onSearch?: (text: string) => void;
onOpenLink?: (kind: "md" | "wiki", target: string) => void;
@@ -24,7 +26,7 @@
blockEditor?: Snippet;
};
let { noteRel, contents, onOpenLink, linkActions = {}, onSearch, onEditBlock, editing = null, blockEditor }: Props = $props();
let { noteRel, contents, focusLine = null, onOpenLink, linkActions = {}, onSearch, onEditBlock, editing = null, blockEditor }: Props = $props();
let html = $state("");
let menuError = $state("");
let sections = $state<MarkdownSection[]>([]);
@@ -82,6 +84,8 @@
void html;
void sections;
void editing;
const line = focusLine;
const headings = documentHeadings(contents);
const el = root;
let cancelled = false;
let releaseImages: (() => void) | undefined;
@@ -90,6 +94,16 @@
if (cancelled) return;
releaseImages = imageControls(el);
headingControls = currentHeadings = readerHeadingFolding(el, collapsedHeadings);
if (line !== null) requestAnimationFrame(() => {
if (cancelled) return;
const index = headings.findIndex(heading => heading.line === line);
const target = line === 1 && index < 0 ? el.querySelector<HTMLElement>(".document-title") :
[...el.querySelectorAll<HTMLElement>("h1, h2, h3, h4, h5, h6")].filter(heading => !heading.classList.contains("document-title"))[index];
if (!target) return;
currentHeadings?.reveal(target);
target.scrollIntoView({ block: "center" });
el.focus({ preventScroll: true });
});
return renderDiagrams(el, () => cancelled);
});
return () => { cancelled = true; releaseImages?.(); currentHeadings?.destroy(); };