{ "version": 3, "sources": ["../../../../../src/lib/ui/hooks/clipboard/pasteFiles.ts"], "sourcesContent": ["import { Editor, TLExternalContentSource, VecLike } from '@tldraw/editor'\n\n/**\n * When the clipboard has a file, create an image shape from the file and paste it into the scene\n *\n * @param editor - The editor instance.\n * @param urls - The file urls.\n * @param point - (optional) The point at which to paste the file.\n * @internal\n */\nexport async function pasteFiles(\n\teditor: Editor,\n\turls: string[],\n\tpoint?: VecLike,\n\tsources?: TLExternalContentSource[]\n) {\n\tconst blobs = await Promise.all(urls.map(async (url) => await (await fetch(url)).blob()))\n\tconst files = blobs.map((blob) => new File([blob], 'tldrawFile', { type: blob.type }))\n\n\teditor.mark('paste')\n\n\tawait editor.putExternalContent({\n\t\ttype: 'files',\n\t\tfiles,\n\t\tpoint,\n\t\tignoreParent: false,\n\t\tsources,\n\t})\n\n\turls.forEach((url) => URL.revokeObjectURL(url))\n}\n"], "mappings": "AAUA,eAAsB,WACrB,QACA,MACA,OACA,SACC;AACD,QAAM,QAAQ,MAAM,QAAQ,IAAI,KAAK,IAAI,OAAO,QAAQ,OAAO,MAAM,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC;AACxF,QAAM,QAAQ,MAAM,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,IAAI,GAAG,cAAc,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC;AAErF,SAAO,KAAK,OAAO;AAEnB,QAAM,OAAO,mBAAmB;AAAA,IAC/B,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,EACD,CAAC;AAED,OAAK,QAAQ,CAAC,QAAQ,IAAI,gBAAgB,GAAG,CAAC;AAC/C;", "names": [] }