Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update and stablize the Clipboard API #3992

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
* Annotated methods in WebCodecs that throw.
[#3970](https://github.com/rustwasm/wasm-bindgen/pull/3970)

* Update and stabilize widely supported parts of the Clipboard API.
* Update and stabilize the Clipboard API.
[#3992](https://github.com/rustwasm/wasm-bindgen/pull/3992)

### Fixed
Expand Down
7 changes: 7 additions & 0 deletions crates/web-sys/src/features/gen_ClipboardItem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ClipboardItem`*"]
pub fn get_type(this: &ClipboardItem, type_: &str) -> ::js_sys::Promise;
# [wasm_bindgen (static_method_of = ClipboardItem , js_class = "ClipboardItem" , js_name = supports)]
#[doc = "The `supports()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/supports)"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link is generated, so that would have to be fixed in the generator.
It would be interesting to see if that is an exception for this specific static method or if this actually fixes a bug in the generator.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #4010.

#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `ClipboardItem`*"]
pub fn supports(type_: &str) -> bool;
}
18 changes: 14 additions & 4 deletions crates/web-sys/webidls/enabled/Clipboard.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
* https://w3c.github.io/clipboard-apis/#idl-index
*/

dictionary ClipboardEventInit : EventInit {
DataTransfer? clipboardData = null;
};

[Exposed=Window]
interface ClipboardEvent : Event {
constructor(DOMString type, optional ClipboardEventInit eventInitDict = {});
readonly attribute DataTransfer? clipboardData;
};

partial interface Navigator {
[SecureContext, SameObject] readonly attribute Clipboard clipboard;
};
Expand All @@ -15,6 +25,7 @@ typedef Promise<(DOMString or Blob)> ClipboardItemData;

[SecureContext, Exposed=Window]
interface ClipboardItem {
[Throws]
constructor(record<DOMString, ClipboardItemData> items,
optional ClipboardItemOptions options = {});

Expand All @@ -23,8 +34,7 @@ interface ClipboardItem {

Promise<Blob> getType(DOMString type);

// Not supported by WebKit
// static boolean supports(DOMString type);
static boolean supports(DOMString type);
};

enum PresentationStyle { "unspecified", "inline", "attachment" };
Expand All @@ -37,7 +47,7 @@ typedef sequence<ClipboardItem> ClipboardItems;

[SecureContext, Exposed=Window]
interface Clipboard : EventTarget {
Promise<ClipboardItems> read(/* optional ClipboardUnsanitizedFormats formats = {} */);
Promise<ClipboardItems> read(optional ClipboardUnsanitizedFormats formats = {});
Promise<DOMString> readText();
Promise<undefined> write(ClipboardItems data);
Promise<undefined> writeText(DOMString data);
Expand All @@ -49,7 +59,7 @@ interface Clipboard : EventTarget {
// sequence<DOMString> unsanitized;
// };

// Also Chrome-only
// Also Chrome-only.
// dictionary ClipboardPermissionDescriptor : PermissionDescriptor {
// boolean allowWithoutGesture = false;
// };
18 changes: 0 additions & 18 deletions crates/web-sys/webidls/enabled/ClipboardEvent.webidl

This file was deleted.