Future-Scholars / paperlib

An open-source academic paper management tool.
https://paperlib.app
GNU General Public License v3.0
1.57k stars 68 forks source link

[Feature Request] Highlight search results #525

Closed thequilo closed 6 months ago

thequilo commented 6 months ago

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.

GeoffreyChen777 commented 6 months ago

From the programming implementation aspect, this is difficult

thequilo commented 6 months ago

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>")?

GeoffreyChen777 commented 6 months ago

Thanks for your suggestion, will consider that

igoogolx commented 6 months ago

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

GeoffreyChen777 commented 6 months ago

@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 commented 6 months ago

Seems the performance is ok. #528

This will be available with the next version.

image
thequilo commented 6 months ago

Thanks a lot!