feat: implement encrypted metadata support and fix public_id handling in letter serialization

This commit is contained in:
Your Name
2026-04-12 05:14:02 +05:30
parent 99ed561570
commit 998ad848b0
4 changed files with 28 additions and 9 deletions
+11 -4
View File
@@ -5,11 +5,15 @@ const PAD = 36;
export type CanvasTools = {
addImage: (url: string, file: File) => void;
getData: () => { objects: any };
getData: () => { objects: any[] };
getJsonData: () => string;
getImages: () => { src: string; file: File }[];
};
export interface FabricImageWithFile extends fabric.FabricImage {
_customRawFile: File;
}
export const ComposeCanvas = forwardRef<CanvasTools>((_props, ref) => {
const wrapperRef = useRef<HTMLDivElement>(null);
const canvasRef = useRef<HTMLCanvasElement>(null);
@@ -150,7 +154,7 @@ export const ComposeCanvas = forwardRef<CanvasTools>((_props, ref) => {
});
},
getData: () => {
if (!fabricRef.current) return "";
if (!fabricRef.current) return { objects: [] };
return fabricRef.current.toJSON();
},
getJsonData: () => {
@@ -159,8 +163,11 @@ export const ComposeCanvas = forwardRef<CanvasTools>((_props, ref) => {
},
getImages: () => {
if (!fabricRef.current) return [];
return fabricRef.current.getObjects("Image").map((img: any) => ({
src: img._element.currentSrc,
const images = fabricRef.current.getObjects(
"Image",
) as FabricImageWithFile[];
return images.map((img) => ({
src: (img.getElement() as HTMLImageElement).currentSrc,
file: img._customRawFile,
}));
},