@@ -3,7 +3,7 @@ import { Fragment, useCallback, useEffect, useRef, useState } from "react";
33import { Link , useNavigate , useSearchParams } from "react-router-dom" ;
44import { get , getPaginated } from "../app/api" ;
55import { theme } from "../app/mui" ;
6- import { randomString , thingFromJsonProperties } from "../app/util" ;
6+ import { randomString , thingFromJsonProperties , highlightMatch } from "../app/util" ;
77import Entity from "../model/Entity" ;
88import Ontology from "../model/Ontology" ;
99import { Suggest } from "../model/Suggest" ;
@@ -175,7 +175,11 @@ export default function SearchBox({
175175 setQuery ( autocomplete . autosuggest ) ;
176176 } }
177177 >
178- { autocomplete . autosuggest }
178+ < span
179+ dangerouslySetInnerHTML = { {
180+ __html : highlightMatch ( autocomplete . autosuggest , query )
181+ } }
182+ />
179183 </ li >
180184 ) ,
181185 } ;
@@ -216,9 +220,13 @@ export default function SearchBox({
216220 to = { linkUrl }
217221 >
218222 < div className = "flex justify-between" >
219- < div className = "truncate flex-auto" title = { name } >
220- { name }
221- </ div >
223+ < div
224+ className = "truncate flex-auto"
225+ title = { name }
226+ dangerouslySetInnerHTML = { {
227+ __html : highlightMatch ( name , query )
228+ } }
229+ />
222230 < div className = "truncate flex-initial ml-2 text-right" >
223231 < span
224232 className = "mr-2 bg-link-default px-3 py-1 rounded-lg text-sm text-white uppercase"
@@ -277,9 +285,10 @@ export default function SearchBox({
277285 title = {
278286 jumpToEntry . getName ( ) || jumpToEntry . getOntologyId ( )
279287 }
280- >
281- { jumpToEntry . getName ( ) || jumpToEntry . getOntologyId ( ) }
282- </ div >
288+ dangerouslySetInnerHTML = { {
289+ __html : highlightMatch ( jumpToEntry . getName ( ) || jumpToEntry . getOntologyId ( ) , query )
290+ } }
291+ />
283292 < div className = "truncate flex-initial ml-2 text-right" >
284293 < span className = "bg-link-default px-3 py-1 rounded-lg text-sm text-white uppercase" >
285294 { jumpToEntry . getOntologyId ( ) }
0 commit comments