clipboard-copy
Lightweight copy to clipboard for the web

clipboard-copy downloads clipboard-copy version clipboard-copy license

clipboard-copy類似套件:
npm下載趨勢
3 年
🌟 在 clipboard-copy 的 README.md 中顯示即時使用量圖表,只需複製下面的代碼。
## Usage Trend
[![Usage Trend of clipboard-copy](https://npm-compare.com/img/npm-trend/THREE_YEARS/clipboard-copy.png)](https://npm-compare.com/clipboard-copy#timeRange=THREE_YEARS)
Cumulative GitHub Star Trend
🌟 在 clipboard-copy 的 README.md 中顯示 GitHub stars 趨勢圖表,只需複製下面的代碼。
## GitHub Stars Trend
[![GitHub Stars Trend of clipboard-copy](https://npm-compare.com/img/github-trend/clipboard-copy.png)](https://npm-compare.com/clipboard-copy)
統計詳情
套件
下載數
Stars
大小
Issues
發布時間
許可
clipboard-copy483,566632-75 年前MIT
clipboard-copy 的 README

clipboard-copy travis npm downloads size javascript style guide

Lightweight copy to clipboard for the web

The goal of this package is to offer simple copy-to-clipboard functionality in modern web browsers using the fewest bytes. To do so, this package only supports modern browsers. No fallback using Adobe Flash, no hacks. Just 30 lines of code.

Unlike other implementations, text copied with clipboard-copy is clean and unstyled. Copied text will not inherit HTML/CSS styling like the page's background color.

Supported browsers: Chrome, Firefox, Edge, Safari.

Works in the browser with browserify!

install

npm install clipboard-copy

usage

const copy = require('clipboard-copy')

button.addEventListener('click', function () {
  copy('This is some cool text')
})

API

successPromise = copy(text)

Copy the given text to the user's clipboard. Returns successPromise, a promise that resolves if the copy was successful and rejects if the copy failed.

Note: in most browsers, copying to the clipboard is only allowed if copy() is triggered in direct response to a user gesture like a 'click' or a 'keypress'.

comparison to alternatives

testing

Testing this module is currently a manual process. Open test.html in your web browser and follow the short instructions. The web page will always load the latest version of the module, no bundling is necessary.

license

MIT. Copyright (c) Feross Aboukhadijeh.