paperlib icon indicating copy to clipboard operation
paperlib copied to clipboard

[Feature Request] Highlight search results

Open thequilo opened this issue 9 months ago • 5 comments

Describe your feature request

It would be nice to highlight the words that match the query in the search results. For me, it makes it much easier to find the item I am looking for when I see the matched words highlighted.

thequilo avatar May 13 '24 08:05 thequilo

From the programming implementation aspect, this is difficult

GeoffreyChen777 avatar May 13 '24 08:05 GeoffreyChen777

I can imagine that. How about doing this just for the simple search and add a second pass, after matching, with something along the lines of result.replace(query_word, "<span class=highlight>" + query_word +"</span>")?

thequilo avatar May 13 '24 08:05 thequilo

Thanks for your suggestion, will consider that

GeoffreyChen777 avatar May 13 '24 08:05 GeoffreyChen777

We can use https://github.com/kawamataryo/vue-word-highlighter with less code.

igoogolx avatar May 13 '24 08:05 igoogolx

@igoogolx that looks pretty good!

Currently, we can get the searing string: https://github.com/Future-Scholars/paperlib/blob/da0f48e65dd3e4144bb6aaa71c2f07726c3b96f0/app/renderer/services/uistate-service.ts#L45 with vue-word-highlighter, it would be easy to implement this feature.

However, we still need to test the rendering performance to make sure it will not slow down the UI if we have numerous papers.

GeoffreyChen777 avatar May 13 '24 08:05 GeoffreyChen777

Seems the performance is ok. #528

This will be available with the next version.

image

GeoffreyChen777 avatar May 17 '24 22:05 GeoffreyChen777

Thanks a lot!

thequilo avatar May 20 '24 12:05 thequilo