Skip to content

Commit 9c8bc4b

Browse files
committed
Add Clipboard read/write methods for Blobs.
https://w3c.github.io/clipboard-apis/#clipboard-interface is Editor's Draft, but these functions are available in Chrome 86+, Safari 13.1+, Edge 79+, and Firefox 87+ (behind a flag).
1 parent 1fd97d1 commit 9c8bc4b

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

baselines/dom.generated.d.ts

+26
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ interface ClipboardEventInit extends EventInit {
196196
clipboardData?: DataTransfer | null;
197197
}
198198

199+
interface ClipboardItemOptions {
200+
presentationStyle?: PresentationStyle;
201+
}
202+
199203
interface CloseEventInit extends EventInit {
200204
code?: number;
201205
reason?: string;
@@ -3559,7 +3563,9 @@ declare var ClientRectList: {
35593563
};
35603564

35613565
interface Clipboard extends EventTarget {
3566+
read(): Promise<ClipboardItems>;
35623567
readText(): Promise<string>;
3568+
write(data: ClipboardItems): Promise<void>;
35633569
writeText(data: string): Promise<void>;
35643570
}
35653571

@@ -3578,6 +3584,18 @@ declare var ClipboardEvent: {
35783584
new(type: string, eventInitDict?: ClipboardEventInit): ClipboardEvent;
35793585
};
35803586

3587+
interface ClipboardItem {
3588+
readonly delayed: boolean;
3589+
readonly lastModified: number;
3590+
readonly presentationStyle: PresentationStyle;
3591+
}
3592+
3593+
declare var ClipboardItem: {
3594+
prototype: ClipboardItem;
3595+
new(items: Record<string, ClipboardItemData>, options?: ClipboardItemOptions): ClipboardItem;
3596+
createDelayed(items: Record<string, ClipboardItemDelayedCallback>, options?: ClipboardItemOptions): ClipboardItem;
3597+
};
3598+
35813599
/** A CloseEvent is sent to clients using WebSockets when the connection is closed. This is delivered to the listener indicated by the WebSocket object's onclose attribute. */
35823600
interface CloseEvent extends Event {
35833601
/**
@@ -18903,6 +18921,10 @@ interface BlobCallback {
1890318921
(blob: Blob | null): void;
1890418922
}
1890518923

18924+
interface ClipboardItemDelayedCallback {
18925+
(): ClipboardItemData;
18926+
}
18927+
1890618928
interface CustomElementConstructor {
1890718929
new (...params: any[]): HTMLElement;
1890818930
}
@@ -19649,6 +19671,9 @@ declare function addEventListener<K extends keyof WindowEventMap>(type: K, liste
1964919671
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
1965019672
declare function removeEventListener<K extends keyof WindowEventMap>(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
1965119673
declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
19674+
type ClipboardItems = ClipboardItem[];
19675+
type ClipboardItemDataType = string | Blob;
19676+
type ClipboardItemData = Promise<ClipboardItemDataType>;
1965219677
type HeadersInit = Headers | string[][] | Record<string, string>;
1965319678
type BodyInit = Blob | BufferSource | FormData | URLSearchParams | ReadableStream<Uint8Array> | string;
1965419679
type RequestInfo = Request | string;
@@ -19787,6 +19812,7 @@ type PermissionState = "denied" | "granted" | "prompt";
1978719812
type PlaybackDirection = "alternate" | "alternate-reverse" | "normal" | "reverse";
1978819813
type PositionAlignSetting = "auto" | "center" | "line-left" | "line-right";
1978919814
type PremultiplyAlpha = "default" | "none" | "premultiply";
19815+
type PresentationStyle = "attachment" | "inline" | "unspecified";
1979019816
type PublicKeyCredentialType = "public-key";
1979119817
type PushEncryptionKeyName = "auth" | "p256dh";
1979219818
type PushPermissionState = "denied" | "granted" | "prompt";

inputfiles/removedTypes.json

-9
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,6 @@
7070
}
7171
}
7272
},
73-
"Clipboard": {
74-
"methods": {
75-
"method": {
76-
"read": null,
77-
"write": null
78-
}
79-
}
80-
},
81-
"ClipboardItem": null,
8273
"Console": null,
8374
"Coordinates": null,
8475
"CSS": null,

0 commit comments

Comments
 (0)