Clipboard

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

clipboard는 데이터 저장 또는 전송을 위한 짧은 기간동안 사용하는 데이터 버퍼 입니다.  documents 와 applications 양쪽에서 사용 가능합니다.  It is usually implemented as an anonymous, temporary data buffer, sometimes called the paste buffer, that can be accessed from most or all programs within the environment via defined programming interfaces.

A typical application accesses clipboard functionality by mapping user input such as keybindingsmenu selections, etc. to these interfaces.

Clipboard API 의 Clipboard 인터페이스는 시스템 클립보드로부터 텍스트 및 데이터를 읽거나 시스템 클립보드에 쓰기 위한 인터페이스를 지원합니다.

The Clipboard API can be used to implement cut, copy, and paste features within a web application.

The system clipboard is exposed through the global Navigator.clipboard property.

Calls to the methods of the Clipboard object will not succeed if the user hasn't granted the needed permissions using the Permissions API and the "clipboard-read" or "clipboard-write" permission as appropriate.

Note: In reality, at this time browser requirements for access to the clipboard vary significantly. Please see the section Clipboard availability for details.

All of the Clipboard API methods operate asynchronously; they return a Promise which is resolved once the clipboard access has been completed. The promise is rejected if clipboard access is denied.

Methods

Clipboard 는 EventTarget 인터페이스를 기반으로 하고 있으며, 해당 인터페이스의 method를 포함합니다.

read()
클립보드로부터 임의의 데이터(이미지와 같은)를 요청하며, returning a Promise. When the data has been retrieved, the promise is resolved with a DataTransfer object that provides the data.
readText()
시스템 클립보드로부터 텍스트를 읽는다. returns a Promise which is resolved with a DOMString containing the clipboard's text once it's available.
write()
시스템 클립보드에 예를 들어 이미지들과 같은 데이터를 쓴다. 이 비동기 작업은 Promise를 반환된 Promise를 resolve 함으로써 작업이 종료되었다는 사실을 알립니다.
writeText()
시스템 클립보드에 텍스트를 쓰며, returning a Promise which is resolved once the text is fully copied into the clipboard.

Clipboard availability

The asynchronous clipboard API is a relatively recent addition, and the process of implementing it in browsers is not yet complete. Due to both potential security concerns and technical complexities, the process of integrating this API is happening gradually in most browsers.

For example, Firefox does not yet support the "clipboard-read" and "clipboard-write" permissions, so access to the methods that access and change the contents of the clipboard are restricted in other ways.

For WebExtensions, you can request the clipboardRead and clipboardWrite permissions to be able to use clipboard.readText() and clipboard.writeText(). Content scripts applied on HTTP sites do not have access to the clipboard object. See extensions in Firefox 63.

In addition, read() and write() are disabled by default and require changing a preference to enable them. Check the compatibility tables for each method before using it.

Specifications

Specification Status Comment
Clipboard API and events
The definition of 'Clipboard' in that specification.
Working Draft Initial definition.

Browser Compatibility

BCD tables only load in the browser

See also