styfle/copee


📄 Copy text from browser to clipboard...natively! < 1kB

https://copee.ceriously.com

License: MIT

Language: TypeScript

Keywords: browser-api, clipboard, copy, text


copee

npm size install size Downloads Dependency Status devDependency Status Build Status

Copy text from browser to clipboard...natively! Less than 1 kB!

Have you ever wanted to send a string to the user's clipboard? Front-end developers have invented many hacks to get around this limitation...until now!

Introducing copee, a micro-wrapper around the browser's native "copy text" API 🗜️

Death to Adobe Flash 💀

Demo

Try the demo to see copee in action!

You can view the page source to quickly learn how to use it.

Also, read this blog post for some background.

Browser ESM Usage

<script type="module">
  import { toClipboard } from 'https://cdn.jsdelivr.net/npm/copee/dist/copee.mjs';

  document.getElementById('btn').addEventListener('click', () => {
    const success = toClipboard('Wow, "copee" works via ES Modules!');
    if (success) {
      // it worked, check your clipboard!
    }
  });
</script>

Browser UMD Usage

<script src="https://cdn.jsdelivr.net/npm/copee/dist/copee.umd.js"></script>
<script type="text/javascript">
  document.getElementById('btn').addEventListener('click', function () {
    var success = copee.toClipboard('Wow, "copee" works!');
    if (success) {
      // it worked, check your clipboard!
    }
  });
</script>

Browser Suppport

  • UMD (.js) supports IE 11+, Chrome 43+, Opera 29+, and Firefox 41+
  • ESM (.mjs) supports Chrome 61+, Safari 10.1+, Edge 16+, and Firefox 60+

Prior Art

This package was influenced by the following:

Authors

Developed by ceriously.com

Project Statistics

Sourcerank 7
Repository Size 162 KB
Stars 81
Forks 3
Watchers 2
Open issues 0
Dependencies 7
Contributors 7
Tags 16
Created
Last updated
Last pushed

Top Contributors See all

Steven dependabot-bot dependabot-preview[bot] dependabot[bot] Andrew Usher

Packages Referencing this Repo

copee
Copy text from browser to clipboard...natively!
Latest release 1.0.6 - Published - 81 stars
copee
Copy text from browser to clipboard...natively! < 1kB
Latest release 1.0.6 - Updated - 81 stars

Recent Tags See all

1.0.6 June 03, 2019
v1.0.6 December 20, 2018
v1.0.5 April 03, 2018
v1.0.4 March 12, 2018
v1.0.3 December 12, 2017
v1.0.2 December 02, 2017
v1.0.1 November 13, 2017
v1.0.0 October 14, 2017
v0.1.6 October 14, 2017
v0.1.5 October 14, 2017
v0.1.4 October 14, 2017
v0.1.3 October 14, 2017
v0.1.2 October 14, 2017
v0.1.1 October 14, 2017
v0.1.0 October 13, 2017

Something wrong with this page? Make a suggestion

Last synced: 2019-12-04 15:32:08 UTC

Login to resync this repository