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:
17
src/clipboard.d.ts
vendored
17
src/clipboard.d.ts
vendored
@@ -2,11 +2,7 @@
|
|||||||
|
|
||||||
type Action = 'cut' | 'copy';
|
type Action = 'cut' | 'copy';
|
||||||
type Response = 'success' | 'error';
|
type Response = 'success' | 'error';
|
||||||
|
type CopyActionOptions = {
|
||||||
type Options = {
|
|
||||||
text?: string;
|
|
||||||
action?: Action;
|
|
||||||
target?: Element;
|
|
||||||
container?: Element;
|
container?: Element;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -38,6 +34,17 @@ declare class ClipboardJS {
|
|||||||
* Checks if clipboard.js is supported
|
* Checks if clipboard.js is supported
|
||||||
*/
|
*/
|
||||||
static isSupported(): boolean;
|
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 {
|
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 }) {
|
static copy(target, options = { container: document.body }) {
|
||||||
return ClipboardActionCopy(target, options);
|
return ClipboardActionCopy(target, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow fire programmatically a cut action
|
||||||
|
* @param {Element} target
|
||||||
|
* @returns Text cutted.
|
||||||
|
*/
|
||||||
static cut(target) {
|
static cut(target) {
|
||||||
return ClipboardActionCut(target);
|
return ClipboardActionCut(target);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { expectType } from 'tsd';
|
import { expectType } from 'tsd';
|
||||||
import Clipboard from './clipboard';
|
import * as Clipboard from './clipboard';
|
||||||
|
|
||||||
expectType<Clipboard>(new Clipboard('.btn'));
|
expectType<Clipboard>(new Clipboard('.btn'));
|
||||||
|
|||||||
Reference in New Issue
Block a user