Move global CSS beside its code and make Documents reactive

Phase 4e.

- app.css holds only imports. Its rules moved into files beside their
  code, in the original cascade order. Dead rules of the deleted TipTap
  Writer are gone.
- workbenchKeys.ts is one table of the workbench shortcuts. Workbench
  runs the commands.
- session.linkTargets is the one link resolution for the link menu and
  for link opening.
- Documents is a rune module (documents.svelte.ts). Workbench reads the
  tabs and the active path from it, without a copy of all buffers on
  each change. The editor mount effect now copies the buffer inside
  untrack, so an edit does not remount the editor.
- Unit tests can import .svelte.ts modules through a Node module hook
  that compiles them with the Svelte compiler.

pnpm check, pnpm test (350 of 350), and the full smoke suite pass,
except tables/linkCaret, which failed one time under load and passed
on retry and 3 of 3 times alone.
This commit is contained in:
Knotty Wyvern
2026-10-28 11:50:33 -07:00
parent f32f60b540
commit 3e6bc5f088
23 changed files with 549 additions and 512 deletions
+8 -3
View File
@@ -150,7 +150,8 @@
}
function writeExtensions(lists: KeyBinding[]): Extension {
const current = untrack(() => buffer);
// A plain copy: the buffer is reactive, and this code must not track its later edits.
const current = untrack(() => ({ ...buffer }));
return [
headingFolding,
tableNavigation,
@@ -198,7 +199,8 @@
}
function configuration(): Extension[] {
const current = untrack(() => buffer);
// A plain copy: the buffer is reactive, and this code must not track its later edits.
const current = untrack(() => ({ ...buffer }));
shown = requested();
return [
completionExtension(current.id, () => ({ kind: isMarkdownPath(buffer.relPath) ? "prose" : "code", language: languageFor(buffer.relPath) })),
@@ -289,7 +291,8 @@
let releaseSelection: (() => void) | undefined;
let releaseDrop: (() => void) | undefined;
let releaseScroll: (() => void) | undefined;
const current = untrack(() => buffer);
// A plain copy: the buffer is reactive, and this code must not track its later edits.
const current = untrack(() => ({ ...buffer }));
void (async () => {
lastValue = current.contents;
const saved = savedEditor(current.id);
@@ -434,6 +437,8 @@
{#if error}<p class="editor-notice" role="alert">{error}<button onclick={() => { error = ""; }}>{$t("Dismiss")}</button></p>{/if}
<style>
.editor-notice { position: absolute; bottom: 12px; left: 12px; right: 12px; z-index: 20; margin: 0; padding: 10px 14px; border: 1px solid var(--rs-border); border-radius: 6px; background: var(--rs-bg-elevated); color: var(--rs-text); }
.editor-notice button { margin-left: 12px; }
.live-writer, .source-editor { position: absolute; inset: 0; }
.live-writer :global(.cm-editor), .source-editor :global(.cm-editor) { height: 100%; color: var(--rs-text); background: transparent; }
.live-writer :global(.cm-editor.cm-focused), .source-editor :global(.cm-editor.cm-focused) { outline: none; }