Package Exports
- copy-to-clipboard
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (copy-to-clipboard) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Copy to clipboard 
Simple module exposing copy function that will try to use execCommand with fallback to IE-specific clipboardData interface and finally, resort to usual prompt with proper text content and message.
Example
import copy from 'copy-to-clipboard';
copy('Text');
// Copy with options
copy('Text', {
debug: true,
message: 'Press #{key} to copy',
});API
copy(text: string, options: object): void — tries to copy text to clipboard.
| Value | Default | Notes |
|---|---|---|
| options.debug | false | Boolean. Optional. Enable output to console. |
| options.message | Copy to clipboard: #{key}, Enter |
String. Optional. Prompt message. * |
* all occurrences of #{key} are replaced with ⌘+C for macOS/iOS users, and Ctrl+C otherwise.
Browser support
Works everywhere where prompt is available. Works best (i.e. without additional keystrokes) in Chrome, FF and, supposedly, IE/Edge.
Note: does not work on some older iOS devices.
Installation
- Can be used as npm package and then leveraged using commonjs bundler/loader:
npm i --save copy-to-clipboard- Can be utilized using wzrd.in. Add following script to your page:
<script src="https://wzrd.in/standalone/copy-to-clipboard@latest" async></script>You will have window.copyToClipboard exposed for you to use.
UI components based on this package:
See also:
Running Tests
This project has some automated tests, that will run using nightwatch on top of selenium.
npm i
npm test