Welcome What's new in Chrome extensions API reference Samples
Welcome What's new in Chrome extensions API reference Samples

chrome.clipboard

This API is part of the Chrome Apps platform, which was deprecated in 2020. It remains supported for Enterprise and Education customers on ChromeOS until at least Jan 2025. Learn more about migrating your app.
Important: This API works only on ChromeOS
  • 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.

  • Permissions
    clipboard
  • Availability
    Dev channel ChromeOS only

Summary

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 of the additional data item.

DataItemType

Enum

"textPlain"

"textHtml"

ImageType

Supported image types.

Enum

"png"

"jpeg"

Methods

setImageData

chrome.clipboard.setImageData(
  imageData: ArrayBuffer,
  type: ImageType,
  additionalItems?: AdditionalDataItem[],
  callback?: function,
)
Promise Chrome 57+

Sets image data to clipboard.

Parameters

  • imageData

    ArrayBuffer

    Chrome 60+

    The encoded image data.

  • The type of image being passed.

  • additionalItems

    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: () => void

Returns

  • Promise<void>

    Chrome 91+

    Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.

Events

onClipboardDataChanged

chrome.clipboard.onClipboardDataChanged.addListener(
  callback: function,
)
Chrome 56+

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: () => void

This site uses cookies to deliver and enhance the quality of its services and to analyze traffic. If you agree, cookies are also used to serve advertising and to personalize the content and advertisements that you see. Learn more about our use of cookies.