ConceptioArchiveW3C TR
W3C TRopen access

clipboard apis

W3C · w3c_tr
W3C TR · Standards · License: Open Access
Open Source ↗
w3c, standard

Clipboard API and events W3C Working Draft , 24 June 2026 More details about this document This version: https://www.w3.org/TR/2026/WD-clipboard-apis-20260624/ Latest published version: https://www.w3.org/TR/clipboard-apis/ Editor's Draft: https://w3c.github.io/clipboard-apis/ Previous Versions: https://www.w3.org/TR/2025/WD-clipboard-apis-20251124/ https://www.w3.org/TR/2025/WD-clipboard-apis-20251124/ History: https://www.w3.org/standards/history/clipboard-apis/ Feedback: GitHub Inline In Spec Editors: Rakesh Goulikar ( Microsoft ) Rohan Raja ( Microsoft ) Former Editors: Gary Kacmarcik ( Google ) Anupam Snigdha ( Microsoft ) Hallvord R. M. Steen ( Mozilla ) Grisha Lyukshin ( Microsoft ) Explainer: Async Clipboard API Explainer Copyright © 2026 World Wide Web Consortium . W3C ® liability , trademark and permissive document license rules apply. Abstract This document describes APIs for accessing data on the system clipboard. It provides operations for overriding the default clipboard actions (cut, copy and paste), and for directly accessing the clipboard contents. Status of this document This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C standards and drafts index . This document was published by the Web Editing Working Group as a Working Draft using the Recommendation track . Publication as a Working Draft does not imply endorsement by W3C and its Members. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than a work in progress. Changes to this document may be tracked at https://github.com/w3c/clipboard-apis . This document was produced by a group operating under the W3C Patent Policy . W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent that the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy . This document is governed by the 18 August 2025 W3C Process Document . Table of Contents 1 Introduction 2 Use Cases 2.1 Changing Default Clipboard Operations 2.2 Remote Clipboard Synchronization 2.3 Trigger Clipboard Actions 3 Terminology 4 Model 5 Clipboard Events 5.1 Clipboard event interfaces 5.2 Clipboard events 5.2.1 The clipboardchange event 5.2.1.1 To fire a clipboardchange event 5.2.1.2 Document focus steps 5.2.1.3 ClipboardChangeEvent constructor steps 5.2.1.4 ChangeId Generation 5.2.2 The copy event 5.2.3 The cut event 5.2.4 The paste event 5.3 Integration with other scripts and events 5.3.1 Event handlers that are allowed to modify the clipboard 5.3.2 Event handlers that are allowed to read from clipboard 5.3.3 Integration with rich text editing APIs 5.3.4 Interaction with other events 5.3.5 Event listeners that modify selection or focus 6 Clipboard Event API 6.1 Overriding the copy event 6.2 Overriding the cut event 6.3 Overriding the paste event 6.4 Mandatory data types 6.4.1 Reading from the clipboard 6.4.2 Writing to the clipboard 6.5 Optional data types 6.6 Unsanitized data types 7 Asynchronous Clipboard API 7.1 Navigator Interface 7.1.1 clipboard 7.2 ClipboardItem Interface 7.2.1 presentationStyle 7.2.2 types 7.2.3 getType(type) 7.2.4 supports(type) 7.3 Clipboard Interface 7.3.1 read( formats ) 7.3.2 readText() 7.3.3 write( data ) 7.3.4 writeText( data ) 8 Clipboard Actions 8.1 The copy action 8.2 The cut action 8.3 The paste action 9 Permissions API Integration 9.1 Clipboard read permission 9.1.1 check clipboard read permission 9.2 Clipboard write permission 9.2.1 check clipboard write permission 10 Security Considerations 10.1 Pasting HTML and multi-part data 10.2 General security policies 10.3 Transcoding images 10.4 Nuisance considerations 11 Privacy Considerations 11.1 Privacy and the Clipboard Event API 11.2 Privacy and the Asychronous Clipboard API 11.2.1 Privacy and Clipboard Permission 11.3 Other Privacy Concerns 12 Acknowledgements Appendix A: Algorithms write content to the clipboard write blobs and option to the clipboard os specific well-known format well-known mime type from os specific format read web custom format write web custom formats os specific custom map name os specific custom name fire a clipboard event process an HTML paste event Conformance Document conventions Conformant Algorithms Index Terms defined by this specification Terms defined by reference References Normative References Non-Normative References IDL Index Issues Index 1. Introduction This section is non-normative. This specification defines how the system clipboard is exposed to web applications. There are two general APIs described in this specification: Clipboard Event API - This API provides a way to hook into the common clipboard operations of cutting, copying and pasting so that web application can adjust the clipboard data as required. Async Clipboard API - This API provides direct access to read and write the clipboard data. Since this is considered to be a powerful feature , access to this API is controlled by a permission. 2. Use Cases This section is non-normative. 2.1. Changing Default Clipboard Operations There are many scenarios where it is desireable to change the default clipboard operations (cut/copy/paste). Here are a few examples: Metadata When copying text from a repository of documents, it can be useful for the copied text to include metadata about the source of the copied content. Rich content editing When copying text which contains hyperlinks or other structure, it is often useful to be able to reformat the content to preserve important information. Graphics with built-in semantics In order to make web applications which allow the manipulation of rich text, or of graphic content such as [SVG11] , it is useful to provide a mechanism that allows for copying more than just the rendered content. Mathematical information With content such as mathematics, simply copying rendered text and pasting it into another application generally leads to most of the semantics being lost. MathML often needs to be transformed to be copied as plain text, for example to make sure "to the power of" is shown with the caret "^" sign in a formula plain-text input. The XML source could also be placed in the clipboard with the appropriate transformation occurring at paste time. 2.2. Remote Clipboard Synchronization For web applications that communicate with remote devices (e.g., remote access or remote shell applications), there is often a need for the clipboard data to be kept in sync between the two devices. One important aspect of this use case is that it requires access to the clipboard in the absense of a user gesture or interaction. To copy the clipboard data from a remote device to the local clipboard, a web application would take the remote clipboard data and then write() the data to the local clipboard. To copy the local clipboard data to a remote device, a web application would listen for clipboardchange events, read() from the clipboard whenever it is updated, and then send the new clipboard data to the remote device. 2.3. Trigger Clipboard Actions Applications that provide an alternate interface to a user agent sometimes need to be able to trigger clipboard actions in the user agent. As an example, consider a screen reader application that provides a more accessible interface to a standard web browser. While the reader can display content and allow the user to interact with it, actions like clipboard copy need to occur in the underlying browser to ensure that the clipboard content is set correctly (with any metadata added by the browser during copy). 3. Terminology The term editable context means any element that is either an editing host , a textarea element, or an input element with its type attribute set to any of "text", "search", "tel", "url", "email", "password" or "number". 4. Model The platform provides a system clipboard . The system clipboard has a list of system clipboard item s that are collectively called the system clipboard data . Each system clipboard item has a list of system clipboard representation s. Each system clipboard representation has a name , which is a string, and data , which is a sequence of bytes. The system clipboard has a clipboard change count , which is a value that changes each time the system clipboard data is modified. 5. Clipboard Events 5.1. Clipboard event interfaces The ClipboardEvent interface extends the Event interface. dictionary ClipboardEventInit : EventInit { DataTransfer ? clipboardData = null ; }; clipboardData A DataTransfer object to hold data and meta data related to the event. [ Exposed = Window ] interface ClipboardEvent : Event { constructor ( DOMString type , optional ClipboardEventInit eventInitDict = {}); readonly attribute DataTransfer ? clipboardData ; }; clipboardData The clipboardData attribute is an instance of the DataTransfer interface which lets a script read and manipulate values on the system clipboard during user-initiated copy, cut and paste operations. The associated drag data store is a live but filtered view of the system clipboard, exposing mandatory data types the implementation knows the script can safely access. For synthetic events, the drag data store contains the data added by the script that created the event. The clipboardData object’s items and files properties enable processing of multi-part or non-textual data from the clipboard. The interface can be used to construct events . An example is given below: var pasteEvent = new ClipboardEvent('paste'); pasteEvent.clipboardData.items.add('My string', 'text/plain'); document.dispatchEvent(pasteEvent); Note: Synthetic clipboard events will not actually modify the clipboard or the document. In other words, while the script above will fire a paste event, the data will not be pasted into the document. 5.2. Clipboard events 5.2.1. The clipboardchange event The clipboardchange event fires whenever the contents of the system clipboard are changed. These changes could be due to any of the following (non-exhaustive): User-initiated cut or copy actions Scripts that use the § 7 Asynchronous Clipboard API to write to the clipboard Actions that update the clipboard outside the user agent 5.2.1.1. To fire a clipboardchange event To fire a clipboardchange event given a Document document : If document does not have sticky activation and document does not have permission to read from the clipboard, then return. Let global be document ’s relevant global object . If document has system focus : Let types be a list of mandatory data types available on the system clipboard . Let changeId be the result of running generate a changeId given document . Let eventInit be a new ClipboardChangeEventInit dictionary with its types member set to types and its changeId member set to changeId . Fire an event named clipboardchange at global , using ClipboardChangeEvent , with eventInit . If document does not have system focus : Set document ’s clipboardchange pending flag to true. User agents MAY choose to skip firing clipboardchange events for clipboard changes that have been superseded by more recent changes before the event would be delivered. This optimization can improve performance in scenarios where clipboard changes occur in rapid succession, as delivering obsolete change notifications provides no value to web applications while consuming processing resources. 5.2.1.2. Document focus steps When a Document document gains system focus : If document ’s clipboardchange pending flag is true: Set document ’s clipboardchange pending flag to false. Let types be a list of mandatory data types available on the system clipboard . Let changeId be the result of running generate a changeId given document . Let eventInit be a new ClipboardChangeEventInit dictionary with its types member set to types and its changeId member set to changeId . Let global be document ’s relevant global object . Fire an event named clipboardchange at global , using ClipboardChangeEvent , with eventInit . For documents in nested browsing contexts, the clipboardchange event fires independently in each Document based on its own focus state. A clipboard change will fire an event in the single document that has system focus (if that document has sticky activation or persistent clipboard permissions). Note: The clipboardchange event is only available after sticky activation , unless the document has persistent permission to read from the clipboard. In user agents that support persistent clipboard permissions, sites with such permissions can receive clipboardchange events without sticky activation, as the permission already grants access to more sensitive clipboard data. The changeId provides a unique identifier for each clipboard change operation. For the same clipboard change, all windows and tabs with the same storage key will receive events with identical changeId values, enabling applications with multiple windows to deduplicate events and avoid redundant processing. The identifier is storage key -specific and does not provide cross- storage key correlation capabilities. The clipboardchange event does not bubble and is not cancelable, as it is not triggered by a user action but rather by changes to the system clipboard state. dictionary ClipboardChangeEventInit : EventInit { sequence < DOMString > types = []; bigint changeId = 0; }; types A sequence of DOMString representing the mandatory data types available on the system clipboard . changeId A bigint representing a unique identifier for the clipboard change operation. [ Exposed = Window ] interface ClipboardChangeEvent : Event { constructor ( DOMString type , optional ClipboardChangeEventInit eventInitDict = {}); readonly attribute FrozenArray < DOMString > types ; readonly attribute bigint changeId ; }; types Returns a FrozenArray of DOMString objects indicating the mandatory data types available on the system clipboard when the event was fired. Optional data types and custom formats are excluded to limit fingerprinting surface. changeId Returns a bigint representing a unique identifier for this specific clipboard change operation. This identifier is consistent across all windows and tabs with the same storage key for the same clipboard change, enabling applications to deduplicate events when multiple windows receive the same clipboard change notification. The changeId is a cryptographically derived 128-bit integer. The only guarantee is that after something is written to the clipboard, changeId will yield a different value than it did before the write operation. 5.2.1.3. ClipboardChangeEvent constructor steps The ClipboardChangeEvent(type, eventInitDict) constructor steps are: Set this . types to a clone of eventInitDict [" types "]. Set this . changeId to eventInitDict [" changeId "]. 5.2.1.4. ChangeId Generation To generate a changeId for a Document document : Let globalChangeId be a user agent-specific unique identifier representing the current state of the system clipboard . This identifier changes each time the system clipboard is modified, and is reset when the user agent restarts. Let storageKey be the result of running obtain a storage key for non-storage purposes given document ’s relevant settings object . Let storageKeyBytes be some user agent-specific binary representation of storageKey . Let hashedValue be the result of applying a cryptographic hash function (such as SHA-256) to the concatenation of globalChangeId (as bytes) and storageKeyBytes . Return a 128-bit integer derived from hashedValue (for example, by taking the first 128 bits of the hash output). The above algorithm ensures that documents from the same origin and with the same partitioning receive identical change IDs for the same clipboard modification, enabling proper event deduplication across multiple windows and tabs, while preventing cross-partition correlation that could be used for tracking. As Client-side Storage Partitioning changes are incorporated into the storage key definition, this approach will automatically provide anonymization across partitions. The changeId does not persist across browser restarts, as the globalChangeId counter is reset when the user agent restarts. Similarly, when a user clears site data, the affected tabs should be refreshed, which causes event listeners to be re-attached and only receive future events with new change IDs. Since synthetic cut and copy events do not update the system clipboard , they will not trigger a "clipboardchange" event. The clipboardchange event enables web applications to efficiently monitor clipboard changes and provide dynamic user interfaces based on available data formats: // For applications with multiple windows, track processed change IDs to avoid duplication const processedChangeIds = new Set();

