-
Notifications
You must be signed in to change notification settings - Fork 37
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
Arbitrary clipboard types #165
Comments
Thanks for the proposal. Some questions below to clarify some details: Your "web" keyword indicates that a mime-type is to be read from the platform-specific location named in the Web Custom Format Map. True? The absence of the keyword means that it is read from the well-known location (assuming we're dealing with a well-known mime-type like "text/html"). True? It is assumed that the content returned is always unsanitized whether the "web" keyword is used or not. True? Say on Windows, if the clipboard contained a Web Custom Format Map entry for "text/html" in "Web Custom Format 1", and the clipboard also contained the "HTML Format", you would expect at least two entries in Stating the above more generally, |
Also cc @mbrodesser, @smaug---- |
Yes.
Yes, in particular this should continue to behave as it does today.
This proposal does not attempt to change the processing model for non-"web" types. (I suspect we need to allow manipulation of non-"web" as Safari does that today for privacy reasons and other browsers might want to as well. Open a new issue for this perhaps?)
Yes.
This is hard to answer as |
Thanks for the responses, @annevk. Another question on a point that escaped my initial reading; you said:
Amongst the goals listed in our current proposal is:
I believe to allow native apps the ability to communicate with web apps via multiple browser implementations, that we'll need to document, by platform, the expected shape of the web custom formats on the clipboard. @snianu has proposed a per-platform shape here. I'm not sure if you meant to imply the format could be different for each browser implementation or not. Could you clarify? |
That's a good point. The intent is to leave the API up to the OS. And indeed implementation-defined is a poor fit for that (unless the user agent happens to be the OS). I suggest we say something like operating-system-defined. |
The Web Editing Working Group just discussed The full IRC log of that discussion<Travis> Topic: Arbitrary clipboard types<Travis> github: https://github.com//issues/165 <Travis> BoCupp: from our last meeting, it sounds like we are flexible and willing to adopt AnneVK's proposal. <Travis> AnneVK is OK with his own proposal.. <Travis> Microsoft is OK with it. <Travis> whsieh: Would like a bit more time to think about it... do like the shape of this proposal more than the unsanitized flag, though. <Travis> .. I'll give it some thought and post something here on this issue in about a week. <Travis> .. was there some other issue that went into more detail? <Travis> .. I was thinking of #150 <Travis> .. (https://github.com//issues/150) <Travis> BoCupp: I think AnneVK split these into two issues... one was about the shape of the API (letting the author pick something from the clipboard) <BoCupp> https://github.com//issues/150#issuecomment-1031684598 <Travis> .. the other about aligning between getData (datatransfer) and behavior of async API. <Travis> .. so user agents may optional transfer that content. <Travis> whsieh: I'll leave a comment by next week. <Travis> action: whsieh to leave a comment on https://github.com//issues/165 in support or with other perspectives. |
@annevk Could you please check the meeting minutes and let us know if it all sounds good to you or do you have any specific questions/concerns? @mbrodesser FYI since it also talks about aligning async APIs with DataTransfer APIs which might resolve our sanitization issue in PR #158 |
It sounded good to me. Looking forward to @whsieh's take. |
We discussed this with Google folks and agreed with this proposal that adds a |
I would suggest we drop "pickling" from the name and use something like "Custom Clipboard Types" or "Web Clipboard Types". It's also not clear to me that OS-Interaction works for macOS given the discussion around that to date, but otherwise it seems fine. We should probably include the 100 limit in the eventual specification to prevent egregious platform differences. |
I suggest we add some sort of feature-detection for custom and classic formats. This is actual nightmare-ish application code of mine that only makes sure copying works on three browsers (Firefox, Chrome, Safari): https://github.com/tomayac/SVGcode/blob/b29b27dadf2cf3c8aefb77e2c3db9feb0872d91d/src/js/clipboard.js#L64-L136 My suggestion would be to add a static function on ClipboardItem.supports('image/webp');
// `false`
ClipboardItem.supports('image/png');
// `true`
ClipboardItem.supports('web');
// `true` Or maybe even better (and similar to await ClipboardItem.getSupportedFormats()
// `['text/plain', 'image/png', 'web']` Not sure how to express custom types here, as a ground for discussion I just went with |
I'm not sure I like enumeration per se (you are likely to run into ordering issues), but |
Just curious, why can't the author enumerate the
|
SGTM, opened as a separate Issue #170. |
Sounds good. I'll remove all references to pickling from the explainer.
Yes, I'm planning to add that to the specification. |
Just to be sure, this is about writing to the clipboard. See my sample code and the comments. |
The overall plan sounds reasonable to me. Thank you for writing this up! One thing I'd like to clarify — would this proposal allow for WebKit's clipboard sanitization policy to apply when reading and writing "web text/html" across different origins? More concretely — if site foo.com writes "web text/html" to the clipboard, we would want to only expose sanitized data on "text/html" to bar.com. However, if a native app writes "web text/html" into the system clipboard, we would allow bar.com to read it as "web text/html" with no sanitization. |
The idea is that if you only write "web text/html" you cannot read "text/html" (as there's no such entry). If you write both "web text/html" and "text/html", then a "text/html" read can be sanitized of course. |
I see — is it the case that site authors should always write both "web text/html" as well as "text/html", then, when copying markup? (That is, for compatibility with other websites that have not yet adopted "web text/html", in addition to browsers, such as WebKit, that would intentionally hide "web text/html" when copying and pasting across security origins). |
WebKit would not support arbitrary types across origins? What is the concern there given it's opt-in from all sides? |
Perhaps a more aggressive term than "web" as "uncontrolled", "unsanitized", "unchecked" or "dangerous" (...) better alert the developers and reassure the Webkit team? |
So in shipping Safari, our DataTransfer APIs don't allow for cross-origin transfer of custom data types, since this could be abused as a potential tracking mechanism. With the async clipboard API, we currently uphold these same rules for the same reasons (as well as consistency with the legacy API). |
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3650952 Commit-Queue: Anupam Snigdha <snianu@microsoft.com> Reviewed-by: Alexander Timin <altimin@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Austin Sullivan <asully@chromium.org> Cr-Commit-Position: refs/heads/main@{#1011078}
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3650952 Commit-Queue: Anupam Snigdha <snianu@microsoft.com> Reviewed-by: Alexander Timin <altimin@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Austin Sullivan <asully@chromium.org> Cr-Commit-Position: refs/heads/main@{#1011078}
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3650952 Commit-Queue: Anupam Snigdha <snianu@microsoft.com> Reviewed-by: Alexander Timin <altimin@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Austin Sullivan <asully@chromium.org> Cr-Commit-Position: refs/heads/main@{#1011078}
…mats implementation., a=testonly Automatic update from web-platform-tests [Clipboard API] Clipboard Web Custom Formats implementation. This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3650952 Commit-Queue: Anupam Snigdha <snianu@microsoft.com> Reviewed-by: Alexander Timin <altimin@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Austin Sullivan <asully@chromium.org> Cr-Commit-Position: refs/heads/main@{#1011078} -- wpt-commits: b8ebea7f172334f5a5d9ac87860aec5f55becd26 wpt-pr: 34117
I am very existed about this proposal! We are building an XML editor in which we would love to have a way to initiate a Our context: we write Ideally, we want to use the async clipboard IFF there is custom mimetype support and instruct using the shortkeys in all other cases. We are however stuck at how we should detect the support of arbitrary mimetypes for the clipboard. Specifically the case where the async clipboard API is available but custom mimetypes are not. IE, Chrome version 103 and earlier. If Firefox would take the same process as Chrome (allow the normal mimetypes before the arbitrary ones), we are unable to detect this. With the current APIs we have a difficult time detecting whether something is pasted from an external source ( Am I overlooking something or is this case indeed very tricky to detect? |
I have opened #170 in which I propose the following: ClipboardItem.supports('image/webp');
// `false`
ClipboardItem.supports('image/png');
// `true`
ClipboardItem.supports('web');
// `true` |
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3650952 Commit-Queue: Anupam Snigdha <snianu@microsoft.com> Reviewed-by: Alexander Timin <altimin@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Austin Sullivan <asully@chromium.org> Cr-Commit-Position: refs/heads/main@{#1011078} NOKEYCHECK=True GitOrigin-RevId: a3b96a459cf17ddc683b510718bfcbe40ed08195
@whsieh For cross-origin copy/paste using DataTransfer APIs, Safari only allows to read sanitized HTML from the standard html format -- Apart from what Ryosuke described in this comment, are there any other reasons as to why this approach was chosen by Safari? |
Is it exepcted according to the spec that these |
@DavidMulder0 Yes, these web custom types are only for async clipboard APIs. However, there are browser specific clipboard formats (e.g in Chromium we have "Chromium Web Custom MIME Data Format") that allow you to read/write custom types from within the browser via DataTransfer APIs, but it's not interoperable with native apps and async clipboard APIs. |
As the current async clipboard API does not have a definition, extensions to it are somewhat hard to define, but here is my basic idea for arbitrary clipboard types that I think works for all parties.
The
ClipboardItem
constructor and theClipboardItem
getType()
method both take a string that represents a type. As this type is a MIME type it's formatted as "type/subtype
". The only types supported there are builtin types, such as "text/plain
".To extend this to allow arbitrary types, without impacting the processing of builtin types, which can be special depending on the user agent and its requirements, this proposal suggests introducing a namespace for arbitrary types. Arbitrary types will always have their data stored and read as-is, without any manipulation.
Arbitrary types are denoted by the prefix "
web
" ("web
" followed by U+0020 SPACE) to distinguish them from builtin types. They are stored in an implementation-defined manner on the underlying OS clipboard and must not interfere with builtin types.Expressed in JavaScript, this is how would you read an arbitrary type:
And this is how would write one:
@whsieh @snianu @BoCupp-Microsoft @travisleithead @johanneswilm
The text was updated successfully, but these errors were encountered: