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