mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Add types. Fix tsd check env. Improve in-code doc comments
This commit is contained in:
parent
ef32d876de
commit
b43d93e69d
17
src/clipboard.d.ts
vendored
17
src/clipboard.d.ts
vendored
@ -2,11 +2,7 @@
|
||||
|
||||
type Action = 'cut' | 'copy';
|
||||
type Response = 'success' | 'error';
|
||||
|
||||
type Options = {
|
||||
text?: string;
|
||||
action?: Action;
|
||||
target?: Element;
|
||||
type CopyActionOptions = {
|
||||
container?: Element;
|
||||
};
|
||||
|
||||
@ -38,6 +34,17 @@ declare class ClipboardJS {
|
||||
* Checks if clipboard.js is supported
|
||||
*/
|
||||
static isSupported(): boolean;
|
||||
|
||||
|
||||
/**
|
||||
* Fires a copy action
|
||||
*/
|
||||
static copy(target: string | Element, options: CopyActionOptions): string;
|
||||
|
||||
/**
|
||||
* Fires a cut action
|
||||
*/
|
||||
static cut(target: string | Element): string;
|
||||
}
|
||||
|
||||
declare namespace ClipboardJS {
|
||||
|
@ -111,10 +111,21 @@ class Clipboard extends Emitter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow fire programmatically a copy action
|
||||
* @param {Element} target
|
||||
* @param {Object} options
|
||||
* @returns Text copied.
|
||||
*/
|
||||
static copy(target, options = { container: document.body }) {
|
||||
return ClipboardActionCopy(target, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow fire programmatically a cut action
|
||||
* @param {Element} target
|
||||
* @returns Text cutted.
|
||||
*/
|
||||
static cut(target) {
|
||||
return ClipboardActionCut(target);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { expectType } from 'tsd';
|
||||
import Clipboard from './clipboard';
|
||||
import * as Clipboard from './clipboard';
|
||||
|
||||
expectType<Clipboard>(new Clipboard('.btn'));
|
||||
|
Loading…
Reference in New Issue
Block a user