MCPcopy Create free account
hub / github.com/dailydotdev/apps / getImageFileFromClipboard

Function getImageFileFromClipboard

packages/shared/src/lib/screenshot.ts:230–250  ·  view source on GitHub ↗
(
  clipboardData: DataTransfer | null,
)

Source from the content-addressed store, hash-verified

228 * an unsupported one still reaches isValidImageType() and gets a toast.
229 */
230export const getImageFileFromClipboard = (
231 clipboardData: DataTransfer | null,
232): File | null => {
233 if (!clipboardData) {
234 return null;
235 }
236
237 const file = Array.from(clipboardData.files ?? []).find((item) =>
238 item.type.startsWith('image/'),
239 );
240
241 if (file) {
242 return file;
243 }
244
245 const item = Array.from(clipboardData.items ?? []).find(
246 (entry) => entry.kind === 'file' && entry.type.startsWith('image/'),
247 );
248
249 return item?.getAsFile() ?? null;
250};

Callers 2

FeedbackModalFunction · 0.90
screenshot.spec.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected