merchi_product_editor
Version:
A React component for editing product images using Fabric.js
43 lines (42 loc) • 1.41 kB
TypeScript
import React from 'react';
import { fabric } from 'fabric';
import { Product, Job, DraftTemplate, Variation } from '../types';
interface ProductEditorContextType {
canvas: fabric.Canvas | null;
setCanvas: (canvas: fabric.Canvas) => void;
canvasRef: React.RefObject<HTMLCanvasElement>;
draftTemplates: {
template: DraftTemplate;
variationObjects: any[];
}[];
selectedTemplate: number | null;
setSelectedTemplate: (templateId: number) => void;
showGrid: boolean;
setShowGrid: (show: boolean) => void;
product: Product;
isMobileView: boolean;
job: Job;
width: number;
height: number;
handleUndo: () => void;
handleRedo: () => void;
handleTemplateChange: (draftTemplate: DraftTemplate) => void;
handleSave: () => void;
handleCancel: () => void;
canvasObjects: Map<string, fabric.Object>;
updateCanvasFromVariations: (newVariations: Variation[], newGroupVariations?: Variation[]) => void;
}
interface ProductEditorProviderProps {
children: React.ReactNode;
product: Product;
width?: number;
height?: number;
job: Job;
onSave: () => void;
onCancel: () => void;
variations: Variation[];
groupVariations: Variation[];
}
export declare const ProductEditorProvider: React.FC<ProductEditorProviderProps>;
export declare const useProductEditor: () => ProductEditorContextType;
export {};