-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28789 from teneeto/ts-migration/clipboard
[No QA][TS migration] Migrate 'Clipboard' lib to TypeScript
- Loading branch information
Showing
5 changed files
with
77 additions
and
39 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
import Clipboard from '@react-native-clipboard/clipboard'; | ||
import {CanSetHtml, SetHtml, SetString} from './types'; | ||
|
||
/** | ||
* Sets a string on the Clipboard object via @react-native-clipboard/clipboard | ||
*/ | ||
const setString: SetString = (text) => { | ||
Clipboard.setString(text); | ||
}; | ||
|
||
// We don't want to set HTML on native platforms so noop them. | ||
const canSetHtml: CanSetHtml = () => false; | ||
const setHtml: SetHtml = () => {}; | ||
|
||
export default { | ||
setString, | ||
canSetHtml, | ||
setHtml, | ||
}; |
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,5 @@ | ||
type SetString = (text: string) => void; | ||
type SetHtml = (html: string, text: string) => void; | ||
type CanSetHtml = (() => (...args: ClipboardItems) => Promise<void>) | (() => boolean); | ||
|
||
export type {SetString, CanSetHtml, SetHtml}; |
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,11 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
/* eslint-disable @typescript-eslint/consistent-type-definitions */ | ||
declare module 'react-native-web' { | ||
class Clipboard { | ||
static isAvailable(): boolean; | ||
static getString(): Promise<string>; | ||
static setString(text: string): boolean; | ||
} | ||
|
||
export {Clipboard}; | ||
} |