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

Spurious text included with copied previews #5263

Closed
wujastyk opened this issue Aug 30, 2019 · 16 comments
Closed

Spurious text included with copied previews #5263

wujastyk opened this issue Aug 30, 2019 · 16 comments
Labels
entry-preview status: waiting-for-feedback The submitter or other users need to provide more information about the issue ui
Milestone

Comments

@wujastyk
Copy link

JabRef 5.0-dev--snapshot--2019-08-30--master--66b7fe3af
Linux 5.0.0-25-generic amd64
Java 11.0.4

  1. Open the entry editor
  2. select the Required fields tab
  3. A right column displays the formatted entry (attached image)

Screenshot from 2019-08-30 14-17-24

  1. right-click the preview and select "copy".
  2. The result in the clipboard is this:
      function highlight(text) {
           var innertxt = document.body.innerText;
           var response = innertxt.replace(new RegExp(text, 'gi'), str => `<span style='background-color:red'>${str}</span>`);
           document.body.innerHTML = response;
       }
   Acharya, D., 2006. Vācaspatimiśra’s Tattvasamīkṣā. the Earliest Commentary on Mandanamiśra’s Brahmasiddhi. Critically Edited with an Introduction and Critical Notes. Nepal Research Centre Publications. Stuttgart: Franz Steiner Verlag.

That spurious "function highlight(text){...} " gets included with all copies.

@wujastyk wujastyk changed the title Spurious text including with copied previews Spurious text included with copied previews Aug 30, 2019
@Siedlerchr
Copy link
Member

The javascript code is from the highlighting for search results in the entry preview. Seems like the entry preview is copied as html. If you use the ctrl +c and ctrl +v it should work without issues.

@AEgit
Copy link

AEgit commented Sep 8, 2019

JabRef 5.0-dev
Linux 5.0.0-27-generic amd64
Java 1.8.0_222

Cannot confirm this issue for the current snap version of JabRef. Note, that the current snap version does not incorporate the preview in the entry editor as shown above. So the issue might actually persist and if that is the case it might have been introduced with the changes made to the preview and the entry editor.

@Siedlerchr
Copy link
Member

Siedlerchr commented Sep 12, 2019

The snap build has been fixed, so that it now also runs with java 11 and the automatic build should also be working again for future updates.
Could you please test that version and report back if the error still occurs?

@AEgit You are now also able to run the newest version without modifying the default java env, as JabRef now ships with all required java dependencies.
https://builds.jabref.org/master/
For Linux use the tar.gz archive. It now contains a start script as well.

@Siedlerchr Siedlerchr added the status: waiting-for-feedback The submitter or other users need to provide more information about the issue label Sep 12, 2019
@AEgit
Copy link

AEgit commented Sep 12, 2019

JabRef 5.0-dev
Linux 5.0.0-27-generic amd64
Java 11.0.4

I can confirm that this issue is fixed in the latest dev-version.

@matthiasgeiger
Copy link
Member

Sorry, need to re-open this, as it is still not working properly for me in latest dev builds...

@matthiasgeiger
Copy link
Member

Moreover: Using the "Copy Preview" functionality from the main table context menu does not work at all.

@AEgit
Copy link

AEgit commented Sep 22, 2019

JabRef 5.0-dev
Linux 5.0.0-29-generic amd64
Java 11.0.4

@matthiasgeiger I have tried to reproduce the issues that you report in #5263 (comment) and #5263 (comment) with the latest snap version (--edge channel), but I still do not manage to: everything works as expected for me. Can you provide a minimum example of a database, where you run into these issues?

@matthiasgeiger
Copy link
Member

Meanwhile I have performed some analysis: the problem is caused by different 'paste'-targets: when the target is able to interpret HTML formatted text it is working fine - if you use a tool supporting only plain text not (e.g. Windows editor).
I'll try to work on a fix in the next days... 😀

@AEgit
Copy link

AEgit commented Sep 22, 2019

@matthiasgeiger You are absolutely right. Now I can confirm the issues you report, if I use a simple text editor as paste target. I never thought, that the paste target would make a difference. Well spotted!

@Siedlerchr
Copy link
Member

The embedded Javascript comes from n the search highlight function. It's added when the citation style is loaded in the web view. So technically it's correct that it's also shown in paste, if the target does not interpret html.

@matthiasgeiger
Copy link
Member

Well, yes and no. The remainder of the HTML code is stripped off before, i.e. the text formatting code is not shown when pasting into a plain text editor.
I'll try to implement the copy action in a way that the plain format does not contain any formatting information, but the HTML content is preserved for editors supporting that.
The question is what should be pasted if someone explicitly wants to copy HTML/XML/... and pastes this to a plain text editor.. the stripped version without formatting, or the code including all HTML/XML tags?

@wujastyk
Copy link
Author

Both HTML and plain "text" are offered separately already, so the "text" option should not have HTML codes. It should be plain text. Seem the two menu choices in the attached screenshot.

Screenshot from 2019-09-22 09-39-28

@tobiasdiez
Copy link
Member

I think one of the problems is that these methods

public void setHtmlContent(String html) {

never set html and string together. Normally you want to use putString and putHtml together and then the target application chooses which representation it wants to use.

@tobiasdiez tobiasdiez added this to the v5.0 milestone Sep 27, 2019
@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.

@wujastyk
Copy link
Author

wujastyk commented Oct 8, 2019

JabRef 5.0.0-dev--2019-10-07----facda00c1
Linux 5.0.0-31-generic amd64
Java 11.0.4

I confirm the fix. Many thanks!

@AEgit
Copy link

AEgit commented Oct 17, 2019

JabRef 5.0.0-dev--2019-10-17----e81d58c51
Windows 10 10.0 amd64
Java 12.0.2

Can confirm that this has been fixed in the current dev version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
entry-preview status: waiting-for-feedback The submitter or other users need to provide more information about the issue ui
Projects
Archived in project
Development

No branches or pull requests

5 participants