add selection copy to preview window#7421
Conversation
|
|
||
| public void copySelectionToClipBoard() { | ||
| ClipboardContent content = new ClipboardContent(); | ||
| content.putString(getSelectionHtmlContent()); |
There was a problem hiding this comment.
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.
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
putHtmlas 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.
Thanks for trying it out! That's not perfect, but I would say good enough for most purposes.
Siedlerchr
left a comment
There was a problem hiding this comment.
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: