mirror of
https://github.com/zadam/trilium.git
synced 2025-10-29 10:39:00 +01:00
chore(react/collections): highlighting in grid title
This commit is contained in:
parent
1cee01a22a
commit
d52f9f2a92
@ -87,11 +87,14 @@ function GridNoteCard({ note, parentNote, highlightedTokens }: { note: FNote, pa
|
|||||||
const titleRef = useRef<HTMLSpanElement>(null);
|
const titleRef = useRef<HTMLSpanElement>(null);
|
||||||
const [ noteTitle, setNoteTitle ] = useState<string>();
|
const [ noteTitle, setNoteTitle ] = useState<string>();
|
||||||
const notePath = getNotePath(parentNote, note);
|
const notePath = getNotePath(parentNote, note);
|
||||||
|
const highlightSearch = useImperativeSearchHighlighlighting(highlightedTokens);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
tree.getNoteTitle(note.noteId, parentNote.noteId).then(setNoteTitle);
|
tree.getNoteTitle(note.noteId, parentNote.noteId).then(setNoteTitle);
|
||||||
}, [ note ]);
|
}, [ note ]);
|
||||||
|
|
||||||
|
useEffect(() => highlightSearch(titleRef.current), [ noteTitle, highlightedTokens ]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`note-book-card no-tooltip-preview block-link`}
|
className={`note-book-card no-tooltip-preview block-link`}
|
||||||
|
|||||||
@ -558,7 +558,7 @@ export function useImperativeSearchHighlighlighting(highlightedTokens: string[]
|
|||||||
return new RegExp(regex, "gi")
|
return new RegExp(regex, "gi")
|
||||||
}, [ highlightedTokens ]);
|
}, [ highlightedTokens ]);
|
||||||
|
|
||||||
return (el: HTMLElement) => {
|
return (el: HTMLElement | null | undefined) => {
|
||||||
if (!el || !highlightRegex) return;
|
if (!el || !highlightRegex) return;
|
||||||
|
|
||||||
if (!mark.current) {
|
if (!mark.current) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user