import { Canvas } from 'fabric'; import { FabricImage } from 'fabric'; import { FabricObject } from 'fabric'; import { FabricObjectProps } from 'fabric'; import { FabricText } from 'fabric'; import { ForwardRefExoticComponent } from 'react'; import { ImageProps } from 'fabric'; import { ObjectEvents } from 'fabric'; import { Point } from 'fabric'; import { RefAttributes } from 'react'; import { SerializedObjectProps } from 'fabric'; import { TEvent } from 'fabric'; import { TextProps } from 'fabric'; import { TOptions } from 'fabric'; import { TPointerEvent } from 'fabric'; import { TPointerEventInfo } from 'fabric'; export declare type CacheFabricImage = FabricImage & CacheProperties; export declare type CacheFabricObject = FabricObject & CacheProperties; export declare type CacheFabricText = FabricText & CacheProperties; declare interface CacheProperties { _cornerSize?: number; } export declare interface CloseSvgOptions { stroke?: string; hoverStroke?: string; src?: string; } declare interface ComponentEmits { onLoaded?: () => void; onReload?: () => void; onPointerDown?: (event: FabricPointerEvent) => void; onPointerMove?: (event: FabricPointerEvent) => void; onPointerUp?: (event: FabricPointerEvent) => void; onSelectionCreated?: (event: FabricSelectionCreatedEvent) => void; onSelectionCleared?: (event: FabricSelectionClearedEvent) => void; } export declare interface ComponentProps { file: PDF; page?: number; canvasId?: string; fileZoom?: number; fileScale?: number; canvasScale?: number; canvasClass?: string; isDrop?: boolean; password?: string; dropTextOptions?: TOptions; dropImageOptions?: TOptions; selectionOptions?: TOptions; closeSvgOptions?: CloseSvgOptions; manualReload?: boolean; onDestroy?: (callback: () => void) => void; } export declare interface CreateCloseFabricArgs { canvas: Canvas; target: FabricObject; stroke?: string; uuid?: number; } export declare type DropOffset = Record<'x' | 'y', number>; export declare interface FabricHookParams { id: string; pointerDown?: (event: FabricPointerEvent) => void; pointerMove?: (event: FabricPointerEvent) => void; pointerUp?: (event: FabricPointerEvent) => void; selectionCreated?: (event: FabricSelectionCreatedEvent) => void; selectionCleared?: (event: FabricSelectionClearedEvent) => void; } export declare type FabricPointerEvent = TPointerEventInfo; export declare type FabricSelectionClearedEvent = Partial> & { deselected: FabricObject[]; }; export declare type FabricSelectionCreatedEvent = Partial> & { selected: FabricObject[]; }; export declare function loadFile(file: File, password?: string, id?: string): Promise<{ pages: number; PDFId: string; name: string; updateDate: number; data: File; }>; export declare interface PDF { PDFId: string; name: string; updateDate: number; data?: File | null; pages: number; } declare const PdfCanvas: ForwardRefExoticComponent>; export default PdfCanvas; export declare interface PdfCanvasHandle { reload: () => Promise; addImage: (src: string, options?: TOptions) => void; addText: (text: string, options?: TOptions) => void; clearActive: () => void; deleteCanvas: () => void; setActiveFabric: (options: TOptions) => void; copyActiveFabric: () => Promise; deleteActiveFabric: () => void; canvasRef: React.RefObject; } export declare interface RenderImageArgs { data: Blob; scale?: number; } export declare type SelectedEvent = Partial & { target: FabricObject, SerializedObjectProps, ObjectEvents>; }; export declare interface SpecifyPageArgs { page: number; data: Blob; scale: number; password?: string; } export declare type SupportFileType = 'application/pdf' | 'image/png' | 'image/jpeg'; export declare interface TCornerPoint { tl: Point; tr: Point; bl: Point; br: Point; } export declare function useFabric(params?: FabricHookParams & { selectionOptions?: TOptions; }): { createCanvas: () => Canvas | undefined; loadFile: (file: File, password?: string) => Promise<{ pages: number; PDFId: string; name: string; updateDate: number; data: File; }>; specifyPage: (specifyPageParams: SpecifyPageArgs) => Promise; renderImage: ({ data, scale }: RenderImageArgs) => Promise; addFabric: (src: string, options?: TOptions, offset?: DropOffset) => Promise; addTextFabric: (text: string, options?: TOptions, offset?: DropOffset) => void; clearActive: () => void; deleteCanvas: () => void; scaleFabric: (scale: number, isCreate?: boolean) => void; setCloseSvgOptions: (options?: CloseSvgOptions) => void; setActiveFabric: (options: TOptions) => void; copyActiveFabric: () => Promise; deleteActiveFabric: () => void; }; export { }