// Listen for clipboard changes navigator.clipboard.addEventListener('clipboardchange', (e) => { // Deduplicate events across multiple windows using changeId if (processedChangeIds.has(e.changeId)) { return; // This change has already been processed } processedChangeIds.add(e.changeId);

// Check what data types are available on the clipboard const hasText = e.types.includes('text/plain'); const hasHTML = e.types.includes('text/html'); const hasImage = e.types.includes('image/png');

// Update UI based on available formats document.getElementById('paste-text-btn').disabled = !hasText; document.getElementById('paste-html-btn').disabled = !hasHTML; document.getElementById('paste-image-btn').disabled = !hasImage;

// For remote desktop apps, sync clipboard to remote only once per change if (hasText || hasHTML || hasImage) { syncClipboardToRemote(e.changeId); } });

// Alternatively, you can use the onclipboardchange property // navigator.clipboard.onclipboardchange = (e) => { ... }; This event-driven approach is more efficient than polling the clipboard with methods like read() or readText() and works across browsers that require user activation for clipboard access, as the UI can react instantly to clipboard changes without waiting for a timer to fire. The changeId is particularly useful for applications with multiple windows, ensuring that each clipboard change is processed only once across all windows with the same storage key . 5.2.2. The copy event When the user initiates a copy action, the user agent fires a clipboard event named copy . If the event is not canceled, the currently selected data will be copied to the system clipboard . The current document selection is not affected. The copy event bubbles, is cancelable, and is composed. See § 8.1 The copy action for a detailed description of the processing model for this event. A synthetic copy event can be manually constructed and dispatched, but it will not affect the contents of the system clipboard . 5.2.3. The cut event When the user initiates a cut action, the user agent fires a clipboard event named cut . In an editable context , if the event is not canceled the action will place the currently selected data on the system clipboard and remove the selection from the document. The cut event fires before the selected data is removed. When the cut operation is completed, the selection is collapsed. In a non- editable context , the clipboardData will be an empty list. Note that the cut event will still be fired in this case. The cut event bubbles, is cancelable, and is composed. See § 8.2 The cut action for a detailed description of the processing model for this event. A synthetic cut event can be manually constructed and dispatched, but it will not affect the contents of the document or of the system clipboard . 5.2.4. The paste event When a user initiates a paste action, the user agent fires a clipboard event named paste . The event fires before any clipboard data is inserted into the document. If the cursor is in an editable context , the paste action will insert clipboard data in the most suitable format (if any) supported for the given context. The paste action has no effect in a non- editable context , but the paste event fires regardless. The paste event bubbles, is cancelable, and is composed. See § 8.3 The paste action for a detailed description of the processing model for this event. A synthetic paste event can be manually constructed and dispatched, but it will not affect the contents of the document. 5.3. Integration with other scripts and events 5.3.1. Event handlers that are allowed to modify the clipboard Event handlers may write to the clipboard if any of the following is true: The action which triggers the event is invoked from the user-agent’s own user interface, e.g. from a "Copy" menu entry or shortcut key. The action which triggers the event is invoked from a scripting thread which is allowed to show a popup . The implementation may allow other trusted event types to modify the clipboard if the implementation authors believe that those event types are likely to express user intention. The implementation may also support configuration that trusts specific sites or apps to modify the clipboard regardless of the origin of the scripting thread. Synthetic cut and copy events must not modify data on the system clipboard. 5.3.2. Event handlers that are allowed to read from clipboard Event handlers may read data from the system clipboard if either of the following is true The action that triggers the event is invoked from the user-agent’s own user interface, e.g. a "Paste" menu entry or shortcut key. The script that triggers the action is running on a site which through an implementation-dependant mechanism is given permission to read data from the clipboard. The action that triggers the event is triggered in an app with permissions to read the clipboard. Synthetic paste events must not give a script access to data on the real system clipboard. 5.3.3. Integration with rich text editing APIs If an implementation supports ways to execute clipboard commands through scripting, for example by calling the document.execCommand() method with the commands "cut", "copy" and "paste", the implementation must trigger the corresponding action, which again will dispatch the associated clipboard event. These are the steps to follow when triggering copy, cut or paste actions through a scripting API: Execute the corresponding action synchronously. Use the action’s return value as the return value for the API call. Note: Copy and cut commands triggered through a scripting API will only affect the contents of the real clipboard if the event is dispatched from an event that is trusted and triggered by the user, or if the implementation is configured to allow this. Paste commands triggered through a scripting API will only fire paste events and give access to clipboard contents if the implementation is configured to allow this. How implementations can be configured to allow read or write access to the clipboard is outside the scope of this specification. 5.3.4. Interaction with other events If the clipboard operation is triggered by keyboard input, the implementation must fire the corresponding event that initiates the clipboard operation. The event is asynchronous but must be dispatched before keyup events for the relevant keys. The cut and paste actions may cause the implementation to dispatch other supported events, such as textInput, input, change, validation events, DOMCharacterDataModified and DOMNodeRemoved / DOMNodeInserted. Any such events are queued up to fire after processing of the cut/paste event is finished. The implementation must not dispatch other input-related events like textInput, input, change, and validation events in response to the copy operation. 5.3.5. Event listeners that modify selection or focus If the event listener modifies the selection or focusable area , the clipboard action must be completed on the modified selection. 6. Clipboard Event API The Clipboard Event API allows you to override the default cut, copy and paste behavior of the user agent. Access to the clipboard is performed using the standard DataTransfer methods to mutate the items on a ClipboardEvent ’s clipboardData attribute. One consequence of this is that these clipboard APIs can only access clipboard data in the context of a ClipboardEvent handler. Note: If you need to access the clipboard outside of a clipboard event handler, see § 7 Asynchronous Clipboard API . Note: The Clipboard Event APIs are synchronous, so they are limited in what they can do. Actions which are potentially blocking (like asking for permission or transcoding a image) are not supported by these APIs. See § 7 Asynchronous Clipboard API for a more powerful API that can support blocking or other time-consuming actions. 6.1. Overriding the copy event To override the default copy event behavior, a copy event handler must be added and this event handler must call preventDefault() to cancel the event. Canceling the event is required in order for the system clipboard to be updated with the data in clipboardData . If the ClipboardEvent is not canceled, then the data from the current document selection will be copied instead. // Overwrite what is being copied to the clipboard. document.addEventListener('copy', function(e) { // e.clipboardData is initially empty, but we can set it to the // data that we want copied onto the clipboard. e.clipboardData.setData('text/plain', 'Hello, world!'); e.clipboardData.setData('text/html', '<b>Hello, world!</b>');

// This is necessary to prevent the current document selection from // being written to the clipboard. e.preventDefault(); }); 6.2. Overriding the cut event To override the default cut event behavior, a cut event handler must be added and this event handler must call preventDefault() to cancel the event. Canceling the event is required in order for the system clipboard to be updated with the data in clipboardData . If the ClipboardEvent is not canceled, then the data from the current document selection will be copied instead. Note that canceling the cut event will also prevent the document from being updated (i.e., the current selection will not be removed). The event handler will need to manually update the document to remove the currently selected text. // Overwrite what is copied to the clipboard. document.addEventListener('cut', function(e) { // e.clipboardData is initially empty, but we can set it to the // data that we want copied onto the clipboard as part of the cut. // Write the data that we want copied onto the clipboard. e.clipboardData.setData('text/plain', 'Hello, world!'); e.clipboardData.setData('text/html', '<b>Hello, world!</b>');

// Since we will be canceling the cut operation, we need to manually // update the document to remove the currently selected text. deleteCurrentDocumentSelection();

