mirror of
https://github.com/cinnyapp/cinny.git
synced 2026-11-20 00:51:24 -08:00
21 lines
534 B
TypeScript
21 lines
534 B
TypeScript
/*
|
|
Cinny Project
|
|
Copyright 2021-present Ajay Bura
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
https://cinny.in
|
|
|
|
Please see LICENSE file in root of repository for full details.
|
|
*/
|
|
|
|
import { useCallback, ClipboardEventHandler } from 'react';
|
|
import { getDataTransferFiles } from '../utils/dom';
|
|
|
|
export const useFilePasteHandler = (onPaste: (file: File[]) => void): ClipboardEventHandler =>
|
|
useCallback(
|
|
(evt) => {
|
|
const files = getDataTransferFiles(evt.clipboardData);
|
|
if (files) onPaste(files);
|
|
},
|
|
[onPaste]
|
|
);
|