File tree Expand file tree Collapse file tree 4 files changed +57
-1
lines changed Expand file tree Collapse file tree 4 files changed +57
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,17 @@ Bugfixes:
12
12
13
13
Other improvements:
14
14
15
+ ## [ v4.1.0] ( https://github.com/purescript-web/purescript-web-clipboard/releases/tag/v4.1.0 ) - 2022-07-14
16
+
17
+ Breaking changes:
18
+
19
+ New features:
20
+ - Added partial ` Clipboard ` interface implementation with ` readText ` and ` writeText ` operations (#11 by @garyb )
21
+
22
+ Bugfixes:
23
+
24
+ Other improvements:
25
+
15
26
## [ v4.0.0] ( https://github.com/purescript-web/purescript-web-clipboard/releases/tag/v4.0.0 ) - 2022-04-27
16
27
17
28
Breaking changes:
Original file line number Diff line number Diff line change 15
15
" package.json"
16
16
],
17
17
"dependencies" : {
18
- "purescript-web-html" : " ^4.0.0"
18
+ "purescript-web-html" : " ^4.0.0" ,
19
+ "purescript-web-promise" : " purescript-web/purescript-web-promise#^3.0.0"
19
20
}
20
21
}
Original file line number Diff line number Diff line change
1
+ export function clipboard ( navigator ) {
2
+ return function ( ) {
3
+ return navigator . clipboard ;
4
+ } ;
5
+ }
6
+
7
+ export function readText ( clipboard ) {
8
+ return function ( ) {
9
+ return clipboard . readText ( ) ;
10
+ } ;
11
+ }
12
+
13
+ export function writeText ( text ) {
14
+ return function ( clipboard ) {
15
+ return function ( ) {
16
+ return clipboard . writeText ( text ) ;
17
+ } ;
18
+ } ;
19
+ }
Original file line number Diff line number Diff line change
1
+ module Web.Clipboard where
2
+
3
+ import Prelude
4
+
5
+ import Data.Maybe (Maybe )
6
+ import Effect (Effect )
7
+ import Unsafe.Coerce (unsafeCoerce )
8
+ import Web.Event.Internal.Types (EventTarget )
9
+ import Web.HTML (Navigator )
10
+ import Web.Internal.FFI (unsafeReadProtoTagged )
11
+ import Web.Promise (Promise )
12
+
13
+ foreign import clipboard :: Navigator -> Effect Clipboard
14
+
15
+ foreign import data Clipboard :: Type
16
+
17
+ toEventTarget :: Clipboard -> EventTarget
18
+ toEventTarget = unsafeCoerce
19
+
20
+ fromEventTarget :: EventTarget -> Maybe Clipboard
21
+ fromEventTarget = unsafeReadProtoTagged " Clipboard"
22
+
23
+ foreign import readText :: Clipboard -> Effect (Promise String )
24
+
25
+ foreign import writeText :: String -> Clipboard -> Effect (Promise Unit )
You can’t perform that action at this time.
0 commit comments