// This is necessary to prevent the document selection from being // written to the clipboard. e.preventDefault(); }); 6.3. Overriding the paste event To override the default paste event behavior, a paste event handler must be added and this event handler must call preventDefault() to cancel the event. Canceling the event is required so that the user agent does not update the document with data from the system clipboard . Note that canceling the paste event will also prevent the document from being updated (i.e., nothing will be pasted into the document). The event handler will need to manually paste the data into the document. Also note that, when pasting, the drag data store mode flag is read-only , hence calling setData() from a paste event handler will not modify the data that is inserted, and not modify the data on the clipboard. // Overwrite what is being pasted onto the clipboard. document.addEventListener('paste', function(e) { // e.clipboardData contains the data that is about to be pasted. if (e.clipboardData.types.indexOf('text/html') > -1) { var oldData = e.clipboardData.getData('text/html'); var newData = '<b>Ha Ha!</b> ' + oldData;

// Since we are canceling the paste operation, we need to manually // paste the data into the document. pasteClipboardData(newData);

// This is necessary to prevent the default paste action. e.preventDefault(); } }); 6.4. Mandatory data types The implementation must recognize the native OS clipboard format description for the following data types, to be able to populate the DataTransferItemList and ClipboardItem with the correct description for paste events, and set the correct data format on the OS clipboard in response to copy and cut events. 6.4.1. Reading from the clipboard These data types must be exposed by paste events if a corresponding native type exists on the clipboard: text/plain text/html image/png 6.4.2. Writing to the clipboard These data types must be placed on the clipboard with a corresponding native type description if added to a DataTransfer object during copy and cut events. text/plain text/html image/png Warning! The data types that untrusted scripts are allowed to write to the clipboard are limited as a security precaution. Untrusted scripts can attempt to exploit security vulnerabilities in local software by placing data known to trigger those vulnerabilities on the clipboard. 6.5. Optional data types The implementation MAY recognize the native OS clipboard format description for the following data types, to be able to populate the ClipboardItem with the correct description for paste events, and set the correct data format on the OS clipboard in response to copy and cut events. These data types MAY be exposed by UAs if a corresponding native type exists on the clipboard: text/uri-list image/svg+xml Custom format starts with `"web "`("web" followed by U+0020 SPACE) prefix and suffix (after stripping out `"web "`) passes the parsing a MIME type check. 6.6. Unsanitized data types This section is non-normative. These data types MUST NOT be sanitized by UAs: image/png These data types MAY NOT be sanitized by UAs: optional unsanitized data types Optional unsanitized data types are mime type s specified by the web authors that MAY NOT be sanitized by the user agent. The valid optional unsanitized data types are listed below: text/html optional unsanitized data types may not be supported by a user agent due to their privacy requirements. 7. Asynchronous Clipboard API 7.1. Navigator Interface partial interface Navigator { [ SecureContext , SameObject ] readonly attribute Clipboard clipboard ; }; 7.1.1. clipboard It is used to execute read/write operations from/to the system clipboard . The clipboard getter steps are to return this ’s clipboard object. 7.2. ClipboardItem Interface typedef Promise <( DOMString or Blob )> ClipboardItemData ;

[ SecureContext , Exposed = Window ] interface ClipboardItem { constructor ( record < DOMString , ClipboardItemData > items , optional ClipboardItemOptions options = {}); readonly attribute PresentationStyle presentationStyle ; readonly attribute FrozenArray < DOMString > types ; Promise < Blob > getType ( DOMString type ); static boolean supports ( DOMString type ); }; enum PresentationStyle { "unspecified" , "inline" , "attachment" }; dictionary ClipboardItemOptions { PresentationStyle presentationStyle = "unspecified"; }; clipboardItem = new ClipboardItem([ items , options ]) Creates a new ClipboardItem object. items denote list of representations , each representation has a mime type and a Promise to Blob or DOMString corresponding to the mime type , options can be used to fill its ClipboardItemOptions , as per the example below. const format1 = 'text/plain' ; const promise_text_blob = Promise . resolve ( new Blob ([ 'hello' ], { type : format1 })); const clipboardItemInput = new ClipboardItem ( {[ format1 ] : promise_text_blob }, { presentationStyle : "unspecified" }); clipboardItem .getType( type ) Returns a Promise to the Blob corresponding to the mime type type . clipboardItem . types Returns the list of mime type s contained in the clipboard item object. ClipboardItem .supports( type ) Returns true if type is in mandatory data types or optional data types , else, returns false. A clipboard item is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or "copy" command. A clipboard item serves two purposes. First, it allows a website to read data copied by a user to the system clipboard . Second, it allows a website to write data to the system clipboard . For example, if a user copies a range of cells from a spreadsheet of a native application, it will result in one clipboard item . If a user copies a set of files from their desktop, that list of files will be represented by multiple clipboard item s. Some platforms may support having more than one clipboard item at a time on the clipboard , while other platforms replace the previous clipboard item with the new one. A clipboard item has a list of representations , each representation with an associated MIME type (a MIME type ), an isCustom flag, initially false , that indicates if this representation should be treated as a web custom format (as opposed to a well-known format of the system clipboard ), and data (a ClipboardItemData ). A web custom format has isCustom set to true . In the example where the user copies a range of cells from a spreadsheet, it may be represented as an image (image/png), an HTML table (text/html), or plain text (text/plain), or a web custom format (web text/csv). Each of these MIME type s describe a different representation of the same clipboard item at different levels of fidelity and make the clipboard item more consumable by target applications during paste. Making the range of cells available as an image will allow the user to paste the cells into a photo editing app, while the text/plain format can be used by text editor apps. A clipboard item has a presentation style (a PresentationStyle ). It helps distinguish whether apps "pasting" a clipboard item should insert the contents of an appropriate representation inline at the point of paste or if it should be treated as an attachment. Web apps that support pasting only a single clipboard item should use the first clipboard item . write() chooses the last clipboard item . Web apps that support pasting more than one clipboard item could, for example, provide a user interface that previews the contents of each clipboard item and allow the user to choose which one to paste. Further, apps are expected to enumerate the MIME type s of the clipboard item they are pasting and select the one best-suited for the app according to some app-specific algorithm. Alternatively, an app can present the user with options on how to paste a clipboard item , e.g. "paste as image" or "paste formatted text", etc. A ClipboardItem object has an associated clipboard item , which is a clipboard item . A ClipboardItem object has an associated types array , which is a FrozenArray < DOMString >. A ClipboardItem object has an associated clipboard change count at read , which is initially null. A ClipboardItem object has an associated originating system clipboard item , which is a system clipboard item or null, initially null. A ClipboardItem object has an associated unsanitized MIME types , which is a sequence < DOMString >, initially empty. A ClipboardItem object has an associated representations with resolvers , which is a map from a string (the MIME type as passed to getType() , including the `"web "` prefix when present) to a Promise < Blob >, initially empty. Each entry represents an OS clipboard read for that type that has either completed or is currently in flight. Note: This map ensures that concurrent getType() calls for the same MIME type on a ClipboardItem obtained from read() share a single OS clipboard read. The first call inserts a pending Promise into the map and initiates the read; subsequent calls for the same MIME type return the existing Promise without re-reading the system clipboard . When a ClipboardItem is created by read() , it acts as a lazy fetcher rather than a data snapshot. Its types array reflects the formats available on the system clipboard at the time of the read() call, but the actual payload bytes are not read until getType() is called. If the system clipboard contents change between the read() call and a subsequent getType() call, the getType() call will be rejected. A ClipboardItem constructed directly via the ClipboardItem(items, options) constructor is not subject to this behavior. To create a ClipboardItem object , given a clipboard item clipboardItem and a Realm realm , run these steps: Let clipboardItemObject be a new ClipboardItem with realm . Set clipboardItemObject ’s clipboard item to clipboardItem . The new ClipboardItem( items , options ) constructor steps are: If items is empty, then throw a TypeError . If options is empty, then set options["presentationStyle"] = "unspecified". Set this ’s clipboard item to a new clipboard item . Set this ’s clipboard item ’s presentation style to options [" presentationStyle "]. Let types be a list of DOMString . For each ( key , value ) in items : Let representation be a new representation . Let isCustom be false . If key starts with `"web "` prefix, then Remove `"web "` prefix and assign the remaining string to key . Set isCustom true Set representation ’s isCustom flag to isCustom . Let mimeType be the result of parsing a MIME type given key . If mimeType is failure, then throw a TypeError . If this ’s clipboard item ’s list of representations contains a representation whose MIME type is mimeType and whose [representation/isCustom] is isCustom , then throw a TypeError . The step above prevents collision between mime-types well-known by the user agent and those that are intended by the author to be treated as a custom type. For example, it would be possible for the author’s list of items to contain representations for "text/html" as well as "web text/html". Set representation ’s MIME type to mimeType . Set representation ’s data to value . Append representation to this ’s clipboard item ’s list of representations . Let mimeTypeString be the result of serializing a MIME type with mimeType . If isCustom is true , prefix mimeTypeString with `"web "`. Add mimeTypeString to types . Set this ’s types array to the result of running create a frozen array from types . 7.2.1. presentationStyle The presentationStyle getter steps are to return this ’s clipboard item ’s presentation style . 7.2.2. types The types getter steps are to return this ’s types array . 7.2.3. getType(type) This method must run the below steps: Let realm be this ’s relevant realm . Let isCustom be false . If type starts with `"web "` prefix, then: Remove `"web "` prefix and assign the remaining string to type . Set isCustom to true . Let mimeType be the result of parsing a MIME type given type . If mimeType is failure, then throw a TypeError . Let itemTypeList be this ’s clipboard item ’s list of representations . Let p be a new promise in realm . For each representation in itemTypeList : If representation ’s MIME type is mimeType and representation ’s isCustom is isCustom , then: If this ’s clipboard change count at read is not null, and the current clipboard change count is not equal to this ’s clipboard change count at read , then reject p with an "InvalidStateError" DOMException in realm , and return p . Note: This ensures that stale data is never returned. If the system clipboard contents have changed since read() was called, this MUST fail rather than returning data that does not correspond to the current system clipboard state. Note: A null clipboard change count at read indicates that this ClipboardItem was constructed directly by the author (e.g., via ClipboardItem(items, options) ), not obtained from read() . In that case, no stale-data check is needed because the data does not originate from the system clipboard . If this ’s clipboard change count at read is not null, then: Note: This branch covers ClipboardItem s obtained from read() , for which the OS clipboard read is deferred to this point. To ensure the read happens at most once per type — even if getType() is called multiple times concurrently for the same MIME type — the resulting Promise is cached in this ’s representations with resolvers map, keyed by a normalized type string so that `"text/html"` and `"web text/html"` are tracked independently while differently-cased spellings of the same type (e.g., `"text/HTML"` and `"text/html"`) collapse to a single entry. Let key be mimeType ’s essence . If isCustom is true, prefix key with `"web "`. If this ’s representations with resolvers [ key ] exists , then return this ’s representations with resolvers [ key ]. Set this ’s representations with resolvers [ key ] to p . Run the following steps in parallel : Let clipboardItem be this ’s originating system clipboard item . If clipboardItem is null, then queue a global task on the clipboard task source , given realm ’s global object , to reject p with an "InvalidStateError" DOMException in realm , then abort these steps. If isCustom is true, then: Let mapName be the os specific custom map name . Let mapRepresentation be the system clipboard representation in clipboardItem ’s list of system clipboard representation s whose name is mapName . If there is no such system clipboard representation , then queue a global task on the clipboard task source , given realm ’s global object , to reject p with a "NotFoundError" DOMException in realm , then abort these steps. Let webCustomFormatMapString be the JSON string deserialized from mapRepresentation ’s data . Let osFormatName be the value in webCustomFormatMapString whose key matches mimeType serialized . If osFormatName is not found, then queue a global task on the clipboard task source , given realm ’s global object , to reject p with a "NotFoundError" DOMException in realm , then abort these steps. Else, let osFormatName be the result of running os specific well-known format given mimeType . Let clipboardRepresentation be the system clipboard representation in clipboardItem ’s list of system clipboard representation s whose name is osFormatName . If there is no such system clipboard representation , then queue a global task on the clipboard task source , given realm ’s global object , to reject p with a "NotFoundError" DOMException in realm , then abort these steps. Let rawData be clipboardRepresentation ’s data . Let cleanData be a copy of rawData . If mimeType ’s essence is in this ’s unsanitized MIME types and mimeType ’s essence is in the optional unsanitized data types list, then do nothing. Else, if mimeType ’s essence is not "image/png", the user agent MAY sanitize cleanData . Let blob be a Blob whose type is mimeType serialized and whose underlying byte sequence is cleanData . Queue a global task on the clipboard task source , given realm ’s global object , to resolve p with blob . Note: Once p has settled, it remains in this ’s representations with resolvers map. Subsequent getType() calls for the same MIME type will return the cached settled Promise without re-reading the system clipboard . The stale-data check above still applies on every call, however: if the system clipboard has changed since read() was called, all getType() calls on this ClipboardItem will be rejected with an "InvalidStateError" — even for previously cached data. Return p . Let representationDataPromise be the representation ’s data . React to representationDataPromise : If representationDataPromise was fulfilled with value v , then: If v is a DOMString , then follow the below steps: Let dataAsBytes be the result of UTF-8 encoding v . Let blobData be a Blob created using dataAsBytes with its type set to mimeType , serialized . Resolve p with blobData . If v is a Blob , then follow the below steps: Resolve p with v . If representationDataPromise was rejected, then: Reject p with "NotFoundError" DOMException in realm . Web developers might be interested in the underlying rejection reason. Return p . Reject p with "NotFoundError" DOMException in realm . Return p . 7.2.4. supports(type) This method must run the below steps: If type is in mandatory data types or optional data types , then return true. If not, then return false. 7.3. Clipboard Interface typedef sequence < ClipboardItem > ClipboardItems ;

