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:
1212
1313Other improvements:
1414
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+
1526## [ v4.0.0] ( https://github.com/purescript-web/purescript-web-clipboard/releases/tag/v4.0.0 ) - 2022-04-27
1627
1728Breaking changes:
Original file line number Diff line number Diff line change 1515 " package.json"
1616 ],
1717 "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"
1920 }
2021}
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