https://github.com/dafrok/clip-it
A totally easy way for modern browsers to put something into clipboard.
https://github.com/dafrok/clip-it
Last synced: about 1 year ago
JSON representation
A totally easy way for modern browsers to put something into clipboard.
- Host: GitHub
- URL: https://github.com/dafrok/clip-it
- Owner: Dafrok
- License: mit
- Created: 2017-03-12T03:03:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-12T08:44:31.000Z (over 3 years ago)
- Last Synced: 2024-10-14T09:22:19.090Z (almost 2 years ago)
- Language: JavaScript
- Homepage: https://dafrok.github.io/clip-it
- Size: 747 KB
- Stars: 12
- Watchers: 2
- Forks: 4
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CLIP IT
A totally easy way for modern browsers to put something into clipboard.
[]()
[](https://www.npmjs.com/package/clip-it)
[](https://codecov.io/gh/Dafrok/clip-it)
[]()
## Try it Out
> [Demo by Codepen](https://codepen.io/Dafrok/full/jaQZME/)
## Installation
```bash
$ npm i --save clip-it
```
## Usage
### HTML
```html
Copy as Text
Copy as HTML
```
### JavaScript
```javascript
import clipIt from 'clip-it'
const $btnCopyText = document.querySelector('button')
const $btnCopyHTML = document.querySelector('button')
$btnCopyText.onclick = e => clipIt('Hello World'))
$btnCopyHTML.onclick = e => clipIt('Hello world!', {
contentType: 'text/html'
}))
```
## ATTENTION
- The `clip-it` API must be triggered in the same callstack with a trusted event.
- Some browsers only supports to copy plain text. (e.g. iOS Safari)