refactor: improve type safety, update navigation, and optimize base64 encoding in auth and editor components

This commit is contained in:
Your Name
2026-04-11 19:33:50 +05:30
parent 4f0355d8eb
commit 9953b27385
7 changed files with 29 additions and 22 deletions
+8 -1
View File
@@ -3,7 +3,11 @@ import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
const PAD = 36;
export const ComposeCanvas = forwardRef((_props, ref) => {
export type CanvasTools = {
addImage: (url: string) => void;
};
export const ComposeCanvas = forwardRef<CanvasTools>((_props, ref) => {
const wrapperRef = useRef<HTMLDivElement>(null);
const canvasRef = useRef<HTMLCanvasElement>(null);
const fabricRef = useRef<fabric.Canvas | null>(null);
@@ -137,6 +141,8 @@ export const ComposeCanvas = forwardRef((_props, ref) => {
fabricRef.current?.add(img);
fabricRef.current?.setActiveObject(img);
fabricRef.current?.requestRenderAll();
URL.revokeObjectURL(url); // cleanup browser upload
});
},
}));
@@ -155,3 +161,4 @@ export const ComposeCanvas = forwardRef((_props, ref) => {
</div>
);
});
ComposeCanvas.displayName = "ComposeCanvas";