- From: snianu <notifications@github.com>
- Date: Mon, 18 Sep 2023 10:44:04 -0700
- To: w3c/clipboard-apis <clipboard-apis@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/clipboard-apis/issues/193@github.com>
On Windows, according to the [mdn doc](https://learn.microsoft.com/en-us/windows/win32/dataxchg/html-clipboard-format), native apps need to write `<!--StartFragment -->` and `<!--EndFragment -->` tags to indicate the fragment start and end in the HTML markup. This information is also present in the[ HTML headers](https://learn.microsoft.com/en-us/windows/win32/dataxchg/html-clipboard-format#description-headers-and-offsets) that get written to the clipboard. However, it's not exactly clear where we should insert these fragment tags into the markup when web authors read/write the HTML data from/to the clipboard via async clipboard read()/write() method and DataTransfer API getData/setData methods. We think that it's better to let the web authors decide what to do with the tags, so it's simpler to just return the start and end fragment tags as-is without any changes to the existing HTML markup. This also makes async read() method interoperable with DataTransfer APIs getData method. Note that even though the below example is specific to Chromium, Firefox also behaves the same way when it comes to DataTransfer APIs set/getData methods. e.g. In Chromium browsers, when `<p>Hello World</p>` is inserted via setData method during copy event, we see the below content for `HTML format` on the system clipboard: ``` Version:0.9 StartHTML:0000000105 EndHTML:0000000195 StartFragment:0000000141 EndFragment:0000000159 <html> <body> <!--StartFragment--><p>Hello World</p><!--EndFragment--> </body> </html> ``` getData method returns the following string during paste event: ``` Version:0.9 StartHTML:0000000105 EndHTML:0000000195 StartFragment:0000000141 EndFragment:0000000159 <html> <body> <!--StartFragment--><p>Hello World</p><!--EndFragment--> </body> </html> ``` In Async clipboard API, write() method produces the below markup: ``` Version:0.9 StartHTML:0000000105 EndHTML:0000000195 StartFragment:0000000141 EndFragment:0000000159 <html> <body> <!--StartFragment--><p>Hello World</p><!--EndFragment--> </body> </html> ``` read() method strips out the fragment tags and returns `<p>Hello World</p>`: ``` <p>Hello World</p> ``` @evanstade @annevk @sanketj @inexorabletash @smaug---- @EdgarChen -- Reply to this email directly or view it on GitHub: https://github.com/w3c/clipboard-apis/issues/193 You are receiving this because you are subscribed to this thread. Message ID: <w3c/clipboard-apis/issues/193@github.com>
Received on Monday, 18 September 2023 17:44:09 UTC