🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

clipboard-text

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clipboard-text

Simple and small copy-text-to-the-clipboard-utility with IE11 support

2.0.0
latest
npm
Version published
Maintainers
1
Created
Source

clipboard-text Build Status npm package

Simple and small copy-text-to-the-clipboard-utility with IE11 support

Installation

npm install clipboard-text

Usage

import copy from 'clipboard-text'

button.addEventListener('click', () => {
  copy('Hi there')
})

API

copy(text: string, parentElement?: Element): boolean

Copy text to the clipboard.

If the event triggering the copy functions comes from an element with a focus trap, like a Modal, you will need to provide a parentElement. By default, parentElement is set to body.

Returns a boolean of whether it succeeded to copy the text.

Must be called in response to a user gesture event, like click or keyup.

  • copy-text-to-clipboard - Original package with no support for IE and no support for focus traps

License

MIT

Keywords

copy

FAQs

Package last updated on 27 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts