Skip to content

Commit 26cb6be

Browse files
nicklockwoodfacebook-github-bot-6
authored andcommitted
Open sourced RCTPasteboard
Summary: public RCTPasteboard is a very basic API for writing strings to the pasteboard. Useful for implementing "copy to clipboard" functionality. Reviewed By: astreet Differential Revision: D2663875 fb-gh-sync-id: 8d0ecd824c3e9fe135b02201d21d0dab1907c329
1 parent 3c5f3b1 commit 26cb6be

5 files changed

Lines changed: 54 additions & 6 deletions

File tree

React/Modules/RCTPasteboard.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#import "RCTBridgeModule.h"
11+
12+
@interface RCTPasteboard : NSObject <RCTBridgeModule>
13+
14+
@end

React/Modules/RCTPasteboard.m

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#import "RCTPasteboard.h"
11+
12+
#import <UIKit/UIKit.h>
13+
14+
@implementation RCTPasteboard
15+
16+
RCT_EXPORT_MODULE()
17+
18+
- (dispatch_queue_t)methodQueue
19+
{
20+
return dispatch_get_main_queue();
21+
}
22+
23+
RCT_EXPORT_METHOD(setPasteboardString:(NSString *)string)
24+
{
25+
[[UIPasteboard generalPasteboard] setString:string];
26+
}
27+
28+
@end

