Skip to content

Commit

Permalink
fixed 4365 put html in clipboard (#4519)
Browse files Browse the repository at this point in the history
* fixed 4365 put html in clipboard

* put into clipboard an clipboard content
  • Loading branch information
Ali96kz authored and tobiasdiez committed Dec 9, 2018
1 parent 41f2d61 commit b52c972
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/main/java/org/jabref/gui/PreviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
import com.google.common.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

/**
* Displays an BibEntry using the given layout format.
Expand Down Expand Up @@ -351,7 +354,19 @@ public void close() {
}

private void copyPreviewToClipBoard() {
String previewContent = (String) previewView.getEngine().executeScript("document.documentElement.outerHTML");
clipBoardManager.setContent(previewContent);
StringBuilder previewStringContent = new StringBuilder();
Document document = previewView.getEngine().getDocument();
NodeList nodeList = document.getElementsByTagName("*");

for (int i = 0; i < nodeList.getLength(); i++) {
Element element = (Element) nodeList.item(i);
previewStringContent.append(element.getNodeValue()).append("\n");
}

ClipboardContent content = new ClipboardContent();
content.putString(previewStringContent.toString());
content.putHtml((String) previewView.getEngine().executeScript("document.documentElement.outerHTML"));

clipBoardManager.setContent(content);
}
}

0 comments on commit b52c972

Please sign in to comment.