Skip to content

Get elements highlighted from the search result #18946

Closed Answered by ruppo-912116
ruppo-912116 asked this question in Q&A
Discussion options

You must be logged in to vote

Let me share my simple work around for this. While inspecting the div, I noticed the highlighted text had class named "highlight" to them. So what I did was obtain all those elements with the 'highlight' class. Then, I obtained the position of each of them via getBoundingRect, created a

element (to show the boxes over the text) for each of the position and width and then appended them to the annotation layer.

Here is a small code snippet to show the main idea

/* id is just a unique identification for those annotations. selectRect is the highlighted span element obtained when looping through the result of getElementsByClassName  */
    renderToViewport = (id, selectionRect) => {
        c…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ruppo-912116
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant