Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export function registerHighlightedText(
},
highlight: {
type: "string",
description: "The substring to highlight (case insensitive)",
description:
'Substring to highlight (case insensitive). For multiple words, use a dynamic value with a string array, e.g. ["APE", "GME"].',
},
textClassName: {
type: "class",
Expand Down
5 changes: 3 additions & 2 deletions src/code-components/HighlightedText/HighlightedText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Highlighter from "react-highlight-words";

interface HighlightedTextProps {
text: string;
highlight: string;
highlight: string | string[];
textClassName?: string;
highlightClassName?: string;
}
Expand All @@ -14,10 +14,11 @@ export function HighlightedText({
textClassName,
highlightClassName,
}: HighlightedTextProps) {
const searchWords = Array.isArray(highlight) ? highlight : [highlight];
return (
<span className={textClassName}>
<Highlighter
searchWords={[highlight]}
searchWords={searchWords}
textToHighlight={text}
highlightClassName={highlightClassName}
caseSensitive={false}
Expand Down
Loading