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 }) {
|
export default function DnDFileUploaderWrapper({ children }) {
|
||||||
const { onDrop, ready, dragging, setDragging } = useContext(DndUploaderContext);
|
const { onDrop, ready, dragging, setDragging } =
|
||||||
|
useContext(DndUploaderContext);
|
||||||
const { getRootProps, getInputProps } = useDropzone({
|
const { getRootProps, getInputProps } = useDropzone({
|
||||||
onDrop,
|
onDrop,
|
||||||
disabled: !ready,
|
disabled: !ready,
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from "react";
|
||||||
|
|
||||||
export function useImagePaste(onImagePaste) {
|
export function useImagePaste(onImagePaste) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handlePaste = (e) => {
|
const handlePaste = (e) => {
|
||||||
const items = e.clipboardData.items;
|
const items = e.clipboardData.items;
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
if (items[i].type.indexOf('image/') !== -1) {
|
if (items[i].type.indexOf("image/") !== -1) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const blob = items[i].getAsFile();
|
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 });
|
const file = new File([blob], fileName, { type: blob.type });
|
||||||
onImagePaste(file);
|
onImagePaste(file);
|
||||||
break;
|
break;
|
||||||
@ -16,9 +19,9 @@ export function useImagePaste(onImagePaste) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('paste', handlePaste);
|
document.addEventListener("paste", handlePaste);
|
||||||
return () => {
|
return () => {
|
||||||
document.removeEventListener('paste', handlePaste);
|
document.removeEventListener("paste", handlePaste);
|
||||||
};
|
};
|
||||||
}, [onImagePaste]);
|
}, [onImagePaste]);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user