From 03fe049265af1c59af50dbf21cf530da7bd4446d Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Mon, 4 Oct 2021 18:52:04 -0700 Subject: [PATCH 01/31] Add clipboard IDL description. --- index.bs | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 04171d6..5aa6610 100644 --- a/index.bs +++ b/index.bs @@ -606,8 +606,51 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; }; -
+ ClipboardItemDataType +

+ Returns a {{DOMString}} or [=Blob=] type. +

+ + ClipboardItemData +

+ Returns a [=Promise=] to the [=ClipboardItemDataType=]. +

+ + {{ClipboardItem}} +

A {{ClipboardItem}} object contains the {{ClipboardItem/types}} listed in the [=mandatory data types=] list that are present on the [=system clipboard=]. +

The {{ClipboardItem/constructor()}} step for new ClipboardItem(items, options) + is to set [=this=]'s items to items and options to options +

+ + Issue: Add definition to clarify what {{ClipboardItem/createDelayed()}} method does. From the discussions it looks like a Windows/Mac only feature where the + platform supports writing of the data to the system clipboard in a delayed fashion so the system clipboard can request data on-demand. + See https://docs.microsoft.com/en-us/windows/win32/dataxchg/clipboard-operations#delayed-rendering + + presentationStyle +

It is an enumerated attribute whose keywords are the string, unspecified, inline and attachment. + The IDL attribute must [=reflect=] the respective content attributes of the same name.

+ +

