mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-19 12:40:09 +01:00
lint
This commit is contained in:
parent
9c3cef242f
commit
2b17687c8f
@ -161,7 +161,8 @@ export function DnDFileUploaderProvider({ workspace, children }) {
|
||||
}
|
||||
|
||||
export default function DnDFileUploaderWrapper({ children }) {
|
||||
const { onDrop, ready, dragging, setDragging } = useContext(DndUploaderContext);
|
||||
const { onDrop, ready, dragging, setDragging } =
|
||||
useContext(DndUploaderContext);
|
||||
const { getRootProps, getInputProps } = useDropzone({
|
||||
onDrop,
|
||||
disabled: !ready,
|
||||
|
@ -1,14 +1,17 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useEffect } from "react";
|
||||
|
||||
export function useImagePaste(onImagePaste) {
|
||||
useEffect(() => {
|
||||
const handlePaste = (e) => {
|
||||
const items = e.clipboardData.items;
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (items[i].type.indexOf('image/') !== -1) {
|
||||
if (items[i].type.indexOf("image/") !== -1) {
|
||||
e.preventDefault();
|
||||
const blob = items[i].getAsFile();
|
||||
const fileName = blob.name !== "image.png" ? blob.name : `pasted-image.${blob.type.split('/')[1]}`;
|
||||
const fileName =
|
||||
blob.name !== "image.png"
|
||||
? blob.name
|
||||
: `pasted-image.${blob.type.split("/")[1]}`;
|
||||
const file = new File([blob], fileName, { type: blob.type });
|
||||
onImagePaste(file);
|
||||
break;
|
||||
@ -16,9 +19,9 @@ export function useImagePaste(onImagePaste) {
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener('paste', handlePaste);
|
||||
document.addEventListener("paste", handlePaste);
|
||||
return () => {
|
||||
document.removeEventListener('paste', handlePaste);
|
||||
document.removeEventListener("paste", handlePaste);
|
||||
};
|
||||
}, [onImagePaste]);
|
||||
}
|
Loading…
Reference in New Issue
Block a user