Skip to content

Commit d0ea7e5

Browse files
committed
docs(sdk): add copyTextToClipboard and downloadFile documentation
1 parent e8ac0a3 commit d0ea7e5

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

apps/docs/packages/telegram-apps-sdk/3-x/utils/uncategorized.md

+38
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
# Uncategorized
22

3+
## `copyTextToClipboard`
4+
5+
Copies specified text to the clipboard using all known methods.
6+
7+
```ts
8+
import { copyTextToClipboard } from '@telegram-apps/sdk';
9+
10+
await copyTextToClipboard('My text goes here');
11+
```
12+
13+
## `downloadFile`
14+
15+
To request file download, use the `downloadFile` function. It accepts a file URL and its proposed saved name.
16+
17+
::: code-group
18+
19+
```ts [Using isAvailable]
20+
import { downloadFile } from '@telegram-apps/sdk';
21+
22+
if (downloadFile.isAvailable()) {
23+
await downloadFile(
24+
'https://telegram.org/js/telegram-web-app.js',
25+
'telegram-sdk.js',
26+
);
27+
}
28+
```
29+
30+
```ts [Using ifAvailable]
31+
import { downloadFile } from '@telegram-apps/sdk';
32+
33+
await downloadFile.ifAvailable(
34+
'https://telegram.org/js/telegram-web-app.js',
35+
'telegram-sdk.js',
36+
);
37+
```
38+
39+
:::
40+
341
## `getCurrentTime`
442

543
To retrieve the current Telegram server time, use the `getCurrentTime` function. It returns

0 commit comments

Comments
 (0)