PluginProbe
Tableberg – Simple Gutenberg Table Block / 1.1.5
Tableberg – Simple Gutenberg Table Block v1.1.5
1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 All 42 releases
tableberg / src / components / HighlightedText.tsx

HighlightedText.tsx in Tableberg – Simple Gutenberg Table Block 1.1.5, at src/components/HighlightedText.tsx

36 lines 875 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { getHighlightSegments } from "../search";
2
3 interface HighlightedTextProps {
4 content: string;
5 searchTerm: string;
6 highlightColor: string;
7 }
8
9 export function HighlightedText({
10 content,
11 searchTerm,
12 highlightColor,
13 }: HighlightedTextProps) {
14 const segments = getHighlightSegments(content, searchTerm);
15
16 return (
17 <>
18 {segments.map((segment, index) =>
19 segment.highlighted ? (
20 <mark
21 key={index}
22 style={{
23 backgroundColor: highlightColor,
24 borderRadius: "2px",
25 }}
26 >
27 {segment.text}
28 </mark>
29 ) : (
30 segment.text
31 )
32 )}
33 </>
34 );
35 }
36