1 |
|
2 |
|
3 | type Action = 'cut' | 'copy';
|
4 | type Response = 'success' | 'error';
|
5 |
|
6 | type Options = {
|
7 | text?: string;
|
8 | action?: Action;
|
9 | target?: Element;
|
10 | container?: Element;
|
11 | };
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | declare class ClipboardJS {
|
18 | constructor(
|
19 | selector: string | Element | NodeListOf<Element>,
|
20 | options?: ClipboardJS.Options
|
21 | );
|
22 |
|
23 | /**
|
24 | * Subscribes to events that indicate the result of a copy/cut operation.
|
25 | * @param type Event type ('success' or 'error').
|
26 | * @param handler Callback function.
|
27 | */
|
28 | on(type: Response, handler: (e: ClipboardJS.Event) => void): this;
|
29 |
|
30 | on(type: string, handler: (...args: any[]) => void): this;
|
31 |
|
32 | /**
|
33 | * Clears all event bindings.
|
34 | */
|
35 | destroy(): void;
|
36 |
|
37 | /**
|
38 | * Checks if clipboard.js is supported
|
39 | */
|
40 | static isSupported(): boolean;
|
41 | }
|
42 |
|
43 | declare namespace ClipboardJS {
|
44 | interface Options {
|
45 | |
46 |
|
47 |
|
48 |
|
49 | action?(elem: Element): Action;
|
50 |
|
51 | |
52 |
|
53 |
|
54 |
|
55 |
|
56 | target?(elem: Element): Element;
|
57 |
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 | text?(elem: Element): string;
|
64 |
|
65 | |
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | container?: Element;
|
72 | }
|
73 |
|
74 | interface Event {
|
75 | action: string;
|
76 | text: string;
|
77 | trigger: Element;
|
78 | clearSelection(): void;
|
79 | }
|
80 | }
|
81 |
|
82 | export = ClipboardJS;
|
83 |
|
84 | export as namespace ClipboardJS;
|