Groups
Sign in
Groups
zotero-dev
Conversations
About
Send feedback
Help
rich text to clipboard
43 views
Skip to first unread message
Emiliano Heyns
unread,
Apr 25, 2021, 10:41:45 AM
4/25/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to zotero-dev
This should do it:
```
const content = <HTML string with may include links>
const clipboard = Components.classes['@
mozilla.org/widget/clipboard;1'].getService(Components.interfaces.nsIClipboard)
const transferable = Components.classes['@
mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable)
const str = Components.classes['@
mozilla.org/supports-string;1'].createInstance(Components.interfaces.nsISupportsString)
str.data = content
transferable.addDataFlavor('text/html')
transferable.setTransferData('text/html', str, content.length * 2) // don't recall why the * 2 is there but it doesn't work without it.
// you can add RTF as mimetype text/richtext in a similar way, and yes, this is the wrong mimetype for RTF, but this is the only thing Firefox accepts
clipboard.setData(transferable, null, Components.interfaces.nsIClipboard.kGlobalClipboard)
```
Bjoern Hassler
unread,
Apr 25, 2021, 11:42:19 AM
4/25/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to zotero-dev
Thank you so much!
Björn
Reply all
Reply to author
Forward
0 new messages