Clipboard Class
The asynchronous clipboard API (https://w3c.github.io/clipboard-apis/#clipboard-interface) of a window (navigator.clipboard): reads and writes the Clipboard.SystemClipboard of the browsing context (BrowsingContextOptions.Clipboard), and fires clipboardchange when it changes.
public sealed class Clipboard : EventTargetRemarks
The clipboard is only available to a fully active document of a secure context that has the focus, and when BrowsingContextOptions.ClipboardPermission allows the access; the promises are rejected with a NotAllowedError DomException otherwise. There is no user activation: the access does not require a user gesture. The HTML read from the clipboard is sanitized by the HTML Sanitizer, unless it is requested unsanitized. The clipboardchange events are fired at this object (as in the browsers, and in the examples of the specification), for the documents allowed to read the clipboard.
See also
- Inheritance
EventTargetClipboard
Methods
| Name | Description |
|---|---|
| Read(ClipboardUnsanitizedFormats?) | Reads the items of the system clipboard (https://w3c.github.io/clipboard-apis/#dom-clipboard-read): their types are known, their data is read by ClipboardItem.GetType. |
| ReadText() | Reads the text of the system clipboard (https://w3c.github.io/clipboard-apis/#dom-clipboard-readtext): the task fails with a NotFoundError when there is no text. |
| Write(IReadOnlyList<ClipboardItem>) | Writes items to the system clipboard (https://w3c.github.io/clipboard-apis/#dom-clipboard-write), once the data of their representations is available. The task fails with a NotAllowedError when the data of a representation is not available, or when its type is not a mandatory or an optional data type (or not the type of the representation). |
| WriteText(string) | Writes text to the system clipboard (https://w3c.github.io/clipboard-apis/#dom-clipboard-writetext). |
Read(ClipboardUnsanitizedFormats?)
Clipboard.csReads the items of the system clipboard (https://w3c.github.io/clipboard-apis/#dom-clipboard-read): their types are known, their data is read by ClipboardItem.GetType.
public Task<IReadOnlyList<ClipboardItem>> Read(ClipboardUnsanitizedFormats? formats = null)ReadText()
Clipboard.csReads the text of the system clipboard (https://w3c.github.io/clipboard-apis/#dom-clipboard-readtext): the task fails with a NotFoundError when there is no text.
Write(IReadOnlyList<ClipboardItem>)
Clipboard.csWrites items to the system clipboard (https://w3c.github.io/clipboard-apis/#dom-clipboard-write), once the data of their representations is available. The task fails with a NotAllowedError when the data of a representation is not available, or when its type is not a mandatory or an optional data type (or not the type of the representation).
public Task Write(IReadOnlyList<ClipboardItem> data)Parameters
Returns
See also
WriteText(string)
Clipboard.csWrites text to the system clipboard (https://w3c.github.io/clipboard-apis/#dom-clipboard-writetext).