Clipboard.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. * @flow strict-local
  9. */
  10. 'use strict';
  11. import NativeClipboard from './NativeClipboard';
  12. /**
  13. * `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
  14. */
  15. module.exports = {
  16. /**
  17. * Get content of string type, this method returns a `Promise`, so you can use following code to get clipboard content
  18. * ```javascript
  19. * async _getContent() {
  20. * var content = await Clipboard.getString();
  21. * }
  22. * ```
  23. */
  24. getString(): Promise<string> {
  25. return NativeClipboard.getString();
  26. },
  27. /**
  28. * Set content of string type. You can use following code to set clipboard content
  29. * ```javascript
  30. * _setContent() {
  31. * Clipboard.setString('hello world');
  32. * }
  33. * ```
  34. * @param the content to be stored in the clipboard.
  35. */
  36. setString(content: string) {
  37. NativeClipboard.setString(content);
  38. },
  39. };