-
setSearchText(e.target.value)}
- placeholder="搜索(上下键切换)"
- />
-
onClose(false)}
- className="music-monaco-editor--close">
-
+ setExpand((pre) => !pre)}
+ >
+
+
+
+
+
setSearchText(e.target.value)}
+ placeholder="搜索(上下键切换)"
/>
+
onClose(false)}
+ className="music-monaco-editor-close"
+ >
+
+
+
+ {expand && (
+
+
setReplaceText(e.target.value)}
+ placeholder="替换"
+ />
+
+
+
+
+ )}
+
);
};
-export default SearchInput;
\ No newline at end of file
+export default SearchInput;
diff --git a/src/components/searchtext/search-result.tsx b/src/components/searchtext/search-result.tsx
index aa776c5..813b530 100644
--- a/src/components/searchtext/search-result.tsx
+++ b/src/components/searchtext/search-result.tsx
@@ -1,60 +1,96 @@
import React from 'react';
-import SearchFileTitle from './search-file-title'
+import SearchFileTitle from './search-file-title';
+import Replace from '@components/icons/replace';
interface SearchResultProps {
searchResults: Array<{ [key: string]: Array<{ code: string }> }>;
unExpandedTitles: Record
;
searchText: string;
selectedRow: { titleIndex: number; rowIndex: number };
- handleRowSelection: (titleIndex: number, title: string, rowIndex: number, row: { code: string }) => void;
+ handleRowSelection: (titleIndex: number, rowIndex: number) => void;
toggleExpand: (expanded: boolean, titleIndex: number) => void;
+ replaceRowSelection: (
+ event: React.MouseEvent
+ ) => void;
+ canReplace: boolean;
}
-const SearchResult : React.FC = ({
+const SearchResult: React.FC = ({
searchResults,
unExpandedTitles,
searchText,
selectedRow,
handleRowSelection,
toggleExpand,
+ replaceRowSelection,
+ canReplace,
}) => {
- const renderStringWithHighlight = (str: string, highlight: string) => {
- const parts = str.split(highlight);
- return (
-
- {parts.map((part, index) => (
-
- {part}
- {index !== parts.length - 1 && {highlight}}
-
- ))}
-
- );
- };
+ const renderStringWithHighlight = (str: string, highlight: string) => {
+ const parts = str.split(highlight);
return (
-
+
+ {parts.map((part, index) => (
+
+ {part}
+ {index !== parts.length - 1 && (
+ {highlight}
+ )}
+
+ ))}
+
+ );
+ };
+ return (
+
{searchResults.map((result, titleIndex) => {
return Object.keys(result ?? {}).map((title) => (
-
toggleExpand(expanded, titleIndex)}
+ onExpanded={(expanded: boolean) =>
+ toggleExpand(expanded, titleIndex)
+ }
/>
-
- {searchText && result[title].map((row, rowIndex) => (
- - handleRowSelection(titleIndex, title, rowIndex, row)}
- >
- {renderStringWithHighlight(row.code, searchText)}
-
- ))}
+
));
@@ -63,4 +99,4 @@ const SearchResult : React.FC = ({
);
};
-export default SearchResult;
\ No newline at end of file
+export default SearchResult;
diff --git a/src/components/searchtext/search-text.less b/src/components/searchtext/search-text.less
index ffbe3b8..3ec9007 100644
--- a/src/components/searchtext/search-text.less
+++ b/src/components/searchtext/search-text.less
@@ -7,15 +7,6 @@
border: 1px solid #F0F0F0;
}
-.search-result-top-search {
- position: sticky;
- z-index: 1;
- background: var(--monaco-editor-background);
- display: flex;
- align-items: center;
- padding-right: 5px;
-}
-
.search-result-list {
margin-top: 0;
overflow-y: auto;
@@ -45,6 +36,21 @@
}
}
+.search-results-code {
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ margin-left: 10px;
+}
+
+.search-results-replace {
+ display: inline-block;
+ width: 20px;
+ height: 20px;
+ cursor: pointer;
+ margin: 0 5px 0 5px;
+}
+
.search-results-title,
.search-results-item-selected,
.search-results-item {
@@ -54,6 +60,9 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
+ display: flex;
+ flex-direction: horizontal;
+ align-items: center;
color: var(--monaco-list-focusForeground)
}
@@ -67,15 +76,82 @@
background: var(--monaco-list-focusBackground);
color: var(--monaco-list-focusForeground)
}
+
+.search-result-top-search {
+ position: sticky;
+ z-index: 1;
+ background: var(--monaco-editor-background);
+ display: flex;
+ flex-direction: horizontal;
+}
+
+.search-result-search-innner {
+ display: flex;
+ flex: 1;
+ flex-direction: column;
+ background: var(--monaco-editor-background);
+}
+
+.search-result-search-replace-container,
+.search-result-search-container {
+ display: flex;
+ background: var(--monaco-editor-background);
+ display: flex;
+ align-items: center;
+ padding-right: 5px;
+}
+
.search-result-input {
flex: 1;
border-radius: 2px;
background: var(--monaco-list-focusBackground);
border: 0.5px solid;
margin: 5px;
+ min-width: 70px;
+ height: 20px;
+ padding-left: 5px;
+ color: var(--monaco-list-focusForeground)
+}
+
+.search-result-input-replace {
+ flex: 1;
+ border-radius: 2px;
+ background: var(--monaco-list-focusBackground);
+ border: 0.5px solid;
+ margin: 0 5px 5px 5px;
margin-right: 5px;
min-width: 70px;
height: 20px;
padding-left: 5px;
color: var(--monaco-list-focusForeground)
}
+
+.music-monaco-editor-close,
+.music-monaco-editor-replace
+{
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ cursor: pointer;
+ width: 20px;
+ height: 20px;
+}
+
+.search-result-replace-switch {
+ display: flex;
+ padding-left: 5px;
+ justify-content: center;
+ align-items: center;
+ cursor: pointer;
+}
+
+.search-results-file-name {
+ color: var(--monaco-list-focusForeground);
+ font-size: 13px;
+}
+
+.search-results-file-path {
+ color: var(--monaco-list-focusForeground);
+ margin-left: 5px;
+ font-size: 12px;
+}
\ No newline at end of file
diff --git a/src/multi/Editor.tsx b/src/multi/Editor.tsx
index 922d720..24053de 100644
--- a/src/multi/Editor.tsx
+++ b/src/multi/Editor.tsx
@@ -797,7 +797,7 @@ const MultiPrivateEditorComp = React.forwardRef<
column: 1,
},
});
- }, []);
+ }, [getAllFiles]);
const configListFiles = useCallback(() => {
const obj = getAllFiles();
@@ -815,6 +815,16 @@ const MultiPrivateEditorComp = React.forwardRef<
return Object.keys(obj);
}, [getAllFiles]);
+ const onReplace = useCallback((listFiles: Record) => {
+ const obj = getAllFiles();
+ for (const key in obj) {
+ if (listFiles[key] !== null) {
+ obj[key] = listFiles[key];
+ }
+ }
+ refreshFiles(obj);
+ }, [getAllFiles]);
+
return (
setSearchTextVisible(false)}
+ onReplace={onReplace}
+ rootEl={rootRef}
/>
)}