11"use client" ;
22
3- import { useEffect } from "react" ;
4- import { useParams , useSearchParams } from "next/navigation" ;
53import { getSearchHighlight } from "@/utils/api" ;
4+ import { useParams , useSearchParams } from "next/navigation" ;
5+ import { useEffect } from "react" ;
66
77const HIGHLIGHT_NAME = "seqout-query" ;
8- const SHOW_MS = 5000 ;
8+ const SHOW_MS = 50000 ;
99/** Project pages fetch client-side, so give the text time to arrive. */
1010const GIVE_UP_MS = 10000 ;
1111const MAX_RANGES = 500 ;
@@ -28,16 +28,20 @@ export function wordsPattern(words: string[]): RegExp | null {
2828}
2929
3030export function findRanges ( pattern : RegExp ) : Range [ ] {
31- const walker = document . createTreeWalker ( document . body , NodeFilter . SHOW_TEXT , {
32- acceptNode : ( node ) => {
33- const parent = node . parentElement ;
34- if ( ! parent || SKIP_TAGS . has ( parent . tagName ) )
35- return NodeFilter . FILTER_REJECT ;
36- return node . nodeValue ?. trim ( )
37- ? NodeFilter . FILTER_ACCEPT
38- : NodeFilter . FILTER_REJECT ;
31+ const walker = document . createTreeWalker (
32+ document . body ,
33+ NodeFilter . SHOW_TEXT ,
34+ {
35+ acceptNode : ( node ) => {
36+ const parent = node . parentElement ;
37+ if ( ! parent || SKIP_TAGS . has ( parent . tagName ) )
38+ return NodeFilter . FILTER_REJECT ;
39+ return node . nodeValue ?. trim ( )
40+ ? NodeFilter . FILTER_ACCEPT
41+ : NodeFilter . FILTER_REJECT ;
42+ } ,
3943 } ,
40- } ) ;
44+ ) ;
4145 const ranges : Range [ ] = [ ] ;
4246 let node : Node | null ;
4347 while ( ( node = walker . nextNode ( ) ) ) {
@@ -64,7 +68,8 @@ export default function QueryHighlight() {
6468
6569 useEffect ( ( ) => {
6670 // CSS Custom Highlight API: no DOM mutation, so React never fights it.
67- if ( ! q || ! accession || typeof CSS === "undefined" || ! CSS . highlights ) return ;
71+ if ( ! q || ! accession || typeof CSS === "undefined" || ! CSS . highlights )
72+ return ;
6873
6974 const abort = new AbortController ( ) ;
7075 let poll : ReturnType < typeof setInterval > | undefined ;
0 commit comments