forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clipboard.d.ts
56 lines (48 loc) · 1.58 KB
/
clipboard.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Type definitions for clipboard.js 1.5.9
// Project: https://github.com/zenorocha/clipboard.js
// Definitions by: Andrei Kurosh <https://github.com/impworks>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class Clipboard {
constructor(selector: (string | Element | NodeListOf<Element>), options?: ClipboardOptions);
/**
* Subscribes to events that indicate the result of a copy/cut operation.
* @param type {String} Event type ('success' or 'error').
* @param handler Callback function.
*/
on(type: "success", handler: (e: ClipboardEvent) => void): this;
on(type: "error", handler: (e: ClipboardEvent) => void): this;
on(type: string, handler: (e: ClipboardEvent) => void): this;
/**
* Clears all event bindings.
*/
destroy(): void;
}
interface ClipboardOptions {
/**
* Overwrites default command ('cut' or 'copy').
* @param {Element} elem Current element
* @returns {String} Only 'cut' or 'copy'.
*/
action?: (elem: Element) => string;
/**
* Overwrites default target input element.
* @param {Element} elem Current element
* @returns {Element} <input> element to use.
*/
target?: (elem: Element) => Element;
/**
* Returns the explicit text to copy.
* @param {Element} elem Current element
* @returns {String} Text to be copied.
*/
text?: (elem: Element) => string;
}
interface ClipboardEvent {
action: string;
text: string;
trigger: Element;
clearSelection(): void;
}
declare module 'clipboard' {
export = Clipboard;
}