Simple module exposing copy(input: text)
function that would try to use execCommand with fallback to IE specific clipboardData
interface and finally, fallback to simple prompt with proper text content & 'Copy to clipboard: Ctrl+C, Enter'
import copy from 'copy-to-clipboard';
copy('Text');
# Copy with options
copy('Text', {
debug: true,
message: 'Press ⌘-C to copy',
});
copy(input: text, options)
- tries to copy text to clipboard.
Value | Default | Notes |
---|---|---|
options.debug | false | Boolean . Optional. Enable output to console. |
options.message | Copy to clipboard: Ctrl+C, Enter | String . Optional. Prompt message. |
Works everywhere where there's prompt
available. Works best (i.e. without additional keystrokes) in Chrome and, supposedly, IE. FF support to come soon-ish.
Note: not working on IOS atm