@ -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-9 00"
class="flex-1 relative border border-gray-200 dark:border-gray-700 rounded-lg bg-white dark:bg-gray-8 00"
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-1 00" >
< 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-2 00 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-3 00 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-2 00 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-3 00 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-9 00 px-3 text-xs text-gray-500 dark:text-gray-400"
class="bg-white dark:bg-gray-8 00 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-9 00 p-2 rounded border"
class="mt-4 text-xs text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-8 00 p-2 rounded border"
>
>
< strong > Event Count:< / strong >
< strong > Event Count:< / strong >
{ #if generatedEvents }
{ #if generatedEvents }