2015-06-25 16:07:19 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-12-09 18:00:19 +00:00
|
|
|
*
|
2016-02-15 18:04:45 +00:00
|
|
|
* @flow
|
2015-06-25 16:07:19 +00:00
|
|
|
*/
|
2015-12-09 18:00:19 +00:00
|
|
|
'use strict';
|
2015-06-25 16:07:19 +00:00
|
|
|
|
2016-02-15 18:04:45 +00:00
|
|
|
const Clipboard = require('NativeModules').Clipboard;
|
2016-01-20 18:53:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
|
|
|
|
*/
|
|
|
|
module.exports = {
|
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*/
|
2016-02-15 18:04:45 +00:00
|
|
|
getString(): Promise<string> {
|
2016-10-11 14:35:49 +00:00
|
|
|
return Clipboard.getString();
|
2016-01-20 18:53:59 +00:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Set content of string type. You can use following code to set clipboard content
|
|
|
|
* ```javascript
|
|
|
|
* _setContent() {
|
|
|
|
* Clipboard.setString('hello world');
|
|
|
|
* }
|
|
|
|
* ```
|
2016-01-26 18:29:47 +00:00
|
|
|
* @param the content to be stored in the clipboard.
|
2016-01-20 18:53:59 +00:00
|
|
|
*/
|
2016-02-15 18:04:45 +00:00
|
|
|
setString(content: string) {
|
2016-01-20 18:53:59 +00:00
|
|
|
Clipboard.setString(content);
|
|
|
|
}
|
|
|
|
};
|