clipboard
- Version 2.0.11
- Published
- 94.5 kB
- 3 dependencies
- MIT license
Install
npm i clipboard
yarn add clipboard
pnpm add clipboard
Overview
Modern copy to clipboard. No Flash. Just 2kb
Index
Classes
class ClipboardJS
class ClipboardJS {}
Base class which takes one or more elements, adds event listeners to them, and instantiates a new
ClipboardAction
on each click.
constructor
constructor( selector: string | Element | NodeListOf<Element>, options?: ClipboardJS.Options);
method copy
static copy: (target: string | Element, options?: CopyActionOptions) => string;
Fires a copy action
method cut
static cut: (target: string | Element) => string;
Fires a cut action
method destroy
destroy: () => void;
Clears all event bindings.
method isSupported
static isSupported: () => boolean;
Checks if clipboard.js is supported
method on
on: { (type: Response, handler: (e: ClipboardJS.Event) => void): this; (type: string, handler: (...args: any[]) => void): this;};
Subscribes to events that indicate the result of a copy/cut operation.
Parameter type
Event type ('success' or 'error').
Parameter handler
Callback function.
Interfaces
interface Event
interface Event {}
property action
action: string;
property text
text: string;
property trigger
trigger: Element;
method clearSelection
clearSelection: () => void;
interface Options
interface Options {}
property container
container?: Element;
For use in Bootstrap Modals or with any other library that changes the focus you'll want to set the focused element as the container value.
method action
action: (elem: Element) => Action;
Overwrites default command ('cut' or 'copy').
Parameter elem
Current element
method target
target: (elem: Element) => Element;
Overwrites default target input element.
Parameter elem
Current element
Returns
element to use.
method text
text: (elem: Element) => string;
Returns the explicit text to copy.
Parameter elem
Current element
Returns
Text to be copied.
Package Files (1)
Dependencies (3)
Dev Dependencies (25)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/clipboard
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/clipboard)
- HTML<a href="https://www.jsdocs.io/package/clipboard"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 1690 ms. - Missing or incorrect documentation? Open an issue for this package.