diff options
Diffstat (limited to 'plugins/base/frontend/src/main/components/search/searchResultRow.tsx')
-rw-r--r-- | plugins/base/frontend/src/main/components/search/searchResultRow.tsx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/plugins/base/frontend/src/main/components/search/searchResultRow.tsx b/plugins/base/frontend/src/main/components/search/searchResultRow.tsx new file mode 100644 index 00000000..9ae19cb9 --- /dev/null +++ b/plugins/base/frontend/src/main/components/search/searchResultRow.tsx @@ -0,0 +1,24 @@ +import React from "react"; +import {OptionWithSearchResult, SearchProps, SearchRank} from "./types"; + +export const SearchResultRow: React.FC<SearchProps> = ({searchResult}: SearchProps) => { + const signatureFromSearchResult = (searchResult: OptionWithSearchResult): string => { + if(searchResult.rank == SearchRank.SearchKeyMatch){ + return searchResult.name.replace(searchResult.searchKey, searchResult.highlight) + } + return searchResult.highlight + } + + const renderHighlightMarkersAsHtml = (record: string): string => { + return record.replace(/\*\*(.*?)\*\*/g, '<span class="phraseHighlight">$1</span>') + } + + return ( + <div className="template-wrapper"> + <span dangerouslySetInnerHTML={ + {__html: renderHighlightMarkersAsHtml(signatureFromSearchResult(searchResult)) } + }/> + <span className="template-description">{searchResult.description}</span> + </div> + ) +}
\ No newline at end of file |