Clipboard.webidl (2047B)
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 * 6 * The origin of this IDL file is 7 * https://w3c.github.io/clipboard-apis/ 8 * 9 * Copyright © 2018 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C 10 * liability, trademark and document use rules apply. 11 */ 12 13 typedef sequence<ClipboardItem> ClipboardItems; 14 15 [SecureContext, 16 Exposed=Window] 17 interface Clipboard : EventTarget { 18 [NewObject, NeedsSubjectPrincipal] 19 Promise<ClipboardItems> read(); 20 [NewObject, NeedsSubjectPrincipal] 21 Promise<DOMString> readText(); 22 23 [NewObject, NeedsSubjectPrincipal] 24 Promise<undefined> write(ClipboardItems data); 25 26 [NewObject, NeedsSubjectPrincipal] 27 Promise<undefined> writeText(DOMString data); 28 }; 29 30 typedef (DOMString or Blob) ClipboardItemDataType; 31 typedef Promise<ClipboardItemDataType> ClipboardItemData; 32 // callback ClipboardItemDelayedCallback = ClipboardItemData (); 33 34 [SecureContext, Exposed=Window] 35 interface ClipboardItem { 36 [Throws] 37 constructor(record<DOMString, ClipboardItemData> items, 38 optional ClipboardItemOptions options = {}); 39 40 // static ClipboardItem createDelayed( 41 // record<DOMString, ClipboardItemDelayedCallback> items, 42 // optional ClipboardItemOptions options = {}); 43 44 readonly attribute PresentationStyle presentationStyle; 45 // readonly attribute long long lastModified; 46 // readonly attribute boolean delayed; 47 48 // TODO: Use FrozenArray once available. (Bug 1236777) 49 // readonly attribute FrozenArray<DOMString> types; 50 [Frozen, Cached, Pure] 51 readonly attribute sequence<DOMString> types; 52 53 [NewObject] 54 Promise<Blob> getType(DOMString type); 55 56 static boolean supports(DOMString type); 57 }; 58 59 enum PresentationStyle { "unspecified", "inline", "attachment" }; 60 61 dictionary ClipboardItemOptions { 62 PresentationStyle presentationStyle = "unspecified"; 63 };