diff options
author | Marcin Aman <maman@virtuslab.com> | 2020-08-04 11:02:51 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-08-05 15:21:13 +0200 |
commit | 08845a66bb86e824f14695a96aa5062ed64edb20 (patch) | |
tree | 13f666fb605de3218d358f8490be1ee666abc310 /plugins/base/frontend/src/main/components/search | |
parent | 046ae90fc7fcf97c6718093b240b55a66670af09 (diff) | |
download | dokka-08845a66bb86e824f14695a96aa5062ed64edb20.tar.gz dokka-08845a66bb86e824f14695a96aa5062ed64edb20.tar.bz2 dokka-08845a66bb86e824f14695a96aa5062ed64edb20.zip |
Fix JS markdown component generating lots of files with highlighting
Diffstat (limited to 'plugins/base/frontend/src/main/components/search')
-rw-r--r-- | plugins/base/frontend/src/main/components/search/searchResultRow.tsx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/plugins/base/frontend/src/main/components/search/searchResultRow.tsx b/plugins/base/frontend/src/main/components/search/searchResultRow.tsx index 81e1bad9..83dd2bcb 100644 --- a/plugins/base/frontend/src/main/components/search/searchResultRow.tsx +++ b/plugins/base/frontend/src/main/components/search/searchResultRow.tsx @@ -1,6 +1,14 @@ import React from "react"; import {OptionWithSearchResult, SearchProps, SearchRank} from "./types"; -import Markdown from '@jetbrains/ring-ui/components/markdown/markdown'; +import _ from "lodash"; + +type HighlighterProps = { + label: string +} + +const Highlighter: React.FC<HighlighterProps> = ({label}: HighlighterProps) => { + return <strong>{label}</strong> +} export const SearchResultRow: React.FC<SearchProps> = ({searchResult}: SearchProps) => { const signatureFromSearchResult = (searchResult: OptionWithSearchResult): string => { @@ -10,9 +18,17 @@ export const SearchResultRow: React.FC<SearchProps> = ({searchResult}: SearchPro return searchResult.highlight } + /* + This is a work-around for an issue: https://youtrack.jetbrains.com/issue/RG-2108 + */ + const out = _.chunk(signatureFromSearchResult(searchResult).split('**'), 2).flatMap(([txt, label]) => [ + txt, + label ? <Highlighter label={label}></Highlighter> : null, + ]); + return ( <div className="template-wrapper"> - <span><Markdown source={signatureFromSearchResult(searchResult)}/></span> + <span>{out}</span> <span className="template-description">{searchResult.description}</span> </div> ) |