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.
@stianlarsen/copy-to-clipboard
Advanced tools
Readme
A robust, easy-to-use utility for copying text to the clipboard with a simple function call. Perfect for developers looking to implement a copy-to-clipboard feature in their web applications with minimal effort.
Using npm:
npm install @stianlarsen/copy-to-clipboard
Or using yarn:
yarn add @stianlarsen/copy-to-clipboard
Import the copy
function and use it to copy text to the clipboard. You can also provide an optional callback function to execute upon successful copy:
import { copy } from "@stianlarsen/copy-to-clipboard";
const yourCallbackFunction = () => {
console.log("Text successfully copied to clipboard!");
};
function App() {
return (
<button onClick={() => copy("Text to copy", yourCallbackFunction)}>
Copy to Clipboard
</button>
);
}
import { copy } from "@stianlarsen/copy-to-clipboard";
// Example function to call the copy functionality
function copyText() {
const textToCopy = "Hello, clipboard!";
copy(textToCopy, () => {
console.log("Text successfully copied to clipboard!");
});
}
// Trigger the copy function
copyText();
Designed to work in modern browsers with full support for the asynchronous Clipboard API. Includes a fallback mechanism for older browsers.
There's no direct customization required for this utility, but it seamlessly integrates into any web application, allowing for customized button or trigger implementation for the copy action.
Contributions to @stianlarsen/copy-to-clipboard
are welcome!
@stianlarsen/copy-to-clipboard
is MIT licensed.
FAQs
A lightweight and modern JavaScript utility function to copy text to the clipboard in web browsers that support the Clipboard API (with fallback support). Ideal for use in web applications and React projects (Javascript).
The npm package @stianlarsen/copy-to-clipboard receives a total of 7 weekly downloads. As such, @stianlarsen/copy-to-clipboard popularity was classified as not popular.
We found that @stianlarsen/copy-to-clipboard demonstrated a healthy version release cadence and project activity because the last version was released less than 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.