diff --git a/src/components/CodeEditor.jsx b/src/components/CodeEditor.jsx index ee2249d..20eff13 100644 --- a/src/components/CodeEditor.jsx +++ b/src/components/CodeEditor.jsx @@ -11,7 +11,7 @@ import { StreamLanguage } from '@codemirror/language'; import { EditorView, showPanel, ViewPlugin } from '@codemirror/view'; import { unifiedMergeView, getChunks } from '@codemirror/merge'; import { showMinimap } from '@replit/codemirror-minimap'; -import { X, Save, Download, Maximize2, Minimize2 } from 'lucide-react'; +import { X, Save, Download, Maximize2, Minimize2, Settings as SettingsIcon } from 'lucide-react'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; import remarkMath from 'remark-math'; @@ -48,7 +48,6 @@ const envLanguage = StreamLanguage.define({ }, }); -// Markdown preview code block component function MarkdownCodeBlock({ inline, className, children, ...props }) { const [copied, setCopied] = useState(false); const raw = Array.isArray(children) ? children.join('') : String(children ?? ''); @@ -241,8 +240,13 @@ function CodeEditor({ file, onClose, projectPath, isSidebar = false, isExpanded ]; }, [file.diffInfo, showDiff]); - // Create editor toolbar panel - always visible + // Whether toolbar has any buttons worth showing + const hasToolbarButtons = !!(file.diffInfo || (isSidebar && onPopOut) || (isSidebar && onToggleExpand)); + + // Create editor toolbar panel - only when there are buttons to show const editorToolbarPanel = useMemo(() => { + if (!hasToolbarButtons) return []; + const createPanel = (view) => { const dom = document.createElement('div'); dom.className = 'cm-editor-toolbar-panel'; @@ -295,15 +299,7 @@ function CodeEditor({ file, onClose, projectPath, isSidebar = false, isExpanded `; } - // Settings button - toolbarHTML += ` - - `; - + // Pop out button (only in sidebar mode with onPopOut) if (isSidebar && onPopOut) { toolbarHTML += ` )} + +