Create all components
This commit is contained in:
@@ -15,30 +15,6 @@ const EditorSidebar = () => {
|
||||
setTool(selectedTool);
|
||||
};
|
||||
|
||||
const handleImageUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = (event) => {
|
||||
const imageUrl = event.target?.result as string;
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
const newImage = {
|
||||
id: `image-${Date.now()}`,
|
||||
type: "image" as ToolType,
|
||||
x: 100,
|
||||
y: 100,
|
||||
width: img.width,
|
||||
height: img.height,
|
||||
imageUrl,
|
||||
};
|
||||
useEditorStore.getState().addObject(newImage);
|
||||
};
|
||||
img.src = imageUrl;
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -72,7 +48,7 @@ const EditorSidebar = () => {
|
||||
onDelete={deleteObject}
|
||||
/>
|
||||
) : (
|
||||
<ToolInstructions tool={tool} onImageUpload={handleImageUpload} />
|
||||
<ToolInstructions tool={tool} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user