[ SecureContext , Exposed = Window ] interface Clipboard : EventTarget { Promise < ClipboardItems > read ( optional ClipboardUnsanitizedFormats formats = {}); Promise < DOMString > readText (); Promise < undefined > write ( ClipboardItems data ); Promise < undefined > writeText ( DOMString data ); }; dictionary ClipboardUnsanitizedFormats { sequence < DOMString > unsanitized ; }; Some methods of the Clipboard interface take or return multiple ClipboardItem objects. However, not all platforms support more than one clipboard item ; on such platforms, the algorithms below will ignore any ClipboardItem objects beyond the first one that are passed to write() , and read() and readText() only get one clipboard item from the OS. A clipboard items object is a sequence of clipboard item s. A web author needs to create a data which is an array of ClipboardItem s in order to write content to system clipboard using the write(data) method. read() returns a Promise to clipboard items object that represents contents of system clipboard data . unsanitized is a sequence of DOMString s corresponding to the mime type that the author wants to be treated as optional unsanitized data types . The unsanitized option MAY NOT be supported by the user agent. The web authors shouldn’t assume that the content for the MIME types listed in unsanitized would be unsanitized as there could be privacy modes where this option may not be allowed. The clipboard task source is triggered in response to reading or writing of system clipboard data . 7.3.1. read( formats ) The read(formats) method must run these steps: Let realm be this ’s relevant realm . Let p be a new promise in realm . If formats is not empty, then: For each format in formats [" unsanitized "]: If format is not in optional unsanitized data types , then reject p with format "NotAllowedError" DOMException in realm . Run the following steps in parallel : Let r be the result of running check clipboard read permission . If r is false, then: Queue a global task on the permission task source , given realm ’s global object , to reject p with "NotAllowedError" DOMException in realm . Abort these steps. Let data be the system clipboard data . Let snapshotChangeCount be the current clipboard change count . Note: Only the name s (format identifiers) from data are enumerated at this point. The underlying payload bytes for each representation are not read until getType() is called. Let items be a sequence of ordered maps , each entry having keys "item" (a clipboard item ) and "originating" (a system clipboard item or null). For each systemClipboardItem in data : Let item be a new clipboard item . For each systemClipboardRepresentation in systemClipboardItem : Let mimeType be the result of running the well-known mime type from os specific format algorithm given systemClipboardRepresentation ’s name . If mimeType is null, continue this loop. Let representation be a new representation . Set representation ’s MIME type to mimeType . Set representation ’s data to a new promise in realm . Note: The OS clipboard data for this representation will not be fetched until the author calls getType() on the resulting ClipboardItem object. Append representation to item ’s list of representations . If item ’s list of representations size is greater than 0, append the ordered map «[ "item" → item , "originating" → systemClipboardItem ]» to items . If items has a size > 0, then: Let firstItem be items [0]["item"] Run the read web custom format algorithm given firstItem . Else: Let customItem be a new clipboard item . Run the read web custom format algorithm given customItem . If customItem ’s list of representations size is greater than 0, append the ordered map «[ "item" → customItem , "originating" → null ]» to items . Queue a global task on the clipboard task source , given realm ’s global object , to perform the below steps: Let clipboardItems be a sequence < ClipboardItem >. For each ordered map entry of items : Let clipboardItem be the result of running the steps of create a ClipboardItem object given entry ["item"] and realm . Set clipboardItem ’s clipboard change count at read to snapshotChangeCount . Set clipboardItem ’s originating system clipboard item to entry ["originating"]. If formats is not empty, set clipboardItem ’s unsanitized MIME types to formats [" unsanitized "]. Append clipboardItem to clipboardItems . Resolve p with clipboardItems . Return p . // clipboard.read() returns ClipboardItems with type metadata only. // No OS clipboard data is read at this point. const items = await navigator . clipboard . read (); // The OS clipboard read happens lazily here, when getType() is called. const textBlob = await items [ 0 ]. getType ( "text/plain" ); const text = await ( new Response ( textBlob )). text (); 7.3.2. readText() The readText() method must run these steps: Let realm be this ’s relevant realm . Let p be a new promise in realm . Run the following steps in parallel : Let r be the result of running check clipboard read permission . If r is false, then: Queue a global task on the permission task source , given realm ’s global object , to reject p with "NotAllowedError" DOMException in realm . Abort these steps. Let data be a copy of the system clipboard data . Some OSs contain multiple clipboard (e.g. Linux, "primary", "secondary", "selection"). Define from which of those data is read. Add definition of sanitized copy. Queue a global task on the clipboard task source , given realm ’s global object , to perform the below steps: For each systemClipboardItem in data : For each systemClipboardRepresentation in systemClipboardItem : Let mimeType be the result of running the well-known mime type from os specific format algorithm given systemClipboardRepresentation ’s name . If mimeType is null, continue this loop. Let representation be a new representation . If representation ’s MIME type essence is "text/plain", then: Set representation ’s MIME type to mimeType . Let representationDataPromise be the representation ’s data . React to representationDataPromise : If representationDataPromise was fulfilled with value v , then: If v is a DOMString , then follow the below steps: Resolve p with v . Return p . If v is a Blob , then follow the below steps: Let string be the result of UTF-8 decoding v ’s underlying byte sequence. Resolve p with string . Return p . If representationDataPromise was rejected, then: Reject p with "NotFoundError" DOMException in realm . Return p . Reject p with "NotFoundError" DOMException in realm . Return p . navigator . clipboard . readText (). then ( function ( data ) { console . log ( "Your string: " , data ); }); 7.3.3. write( data ) The write(data) method must run these steps: Let realm be this ’s relevant realm . Let p be a new promise in realm . Run the following steps in parallel : Let r be the result of running check clipboard write permission . clipboard-write was removed in https://github.com/w3c/clipboard-apis/pull/164. If r is false, then: Queue a global task on the permission task source , given realm ’s global object , to reject p with "NotAllowedError" DOMException in realm . Abort these steps. Queue a global task on the clipboard task source , given realm ’s global object , to perform the below steps: Let itemList and cleanItemList be an empty sequence < Blob >. Let dataList be a sequence < ClipboardItem >. If data ’s size is greater than 1, and the current operating system does not support multiple native clipboard items on the system clipboard , then add data [0] to dataList , else, set dataList to data . when data contains multiple items and the operating system supports multiple native clipboard items, the current algorithm writes the items in sequence to the system clipboard instead of writing them collectively. For each clipboardItem in dataList : For each representation in clipboardItem ’s clipboard item ’s list of representations : Let representationDataPromise be the representation ’s data . React to representationDataPromise : If representationDataPromise was fulfilled with value v , then: If v is a DOMString , then follow the below steps: Let dataAsBytes be the result of UTF-8 encoding v . Let blobData be a Blob created using dataAsBytes with its type set to representation ’s MIME type . Add blobData to itemList . If v is a Blob , then add v to itemList . If representationDataPromise was rejected, then: Reject p with "NotAllowedError" DOMException in realm . Abort these steps. For each blob in itemList : Let type be the blob ’s type . If type is not in the mandatory data types or optional data types list, then reject p with "NotAllowedError" DOMException in realm and abort these steps. Let cleanItem be an optionally sanitized copy of blob . Add definition of sanitized copy. If sanitization was attempted and was not successfully completed, then follow the below steps: Reject p with "NotAllowedError" DOMException in realm . Abort these steps. Append cleanItem to cleanItemList . Let option be clipboardItem ’s clipboard item ’s presentation style . Write blobs and option to the clipboard with cleanItemList and option . Resolve p . Return p . var data = [ new ClipboardItem ({ "text/plain" : Promise . resolve ( new Blob ([ "Text data" ], { type : "text/plain" })) })]; navigator . clipboard . write ( data ). then ( function () { console . log ( "Copied to clipboard successfully!" ); }, function () { console . error ( "Unable to write to clipboard. :-(" ); }); 7.3.4. writeText( data ) The writeText(data) method must run these steps: Let realm be this ’s relevant realm . Let p be a new promise in realm . Run the following steps in parallel : Let r be the result of running check clipboard write permission . clipboard-write was removed in https://github.com/w3c/clipboard-apis/pull/164. If r is false, then: Queue a global task on the permission task source , given realm ’s global object , to reject p with "NotAllowedError" DOMException in realm . Abort these steps. Queue a global task on the clipboard task source , given realm ’s global object , to perform the below steps: Let itemList be an empty sequence < Blob >. Let textBlob be a new Blob created with: type attribute set to " text/plain;charset=utf-8 ", and its underlying byte sequence set to the UTF-8 encoding of data . Note: On Windows replace `\n` characters with `\r\n` in data before creating textBlob . Add textBlob to itemList . Let option be set to "unspecified". Write blobs and option to the clipboard with itemList and option . Resolve p . Return p . await navigator . clipboard . writeText ( "Howdy, partner!" ); 8. Clipboard Actions This section defines clipboard actions and the processing model for event dispatch. Each clipboard action has two flags called script-triggered and script-may-access-clipboard . The script-triggered flag is set if the action runs because of a script, for example a document.execCommand() call. Future scripting APIs that interact with the clipboard should also use these actions, and the script-triggered flag must be set accordingly. The script-may-access-clipboard flag is set as follows: If action is copy or cut and the script thread is allowed to modify the clipboard , then Set the action’s script-may-access-clipboard flag If action is paste and the script thread is allowed to read from clipboard , then Set the action’s script-may-access-clipboard flag. 8.1. The copy action The copy action consists of the following steps: If the script-triggered flag is set, then If the script-may-access-clipboard flag is unset, then Return false from the copy action, terminate this algorithm Fire a clipboard event named copy If the event was not canceled, then Copy the selected contents, if any, to the clipboard. Implementations should create alternate text/html and text/plain clipboard formats when content in a web page is selected. Fire a clipboard event named clipboardchange Else, if the event was canceled, then Call the write content to the clipboard algorithm, passing on the DataTransferItemList list items , a clear-was-called flag and a types-to-clear list. Return true from the copy action 8.2. The cut action The cut action consists of the following steps: If the script-triggered flag is set, then If the script-may-access-clipboard flag is unset, then Return false from the cut action, terminate this algorithm Fire a clipboard event named cut If the event was not canceled, then If there is a selection in an editable context where cutting is enabled, then Copy the selected contents, if any, to the clipboard. Implementations should create alternate text/html and text/plain clipboard formats when content in a web page is selected. Remove the contents of the selection from the document and collapse the selection. Fire a clipboard event named clipboardchange Queue tasks to fire any events that should fire due to the modification, see § 5.3 Integration with other scripts and events for details. Else, if there is no selection or the context is not editable, then Return false Else, if the event was canceled, then Call the write content to the clipboard algorithm, passing on the DataTransferItemList list items , a clear-was-called flag and a types-to-clear list. Fire a clipboard event named clipboardchange Return true from the cut action 8.3. The paste action For the paste action, the script-may-access-clipboard flag depends on an implementation-specific permission mechanism for determining what sites or apps may read from the clipboard. When a paste action is triggered by a script, the implementation must not make clipboard contents available without the user’s permission. If the permission has not already been granted, the permission prompt must include the hostname of the document associated with the script thread. The paste action consists of the following steps: If the script-triggered flag is set, then If script-may-access-clipboard is unset, then Return false from the paste action, terminate this algorithm Fire a clipboard event named paste If the event was not canceled, then If there is a selection or cursor in an editable context where pasting is enabled, then Insert the most suitable content found on the clipboard, if any, into the context. Queue tasks to fire any events that should fire due to the modification, see § 5.3 Integration with other scripts and events for details. Else Return false Else, if the event was canceled Return false Return true from the action 9. Permissions API Integration The [permissions] API provides a uniform way for websites to access powerful feature s like the clipboard. It allows websites to request permissions from users and query which permissions they have. For the clipboard, one permission is defined: "clipboard-write" Note: Clipboard permissions currently only apply to the Async Clipboard API. Future versions of this specification may be updated to apply this permission to other Clipboard interactions. These clipboard permissions are powerful feature s permission-related algorithms and types are defined as follows: permission descriptor type dictionary ClipboardPermissionDescriptor : PermissionDescriptor { boolean allowWithoutGesture = false ; }; There are 4 clipboard permissions: { name: "clipboard-write", allowWithoutGesture: false } { name: "clipboard-write", allowWithoutGesture: true } With the following relationships: { "clipboard-write" + true } is stronger than { "clipboard-write" + false } While user agents MUST support the ClipboardPermissionDescriptor as described in this specification, they, of course, retain complete control over the default settings and how (or if) they are exposed to the user. A user agent that wants to have separate user-settable write controls over the clipboard and always require a user gesture would handle each descriptor as follows: { "clipboard-write" + false } is exposed for user control { "clipboard-write" + true } is always denied 9.1. Clipboard read permission 9.1.1. check clipboard read permission Let hasGesture be true if the relevant global object of this has transient activation , false otherwise. If hasGesture then, Return true if the current script is running as a result of user interaction with a "Paste" element created by the user agent or operating system. Return false. 9.2. Clipboard write permission 9.2.1. check clipboard write permission Let writeWithoutGesture be the permission state of the { name: "clipboard-write", allowWithoutGesture: true } permission. If writeWithoutGesture is granted , then return true. Let hasGesture be true if the relevant global object of this has transient activation , false otherwise. If hasGesture then, Let systemCopy be true if the current script is running as a result of user interaction with a "cut" or "copy" element created by the user agent or operating system. If systemCopy is true, then return true. Return the result of request permission to use the { name: "clipboard-write", allowWithoutGesture: false } permission. Note: User agents may choose to request a stronger permission that will implicitly update this permission. Return the result of request permission to use the { name: "clipboard-write", allowWithoutGesture: true } permission. 10. Security Considerations Enabling authors to change what is copied by a user, or to make an automated copy of something that was never selected and allowing unrestricted calls to paste information can raise various security concerns. Some example scenarios include: A user selects a link and copies it, but a different link is copied to the clipboard. The effect of this can range from an unexpected result on pasting to an attempted "phishing" attack. (Self-XSS) Shell commands or executable script can be placed in the clipboard with the intent that the user will run the pasted content. An image that is specially crafted to exploit bugs in the core OS image handling code can be written to the clipboard. 10.1. Pasting HTML and multi-part data This section is non-normative. There are certain security risks associated with pasting formatted or multi-part data. The user might paste hidden data without realising it is there. This may happen if, for example, the markup includes <input type="hidden"> tags or HTML comments. Such hidden data might contain sensitive information. The user might paste malicious JavaScript into a trusted page. The implementation might grant scripts access to local files the user did not intend to expose. To determine what policies to use, the factors we consider are: The origin of the data being pasted The origin of data sub-parts such as referenced images The origin of the running script This is an overview of the scenarios and the possible security policies: Origin of data Origin of script Rules Originates from online source Same as data Do not sanitize HTML. Do not access any local files. Different origin Optionally sanitize content. Do not access any local files. Originates from local application Any Do not sanitize HTML. Grant access to local files Some implementations mitigate the risks associated with pasting rich text by stripping potentially malicious content such as SCRIPT elements and javascript: links by default when pasting rich text, but allow a paste event handler to retrieve and process the original, un-sanitized data. 10.2. General security policies The implementation must not download referenced online resources, or expose their contents in the files list or DataTransferItemList . If the data on the clipboard is not from a local application, the implementation must not give access to any referenced local files. For example, if the data contains <img src="file://localhost/example.jpg"> but the data’s origin is an online resource, the implementation must not add an entry for example.jpg to the clipboardData.items list. 10.3. Transcoding images To prevent malicious image data from being placed on the clipboard, the image data may be transcoded to produce a safe version of the image. This prevents websites from trying to exploit security vulnerabilities in other applications. Implementations should not transcode images being read from the clipboard. Transcoding images can lose important metadata (such as the physical resolution of an image). This is also consistent with other methods in which images can be shared with a website (such as `<input type=file>`). 10.4. Nuisance considerations Scripts may use the DataTransfer API to annoy and confuse users by altering the data on the system clipboard from copy and cut events. This specification does not attempt to prevent such nuisances, though implementations may add additional restrictions. Implementations must handle scripts that try to place excessive amounts of data on the clipboard gracefully. 11. Privacy Considerations Because these APIs provide access to the user’s clipboard data, there are serious privacy concerns due to the possibility that the clipboard will contain personally-identifiable information (PII) like names, addresses, or passwords. In general, user agents must ensure that untrusted scripts do not get uncontrolled access to a user’s clipboard data through these APIs. 11.1. Privacy and the Clipboard Event API The Clipboard Event API allows scripts running in the context of a clipboard event handler to access a copy of the system clipboard and potentially modify the data being written to the clipboard. User agents should be aware of the following requirements with regards to securing the data accessed by the Clipboard Event API: Objects implementing the DataTransfer interface to return clipboard data must not be available outside the ClipboardEvent event handler that the data is provided to. If a script stores a reference to an object implementing the DataTransfer interface to use from outside the ClipboardEvent event handler, all methods must be no-ops when called outside the expected context. Implementations must not let scripts create synthetic clipboard events to get access to real clipboard data (unless the user has configured it to do so). Even though the Clipboard Event API is not covered by the Clipboard permission, user agents may choose to provide a method for the user to disable this API or to configure which sites are allowed to access it. 11.2. Privacy and the Asychronous Clipboard API The Asynchronous Clipboard API is a powerful feature because it can allow access to the clipboard data from any script (access is not restricted to Clipboard Event handlers) and data can be accessed in the absence of a user provided gesture. To help prevent abuse, this API must not be available unless the script is executing in the context of a document that has focus . 11.2.1. Privacy and Clipboard Permission The Clipboard Permission gates access to this API, but user agents get to choose the permission defaults and which of these permission settings can be set by the user. For example, a user agent may choose to only allow access to the Asynchronous Clipboard API when a user gesture is present and always deny script requests for access without a gesture. User agents may opt to have this permission automatically expire sometime after the user grants permission, for example, by having the permission expire: After a set time from when the permission was first granted After a set time from the user’s last visit to a site When the user navigates away from the page 11.3. Other Privacy Concerns If the user agent allows clipboard data to be read using document.execCommand("paste") then the user agent must ensure that the user has explicitly allowed that access to take place. 12. Acknowledgements This section is non-normative The editors would like to acknowledge the contributions of the former editors who helped shepherd this specification through various meetings and mailing-list discussions to bring it to its current state. Hallvord R. M. Steen The editors would also like to acknowledge their intellectual debt to the documentation of Data Transfer functionalities from Microsoft [MICROSOFT-CLIP-OP] and earlier drafts of the [HTML5] specification. We are also grateful for the draft "safe copy and paste" from Paul Libbrecht (this draft is no longer available on the Web). And finally, we would like to acknowledge the contributions made by the following: Adam Barth, Shawn Carnell, Daniel Cheng, Daniel Dardailler, Domenic Denicola, Al Gilman, James Graham, James Greene, Ian Hickson, Darwin Huang, Lachlan Hunt, Philip Jägenstedt, Anne van Kesteren, Marijn Kruisselbrink, Aaron Leventhal, Jim Ley, Paul Libbrecht, "Martijn", Glenn Maynard, Chris Mills, ms2ger, Ryosuke Niwa, Robert O’Callahan, Dave Poehlman, "ROBO Design", Janina Sajka, Rich Schwerdtfeger, Jonas Sicking, Maciej Stachowiak, Mihai Sucan, Dmitry Titov, Ojan Vafai, Tarquin Wilton-Jones, Tom Wlodkowski, Bo Cupp, mbrodesser and Boris Zbarsky. Appendix A: Algorithms write content to the clipboard Input items , a DataTransferItemList list of items to write clear-was-called , a boolean types-to-clear , a list Output None If the items list is not empty, then Clear the clipboard For each part in the list, If data type is text/plain , then Ensure encoding is correct per OS and locale conventions Normalize line endings according to platform conventions Place text on clipboard with the appropriate OS clipboard format description Else, if data is of a type listed in the mandatory data types list, then Place part on clipboard with the appropriate OS clipboard format description Else This is left to the implementation... It’s not good to leave things up to the implementation. What should happen here? Note: Due to limitations in the implementation of operating system clipboards, scripts should not assume that custom formats will be available to other applications on the system. For example, there is a limit to how many custom clipboard formats can be registered in Microsoft Windows. While it is possible to use any string for setData() ’s type argument, sticking to the mandatory data types is strongly recommended. Else, the items list is empty. Follow these steps to determine whether to clear the clipboard: If the list of items is empty and the clear-was-called flag is true , then If the types-to-clear list is empty, then Clear the clipboard Else Remove types in the types-to-clear list from the clipboard in an operating system and implementation-specific way The "remove specific types from clipboard" feature is at risk. It doesn’t seem all that important, and it’s unclear if it can be implemented easily across relevant platforms. write blobs and option to the clipboard Input items , a sequence < Blob > presentationStyle , a clipboard item ’s presentation style Output None Let webCustomFormats be a sequence < Blob >. For each item in items : Let formatString be the result of running os specific well-known format given item ’s type . If formatString is empty then follow the below steps: Let webCustomFormatString be the item ’s type . Let webCustomFormat be an empty type . If webCustomFormatString starts with `"web "` prefix, then remove the `"web "` prefix and store the remaining string in webMimeTypeString . Let webMimeType be the result of parsing a MIME type given webMimeTypeString . If webMimeType is failure, then abort all steps. Let webCustomFormat ’s type ’s essence equal to webMimeType . Set item ’s type to webCustomFormat . Append webCustomFormat to webCustomFormats . Let payload be the result of UTF-8 decoding item ’s underlying byte sequence. Insert payload and presentationStyle into the system clipboard using formatString as the native clipboard format. some OSs contain multiple clipboard (e.g. Linux, "primary", "secondary", "selection"). Define to which of those data is written. Write web custom formats given webCustomFormats . os specific well-known format Input mimeType , a type Output wellKnownFormat , a platform specific string type. On Mac it’s NSPasteboardType, on Windows it’s LPCWSTR and Linux it’s a const char*. For Windows see https://docs.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats and https://docs.microsoft.com/en-us/windows/win32/dataxchg/about-atom-tables?redirectedfrom=MSDN For Mac see https://developer.apple.com/documentation/appkit/nspasteboardtype Let wellKnownFormat be an empty string. If mimeType ’s essence is "text/plain", then On Windows, follow the convention described below: Assign CF_UNICODETEXT to wellKnownFormat . On MacOS, follow the convention described below: Assign NSPasteboardTypeString to wellKnownFormat . On Linux, ChromeOS, and Android, follow the convention described below: Assign "text/plain" to wellKnownFormat . Else, if mimeType ’s essence is "text/html", then On Windows, follow the convention described below: Assign CF_HTML to wellKnownFormat . On MacOS, follow the convention described below: Assign NSPasteboardTypeHTML to wellKnownFormat . On Linux, ChromeOS, and Android, follow the convention described below: Assign "text/html" to wellKnownFormat . Else, if mimeType ’s essence is "image/png", then On Windows, follow the convention described below: Assign "PNG" to wellKnownFormat . On MacOS, follow the convention described below: Assign NSPasteboardTypePNG to wellKnownFormat . On Linux, ChromeOS, and Android, follow the convention described below: Assign "image/png" to wellKnownFormat . Else, if mimeType ’s essence is "image/svg+xml", then On Windows, follow the convention described below: Assign CFSTR_MIME_SVG_XML to wellKnownFormat . On MacOS, follow the convention described below: Assign UTTypeSVG to wellKnownFormat . On Linux, ChromeOS, and Android, follow the convention described below: Assign "image/svg+xml" to wellKnownFormat . Return wellKnownFormat . well-known mime type from os specific format Input osFormatName , a platform specific string type. On Mac it’s NSPasteboardType, on Windows it’s LPCWSTR and Linux it’s a const char*. Output mimeType , a MIME type For Windows see https://docs.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats and https://docs.microsoft.com/en-us/windows/win32/dataxchg/about-atom-tables?redirectedfrom=MSDN For Mac see https://developer.apple.com/documentation/appkit/nspasteboardtype On Windows, follow the convention described below: If osFormatName "UnicodeText", then set mimeTypeString to "text/plain". Else, if osFormatName "HTML Format", then set mimeTypeString to "text/html". Else, if osFormatName "PNG", then set mimeTypeString to "image/png". Else, if osFormatName CFSTR_MIME_SVG_XML, then set mimeTypeString to "image/svg+xml". On MacOS, follow the convention described below: If osFormatName is NSPasteboardTypeString, then set mimeTypeString to "text/plain". Else, if osFormatName is NSPasteboardTypeHTML, then set mimeTypeString to "text/html". Else, if osFormatName NSPasteboardTypePNG, then set mimeTypeString to "image/png". Else, if osFormatName UTTypeSVG, then set mimeTypeString to "image/svg+xml". On Linux, ChromeOS, and Android, follow the convention described below: If osFormatName is "text/plain", then set mimeTypeString to "text/plain". Else, if osFormatName "text/html", then set mimeTypeString to "text/html". Else, if osFormatName "image/png", then set mimeTypeString to "image/png". Else, if osFormatName "image/svg+xml", then set mimeTypeString to "image/svg+xml". Let mimeType be the result of parsing a MIME type given mimeTypeString . Return mimeType . read web custom format Input item , a clipboard item Let webCustomFormatMap be the os specific custom map name . Read webCustomFormatMap from the system clipboard . specify in more detail the process of reading a webCustomFormatMap . If webCustomFormatMap is empty, then return item . Let webCustomFormatMapString be the JSON string deserialized from webCustomFormatMap . Note: Need a JSON reader to deserialize the content from the webCustomFormatMap . For each ( key , value ) in webCustomFormatMapString : Let mimeType be the result of parsing a MIME type given key . If mimeType is failure, then continue the loop. Let representation be a new representation . Set representation ’s MIME type to mimeType . Set representation ’s isCustom flag to true . Set representation ’s data to a new promise . Note: The OS clipboard data for this web custom format will not be fetched until the author calls getType() on the resulting ClipboardItem object. Append representation to item ’s list of representations . write web custom formats Input items , a sequence < Blob > Let idx be a number initialized to 0. Let webCustomFormatMap be the os specific custom map name . Let webCustomFormatMapString be an empty JSON string. For each item in items : Let webCustomFormat be the os specific custom name . Let webCustomFormatIdx be the result of appending idx to webCustomFormat . Insert item ’s type as key and webCustomFormatIdx as value into the webCustomFormatMapString using a JSON serializer. Note: Need a JSON writer to serialize the content into the webCustomFormatMapString . Insert the item into the system clipboard using webCustomFormatIdx as the format. Increment idx . If idx is greater than 100, then break from this loop. Insert the webCustomFormatMapString into the system clipboard using webCustomFormatMap as the format. os specific custom map name Output webCustomFormatMap , a string On Windows, follow the convention described below: Assign "Web Custom Format Map" to webCustomFormatMap . Return webCustomFormatMap . On MacOS, follow the convention described below: Assign "org.w3.web-custom-format.map" to webCustomFormatMap . Return webCustomFormatMap . On Linux, ChromeOS, and Android, follow the convention described below: Assign "application/web;type=\"custom/formatmap\"" to webCustomFormatMap . Return webCustomFormatMap . os specific custom name Output webCustomFormat , a string On Windows, follow the convention described below: Assign "Web Custom Format" to webCustomFormat . Return webCustomFormat . On MacOS, follow the convention described below: Assign "org.w3.web-custom-format.type-" to webCustomFormat . Return webCustomFormat . On Linux, ChromeOS, and Android, follow the convention described below: Assign "application/web;type="custom/format" to webCustomFormat . Return webCustomFormat . fire a clipboard event Input e , the ClipboardEvent to fire Output None Let clear-was-called be false Let types-to-clear be an empty list Let clipboard-event-data be a new DataTransfer object with an empty items list. Let clipboard-entry be the sequence number of the current clipboard content, or null if the OS clipboard does not support sequence numbers Let trusted be true if the event is generated by the user agent, false otherwise Let target be set as follows: If the context is editable, then Set target to be the element that contains the start of the visible selection or cursor in document order, or the body element if there is no visible selection or cursor. Else, if the context is not editable, then Set target to the focused node, or the body element if no node has focus. Process the event as follows: If e is "paste", then Set the clipboard-event-data ’s internal drag data store mode flag to read-only . If trusted is true , or the implementation is configured to give script-generated events read access to the OS clipboard For each clipboard-part on the OS clipboard, carry out these steps: If clipboard-part contains plain text, then Ensure the text is in the encoding the scripting engine uses internally Let new-data be a new DataTransferItem with drag data item kind set to string and drag data item type string set to text/plain . Set new-data ’s data to the plain text. Add new-data to clipboard-event-data ’s items If clipboard-part represents file references, then for each file reference: Determine MIME type of referenced file Let new-data be a new DataTransferItem with drag data item kind set to file and drag data item type string set to the corresponding MIME type, or application/octet-stream if the file’s type is unknown. Set new-data ’s data to the file reference data. Add new-data to clipboard-event-data ’s items If clipboard-part contains HTML- or XHTML-formatted text, according to the operating system’s convention for describing such clipboard formats, then If the implementation supports pasting HTML, then the implementation must process the markup by calling process an html paste event with clipboard-part and clipboard-event-data . If clipboard-part contains data in another supported binary or text-based format (see mandatory data types ), then Determine the MIME type of the data Let new-data be a new DataTransferItem with drag data item kind set to file , drag data item type string set to the corresponding MIME type Set new-data ’s data to be the binary or text-based data. Add new-data to clipboard-event-data ’s items Update clipboard-event-data ’s files property to match entries in clipboard-event-data ’s items . Update clipboard-event-data ’s types property to match entries in clipboard-event-data ’s items . If e is "copy" or "cut", then Set the associated DataTransfer object’s internal drag data store mode flag to read/write Set e ’s clipboardData to clipboard-event-data . Set e ’s isTrusted to trusted . Set e ’s composed to true. Dispatch the event e which bubbles and is cancelable, and which uses the ClipboardEvent interface, at target . Implementation requirements for access to data during event dispatch are defined in [HTML] . Some additional clipboard event-specific processing rules are given below: Why here? Why not in the HTML spec? If a script calls clearData() or clear() and the DataTransfer object’s internal drag data store mode flag is read/write , then Set the clear-was-called flag to true. If an argument is given, add the argument to the types-to-clear list. If a script calls setData() or modifies items and the clear-was-called flag is true, then If the types-to-clear list is empty, then Set the clear-was-called flag to false, then Else, if setData() ’s type argument or the new item’s drag data item type string is found in the types-to-clear list, then Remove it from the list. If the list is now empty, set the clear-was-called flag to false. If a script calls getData() or accesses items in the DataTransferItemList and clipboard-entry is set, then Check that the clipboard data’s sequence number matches clipboard-entry . If the clipboard no longer contains the same entry, set the DataTransferItemList object’s internal drag data store mode to protected . Warning! A malicious script listening to a paste event may set up a never-ending loop in order to read what the user places on the clipboard in the future. On platforms where a clipboard sequence number is not available, other limitations should be implemented. process an HTML paste event Input clipboard-part , the clipboard part to process clipboard-event-data , the DataTransfer object for this event Output None Let new-data be a new DataTransferItem with drag data item kind set to Plain Unicode string , drag data item type string set to text/html or application/xhtml+xml accordingly. Extract the markup from clipboard-part and use the relevant parser to construct a DOM tree. If the markup’s source URL is known, then resolve all relative URLs in HREF and SRC attributes using the source URL as base URL, and set the respective attributes to the resolved absolute URL. If the markup’s origin is from a local application, then check whether there are references to local files and/or other parts of the OS clipboard’s contents. If such references are found, references to sub-parts must be replaced by content-id references using the cid: URL scheme [RFC2392] . To do so, process each attribute referencing a local file or clipboard part according to the following steps: Are these steps necessary? Do we know about native (platform) clipboard implementations that support multiple parts with internal references? This feature is at risk because it’s unclear whether it is required, and because it’s hard to test in a cross-platform way. If clipboard-event-data ’s items already contains an entry for the referenced file or clipboard part, then Set itemNumber to the index of the existing entry. Else, Let new-file-data be a new DataTransferItem with drag data item kind set to "file", and drag data item type string set to the MIME type of the file or clipboard part if known, or application/octet-stream if the file’s type is unknown. Let file-info be a new File object with name set to the name part of the HTML attribute contents, and lastModified set to the timestamp of the referenced file or 0 if the entry references a clipboard part. Set new-file-data ’s internal File object to file-info . Add new-file-data to clipboard-event-data ’s items and let itemNumber be the index of this entry in the DataTransferItemList . Update the DOM attribute that referenced the local file or clipboard part to contain the string 'cid:' followed by itemNumber . Serialize the processed DOM and update new-data with the resulting HTML code. Add new-data to clipboard-event-data ’s items . Conformance Document conventions Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification. All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119] Examples in this specification are introduced with the words “for example” or are set apart from the normative text with class="example" , like this: This is an example of an informative example. Informative notes begin with the word “Note” and are set apart from the normative text with class="note" , like this: Note, this is an informative note. Conformant Algorithms Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or "return false and abort these steps") are to be interpreted with the meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm. Conformance requirements phrased as algorithms or specific steps can be implemented in any manner, so long as the end result is equivalent. In particular, the algorithms defined in this specification are intended to be easy to understand and are not intended to be performant. Implementers are encouraged to optimize. Index Terms defined by this specification allowed to modify the clipboard , in § 5.3.1 allowed to read from clipboard , in § 5.3.2 allowWithoutGesture , in § 9 "attachment" , in § 7.2 changeId attribute for ClipboardChangeEvent , in § 5.2.1 dfn for ClipboardChangeEvent , in § 5.2.1 dfn for ClipboardChangeEventInit , in § 5.2.1 dict-member for ClipboardChangeEventInit , in § 5.2.1 check clipboard read permission , in § 9.1.1 check clipboard write permission , in § 9.2.1 Clipboard , in § 7.3 clipboard attribute for Navigator , in § 7.1 dfn for Navigator , in § 7.1.1 clipboardchange , in § 5.2.1 clipboard change count , in § 4 clipboard change count at read , in § 7.2 ClipboardChangeEvent , in § 5.2.1 ClipboardChangeEventInit , in § 5.2.1 ClipboardChangeEvent(type) , in § 5.2.1 ClipboardChangeEvent(type, eventInitDict) constructor for ClipboardChangeEvent , in § 5.2.1 dfn for ClipboardChangeEvent , in § 5.2.1.3 clipboardchange pending flag , in § 5.2.1.1 clipboardData attribute for ClipboardEvent , in § 5.1 dfn for ClipboardEvent , in § 5.1 dfn for ClipboardEventInit , in § 5.1 dict-member for ClipboardEventInit , in § 5.1 ClipboardEvent , in § 5.1 ClipboardEventInit , in § 5.1 ClipboardEvent(type) , in § 5.1 ClipboardEvent(type, eventInitDict) , in § 5.1 clipboard item definition of , in § 7.2 dfn for ClipboardItem , in § 7.2 ClipboardItem , in § 7.2 ClipboardItemData , in § 7.2 ClipboardItem(items) , in § 7.2 ClipboardItem(items, options) , in § 7.2 ClipboardItemOptions , in § 7.2 clipboard items , in § 7.3 ClipboardItems , in § 7.3 ClipboardPermissionDescriptor , in § 9 clipboard task source , in § 7.3 ClipboardUnsanitizedFormats , in § 7.3 "clipboard-write" , in § 9 constructor(items) , in § 7.2 constructor(items, options) , in § 7.2 constructor(type) constructor for ClipboardChangeEvent , in § 5.2.1 constructor for ClipboardEvent , in § 5.1 constructor(type, eventInitDict) constructor for ClipboardChangeEvent , in § 5.2.1 constructor for ClipboardEvent , in § 5.1 copy , in § 5.2.2 create a ClipboardItem object , in § 7.2 cut , in § 5.2.3 data dfn for representation , in § 7.2 dfn for system clipboard representation , in § 4 editable context , in § 3 fire a clipboardchange event , in § 5.2.1.1 fire a clipboard event , in § Unnumbered section generate a changeId , in § 5.2.1.4 getType(type) , in § 7.2.2 "inline" , in § 7.2 isCustom , in § 7.2 list of representations , in § 7.2 Mandatory data types , in § 6.4 MIME type , in § 7.2 name , in § 4 Optional data types , in § 6.5 Optional unsanitized data types , in § 6.6 originating system clipboard item , in § 7.2 os specific custom map name , in § Unnumbered section os specific custom name , in § Unnumbered section os specific well-known format , in § Unnumbered section paste , in § 5.2.4 presentation style , in § 7.2 PresentationStyle , in § 7.2 presentationStyle attribute for ClipboardItem , in § 7.2 dict-member for ClipboardItemOptions , in § 7.2 process an HTML paste event , in § Unnumbered section read() , in § 7.3 read(formats) , in § 7.3 readText() , in § 7.3 read web custom format , in § Unnumbered section representation , in § 7.2 representations with resolvers , in § 7.2 script-may-access-clipboard , in § 8 script-triggered , in § 8 supports(type) , in § 7.2.3 system clipboard , in § 4 system clipboard data , in § 4 system clipboard item , in § 4 system clipboard representation , in § 4 types attribute for ClipboardChangeEvent , in § 5.2.1 attribute for ClipboardItem , in § 7.2.1 dfn for ClipboardChangeEvent , in § 5.2.1 dfn for ClipboardChangeEventInit , in § 5.2.1 dict-member for ClipboardChangeEventInit , in § 5.2.1 types array , in § 7.2 unsanitized , in § 7.3 Unsanitized data types , in § 6.6 unsanitized MIME types , in § 7.2 "unspecified" , in § 7.2 web custom format , in § 7.2 well-known mime type from os specific format , in § Unnumbered section write blobs and option to the clipboard , in § Unnumbered section write content to the clipboard , in § Unnumbered section write(data) , in § 7.3 writeText(data) , in § 7.3 write web custom formats , in § Unnumbered section Terms defined by reference [] defines the following terms: allowed to show a popup concept dnd p concept dnd ro concept dnd rw constructing events drag data item kind drag data item type string drag data store mode focusable area permission task source storage key [DOM] defines the following terms: Document Event EventInit EventTarget composed fire an event isTrusted preventDefault() [ENCODING] defines the following terms: UTF-8 decode UTF-8 encode [FileAPI] defines the following terms: Blob File lastModified name type [HTML] defines the following terms: DataTransfer DataTransferItem DataTransferItemList Navigator clear() clearData(format) editing host files getData(format) global object has focus steps in parallel items queue a global task relevant global object relevant realm relevant settings object setData(format, data) sticky activation system focus the body element transient activation types [INFRA] defines the following terms: clone contain exist map ordered map set size starts with [MIMESNIFF] defines the following terms: essence MIME type parse a MIME type serialize a MIME type [PERMISSIONS] defines the following terms: PermissionDescriptor denied granted permission descriptor type permission state powerful feature request permission to use [WEBIDL] defines the following terms: DOMException DOMString Exposed FrozenArray InvalidStateError NotAllowedError NotFoundError Promise SameObject SecureContext TypeError a new promise bigint boolean create a frozen array new react record reject sequence this undefined References Normative References [DOM] Anne van Kesteren. DOM Standard . Living Standard. URL: https://dom.spec.whatwg.org/ [ENCODING] Anne van Kesteren. Encoding Standard . Living Standard. URL: https://encoding.spec.whatwg.org/ [FileAPI] Marijn Kruisselbrink. File API . 4 June 2026. WD. URL: https://www.w3.org/TR/FileAPI/ [HTML] Anne van Kesteren; et al. HTML Standard . Living Standard. URL: https://html.spec.whatwg.org/multipage/ [INFRA] Anne van Kesteren; Domenic Denicola. Infra Standard . Living Standard. URL: https://infra.spec.whatwg.org/ [MIMESNIFF] Gordon P. Hemsley. MIME Sniffing Standard . Living Standard. URL: https://mimesniff.spec.whatwg.org/ [PERMISSIONS] Marcos Caceres; Mike Taylor. Permissions . 6 October 2025. WD. URL: https://www.w3.org/TR/permissions/ [RFC2119] S. Bradner. Key words for use in RFCs to Indicate Requirement Levels . March 1997. Best Current Practice. URL: https://datatracker.ietf.org/doc/html/rfc2119 [RFC2392] E. Levinson. Content-ID and Message-ID Uniform Resource Locators . August 1998. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc2392 [WEBIDL] Edgar Chen; Timothy Gu. Web IDL Standard . Living Standard. URL: https://webidl.spec.whatwg.org/ Non-Normative References [HTML5] Ian Hickson; et al. HTML5 . 27 March 2018. REC. URL: https://www.w3.org/TR/html5/ [MICROSOFT-CLIP-OP] About DHTML Data Transfer. Microsoft Developer Network. . URL: https://msdn.microsoft.com/en-us/ie/ms537658(v=vs.94) [SVG11] Erik Dahlström; et al. Scalable Vector Graphics (SVG) 1.1 (Second Edition) . 16 August 2011. REC. URL: https://www.w3.org/TR/SVG11/ IDL Index dictionary ClipboardEventInit : EventInit { DataTransfer ? clipboardData = null ; };

