The new asynchronous clipboard API makes use of DataTransfer objects and has a need to be able to construct new ones. For example (with new clipboard api): var data = new DataTransfer(); data.items.add("\(°o°)/", "text/plain"); navigator.clipboard.write(data).then(function() { console.log(“Copied to clipboard successfully! ᕕ( ᐛ )ᕗ”); }, function() { console.error(“Unable to write to clipboard. (╯ಠ_ಠ)╯︵ ┻━┻”); });
Demo
Documentation
- Spec change: https://github.com/whatwg/html/commit/688a102b52c7050a6808a05c5d8fe149c0937fd7
- Tests: http://w3c-test.org/html/editing/dnd/datastore/datatransfer-constructor-001.html
- https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer
- https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/DataTransfer
Specification
Status in Chromium
Enabled by default (tracking bug) in:
- Chrome for desktop release 60
- Chrome for Android release 60
- Android WebView release 60
Consensus & Standardization
After a feature ships in Chrome, the values listed here are not guaranteed to be up to date.
- No signal
- No signal
- No signal
- No signals
Owner
Search tags
datatransfer constructor clipboard,Last updated on 2020-11-09