File tree Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ Notable changes to this project are documented in this file. The format is based
6
6
7
7
Breaking changes:
8
8
9
+ - ` clipboard ` now returns ` Effect (Maybe Clipboard) ` instead of ` Effect Clipboard ` .
10
+ This is because insecure contexts don't have the clipboard available, see
11
+ [ MDN] ( https://developer.mozilla.org/en-US/docs/Web/API/Navigator/clipboard ) .
12
+
9
13
New features:
10
14
11
15
Bugfixes:
Original file line number Diff line number Diff line change 1
- export function clipboard ( navigator ) {
1
+ export function clipboardWrapper ( just , nothing , navigator ) {
2
2
return function ( ) {
3
- return navigator . clipboard ;
3
+ var clp = navigator . clipboard ;
4
+ if ( typeof clp === "undefined" ) {
5
+ // This is expected if we don't have a SecureContext (see w3 spec).
6
+ return nothing ;
7
+ } else {
8
+ return just ( clp ) ;
9
+ }
4
10
} ;
5
11
}
6
12
Original file line number Diff line number Diff line change 1
- module Web.Clipboard where
1
+ module Web.Clipboard
2
+ ( clipboard
3
+ , Clipboard
4
+ , toEventTarget
5
+ , fromEventTarget
6
+ , readText
7
+ , writeText
8
+ ) where
2
9
3
10
import Prelude
4
11
5
- import Data.Maybe (Maybe )
12
+ import Data.Function.Uncurried (Fn3 , runFn3 )
13
+ import Data.Maybe (Maybe (..))
6
14
import Effect (Effect )
7
15
import Promise (Promise )
8
16
import Unsafe.Coerce (unsafeCoerce )
9
17
import Web.Event.Internal.Types (EventTarget )
10
18
import Web.HTML (Navigator )
11
19
import Web.Internal.FFI (unsafeReadProtoTagged )
12
20
13
- foreign import clipboard :: Navigator -> Effect Clipboard
21
+ foreign import clipboardWrapper :: Fn3 (forall a . a -> Maybe a ) (forall a . Maybe a ) Navigator (Effect (Maybe Clipboard ))
22
+
23
+ clipboard :: Navigator -> Effect (Maybe Clipboard )
24
+ clipboard = runFn3 clipboardWrapper Just Nothing
14
25
15
26
foreign import data Clipboard :: Type
16
27
You can’t perform that action at this time.
0 commit comments