-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Copy real HTML from entry preview #13339
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
Conversation
|
About the PR description: Do not put your code changes in there. Put it into the code. This is what the git diff in github is for. |
calixtus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple violations of checkstyle rules.
Please set up your workspace correctly!
https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.html#step-3-set-up-jabrefs-code-style
I don't see that you have applied your proposed fix:

I only see this:
| Document document = previewView.getEngine().getDocument(); | ||
| ClipboardContent content = ClipboardContentGenerator.processHtml(List.of(document.getElementById("content").getTextContent())); | ||
| Document doc = previewView.getEngine().getDocument(); | ||
| ClipboardContent content = ClipboardContentGenerator.processHtml(Arrays.asList(doc.getElementById("content").getTextContent())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid abbreviations. Use modern Java factory methods.
|
What changes are needed kindly guide me. |
|
@trag-bot didn't find any issues in the code! ✅✨ |
|
Works! Looks good now. |
* upstream/main: (54 commits) Move publishing to maven central to a separate workflow (JabRef#13372) Add more guards to workflows not running on forked JabRef repos Copy real HTML from entry preview (JabRef#13339) Adapt some fetcher tests (JabRef#13370) change template issue number (JabRef#13367) Refine error message in URLUtil::create (JabRef#13337) fix deletion again (JabRef#13369) Only prevent failure in publishing from stopping the workflow (JabRef#13368) Refactor "enableFileAnnotationsTab" to "smartFileAnnotationsTab" and rewrote shouldShow in FileAnnotationTab as requested in JabRef#13279 (JabRef#13338) fix workflow (JabRef#13366) Fixamd64linux (JabRef#13365) Only delete for arm64 (JabRef#13364) New Crowdin updates (JabRef#13363) Bump org.junit.jupiter:junit-jupiter-api in /versions (JabRef#13362) Bump org.apache.logging.log4j:log4j-to-slf4j in /versions (JabRef#13359) Bump com.github.javaparser:javaparser-symbol-solver-core in /versions (JabRef#13361) Bump org.junit.platform:junit-platform-launcher in /versions (JabRef#13360) Bump com.fasterxml.jackson.datatype:jackson-datatype-jsr310 in /versions (JabRef#13358) Gradle build updates (JabRef#13319) Add "Disable GitHub actions" (JabRef#13356) ...



Closes #13041
Description
This PR provides a proper fix for the HTML citation copy functionality in the entry preview panel. Previously, when clicking “Copy citation (HTML)”, all formatting and highlighting were lost. This was due to the copyPreviewHtmlToClipBoard() method using getTextContent(), which strips away all HTML elements and style data.
Issue:
The copied content lacks formatting, emphasis, or structure — defeating the purpose of copying HTML.
Comparison:
The “Copy preview” functionality in the main table uses the correct mechanism via CopyCitationAction, which leverages ClipboardContentGenerator.generateCitations() and retains proper HTML structure.
Changes
File: src/main/java/org/jabref/gui/preview/PreviewViewer.java
What:
Replaced the incorrect call to getTextContent() with a proper integration of CopyCitationAction, which uses the citation layout generator to produce well-structured HTML and plain-text versions.
How:
Introduced CopyCitationAction usage in copyPreviewHtmlToClipBoard(), aligned with how it is invoked in the main table right-click menu.
130
Now relies on ClipboardContentGenerator.generateCitations() for consistent formatting.
Result:
Correct and consistent HTML structure is now copied.
Highlighting, formatting, and full HTML tags are preserved.
Aligns functionality with main table's citation copy behavior.
Mandatory checks