clipboard module

Note

This namespace is in Beta and provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Interact with the system clipboard

Functions

isSupported()

Checks if clipboard capability is supported by the host

read()

Function to read data from clipboard.

write(Blob)

Function to copy data to clipboard.

Function Details

isSupported()

Note

This API is in Beta and provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Checks if clipboard capability is supported by the host

function isSupported(): boolean

Returns

boolean

boolean to represent whether the clipboard capability is supported

read()

Function to read data from clipboard.

function read(): Promise<Blob>

Returns

Promise<Blob>

A promise blob which resolves to the data read from the clipboard or rejects stating the reason for failure. Note: Returned blob type will contain one of the MIME type image/png, text/plain or text/html.

write(Blob)

Function to copy data to clipboard.

function write(blob: Blob): Promise<void>

Parameters

blob

Blob

A Blob object representing the data to be copied to clipboard.

Returns

Promise<void>

A string promise which resolves to success message from the clipboard or rejects with error stating the reason for failure.

Remarks

Note: clipboard.write only supports Text, HTML, PNG, and JPEG data format. MIME type for Text -> text/plain, HTML -> text/html, PNG/JPEG -> image/(png | jpeg) Also, JPEG will be converted to PNG image when copying to clipboard.