-
-
Notifications
You must be signed in to change notification settings - Fork 235
/
index.d.ts
42 lines (32 loc) · 940 Bytes
/
index.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
/// <reference lib="dom"/>
export interface Options {
/**
Specify a DOM element where the temporary, behind-the-scenes `textarea` should be appended, in cases where you need to stay within a focus trap, like in a modal.
@default document.body
@example
```
import copy from 'copy-text-to-clipboard';
const modalWithFocusTrap = document.getElementById('modal');
button.addEventListener('click', () => {
copy('🦄🌈', {
target: modalWithFocusTrap
});
});
```
*/
readonly target?: HTMLElement;
}
/**
Copy text to the clipboard.
Must be called in response to a user gesture event, like `click` or `keyup`.
@param text - The text to copy to clipboard.
@returns Whether it succeeded to copy the text.
@example
```
import copy from 'copy-text-to-clipboard';
button.addEventListener('click', () => {
copy('🦄🌈');
});
```
*/
export default function copyTextToClipboard(text: string, options?: Options): boolean;