Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
org.webjars.npm:copy-to-clipboard
Advanced tools
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.
import copy from 'copy-to-clipboard';
copy('Text');
// Copy with options
copy('Text', {
debug: true,
message: 'Press #{key} to copy',
});
copy(text: string, options: object): boolean
— tries to copy text to clipboard. Returns true
if no additional keystrokes were required from user (so, execCommand
, IE's clipboardData
worked) or false
.
Value | Default | Notes |
---|---|---|
options.debug | false | Boolean . Optional. Enable output to console. |
options.message | Copy to clipboard: #{key} , Enter | String . Optional. Prompt message. * |
options.format | "text/html" | String . Optional. Set the MIME type of what you want to copy as. Use text/html to copy as HTML, text/plain to avoid inherited styles showing when pasted into rich text editor. |
options.onCopy | null | function onCopy(clipboardData: object): void . Optional. Receives the clipboardData element for adding custom behavior such as additional formats |
*
all occurrences of #{key}
are replaced with ⌘+C
for macOS/iOS users, and Ctrl+C
otherwise.
Works everywhere where prompt
* is available. Works best (i.e. without additional keystrokes) in Chrome, FF, Safari 10+, and, supposedly, IE/Edge.
Note: does not work on some older iOS devices.
*
– even though Safari 8 has prompt
, you cannot specify prefilled content for prompt modal – thus it doesn't work as expected.
npm i --save copy-to-clipboard
<script src="https://wzrd.in/standalone/copy-to-clipboard@latest" async></script>
You will have window.copyToClipboard
exposed for you to use.
This project has some automated tests, that will run using nightwatch on top of selenium.
npm i
npm test
This library has built-in Typescript definitions.
import * as copy from 'copy-to-clipboard';
FAQs
WebJar for copy-to-clipboard
We found that org.webjars.npm:copy-to-clipboard demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.