add konva js to project + create some components with ai
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { DocumentUpload } from "iconsax-react";
|
||||
import { useEditorStore, type ToolType } from "../../../store/editorStore";
|
||||
import Button from "@/components/Button";
|
||||
|
||||
const DocumentUploadComponent = () => {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<label className="block text-sm mb-2">آپلود سند</label>
|
||||
<input
|
||||
type="file"
|
||||
accept=".pdf,.doc,.docx"
|
||||
onChange={(e) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (event) => {
|
||||
const fileUrl = event.target?.result as string;
|
||||
const newDocument = {
|
||||
id: `document-${Date.now()}`,
|
||||
type: "document" as ToolType,
|
||||
x: 100,
|
||||
y: 100,
|
||||
width: 200,
|
||||
height: 250,
|
||||
imageUrl: fileUrl,
|
||||
};
|
||||
const { addObject } = useEditorStore.getState();
|
||||
addObject(newDocument);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
}}
|
||||
className="hidden"
|
||||
id="document-upload"
|
||||
/>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => document.getElementById("document-upload")?.click()}
|
||||
className="w-full"
|
||||
>
|
||||
<DocumentUpload size={20} />
|
||||
انتخاب سند
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default DocumentUploadComponent;
|
||||
|
||||
Reference in New Issue
Block a user