Skip to content

Commit 2a56788

Browse files
authored
Merge pull request #639 from Microsoft/ClipboardEventInit-try-2
Add Clipboard Interfaces to idlSources
2 parents ff375bf + 2ae159a commit 2a56788

File tree

6 files changed

+51
-34
lines changed

6 files changed

+51
-34
lines changed

baselines/dom.generated.d.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ interface ClientQueryOptions {
183183
type?: ClientTypes;
184184
}
185185

186+
interface ClipboardEventInit extends EventInit {
187+
clipboardData?: DataTransfer | null;
188+
}
189+
186190
interface CloseEventInit extends EventInit {
187191
code?: number;
188192
reason?: string;
@@ -3260,21 +3264,26 @@ declare var ClientRectList: {
32603264
new(): ClientRectList;
32613265
};
32623266

3267+
interface Clipboard extends EventTarget {
3268+
readText(): Promise<string>;
3269+
writeText(data: string): Promise<void>;
3270+
}
3271+
3272+
declare var Clipboard: {
3273+
prototype: Clipboard;
3274+
new(): Clipboard;
3275+
};
3276+
32633277
/** The ClipboardEvent interface represents events providing information related to modification of the clipboard, that is cut, copy, and paste events. */
32643278
interface ClipboardEvent extends Event {
3265-
readonly clipboardData: DataTransfer;
3279+
readonly clipboardData: DataTransfer | null;
32663280
}
32673281

32683282
declare var ClipboardEvent: {
32693283
prototype: ClipboardEvent;
32703284
new(type: string, eventInitDict?: ClipboardEventInit): ClipboardEvent;
32713285
};
32723286

3273-
interface ClipboardEventInit extends EventInit {
3274-
data?: string;
3275-
dataType?: string;
3276-
}
3277-
32783287
/** 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. */
32793288
interface CloseEvent extends Event {
32803289
readonly code: number;
@@ -10494,6 +10503,7 @@ declare var NavigationPreloadManager: {
1049410503
interface Navigator extends NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia, NavigatorLanguage, NavigatorStorage, NavigatorAutomationInformation {
1049510504
readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
1049610505
readonly authentication: WebAuthentication;
10506+
readonly clipboard: Clipboard;
1049710507
readonly cookieEnabled: boolean;
1049810508
readonly doNotTrack: string | null;
1049910509
gamepadInputEmulation: GamepadInputEmulationType;

inputfiles/addedTypes.json

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -832,26 +832,6 @@
832832
}
833833
}
834834
},
835-
"ClipboardEventInit": {
836-
"exposed": "Window",
837-
"name": "ClipboardEventInit",
838-
"extends": "EventInit",
839-
"properties": {
840-
"property": {
841-
"data": {
842-
"name": "data",
843-
"override-type": "string",
844-
"required": 0
845-
},
846-
"dataType": {
847-
"name": "dataType",
848-
"override-type": "string",
849-
"required": 0
850-
}
851-
}
852-
},
853-
"no-interface-object": "1"
854-
},
855835
"IDBArrayKey": {
856836
"name": "IDBArrayKey",
857837
"extends": "Array<IDBValidKey>",

inputfiles/idl/Clipboard.widl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
dictionary ClipboardEventInit : EventInit {
2+
DataTransfer? clipboardData = null;
3+
};
4+
5+
[Constructor(DOMString type, optional ClipboardEventInit eventInitDict), Exposed=Window]
6+
interface ClipboardEvent : Event {
7+
readonly attribute DataTransfer? clipboardData;
8+
};
9+
10+
partial interface Navigator {
11+
[SecureContext, SameObject] readonly attribute Clipboard clipboard;
12+
};
13+
14+
[SecureContext, Exposed=Window] interface Clipboard : EventTarget {
15+
Promise<DataTransfer> read();
16+
Promise<DOMString> readText();
17+
Promise<void> write(DataTransfer data);
18+
Promise<void> writeText(DOMString data);
19+
};
20+
21+
dictionary ClipboardPermissionDescriptor : PermissionDescriptor {
22+
boolean allowWithoutGesture = false;
23+
};

inputfiles/idlSources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[
2+
{
3+
"url": "https://www.w3.org/TR/clipboard-apis/",
4+
"title": "Clipboard"
5+
},
26
{
37
"url": "https://compat.spec.whatwg.org/",
48
"title": "Compatibility",

inputfiles/overridingTypes.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,14 +1342,6 @@
13421342
}
13431343
}
13441344
},
1345-
"ClipboardEvent": {
1346-
"name": "ClipboardEvent",
1347-
"constructor": {
1348-
"override-signatures": [
1349-
"new(type: string, eventInitDict?: ClipboardEventInit): ClipboardEvent"
1350-
]
1351-
}
1352-
},
13531345
"Storage": {
13541346
"name": "Storage",
13551347
"methods": {

inputfiles/removedTypes.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
},
4242
"interfaces": {
4343
"interface": {
44+
"Clipboard": {
45+
"methods": {
46+
"method": {
47+
"read": null,
48+
"write": null
49+
}
50+
}
51+
},
4452
"Console": {
4553
"methods": {
4654
"method": {

0 commit comments

Comments
 (0)