-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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 clipboard API docs to better represent ClipboardItem with string item data #37677
base: main
Are you sure you want to change the base?
Update clipboard API docs to better represent ClipboardItem with string item data #37677
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor suggestions, otherwise LGTM.
@@ -34,8 +34,7 @@ A {{jsxref("Promise")}} that resolves with a {{domxref("Blob")}} object. | |||
|
|||
## Examples | |||
|
|||
In the following example, we're returning all items on the clipboard via the {{domxref("clipboard.read()")}} method. | |||
Then utilizing the {{domxref("ClipboardItem.types")}} property to set the `getType()` argument and return the corresponding blob object. | |||
In the following example, we're returning all items on the clipboard via the {{domxref("clipboard.read()")}} method, then using the {{domxref("ClipboardItem.types")}} property to set the `getType()` argument and return the corresponding `Blob` object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the following example, we're returning all items on the clipboard via the {{domxref("clipboard.read()")}} method, then using the {{domxref("ClipboardItem.types")}} property to set the `getType()` argument and return the corresponding `Blob` object. | |
In the following example, we're returning all items on the clipboard via the {{domxref("clipboard.read()")}} method, then using the {{domxref("ClipboardItem.types")}} property to set the `getType()` argument, and return the corresponding `Blob` object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this one in a slightly different way:
In the following example, we're returning all items on the clipboard via the {{domxref("clipboard.read()")}} method. For each one, we pass the {{domxref("ClipboardItem.types")}} property to the
getType()
method, which returns the correspondingBlob
object.
### Writing to the clipboard | ||
### Writing text to the clipboard | ||
|
||
In this example we first define two constants, which respectively contain references to a {{htmlelement("p")}} element containing some text, and a {{htmlelement("button")}}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this example we first define two constants, which respectively contain references to a {{htmlelement("p")}} element containing some text, and a {{htmlelement("button")}}. | |
In this example, we first define two constants, which respectively contain references to a {{htmlelement("p")}} element containing some text, and a {{htmlelement("button")}} element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this one like so:
In this example we first define two constants containing references to a {{htmlelement("p")}} element containing some text and a {{htmlelement("button")}} element.
Co-authored-by: Thomas Steiner <[email protected]>
Co-authored-by: Thomas Steiner <[email protected]>
Co-authored-by: Thomas Steiner <[email protected]>
Yay, thanks for the technical review, @tomayac! |
Description
Chrome 133 now supports using item data of type string or a promise that resolves to a string when constructing a
ClipboardItem
object. Previously, Chrome only supported item data of typeBlob
, or a promise that resolves to aBlob
, but this change brings it up to full standards support and parity with Firefox and Safari.This PR mostly makes small changes to multiple pages to improve grammar and make sure
ClipboardItem
with string data is represented as a valid possibility.I have also added a small example to the
ClipboardItem
landing page to show the simple case for text, where you don't need to use a Blob.Motivation
Additional details
See https://chromestatus.com/feature/4926138582040576 for the data source.
The example I used for testing can be found at https://clipboard-api-string-test.glitch.me/.
Related issues and pull requests
BCD: mdn/browser-compat-data#25673