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
66
77Breaking changes:
88
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+
913New features:
1014
1115Bugfixes:
Original file line number Diff line number Diff line change 1- export function clipboard ( navigator ) {
1+ export function clipboardWrapper ( just , nothing , navigator ) {
22 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+ }
410 } ;
511}
612
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
29
310import Prelude
411
5- import Data.Maybe (Maybe )
12+ import Data.Function.Uncurried (Fn3 , runFn3 )
13+ import Data.Maybe (Maybe (..))
614import Effect (Effect )
715import Promise (Promise )
816import Unsafe.Coerce (unsafeCoerce )
917import Web.Event.Internal.Types (EventTarget )
1018import Web.HTML (Navigator )
1119import Web.Internal.FFI (unsafeReadProtoTagged )
1220
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
1425
1526foreign import data Clipboard :: Type
1627
You can’t perform that action at this time.
0 commit comments