From 978981dd6bddac9476c04a122df11e02fd31b0f3 Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Tue, 16 Sep 2025 18:06:15 +0800 Subject: [PATCH] Fix search highlighting scroll issue and improve color contrast - Remove overlay-based highlighting that stayed in place during scroll - Switch between read-only highlighted view and editable textarea based on search state - Enhance color contrast: current match (red text + yellow bg), other matches (blue text + light blue bg) - Use font-bold for better visibility of search results - Ensure highlights follow text content during scrolling --- .../File Manager/components/FileViewer.tsx | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/src/ui/Desktop/Apps/File Manager/components/FileViewer.tsx b/src/ui/Desktop/Apps/File Manager/components/FileViewer.tsx index 6422bc72..df74e5cd 100644 --- a/src/ui/Desktop/Apps/File Manager/components/FileViewer.tsx +++ b/src/ui/Desktop/Apps/File Manager/components/FileViewer.tsx @@ -240,10 +240,10 @@ export function FileViewer({ {text.substring(match.start, match.end)} @@ -522,32 +522,29 @@ export function FileViewer({ {shouldShowAsText && !showLargeFileWarning && (
{isEditable ? ( -
- {/* 高亮背景层 */} - {searchText && ( -
+
+ {searchText && searchMatches.length > 0 ? ( + // 当有搜索结果时,显示只读的高亮文本 +
{renderHighlightedText(editedContent)}
+ ) : ( + // 没有搜索时显示可编辑的textarea +