🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

clipboard-js

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clipboard-js

A web shim to handle clipboard APIs across browsers using a simple Promise API.

0.3.6
latest
Version published
Weekly downloads
6.5K
-91.46%
Maintainers
1
Weekly downloads
 
Created

clipboard.js

This library has been superseded by clipboard-polyfill, which works in more browsers.

Here's how to migrate:

Plain Text

// clipboard.js
clipboard.copy("plain text");
// clipboard-polyfill
clipboard.writeText("plain text");

Rich Text

// clipboard.js
clipboard.copy({
  "text/plain": "Fallback markup text.",
  "text/html": "<i>Markup</i> <b>text</b>."
});
// clipboard-polyfill, similar to async clipboard API
var dt = new clipboard.DT();
dt.setData("text/plain", "Fallback markup text.");
dt.setData("text/html", "<i>Markup</i> <b>text</b>.");
clipboard.write(dt);

DOM element

// clipboard.js
clipboard.copy(document.body);
// clipboard-polyfill, similar to async clipboard API
var dt = new clipboard.DT();
dt.setData("text/plain", document.body.innerText);
dt.setData("text/html", new XMLSerializer().serializeToString(document.body));
clipboard.write(dt);

FAQs

Package last updated on 26 Oct 2017

Did you know?

Socket

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.

Install

Related posts