Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight search results #12

Closed
miwurster opened this issue Dec 30, 2017 · 13 comments · Fixed by #26
Closed

Highlight search results #12

miwurster opened this issue Dec 30, 2017 · 13 comments · Fixed by #26

Comments

@miwurster
Copy link

image

See an example:
image

@luko0610
Copy link
Contributor

Hello, if this is still available I'd like to take it.

@koppor
Copy link
Member

koppor commented Oct 18, 2019

Sure, go ahead!

@luko0610
Copy link
Contributor

I'm having an issue setting up the project. I cannot login, altough I created the sqlite file under the user.home directory.

@luko0610
Copy link
Contributor

Okay, I got it to work.

@koppor
Copy link
Member

koppor commented Oct 19, 2019

No login issue is described at #24. Maybe, you can support there, too.

@luko0610
Copy link
Contributor

I'll look into it once I'm back home.

@luko0610
Copy link
Contributor

luko0610 commented Oct 19, 2019

@koppor
Hello,
So I ran into a small issue and need some advice.
My approach is to insert a html tag directly into the references array, which works perfect if you only search once. The problem is because I am directly altering the data, the added from the previous search will still be there. So I need to find a way to create a backup of the references array before altering it, which I can then use to restore the references before the next search.

I've tried several approaches to make a deep copy of the references, but it always copies by reference.

1st search (works perfectly)
1
2nd search (still having the markup from the 1st search)
2

@koppor
Copy link
Member

koppor commented Oct 20, 2019

I think, the reference should have an attribute "searchResultHit" (boolean). If true, the CSS class "highlighted" is applied. This CSS class implements some sort of highlighting. - At the beginning of a search. searchResultHit is cleared.

@luko0610
Copy link
Contributor

luko0610 commented Oct 20, 2019

Yes, but because we do not want to highlight the whole text we need to actually insert a html tag around the part of the text we want to highlight and assign the css class to that tag.

@koppor
Copy link
Member

koppor commented Oct 20, 2019

Oh, I see.

Did you check https://angular.de/artikel/mark-highlight-search-results/ and https://stackoverflow.com/a/52569482/873282 and https://stackoverflow.com/a/46106843/873282. These came out here when I googled angular highlight search result. Did they work? If not, please start creating an ADR in docs/adr.

@luko0610
Copy link
Contributor

Thanks for your response. First link looks promising. Haven't been thinking about that approch. I'll try it out tomorrow.

@tobiasdiez
Copy link
Member

There is also markjs if you want to highlight on the client side

@luko0610
Copy link
Contributor

Okay, I finished it and made a pull request. Solving this using a custom pipe was way easier than I thought.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants