mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-30 02:18:29 +00:00

- `text/uri-list` type is now accepted (such as clipboard data from bluesky) - http links are now allowed (such as those from rednote) - rednote share link is properly extracted
18 lines
528 B
TypeScript
18 lines
528 B
TypeScript
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;
|
|
}
|
|
}
|
|
}
|
|
}
|