[ Exposed = Window ] interface ClipboardEvent : Event { constructor ( DOMString type , optional ClipboardEventInit eventInitDict = {}); readonly attribute DataTransfer ? clipboardData ; }; dictionary ClipboardChangeEventInit : EventInit { sequence < DOMString > types = []; bigint changeId = 0; };

[ Exposed = Window ] interface ClipboardChangeEvent : Event { constructor ( DOMString type , optional ClipboardChangeEventInit eventInitDict = {}); readonly attribute FrozenArray < DOMString > types ; readonly attribute bigint changeId ; }; partial interface Navigator { [ SecureContext , SameObject ] readonly attribute Clipboard clipboard ; }; typedef Promise <( DOMString or Blob )> ClipboardItemData ;

[ SecureContext , Exposed = Window ] interface ClipboardItem { constructor ( record < DOMString , ClipboardItemData > items , optional ClipboardItemOptions options = {}); readonly attribute PresentationStyle presentationStyle ; readonly attribute FrozenArray < DOMString > types ; Promise < Blob > getType ( DOMString type ); static boolean supports ( DOMString type ); }; enum PresentationStyle { "unspecified" , "inline" , "attachment" }; dictionary ClipboardItemOptions { PresentationStyle presentationStyle = "unspecified"; }; typedef sequence < ClipboardItem > ClipboardItems ;

