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
| is |
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()
Warning
This API is now deprecated.
As of TeamsJS v2.54.0, the clipboard capability is deprecated. These APIs may stop working at
any time without notice: support for this capability in Teams and other host apps may be removed
entirely and independently of a TeamsJS major release, so continued functionality is not
guaranteed. The intended long-term replacement is the standardized Clipboard API provided by the
browser (Clipboard API, navigator.clipboard).
Note that using the browser-native Clipboard API directly within Teams hosts is not yet fully
supported; it depends on native device permission handling that is still being enabled as a
separate effort.
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()
Warning
This API is now deprecated.
As of TeamsJS v2.54.0, the clipboard capability is deprecated. These APIs may stop working at
any time without notice: support for this capability in Teams and other host apps may be removed
entirely and independently of a TeamsJS major release, so continued functionality is not
guaranteed. The intended long-term replacement is the standardized Clipboard API provided by the
browser (Clipboard API, navigator.clipboard).
Note that using the browser-native Clipboard API directly within Teams hosts is not yet fully
supported; it depends on native device permission handling that is still being enabled as a
separate effort.
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)
Warning
This API is now deprecated.
As of TeamsJS v2.54.0, the clipboard capability is deprecated. These APIs may stop working at
any time without notice: support for this capability in Teams and other host apps may be removed
entirely and independently of a TeamsJS major release, so continued functionality is not
guaranteed. The intended long-term replacement is the standardized Clipboard API provided by the
browser (Clipboard API, navigator.clipboard).
Note that using the browser-native Clipboard API directly within Teams hosts is not yet fully
supported; it depends on native device permission handling that is still being enabled as a
separate effort.
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.