Spaces:
Paused
Paused
Download web/src/lib/clipboard.ts from Lordgrim7/cobalt-api: direct link, hf CLI and curl.
- Browser
- Download file 528 Bytes
-
https://huggingface.co/spaces/Lordgrim7/cobalt-api/resolve/main/web/src/lib/clipboard.ts
- Command line
-
hf download hf://spaces/Lordgrim7/cobalt-api/web/src/lib/clipboard.ts
-
curl -L -o clipboard.ts https://huggingface.co/spaces/Lordgrim7/cobalt-api/resolve/main/web/src/lib/clipboard.ts
528 Bytes
| const allowedLinkTypes = new Set(["text/plain", "text/uri-list"]); | |
| export const pasteLinkFromClipboard = async () => { | |
| const clipboard = await navigator.clipboard.read(); | |
| if (clipboard?.length) { | |
| const clipboardItem = clipboard[0]; | |
| for (const type of clipboardItem.types) { | |
| if (allowedLinkTypes.has(type)) { | |
| const blob = await clipboardItem.getType(type); | |
| const blobText = await blob.text(); | |
| return blobText; | |
| } | |
| } | |
| } | |
| } | |