[ SecureContext , Exposed = Window ] interface Clipboard : EventTarget { Promise < ClipboardItems > read ( optional ClipboardUnsanitizedFormats formats = {}); Promise < DOMString > readText (); Promise < undefined > write ( ClipboardItems data ); Promise < undefined > writeText ( DOMString data ); }; dictionary ClipboardUnsanitizedFormats { sequence < DOMString > unsanitized ; }; dictionary ClipboardPermissionDescriptor : PermissionDescriptor { boolean allowWithoutGesture = false ; }; Issues Index Web developers might be interested in the underlying rejection reason. ↵ Some OSs contain multiple clipboard (e.g. Linux, "primary", "secondary", "selection"). Define from which of those data is read. ↵ Add definition of sanitized copy. ↵ clipboard-write was removed in https://github.com/w3c/clipboard-apis/pull/164. ↵ when data contains multiple items and the operating system supports multiple native clipboard items, the current algorithm writes the items in sequence to the system clipboard instead of writing them collectively. ↵ Add definition of sanitized copy. ↵ clipboard-write was removed in https://github.com/w3c/clipboard-apis/pull/164. ↵ It’s not good to leave things up to the implementation. What should happen here? ↵ The "remove specific types from clipboard" feature is at risk. It doesn’t seem all that important, and it’s unclear if it can be implemented easily across relevant platforms. ↵ some OSs contain multiple clipboard (e.g. Linux, "primary", "secondary", "selection"). Define to which of those data is written. ↵ specify in more detail the process of reading a webCustomFormatMap . ↵ Why here? Why not in the HTML spec? ↵ Are these steps necessary? Do we know about native (platform) clipboard implementations that support multiple parts with internal references? ↵ This feature is at risk because it’s unclear whether it is required, and because it’s hard to test in a cross-platform way. ↵ MDN Clipboard/read Firefox 🔰 90+ Safari 13.1+ Chrome ? Opera 63+ Edge ? Edge (Legacy) None IE None Firefox for Android ? iOS Safari ? Chrome for Android ? Android WebView ? Samsung Internet 12.0+ Opera Mobile 54+ MDN Clipboard/readText Firefox None Safari 13.1+ Chrome 66+ Opera ? Edge 79+ Edge (Legacy) ? IE None Firefox for Android ? iOS Safari ? Chrome for Android ? Android WebView ? Samsung Internet ? Opera Mobile ? ✔ MDN Clipboard/write In all current engines. Firefox 87+ Safari 13.1+ Chrome 66+ Opera 63+ Edge 79+ Edge (Legacy) None IE None Firefox for Android ? iOS Safari ? Chrome for Android 66+ Android WebView ? Samsung Internet 12.0+ Opera Mobile 54+ ✔ MDN Clipboard/writeText In all current engines. Firefox 63+ Safari 13.1+ Chrome 66+ Opera ? Edge 79+ Edge (Legacy) ? IE None Firefox for Android ? iOS Safari ? Chrome for Android ? Android WebView ? Samsung Internet ? Opera Mobile ? ✔ MDN Clipboard In all current engines. Firefox 63+ Safari 13.1+ Chrome 66+ Opera ? Edge 79+ Edge (Legacy) ? IE None Firefox for Android ? iOS Safari ? Chrome for Android ? Android WebView ? Samsung Internet ? Opera Mobile ? ✔ MDN ClipboardEvent/ClipboardEvent In all current engines. Firefox 22+ Safari 10.1+ Chrome 58+ Opera ? Edge 79+ Edge (Legacy) 17+ IE None Firefox for Android ? iOS Safari ? Chrome for Android ? Android WebView ? Samsung Internet ? Opera Mobile ? ✔ MDN ClipboardEvent/clipboardData In all current engines. Firefox 22+ Safari 10.1+ Chrome 41+ Opera ? Edge 79+ Edge (Legacy) 12+ IE 5+ Firefox for Android ? iOS Safari ? Chrome for Android ? Android WebView ? Samsung Internet ? Opera Mobile ? ✔ MDN ClipboardEvent In all current engines. Firefox 22+ Safari 10.1+ Chrome 41+ Opera ? Edge 79+ Edge (Legacy) 12+ IE 4+ Firefox for Android ? iOS Safari ? Chrome for Android ? Android WebView ? Samsung Internet ? Opera Mobile ? ✔ MDN ClipboardItem/ClipboardItem In all current engines. Firefox 🔰 87+ Safari 13.1+ Chrome 98+ Opera ? Edge 98+ Edge (Legacy) ? IE None Firefox for Android ? iOS Safari ? Chrome for Android 98+ Android WebView ? Samsung Internet ? Opera Mobile ? ✔ MDN ClipboardItem/getType In all current engines. Firefox 🔰 87+ Safari 13.1+ Chrome 76+ Opera ? Edge 79+ Edge (Legacy) ? IE None Firefox for Android ? iOS Safari ? Chrome for Android 84+ Android WebView ? Samsung Internet ? Opera Mobile ? MDN ClipboardItem/presentationStyle Firefox 🔰 87+ Safari 13.1+ Chrome None Opera ? Edge None Edge (Legacy) ? IE None Firefox for Android ? iOS Safari ? Chrome for Android ? Android WebView ? Samsung Internet ? Opera Mobile ? ✔ MDN ClipboardItem/types In all current engines. Firefox 🔰 87+ Safari 13.1+ Chrome 76+ Opera ? Edge 79+ Edge (Legacy) ? IE None Firefox for Android ? iOS Safari ? Chrome for Android 84+ Android WebView ? Samsung Internet ? Opera Mobile ? ✔ MDN ClipboardItem In all current engines. Firefox 🔰 87+ Safari 13.1+ Chrome 76+ Opera ? Edge 79+ Edge (Legacy) ? IE None Firefox for Android ? iOS Safari ? Chrome for Android 84+ Android WebView ? Samsung Internet ? Opera Mobile ? ✔ MDN Element/copy_event In all current engines. Firefox 22+ Safari 3+ Chrome 1+ Opera 12.1+ Edge 79+ Edge (Legacy) 12+ IE 9+ Firefox for Android ? iOS Safari 3+ Chrome for Android ? Android WebView ? Samsung Internet ? Opera Mobile 12.1+ ✔ MDN Element/cut_event In all current engines. Firefox 22+ Safari 3+ Chrome 1+ Opera 12.1+ Edge 79+ Edge (Legacy) 12+ IE 9+ Firefox for Android ? iOS Safari 3+ Chrome for Android ? Android WebView ? Samsung Internet ? Opera Mobile 12.1+ ✔ MDN Element/paste_event In all current engines. Firefox 22+ Safari 3+ Chrome 1+ Opera 12.1+ Edge 79+ Edge (Legacy) 12+ IE 9+ Firefox for Android ? iOS Safari 3+ Chrome for Android ? Android WebView 37+ Samsung Internet ? Opera Mobile 12.1+ ✔ MDN Navigator/clipboard In all current engines. Firefox 63+ Safari 13.1+ Chrome 66+ Opera ? Edge 79+ Edge (Legacy) ? IE None Firefox for Android ? iOS Safari ? Chrome for Android ? Android WebView ? Samsung Internet ? Opera Mobile ?

Related documents

Record · ID 310534 · SHA-256 64ff9e279103212d
Conceptio Open Knowledge Archive — every document is proof-bundled with source, license, and retrieval metadata.