From f5685b2f3a1ffe0edc3b5fa95fb182d402b923c1 Mon Sep 17 00:00:00 2001 From: limina1 Date: Tue, 5 Aug 2025 18:45:33 -0400 Subject: [PATCH] Fix TypeScript errors and improve ZettelEditor preview MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix {@const} placement errors by using Svelte 5 snippets - Add proper TypeScript types to levelColors objects - Rename and fix test file from .js to .ts with proper typing - Remove indent guides from editor text area for cleaner writing - Improve preview layout with proper indentation and spacing - Add continuous vertical guides in preview that don't overlap text ๐Ÿค– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/lib/components/ZettelEditor.svelte | 215 +++++----- tests/zettel-publisher-tdd.test.ts | 560 +++++++++++++++++++++++++ 2 files changed, 676 insertions(+), 99 deletions(-) create mode 100644 tests/zettel-publisher-tdd.test.ts diff --git a/src/lib/components/ZettelEditor.svelte b/src/lib/components/ZettelEditor.svelte index e3fb92e..a993d26 100644 --- a/src/lib/components/ZettelEditor.svelte +++ b/src/lib/components/ZettelEditor.svelte @@ -101,6 +101,18 @@ Understanding the nature of knowledge itself... return detectContentType(content); }); + // Helper function to get section level from content + function getSectionLevel(sectionContent: string): number { + const lines = sectionContent.split(/\r?\n/); + for (const line of lines) { + const match = line.match(/^(=+)\s+/); + if (match) { + return match[1].length; + } + } + return 2; // Default to level 2 + } + // Parse sections for preview display let parsedSections = $derived.by(() => { if (!parsedContent) return []; @@ -108,11 +120,13 @@ Understanding the nature of knowledge itself... return parsedContent.sections.map((section: { metadata: AsciiDocMetadata; content: string; title: string }) => { // Use simple parsing directly on section content for accurate tag extraction const tags = parseSimpleAttributes(section.content); + const level = getSectionLevel(section.content); return { title: section.title || "Untitled", content: section.content.trim(), tags, + level, }; }); }); @@ -230,136 +244,139 @@ Understanding the nature of knowledge itself... {/if} -
+
-
-
+
+