Created
January 22, 2024 13:42
-
-
Save mbixby/ea0b044c5552b8df439d3b724659458c to your computer and use it in GitHub Desktop.
Rich text clipboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const clipboardItem = new ClipboardItem({ | |
"text/plain": new Blob( | |
['https://example.com'], | |
{ type: "text/plain" } | |
), | |
"text/html": new Blob( | |
['<a href="https://example.com">Example link</a>'], | |
{ type: "text/html" } | |
), | |
"application/rtf": new Blob( | |
['{\field{\*\fldinst HYPERLINK "https://example.com"}{\fldrslt Example link}}'], | |
{ type: "text/html" } | |
), | |
}); | |
navigator.clipboard.write([clipboardItem]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment