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

Entry preview lose formating if search field is used #5069

Closed
buhtz opened this issue Jun 20, 2019 · 8 comments · Fixed by #5472
Closed

Entry preview lose formating if search field is used #5069

buhtz opened this issue Jun 20, 2019 · 8 comments · Fixed by #5472
Labels
bug Confirmed bugs or reports that are very likely to be bugs entry-preview search
Milestone

Comments

@buhtz
Copy link

buhtz commented Jun 20, 2019

Tried with current 5.* dev on Windows 10.

Entry preview looks nice.
snapshot

But when I use the search field e.g. keywords=lesen or author=nord then it looks like this.
copy-paste

@Siedlerchr
Copy link
Member

Issues is from the search highlighting of the search term. When you stop searching it's back to normal

@Siedlerchr Siedlerchr added bug Confirmed bugs or reports that are very likely to be bugs search entry-preview labels Jul 6, 2019
@Siedlerchr
Copy link
Member

The highlighting is handled by this simple javascript code:

private static final String JS_HIGHLIGHT_FUNCTION = " <script type=\"text/javascript\">\r\n" +
" function highlight(text) {\r\n" +
" var innertxt = document.body.innerText;\r\n" +
" var response = innertxt.replace(new RegExp(text, 'gi'), str => `<span style='background-color:red'>${str}</span>`);\r\n" +
" document.body.innerHTML = response;\r\n" +
" }\r\n" +
" </script>";

@buhtz
Copy link
Author

buhtz commented Jul 10, 2019

I know nothing about JS.
What does your last post mean? It is easy to fix or the opposite?

@TomasLukac
Copy link

I have tried if this issue still remains in the master branch and not only does it lose formatting, it also jumps to the Author field automatically, so I am rewriting my Author after search finds a result.
The formatting goes back to normal when I click to other article, not after finishing search, as @Siedlerchr said.

I would like to look at this issue and fix it.

@tobiasdiez
Copy link
Member

The problem is probably that we read the inner text (i.e everything without formatting) and then set it as the inner html. Should work if document.body.innerText is replaced by document.body.innerHtml

@tobiasdiez tobiasdiez added this to the v5.0 milestone Oct 7, 2019
@Siedlerchr
Copy link
Member

Siedlerchr commented Oct 7, 2019

@tobiasdiez It is not that easy. That's what I did before. The problem is then that it displays and searches matches in html tags

@tobiasdiez
Copy link
Member

This should be fixed in the latest development version. Could you please check the build from http://builds.jabref.org/master/. Thanks! Please remember to make a backup of your library before trying-out this version.

@buhtz
Copy link
Author

buhtz commented Oct 19, 2019

Confirmed. It is fixed and working for me.
Thanks a lot.

@koppor koppor moved this to Done in Prioritization Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bugs or reports that are very likely to be bugs entry-preview search
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants