From c8aa3d5d4ee6c42e6c9cfb389f7a98cccf224fab Mon Sep 17 00:00:00 2001 From: simos Date: Tue, 8 Jul 2025 15:31:03 +0000 Subject: [PATCH] Add word wrap feature to CodeEditor component and clean up styles --- src/components/CodeEditor.jsx | 100 +++++++++++++++------------------- 1 file changed, 45 insertions(+), 55 deletions(-) diff --git a/src/components/CodeEditor.jsx b/src/components/CodeEditor.jsx index 991ca56..ee30230 100755 --- a/src/components/CodeEditor.jsx +++ b/src/components/CodeEditor.jsx @@ -19,6 +19,7 @@ function CodeEditor({ file, onClose, projectPath }) { const [isDarkMode, setIsDarkMode] = useState(true); const [saveSuccess, setSaveSuccess] = useState(false); const [showDiff, setShowDiff] = useState(!!file.diffInfo); + const [wordWrap, setWordWrap] = useState(false); // Create diff highlighting const diffEffect = StateEffect.define(); @@ -75,7 +76,7 @@ function CodeEditor({ file, onClose, projectPath }) { const lineStart = pos; const lineEnd = pos + oldLines[i].length; builder.add(lineStart, lineEnd, Decoration.line({ - class: isDarkMode ? 'diff-removed-dark' : 'diff-removed-light' + class: 'diff-removed-light' })); pos += oldLines[i].length + 1; } @@ -170,7 +171,7 @@ function CodeEditor({ file, onClose, projectPath }) { }); } } - }, [content, file.diffInfo, showDiff, isDarkMode]); + }, [content, file.diffInfo, showDiff]); const handleSave = async () => { setSaving(true); @@ -241,52 +242,29 @@ function CodeEditor({ file, onClose, projectPath }) { if (loading) { return ( - <> - -
-
-
-
- Loading {file.name}... -
+
+
+
+
+ Loading {file.name}...
- +
); } return ( - <> - -
-
+
+
{/* Header */} -
+
@@ -295,14 +273,14 @@ function CodeEditor({ file, onClose, projectPath }) {
-

{file.name}

+

{file.name}

{file.diffInfo && ( - + 📝 Has changes )}
-

{file.path}

+

{file.path}

@@ -310,24 +288,36 @@ function CodeEditor({ file, onClose, projectPath }) { {file.diffInfo && ( )} + +
{/* Footer */} -
-
+
+
Lines: {content.split('\n').length} Characters: {content.length} Language: {file.name.split('.').pop()?.toUpperCase() || 'Text'}
-
+
Press Ctrl+S to save • Esc to close
- ); }