Browse Source

Merge wiki links and dark mode improvements

Combines wiki link support with dark mode readability fixes:
- Wiki link syntax highlighting in editor ([[term]], [[w:term]], [[d:term]])
- Separated hashtags and wiki links in preview
- Improved dark mode colors (40% opacity backgrounds, lighter text)
- White text editor theme matching preview
- MutationObserver for dynamic theme switching

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
master
limina1 4 months ago
parent
commit
39e9d2a1e5
  1. BIN
      .playwright-mcp/.playwright-mcp/dark-mode-complete.png
  2. BIN
      .playwright-mcp/.playwright-mcp/dark-mode-editor-fix.png
  3. BIN
      .playwright-mcp/.playwright-mcp/dark-mode-final.png
  4. BIN
      .playwright-mcp/.playwright-mcp/dark-mode-preview-update.png
  5. BIN
      .playwright-mcp/.playwright-mcp/dark-mode-text-fix.png
  6. BIN
      .playwright-mcp/.playwright-mcp/dark-mode-white-text.png
  7. BIN
      .playwright-mcp/.playwright-mcp/dark-mode-with-preview.png
  8. BIN
      .playwright-mcp/compose-darkmode-preview.png
  9. BIN
      .playwright-mcp/dark-mode-full-preview.png
  10. BIN
      .playwright-mcp/dark-mode-preview-after.png
  11. BIN
      .playwright-mcp/preview-area.png
  12. 77
      src/lib/components/ZettelEditor.svelte

BIN
.playwright-mcp/.playwright-mcp/dark-mode-complete.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
.playwright-mcp/.playwright-mcp/dark-mode-editor-fix.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
.playwright-mcp/.playwright-mcp/dark-mode-final.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
.playwright-mcp/.playwright-mcp/dark-mode-preview-update.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

BIN
.playwright-mcp/.playwright-mcp/dark-mode-text-fix.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
.playwright-mcp/.playwright-mcp/dark-mode-white-text.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
.playwright-mcp/.playwright-mcp/dark-mode-with-preview.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
.playwright-mcp/compose-darkmode-preview.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
.playwright-mcp/dark-mode-full-preview.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
.playwright-mcp/dark-mode-preview-after.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
.playwright-mcp/preview-area.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

77
src/lib/components/ZettelEditor.svelte

@ -61,6 +61,9 @@
let generatedEvents = $state<any>(null); let generatedEvents = $state<any>(null);
let contentType = $state<"article" | "scattered-notes" | "none">("none"); let contentType = $state<"article" | "scattered-notes" | "none">("none");
// Dark mode state
let isDarkMode = $state(false);
// Note: updateEditorContent() is only called manually when needed // Note: updateEditorContent() is only called manually when needed
// The automatic effect was causing feedback loops with user typing // The automatic effect was causing feedback loops with user typing
@ -786,6 +789,36 @@
outline: "none", outline: "none",
}, },
}), }),
// Override background and text to match preview (gray-800 bg, gray-100 text)
...(isDarkMode ? [EditorView.theme({
"&": {
backgroundColor: "#1f2937",
color: "#f3f4f6",
},
".cm-content": {
color: "#f3f4f6",
},
".cm-line": {
color: "#f3f4f6",
},
".cm-gutters": {
backgroundColor: "#1f2937",
borderColor: "#374151",
color: "#9ca3af",
},
".cm-activeLineGutter": {
backgroundColor: "#374151",
},
".cm-cursor": {
borderLeftColor: "#f3f4f6",
},
".cm-selectionBackground, ::selection": {
backgroundColor: "#374151 !important",
},
"&.cm-focused .cm-selectionBackground, &.cm-focused ::selection": {
backgroundColor: "#4b5563 !important",
},
}, { dark: true })] : []),
], ],
}); });
@ -813,9 +846,41 @@
// Mount CodeMirror when component mounts // Mount CodeMirror when component mounts
onMount(() => { onMount(() => {
// Initialize dark mode state
isDarkMode = document.documentElement.classList.contains('dark');
createEditor(); createEditor();
// Watch for dark mode changes
const observer = new MutationObserver(() => {
const newDarkMode = document.documentElement.classList.contains('dark');
if (newDarkMode !== isDarkMode) {
isDarkMode = newDarkMode;
// Recreate editor with new theme
if (editorView) {
const currentContent = editorView.state.doc.toString();
editorView.destroy();
createEditor();
// Restore content
if (editorView && currentContent !== content) {
editorView.dispatch({
changes: {
from: 0,
to: editorView.state.doc.length,
insert: currentContent,
},
});
}
}
}
});
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['class'],
});
return () => { return () => {
observer.disconnect();
if (editorView) { if (editorView) {
editorView.destroy(); editorView.destroy();
} }
@ -951,7 +1016,7 @@
: 'w-full'} flex flex-col" : 'w-full'} flex flex-col"
> >
<div <div
class="flex-1 relative border border-gray-200 dark:border-gray-700 rounded-lg bg-white dark:bg-gray-900" class="flex-1 relative border border-gray-200 dark:border-gray-700 rounded-lg bg-white dark:bg-gray-800"
style="overflow: hidden;" style="overflow: hidden;"
> >
<!-- CodeMirror Editor Container --> <!-- CodeMirror Editor Container -->
@ -977,7 +1042,7 @@
</h3> </h3>
</div> </div>
<div class="flex-1 overflow-y-auto p-6 bg-white dark:bg-gray-900"> <div class="flex-1 overflow-y-auto p-6 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100">
<div class="max-w-4xl mx-auto"> <div class="max-w-4xl mx-auto">
{#if !content.trim()} {#if !content.trim()}
<div <div
@ -1038,7 +1103,7 @@
<div class="flex flex-wrap gap-2"> <div class="flex flex-wrap gap-2">
{#each tTags as tag} {#each tTags as tag}
<span <span
class="bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200 px-2 py-1 rounded-full text-xs font-medium" class="bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300 px-2 py-1 rounded-full text-xs font-medium"
> >
#{tag[1]} #{tag[1]}
</span> </span>
@ -1101,7 +1166,7 @@
<div class="flex flex-wrap gap-2"> <div class="flex flex-wrap gap-2">
{#each tTags as tag} {#each tTags as tag}
<span <span
class="bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 py-1 rounded-full text-xs font-medium" class="bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300 px-2 py-1 rounded-full text-xs font-medium"
> >
#{tag[1]} #{tag[1]}
</span> </span>
@ -1230,7 +1295,7 @@
</div> </div>
<div class="relative flex justify-center"> <div class="relative flex justify-center">
<span <span
class="bg-white dark:bg-gray-900 px-3 text-xs text-gray-500 dark:text-gray-400" class="bg-white dark:bg-gray-800 px-3 text-xs text-gray-500 dark:text-gray-400"
> >
Event Boundary Event Boundary
</span> </span>
@ -1242,7 +1307,7 @@
</div> </div>
<div <div
class="mt-4 text-xs text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-900 p-2 rounded border" class="mt-4 text-xs text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-800 p-2 rounded border"
> >
<strong>Event Count:</strong> <strong>Event Count:</strong>
{#if generatedEvents} {#if generatedEvents}

Loading…
Cancel
Save