From 37808789b2537bbaeb627f80b8d0a415f47363fc Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Thu, 5 May 2022 15:49:06 -0700 Subject: [PATCH] Add web custom format. --- index.bs | 50 ++++++++++++++++---------------------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/index.bs b/index.bs index 62eea94..4d4dcba 100644 --- a/index.bs +++ b/index.bs @@ -786,15 +786,13 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Abort these steps. - 1. Let |data| be a copy of the [=system clipboard data=] represented as [=clipboard items=]. For the MIME types defined in the [=mandatory data types=] list, |data| contains the sanitized copy of text/html format, but image/png format has unsanitized payload to preserve meta data. + 1. Let |data| be a copy of the [=system clipboard data=] represented as [=clipboard items=]. For the [=/MIME type=]s defined in the [=mandatory data types=] list, |data| contains the content of text/html format, but image/png format has unsanitized payload to preserve meta data. For the [=/MIME type=]s that has a "web" prefix, [=read unsanitized format=] from the [=system clipboard=] and append the content of the format to |data|. Issue: Some OSs contain multiple clipboard (e.g. Linux, "primary", "secondary", "selection"). Define from which of those data is read. Note: As further described in [[#image-transcode]] this explicitly does not transcode images. Rather the original unmodified image data should be exposed to the website. - Issue: Add definition of sanitized copy. - 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: 1. Let |items| be a [=sequence=]<{{ClipboardItem}}>. @@ -951,19 +949,11 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |type| be the |blob|'s {{Blob/type}}. - 1. If |type| is not in the [=mandatory data types=] list, then [=reject=] |p| with {{"NotAllowedError"}} {{DOMException}} in |realm| and abort these steps. - - 1. Let |cleanItem| be a sanitized copy of |blob|. - - Issue: Add definition of sanitized copy. - - 1. If unable to create a sanitized copy, then follow the below steps: - - 1. [=Reject=] |p| with {{"NotAllowedError"}} DOMException in |realm|. + 1. If |type| is not in either the [=mandatory data types=] list or has "web " prefix, then [=reject=] |p| with {{"NotAllowedError"}} {{DOMException}} in |realm| and abort these steps. - 1. Abort these steps. + 1. Append |blob| to |cleanItemList|. - 1. Append |cleanItem| to |cleanItemList|. + Issue: Currently Safari does some sanitization for [=mandatory data types=]. See https://github.com/w3c/clipboard-apis/issues/150. 1. Let |option| be |clipboardItem|'s [=ClipboardItem/clipboard item=]'s [=presentation style=]. @@ -1609,11 +1599,15 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; : Output :: None + 1. Let |webCustomFormats| be a [=sequence=]<{{Blob}}>. + 1. For each |item| in |items|: 1. Let |formatString| be the result of running [=os specific well-known format=] given |item|'s {{Blob/type}}. - 1. If |formatString| is empty then abort these steps. + 1. If |formatString| is empty then follow the below steps: + + 1. If |formatString| has "web " prefix, then add |item| to |webCustomFormats|, else abort all steps. 1. Let |payload| be the result of [=UTF-8 decoding=] |item|'s underlying byte sequence. @@ -1621,6 +1615,10 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; Issue: some OSs contain multiple clipboard (e.g. Linux, "primary", "secondary", "selection"). Define to which of those data is written. + 1. For each |customItem| in |webCustomFormats|: + + 1. [=Write unsanitized format=] with |customItem| and |customItem|'s {{Blob/type}}'s [=MIME type/essence=]. +
@@ -1638,7 +1636,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; For Mac see https://developer.apple.com/documentation/appkit/nspasteboardtype

- 1. Let |wellKnownFormat| be a string. + 1. Let |wellKnownFormat| be an empty string. 1. If |mimeType|'s [=MIME type/essence=] is "text/plain", then @@ -1646,59 +1644,43 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Assign CF_UNICODETEXT to |wellKnownFormat|. - 1. Return |wellKnownFormat|. - On MacOS, follow the convention described below: 1. Assign NSPasteboardTypeString to |wellKnownFormat|. - 1. Return |wellKnownFormat|. - On Linux, ChromeOS, and Android, follow the convention described below: 1. Assign "text/plain" to |wellKnownFormat|. - 1. Return |wellKnownFormat|. - 1. Else, if |mimeType|'s [=MIME type/essence=] is "text/html", then On Windows, follow the convention described below: 1. Assign CF_HTML to |wellKnownFormat|. - 1. Return |wellKnownFormat|. - On MacOS, follow the convention described below: 1. Assign NSHTMLPboardType to |wellKnownFormat|. - 1. Return |wellKnownFormat|. - On Linux, ChromeOS, and Android, follow the convention described below: 1. Assign "text/html" to |wellKnownFormat|. - 1. Return |wellKnownFormat|. - 1. Else, if |mimeType|'s [=MIME type/essence=] is "image/png", then On Windows, follow the convention described below: 1. Assign "PNG" to |wellKnownFormat|. - 1. Return |wellKnownFormat|. - On MacOS, follow the convention described below: 1. Assign NSPasteboardTypePNG to |wellKnownFormat|. - 1. Return |wellKnownFormat|. - On Linux, ChromeOS, and Android, follow the convention described below: 1. Assign "image/png" to |wellKnownFormat|. - 1. Return |wellKnownFormat|. + 1. Return |wellKnownFormat|.
@@ -1732,7 +1714,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

write unsanitized format

: Input - :: |items|, {{Blob}}s + :: |items|, a [=sequence=]<{{Blob}}> :: |mimeType|, a string 1. Let |idx| be a number initialized to 0.