This proposal aligns the HTML format read/write async API with the setData/getData DataTransfer APIs. Currently, when we read/write text/html MIME types using the async API, the sanitizer is invoked to strip out contents from the HTML markup due to security concerns, and styles are inlined in the HTML. This leads to loss of fidelity of HTML content when read by web authors or native apps. DataTransfer APIs in most browsers provide unsanitized HTML read/write so we want to align the behavior.

Motivation

Using DataTransfer object’s setData and async clipboard write method, we are seeing interop differences in how the HTML content is sanitized and written to the clipboard. In Chromium async clipboard write method clears the clipboard content first and then writes the payload which results in overwriting the previous HTML content that was inserted by authors using DataTransfer object’s setData API. It’d be beneficial for the web authors if async clipboard and setData APIs provide the same HTML content during copy operation so round tripping is possible without any interop differences. Also creating a fragment and inlining the styles bloats the payload and strips out the custom styles inserted by sites like Excel online that are used to preserve excel specific semantics.

Specification

Specification link


Specification currently under development in a Working Group

Status in Chromium

Blink>DataTransfer


In development (tracking bug)

Consensus & Standardization

After a feature ships in Chrome, the values listed here are not guaranteed to be up to date.

  • Positive
  • No signal
  • Positive

Owners

Comments

Discussion between stakeholders: https://docs.google.com/document/d/1ha0pcpQsEgVGtPK8dd8N_0P1ynI7rXV7bR5ZFmOTD6Y/edit?usp=sharing Firefox's support: https://github.com/w3c/clipboard-apis/issues/150#issuecomment-1031684598

Last updated on 2022-04-27