diff --git a/surfsense_web/components/editor-panel/editor-panel.tsx b/surfsense_web/components/editor-panel/editor-panel.tsx index 41cbb2ca1..71cdc79ea 100644 --- a/surfsense_web/components/editor-panel/editor-panel.tsx +++ b/surfsense_web/components/editor-panel/editor-panel.tsx @@ -313,13 +313,20 @@ export function EditorPanelContent({ }; }, []); - const handleMarkdownChange = useCallback((md: string) => { - markdownRef.current = md; - if (!initialLoadDone.current) return; - changeCountRef.current += 1; - if (changeCountRef.current <= 1) return; - setEditedMarkdown(md); - }, []); + const handleMarkdownChange = useCallback( + (md: string) => { + if (!isEditing) return; + + markdownRef.current = md; + if (!initialLoadDone.current) return; + changeCountRef.current += 1; + if (changeCountRef.current <= 1) return; + + const savedContent = editorDoc?.source_markdown ?? ""; + setEditedMarkdown(md === savedContent ? null : md); + }, + [editorDoc?.source_markdown, isEditing] + ); const handleCopy = useCallback(async () => { try { @@ -798,7 +805,7 @@ export function EditorPanelContent({ placeholder="Start writing..." editorVariant="default" allowModeToggle={false} - reserveToolbarSpace={isEditing} + reserveToolbarSpace defaultEditing={isEditing} className="**:[[role=toolbar]]:bg-sidebar!" // Render `[citation:N]` badges in view mode only. diff --git a/surfsense_web/components/ui/fixed-toolbar.tsx b/surfsense_web/components/ui/fixed-toolbar.tsx index 540088ea5..591d2a5d3 100644 --- a/surfsense_web/components/ui/fixed-toolbar.tsx +++ b/surfsense_web/components/ui/fixed-toolbar.tsx @@ -14,7 +14,7 @@ export function FixedToolbar({ return (