{ "version": 3, "sources": ["../../../../../src/lib/ui/hooks/clipboard/pasteUrl.ts"], "sourcesContent": ["import { Editor, TLExternalContentSource, VecLike } from '@tldraw/editor'\nimport { pasteFiles } from './pasteFiles'\n\n/**\n * When the clipboard has plain text that is a valid URL, create a bookmark shape and insert it into\n * the scene\n *\n * @param editor - The editor instance.\n * @param url - The URL to paste.\n * @param point - (optional) The point at which to paste the file.\n * @internal\n */\nexport async function pasteUrl(\n\teditor: Editor,\n\turl: string,\n\tpoint?: VecLike,\n\tsources?: TLExternalContentSource[]\n) {\n\t// Lets see if its an image and we have CORs\n\ttry {\n\t\tconst resp = await fetch(url)\n\t\tif (resp.headers.get('content-type')?.match(/^image\\//)) {\n\t\t\teditor.mark('paste')\n\t\t\tpasteFiles(editor, [url])\n\t\t\treturn\n\t\t}\n\t} catch (err: any) {\n\t\tif (err.message !== 'Failed to fetch') {\n\t\t\tconsole.error(err)\n\t\t}\n\t}\n\n\teditor.mark('paste')\n\n\treturn await editor.putExternalContent({\n\t\ttype: 'url',\n\t\tpoint,\n\t\turl,\n\t\tsources,\n\t})\n}\n"], "mappings": "AACA,SAAS,kBAAkB;AAW3B,eAAsB,SACrB,QACA,KACA,OACA,SACC;AAED,MAAI;AACH,UAAM,OAAO,MAAM,MAAM,GAAG;AAC5B,QAAI,KAAK,QAAQ,IAAI,cAAc,GAAG,MAAM,UAAU,GAAG;AACxD,aAAO,KAAK,OAAO;AACnB,iBAAW,QAAQ,CAAC,GAAG,CAAC;AACxB;AAAA,IACD;AAAA,EACD,SAAS,KAAU;AAClB,QAAI,IAAI,YAAY,mBAAmB;AACtC,cAAQ,MAAM,GAAG;AAAA,IAClB;AAAA,EACD;AAEA,SAAO,KAAK,OAAO;AAEnB,SAAO,MAAM,OAAO,mBAAmB;AAAA,IACtC,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAC;AACF;", "names": [] }