-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update and stablize the Clipboard API (#3992)
- Loading branch information
Showing
13 changed files
with
155 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
crates/web-sys/src/features/gen_ClipboardUnsanitizedFormats.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#![allow(unused_imports)] | ||
#![allow(clippy::all)] | ||
use super::*; | ||
use wasm_bindgen::prelude::*; | ||
#[cfg(web_sys_unstable_apis)] | ||
#[wasm_bindgen] | ||
extern "C" { | ||
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = ClipboardUnsanitizedFormats)] | ||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
#[doc = "The `ClipboardUnsanitizedFormats` dictionary."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `ClipboardUnsanitizedFormats`*"] | ||
#[doc = ""] | ||
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] | ||
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] | ||
pub type ClipboardUnsanitizedFormats; | ||
#[wasm_bindgen(method, setter = "unsanitized")] | ||
fn unsanitized_shim(this: &ClipboardUnsanitizedFormats, val: &::wasm_bindgen::JsValue); | ||
} | ||
#[cfg(web_sys_unstable_apis)] | ||
impl ClipboardUnsanitizedFormats { | ||
#[doc = "Construct a new `ClipboardUnsanitizedFormats`."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `ClipboardUnsanitizedFormats`*"] | ||
#[doc = ""] | ||
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] | ||
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] | ||
pub fn new() -> Self { | ||
#[allow(unused_mut)] | ||
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); | ||
ret | ||
} | ||
#[cfg(web_sys_unstable_apis)] | ||
#[doc = "Change the `unsanitized` field of this object."] | ||
#[doc = ""] | ||
#[doc = "*This API requires the following crate features to be activated: `ClipboardUnsanitizedFormats`*"] | ||
#[doc = ""] | ||
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] | ||
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] | ||
pub fn unsanitized(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { | ||
self.unsanitized_shim(val); | ||
self | ||
} | ||
} | ||
#[cfg(web_sys_unstable_apis)] | ||
impl Default for ClipboardUnsanitizedFormats { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | ||
/* | ||
* Clipboard API and events | ||
* Editor’s Draft, 4 June 2024 | ||
* | ||
* The origin of this IDL file is: | ||
* 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; | ||
}; | ||
|
||
typedef Promise<(DOMString or Blob)> ClipboardItemData; | ||
|
||
[SecureContext, Exposed=Window] | ||
interface ClipboardItem { | ||
[Throws] | ||
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); | ||
}; |
Oops, something went wrong.