diff --git a/index.html b/index.html index eb17917..2630c11 100644 --- a/index.html +++ b/index.html @@ -92,6 +92,25 @@

display a picker or chooser dialog, allowing the user to select a target to share this title and the page URL to.

+

+ Calling {{Navigator/canShare()}} method with a {{ShareData}} dictionary + [=validate share data|validates=] the shared data. unlike + {{Navigator/share()}}, it can be called without [=transient + activation=]. +

+
+        const file = new File([], "some.png", { type: "image/png" });
+
+        // Check if files are supported
+        if (navigates.canShare({files: [file]})) {
+          // Sharing a png file would probably be ok...
+        }
+
+        // Check if a URL is ok to share...
+        if (navigates.canShare({ url: someURL })) {
+          // The URL is valid and can probably be shared...
+        }
+      

@@ -104,6 +123,8 @@

           partial interface Navigator {
             [SecureContext] Promise<undefined> share(optional ShareData data = {});
+
+            [SecureContext] boolean canShare(optional ShareData data = {});
           };
         

@@ -257,6 +278,25 @@

or bypassing the UI if there is only a single share target.

+
+

+ `canShare(data)` method +

+

+ When the canShare(data) method is called with argument + {{ShareData}} |data:ShareData|, run the following steps: +

+
    +
  1. If the [=current settings object=]'s [=environment settings + object/responsible document=] is not allowed to use + "web-share", return false. +
  2. +
  3. Return the result of [=validate share data=] with |data| and + [=this=]'s [=relevant settings object=]'s [=environment settings + object/API base URL=]. +
  4. +
+

Validate share data