
Copy: writing data to the clipboard # writeText() # Chrome 84 introduces an experimental feature that allows the clipboard to handle any arbitrary data type. The Async Clipboard API is limited to handling text and images. If you're interested in using the API, consult a browser support table before proceeding. As of this writing, Firefox only supports text and image support is limited to PNGs in some browsers. With that, major browsers have a basic level of support in place. Safari recently announced support for it in version 13.1. The Async Clipboard API addresses these issues, providing a well-defined permissions model that doesn't block the page. At the same time, the permissions put in place around document.execCommand() for clipboard interaction are loosely defined and vary between browsers. Imagine adding permissions into the mix, requiring that the browser block the page while requesting clipboard access. That would block the page while waiting on the disk or network. The browser may need to load or inline linked resources from a pasted document. Time consuming sanitization or image decoding might be needed before content can be safely pasted. That's fine for small bits of text, but there are many cases where blocking the page for clipboard transfer is a poor experience. Though widely supported, this method of cutting and pasting came at a cost: clipboard access was synchronous, and could only read and write to the DOM. Over the past few years, browsers have used document.execCommand() for clipboard interactions.