{{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s {{ClipboardItem/presentationStyle}}

+ + Issue: Currently {{ClipboardItem/lastModified}} is not supported in Chromium and Safari, Should we remove it? + + Issue: Delay rendering support has not been added to Chromium and Safari so {{ClipboardItem/delayed}} is unused. + types +

Returns {{ClipboardItem/types}} listed in the [=mandatory data types=] list that are present on the [=system clipboard=]. + + getType({{DOMString}} type) +

The {{ClipboardItem/getType}} must run the below steps:

+ + 1. Let |p| be a new [=Promise=]. + + 1. If |type| is not listed in the [=mandatory data types=] list, then reject |p| with a "The type was not found" DOMException. + + 1. Let |data| be the result of reading the |type| from the [=system clipboard=]. + + 1. Resolve |p| with |data|. + +

read()

The {{Clipboard/read()}} method must run these steps: @@ -617,6 +660,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Run the following steps [=in parallel=]: 1. Let |r| be the result of running [=check clipboard read permission=] [=in parallel=] + Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside + a user gesture event and the user must select the paste option from the native context menu that pops up + when read() is called from JS, otherwise, the promise will be rejected. 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException @@ -1245,6 +1291,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; Ojan Vafai, Tarquin Wilton-Jones, Tom Wlodkowski, + Bo Cupp, and Boris Zbarsky. From 51c8bc51971dd5e98d082025cf07bf1d5b9e29c2 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Mon, 4 Oct 2021 18:59:30 -0700 Subject: [PATCH 02/31] Fix bikeshed error. --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 5aa6610..100ff31 100644 --- a/index.bs +++ b/index.bs @@ -640,7 +640,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

Returns {{ClipboardItem/types}} listed in the [=mandatory data types=] list that are present on the [=system clipboard=]. getType({{DOMString}} type) -

The {{ClipboardItem/getType}} must run the below steps:

+

The {{ClipboardItem/getType()}} must run the below steps:

1. Let |p| be a new [=Promise=]. From 34a50d0d400dc777bad53826181875347240a673 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Tue, 5 Oct 2021 23:53:56 -0700 Subject: [PATCH 03/31] Address comments. --- index.bs | 73 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/index.bs b/index.bs index 100ff31..12e4fd3 100644 --- a/index.bs +++ b/index.bs @@ -562,6 +562,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

clipboard

The [=clipboard=] attribute must return the {{Navigator}}'s [=clipboard=] object. + The [=clipboard=] attribute is used to execute read/write operation from/to the [=system clipboard=].
@@ -606,20 +607,50 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; }; - ClipboardItemDataType +
+

ClipboardItem

+ The [=ClipboardItem=] object represents the content of the MIME types that are in the [=mandatory data types=] list, and are currently on the [=system clipboard=]. + It has a mapping of the MIME types in {{DOMString}} format and a [=Blob=] corresponding to the MIME types that contains the actual payload. A web author needs to + create a [=ClipboardItem=] object in order to write content to the clipboard using the {{Clipboard/write()}} method. {{Clipboard/read()}} returns a [=ClipboardItem=] object + that can be used to read a specific |type| using {{ClipboardItem/getType()}}. +
+
+
clipboardItem = new ClipboardItem([items, options]) +
+ Creates a new {{ClipboardItem}} object. items are used to fill its MIME types and [=Promise=]s to [=Blob=]s corresponding to the MIME types, options can be used to fill its {{ClipboardItemOptions}}, + as per the example below. + +
+

+			const format1 = 'text/plain';
+			const format2 = 'text/html';
+			const promise_text_blob = Promise.resolve(new Blob(['hello'], {type: format1}));
+			const promise_html_blob = Promise.resolve(new Blob(['

Test

'], {type: format2})); + const clipboardItemInput = new ClipboardItem( + {[format1]: promise_text_blob, [format2]: promise_html_blob}, + {options: "unspecified"}); +
+
+ +
clipboardItem . getType(type) +

Returns a [=Promise=] to the [=Blob=] corresponding to the type. + +

types of clipboardItem +

Returns the list of types contained in the clipboardItem object. + +

- Returns a {{DOMString}} or [=Blob=] type. + The {{ClipboardItem/constructor()}} step for new ClipboardItem(items, options) is to set [=this=]'s items to items and options to options

- ClipboardItemData + ClipboardItemDataType

- Returns a [=Promise=] to the [=ClipboardItemDataType=]. + A {{DOMString}} or [=Blob=] type. This contains the payload corresponding to the MIME type while creating a {{ClipboardItem}} object.

- {{ClipboardItem}} -

A {{ClipboardItem}} object contains the {{ClipboardItem/types}} listed in the [=mandatory data types=] list that are present on the [=system clipboard=]. -

The {{ClipboardItem/constructor()}} step for new ClipboardItem(items, options) - is to set [=this=]'s items to items and options to options + ClipboardItemData +

+ A [=Promise=] to the [=ClipboardItemDataType=].

Issue: Add definition to clarify what {{ClipboardItem/createDelayed()}} method does. From the discussions it looks like a Windows/Mac only feature where the @@ -627,8 +658,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; See https://docs.microsoft.com/en-us/windows/win32/dataxchg/clipboard-operations#delayed-rendering presentationStyle -

It is an enumerated attribute whose keywords are the string, unspecified, inline and attachment. - The IDL attribute must [=reflect=] the respective content attributes of the same name.

+

It is an enumerated attribute whose keywords are the string, unspecified, inline and attachment.

{{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s {{ClipboardItem/presentationStyle}}

@@ -650,7 +680,6 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Resolve |p| with |data|. -

read()

The {{Clipboard/read()}} method must run these steps: @@ -667,7 +696,10 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException 1. Let |data| be a copy of the [=system clipboard data=] represented as - a sequence of {{ClipboardItem}}s. + a sequence of {{ClipboardItem}}s. 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. + + Note: Currently in Chromium, only a single {{ClipboardItem}} object is supported for reading and writing via [=clipboard=] object. 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. @@ -732,11 +764,20 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException - 1. Let |cleanItemList| be an empty sequence<{{Blob}}>. + 1. Let |itemList| and |cleanItemList| be an empty sequence<{{Blob}}>. + + 1. For each |item| in |data|: + 1. If [=Promise=] to {{Blob}} in |item| is rejected, then throw "Promises to Blobs were rejected." DOMException. + + 1. Add the {{Blob}} in |item| to |itemList| after the promise has been resolved. + + 1. For each {{Blob}} |itemBlob| in |itemList|: + + 1. If {{Blob/type}} is not in the [=mandatory data types=] list, then reject |p| with a "Type {{Blob/type}} not supported on write." DOMException. - 1. For each {{Blob}} |item| in |data|: + 1. Let |cleanItem| be a sanitized copy of |itemBlob|. - 1. Let |cleanItem| be a sanitized copy of |item|. + Issue: Add definition of sanitized copy. 1. If unable to create a sanitized copy, then reject |p|. @@ -751,7 +792,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
-				var data = [new ClipboardItem({ "text/plain": new Blob(["Text data"], { type: "text/plain" }) })];
+				var data = [new ClipboardItem({ "text/plain": Promise.resolve(new Blob(["Text data"], { type: "text/plain" }) }))];
 				navigator.clipboard.write(data).then(function() {
 					console.log("Copied to clipboard successfully!");
 				}, function() {

From 2f673f9a0d70f4f4fe51711d4dfc86058a04bdaa Mon Sep 17 00:00:00 2001
From: Anupam Snigdha 
Date: Tue, 5 Oct 2021 23:58:56 -0700
Subject: [PATCH 04/31] Fix error.

---
 index.bs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/index.bs b/index.bs
index 12e4fd3..ac5534a 100644
--- a/index.bs
+++ b/index.bs
@@ -633,7 +633,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
 			
clipboardItem . getType(type) -

Returns a [=Promise=] to the [=Blob=] corresponding to the type. +

Returns a [=Promise=] to the [=Blob=] corresponding to the type.

types of clipboardItem

Returns the list of types contained in the clipboardItem object. From 639cc9701ac9e1b1d21c31968d682cfa898ea736 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Tue, 5 Oct 2021 23:58:56 -0700 Subject: [PATCH 05/31] Fix error. --- index.bs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/index.bs b/index.bs index ac5534a..432a1bc 100644 --- a/index.bs +++ b/index.bs @@ -623,11 +623,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;


 			const format1 = 'text/plain';
-			const format2 = 'text/html';
 			const promise_text_blob = Promise.resolve(new Blob(['hello'], {type: format1}));
-			const promise_html_blob = Promise.resolve(new Blob(['

Test

'], {type: format2})); const clipboardItemInput = new ClipboardItem( - {[format1]: promise_text_blob, [format2]: promise_html_blob}, + {[format1]: promise_text_blob}, {options: "unspecified"});
From 55548e6f82f5f344c44961ea9340fa72d6279a67 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Wed, 6 Oct 2021 00:05:08 -0700 Subject: [PATCH 06/31] Revert "Address comments." This reverts commit 8cd8570b84bb283aaa4e4a9a31ca6f7f35b67c06. --- index.bs | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/index.bs b/index.bs index 432a1bc..c481cca 100644 --- a/index.bs +++ b/index.bs @@ -562,7 +562,6 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

clipboard

The [=clipboard=] attribute must return the {{Navigator}}'s [=clipboard=] object. - The [=clipboard=] attribute is used to execute read/write operation from/to the [=system clipboard=].
@@ -643,12 +642,18 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; ClipboardItemDataType

- A {{DOMString}} or [=Blob=] type. This contains the payload corresponding to the MIME type while creating a {{ClipboardItem}} object. + Returns a {{DOMString}} or [=Blob=] type.

ClipboardItemData

- A [=Promise=] to the [=ClipboardItemDataType=]. + Returns a [=Promise=] to the [=ClipboardItemDataType=]. +

+ + {{ClipboardItem}} +

A {{ClipboardItem}} object contains the {{ClipboardItem/types}} listed in the [=mandatory data types=] list that are present on the [=system clipboard=]. +

The {{ClipboardItem/constructor()}} step for new ClipboardItem(items, options) + is to set [=this=]'s items to items and options to options

Issue: Add definition to clarify what {{ClipboardItem/createDelayed()}} method does. From the discussions it looks like a Windows/Mac only feature where the @@ -656,7 +661,8 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; See https://docs.microsoft.com/en-us/windows/win32/dataxchg/clipboard-operations#delayed-rendering presentationStyle -

It is an enumerated attribute whose keywords are the string, unspecified, inline and attachment.

+

It is an enumerated attribute whose keywords are the string, unspecified, inline and attachment. + The IDL attribute must [=reflect=] the respective content attributes of the same name.

{{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s {{ClipboardItem/presentationStyle}}

@@ -678,6 +684,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Resolve |p| with |data|. +

read()

The {{Clipboard/read()}} method must run these steps: @@ -694,10 +701,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException 1. Let |data| be a copy of the [=system clipboard data=] represented as - a sequence of {{ClipboardItem}}s. 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. - - Note: Currently in Chromium, only a single {{ClipboardItem}} object is supported for reading and writing via [=clipboard=] object. + a sequence of {{ClipboardItem}}s. 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. @@ -762,20 +766,11 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException - 1. Let |itemList| and |cleanItemList| be an empty sequence<{{Blob}}>. - - 1. For each |item| in |data|: - 1. If [=Promise=] to {{Blob}} in |item| is rejected, then throw "Promises to Blobs were rejected." DOMException. - - 1. Add the {{Blob}} in |item| to |itemList| after the promise has been resolved. - - 1. For each {{Blob}} |itemBlob| in |itemList|: - - 1. If {{Blob/type}} is not in the [=mandatory data types=] list, then reject |p| with a "Type {{Blob/type}} not supported on write." DOMException. + 1. Let |cleanItemList| be an empty sequence<{{Blob}}>. - 1. Let |cleanItem| be a sanitized copy of |itemBlob|. + 1. For each {{Blob}} |item| in |data|: - Issue: Add definition of sanitized copy. + 1. Let |cleanItem| be a sanitized copy of |item|. 1. If unable to create a sanitized copy, then reject |p|. @@ -790,7 +785,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
-				var data = [new ClipboardItem({ "text/plain": Promise.resolve(new Blob(["Text data"], { type: "text/plain" }) }))];
+				var data = [new ClipboardItem({ "text/plain": new Blob(["Text data"], { type: "text/plain" }) })];
 				navigator.clipboard.write(data).then(function() {
 					console.log("Copied to clipboard successfully!");
 				}, function() {

From 3bb6d2809c6e46975456867a31d02804389324fa Mon Sep 17 00:00:00 2001
From: Anupam Snigdha 
Date: Wed, 6 Oct 2021 00:14:31 -0700
Subject: [PATCH 07/31] Address comments.

---
 index.bs | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/index.bs b/index.bs
index c481cca..864feae 100644
--- a/index.bs
+++ b/index.bs
@@ -562,6 +562,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
 		

clipboard

The [=clipboard=] attribute must return the {{Navigator}}'s [=clipboard=] object. + It is used to execute read/write operation from/to the [=system clipboard=].
@@ -642,12 +643,12 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; ClipboardItemDataType

- Returns a {{DOMString}} or [=Blob=] type. + A {{DOMString}} or [=Blob=] type. This contains the payload corresponding to the MIME type while creating a {{ClipboardItem}} object.

ClipboardItemData

- Returns a [=Promise=] to the [=ClipboardItemDataType=]. + A [=Promise=] to the [=ClipboardItemDataType=].

{{ClipboardItem}} @@ -661,8 +662,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; See https://docs.microsoft.com/en-us/windows/win32/dataxchg/clipboard-operations#delayed-rendering presentationStyle -

It is an enumerated attribute whose keywords are the string, unspecified, inline and attachment. - The IDL attribute must [=reflect=] the respective content attributes of the same name.

+

It is an enumerated attribute whose keywords are the string, unspecified, inline and attachment.

{{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s {{ClipboardItem/presentationStyle}}

@@ -701,7 +701,10 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException 1. Let |data| be a copy of the [=system clipboard data=] represented as - a sequence of {{ClipboardItem}}s. + a sequence of {{ClipboardItem}}s. 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. + + Note: Currently in Chromium, only a single {{ClipboardItem}} object is supported for reading and writing via [=clipboard=] object. 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. @@ -766,11 +769,20 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException - 1. Let |cleanItemList| be an empty sequence<{{Blob}}>. + 1. Let |itemList| and |cleanItemList| be an empty sequence<{{Blob}}>. + + 1. For each |item| in |data|: + 1. If [=Promise=] to {{Blob}} in |item| is rejected, then throw "Promises to Blobs were rejected." DOMException. + + 1. Add the {{Blob}} in |item| to |itemList| after the promise has been resolved. + + 1. For each {{Blob}} |itemBlob| in |itemList|: + + 1. If {{Blob/type}} is not in the [=mandatory data types=] list, then reject |p| with a "Type {{Blob/type}} not supported on write." DOMException. - 1. For each {{Blob}} |item| in |data|: + 1. Let |cleanItem| be a sanitized copy of |itemBlob|. - 1. Let |cleanItem| be a sanitized copy of |item|. + Issue: Add definition of sanitized copy. 1. If unable to create a sanitized copy, then reject |p|. @@ -785,7 +797,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
-				var data = [new ClipboardItem({ "text/plain": new Blob(["Text data"], { type: "text/plain" }) })];
+				var data = [new ClipboardItem({ "text/plain": Promise.resolve(new Blob(["Text data"], { type: "text/plain" }) }))];
 				navigator.clipboard.write(data).then(function() {
 					console.log("Copied to clipboard successfully!");
 				}, function() {

From eadb6dfb002ead76169dbc11fae95c98fb8216ea Mon Sep 17 00:00:00 2001
From: Anupam Snigdha 
Date: Wed, 13 Oct 2021 18:39:06 -0700
Subject: [PATCH 08/31] Address comments.

---
 index.bs | 178 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 90 insertions(+), 88 deletions(-)

diff --git a/index.bs b/index.bs
index 864feae..be28b82 100644
--- a/index.bs
+++ b/index.bs
@@ -168,7 +168,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
 		exposed as a {{DataTransfer}} object that mirrors the contents of the clipboard.
 
 	* For the [[#async-clipboard-api]], the [=system clipboard data=] is
-		exposed as a sequence of {{ClipboardItem}} objects that mirrors the contents of
+		exposed as a sequence of [=ClipboardItem=] objects that mirrors the contents of
 		the clipboard.
 
 

Clipboard Events

@@ -562,107 +562,82 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

clipboard

The [=clipboard=] attribute must return the {{Navigator}}'s [=clipboard=] object. - It is used to execute read/write operation from/to the [=system clipboard=]. + It is used to execute read/write operations from/to the [=system clipboard=].
-

Clipboard Interface

- +

ClipboardItem Interface

-		typedef sequence<ClipboardItem> ClipboardItems;
+			typedef (DOMString or Blob) ClipboardItemDataType;
+			typedef Promise<ClipboardItemDataType> ClipboardItemData;
 
-		[SecureContext, Exposed=Window] interface Clipboard : EventTarget {
-		  Promise<ClipboardItems> read();
-		  Promise<DOMString> readText();
-		  Promise<undefined> write(ClipboardItems data);
-		  Promise<undefined> writeText(DOMString data);
-		};
-
-		typedef (DOMString or Blob) ClipboardItemDataType;
-		typedef Promise<ClipboardItemDataType> ClipboardItemData;
+			callback ClipboardItemDelayedCallback = ClipboardItemData ();
 
-		callback ClipboardItemDelayedCallback = ClipboardItemData ();
+			[SecureContext, Exposed=Window] interface ClipboardItem {
+			constructor(record<DOMString, ClipboardItemData> items,
+				optional ClipboardItemOptions options = {});
+			static ClipboardItem createDelayed(
+				record<DOMString, ClipboardItemDelayedCallback> items,
+				optional ClipboardItemOptions options = {});
 
-		[Exposed=Window] interface ClipboardItem {
-		  constructor(record<DOMString, ClipboardItemData> items,
-		    optional ClipboardItemOptions options = {});
-		  static ClipboardItem createDelayed(
-		      record<DOMString, ClipboardItemDelayedCallback> items,
-		      optional ClipboardItemOptions options = {});
+			readonly attribute PresentationStyle presentationStyle;
+			readonly attribute long long lastModified;
+			readonly attribute boolean delayed;
 
-		  readonly attribute PresentationStyle presentationStyle;
-		  readonly attribute long long lastModified;
-		  readonly attribute boolean delayed;
+			readonly attribute FrozenArray<DOMString> types;
 
-		  readonly attribute FrozenArray<DOMString> types;
-
-		  Promise<Blob> getType(DOMString type);
-		};
+			Promise<Blob> getType(DOMString type);
+			};
 
-		enum PresentationStyle { "unspecified", "inline", "attachment" };
+			enum PresentationStyle { "unspecified", "inline", "attachment" };
 
-		dictionary ClipboardItemOptions {
-		  PresentationStyle presentationStyle = "unspecified";
-		};
+			dictionary ClipboardItemOptions {
+			PresentationStyle presentationStyle = "unspecified";
+			};
 		
- -
-

ClipboardItem

- The [=ClipboardItem=] object represents the content of the MIME types that are in the [=mandatory data types=] list, and are currently on the [=system clipboard=]. - It has a mapping of the MIME types in {{DOMString}} format and a [=Blob=] corresponding to the MIME types that contains the actual payload. A web author needs to - create a [=ClipboardItem=] object in order to write content to the clipboard using the {{Clipboard/write()}} method. {{Clipboard/read()}} returns a [=ClipboardItem=] object - that can be used to read a specific |type| using {{ClipboardItem/getType()}}. -
+

ClipboardItem

+ The [=ClipboardItem=] object has MIME types that are in the {{ClipboardItem/types}} list, and [=Blob=]s corresponding to the {{ClipboardItem/types}}. + It has a mapping of the MIME types in {{DOMString}} format and a [=Blob=] corresponding to the MIME types that contains the actual payload. + There can be multiple [=ClipboardItem=]s as each [=ClipboardItem=] represents contents of a clipboard, and there can be multiple clipboards supported on a platform such as iOS/iPadOS. + A web author needs to create a |data| which is a [=ClipboardItems=] object in order to write content to multiple clipboards using the {{Clipboard/write(data)}} method. {{Clipboard/read()}} returns a [=Promise=] to [=ClipboardItems=] object + that represents contents of multiple clipboards. A [=ClipboardItem=] can be read from [=ClipboardItems=], which then can be used to read a specific |type| using {{ClipboardItem/getType(type)}}.
-
clipboardItem = new ClipboardItem([items, options]) +
clipboardItem = new ClipboardItem([items, options])
- Creates a new {{ClipboardItem}} object. items are used to fill its MIME types and [=Promise=]s to [=Blob=]s corresponding to the MIME types, options can be used to fill its {{ClipboardItemOptions}}, + Creates a new [=ClipboardItem=] object. items are used to fill its MIME types and [=Promise=]s to [=Blob=]s corresponding to the MIME types, options can be used to fill its {{ClipboardItemOptions}}, as per the example below. -
-

+			
 			const format1 = 'text/plain';
 			const promise_text_blob = Promise.resolve(new Blob(['hello'], {type: format1}));
 			const clipboardItemInput = new ClipboardItem(
 				{[format1]: promise_text_blob},
 				{options: "unspecified"});
-			
-
+ -
clipboardItem . getType(type) +
clipboardItem.getType(type)

Returns a [=Promise=] to the [=Blob=] corresponding to the type.

-
types of clipboardItem +
clipboardItem.types

Returns the list of types contained in the clipboardItem object.

- The {{ClipboardItem/constructor()}} step for new ClipboardItem(items, options) is to set [=this=]'s items to items and options to options -

- - ClipboardItemDataType -

- A {{DOMString}} or [=Blob=] type. This contains the payload corresponding to the MIME type while creating a {{ClipboardItem}} object. -

- - ClipboardItemData -

- A [=Promise=] to the [=ClipboardItemDataType=]. -

- - {{ClipboardItem}} -

A {{ClipboardItem}} object contains the {{ClipboardItem/types}} listed in the [=mandatory data types=] list that are present on the [=system clipboard=]. -

The {{ClipboardItem/constructor()}} step for new ClipboardItem(items, options) - is to set [=this=]'s items to items and options to options + The ClipboardItem step for new ClipboardItem(items, options) is to set [=this=]'s items to items and options to options

Issue: Add definition to clarify what {{ClipboardItem/createDelayed()}} method does. From the discussions it looks like a Windows/Mac only feature where the platform supports writing of the data to the system clipboard in a delayed fashion so the system clipboard can request data on-demand. See https://docs.microsoft.com/en-us/windows/win32/dataxchg/clipboard-operations#delayed-rendering - presentationStyle -

It is an enumerated attribute whose keywords are the string, unspecified, inline and attachment.

+

presentationStyle

+

It is an enumerated attribute whose keywords are the string, unspecified, inline and attachment. + + Note: {{ClipboardItem/presentationStyle}} helps distinguish between "inline" data(e.g. selecting text on a web page and copying), vs. file-like data (e.g. copying a plain text file). + This difference is used to provide a hint when writing to the system pasteboard on iOS/iPadOS. This allows apps like Notes to insert a file attachment when copying a plain text file from the Files app, but insert text inline when + copying a selected piece of plain text from another app. In both cases, the MIME type in the pasteboard would be text/plain. This is used for both reading and writing. +

{{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s {{ClipboardItem/presentationStyle}}

@@ -670,11 +645,11 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; Issue: Delay rendering support has not been added to Chromium and Safari so {{ClipboardItem/delayed}} is unused. - types -

Returns {{ClipboardItem/types}} listed in the [=mandatory data types=] list that are present on the [=system clipboard=]. +

types

+

Returns the MIME types used to create the [=ClipboardItem=] object.

+

{{ClipboardItem/types}} getter steps are to return [=this=]'s {{ClipboardItem/types}}

- getType({{DOMString}} type) -

The {{ClipboardItem/getType()}} must run the below steps:

+

getType(type) must run the below steps:

1. Let |p| be a new [=Promise=]. @@ -682,7 +657,34 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |data| be the result of reading the |type| from the [=system clipboard=]. - 1. Resolve |p| with |data|. + 1. Let |blobData| be the |data| represented as a [=Blob=]. + + 1. Resolve |p| with |blobData|. + +

ClipboardItemDataType

+

+ It is a {{DOMString}} or [=Blob=] type. This contains the payload corresponding to the MIME type while creating a [=ClipboardItem=] object. +

+

ClipboardItemData

+

+ It is a [=Promise=] to the {{ClipboardItemDataType}}. +

+ +

Clipboard Interface

+ +
+		typedef sequence<ClipboardItem> ClipboardItems;
+
+		[SecureContext, Exposed=Window] interface Clipboard : EventTarget {
+		  Promise<ClipboardItems> read();
+		  Promise<DOMString> readText();
+		  Promise<undefined> write(ClipboardItems data);
+		  Promise<undefined> writeText(DOMString data);
+		};
+		
+ +

ClipboardItems

+

A sequence of [=ClipboardItem=] objects

@@ -700,11 +702,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException - 1. Let |data| be a copy of the [=system clipboard data=] represented as - a sequence of {{ClipboardItem}}s. 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 [=ClipboardItems=]. 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. - Note: Currently in Chromium, only a single {{ClipboardItem}} object is supported for reading and writing via [=clipboard=] object. + Note: Currently in Chromium, only one [=ClipboardItem=] object is supported for reading and writing via [=clipboard=] object. 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. @@ -771,24 +771,26 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |itemList| and |cleanItemList| be an empty sequence<{{Blob}}>. - 1. For each |item| in |data|: - 1. If [=Promise=] to {{Blob}} in |item| is rejected, then throw "Promises to Blobs were rejected." DOMException. + 1. For each |itemData| in |data|: + + 1. For each |item| in |itemData|: + 1. If [=Promise=] to {{Blob}} in |item| is rejected, then throw "Promises to Blobs were rejected." DOMException. - 1. Add the {{Blob}} in |item| to |itemList| after the promise has been resolved. + 1. Add the {{Blob}} in |item| to |itemList| after the promise has been resolved. - 1. For each {{Blob}} |itemBlob| in |itemList|: + 1. For each {{Blob}} |itemBlob| in |itemList|: - 1. If {{Blob/type}} is not in the [=mandatory data types=] list, then reject |p| with a "Type {{Blob/type}} not supported on write." DOMException. + 1. If {{Blob/type}} is not in the [=mandatory data types=] list, then reject |p| with a "Type {{Blob/type}} not supported on write." DOMException. - 1. Let |cleanItem| be a sanitized copy of |itemBlob|. + 1. Let |cleanItem| be a sanitized copy of |itemBlob|. - Issue: Add definition of sanitized copy. + Issue: Add definition of sanitized copy. - 1. If unable to create a sanitized copy, then reject |p|. + 1. If unable to create a sanitized copy, then reject |p|. - 1. Add |cleanItem| to |cleanItemList|. + 1. Add |cleanItem| to |cleanItemList|. - 1. Replace the [=system clipboard data=] with |cleanItemList|. + 1. Replace the [=system clipboard data=] with |cleanItemList|. 1. Resolve |p|. @@ -819,13 +821,13 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException - 1. Let |newItemList| be an empty sequence<{{ClipboardItem}}>. + 1. Let |newItemList| be empty [=ClipboardItems=]. 1. Let |textBlob| be a new {{Blob}} created with: [=type=] attribute set to text/plain;charset=utf-8, and [=blobParts=] set to a sequence containing the string |data|. - 1. Let |newItem| be a new {{ClipboardItem}} created with a single + 1. Let |newItem| be a new [=ClipboardItem=] created with a single representation: [=type=] attribute set to text/plain8, and [=data=] set to |textBlob|. From c77e6caf7c0ef959ae75f66e0cca0571c6db5ee0 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Mon, 1 Nov 2021 19:00:15 -0700 Subject: [PATCH 09/31] Addressed review comments. --- index.bs | 99 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 39 deletions(-) diff --git a/index.bs b/index.bs index be28b82..bfd841b 100644 --- a/index.bs +++ b/index.bs @@ -570,24 +570,18 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

ClipboardItem Interface

 			typedef (DOMString or Blob) ClipboardItemDataType;
-			typedef Promise<ClipboardItemDataType> ClipboardItemData;
+			typedef Promise<ClipboardItemDataType> ClipboardItemData;
 
 			callback ClipboardItemDelayedCallback = ClipboardItemData ();
 
 			[SecureContext, Exposed=Window] interface ClipboardItem {
 			constructor(record<DOMString, ClipboardItemData> items,
 				optional ClipboardItemOptions options = {});
-			static ClipboardItem createDelayed(
-				record<DOMString, ClipboardItemDelayedCallback> items,
-				optional ClipboardItemOptions options = {});
 
 			readonly attribute PresentationStyle presentationStyle;
-			readonly attribute long long lastModified;
-			readonly attribute boolean delayed;
-
 			readonly attribute FrozenArray<DOMString> types;
 
-			Promise<Blob> getType(DOMString type);
+			Promise<Blob> getType(DOMString type);
 			};
 
 			enum PresentationStyle { "unspecified", "inline", "attachment" };
@@ -597,11 +591,21 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
 			};
 		

ClipboardItem

- The [=ClipboardItem=] object has MIME types that are in the {{ClipboardItem/types}} list, and [=Blob=]s corresponding to the {{ClipboardItem/types}}. - It has a mapping of the MIME types in {{DOMString}} format and a [=Blob=] corresponding to the MIME types that contains the actual payload. - There can be multiple [=ClipboardItem=]s as each [=ClipboardItem=] represents contents of a clipboard, and there can be multiple clipboards supported on a platform such as iOS/iPadOS. - A web author needs to create a |data| which is a [=ClipboardItems=] object in order to write content to multiple clipboards using the {{Clipboard/write(data)}} method. {{Clipboard/read()}} returns a [=Promise=] to [=ClipboardItems=] object - that represents contents of multiple clipboards. A [=ClipboardItem=] can be read from [=ClipboardItems=], which then can be used to read a specific |type| using {{ClipboardItem/getType(type)}}. + A [=ClipboardItem=] is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or "copy" command. + For example, if a user copies a range of cells from a spreadsheet, it will result in one [=ClipboardItem=]. If a user copies a set of files from their desktop, that list of files will be a different single [=ClipboardItem=]. + Some platforms may support having more than one [=ClipboardItem=] at a time on the [=Clipboard=], while other platforms replace the previous [=ClipboardItem=] with the new one. + + Each [=ClipboardItem=] can be represented as multiple mime-types. In the example where the user copies a range of cells from a spreadsheet, it may be represented as an image (image/png), an HTML table (text/html), or plain text (text/plain). + Each of these mime-types describe the same [=ClipboardItem=] at different levels of fidelity and make the [=ClipboardItem=] more consumable by target applications during paste. + Making the range of cells available as an image will allow the user to paste the cells into Photoshop, while the text/plain format can be used by applications like Windows Notepad. + + Apps that support pasting only a single [=ClipboardItem=] should use the first [=ClipboardItem=]. + Apps that support pasting more than one [=ClipboardItem=] could, for example, provide a user interface that previews the contents of each [=ClipboardItem=] and allow the user to choose which one to paste. + Further, apps are expected to enumerate the mime-types of the [=ClipboardItem=] 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 [=ClipboardItem=], e.g. “paste as image” or “paste formatted text”, etc. + + A [=ClipboardItem=] contains multiple representations. Each representation consists of a MIME type and a corresponding {{DOMString}} or [=Blob=]. +
clipboardItem = new ClipboardItem([items, options])
@@ -617,7 +621,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
clipboardItem.getType(type) -

Returns a [=Promise=] to the [=Blob=] corresponding to the type.

+

Returns a [=Promise=] to the [=Blob=] corresponding to type.

clipboardItem.types

Returns the list of types contained in the clipboardItem object. @@ -627,10 +631,6 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; The ClipboardItem step for new ClipboardItem(items, options) is to set [=this=]'s items to items and options to options

- Issue: Add definition to clarify what {{ClipboardItem/createDelayed()}} method does. From the discussions it looks like a Windows/Mac only feature where the - platform supports writing of the data to the system clipboard in a delayed fashion so the system clipboard can request data on-demand. - See https://docs.microsoft.com/en-us/windows/win32/dataxchg/clipboard-operations#delayed-rendering -

presentationStyle

It is an enumerated attribute whose keywords are the string, unspecified, inline and attachment. @@ -641,10 +641,6 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

{{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s {{ClipboardItem/presentationStyle}}

- Issue: Currently {{ClipboardItem/lastModified}} is not supported in Chromium and Safari, Should we remove it? - - Issue: Delay rendering support has not been added to Chromium and Safari so {{ClipboardItem/delayed}} is unused. -

types

Returns the MIME types used to create the [=ClipboardItem=] object.

{{ClipboardItem/types}} getter steps are to return [=this=]'s {{ClipboardItem/types}}

@@ -655,9 +651,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |type| is not listed in the [=mandatory data types=] list, then reject |p| with a "The type was not found" DOMException. - 1. Let |data| be the result of reading the |type| from the [=system clipboard=]. - - 1. Let |blobData| be the |data| represented as a [=Blob=]. + 1. Let |blobData| be a [=Blob=] corresponding to the |type|. 1. Resolve |p| with |blobData|. @@ -667,22 +661,27 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

ClipboardItemData

- It is a [=Promise=] to the {{ClipboardItemDataType}}. + A [=Promise=] to a {{ClipboardItemDataType}}.

Clipboard Interface

-		typedef sequence<ClipboardItem> ClipboardItems;
+		typedef sequence<ClipboardItem> ClipboardItems;
 
 		[SecureContext, Exposed=Window] interface Clipboard : EventTarget {
-		  Promise<ClipboardItems> read();
-		  Promise<DOMString> readText();
-		  Promise<undefined> write(ClipboardItems data);
-		  Promise<undefined> writeText(DOMString data);
+		  Promise<ClipboardItems> read();
+		  Promise<DOMString> readText();
+		  Promise<undefined> write(ClipboardItems data);
+		  Promise<undefined> writeText(DOMString data);
 		};
 		
+ A [=Clipboard=] may contain one or more [=ClipboardItem=]s. Multiple [=ClipboardItem=]s are only supported on platforms such as iOS/iPadOS. + A web author needs to create a |data| which is a [=ClipboardItems=] object in order to write content to clipboard using the {{Clipboard/write(data)}} method. + {{Clipboard/read()}} returns a [=Promise=] to [=ClipboardItems=] object that represents contents of clipboard. + A [=ClipboardItem=] can be read from [=ClipboardItems=], which then can be used to read a specific |type| using {{ClipboardItem/getType(type)}}. +

ClipboardItems

A sequence of [=ClipboardItem=] objects

@@ -696,6 +695,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Run the following steps [=in parallel=]: 1. Let |r| be the result of running [=check clipboard read permission=] [=in parallel=] + Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. @@ -704,7 +704,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |data| be a copy of the [=system clipboard data=] represented as [=ClipboardItems=]. 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. - Note: Currently in Chromium, only one [=ClipboardItem=] object is supported for reading and writing via [=clipboard=] object. + Note: Currently in Chromium, only one [=ClipboardItem=] object is supported for reading and writing via the [=clipboard=] object. 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. @@ -733,6 +733,10 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |r| be the result of running [=check clipboard read permission=] [=in parallel=] + Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside + a user gesture event and the user must select the paste option from the native context menu that pops up + when read() is called from JS, otherwise, the promise will be rejected. + 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException 1. Let |data| be a copy of the [=system clipboard data=]. @@ -767,30 +771,43 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |r| be the result of running [=check clipboard write permission=] [=in parallel=] + Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside + a user gesture event and the user must select the paste option from the native context menu that pops up + when read() is called from JS, otherwise, the promise will be rejected. + 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException - 1. Let |itemList| and |cleanItemList| be an empty sequence<{{Blob}}>. + 1. Let |itemList| and |cleanItemList| be an empty sequence<{{Blob}}>. + + 1. Let |clipboardItemList| be an empty [=ClipboardItems=]. - 1. For each |itemData| in |data|: + 1. For each |clipboardItem| in |data|: - 1. For each |item| in |itemData|: + 1. For each |item| in |clipboardItem|: 1. If [=Promise=] to {{Blob}} in |item| is rejected, then throw "Promises to Blobs were rejected." DOMException. 1. Add the {{Blob}} in |item| to |itemList| after the promise has been resolved. - 1. For each {{Blob}} |itemBlob| in |itemList|: + 1. For each {{Blob}} |blob| in |itemList|: - 1. If {{Blob/type}} is not in the [=mandatory data types=] list, then reject |p| with a "Type {{Blob/type}} not supported on write." DOMException. + 1. Let |type| be the |blob|'s {{Blob/type}}. - 1. Let |cleanItem| be a sanitized copy of |itemBlob|. + 1. If |type| is not in the [=mandatory data types=] list, then reject |p| with a "Type |type| not supported on write." DOMException. + + 1. Let |cleanItem| be a sanitized copy of |blob|. Issue: Add definition of sanitized copy. 1. If unable to create a sanitized copy, then reject |p|. 1. Add |cleanItem| to |cleanItemList|. + + 1. Add |cleanItemList| to |clipboardItemList|. - 1. Replace the [=system clipboard data=] with |cleanItemList|. + 1. Replace the [=system clipboard data=] with |clipboardItemList|. + + Note: Writing multiple [=ClipboardItem=]s to the clipboard is only supported on MacOS. + For other platforms, only the first [=ClipboardItem=] should be written to the clipboard. 1. Resolve |p|. @@ -819,6 +836,10 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |r| be the result of running [=check clipboard write permission=] [=in parallel=] + Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside + a user gesture event and the user must select the paste option from the native context menu that pops up + when read() is called from JS, otherwise, the promise will be rejected. + 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException 1. Let |newItemList| be empty [=ClipboardItems=]. From 713cf1e8a7958412c1a3cfeab5c99c396dc8aab1 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Tue, 2 Nov 2021 18:42:57 -0700 Subject: [PATCH 10/31] Address review comments. --- index.bs | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/index.bs b/index.bs index bfd841b..e740447 100644 --- a/index.bs +++ b/index.bs @@ -647,14 +647,18 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

getType(type) must run the below steps:

- 1. Let |p| be a new [=Promise=]. + 1. Let |realm| be [=this=]'s [=relevant realm=]. - 1. If |type| is not listed in the [=mandatory data types=] list, then reject |p| with a "The type was not found" DOMException. + 1. If |type| is not listed in the [=mandatory data types=] list, then [=a promise rejected with=] "The type was not found" DOMException in |realm|. + + 1. Let |p| be [=a new promise=] in |realm|. 1. Let |blobData| be a [=Blob=] corresponding to the |type|. 1. Resolve |p| with |blobData|. + 1. Return |p|. +

ClipboardItemDataType

It is a {{DOMString}} or [=Blob=] type. This contains the payload corresponding to the MIME type while creating a [=ClipboardItem=] object. @@ -690,7 +694,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

read()

The {{Clipboard/read()}} method must run these steps: - 1. Let |p| be a new [=Promise=]. + 1. Let |realm| be [=this=]'s [=relevant realm=]. + + 1. Let |p| be [=a new promise=] in |realm|. 1. Run the following steps [=in parallel=]: @@ -700,7 +706,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException + 1. If |r| is not "granted", then [=a promise rejected with=] "NotAllowedError" DOMException in |realm|. 1. Let |data| be a copy of the [=system clipboard data=] represented as [=ClipboardItems=]. 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. @@ -727,7 +733,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

readText()

The {{Clipboard/readText()}} method must run these steps: - 1. Let |p| be a new [=Promise=]. + 1. Let |realm| be [=this=]'s [=relevant realm=]. + + 1. Let |p| be [=a new promise=] in |realm|. 1. Run the following steps [=in parallel=]: @@ -737,7 +745,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException + 1. If |r| is not "granted", then [=a promise rejected with=] "NotAllowedError" DOMException in |realm|. 1. Let |data| be a copy of the [=system clipboard data=]. @@ -765,7 +773,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

write(|data|)

The {{Clipboard/write(data)}} method must run these steps: - 1. Let |p| be a new [=Promise=]. + 1. Let |realm| be [=this=]'s [=relevant realm=]. + + 1. Let |p| be [=a new promise=] in |realm|. 1. Run the following steps [=in parallel=]: @@ -775,7 +785,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException + 1. If |r| is not "granted", then [=a promise rejected with=] "NotAllowedError" DOMException in |realm|. 1. Let |itemList| and |cleanItemList| be an empty sequence<{{Blob}}>. @@ -784,21 +794,24 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. For each |clipboardItem| in |data|: 1. For each |item| in |clipboardItem|: - 1. If [=Promise=] to {{Blob}} in |item| is rejected, then throw "Promises to Blobs were rejected." DOMException. - 1. Add the {{Blob}} in |item| to |itemList| after the promise has been resolved. + 1. Let |p1| be [=a new promise=] to {{Blob}} in |realm|. + + 1. If |p1| is [=reject=]d, then throw "Promises to Blobs were rejected." DOMException in |realm|. + + 1. Add the {{Blob}} in |item| to |itemList| after |p1| has been resolved. 1. For each {{Blob}} |blob| in |itemList|: 1. Let |type| be the |blob|'s {{Blob/type}}. - 1. If |type| is not in the [=mandatory data types=] list, then reject |p| with a "Type |type| not supported on write." DOMException. + 1. If |type| is not in the [=mandatory data types=] list, then [=a promise rejected with=] "Type |type| not supported on write." DOMException in |realm|. 1. Let |cleanItem| be a sanitized copy of |blob|. Issue: Add definition of sanitized copy. - 1. If unable to create a sanitized copy, then reject |p|. + 1. If unable to create a sanitized copy, then [=reject=] |p|. 1. Add |cleanItem| to |cleanItemList|. @@ -830,7 +843,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

writeText(|data|)

The {{Clipboard/writeText(data)}} method must run these steps: - 1. Let |p| be a new [=Promise=]. + 1. Let |realm| be [=this=]'s [=relevant realm=]. + + 1. Let |p| be [=a new promise=] in |realm|. 1. Run the following steps [=in parallel=]: @@ -840,7 +855,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException + 1. If |r| is not "granted", then [=a promise rejected with=] "NotAllowedError" DOMException in |realm|. 1. Let |newItemList| be empty [=ClipboardItems=]. From 2249e8babeda5f9c3815003bfe60f53920b80b7f Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Wed, 3 Nov 2021 16:25:50 -0700 Subject: [PATCH 11/31] Add conversion of DOMString to Blob type. --- index.bs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.bs b/index.bs index e740447..9f96360 100644 --- a/index.bs +++ b/index.bs @@ -799,7 +799,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |p1| is [=reject=]d, then throw "Promises to Blobs were rejected." DOMException in |realm|. - 1. Add the {{Blob}} in |item| to |itemList| after |p1| has been resolved. + 1. If |item| is a {{DOMString}}, then convert it into {{Blob}} and add it to |itemList|. + + 1. If |item| is a {{Blob}}, then add the {{Blob}} in |item| to |itemList| after |p1| has been resolved. 1. For each {{Blob}} |blob| in |itemList|: From 3065ce8e2296fb429409bf21687cd60a4dd0aef2 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Thu, 4 Nov 2021 17:28:04 -0700 Subject: [PATCH 12/31] Address PR comments. --- index.bs | 125 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 70 insertions(+), 55 deletions(-) diff --git a/index.bs b/index.bs index 9f96360..8c7509f 100644 --- a/index.bs +++ b/index.bs @@ -168,7 +168,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; exposed as a {{DataTransfer}} object that mirrors the contents of the clipboard. * For the [[#async-clipboard-api]], the [=system clipboard data=] is - exposed as a sequence of [=ClipboardItem=] objects that mirrors the contents of + exposed as a sequence of [=clipboard item=] objects that mirrors the contents of the clipboard.

Clipboard Events

@@ -574,51 +574,60 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; callback ClipboardItemDelayedCallback = ClipboardItemData (); - [SecureContext, Exposed=Window] interface ClipboardItem { - constructor(record<DOMString, ClipboardItemData> items, - optional ClipboardItemOptions options = {}); + [SecureContext, Exposed=Window] + interface ClipboardItem { + constructor(record<DOMString, ClipboardItemData> items, + optional ClipboardItemOptions options = {}); - readonly attribute PresentationStyle presentationStyle; - readonly attribute FrozenArray<DOMString> types; + readonly attribute PresentationStyle presentationStyle; + readonly attribute FrozenArray<DOMString> types; - Promise<Blob> getType(DOMString type); + Promise<Blob> getType(DOMString type); }; enum PresentationStyle { "unspecified", "inline", "attachment" }; dictionary ClipboardItemOptions { - PresentationStyle presentationStyle = "unspecified"; + PresentationStyle presentationStyle = "unspecified"; }; -

ClipboardItem

- A [=ClipboardItem=] is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or "copy" command. - For example, if a user copies a range of cells from a spreadsheet, it will result in one [=ClipboardItem=]. If a user copies a set of files from their desktop, that list of files will be a different single [=ClipboardItem=]. - Some platforms may support having more than one [=ClipboardItem=] at a time on the [=Clipboard=], while other platforms replace the previous [=ClipboardItem=] with the new one. +

Clipboard Item

+ A [=clipboard item=] is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or "copy" command. + For example, if a user copies a range of cells from a spreadsheet, it will result in one [=clipboard item=]. If a user copies a set of files from their desktop, that list of files will be a different single [=clipboard item=]. + Some platforms may support having more than one [=clipboard item=] at a time on the [=Clipboard=], while other platforms replace the previous [=clipboard item=] with the new one. - Each [=ClipboardItem=] can be represented as multiple mime-types. In the example where the user copies a range of cells from a spreadsheet, it may be represented as an image (image/png), an HTML table (text/html), or plain text (text/plain). - Each of these mime-types describe the same [=ClipboardItem=] at different levels of fidelity and make the [=ClipboardItem=] more consumable by target applications during paste. + Each [=clipboard item=] can be represented as multiple mime-types. In the example where the user copies a range of cells from a spreadsheet, it may be represented as an image (image/png), an HTML table (text/html), or plain text (text/plain). + Each of these mime-types describe the same [=clipboard item=] at different levels of fidelity and make the [=clipboard item=] more consumable by target applications during paste. Making the range of cells available as an image will allow the user to paste the cells into Photoshop, while the text/plain format can be used by applications like Windows Notepad. - Apps that support pasting only a single [=ClipboardItem=] should use the first [=ClipboardItem=]. - Apps that support pasting more than one [=ClipboardItem=] could, for example, provide a user interface that previews the contents of each [=ClipboardItem=] and allow the user to choose which one to paste. - Further, apps are expected to enumerate the mime-types of the [=ClipboardItem=] 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 [=ClipboardItem=], e.g. “paste as image” or “paste formatted text”, etc. + Apps that support pasting only a single [=clipboard item=] should use the first [=clipboard item=]. + Apps that support pasting more than one [=clipboard item=] could, for example, provide a user interface that previews the contents of each [=clipboard item=] and allow the user to choose which one to paste. + Further, apps are expected to enumerate the mime-types 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=] contains multiple representations. Each representation consists of a MIME type and a corresponding {{DOMString}} or [=Blob=]. + A [=clipboard item=] contains multiple representations. Each representation consists of a MIME type and a corresponding {{DOMString}} or [=Blob=]. + +

A [=clipboard item=] has an associated presentation style which is "unspecified" or "inline" or "attachment". + [=presentation style=] helps distinguish between "inline" data(e.g. selecting text on a web page and copying), vs. file-like data (e.g. copying a plain text file). + This difference is used to provide a hint when writing to the system pasteboard on iOS/iPadOS. This allows apps like Notes to insert a file attachment when copying a plain text file from the Files app, but insert text inline when + copying a selected piece of plain text from another app. In both cases, the MIME type in the pasteboard would be text/plain. This is used for both reading and writing. +

+ +

A [=clipboard item=] has an associated types which contains the MIME types.

clipboardItem = new ClipboardItem([items, options])
- Creates a new [=ClipboardItem=] object. items are used to fill its MIME types and [=Promise=]s to [=Blob=]s corresponding to the MIME types, options can be used to fill its {{ClipboardItemOptions}}, + Creates a new {{ClipboardItem}} object. items are used to fill its MIME types and [=Promise=]s to [=Blob=]s or {{DOMString}}s corresponding to the MIME types, options can be used to fill its {{ClipboardItemOptions}}, as per the example below. -
-			const format1 = 'text/plain';
-			const promise_text_blob = Promise.resolve(new Blob(['hello'], {type: format1}));
-			const clipboardItemInput = new ClipboardItem(
-				{[format1]: promise_text_blob},
-				{options: "unspecified"});
-			
+
+					const format1 = 'text/plain';
+					const promise_text_blob = Promise.resolve(new Blob(['hello'], {type: format1}));
+					const clipboardItemInput = new ClipboardItem(
+						{[format1]: promise_text_blob},
+						{options: "unspecified"});
+				
clipboardItem.getType(type)

Returns a [=Promise=] to the [=Blob=] corresponding to type.

@@ -628,22 +637,27 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

- The ClipboardItem step for new ClipboardItem(items, options) is to set [=this=]'s items to items and options to options + A {{ClipboardItem}} object has an associated [=clipboard item=]. +

+

+ A {{ClipboardItem}} object's {{ClipboardItem/presentationStyle}} is its [=clipboard item=]'s [=presentation style=]. +

+

+ A {{ClipboardItem}} object's {{ClipboardItem/types}} is its [=clipboard item=]'s [=types=]. +

+

+ The constructor steps for new ClipboardItem(items, options) are to set [=this=]'s items to items and options to options.

presentationStyle

-

It is an enumerated attribute whose keywords are the string, unspecified, inline and attachment. - - Note: {{ClipboardItem/presentationStyle}} helps distinguish between "inline" data(e.g. selecting text on a web page and copying), vs. file-like data (e.g. copying a plain text file). - This difference is used to provide a hint when writing to the system pasteboard on iOS/iPadOS. This allows apps like Notes to insert a file attachment when copying a plain text file from the Files app, but insert text inline when - copying a selected piece of plain text from another app. In both cases, the MIME type in the pasteboard would be text/plain. This is used for both reading and writing. +

+ Each {{ClipboardItem}} has a {{ClipboardItem/presentationStyle}}, which is a {{PresentationStyle}}. + The {{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s [=clipboard item=]'s [=presentation style=].

-

{{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s {{ClipboardItem/presentationStyle}}

-

types

-

Returns the MIME types used to create the [=ClipboardItem=] object.

-

{{ClipboardItem/types}} getter steps are to return [=this=]'s {{ClipboardItem/types}}

+

Each {{ClipboardItem}} has a {{ClipboardItem/types}}, which contains the MIME types. + {{ClipboardItem/types}} getter steps are to return [=this=]'s [=clipboard item=]'s [=types=].

getType(type) must run the below steps:

@@ -661,7 +675,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

ClipboardItemDataType

- It is a {{DOMString}} or [=Blob=] type. This contains the payload corresponding to the MIME type while creating a [=ClipboardItem=] object. + It is a {{DOMString}} or [=Blob=] type. This contains the payload corresponding to the MIME type while creating a [=clipboard item=] object.

ClipboardItemData

@@ -673,21 +687,22 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

 		typedef sequence<ClipboardItem> ClipboardItems;
 
-		[SecureContext, Exposed=Window] interface Clipboard : EventTarget {
-		  Promise<ClipboardItems> read();
-		  Promise<DOMString> readText();
-		  Promise<undefined> write(ClipboardItems data);
-		  Promise<undefined> writeText(DOMString data);
+		[SecureContext, Exposed=Window]
+		interface Clipboard : EventTarget {
+			Promise<ClipboardItems> read();
+			Promise<DOMString> readText();
+			Promise<undefined> write(ClipboardItems data);
+			Promise<undefined> writeText(DOMString data);
 		};
 		
- A [=Clipboard=] may contain one or more [=ClipboardItem=]s. Multiple [=ClipboardItem=]s are only supported on platforms such as iOS/iPadOS. + A [=Clipboard=] may contain one or more [=clipboard item=]s. Multiple [=clipboard item=]s are only supported on platforms such as iOS/iPadOS. A web author needs to create a |data| which is a [=ClipboardItems=] object in order to write content to clipboard using the {{Clipboard/write(data)}} method. {{Clipboard/read()}} returns a [=Promise=] to [=ClipboardItems=] object that represents contents of clipboard. - A [=ClipboardItem=] can be read from [=ClipboardItems=], which then can be used to read a specific |type| using {{ClipboardItem/getType(type)}}. + A [=clipboard item=] can be read from [=ClipboardItems=], which then can be used to read a specific |type| using {{ClipboardItem/getType(type)}}. -

ClipboardItems

-

A sequence of [=ClipboardItem=] objects

+

ClipboardItems

+

A sequence of [=clipboard item=] objects

@@ -710,7 +725,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |data| be a copy of the [=system clipboard data=] represented as [=ClipboardItems=]. 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. - Note: Currently in Chromium, only one [=ClipboardItem=] object is supported for reading and writing via the [=clipboard=] object. + Note: Currently in Chromium, only one [=clipboard item=] object is supported for reading and writing via the [=clipboard=] object. 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. @@ -721,7 +736,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
-
+			
 				const items = await navigator.clipboard.read();
 				const textBlob = await items[0].getType("text/plain");
 				const text = await (new Response(textBlob)).text();
@@ -761,7 +776,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
 
 			
-
+			
 				navigator.clipboard.readText().then(function(data) {
 					console.log(“Your string: ”, data);
 				});
@@ -821,8 +836,8 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
 
 				1. Replace the [=system clipboard data=] with |clipboardItemList|.
 
-				Note: Writing multiple [=ClipboardItem=]s to the clipboard is only supported on MacOS.
-				For other platforms, only the first [=ClipboardItem=] should be written to the clipboard.
+				Note: Writing multiple [=clipboard item=]s to the clipboard is only supported on MacOS.
+				For other platforms, only the first [=clipboard item=] should be written to the clipboard.
 
 				1. Resolve |p|.
 
@@ -830,7 +845,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
 
 			
-
+			
 				var data = [new ClipboardItem({ "text/plain": Promise.resolve(new Blob(["Text data"], { type: "text/plain" }) }))];
 				navigator.clipboard.write(data).then(function() {
 					console.log("Copied to clipboard successfully!");
@@ -865,7 +880,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
 					[=type=] attribute set to text/plain;charset=utf-8, and
 					[=blobParts=] set to a sequence containing the string |data|.
 
-				1. Let |newItem| be a new [=ClipboardItem=] created with a single
+				1. Let |newItem| be a new [=clipboard item=] created with a single
 					representation:
 					[=type=] attribute set to text/plain8, and
 					[=data=] set to |textBlob|.
@@ -880,7 +895,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
 
 			
-
+			
 				await navigator.clipboard.writeText("Howdy, partner!");
 			
From d42241deffbd88f93f9f53d2a313b98adfd506e9 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Wed, 10 Nov 2021 18:28:32 -0800 Subject: [PATCH 13/31] Addressed comments. --- index.bs | 156 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 83 insertions(+), 73 deletions(-) diff --git a/index.bs b/index.bs index 8c7509f..02cb228 100644 --- a/index.bs +++ b/index.bs @@ -560,9 +560,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; @@ -572,12 +572,10 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; typedef (DOMString or Blob) ClipboardItemDataType; typedef Promise<ClipboardItemDataType> ClipboardItemData; - callback ClipboardItemDelayedCallback = ClipboardItemData (); - [SecureContext, Exposed=Window] interface ClipboardItem { constructor(record<DOMString, ClipboardItemData> items, - optional ClipboardItemOptions options = {}); + optional ClipboardItemOptions options = {}); readonly attribute PresentationStyle presentationStyle; readonly attribute FrozenArray<DOMString> types; @@ -591,96 +589,111 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; PresentationStyle presentationStyle = "unspecified"; };
-

Clipboard Item

+ +

Clipboard Item

+ A [=clipboard item=] is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or "copy" command. - For example, if a user copies a range of cells from a spreadsheet, it will result in one [=clipboard item=]. If a user copies a set of files from their desktop, that list of files will be a different single [=clipboard item=]. + For example, if a user copies a range of cells from a spreadsheet of a native application, it will result in one [=clipboard item=]. If a user copies a set of files from their desktop, that list of files will be represented by multiple [=clipboard item=]s. Some platforms may support having more than one [=clipboard item=] at a time on the [=Clipboard=], while other platforms replace the previous [=clipboard item=] with the new one. - Each [=clipboard item=] can be represented as multiple mime-types. In the example where the user copies a range of cells from a spreadsheet, it may be represented as an image (image/png), an HTML table (text/html), or plain text (text/plain). - Each of these mime-types describe the same [=clipboard item=] at different levels of fidelity and make the [=clipboard item=] more consumable by target applications during paste. - Making the range of cells available as an image will allow the user to paste the cells into Photoshop, while the text/plain format can be used by applications like Windows Notepad. + A [=clipboard item=] has a list of representations, each representation with an associated mime type and data. In the example where the user copies a range of cells from a spreadsheet, it may be represented as an image (image/png), an HTML table (text/html), or plain text (text/plain). + Each of these [=mime type=]s describe a different [=representation=] of the same [=clipboard item=] at different levels of fidelity and make the [=clipboard item=] more consumable by target applications during paste. + Making the range of cells available as an image will allow the user to paste the cells into a photo editing app, while the text/plain format can be used by text editor apps. + + A [=clipboard item=] can also optionally have a presentation style that helps distinguish whether apps "pasting" a [=clipboard item=] should insert the contents of an appropriate [=representation=] inline at the point of paste or if it should be treated as an attachment. Apps that support pasting only a single [=clipboard item=] should use the first [=clipboard item=]. Apps that support pasting more than one [=clipboard item=] could, for example, provide a user interface that previews the contents of each [=clipboard item=] and allow the user to choose which one to paste. - Further, apps are expected to enumerate the mime-types 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. + 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 [=clipboard item=] contains multiple representations. Each representation consists of a MIME type and a corresponding {{DOMString}} or [=Blob=]. + A {{ClipboardItem}} object has an associated [=ClipboardItem/clipboard item=], which is a [=clipboard item=]. -

A [=clipboard item=] has an associated presentation style which is "unspecified" or "inline" or "attachment". - [=presentation style=] helps distinguish between "inline" data(e.g. selecting text on a web page and copying), vs. file-like data (e.g. copying a plain text file). - This difference is used to provide a hint when writing to the system pasteboard on iOS/iPadOS. This allows apps like Notes to insert a file attachment when copying a plain text file from the Files app, but insert text inline when - copying a selected piece of plain text from another app. In both cases, the MIME type in the pasteboard would be text/plain. This is used for both reading and writing. -

+ To create a {{ClipboardItem}} object, given a [=clipboard item=] |clipboardItem|'s [=relevant realm=] |realm|, run these steps: + 1. Let |clipboardItemObject| be a new {{ClipboardItem}} with |realm|. -

A [=clipboard item=] has an associated types which contains the MIME types.

+ 1. Set |clipboardItemObject|'s [=clipboard item=] to |clipboardItem|. -
-
clipboardItem = new ClipboardItem([items, options]) -
- Creates a new {{ClipboardItem}} object. items are used to fill its MIME types and [=Promise=]s to [=Blob=]s or {{DOMString}}s corresponding to the MIME types, options can be used to fill its {{ClipboardItemOptions}}, - as per the example below. + constructor steps for new ClipboardItem(items, options) are: + 1. Set [=this=]'s [=ClipboardItem/clipboard item=] to a new [=clipboard item=]. -
-					const format1 = 'text/plain';
-					const promise_text_blob = Promise.resolve(new Blob(['hello'], {type: format1}));
-					const clipboardItemInput = new ClipboardItem(
-						{[format1]: promise_text_blob},
-						{options: "unspecified"});
-				
+ 1. If |options| is empty, then set [=this=]'s [=ClipboardItem/clipboard item=]'s [=presentation style=] to "unspecified", else, set [=this=]'s [=ClipboardItem/clipboard item=]'s [=presentation style=] to |options|["presentationStyle"]. -
clipboardItem.getType(type) -

Returns a [=Promise=] to the [=Blob=] corresponding to type.

+ 1. For each (|key|, |value|) in |items|: -
clipboardItem.types -

Returns the list of types contained in the clipboardItem object. + 1. Let |mimeType| be the result of [=parse a mime type=] given |key|. -

-

- A {{ClipboardItem}} object has an associated [=clipboard item=]. -

-

- A {{ClipboardItem}} object's {{ClipboardItem/presentationStyle}} is its [=clipboard item=]'s [=presentation style=]. -

-

- A {{ClipboardItem}} object's {{ClipboardItem/types}} is its [=clipboard item=]'s [=types=]. -

-

- The constructor steps for new ClipboardItem(items, options) are to set [=this=]'s items to items and options to options. -

+ 1. If |mimeType| is failure, then throw a {{TypeError}}. + + 1. Let |representation| be a new [=representation=]. + + 1. Set |representation|'s [=mime type=] to |key|. + + 1. Set |representation|'s [=data=] to |value|. + + 1. Append |representation| to [=this=]'s [=ClipboardItem/clipboard item=]'s [=list of representations=].

presentationStyle

- Each {{ClipboardItem}} has a {{ClipboardItem/presentationStyle}}, which is a {{PresentationStyle}}. - The {{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s [=clipboard item=]'s [=presentation style=]. + The {{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s [=ClipboardItem/clipboard item=]'s [=presentation style=].

types

-

Each {{ClipboardItem}} has a {{ClipboardItem/types}}, which contains the MIME types. - {{ClipboardItem/types}} getter steps are to return [=this=]'s [=clipboard item=]'s [=types=].

+

+ {{ClipboardItem/types}} getter steps are: + + 1. Let |types| be the result of running [=create a frozen array=]. + + 1. Let |itemTypeList| be [=this=]'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. + + 1. For each |itemType| in |itemTypeList|: + + 1. Add |itemType|'s [=mime type=] to |types|. + + 1. Return |types|. +

getType(type) must run the below steps:

1. Let |realm| be [=this=]'s [=relevant realm=]. - 1. If |type| is not listed in the [=mandatory data types=] list, then [=a promise rejected with=] "The type was not found" DOMException in |realm|. + 1. Let |mimeType| be the result of [=parse a mime type=] given |type|. + + 1. If |mimeType| is failure, then throw a {{TypeError}}. + + 1. Let |itemTypeList| be [=this=]'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. + + 1. If |mimeType| is not present in |itemTypeList|'s [=representation=]'s [=mime type=], then [=a promise rejected with=] {{"NotFoundError"}} DOMException in |realm|. 1. Let |p| be [=a new promise=] in |realm|. - 1. Let |blobData| be a [=Blob=] corresponding to the |type|. + 1. Let |blobData| be a [=Blob=] created using [=representation=]'s [=data=] corresponding to the |mimeType|. 1. Resolve |p| with |blobData|. 1. Return |p|. -

ClipboardItemDataType

-

- It is a {{DOMString}} or [=Blob=] type. This contains the payload corresponding to the MIME type while creating a [=clipboard item=] object. -

-

ClipboardItemData

-

- A [=Promise=] to a {{ClipboardItemDataType}}. -

+
+
clipboardItem = new ClipboardItem([items, options]) +
+ Creates a new {{ClipboardItem}} object. items are used to fill its MIME types and [=Promise=]s to [=Blob=]s or {{DOMString}}s corresponding to the MIME types, options can be used to fill its {{ClipboardItemOptions}}, + as per the example below. + +
+					const format1 = 'text/plain';
+					const promise_text_blob = Promise.resolve(new Blob(['hello'], {type: format1}));
+					const clipboardItemInput = new ClipboardItem(
+						{[format1]: promise_text_blob},
+						{presentationStyle: "unspecified"});
+				
+ +
clipboardItem.getType(type) +

Returns a [=Promise=] to the [=Blob=] corresponding to type.

+ +
clipboardItem.types +

Returns the list of types contained in the clipboardItem object. + +

Clipboard Interface

@@ -696,13 +709,10 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; };
- A [=Clipboard=] may contain one or more [=clipboard item=]s. Multiple [=clipboard item=]s are only supported on platforms such as iOS/iPadOS. + A Clipboard may contain ClipboardItems which has one or more [=clipboard item=]s. Multiple [=clipboard item=]s are only supported on platforms such as iOS/iPadOS. A web author needs to create a |data| which is a [=ClipboardItems=] object in order to write content to clipboard using the {{Clipboard/write(data)}} method. {{Clipboard/read()}} returns a [=Promise=] to [=ClipboardItems=] object that represents contents of clipboard. - A [=clipboard item=] can be read from [=ClipboardItems=], which then can be used to read a specific |type| using {{ClipboardItem/getType(type)}}. - -

ClipboardItems

-

A sequence of [=clipboard item=] objects

+ A [=clipboard item=] can be read from [=ClipboardItems=].
@@ -721,7 +731,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then [=a promise rejected with=] "NotAllowedError" DOMException in |realm|. + 1. If |r| is not "granted", then [=a promise rejected with=] {{"NotAllowedError"}} DOMException in |realm|. 1. Let |data| be a copy of the [=system clipboard data=] represented as [=ClipboardItems=]. 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. @@ -760,7 +770,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then [=a promise rejected with=] "NotAllowedError" DOMException in |realm|. + 1. If |r| is not "granted", then [=a promise rejected with=] {{"NotAllowedError"}} DOMException in |realm|. 1. Let |data| be a copy of the [=system clipboard data=]. @@ -778,7 +788,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
 				navigator.clipboard.readText().then(function(data) {
-					console.log(“Your string: ”, data);
+					console.log("Your string: ", data);
 				});
 			
@@ -800,7 +810,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then [=a promise rejected with=] "NotAllowedError" DOMException in |realm|. + 1. If |r| is not "granted", then [=a promise rejected with=] {{"NotAllowedError"}} DOMException in |realm|. 1. Let |itemList| and |cleanItemList| be an empty sequence<{{Blob}}>. @@ -812,7 +822,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |p1| be [=a new promise=] to {{Blob}} in |realm|. - 1. If |p1| is [=reject=]d, then throw "Promises to Blobs were rejected." DOMException in |realm|. + 1. If |p1| is [=reject=]ed, then throw "Promises to Blobs were rejected." DOMException in |realm|. 1. If |item| is a {{DOMString}}, then convert it into {{Blob}} and add it to |itemList|. @@ -872,7 +882,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then [=a promise rejected with=] "NotAllowedError" DOMException in |realm|. + 1. If |r| is not "granted", then [=a promise rejected with=] {{"NotAllowedError"}} DOMException in |realm|. 1. Let |newItemList| be empty [=ClipboardItems=]. From bf13db219c5cbcb1a6980d1bd24edf6f2e347c07 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Tue, 16 Nov 2021 11:35:20 -0800 Subject: [PATCH 14/31] Address PR comments. --- index.bs | 238 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 141 insertions(+), 97 deletions(-) diff --git a/index.bs b/index.bs index 02cb228..e4a69e1 100644 --- a/index.bs +++ b/index.bs @@ -590,15 +590,49 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; };
-

Clipboard Item

+
+
clipboardItem = new ClipboardItem([items, options]) +
+ Creates a new {{ClipboardItem}} object. items are used to fill its MIME types and [=Promise=]s to [=Blob=]s or {{DOMString}}s corresponding to the MIME types, options can be used to fill its {{ClipboardItemOptions}}, + as per the example below. + +
+					const format1 = 'text/plain';
+					const promise_text_blob = Promise.resolve(new Blob(['hello'], {type: format1}));
+					const clipboardItemInput = new ClipboardItem(
+						{[format1]: promise_text_blob},
+						{presentationStyle: "unspecified"});
+				
+ +
clipboardItem.getType(type) +

Returns a [=Promise=] to the [=Blob=] corresponding to type.

+ +
clipboardItem.types +

Returns the list of types contained in the clipboardItem object. + +

+ +

Clipboard Item

A [=clipboard item=] is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or "copy" command. - For example, if a user copies a range of cells from a spreadsheet of a native application, it will result in one [=clipboard item=]. If a user copies a set of files from their desktop, that list of files will be represented by multiple [=clipboard item=]s. + +

+ For example, if a user copies a range of cells from a spreadsheet of a native application, it will result in one [=clipboard item=]. If a user copies a set of files from their desktop, that list of files will be represented by multiple [=clipboard item=]s. +

+ Some platforms may support having more than one [=clipboard item=] at a time on the [=Clipboard=], while other platforms replace the previous [=clipboard item=] with the new one. - A [=clipboard item=] has a list of representations, each representation with an associated mime type and data. In the example where the user copies a range of cells from a spreadsheet, it may be represented as an image (image/png), an HTML table (text/html), or plain text (text/plain). + A [=clipboard item=] has a list of representations, each representation with an associated [=mime type=] and data. + +

+ In the example where the user copies a range of cells from a spreadsheet, it may be represented as an image (image/png), an HTML table (text/html), or plain text (text/plain). +

+ Each of these [=mime type=]s describe a different [=representation=] of the same [=clipboard item=] at different levels of fidelity and make the [=clipboard item=] more consumable by target applications during paste. - Making the range of cells available as an image will allow the user to paste the cells into a photo editing app, while the text/plain format can be used by text editor apps. + +

+ Making the range of cells available as an image will allow the user to paste the cells into a photo editing app, while the text/plain format can be used by text editor apps. +

A [=clipboard item=] can also optionally have a presentation style that helps distinguish whether apps "pasting" a [=clipboard item=] should insert the contents of an appropriate [=representation=] inline at the point of paste or if it should be treated as an attachment. @@ -607,17 +641,19 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 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 [=ClipboardItem/clipboard item=], which is a [=clipboard item=]. + A {{ClipboardItem}} object has an associated clipboard item, which is a [=clipboard item=]. + + A {{ClipboardItem}} object has an associated types array, which is a {{FrozenArray}}. - To create a {{ClipboardItem}} object, given a [=clipboard item=] |clipboardItem|'s [=relevant realm=] |realm|, run these steps: - 1. Let |clipboardItemObject| be a new {{ClipboardItem}} with |realm|. + To create a {{ClipboardItem}} object, given a [=clipboard item=] |clipboardItem|'s [=relevant realm=] |realm|, run these steps: + 1. Let |clipboardItemObject| be a [=new=] {{ClipboardItem}} with |realm|. 1. Set |clipboardItemObject|'s [=clipboard item=] to |clipboardItem|. - constructor steps for new ClipboardItem(items, options) are: + The constructor steps for new ClipboardItem(items, options) are: 1. Set [=this=]'s [=ClipboardItem/clipboard item=] to a new [=clipboard item=]. - 1. If |options| is empty, then set [=this=]'s [=ClipboardItem/clipboard item=]'s [=presentation style=] to "unspecified", else, set [=this=]'s [=ClipboardItem/clipboard item=]'s [=presentation style=] to |options|["presentationStyle"]. + 1. Set [=this=]'s [=ClipboardItem/clipboard item=]'s [=presentation style=] to |options|["{{ClipboardItemOptions/presentationStyle}}"]. 1. For each (|key|, |value|) in |items|: @@ -633,6 +669,14 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Append |representation| to [=this=]'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. + 1. Let |types| be the result of running [=create a frozen array=] of {{DOMString}}. + + 1. Let |mimeTypeString| be the result of [=serialize a mime type=] with |mimeType|. + + 1. Add |mimeTypeString| to |types|. + + 1. Set |types| to [=this=]'s [=ClipboardItem/types array=]. +

presentationStyle

The {{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s [=ClipboardItem/clipboard item=]'s [=presentation style=]. @@ -640,17 +684,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

types

- {{ClipboardItem/types}} getter steps are: - - 1. Let |types| be the result of running [=create a frozen array=]. - - 1. Let |itemTypeList| be [=this=]'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. - - 1. For each |itemType| in |itemTypeList|: - - 1. Add |itemType|'s [=mime type=] to |types|. - - 1. Return |types|. + {{ClipboardItem/types}} getter steps are to return [=this=]'s [=ClipboardItem/types array=].

getType(type) must run the below steps:

@@ -663,37 +697,19 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |itemTypeList| be [=this=]'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. - 1. If |mimeType| is not present in |itemTypeList|'s [=representation=]'s [=mime type=], then [=a promise rejected with=] {{"NotFoundError"}} DOMException in |realm|. - - 1. Let |p| be [=a new promise=] in |realm|. - - 1. Let |blobData| be a [=Blob=] created using [=representation=]'s [=data=] corresponding to the |mimeType|. + 1. For each |representation| in |itemTypeList|: - 1. Resolve |p| with |blobData|. + 1. If |representation|'s [=mime type=] is |mimeType|, then: - 1. Return |p|. + 1. Let |blobData| be a [=Blob=] created using |representation|'s [=data=]. -
-
clipboardItem = new ClipboardItem([items, options]) -
- Creates a new {{ClipboardItem}} object. items are used to fill its MIME types and [=Promise=]s to [=Blob=]s or {{DOMString}}s corresponding to the MIME types, options can be used to fill its {{ClipboardItemOptions}}, - as per the example below. + 1. Let |p| be [=a new promise=] in |realm|. -
-					const format1 = 'text/plain';
-					const promise_text_blob = Promise.resolve(new Blob(['hello'], {type: format1}));
-					const clipboardItemInput = new ClipboardItem(
-						{[format1]: promise_text_blob},
-						{presentationStyle: "unspecified"});
-				
- -
clipboardItem.getType(type) -

Returns a [=Promise=] to the [=Blob=] corresponding to type.

+ 1. Resolve |p| with |blobData|. -
clipboardItem.types -

Returns the list of types contained in the clipboardItem object. + 1. Return |p|. -

+ 1. Return [=a promise rejected with=] {{"NotFoundError"}} DOMException in |realm|.

Clipboard Interface

@@ -709,10 +725,14 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; };
- A Clipboard may contain ClipboardItems which has one or more [=clipboard item=]s. Multiple [=clipboard item=]s are only supported on platforms such as iOS/iPadOS. - A web author needs to create a |data| which is a [=ClipboardItems=] object in order to write content to clipboard using the {{Clipboard/write(data)}} method. - {{Clipboard/read()}} returns a [=Promise=] to [=ClipboardItems=] object that represents contents of clipboard. - A [=clipboard item=] can be read from [=ClipboardItems=]. + A Clipboard may contain Clipboard Items which has one or more [=clipboard item=]s. Multiple [=clipboard item=]s are only supported on platforms such as iOS/iPadOS. + A web author needs to create a |data| which is a [=Clipboard items=] object in order to write content to [=system clipboard=] using the {{Clipboard/write(data)}} method. + {{Clipboard/read()}} returns a [=Promise=] to [=Clipboard items=] object that represents contents of [=system clipboard=]. + A [=clipboard item=] can be read from [=clipboard items=]. + + The clipboard task source is triggered in response to reading or writing of [=system clipboard data=]. + + The permission task source is triggered in response to [=request permission to use=].
@@ -725,22 +745,34 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Run the following steps [=in parallel=]: - 1. Let |r| be the result of running [=check clipboard read permission=] [=in parallel=] + 1. Let |r| be the result of running [=check clipboard read permission=]. Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then [=a promise rejected with=] {{"NotAllowedError"}} DOMException in |realm|. + 1. [=queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below steps: + + 1. If |r| is not "granted", then reject |p| with {{"NotAllowedError"}} DOMException in |realm|. - 1. Let |data| be a copy of the [=system clipboard data=] represented as [=ClipboardItems=]. 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 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. Note: Currently in Chromium, only one [=clipboard item=] object is supported for reading and writing via the [=clipboard=] object. 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. - 1. Resolve |p| with |data|. + 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}}>. + + 1. For each [=clipboard item=] |underlyingItem| of |data|: + + 1. Let |item| be the result of running the steps of [=create a ClipboardItem object=] given |underlyingItem|. + + 1. Append |item| to |items|. + + 1. Resolve |p| with |items|. 1. Return |p|. @@ -764,23 +796,27 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Run the following steps [=in parallel=]: - 1. Let |r| be the result of running [=check clipboard read permission=] [=in parallel=] + 1. Let |r| be the result of running [=check clipboard read permission=]. - Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside - a user gesture event and the user must select the paste option from the native context menu that pops up - when read() is called from JS, otherwise, the promise will be rejected. + Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside + a user gesture event and the user must select the paste option from the native context menu that pops up + when read() is called from JS, otherwise, the promise will be rejected. + + 1. [=queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below steps: + + 1. If |r| is not "granted", then reject |p| with {{"NotAllowedError"}} DOMException in |realm|. - 1. If |r| is not "granted", then [=a promise rejected with=] {{"NotAllowedError"}} DOMException in |realm|. + 1. Let |data| be a copy of the [=system clipboard data=] represented as [=clipboard item=]. |data| contains the sanitized copy of text/plain format. - 1. Let |data| be a copy of the [=system clipboard data=]. + 1. [=queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: - 1. Let |textData| be an empty string. + 1. Let |textData| be an empty {{DOMString}}. - 1. If |data| contains a "text/plain" item |textItem|, then: + 1. If |data| contains a "text/plain" item |textItem|, then: - 1. Set |textData| to be a copy of |textItem|'s string data + 1. Set |textData| to be a copy of |textItem|'s string data - 1. Resolve |p| with |textData|. + 1. Resolve |p| with |textData|. 1. Return |p|. @@ -810,46 +846,50 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then [=a promise rejected with=] {{"NotAllowedError"}} DOMException in |realm|. + 1. [=queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below steps: + + 1. If |r| is not "granted", then reject |p| with {{"NotAllowedError"}} DOMException in |realm|. - 1. Let |itemList| and |cleanItemList| be an empty sequence<{{Blob}}>. + 1. [=queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: - 1. Let |clipboardItemList| be an empty [=ClipboardItems=]. + 1. Let |itemList| and |cleanItemList| be an empty [=sequence=]<{{Blob}}>. - 1. For each |clipboardItem| in |data|: + 1. Let |clipboardItemList| be an empty [=clipboard items=]. - 1. For each |item| in |clipboardItem|: + 1. For each |clipboardItem| in |data|: - 1. Let |p1| be [=a new promise=] to {{Blob}} in |realm|. + 1. For each |item| in |clipboardItem|: - 1. If |p1| is [=reject=]ed, then throw "Promises to Blobs were rejected." DOMException in |realm|. + 1. Let |p1| be {{Promise}} in |item|. - 1. If |item| is a {{DOMString}}, then convert it into {{Blob}} and add it to |itemList|. + 1. If |p1| is [=reject=]ed, then throw {{"NotAllowedError"}} DOMException in |realm|. - 1. If |item| is a {{Blob}}, then add the {{Blob}} in |item| to |itemList| after |p1| has been resolved. + 1. If |item| is a {{DOMString}}, then convert it into {{Blob}} and add it to |itemList|. - 1. For each {{Blob}} |blob| in |itemList|: + 1. If |item| is a {{Blob}}, then add the {{Blob}} in |item| to |itemList|. - 1. Let |type| be the |blob|'s {{Blob/type}}. + 1. For each {{Blob}} |blob| in |itemList|: - 1. If |type| is not in the [=mandatory data types=] list, then [=a promise rejected with=] "Type |type| not supported on write." DOMException in |realm|. + 1. Let |type| be the |blob|'s {{Blob/type}}. - 1. Let |cleanItem| be a sanitized copy of |blob|. + 1. If |type| is not in the [=mandatory data types=] list, then [=a promise rejected with=] {{"NotAllowedError"}} DOMException in |realm|. - Issue: Add definition of sanitized copy. + 1. Let |cleanItem| be a sanitized copy of |blob|. - 1. If unable to create a sanitized copy, then [=reject=] |p|. + Issue: Add definition of sanitized copy. - 1. Add |cleanItem| to |cleanItemList|. - - 1. Add |cleanItemList| to |clipboardItemList|. + 1. If unable to create a sanitized copy, then [=reject=] |p|. + + 1. Add |cleanItem| to |cleanItemList|. + + 1. Add |cleanItemList| to |clipboardItemList|. - 1. Replace the [=system clipboard data=] with |clipboardItemList|. + 1. Replace the [=system clipboard data=] with |clipboardItemList|. - Note: Writing multiple [=clipboard item=]s to the clipboard is only supported on MacOS. - For other platforms, only the first [=clipboard item=] should be written to the clipboard. + Note: Writing multiple [=clipboard item=]s to the clipboard is only supported on MacOS. + For other platforms, only the first [=clipboard item=] should be written to the clipboard. - 1. Resolve |p|. + 1. Resolve |p|. 1. Return |p|. @@ -882,24 +922,28 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then [=a promise rejected with=] {{"NotAllowedError"}} DOMException in |realm|. + 1. [=queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below steps: + + 1. If |r| is not "granted", then reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + + 1. [=queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: - 1. Let |newItemList| be empty [=ClipboardItems=]. + 1. Let |newItemList| be empty [=clipboard items=]. - 1. Let |textBlob| be a new {{Blob}} created with: - [=type=] attribute set to text/plain;charset=utf-8, and - [=blobParts=] set to a sequence containing the string |data|. + 1. Let |textBlob| be a new {{Blob}} created with: + [=type=] attribute set to text/plain;charset=utf-8, and + [=blobParts=] set to a sequence containing the string |data|. - 1. Let |newItem| be a new [=clipboard item=] created with a single - representation: - [=type=] attribute set to text/plain8, and - [=data=] set to |textBlob|. + 1. Let |newItem| be a new [=clipboard item=] created with a single + representation: + [=type=] attribute set to text/plain8, and + [=data=] set to |textBlob|. - 1. Add |newItem| to |newItemList|. + 1. Add |newItem| to |newItemList|. - 1. Replace the [=system clipboard data=] with |newItemList|. + 1. Replace the [=system clipboard data=] with |newItemList|. - 1. Resolve |p|. + 1. Resolve |p|. 1. Return |p|. From 5965fc36e29b444c25431b36f75b5cbc491f3d6b Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Tue, 16 Nov 2021 12:47:00 -0800 Subject: [PATCH 15/31] Fix bikeshed error. --- index.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.bs b/index.bs index e4a69e1..dfdf30c 100644 --- a/index.bs +++ b/index.bs @@ -612,7 +612,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
-

Clipboard Item

+

Clipboard Item

A [=clipboard item=] is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or "copy" command. @@ -860,7 +860,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. For each |item| in |clipboardItem|: - 1. Let |p1| be {{Promise}} in |item|. + 1. Let |p1| be [=Promise=] in |item|. 1. If |p1| is [=reject=]ed, then throw {{"NotAllowedError"}} DOMException in |realm|. From ce519576d6e9befc0ed43d29a8126ffe3941fd39 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Fri, 19 Nov 2021 13:29:03 -0800 Subject: [PATCH 16/31] Address PR comments. --- index.bs | 71 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/index.bs b/index.bs index dfdf30c..0651baa 100644 --- a/index.bs +++ b/index.bs @@ -655,6 +655,8 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Set [=this=]'s [=ClipboardItem/clipboard item=]'s [=presentation style=] to |options|["{{ClipboardItemOptions/presentationStyle}}"]. + 1. Let |types| be a list of {{DOMString}}. + 1. For each (|key|, |value|) in |items|: 1. Let |mimeType| be the result of [=parse a mime type=] given |key|. @@ -669,13 +671,11 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Append |representation| to [=this=]'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. - 1. Let |types| be the result of running [=create a frozen array=] of {{DOMString}}. - 1. Let |mimeTypeString| be the result of [=serialize a mime type=] with |mimeType|. 1. Add |mimeTypeString| to |types|. - 1. Set |types| to [=this=]'s [=ClipboardItem/types array=]. + 1. Set [=this=]'s [=ClipboardItem/types array=] to the result of running [=create a frozen array=] from |types|.

presentationStyle

@@ -701,7 +701,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |representation|'s [=mime type=] is |mimeType|, then: - 1. Let |blobData| be a [=Blob=] created using |representation|'s [=data=]. + 1. Let |blobData| be a [=Blob=] created using |representation|'s [=data=] and with its {{Blob/type}} set to |mimeType|, [=serialize a MIME type|serialized=]. 1. Let |p| be [=a new promise=] in |realm|. @@ -732,8 +732,6 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; The clipboard task source is triggered in response to reading or writing of [=system clipboard data=]. - The permission task source is triggered in response to [=request permission to use=]. -

read()

@@ -751,9 +749,11 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. [=queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below steps: + 1. If |r| is not "granted", then [=Queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below step: - 1. If |r| is not "granted", then reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + 1. Reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + + 1. Abort all 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. @@ -762,7 +762,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 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. - 1. [=queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: + 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}}>. @@ -802,13 +802,15 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. [=queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below steps: + 1. If |r| is not "granted", then [=Queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below step: - 1. If |r| is not "granted", then reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + 1. Reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + + 1. Abort all steps. 1. Let |data| be a copy of the [=system clipboard data=] represented as [=clipboard item=]. |data| contains the sanitized copy of text/plain format. - 1. [=queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: + 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: 1. Let |textData| be an empty {{DOMString}}. @@ -840,17 +842,19 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Run the following steps [=in parallel=]: - 1. Let |r| be the result of running [=check clipboard write permission=] [=in parallel=] + 1. Let |r| be the result of running [=check clipboard write permission=]. Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. [=queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below steps: + 1. If |r| is not "granted", then [=Queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below step: - 1. If |r| is not "granted", then reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + 1. Reject |p| with {{"NotAllowedError"}} DOMException in |realm|. - 1. [=queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: + 1. Abort all steps. + + 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: 1. Let |itemList| and |cleanItemList| be an empty [=sequence=]<{{Blob}}>. @@ -858,31 +862,27 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. For each |clipboardItem| in |data|: - 1. For each |item| in |clipboardItem|: - - 1. Let |p1| be [=Promise=] in |item|. - - 1. If |p1| is [=reject=]ed, then throw {{"NotAllowedError"}} DOMException in |realm|. + 1. For each |item| in |clipboardItem|'s [=ClipboardItem/clipboard item=]'s [=list of representations=]: 1. If |item| is a {{DOMString}}, then convert it into {{Blob}} and add it to |itemList|. 1. If |item| is a {{Blob}}, then add the {{Blob}} in |item| to |itemList|. - 1. For each {{Blob}} |blob| in |itemList|: + 1. For each {{Blob}} |blob| in |itemList|: - 1. Let |type| be the |blob|'s {{Blob/type}}. + 1. Let |type| be the |blob|'s {{Blob/type}}. - 1. If |type| is not in the [=mandatory data types=] list, then [=a promise rejected with=] {{"NotAllowedError"}} DOMException in |realm|. + 1. If |type| is not in the [=mandatory data types=] list, then [=a promise rejected with=] {{"NotAllowedError"}} DOMException in |realm|. - 1. Let |cleanItem| be a sanitized copy of |blob|. + 1. Let |cleanItem| be a sanitized copy of |blob|. - Issue: Add definition of sanitized copy. + Issue: Add definition of sanitized copy. - 1. If unable to create a sanitized copy, then [=reject=] |p|. + 1. If unable to create a sanitized copy, then [=reject=] |p|. - 1. Add |cleanItem| to |cleanItemList|. - - 1. Add |cleanItemList| to |clipboardItemList|. + 1. Add |cleanItem| to |cleanItemList|. + + 1. Add |cleanItemList| to |clipboardItemList|. 1. Replace the [=system clipboard data=] with |clipboardItemList|. @@ -916,17 +916,19 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Run the following steps [=in parallel=]: - 1. Let |r| be the result of running [=check clipboard write permission=] [=in parallel=] + 1. Let |r| be the result of running [=check clipboard write permission=]. Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. [=queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below steps: + 1. If |r| is not "granted", then [=Queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below step: - 1. If |r| is not "granted", then reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + 1. Reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + + 1. Abort all steps. - 1. [=queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: + 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: 1. Let |newItemList| be empty [=clipboard items=]. @@ -1447,6 +1449,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; Tarquin Wilton-Jones, Tom Wlodkowski, Bo Cupp, + mbrodesser and Boris Zbarsky. From 7605ea3a6a11e9d52f0aa5438be479b642bf4d40 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Fri, 19 Nov 2021 16:56:40 -0800 Subject: [PATCH 17/31] Address PR comments. --- index.bs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/index.bs b/index.bs index 0651baa..4515859 100644 --- a/index.bs +++ b/index.bs @@ -864,21 +864,33 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. For each |item| in |clipboardItem|'s [=ClipboardItem/clipboard item=]'s [=list of representations=]: - 1. If |item| is a {{DOMString}}, then convert it into {{Blob}} and add it to |itemList|. + 1. Let |p1| be the |item|'s [=data=]. - 1. If |item| is a {{Blob}}, then add the {{Blob}} in |item| to |itemList|. + 1. [=promise/React=] to |p1|: - 1. For each {{Blob}} |blob| in |itemList|: + 1. If |p1| was fulfilled with value |v|, then: + + 1. If |v| is a {{DOMString}}, then convert it into {{Blob}} and add it to |itemList|. + + 1. If |v| is a {{Blob}}, then add it to |itemList|. + + 1. If |p1| was rejected, then: + + 1. Reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + + 1. Abort all steps. + + 1. For each |blob| in |itemList|: 1. Let |type| be the |blob|'s {{Blob/type}}. - 1. If |type| is not in the [=mandatory data types=] list, then [=a promise rejected with=] {{"NotAllowedError"}} DOMException in |realm|. + 1. If |type| is not in the [=mandatory data types=] list, then reject |p| with {{"NotAllowedError"}} DOMException in |realm|. 1. Let |cleanItem| be a sanitized copy of |blob|. Issue: Add definition of sanitized copy. - 1. If unable to create a sanitized copy, then [=reject=] |p|. + 1. If unable to create a sanitized copy, then reject |p| with {{"NotAllowedError"}} DOMException in |realm|. 1. Add |cleanItem| to |cleanItemList|. From ca32200ea7af24fb25e27d11e50aba37fe95f1b9 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Mon, 13 Dec 2021 15:25:13 -0800 Subject: [PATCH 18/31] Address PR comments. --- index.bs | 149 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 90 insertions(+), 59 deletions(-) diff --git a/index.bs b/index.bs index 4515859..de44381 100644 --- a/index.bs +++ b/index.bs @@ -569,8 +569,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

ClipboardItem Interface

-			typedef (DOMString or Blob) ClipboardItemDataType;
-			typedef Promise<ClipboardItemDataType> ClipboardItemData;
+			typedef Promise<(DOMString or Blob)> ClipboardItemData;
 
 			[SecureContext, Exposed=Window]
 			interface ClipboardItem {
@@ -614,21 +613,21 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
 
 		

Clipboard Item

- A [=clipboard item=] is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or "copy" command. + A clipboard item is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or "copy" command.

For example, if a user copies a range of cells from a spreadsheet of a native application, it will result in one [=clipboard item=]. If a user copies a set of files from their desktop, that list of files will be represented by multiple [=clipboard item=]s.

- Some platforms may support having more than one [=clipboard item=] at a time on the [=Clipboard=], while other platforms replace the previous [=clipboard item=] with the new one. + Some platforms may support having more than one [=clipboard item=] at a time on the [=Clipboard=], while other platforms replace the previous [=clipboard item=] with the new one. - A [=clipboard item=] has a list of representations, each representation with an associated [=mime type=] and data. + A [=clipboard item=] has a list of representations, each representation with an associated mime type (a [=/MIME type=]) and data (a {{ClipboardItemData}}).

In the example where the user copies a range of cells from a spreadsheet, it may be represented as an image (image/png), an HTML table (text/html), or plain text (text/plain).

- Each of these [=mime type=]s describe a different [=representation=] of the same [=clipboard item=] at different levels of fidelity and make the [=clipboard item=] more consumable by target applications during paste. + Each of these [=/MIME type=]s describe a different [=representation=] of the same [=clipboard item=] at different levels of fidelity and make the [=clipboard item=] more consumable by target applications during paste.

Making the range of cells available as an image will allow the user to paste the cells into a photo editing app, while the text/plain format can be used by text editor apps. @@ -638,40 +637,40 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; Apps that support pasting only a single [=clipboard item=] should use the first [=clipboard item=]. Apps that support pasting more than one [=clipboard item=] could, for example, provide a user interface that previews the contents of each [=clipboard item=] and allow the user to choose which one to paste. - 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. + 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 clipboard item, which is a [=clipboard item=]. + A {{ClipboardItem}} object has an associated clipboardItem, which is a [=clipboard item=]. A {{ClipboardItem}} object has an associated types array, which is a {{FrozenArray}}. - To create a {{ClipboardItem}} object, given a [=clipboard item=] |clipboardItem|'s [=relevant realm=] |realm|, run these steps: + To create a {{ClipboardItem}} object, given a [=clipboard item=] |clipboardItem| and a [=global object/Realm=] |realm|, run these steps: 1. Let |clipboardItemObject| be a [=new=] {{ClipboardItem}} with |realm|. 1. Set |clipboardItemObject|'s [=clipboard item=] to |clipboardItem|. - The constructor steps for new ClipboardItem(items, options) are: - 1. Set [=this=]'s [=ClipboardItem/clipboard item=] to a new [=clipboard item=]. + The new ClipboardItem(items, options) constructor steps are: + 1. Set [=this=]'s [=ClipboardItem/clipboardItem=] to a new [=clipboard item=]. - 1. Set [=this=]'s [=ClipboardItem/clipboard item=]'s [=presentation style=] to |options|["{{ClipboardItemOptions/presentationStyle}}"]. + 1. Set [=this=]'s [=ClipboardItem/clipboardItem=]'s [=presentation style=] to |options|["{{ClipboardItemOptions/presentationStyle}}"]. 1. Let |types| be a list of {{DOMString}}. 1. For each (|key|, |value|) in |items|: - 1. Let |mimeType| be the result of [=parse a mime type=] given |key|. + 1. Let |mimeType| be the result of [=parsing a MIME type=] given |key|. 1. If |mimeType| is failure, then throw a {{TypeError}}. 1. Let |representation| be a new [=representation=]. - 1. Set |representation|'s [=mime type=] to |key|. + 1. Set |representation|'s [=representation/MIME type=] to |key|. - 1. Set |representation|'s [=data=] to |value|. + 1. Set |representation|'s [=representation/data=] to |value|. - 1. Append |representation| to [=this=]'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. + 1. Append |representation| to [=this=]'s [=ClipboardItem/clipboardItem=]'s [=list of representations=]. - 1. Let |mimeTypeString| be the result of [=serialize a mime type=] with |mimeType|. + 1. Let |mimeTypeString| be the result of [=serializing a MIME type=] with |mimeType|. 1. Add |mimeTypeString| to |types|. @@ -679,37 +678,61 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

presentationStyle

- The {{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s [=ClipboardItem/clipboard item=]'s [=presentation style=]. + The {{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s [=ClipboardItem/clipboardItem=]'s [=presentation style=].

types

- {{ClipboardItem/types}} getter steps are to return [=this=]'s [=ClipboardItem/types array=]. + The {{ClipboardItem/types}} getter steps are to return [=this=]'s [=ClipboardItem/types array=].

getType(type) must run the below steps:

1. Let |realm| be [=this=]'s [=relevant realm=]. - 1. Let |mimeType| be the result of [=parse a mime type=] given |type|. + 1. Let |mimeType| be the result of [=parsing a MIME type=] given |type|. 1. If |mimeType| is failure, then throw a {{TypeError}}. - 1. Let |itemTypeList| be [=this=]'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. + 1. Let |itemTypeList| be [=this=]'s [=ClipboardItem/clipboardItem=]'s [=list of representations=]. + + 1. Let |p| be [=a new promise=] in |realm|. 1. For each |representation| in |itemTypeList|: - 1. If |representation|'s [=mime type=] is |mimeType|, then: + 1. If |representation|'s [=representation/MIME type=] is |mimeType|, then: + + 1. Let |p1| be the |representation|'s [=representation/data=]. + + 1. [=promise/React=] to |p1|: + + 1. If |p1| was fulfilled with value |v|, then: + + 1. If |v| is a {{DOMString}}, then follow the below steps: + + 1. Let |v1| be the result of [=/encoding=] |v|. + + 1. Let |blobData| be a [=Blob=] created using |v1| with its {{Blob/type}} set to |mimeType|, [=serialize a MIME type|serialized=]. + + 1. Resolve |p| with |blobData|. + + 1. Return |p|. - 1. Let |blobData| be a [=Blob=] created using |representation|'s [=data=] and with its {{Blob/type}} set to |mimeType|, [=serialize a MIME type|serialized=]. + 1. If |v| is a [=Blob=], then follow the below steps: - 1. Let |p| be [=a new promise=] in |realm|. + 1. Resolve |p| with |v|. - 1. Resolve |p| with |blobData|. + 1. Return |p|. - 1. Return |p|. + 1. If |p1| was rejected, then: - 1. Return [=a promise rejected with=] {{"NotFoundError"}} DOMException in |realm|. + 1. [=Reject=] |p| with {{"NotFoundError"}} DOMException in |realm|. + + 1. Return |p|. + + 1. [=Reject=] |p| with {{"NotFoundError"}} DOMException in |realm|. + + 1. Return |p|.

Clipboard Interface

@@ -749,16 +772,14 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; a user gesture event and the user must select the paste option from the native context menu that pops up when read() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then [=Queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below step: + 1. If |r| is false, then: - 1. Reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + 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 all steps. + 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. - Note: Currently in Chromium, only one [=clipboard item=] object is supported for reading and writing via the [=clipboard=] object. - 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. @@ -772,7 +793,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Append |item| to |items|. - 1. Resolve |p| with |items|. + 1. Resolve |p| with |items|. 1. Return |p|. @@ -798,15 +819,15 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |r| be the result of running [=check clipboard read permission=]. - Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside + Note: Clipboard permission is not supported on Safari. However, the readText() method must be called inside a user gesture event and the user must select the paste option from the native context menu that pops up - when read() is called from JS, otherwise, the promise will be rejected. + when readText() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then [=Queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below step: + 1. If |r| is false, then: - 1. Reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + 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 all steps. + 1. Abort these steps. 1. Let |data| be a copy of the [=system clipboard data=] represented as [=clipboard item=]. |data| contains the sanitized copy of text/plain format. @@ -844,15 +865,15 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |r| be the result of running [=check clipboard write permission=]. - Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside + Note: Clipboard permission is not supported on Safari. However, the write() method must be called inside a user gesture event and the user must select the paste option from the native context menu that pops up - when read() is called from JS, otherwise, the promise will be rejected. + when write() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then [=Queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below step: + 1. If |r| is false, then: - 1. Reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + 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 all steps. + 1. Abort these steps. 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: @@ -862,35 +883,45 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. For each |clipboardItem| in |data|: - 1. For each |item| in |clipboardItem|'s [=ClipboardItem/clipboard item=]'s [=list of representations=]: + 1. For each |item| in |clipboardItem|'s [=ClipboardItem/clipboardItem=]'s [=list of representations=]: - 1. Let |p1| be the |item|'s [=data=]. + 1. Let |p1| be the |item|'s [=representation/data=]. 1. [=promise/React=] to |p1|: 1. If |p1| was fulfilled with value |v|, then: - 1. If |v| is a {{DOMString}}, then convert it into {{Blob}} and add it to |itemList|. + 1. If |v| is a {{DOMString}}, then follow the below steps: + + 1. Let |v1| be the result of [=/encoding=] |v|. + + 1. Let |blobData| be a [=Blob=] created using |v1| with its {{Blob/type}} set to |mimeType|, [=serialize a MIME type|serialized=]. - 1. If |v| is a {{Blob}}, then add it to |itemList|. + 1. Add |blobData| to |itemList|. + + 1. If |v| is a [=Blob=], then add |v| to |itemList|. 1. If |p1| was rejected, then: - 1. Reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + 1. [=Reject=] |p| with {{"NotAllowedError"}} DOMException in |realm|. - 1. Abort all steps. + 1. Return |p|. 1. For each |blob| in |itemList|: 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|. + 1. If |type| is not in the [=mandatory data types=] list, then [=reject=] |p| with {{"NotAllowedError"}} DOMException in |realm|. 1. Let |cleanItem| be a sanitized copy of |blob|. Issue: Add definition of sanitized copy. - 1. If unable to create a sanitized copy, then reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + 1. If unable to create a sanitized copy, then follow the below steps: + + 1. [=Reject=] |p| with {{"NotAllowedError"}} DOMException in |realm|. + + 1. Return |p|. 1. Add |cleanItem| to |cleanItemList|. @@ -930,15 +961,15 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |r| be the result of running [=check clipboard write permission=]. - Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside + Note: Clipboard permission is not supported on Safari. However, the writeText() method must be called inside a user gesture event and the user must select the paste option from the native context menu that pops up - when read() is called from JS, otherwise, the promise will be rejected. + when writeText() is called from JS, otherwise, the promise will be rejected. - 1. If |r| is not "granted", then [=Queue a global task=] on the [=permission task source=], given |realm|'s [=Realm/global object=], to perform the below step: + 1. If |r| is false, then: - 1. Reject |p| with {{"NotAllowedError"}} DOMException in |realm|. + 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 all steps. + 1. Abort these steps. 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: @@ -949,9 +980,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; [=blobParts=] set to a sequence containing the string |data|. 1. Let |newItem| be a new [=clipboard item=] created with a single - representation: - [=type=] attribute set to text/plain8, and - [=data=] set to |textBlob|. + [=representation=]: + [=representation/MIME type=] attribute set to text/plain8, and + [=representation/data=] set to |textBlob|. 1. Add |newItem| to |newItemList|. From 0bbf8a8c6081b67cee7dca8361957eeee4097185 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Mon, 3 Jan 2022 11:08:10 -0800 Subject: [PATCH 19/31] Address review comments. --- index.bs | 98 +++++++++++++++++++++++++++----------------------------- 1 file changed, 48 insertions(+), 50 deletions(-) diff --git a/index.bs b/index.bs index de44381..474596f 100644 --- a/index.bs +++ b/index.bs @@ -168,7 +168,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; exposed as a {{DataTransfer}} object that mirrors the contents of the clipboard. * For the [[#async-clipboard-api]], the [=system clipboard data=] is - exposed as a sequence of [=clipboard item=] objects that mirrors the contents of + exposed as a sequence of [=/clipboard item=] objects that mirrors the contents of the clipboard.

Clipboard Events

@@ -616,43 +616,43 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; A clipboard item is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or "copy" command.

- For example, if a user copies a range of cells from a spreadsheet of a native application, it will result in one [=clipboard item=]. If a user copies a set of files from their desktop, that list of files will be represented by multiple [=clipboard item=]s. + For example, if a user copies a range of cells from a spreadsheet of a native application, it will result in one [=/clipboard item=]. If a user copies a set of files from their desktop, that list of files will be represented by multiple [=/clipboard item=]s.

- Some platforms may support having more than one [=clipboard item=] at a time on the [=Clipboard=], while other platforms replace the previous [=clipboard item=] with the new one. + Some platforms may support having more than one [=/clipboard item=] at a time on the [=Clipboard=], while other platforms replace the previous [=/clipboard item=] with the new one. - A [=clipboard item=] has a list of representations, each representation with an associated mime type (a [=/MIME type=]) and data (a {{ClipboardItemData}}). + A [=/clipboard item=] has a list of representations, each representation with an associated mime type (a [=/MIME type=]) and data (a {{ClipboardItemData}}).

In the example where the user copies a range of cells from a spreadsheet, it may be represented as an image (image/png), an HTML table (text/html), or plain text (text/plain).

- Each of these [=/MIME type=]s describe a different [=representation=] of the same [=clipboard item=] at different levels of fidelity and make the [=clipboard item=] more consumable by target applications during paste. + Each of these [=/MIME type=]s describe a different [=representation=] of the same [=/clipboard item=] at different levels of fidelity and make the [=/clipboard item=] more consumable by target applications during paste.

Making the range of cells available as an image will allow the user to paste the cells into a photo editing app, while the text/plain format can be used by text editor apps.

- A [=clipboard item=] can also optionally have a presentation style that helps distinguish whether apps "pasting" a [=clipboard item=] should insert the contents of an appropriate [=representation=] inline at the point of paste or if it should be treated as an attachment. + A [=/clipboard item=] can also optionally have a presentation style that helps distinguish whether apps "pasting" a [=/clipboard item=] should insert the contents of an appropriate [=representation=] inline at the point of paste or if it should be treated as an attachment. - Apps that support pasting only a single [=clipboard item=] should use the first [=clipboard item=]. - Apps that support pasting more than one [=clipboard item=] could, for example, provide a user interface that previews the contents of each [=clipboard item=] and allow the user to choose which one to paste. - 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. + Apps that support pasting only a single [=/clipboard item=] should use the first [=/clipboard item=]. + Apps that support pasting more than one [=/clipboard item=] could, for example, provide a user interface that previews the contents of each [=/clipboard item=] and allow the user to choose which one to paste. + 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 clipboardItem, which is a [=clipboard item=]. + A {{ClipboardItem}} object has an associated clipboard item, which is a [=/clipboard item=]. A {{ClipboardItem}} object has an associated types array, which is a {{FrozenArray}}. - To create a {{ClipboardItem}} object, given a [=clipboard item=] |clipboardItem| and a [=global object/Realm=] |realm|, run these steps: + To create a {{ClipboardItem}} object, 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|. + 1. Set |clipboardItemObject|'s [=/clipboard item=] to |clipboardItem|. The new ClipboardItem(items, options) constructor steps are: - 1. Set [=this=]'s [=ClipboardItem/clipboardItem=] to a new [=clipboard item=]. + 1. Set [=this=]'s [=ClipboardItem/clipboard item=] to a new [=/clipboard item=]. - 1. Set [=this=]'s [=ClipboardItem/clipboardItem=]'s [=presentation style=] to |options|["{{ClipboardItemOptions/presentationStyle}}"]. + 1. Set [=this=]'s [=ClipboardItem/clipboard item=]'s [=presentation style=] to |options|["{{ClipboardItemOptions/presentationStyle}}"]. 1. Let |types| be a list of {{DOMString}}. @@ -662,13 +662,15 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |mimeType| is failure, then throw a {{TypeError}}. + 1. If [=this=]'s [=ClipboardItem/clipboard item=]'s [=list of representations=] [=list/contains=] a [=representation=] whose [=representation/MIME type=] is |mimeType|, then throw a {{TypeError}}. + 1. Let |representation| be a new [=representation=]. - 1. Set |representation|'s [=representation/MIME type=] to |key|. + 1. Set |representation|'s [=representation/MIME type=] to |mimeType|. 1. Set |representation|'s [=representation/data=] to |value|. - 1. Append |representation| to [=this=]'s [=ClipboardItem/clipboardItem=]'s [=list of representations=]. + 1. Append |representation| to [=this=]'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. 1. Let |mimeTypeString| be the result of [=serializing a MIME type=] with |mimeType|. @@ -678,7 +680,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

presentationStyle

- The {{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s [=ClipboardItem/clipboardItem=]'s [=presentation style=]. + The {{ClipboardItem/presentationStyle}} getter steps are to return [=this=]'s [=ClipboardItem/clipboard item=]'s [=presentation style=].

types

@@ -686,7 +688,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; The {{ClipboardItem/types}} getter steps are to return [=this=]'s [=ClipboardItem/types array=].

-

getType(type) must run the below steps:

+

getType(type)

+ + This method must run the below steps: 1. Let |realm| be [=this=]'s [=relevant realm=]. @@ -694,7 +698,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |mimeType| is failure, then throw a {{TypeError}}. - 1. Let |itemTypeList| be [=this=]'s [=ClipboardItem/clipboardItem=]'s [=list of representations=]. + 1. Let |itemTypeList| be [=this=]'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. 1. Let |p| be [=a new promise=] in |realm|. @@ -704,33 +708,27 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |p1| be the |representation|'s [=representation/data=]. - 1. [=promise/React=] to |p1|: - - 1. If |p1| was fulfilled with value |v|, then: - - 1. If |v| is a {{DOMString}}, then follow the below steps: + 1. [=promise/React=] to |p1|: - 1. Let |v1| be the result of [=/encoding=] |v|. + 1. If |p1| was fulfilled with value |v|, then: - 1. Let |blobData| be a [=Blob=] created using |v1| with its {{Blob/type}} set to |mimeType|, [=serialize a MIME type|serialized=]. + 1. If |v| is a {{DOMString}}, then follow the below steps: - 1. Resolve |p| with |blobData|. - - 1. Return |p|. + 1. Let |v1| be the result of [=/encoding=] |v|. - 1. If |v| is a [=Blob=], then follow the below steps: + 1. Let |blobData| be a [=Blob=] created using |v1| with its {{Blob/type}} set to |mimeType|, [=serialize a MIME type|serialized=]. - 1. Resolve |p| with |v|. + 1. Resolve |p| with |blobData|. - 1. Return |p|. + 1. If |v| is a [=Blob=], then follow the below steps: - 1. If |p1| was rejected, then: + 1. Resolve |p| with |v|. - 1. [=Reject=] |p| with {{"NotFoundError"}} DOMException in |realm|. + 1. If |p1| was rejected, then: - 1. Return |p|. + 1. [=Reject=] |p| with {{"NotFoundError"}} {{DOMException}} in |realm|. - 1. [=Reject=] |p| with {{"NotFoundError"}} DOMException in |realm|. + 1. [=Reject=] |p| with {{"NotFoundError"}} {{DOMException}} in |realm|. 1. Return |p|. @@ -748,10 +746,10 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; };
- A Clipboard may contain Clipboard Items which has one or more [=clipboard item=]s. Multiple [=clipboard item=]s are only supported on platforms such as iOS/iPadOS. + A Clipboard may contain Clipboard Items which has one or more [=/clipboard item=]s. Multiple [=/clipboard item=]s are only supported on platforms such as iOS/iPadOS. A web author needs to create a |data| which is a [=Clipboard items=] object in order to write content to [=system clipboard=] using the {{Clipboard/write(data)}} method. {{Clipboard/read()}} returns a [=Promise=] to [=Clipboard items=] object that represents contents of [=system clipboard=]. - A [=clipboard item=] can be read from [=clipboard items=]. + A [=/clipboard item=] can be read from [=clipboard items=]. The clipboard task source is triggered in response to reading or writing of [=system clipboard data=]. @@ -774,7 +772,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 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. [=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. @@ -787,7 +785,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |items| be a [=sequence=]<{{ClipboardItem}}>. - 1. For each [=clipboard item=] |underlyingItem| of |data|: + 1. For each [=/clipboard item=] |underlyingItem| of |data|: 1. Let |item| be the result of running the steps of [=create a ClipboardItem object=] given |underlyingItem|. @@ -825,11 +823,11 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 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. [=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 item=]. |data| contains the sanitized copy of text/plain format. + 1. Let |data| be a copy of the [=system clipboard data=] represented as [=/clipboard item=]. |data| contains the sanitized copy of text/plain format. 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: @@ -871,7 +869,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 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. [=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. @@ -883,7 +881,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. For each |clipboardItem| in |data|: - 1. For each |item| in |clipboardItem|'s [=ClipboardItem/clipboardItem=]'s [=list of representations=]: + 1. For each |item| in |clipboardItem|'s [=ClipboardItem/clipboard item=]'s [=list of representations=]: 1. Let |p1| be the |item|'s [=representation/data=]. @@ -903,7 +901,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |p1| was rejected, then: - 1. [=Reject=] |p| with {{"NotAllowedError"}} DOMException in |realm|. + 1. [=Reject=] |p| with {{"NotAllowedError"}} {{DOMException}} in |realm|. 1. Return |p|. @@ -911,7 +909,7 @@ 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|. + 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|. @@ -929,8 +927,8 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Replace the [=system clipboard data=] with |clipboardItemList|. - Note: Writing multiple [=clipboard item=]s to the clipboard is only supported on MacOS. - For other platforms, only the first [=clipboard item=] should be written to the clipboard. + Note: Writing multiple [=/clipboard item=]s to the clipboard is only supported on MacOS. + For other platforms, only the first [=/clipboard item=] should be written to the clipboard. 1. Resolve |p|. @@ -979,7 +977,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; [=type=] attribute set to text/plain;charset=utf-8, and [=blobParts=] set to a sequence containing the string |data|. - 1. Let |newItem| be a new [=clipboard item=] created with a single + 1. Let |newItem| be a new [=/clipboard item=] created with a single [=representation=]: [=representation/MIME type=] attribute set to text/plain8, and [=representation/data=] set to |textBlob|. From e77dc678a4fcb645e6eaddec2125532151701229 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Mon, 3 Jan 2022 16:31:24 -0800 Subject: [PATCH 20/31] Address more review comments. --- index.bs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/index.bs b/index.bs index 474596f..5efe93f 100644 --- a/index.bs +++ b/index.bs @@ -592,7 +592,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
clipboardItem = new ClipboardItem([items, options])
- Creates a new {{ClipboardItem}} object. items are used to fill its MIME types and [=Promise=]s to [=Blob=]s or {{DOMString}}s corresponding to the MIME types, options can be used to fill its {{ClipboardItemOptions}}, + Creates a new {{ClipboardItem}} object. items are used to fill its MIME types and [=Promise=]s to {{Blob}}s or {{DOMString}}s corresponding to the MIME types, options can be used to fill its {{ClipboardItemOptions}}, as per the example below.
@@ -604,7 +604,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
 				
clipboardItem.getType(type) -

Returns a [=Promise=] to the [=Blob=] corresponding to type.

+

Returns a [=Promise=] to the {{Blob}} corresponding to type.

clipboardItem.types

Returns the list of types contained in the clipboardItem object. @@ -716,11 +716,11 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |v1| be the result of [=/encoding=] |v|. - 1. Let |blobData| be a [=Blob=] created using |v1| with its {{Blob/type}} set to |mimeType|, [=serialize a MIME type|serialized=]. + 1. Let |blobData| be a {{Blob}} created using |v1| with its {{Blob/type}} set to |mimeType|, [=serialize a MIME type|serialized=]. 1. Resolve |p| with |blobData|. - 1. If |v| is a [=Blob=], then follow the below steps: + 1. If |v| is a {{Blob}}, then follow the below steps: 1. Resolve |p| with |v|. @@ -875,7 +875,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: - 1. Let |itemList| and |cleanItemList| be an empty [=sequence=]<{{Blob}}>. + 1. Let |itemList| be an empty [=sequence=]<{{Blob}}>. + + 1. Let |cleanItemList| be an empty [=/record=]<{{DOMString}}, [=Promise=]<{{Blob}}>>. 1. Let |clipboardItemList| be an empty [=clipboard items=]. @@ -893,11 +895,11 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |v1| be the result of [=/encoding=] |v|. - 1. Let |blobData| be a [=Blob=] created using |v1| with its {{Blob/type}} set to |mimeType|, [=serialize a MIME type|serialized=]. + 1. Let |blobData| be a {{Blob}} created using |v1| with its {{Blob/type}} set to |mimeType|, [=serialize a MIME type|serialized=]. 1. Add |blobData| to |itemList|. - 1. If |v| is a [=Blob=], then add |v| to |itemList|. + 1. If |v| is a {{Blob}}, then add |v| to |itemList|. 1. If |p1| was rejected, then: @@ -921,9 +923,17 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Return |p|. - 1. Add |cleanItem| to |cleanItemList|. - - 1. Add |cleanItemList| to |clipboardItemList|. + 1. Let |p2| be [=a new promise=] in |realm|. + + 1. Resolve |p2| with |cleanItem|. + + 1. Append |cleanItem|'s {{Blob/type}} as the key and |p2| as value to |cleanItemList|. + + 1. Let |option| be |clipboardItem|'s [=ClipboardItem/clipboard item=]'s [=presentation style=]. + + 1. Let |cleanClipboarditem| be the result of running the steps of {{ClipboardItem/ClipboardItem()}} given |cleanItemList| and |option|. + + 1. Add |cleanClipboarditem| to |clipboardItemList|. 1. Replace the [=system clipboard data=] with |clipboardItemList|. From 68da09881b3b99768cf6811ee13f6b07dcdc6a0a Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Tue, 4 Jan 2022 11:35:26 -0800 Subject: [PATCH 21/31] Address review comments. --- index.bs | 112 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 88 insertions(+), 24 deletions(-) diff --git a/index.bs b/index.bs index 5efe93f..0ad852e 100644 --- a/index.bs +++ b/index.bs @@ -746,7 +746,12 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; }; - A Clipboard may contain Clipboard Items which has one or more [=/clipboard item=]s. Multiple [=/clipboard item=]s are only supported on platforms such as iOS/iPadOS. + A Clipboard's read() and write() methods must support Clipboard Items that has one or more [=/clipboard item=]s. + +

+ Writing multiple [=/clipboard item=]s to the clipboard is only supported on Apple platforms such as iOS/iPadOS. For other platforms, only the first [=/clipboard item=] should be written to the clipboard. +

+ A web author needs to create a |data| which is a [=Clipboard items=] object in order to write content to [=system clipboard=] using the {{Clipboard/write(data)}} method. {{Clipboard/read()}} returns a [=Promise=] to [=Clipboard items=] object that represents contents of [=system clipboard=]. A [=/clipboard item=] can be read from [=clipboard items=]. @@ -827,19 +832,39 @@ 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 item=]. |data| contains the sanitized copy of text/plain format. + 1. Let |data| be a copy of the [=system clipboard data=] represented as [=/clipboard item=]. 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: - 1. Let |textData| be an empty {{DOMString}}. + 1. Let |itemTypeList| be |data|'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. - 1. If |data| contains a "text/plain" item |textItem|, then: + 1. For each |representation| in |itemTypeList|: - 1. Set |textData| to be a copy of |textItem|'s string data + 1. If |representation|'s [=representation/MIME type=] contains "text/plain", then: - 1. Resolve |p| with |textData|. + 1. Let |p1| be the |representation|'s [=representation/data=]. - 1. Return |p|. + 1. [=promise/React=] to |p1|: + + 1. If |p1| was fulfilled with value |v|, then: + + 1. If |v| is a {{DOMString}}, then follow the below steps: + + 1. Resolve |p| with |v|. + + 1. If |v| is a {{Blob}}, then follow the below steps: + + 1. Let |blobData| be a {{DOMString}} created using |v|'s {{Blob/text()}}. + + 1. Resolve |p| with |blobData|. + + 1. If |p1| was rejected, then: + + 1. [=Reject=] |p| with {{"NotFoundError"}} {{DOMException}} in |realm|. + + 1. [=Reject=] |p| with {{"NotFoundError"}} {{DOMException}} in |realm|. + + 1. Return |p|.
@@ -875,11 +900,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: - 1. Let |itemList| be an empty [=sequence=]<{{Blob}}>. - - 1. Let |cleanItemList| be an empty [=/record=]<{{DOMString}}, [=Promise=]<{{Blob}}>>. - - 1. Let |clipboardItemList| be an empty [=clipboard items=]. + 1. Let |itemList| and |cleanItemList| be an empty [=sequence=]<{{Blob}}>. 1. For each |clipboardItem| in |data|: @@ -923,22 +944,14 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Return |p|. - 1. Let |p2| be [=a new promise=] in |realm|. - - 1. Resolve |p2| with |cleanItem|. - - 1. Append |cleanItem|'s {{Blob/type}} as the key and |p2| as value to |cleanItemList|. + 1. Append |cleanItem| to |cleanItemList|. 1. Let |option| be |clipboardItem|'s [=ClipboardItem/clipboard item=]'s [=presentation style=]. - 1. Let |cleanClipboarditem| be the result of running the steps of {{ClipboardItem/ClipboardItem()}} given |cleanItemList| and |option|. - - 1. Add |cleanClipboarditem| to |clipboardItemList|. + 1. [=write blobs and option to the clipboard=] with |cleanItemList| and |option|. - 1. Replace the [=system clipboard data=] with |clipboardItemList|. - - Note: Writing multiple [=/clipboard item=]s to the clipboard is only supported on MacOS. - For other platforms, only the first [=/clipboard item=] should be written to the clipboard. + Note: Writing multiple [=/clipboard item=]s to the clipboard is only supported on MacOS. + For other platforms, only the first [=/clipboard item=] should be written to the clipboard. 1. Resolve |p|. @@ -1577,6 +1590,57 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
+
+

write blobs and option to the clipboard

+ + : Input + :: |items|, a [=sequence=]<{{Blob}}> list of {{Blob}}s to write + :: |option|, a [=ClipboardItem/clipboard item=]'s [=presentation style=] + + : Output + :: None + + 1. If the |items| list is not empty, then + + 1. For each |item| in |items|: + + 1. If data type is text/plain, then + + 1. Ensure encoding is correct per OS and locale conventions + + 1. Normalize line endings according to platform conventions + + 1. Place text on clipboard with the appropriate OS clipboard + format description + + 1. Set the [=presentation style=] to |option|. + + 1. Else, if data is of a type listed in the + [=mandatory data types=] list, then + + 1. Place |item| on clipboard with the appropriate OS clipboard + format description + + 1. Set the [=presentation style=] to |option|. + + 1. Else + + 1. This is left to the implementation... + + Issue: It's not good to leave things up to the + implementation. What should happen here? + + Note: Due to limitations in the implementation of operating + system clipboards, scripts should not assume that custom + formats will be available to other applications on the + system. For example, there is a limit to how many custom + clipboard formats can be registered in Microsoft Windows. + While it is possible to use any string for + setData()'s type argument, sticking to the + [=mandatory data types=] is strongly recommended. + +
+

fire a clipboard event

From 9c96efc3f47573fc16a662ed75e2111c4f39a040 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Wed, 5 Jan 2022 17:15:38 -0800 Subject: [PATCH 22/31] Address review comments. --- index.bs | 97 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/index.bs b/index.bs index 0ad852e..4a1640f 100644 --- a/index.bs +++ b/index.bs @@ -619,7 +619,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; For example, if a user copies a range of cells from a spreadsheet of a native application, it will result in one [=/clipboard item=]. If a user copies a set of files from their desktop, that list of files will be represented by multiple [=/clipboard item=]s.

- Some platforms may support having more than one [=/clipboard item=] at a time on the [=Clipboard=], while other platforms replace the previous [=/clipboard item=] with the new one. + Some platforms may support having more than one [=/clipboard item=] at a time on the [=clipboard=], while other platforms replace the previous [=/clipboard item=] with the new one. A [=/clipboard item=] has a list of representations, each representation with an associated mime type (a [=/MIME type=]) and data (a {{ClipboardItemData}}). @@ -706,17 +706,17 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |representation|'s [=representation/MIME type=] is |mimeType|, then: - 1. Let |p1| be the |representation|'s [=representation/data=]. + 1. Let |representationDataPromise| be the |representation|'s [=representation/data=]. - 1. [=promise/React=] to |p1|: + 1. [=promise/React=] to |representationDataPromise|: - 1. If |p1| was fulfilled with value |v|, then: + 1. If |representationDataPromise| was fulfilled with value |v|, then: 1. If |v| is a {{DOMString}}, then follow the below steps: - 1. Let |v1| be the result of [=/encoding=] |v|. + 1. Let |dataAsBytes| be the result of [=UTF-8 encoding=] |v|. - 1. Let |blobData| be a {{Blob}} created using |v1| with its {{Blob/type}} set to |mimeType|, [=serialize a MIME type|serialized=]. + 1. Let |blobData| be a {{Blob}} created using |dataAsBytes| with its {{Blob/type}} set to |mimeType|, [=serialize a MIME type|serialized=]. 1. Resolve |p| with |blobData|. @@ -724,10 +724,12 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Resolve |p| with |v|. - 1. If |p1| was rejected, then: + 1. If |representationDataPromise| was rejected, then: 1. [=Reject=] |p| with {{"NotFoundError"}} {{DOMException}} in |realm|. + 1. Return |p|. + 1. [=Reject=] |p| with {{"NotFoundError"}} {{DOMException}} in |realm|. 1. Return |p|. @@ -746,16 +748,16 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; }; - A Clipboard's read() and write() methods must support Clipboard Items that has one or more [=/clipboard item=]s. + The methods of the {{Clipboard}} interface take or return multiple {{ClipboardItem}} objects, and their specification is written to deal with the generic case. 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 clipboard, which is a [=clipboard=]. + A clipboard items object is a [=sequence=] of [=/clipboard item=]s.

- Writing multiple [=/clipboard item=]s to the clipboard is only supported on Apple platforms such as iOS/iPadOS. For other platforms, only the first [=/clipboard item=] should be written to the clipboard. + A web author needs to create a |data| which is an array of {{ClipboardItem}}s in order to write content to [=system clipboard=] using the {{Clipboard/write(data)}} method. + {{Clipboard/read()}} returns a [=Promise=] to [=clipboard items=] object that represents contents of [=system clipboard=].

- A web author needs to create a |data| which is a [=Clipboard items=] object in order to write content to [=system clipboard=] using the {{Clipboard/write(data)}} method. - {{Clipboard/read()}} returns a [=Promise=] to [=Clipboard items=] object that represents contents of [=system clipboard=]. - A [=/clipboard item=] can be read from [=clipboard items=]. - The clipboard task source is triggered in response to reading or writing of [=system clipboard data=].
@@ -832,7 +834,7 @@ 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 item=]. + 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. 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: @@ -840,13 +842,13 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. For each |representation| in |itemTypeList|: - 1. If |representation|'s [=representation/MIME type=] contains "text/plain", then: + 1. If |representation|'s [=representation/MIME type=] [=MIME type/essence=] is "text/plain", then: - 1. Let |p1| be the |representation|'s [=representation/data=]. + 1. Let |representationDataPromise| be the |representation|'s [=representation/data=]. - 1. [=promise/React=] to |p1|: + 1. [=promise/React=] to |representationDataPromise|: - 1. If |p1| was fulfilled with value |v|, then: + 1. If |representationDataPromise| was fulfilled with value |v|, then: 1. If |v| is a {{DOMString}}, then follow the below steps: @@ -854,11 +856,11 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |v| is a {{Blob}}, then follow the below steps: - 1. Let |blobData| be a {{DOMString}} created using |v|'s {{Blob/text()}}. + 1. Let |string| be the result of [=UTF-8 decoding=] |v|'s underlying byte sequence. - 1. Resolve |p| with |blobData|. + 1. Resolve |p| with |string|. - 1. If |p1| was rejected, then: + 1. If |representationDataPromise| was rejected, then: 1. [=Reject=] |p| with {{"NotFoundError"}} {{DOMException}} in |realm|. @@ -888,9 +890,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |r| be the result of running [=check clipboard write permission=]. - Note: Clipboard permission is not supported on Safari. However, the write() method must be called inside - a user gesture event and the user must select the paste option from the native context menu that pops up - when write() is called from JS, otherwise, the promise will be rejected. + Note: Clipboard permission is not supported on Safari. However, the write() method must be called inside + a user gesture event and the user must select the paste option from the native context menu that pops up + when write() is called from JS, otherwise, the promise will be rejected. 1. If |r| is false, then: @@ -902,31 +904,33 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |itemList| and |cleanItemList| be an empty [=sequence=]<{{Blob}}>. + 1. If |data|'s [=list/size=] is greater than 1, and the current operating system does not support multiple [=/clipboard item=]s on the [=system clipboard data=], then set |data| to « |data|[0] ». + 1. For each |clipboardItem| in |data|: - 1. For each |item| in |clipboardItem|'s [=ClipboardItem/clipboard item=]'s [=list of representations=]: + 1. For each |representation| in |clipboardItem|'s [=ClipboardItem/clipboard item=]'s [=list of representations=]: - 1. Let |p1| be the |item|'s [=representation/data=]. + 1. Let |representationDataPromise| be the |representation|'s [=representation/data=]. - 1. [=promise/React=] to |p1|: + 1. [=promise/React=] to |representationDataPromise|: - 1. If |p1| was fulfilled with value |v|, then: + 1. If |representationDataPromise| was fulfilled with value |v|, then: 1. If |v| is a {{DOMString}}, then follow the below steps: - 1. Let |v1| be the result of [=/encoding=] |v|. + 1. Let |dataAsBytes| be the result of [=UTF-8 encoding=] |v|. - 1. Let |blobData| be a {{Blob}} created using |v1| with its {{Blob/type}} set to |mimeType|, [=serialize a MIME type|serialized=]. + 1. Let |blobData| be a {{Blob}} created using |dataAsBytes| with its {{Blob/type}} set to |representation|'s [=representation/MIME type=]. 1. Add |blobData| to |itemList|. 1. If |v| is a {{Blob}}, then add |v| to |itemList|. - 1. If |p1| was rejected, then: + 1. If |representationDataPromise| was rejected, then: 1. [=Reject=] |p| with {{"NotAllowedError"}} {{DOMException}} in |realm|. - 1. Return |p|. + 1. Abort these steps. 1. For each |blob| in |itemList|: @@ -942,16 +946,13 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. [=Reject=] |p| with {{"NotAllowedError"}} DOMException in |realm|. - 1. Return |p|. + 1. Abort these steps. 1. Append |cleanItem| to |cleanItemList|. 1. Let |option| be |clipboardItem|'s [=ClipboardItem/clipboard item=]'s [=presentation style=]. - 1. [=write blobs and option to the clipboard=] with |cleanItemList| and |option|. - - Note: Writing multiple [=/clipboard item=]s to the clipboard is only supported on MacOS. - For other platforms, only the first [=/clipboard item=] should be written to the clipboard. + 1. [=Write blobs and option to the clipboard=] with |cleanItemList| and |option|. 1. Resolve |p|. @@ -982,9 +983,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |r| be the result of running [=check clipboard write permission=]. - Note: Clipboard permission is not supported on Safari. However, the writeText() method must be called inside - a user gesture event and the user must select the paste option from the native context menu that pops up - when writeText() is called from JS, otherwise, the promise will be rejected. + Note: Clipboard permission is not supported on Safari. However, the writeText() method must be called inside + a user gesture event and the user must select the paste option from the native context menu that pops up + when writeText() is called from JS, otherwise, the promise will be rejected. 1. If |r| is false, then: @@ -994,16 +995,16 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: - 1. Let |newItemList| be empty [=clipboard items=]. + 1. Let |newItemList| be empty [=/list=] of [=/clipboard item=]s. 1. Let |textBlob| be a new {{Blob}} created with: - [=type=] attribute set to text/plain;charset=utf-8, and - [=blobParts=] set to a sequence containing the string |data|. + {{Blob/type}} attribute set to "text/plain;charset=utf-8", and + its underlying byte sequence set to the [=UTF-8 encoding=] of |data|. 1. Let |newItem| be a new [=/clipboard item=] created with a single [=representation=]: - [=representation/MIME type=] attribute set to text/plain8, and - [=representation/data=] set to |textBlob|. + [=representation/MIME type=] set to the result of [=parse a MIME type|parsing=] "text/plain;charset=utf-8", and + [=representation/data=] set to [=a promise resolved with=] |textBlob|. 1. Add |newItem| to |newItemList|. @@ -1595,7 +1596,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; : Input :: |items|, a [=sequence=]<{{Blob}}> list of {{Blob}}s to write - :: |option|, a [=ClipboardItem/clipboard item=]'s [=presentation style=] + :: |presentationStyle|, a [=ClipboardItem/clipboard item=]'s [=presentation style=] : Output :: None @@ -1613,7 +1614,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Place text on clipboard with the appropriate OS clipboard format description - 1. Set the [=presentation style=] to |option|. + 1. Set the [=presentation style=] to |presentationStyle|. 1. Else, if data is of a type listed in the [=mandatory data types=] list, then @@ -1621,7 +1622,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Place |item| on clipboard with the appropriate OS clipboard format description - 1. Set the [=presentation style=] to |option|. + 1. Set the [=presentation style=] to |presentationStyle|. 1. Else From eb8c313b226e571b512509bdb64d30183932ee06 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Thu, 6 Jan 2022 14:25:19 -0800 Subject: [PATCH 23/31] Address PR comments. --- index.bs | 119 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 92 insertions(+), 27 deletions(-) diff --git a/index.bs b/index.bs index 4a1640f..34205bc 100644 --- a/index.bs +++ b/index.bs @@ -904,7 +904,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |itemList| and |cleanItemList| be an empty [=sequence=]<{{Blob}}>. - 1. If |data|'s [=list/size=] is greater than 1, and the current operating system does not support multiple [=/clipboard item=]s on the [=system clipboard data=], then set |data| to « |data|[0] ». + 1. If |data|'s [=list/size=] is greater than 1, and the current operating system does not support multiple [=/clipboard item=]s on the [=system clipboard data=], then set |data| to |data|[0]. 1. For each |clipboardItem| in |data|: @@ -1601,44 +1601,109 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; : Output :: None - 1. If the |items| list is not empty, then + 1. For each |item| in |items|: - 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 data type is text/plain, then + 1. If |formatString| is empty then abort these steps. - 1. Ensure encoding is correct per OS and locale conventions + 1. Let |payload| be the result of [=UTF-8 decoding=] |item|'s underlying byte sequence. - 1. Normalize line endings according to platform conventions + 1. Insert |payload| and |presentationStyle| into the [=system clipboard=] using |formatString| as the native clipboard format. - 1. Place text on clipboard with the appropriate OS clipboard - format description - - 1. Set the [=presentation style=] to |presentationStyle|. +
- 1. Else, if data is of a type listed in the - [=mandatory data types=] list, then +
+

os specific well-known format

- 1. Place |item| on clipboard with the appropriate OS clipboard - format description + : Input + :: |mimeType|, a {{Blob/type}} - 1. Set the [=presentation style=] to |presentationStyle|. + : Output + :: |wellKnownFormat|, a platform specific string type. On Mac it's NSString, on Windows and Linux it is fetched from the atom table. - 1. Else +

+ For Windows see https://docs.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats + For Mac see https://developer.apple.com/documentation/appkit/nspasteboardtype +

- 1. This is left to the implementation... + 1. Let |wellKnownFormat| be a string. - Issue: It's not good to leave things up to the - implementation. What should happen here? + 1. If |mimeType|'s [=MIME type/essence=] is "text/plain", then - Note: Due to limitations in the implementation of operating - system clipboards, scripts should not assume that custom - formats will be available to other applications on the - system. For example, there is a limit to how many custom - clipboard formats can be registered in Microsoft Windows. - While it is possible to use any string for - setData()'s type argument, sticking to the - [=mandatory data types=] is strongly recommended. + On Windows, follow the convention described below: + + 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. Else + + 1. This is left to the implementation... + + Issue: It's not good to leave things up to the + implementation. What should happen here? + + Note: Due to limitations in the implementation of operating + system clipboards, scripts should not assume that custom + formats will be available to other applications on the + system. For example, there is a limit to how many custom + clipboard formats can be registered in Microsoft Windows. + While it is possible to use any string for + setData()'s type argument, sticking to the + [=mandatory data types=] is strongly recommended.
From 8b475d5aeb83de4913a7e5670229f14b60ff4e2c Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Tue, 18 Jan 2022 17:41:11 -0800 Subject: [PATCH 24/31] Address PR comments. --- index.bs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/index.bs b/index.bs index 34205bc..e68b899 100644 --- a/index.bs +++ b/index.bs @@ -592,7 +592,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
clipboardItem = new ClipboardItem([items, options])
- Creates a new {{ClipboardItem}} object. items are used to fill its MIME types and [=Promise=]s to {{Blob}}s or {{DOMString}}s corresponding to the MIME types, options can be used to fill its {{ClipboardItemOptions}}, + Creates a new {{ClipboardItem}} object. items denote [=list of representations=], each [=representation=] has a [=representation/mime type=] and a [=Promise=] to {{Blob}} or {{DOMString}} corresponding to the [=representation/mime type=], options can be used to fill its {{ClipboardItemOptions}}, as per the example below.
@@ -604,16 +604,16 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
 				
clipboardItem.getType(type) -

Returns a [=Promise=] to the {{Blob}} corresponding to type.

+

Returns a [=Promise=] to the {{Blob}} corresponding to the [=representation/mime type=] type.

clipboardItem.types -

Returns the list of types contained in the clipboardItem object. +

Returns the list of [=representation/mime type=]s contained in the [=/clipboard item=] object.

Clipboard Item

- A clipboard item is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or "copy" command. + A clipboard item is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or "copy" command. A [=/clipboard item=] serves two purposes. First, it allows a website to read data copied by a user to the system clipboard. Second, it allows a website to write data to the system clipboard.

For example, if a user copies a range of cells from a spreadsheet of a native application, it will result in one [=/clipboard item=]. If a user copies a set of files from their desktop, that list of files will be represented by multiple [=/clipboard item=]s. @@ -633,16 +633,21 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; Making the range of cells available as an image will allow the user to paste the cells into a photo editing app, while the text/plain format can be used by text editor apps.

- A [=/clipboard item=] can also optionally have a presentation style that helps distinguish whether apps "pasting" a [=/clipboard item=] should insert the contents of an appropriate [=representation=] inline at the point of paste or if it should be treated as an attachment. + A [=/clipboard item=] has a presentation style (a {{PresentationStyle}}). It helps distinguish whether apps "pasting" a [=/clipboard item=] should insert the contents of an appropriate [=representation=] inline at the point of paste or if it should be treated as an attachment. - Apps that support pasting only a single [=/clipboard item=] should use the first [=/clipboard item=]. - Apps that support pasting more than one [=/clipboard item=] could, for example, provide a user interface that previews the contents of each [=/clipboard item=] and allow the user to choose which one to paste. + Web apps that support pasting only a single [=/clipboard item=] should use the first [=/clipboard item=]. + +

+ {{Clipboard/write()}} chooses the last [=/clipboard item=]. +

+ + Web apps that support pasting more than one [=/clipboard item=] could, for example, provide a user interface that previews the contents of each [=/clipboard item=] and allow the user to choose which one to paste. 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 clipboard item, which is a [=/clipboard item=]. - A {{ClipboardItem}} object has an associated types array, which is a {{FrozenArray}}. + A {{ClipboardItem}} object has an associated types array, which is a {{FrozenArray}}<{{DOMString}}>. To create a {{ClipboardItem}} object, given a [=/clipboard item=] |clipboardItem| and a Realm |realm|, run these steps: 1. Let |clipboardItemObject| be a [=new=] {{ClipboardItem}} with |realm|. @@ -728,6 +733,8 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. [=Reject=] |p| with {{"NotFoundError"}} {{DOMException}} in |realm|. + Issue: Web developers might be interested in the underlying rejection reason. + 1. Return |p|. 1. [=Reject=] |p| with {{"NotFoundError"}} {{DOMException}} in |realm|. @@ -748,9 +755,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; }; - The methods of the {{Clipboard}} interface take or return multiple {{ClipboardItem}} objects, and their specification is written to deal with the generic case. 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. + 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 clipboard, which is a [=clipboard=]. + A {{Clipboard}} object has an associated clipboard. A clipboard items object is a [=sequence=] of [=/clipboard item=]s.

@@ -838,6 +845,8 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: + 1. If |data|'s [=list/size=] is greater than 1, and the current operating system does not support multiple [=/clipboard item=]s on the [=system clipboard data=], then set |data| to |data|[0]. + 1. Let |itemTypeList| be |data|'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. 1. For each |representation| in |itemTypeList|: From c2f9c3878993040bedf411962a7b91662e0234b9 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Fri, 21 Jan 2022 18:03:42 -0800 Subject: [PATCH 25/31] Address PR comments. --- index.bs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.bs b/index.bs index e68b899..c0ebda3 100644 --- a/index.bs +++ b/index.bs @@ -611,8 +611,6 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; -

Clipboard Item

- A clipboard item is conceptually data that the user has expressed a desire to make shareable by invoking a "cut" or "copy" command. A [=/clipboard item=] serves two purposes. First, it allows a website to read data copied by a user to the system clipboard. Second, it allows a website to write data to the system clipboard.

@@ -1604,7 +1602,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

write blobs and option to the clipboard

: Input - :: |items|, a [=sequence=]<{{Blob}}> list of {{Blob}}s to write + :: |items|, a [=sequence=]<{{Blob}}> :: |presentationStyle|, a [=ClipboardItem/clipboard item=]'s [=presentation style=] : Output @@ -1632,7 +1630,8 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; :: |wellKnownFormat|, a platform specific string type. On Mac it's NSString, on Windows and Linux it is fetched from the atom table.

- For Windows see https://docs.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats + For Windows see https://docs.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats and + https://docs.microsoft.com/en-us/windows/win32/dataxchg/about-atom-tables?redirectedfrom=MSDN For Mac see https://developer.apple.com/documentation/appkit/nspasteboardtype

From 5ab3eabd5b38d4b53f26dd181200dca11280cebc Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Tue, 1 Feb 2022 15:26:53 -0800 Subject: [PATCH 26/31] Address comments. --- index.bs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/index.bs b/index.bs index c0ebda3..b893302 100644 --- a/index.bs +++ b/index.bs @@ -843,9 +843,13 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: - 1. If |data|'s [=list/size=] is greater than 1, and the current operating system does not support multiple [=/clipboard item=]s on the [=system clipboard data=], then set |data| to |data|[0]. + 1. Let |dataList| be a [=sequence=]<{{ClipboardItem}}>. - 1. Let |itemTypeList| be |data|'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. + 1. If |data|'s [=list/size=] is greater than 1, then add |data|[0] to |dataList|. + + Issue: when |data| contains multiple items and the operating system supports multiple clipboard items, the current algorithm writes the items in sequence to the system clipboard instead of writing them collectively. That is, the last item replaces the previous ones. + + 1. Let |itemTypeList| be |dataList|'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. 1. For each |representation| in |itemTypeList|: @@ -911,9 +915,13 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |itemList| and |cleanItemList| be an empty [=sequence=]<{{Blob}}>. - 1. If |data|'s [=list/size=] is greater than 1, and the current operating system does not support multiple [=/clipboard item=]s on the [=system clipboard data=], then set |data| to |data|[0]. + 1. Let |dataList| be a [=sequence=]<{{ClipboardItem}}>. + + 1. If |data|'s [=list/size=] is greater than 1, and the current operating system does not support multiple [=/clipboard item=]s on the [=system clipboard data=], then add |data|[0] to |dataList|, else, set |dataList| to |data|. + + Issue: when |data| contains multiple items and the operating system supports multiple clipboard items, the current algorithm writes the items in sequence to the system clipboard instead of writing them collectively. That is, the last item replaces the previous ones. - 1. For each |clipboardItem| in |data|: + 1. For each |clipboardItem| in |dataList|: 1. For each |representation| in |clipboardItem|'s [=ClipboardItem/clipboard item=]'s [=list of representations=]: @@ -1002,20 +1010,17 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. [=Queue a global task=] on the [=clipboard task source=], given |realm|'s [=Realm/global object=], to perform the below steps: - 1. Let |newItemList| be empty [=/list=] of [=/clipboard item=]s. + 1. Let |itemList| be an empty [=sequence=]<{{Blob}}>. 1. Let |textBlob| be a new {{Blob}} created with: {{Blob/type}} attribute set to "text/plain;charset=utf-8", and its underlying byte sequence set to the [=UTF-8 encoding=] of |data|. - 1. Let |newItem| be a new [=/clipboard item=] created with a single - [=representation=]: - [=representation/MIME type=] set to the result of [=parse a MIME type|parsing=] "text/plain;charset=utf-8", and - [=representation/data=] set to [=a promise resolved with=] |textBlob|. + 1. Add |textBlob| to |itemList|. - 1. Add |newItem| to |newItemList|. + 1. Let |option| be set to "unspecified". - 1. Replace the [=system clipboard data=] with |newItemList|. + 1. [=Write blobs and option to the clipboard=] with |itemList| and |option|. 1. Resolve |p|. @@ -1627,7 +1632,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; :: |mimeType|, a {{Blob/type}} : Output - :: |wellKnownFormat|, a platform specific string type. On Mac it's NSString, on Windows and Linux it is fetched from the atom table. + :: |wellKnownFormat|, a platform specific string type. On Mac it's NSPasteboardType, on Windows it's LPCWSTR and Linux it's a const char*.

For Windows see https://docs.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats and From 4f9b71c29f745ee427b6aeed71e2211e94b801cd Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Wed, 2 Feb 2022 10:47:57 -0800 Subject: [PATCH 27/31] Address comments. --- index.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.bs b/index.bs index b893302..9700d30 100644 --- a/index.bs +++ b/index.bs @@ -847,7 +847,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |data|'s [=list/size=] is greater than 1, then add |data|[0] to |dataList|. - Issue: when |data| contains multiple items and the operating system supports multiple clipboard items, the current algorithm writes the items in sequence to the system clipboard instead of writing them collectively. That is, the last item replaces the previous ones. + Issue: when |data| contains multiple items and the operating system supports multiple native clipboard items, the current algorithm writes the items in sequence to the system clipboard instead of writing them collectively. That is, the last item replaces the previous ones. 1. Let |itemTypeList| be |dataList|'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. @@ -917,9 +917,9 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |dataList| be a [=sequence=]<{{ClipboardItem}}>. - 1. If |data|'s [=list/size=] is greater than 1, and the current operating system does not support multiple [=/clipboard item=]s on the [=system clipboard data=], then add |data|[0] to |dataList|, else, set |dataList| to |data|. + 1. If |data|'s [=list/size=] is greater than 1, and the current operating system does not support multiple native clipboard items on the [=system clipboard=], then add |data|[0] to |dataList|, else, set |dataList| to |data|. - Issue: when |data| contains multiple items and the operating system supports multiple clipboard items, the current algorithm writes the items in sequence to the system clipboard instead of writing them collectively. That is, the last item replaces the previous ones. + Issue: when |data| contains multiple items and the operating system supports multiple native clipboard items, the current algorithm writes the items in sequence to the system clipboard instead of writing them collectively. That is, the last item replaces the previous ones. 1. For each |clipboardItem| in |dataList|: From 9694d17d17c2d31c8f7ce40d6bc465117754a3e2 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Fri, 4 Feb 2022 09:58:45 -0800 Subject: [PATCH 28/31] Address comments. --- index.bs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/index.bs b/index.bs index 9700d30..609e54b 100644 --- a/index.bs +++ b/index.bs @@ -778,10 +778,6 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |r| be the result of running [=check clipboard read permission=]. - Note: Clipboard permission is not supported on Safari. However, the read() method must be called inside - a user gesture event and the user must select the paste option from the native context menu that pops up - when read() is called from JS, otherwise, the promise will be rejected. - 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|. @@ -829,10 +825,6 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |r| be the result of running [=check clipboard read permission=]. - Note: Clipboard permission is not supported on Safari. However, the readText() method must be called inside - a user gesture event and the user must select the paste option from the native context menu that pops up - when readText() is called from JS, otherwise, the promise will be rejected. - 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|. @@ -919,7 +911,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. If |data|'s [=list/size=] is greater than 1, and the current operating system does not support multiple native clipboard items on the [=system clipboard=], then add |data|[0] to |dataList|, else, set |dataList| to |data|. - Issue: when |data| contains multiple items and the operating system supports multiple native clipboard items, the current algorithm writes the items in sequence to the system clipboard instead of writing them collectively. That is, the last item replaces the previous ones. + Issue: when |data| contains multiple items and the operating system supports multiple native clipboard items, the current algorithm writes the items in sequence to the system clipboard instead of writing them collectively. 1. For each |clipboardItem| in |dataList|: @@ -1015,6 +1007,8 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |textBlob| be a new {{Blob}} created with: {{Blob/type}} attribute set to "text/plain;charset=utf-8", and its underlying byte sequence set to the [=UTF-8 encoding=] of |data|. + + Note: On Windows replace `\n` characters with `\r\n` in |data| before creating |textBlob|. 1. Add |textBlob| to |itemList|. From fd317bace1246e33fdb715f7db9cb5acfebe096b Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Mon, 14 Feb 2022 17:47:37 -0800 Subject: [PATCH 29/31] Address comments. --- index.bs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/index.bs b/index.bs index 609e54b..f928eed 100644 --- a/index.bs +++ b/index.bs @@ -653,6 +653,10 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Set |clipboardItemObject|'s [=/clipboard item=] to |clipboardItem|. The new ClipboardItem(items, options) constructor steps are: + 1. If |items| is empty, then throw a {{TypeError}}. + + 1. If |options| is empty, then set |options| to "unspecified". + 1. Set [=this=]'s [=ClipboardItem/clipboard item=] to a new [=/clipboard item=]. 1. Set [=this=]'s [=ClipboardItem/clipboard item=]'s [=presentation style=] to |options|["{{ClipboardItemOptions/presentationStyle}}"]. @@ -789,6 +793,8 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 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}}>. @@ -833,13 +839,15 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 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. + 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 |dataList| be a [=sequence=]<{{ClipboardItem}}>. 1. If |data|'s [=list/size=] is greater than 1, then add |data|[0] to |dataList|. - Issue: when |data| contains multiple items and the operating system supports multiple native clipboard items, the current algorithm writes the items in sequence to the system clipboard instead of writing them collectively. That is, the last item replaces the previous ones. + Issue: Reading multiple clipboard items should be fixed in https://github.com/w3c/clipboard-apis/issues/166. 1. Let |itemTypeList| be |dataList|'s [=ClipboardItem/clipboard item=]'s [=list of representations=]. @@ -893,9 +901,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |r| be the result of running [=check clipboard write permission=]. - Note: Clipboard permission is not supported on Safari. However, the write() method must be called inside - a user gesture event and the user must select the paste option from the native context menu that pops up - when write() is called from JS, otherwise, the promise will be rejected. + Issue: clipboard-write was removed in https://github.com/w3c/clipboard-apis/pull/164. 1. If |r| is false, then: @@ -990,9 +996,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Let |r| be the result of running [=check clipboard write permission=]. - Note: Clipboard permission is not supported on Safari. However, the writeText() method must be called inside - a user gesture event and the user must select the paste option from the native context menu that pops up - when writeText() is called from JS, otherwise, the promise will be rejected. + Issue: clipboard-write was removed in https://github.com/w3c/clipboard-apis/pull/164. 1. If |r| is false, then: From 02c7b2babc95879c67412e38c6cb94b09a8de63d Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Tue, 1 Mar 2022 14:08:28 -0800 Subject: [PATCH 30/31] Address PR comments. --- index.bs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/index.bs b/index.bs index f928eed..ff9423c 100644 --- a/index.bs +++ b/index.bs @@ -560,7 +560,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

From 0ab5153a41117f1b0a5085b3ef3ad5b41bc28d86 Mon Sep 17 00:00:00 2001 From: Anupam Snigdha Date: Wed, 2 Mar 2022 09:15:13 -0800 Subject: [PATCH 31/31] Address comment. --- index.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.bs b/index.bs index ff9423c..18c366d 100644 --- a/index.bs +++ b/index.bs @@ -802,7 +802,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. For each [=/clipboard item=] |underlyingItem| of |data|: - 1. Let |item| be the result of running the steps of [=create a ClipboardItem object=] given |underlyingItem|. + 1. Let |item| be the result of running the steps of [=create a ClipboardItem object=] given |underlyingItem| and |realm|. 1. Append |item| to |items|. @@ -1624,7 +1624,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; 1. Insert |payload| and |presentationStyle| into the [=system clipboard=] using |formatString| as the native clipboard format. - Issue: some OSs contain multiple clipboard (e.g. Linux, "primary", "secondary", "selection"). Define from which of those data is written. + Issue: some OSs contain multiple clipboard (e.g. Linux, "primary", "secondary", "selection"). Define to which of those data is written.