This package has been deprecated

Author message:

Please migrate to https://github.com/lgarron/clipboard-polyfill

clipboard-js
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/clipboard-js package

0.3.6 • Public • Published

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);

Package Sidebar

Install

npm i clipboard-js

Weekly Downloads

16,237

Version

0.3.6

License

MIT

Last publish

Collaborators

  • lgarron