1.0.8 ā€¢ Published 3 years ago

copy-to-clipbord-ultralight v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

copy-to-clipbord-ultralight

npm.io

A šŸš€ ultralight tool ( 596Byte ) that can copy a string to system clipboard.

āš ļø Only support modern browser.

šŸ”‘ UMD module & ESModule, offer .d.ts file to support Typescript.

Install

npm i copy-to-clipbord-ultralight

API

function ultralightCopy(sourceStr: string): boolean

DEMO

Check demo.html in Git for more detail.

import ultralightCopy from 'copy-to-clipbord-ultralight';
// const ultralightCopy = require('copy-to-clipbord-ultralight') // import as commonJS module

document.querySelector('#test').addEventListener('click',()=> {
   if (ultralightCopy('This is test string.')) {
     alert('success !')
   } else {
     alert('copy failed !')
   }
})
<script src="https://cdn.jsdelivr.net/npm/copy-to-clipbord-ultralight"></script>
<script>
  document.querySelector('#test').addEventListener('click',()=> {
    if (ultralightCopy('This is test string.')) {
      alert('success !')
    } else {
      alert('copy failed !')
    }
  })
</script>

Compatibility

We would try to use document.execCommand('copy') with NO FALLBACK. So this tool only support modern browser like Chrome, Edge, safari, etc.

You can check compatibility here https://caniuse.com/?search=execCommand%3A%20copy%20command

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago