chrome.clipboard
- Description
The
chrome.clipboardAPI 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 - AvailabilityDev channel
Summary
- Types
- Methods
- Events
Types
AdditionalDataItem
Properties
- data
string
Content of the additional data item. Either the plain text string if
typeis "textPlain" or markup string iftypeis "textHtml". The data can not exceed 2MB. - type
Type of the additional data item.
DataItemType
Type
"textPlain"
, or"textHtml"
ImageType
Supported image types.
Type
"png"
, or"jpeg"
Methods
setImageData
chrome.clipboard.setImageData(
imageData:
ArrayBuffer,
type:
ImageType,
additionalItems?:
AdditionalDataItem[],
callback?:
function,
)
Sets image data to clipboard.
Parameters
- imageData
ArrayBuffer
Chrome 60+The encoded image data.
- type
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.lastErrorset to error code if there is an error. Requires clipboard and clipboardWrite permissions. - callback
function optional
The
callbackparameter 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,
)
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
callbackparameter looks like:() => void