Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
copy-html-to-clipboard
Advanced tools
Readme
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.
Forked from copy-to-clipboard to add html support.
import copy from 'copy-html-to-clipboard';
copy('Text');
// Copy with options
copy('Text', {
debug: true,
message: 'Press #{key} to copy',
});
// Copy html
copy('<b>i am bold</b>', {
asHtml: true,
});
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.asHtml | false | Boolean . True - use param text as html. |
options.onlyHtml | false | Boolean . True - if can't copy html to clipboard, don't try to copy text with alternative ways. |
options.canUsePrompt | true | Boolean . True - try alternative ugly prompt-way. |
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.
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-html-to-clipboard
<script src="https://wzrd.in/standalone/copy-html-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
FAQs
Copy text/html into clipboard using JS
The npm package copy-html-to-clipboard receives a total of 2,179 weekly downloads. As such, copy-html-to-clipboard popularity was classified as popular.
We found that copy-html-to-clipboard demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.