React/React.xcodeproj/project.pbxproj

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
13B0801D1A69489C00A75B9A /* RCTNavItemManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B080131A69489C00A75B9A /* RCTNavItemManager.m */; };
3939
13B080201A69489C00A75B9A /* RCTActivityIndicatorViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B080191A69489C00A75B9A /* RCTActivityIndicatorViewManager.m */; };
4040
13B080261A694A8400A75B9A /* RCTWrapperViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B080241A694A8400A75B9A /* RCTWrapperViewController.m */; };
41+
13B202011BFB945300C07393 /* RCTPasteboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B202001BFB945300C07393 /* RCTPasteboard.m */; };
42+
13B202041BFB948C00C07393 /* RCTPointAnnotation.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B202031BFB948C00C07393 /* RCTPointAnnotation.m */; };
4143
13C156051AB1A2840079392D /* RCTWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 13C156021AB1A2840079392D /* RCTWebView.m */; };
4244
13C156061AB1A2840079392D /* RCTWebViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13C156041AB1A2840079392D /* RCTWebViewManager.m */; };
4345
13CC8A821B17642100940AE7 /* RCTBorderDrawing.m in Sources */ = {isa = PBXBuildFile; fileRef = 13CC8A811B17642100940AE7 /* RCTBorderDrawing.m */; };
@@ -69,7 +71,6 @@
6971
58114A171AAE854800E7D092 /* RCTPickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A151AAE854800E7D092 /* RCTPickerManager.m */; };
7072
58114A501AAE93D500E7D092 /* RCTAsyncLocalStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 58114A4E1AAE93D500E7D092 /* RCTAsyncLocalStorage.m */; };
7173
58C571C11AA56C1900CDF9C8 /* RCTDatePickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 58C571BF1AA56C1900CDF9C8 /* RCTDatePickerManager.m */; };
72-
63F014C01B02080B003B75D2 /* RCTPointAnnotation.m in Sources */ = {isa = PBXBuildFile; fileRef = 63F014BF1B02080B003B75D2 /* RCTPointAnnotation.m */; };
7374
830A229E1A66C68A008503DA /* RCTRootView.m in Sources */ = {isa = PBXBuildFile; fileRef = 830A229D1A66C68A008503DA /* RCTRootView.m */; };
7475
832348161A77A5AA00B55238 /* Layout.c in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FC71A68125100A75B9A /* Layout.c */; };
7576
83392EB31B6634E10013B15F /* RCTModalHostViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83392EB21B6634E10013B15F /* RCTModalHostViewController.m */; };
@@ -170,6 +171,10 @@
170171
13B080191A69489C00A75B9A /* RCTActivityIndicatorViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTActivityIndicatorViewManager.m; sourceTree = "<group>"; };
171172
13B080231A694A8400A75B9A /* RCTWrapperViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTWrapperViewController.h; sourceTree = "<group>"; };
172173
13B080241A694A8400A75B9A /* RCTWrapperViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTWrapperViewController.m; sourceTree = "<group>"; };
174+
13B201FF1BFB945300C07393 /* RCTPasteboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPasteboard.h; sourceTree = "<group>"; };
175+
13B202001BFB945300C07393 /* RCTPasteboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTPasteboard.m; sourceTree = "<group>"; };
176+
13B202021BFB948C00C07393 /* RCTPointAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPointAnnotation.h; sourceTree = "<group>"; };
177+
13B202031BFB948C00C07393 /* RCTPointAnnotation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTPointAnnotation.m; sourceTree = "<group>"; };
173178
13C156011AB1A2840079392D /* RCTWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTWebView.h; sourceTree = "<group>"; };
174179
13C156021AB1A2840079392D /* RCTWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTWebView.m; sourceTree = "<group>"; };
175180
13C156031AB1A2840079392D /* RCTWebViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTWebViewManager.h; sourceTree = "<group>"; };
@@ -231,8 +236,6 @@
231236
58114A4F1AAE93D500E7D092 /* RCTAsyncLocalStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAsyncLocalStorage.h; sourceTree = "<group>"; };
232237
58C571BF1AA56C1900CDF9C8 /* RCTDatePickerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDatePickerManager.m; sourceTree = "<group>"; };
233238
58C571C01AA56C1900CDF9C8 /* RCTDatePickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDatePickerManager.h; sourceTree = "<group>"; };
234-
63F014BE1B02080B003B75D2 /* RCTPointAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPointAnnotation.h; sourceTree = "<group>"; };
235-
63F014BF1B02080B003B75D2 /* RCTPointAnnotation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTPointAnnotation.m; sourceTree = "<group>"; };
236239
6A15FB0C1BDF663500531DFB /* RCTRootViewInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRootViewInternal.h; sourceTree = "<group>"; };
237240
830213F31A654E0800B993E6 /* RCTBridgeModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTBridgeModule.h; sourceTree = "<group>"; };
238241
830A229C1A66C68A008503DA /* RCTRootView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRootView.h; sourceTree = "<group>"; };
@@ -314,8 +317,8 @@
314317
13A0C2881B74F71200B29F6F /* RCTDevMenu.m */,
315318
13B07FE91A69327A00A75B9A /* RCTExceptionsManager.h */,
316319
13B07FEA1A69327A00A75B9A /* RCTExceptionsManager.m */,
317-
63F014BE1B02080B003B75D2 /* RCTPointAnnotation.h */,
318-
63F014BF1B02080B003B75D2 /* RCTPointAnnotation.m */,
320+
13B201FF1BFB945300C07393 /* RCTPasteboard.h */,
321+
13B202001BFB945300C07393 /* RCTPasteboard.m */,
319322
13F17A831B8493E5007D4C75 /* RCTRedBox.h */,
320323
13F17A841B8493E5007D4C75 /* RCTRedBox.m */,
321324
000E6CE91AB0E97F000CDF4D /* RCTSourceCode.h */,
@@ -361,6 +364,8 @@
361364
83392EB21B6634E10013B15F /* RCTModalHostViewController.m */,
362365
83A1FE8D1B62643A00BE0E65 /* RCTModalHostViewManager.h */,
363366
83A1FE8E1B62643A00BE0E65 /* RCTModalHostViewManager.m */,
367+
13B202021BFB948C00C07393 /* RCTPointAnnotation.h */,
368+
13B202031BFB948C00C07393 /* RCTPointAnnotation.m */,
364369
13B0800C1A69489C00A75B9A /* RCTNavigator.h */,
365370
13B0800D1A69489C00A75B9A /* RCTNavigator.m */,
366371
13B0800E1A69489C00A75B9A /* RCTNavigatorManager.h */,
@@ -610,12 +615,14 @@
610615
13723B501A82FD3C00F88898 /* RCTStatusBarManager.m in Sources */,
611616
000E6CEB1AB0E980000CDF4D /* RCTSourceCode.m in Sources */,
612617
133CAE8E1B8E5CFD00F6AD92 /* RCTDatePicker.m in Sources */,
618+
13B202011BFB945300C07393 /* RCTPasteboard.m in Sources */,
613619
14C2CA761B3AC64F00E6CBB2 /* RCTFrameUpdate.m in Sources */,
614620
13B07FEF1A69327A00A75B9A /* RCTAlertManager.m in Sources */,
615621
83CBBACC1A6023D300E9B192 /* RCTConvert.m in Sources */,
616622
131B6AF41AF1093D00FFC3E0 /* RCTSegmentedControl.m in Sources */,
617623
830A229E1A66C68A008503DA /* RCTRootView.m in Sources */,
618624
13B07FF01A69327A00A75B9A /* RCTExceptionsManager.m in Sources */,
625+
13B202041BFB948C00C07393 /* RCTPointAnnotation.m in Sources */,
619626
13A0C28A1B74F71200B29F6F /* RCTDevMenu.m in Sources */,
620627
14C2CA711B3AC63800E6CBB2 /* RCTModuleMethod.m in Sources */,
621628
13CC8A821B17642100940AE7 /* RCTBorderDrawing.m in Sources */,
@@ -670,7 +677,6 @@
670677
58114A171AAE854800E7D092 /* RCTPickerManager.m in Sources */,
671678
13B0801A1A69489C00A75B9A /* RCTNavigator.m in Sources */,
672679
137327E71AA5CF210034F82E /* RCTTabBar.m in Sources */,
673-
63F014C01B02080B003B75D2 /* RCTPointAnnotation.m in Sources */,
674680
13F17A851B8493E5007D4C75 /* RCTRedBox.m in Sources */,
675681
83392EB31B6634E10013B15F /* RCTModalHostViewController.m in Sources */,
676682
14435CE51AAC4AE100FC20F4 /* RCTMap.m in Sources */,

0 commit comments

Comments
 (0)