-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
add selection copy to preview window #7421
add selection copy to preview window #7421
Conversation
@@ -224,6 +224,13 @@ public void copyPreviewToClipBoard() { | |||
clipBoardManager.setContent(content); | |||
} | |||
|
|||
public void copySelectionToClipBoard() { | |||
ClipboardContent content = new ClipboardContent(); | |||
content.putString(getSelectionHtmlContent()); |
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.
We had some problems in the past with rich-text copy & past, i.e. if you copy bold text and past it into say Word.
For this to work you also need to use putHtml
as the other methods above. Moreover, the method getSelectionHtmlContent seems to only return the text, not the html, so a better name would be getSelectionTextContent
. Getting the html might be a bit more difficult, https://stackoverflow.com/questions/4176923/html-of-selected-text/4177234#4177234 is a starting point but maybe there are also simpler ways in the meantime.
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.
We had some problems in the past with rich-text copy & past, i.e. if you copy bold text and past it into say Word.
For this to work you also need to use
putHtml
as the other methods above. Moreover, the method getSelectionHtmlContent seems to only return the text, not the html, so a better name would begetSelectionTextContent
. Getting the html might be a bit more difficult, https://stackoverflow.com/questions/4176923/html-of-selected-text/4177234#4177234 is a starting point but maybe there are also simpler ways in the meantime.
The JS script above seems to work quite nicely, there is however a downside to it. I don't know if it's intended but it's not extracting html of substrings. For example, if we highlight and copy the title InProceedings (Salm2020)
, we get <i>InProceedings</i><a name="Salm2020"> (Salm2020)</a>
, which is correct. However if we only highlight and copy the part Proceedings
we simply get the plaintext Proceedings
.
I played around copy & pasting into open office and apart from the limitation above, it works as intended.
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.
Thanks for trying it out! That's not perfect, but I would say good enough for most purposes.
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.
Thanks! Looks good to me.
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.
Works fine, just tested it! Thanks for adding this very useful feature!
Fixes #6962
Added a feature that allows users to copy highlighted text in the preview window
Screenshot: