Skip to content
/ clip-it Public

A totally easy way for modern browsers to put something into clipboard.

License

Notifications You must be signed in to change notification settings

Dafrok/clip-it

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLIP IT

A totally easy way for modern browsers to put something into clipboard.

build npm codecov license

Try it Out

Demo by Codepen

Installation

$ npm i --save clip-it

Usage

HTML

<button>Copy as Text</button>
<button>Copy as HTML</button>

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('<span style="color: red;">Hello world!</span>', {
  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)

About

A totally easy way for modern browsers to put something into clipboard.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published