<br />

> [!NOTE]
> **Important:** This API works **only on ChromeOS**.

<br />

<br />

## Description

The `chrome.clipboard` API is provided to allow users to access data of the clipboard. This is a temporary solution for chromeos platform apps until open-web alternative is available. It will be deprecated once open-web solution is available, which could be in 2017 Q4.

<br />

<br />

## Permissions

`clipboard`  

<br />

<br />

## Availability

Dev channel ChromeOS only

<br />

<br />

<br />

## Types

### AdditionalDataItem

#### Properties

- data string

  Content of the additional data item. Either the plain text string if `type` is "textPlain" or markup string if `type` is "textHtml". The data can not exceed 2MB.
- type [DataItemType](https://developer.chrome.com/docs/apps/reference/clipboard#type-DataItemType)

  Type of the additional data item.

### DataItemType

#### Enum

"textPlain"   
"textHtml"   

<br />

### ImageType

Supported image types.

#### Enum

"png"   
"jpeg"   

<br />

## Methods

### setImageData()

Promise Chrome 57+

```typescript
chrome.clipboard.setImageData(
  imageData: ArrayBuffer,
  type: ImageType,
  additionalItems?: AdditionalDataItem[],
  callback?: function,
): Promise<void>
```

Sets image data to clipboard.

#### Parameters

- imageData ArrayBuffer
  Chrome 60+

  The encoded image data.
- type [ImageType](https://developer.chrome.com/docs/apps/reference/clipboard#type-ImageType)

  The type of image being passed.
- additionalItems [AdditionalDataItem](https://developer.chrome.com/docs/apps/reference/clipboard#type-AdditionalDataItem)\[\] optional
  Chrome 60+

  Additional data items for describing image data. The callback is called with `chrome.runtime.lastError` set to error code if there is an error. Requires clipboard and clipboardWrite permissions.
- callback function optional


  The `callback` parameter looks like:

  ```typescript
  () => void
  ```

  <br />

#### Returns

- Promise\<void\>
  Chrome 91+


  Promises are only supported for Manifest V3 and later, other platforms need to use callbacks.

## Events

### onClipboardDataChanged

Chrome 56+

```typescript
chrome.clipboard.onClipboardDataChanged.addListener(
  callback: function,
)
```

Fired when clipboard data changes. Requires clipboard and clipboardRead permissions for adding listener to chrome.clipboard.onClipboardDataChanged event. After this event fires, the clipboard data is available by calling document.execCommand('paste').

#### Parameters

- callback function


  The `callback` parameter looks like:

  ```typescript
  () => void
  ```

  <br />

<br />