This commit is contained in:
Ilya Kantor 2020-11-22 14:29:25 +03:00
parent 99e59ba611
commit 2f0c37db83
3 changed files with 28 additions and 27 deletions

View file

@ -76,11 +76,13 @@ For instance, the code below prevents all such events and shows what we are tryi
Please note, that it's possible to copy/paste not just text, but everything. For instance, we can copy a file in the OS file manager, and paste it.
There's a list of methods [in the specification](https://www.w3.org/TR/clipboard-apis/#dfn-datatransfer) that can work with different data types including files, read/write to the clipboard.
That's because `clipboardData` implements `DataTransfer` interface, commonly used for drag'n'drop and copy/pasting. It's bit beyound our scope now, but you can find its methods [in the specification](https://html.spec.whatwg.org/multipage/dnd.html#the-datatransfer-interface).
But please note that clipboard is a "global" OS-level thing. Most browsers allow read/write access to the clipboard only in the scope of certain user actions for the safety, e.g. in `onclick` event handlers.
```warn header="ClipboardAPI: user safety restrictions"
The clipboard is a "global" OS-level thing. So most browsers allow read/write access to the clipboard only in the scope of certain user actions for the safety, e.g. in `onclick` event handlers.
Also it's forbidden to generate "custom" clipboard events with `dispatchEvent` in all browsers except Firefox.
```
## Summary