Re: [w3c/clipboard-apis] Add clipboard IDL description. (#158)

@mbrodesser requested changes on this pull request.

@snianu thanks for incorporating the previous feedback.

PTAL again. When the proposed changes are addressed, I'll approve the PR without reading the whole async clipboard spec again.

> +  Further, apps are expected to enumerate the [=/MIME type=]s of the [=/clipboard item=] they are pasting and select the one best-suited for the app according to some app-specific algorithm.
+  Alternatively, an app can present the user with options on how to paste a [=/clipboard item=], e.g. "paste as image" or "paste formatted text", etc.
+
+  A {{ClipboardItem}} object has an associated <dfn for="ClipboardItem">clipboard item</dfn>, which is a [=/clipboard item=].
+
+  A {{ClipboardItem}} object has an associated <dfn for="ClipboardItem">types array</dfn>, which is a {{FrozenArray}}&lt;{{DOMString}}&gt;.
+
+  To <dfn>create a {{ClipboardItem}} object</dfn>, given a [=/clipboard item=] |clipboardItem| and a Realm |realm|, run these steps:
+   1. Let |clipboardItemObject| be a [=new=] {{ClipboardItem}} with |realm|.
+
+   1. Set |clipboardItemObject|'s [=/clipboard item=] to |clipboardItem|.
+
+  The <dfn constructor for="ClipboardItem" lt="ClipboardItem(items, options)"><code>new ClipboardItem(<var>items</var>, <var>options</var>)</code></dfn> constructor steps are:
+   1. If |items| is empty, then throw a {{TypeError}}.
+
+   1. If |options| is empty, then set |options| to "unspecified".

Should be:
```
... set options["presentationStyle"] = "unspecified"
```

>    };
   </pre>
 
-  <div id="clipboard-idl" dfn-for="Clipboard">
+  Some methods of the {{Clipboard}} interface take or return multiple {{ClipboardItem}} objects. However, not all platforms support more than one [=/clipboard item=]; on such platforms, the algorithms below will ignore any {{ClipboardItem}} objects beyond the first one that are passed to {{Clipboard/write()}}, and {{Clipboard/read()}} and {{Clipboard/readText()}} will only ever return a single-item array.

```
... on such platforms, {{Clipboard/write()}} will ignore all items beyond the first one.
```

`read()` and `readText()` only get one clipboard item from the OS.

>    };
   </pre>
 
-  <div id="clipboard-idl" dfn-for="Clipboard">
+  Some methods of the {{Clipboard}} interface take or return multiple {{ClipboardItem}} objects. However, not all platforms support more than one [=/clipboard item=]; on such platforms, the algorithms below will ignore any {{ClipboardItem}} objects beyond the first one that are passed to {{Clipboard/write()}}, and {{Clipboard/read()}} and {{Clipboard/readText()}} will only ever return a single-item array.
+
+  A {{Clipboard}} object has an associated <dfn>clipboard</dfn>.

It hasn't. That sentence can be deleted.

>  
-    1. Let |textData| be an empty string.
+    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/plain format.

The type here doesn't match the type of `dataList` below. Either both should be `ClipboardItem`s or `clipboard item`s. It's simpler to change `dataList` to a sequence of `clipboard item`s.

>  
-    1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException
+    1. If |r| is false, then:
+    
+     1. [=Queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to [=reject=] |p| with {{"NotAllowedError"}} {{DOMException}} in |realm|.
+
+     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.

Please add:
```
Issue: some OSs contain multiple clipboard (e.g. Linux, "primary", "secondary", "selection"). Define from which of those data is read.
```
here and to `readText()`.

Please add to "write blobs and option to the clipboard":
```
Issue: some OSs contain multiple clipboard (e.g. Linux, "primary", "secondary", "selection"). Define from which of those data is written.
```


-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/pull/158#pullrequestreview-888676085
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/clipboard-apis/pull/158/review/888676085@github.com>

Received on Monday, 21 February 2022 14:38:51 UTC