-
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
updated ClipboardItem and Clipboard documentation and examples using … #33262
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.
Added some comments. PTAL, thanks!
Preview URLs
External URLs (1)URL:
(comment last updated: 2024-05-27 03:35:54) |
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.
Thank you for the PR, @tayloregivens !
Oh, also I missed that the directory for |
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.
Drive-by approval with a couple of comments. Let's wait for Will to do a more official review.
const blob = new Blob([text], { type }); | ||
const data = [new ClipboardItem({ [type]: blob })]; | ||
await navigator.clipboard.write(data); | ||
if (ClipboardItem.supports(type)) { |
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.
As discussed offline, let's remove this change since text/plain
is always supported.
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.
"image/png" is also listed as a mandatory data type: should we then change the example in the supports()
page to use something from the optional list, like "image/svg+xml" ?
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.
- We should list the types in supports() as per updated ClipboardItem and Clipboard documentation and examples using … #33262 (comment) - the lists are small and discrete, while the current implication of that doc is you can use any MIME type.
- I don't understand it yet, but the interesting optional type I'd like here is the custom type prefixed by
web
.
@tayloregivens (and @wbamberg) FYI, I'm showing an interest because this is being supported in FF127, and I'm part of the MDN team documenting that, - see #33564 . Great so see work already happening on this!
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.
Thank you for the updates @tayloregivens !
I had just one more suggested change, but I think we also have an open question about whether it's appropriate to use supports()
with "img/png" (#33262 (comment)). If not we should use a different MIME type for the supports()
page and remove the supports()
check from the examples that use "img/png" as well as the plain text ones.
This pull request has merge conflicts that must be resolved before it can be merged. |
Since plain text is always supported no need to add support() static method to example
text always support so no need for supports()
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
470c814
to
e7270dc
Compare
abf8d8b
to
5c58947
Compare
Hi @tayloregivens |
@tayloregivens I have fixed this up to address the comments. Let's see if we can get it through review! @wbamberg Can you please look at this again. The main changes are:
|
Thanks for addressing the remaining comments and updating the 'supports()' page to use 'image/svg+xml' and making a note that supports() isn't necessary with 'image/png' on the Clipboard.write() for 3. the supports method allows web authors to specify any arbitrary type and returns false for types that aren't supported by the browser. If you did want to add extra information there you could say that the mandatory types, html, text, and png are always supported and don't require using supports() static method. |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
👍 thank you @tayloregivens and @hamishwillee for your work on this PR!
* upstream/main: (55 commits) Replace `.` with `#` in example given selectors are `#ids` (mdn#33791) update info in cross browser testing strategies (mdn#33730) Clarify that `navigator.storage.persist()` depends on heuristics (mdn#33780) fix typo (mdn#33785) feat: improvements on Glossary/Hoisting (mdn#33787) CSS update: overview of shapes guide (mdn#33771) CSS update: Shapes from box values (mdn#33770) Fix issue 033506: correct droppedEntriesCount (mdn#33538) Revert "=== Symbol("foo")" (mdn#33782) docs(css): FF126 - Support for `shape()` function (mdn#33446) Bump lint-staged from 15.2.4 to 15.2.5 (mdn#33777) Bump ajv from 8.13.0 to 8.14.0 (mdn#33776) Add missing spaces for `subtlecrypto` (mdn#33774) fix: typo in `color_and_luminca` (mdn#33775) feat: improvments on gutters (mdn#33751) FF127Relnote- data: and javascript: URLS forbidden in base HREF (mdn#33738) update the content of SVG `<view>` element (mdn#33710) Clipboard.write() - log and fixes (mdn#33769) updated ClipboardItem and Clipboard documentation and examples using … (mdn#33262) Fix error in the code snippet for Symbol (mdn#33765) ...
…supports()
Updated the web API ClipboardItem and Clipboard pages to describe the supports() method. I also updated the code samples that write data to the clipboard so they use the supports method as well.
My team at Microsoft created the supports() static method and so we wanted to go ahead and document on MDN as well.