-
-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps: Migrate to @react-native-clipboard/clipboard
`Clipboard` in RN core is deprecated; see warning at https://reactnative.dev/docs/clipboard We've reportedly been getting console warnings that we should use @react-native-community/clipboard instead of the RN-core module. Do basically that, except we use its new name, @react-native-clipboard/clipboard; see react-native-clipboard/clipboard#87 Put the types in a .js.flow file, rather than a libdef in `flow-typed/`, inspired by Greg's commit 007dea3. Supersedes: #4502 Co-authored-by: rajprakash00 <rajprakash1999@gmail.com>
- Loading branch information
1 parent
dc5ab4c
commit 3d9cd20
Showing
10 changed files
with
184 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/** | ||
* Flowtype definitions for Clipboard | ||
* Generated by Flowgen from a Typescript Definition | ||
* Flowgen v1.11.0 | ||
* | ||
* @flow strict-local | ||
*/ | ||
|
||
import type EmitterSubscription from 'react-native/Libraries/vendor/emitter/_EmitterSubscription'; | ||
|
||
/** | ||
* `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android | ||
*/ | ||
declare var Clipboard: { | ||
/** | ||
* Get content of string type, this method returns a `Promise`, so you can use following code to get clipboard content | ||
* ```javascript | ||
* async _getContent() { | ||
* var content = await Clipboard.getString(); | ||
* } | ||
* ``` | ||
*/ | ||
getString(): Promise<string>, | ||
|
||
/** | ||
* Get clipboard image as PNG in base64, this method returns a `Promise`, so you can use following code to get clipboard content | ||
* ```javascript | ||
* async _getContent() { | ||
* var content = await Clipboard.getImagePNG(); | ||
* } | ||
* ``` | ||
*/ | ||
getImagePNG(): Promise<string>, | ||
|
||
/** | ||
* Get clipboard image as JPG in base64, this method returns a `Promise`, so you can use following code to get clipboard content | ||
* ```javascript | ||
* async _getContent() { | ||
* var content = await Clipboard.getImageJPG(); | ||
* } | ||
* ``` | ||
*/ | ||
getImageJPG(): Promise<string>, | ||
|
||
/** | ||
* Set content of base64 image type. You can use following code to set clipboard content | ||
* ```javascript | ||
* _setContent() { | ||
* Clipboard.setImage(...); | ||
* } | ||
* | ||
* iOS only | ||
* ``` | ||
* @param the content to be stored in the clipboard. | ||
*/ | ||
setImage(content: string): void, | ||
getImage(): Promise<string>, | ||
|
||
/** | ||
* Set content of string type. You can use following code to set clipboard content | ||
* ```javascript | ||
* _setContent() { | ||
* Clipboard.setString('hello world'); | ||
* } | ||
* ``` | ||
* @param the content to be stored in the clipboard. | ||
*/ | ||
setString(content: string): void, | ||
|
||
/** | ||
* Returns whether the clipboard has content or is empty. | ||
* This method returns a `Promise`, so you can use following code to get clipboard content | ||
* ```javascript | ||
* async _hasContent() { | ||
* var hasContent = await Clipboard.hasString(); | ||
* } | ||
* ``` | ||
*/ | ||
hasString(): $FlowFixMe, // `any` in TypeScript upstream :( | ||
|
||
/** | ||
* Returns whether the clipboard has an image or is empty. | ||
* This method returns a `Promise`, so you can use following code to check clipboard content | ||
* ```javascript | ||
* async _hasContent() { | ||
* var hasContent = await Clipboard.hasImage(); | ||
* } | ||
* ``` | ||
*/ | ||
hasImage(): $FlowFixMe, // `any` in TypeScript upstream :( | ||
|
||
/** | ||
* (IOS Only) | ||
* Returns whether the clipboard has a URL content. Can check | ||
* if there is a URL content in clipboard without triggering PasteBoard notification for iOS 14+ | ||
* This method returns a `Promise`, so you can use following code to check for url content in clipboard. | ||
* ```javascript | ||
* async _hasURL() { | ||
* var hasURL = await Clipboard.hasURL(); | ||
* } | ||
* ``` | ||
*/ | ||
hasURL(): $FlowFixMe, // `any` in TypeScript upstream :( | ||
|
||
/** | ||
* (IOS 14+ Only) | ||
* Returns whether the clipboard has a Number(UIPasteboardDetectionPatternNumber) content. Can check | ||
* if there is a Number content in clipboard without triggering PasteBoard notification for iOS 14+ | ||
* This method returns a `Promise`, so you can use following code to check for Number content in clipboard. | ||
* ```javascript | ||
* async _hasNumber() { | ||
* var hasNumber = await Clipboard.hasNumber(); | ||
* } | ||
* ``` | ||
*/ | ||
hasNumber(): $FlowFixMe, // `any` in TypeScript upstream :( | ||
|
||
/** | ||
* (IOS 14+ Only) | ||
* Returns whether the clipboard has a WebURL(UIPasteboardDetectionPatternProbableWebURL) content. Can check | ||
* if there is a WebURL content in clipboard without triggering PasteBoard notification for iOS 14+ | ||
* This method returns a `Promise`, so you can use following code to check for WebURL content in clipboard. | ||
* ```javascript | ||
* async _hasWebURL() { | ||
* var hasWebURL = await Clipboard.hasWebURL(); | ||
* } | ||
* ``` | ||
*/ | ||
hasWebURL(): $FlowFixMe, // `any` in TypeScript upstream :( | ||
|
||
/** | ||
* (iOS and Android Only) | ||
* Adds a listener to get notifications when the clipboard has changed. | ||
* If this is the first listener, turns on clipboard notifications on the native side. | ||
* It returns EmitterSubscription where you can call "remove" to remove listener | ||
* ```javascript | ||
* const listener = () => console.log("changed!"); | ||
* Clipboard.addListener(listener); | ||
* ``` | ||
*/ | ||
addListener(callback: () => void): EmitterSubscription, | ||
|
||
/** | ||
* (iOS and Android Only) | ||
* Removes all previously registered listeners and turns off notifications on the native side. | ||
* ```javascript | ||
* Clipboard.removeAllListeners(); | ||
* ``` | ||
*/ | ||
removeAllListeners(): void, | ||
... | ||
}; | ||
|
||
export default Clipboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters