1.3.3 • Published 3 months ago

@clairelizbet/copy-to-clipboard v1.3.3

Weekly downloads
-
License
CC0-1.0
Repository
github
Last release
3 months ago

Copy to Clipboard

Small (~600 bytes minified+gzipped) script for copying text to the clipboard.

It uses the modern Clipboard API and falls back to the deprecated execCommand method as needed.

Installation

npm install @clairelizbet/copy-to-clipboard

You can also find the latest compiled and minified version on the current release page.

Usage

The script is written as a module, with named exports.

  • copyToClipboard(text: string) - Copies using the best available method (Clipboard or Selection API)
  • copyToClipboardViaSelection(text: string) - Copies using the legacy Selection API
import { copyToClipboard } from "@clairelizbet/copy-to-clipboard"
import { copyToClipboardViaSelection } from "@clairelizbet/copy-to-clipboard"

These methods are asynchronous and may throw an Error if the copy command is rejected so it's a good idea to have error handling.

License

CC0 Public Domain

1.3.3

3 months ago

1.3.2

3 months ago

1.3.1

8 months ago

1.3.0

9 months ago

1.2.0

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.0

9 months ago