mirror of
https://github.com/ramvignesh-b/pi-ku.git
synced 2026-05-04 15:56:56 +00:00
refactor: improve type safety, update navigation, and optimize base64 encoding in auth and editor components
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user