@component-hook/pdf-canvas 1.1.0-alpha.1 → 1.1.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
1
  import { Canvas } from 'fabric';
2
+ import { FabricImage } from 'fabric';
2
3
  import { FabricObject } from 'fabric';
3
4
  import { FabricObjectProps } from 'fabric';
5
+ import { FabricText } from 'fabric';
4
6
  import { ForwardRefExoticComponent } from 'react';
5
7
  import { ImageProps } from 'fabric';
6
8
  import { ObjectEvents } from 'fabric';
@@ -13,10 +15,28 @@ import { TOptions } from 'fabric';
13
15
  import { TPointerEvent } from 'fabric';
14
16
  import { TPointerEventInfo } from 'fabric';
15
17
 
18
+ export declare type CacheFabricImage = FabricImage & CacheProperties;
19
+
20
+ export declare type CacheFabricObject = FabricObject & CacheProperties;
21
+
22
+ export declare type CacheFabricText = FabricText & CacheProperties;
23
+
24
+ declare interface CacheProperties {
25
+ _cornerSize?: number;
26
+ }
27
+
16
28
  export declare interface CloseSvgOptions {
17
- stroke: string;
18
- hoverStroke: string;
19
- src: string;
29
+ stroke?: string;
30
+ hoverStroke?: string;
31
+ src?: string;
32
+ }
33
+
34
+ declare interface ComponentEmits {
35
+ onLoaded?: () => void;
36
+ onReload?: () => void;
37
+ onPointerDown?: (event: TPointerEventInfo<TPointerEvent>) => void;
38
+ onPointerMove?: (event: TPointerEventInfo<TPointerEvent>) => void;
39
+ onPointerUp?: (event: TPointerEventInfo<TPointerEvent>) => void;
20
40
  }
21
41
 
22
42
  export declare interface ComponentProps {
@@ -31,7 +51,9 @@ export declare interface ComponentProps {
31
51
  password?: string;
32
52
  dropTextOptions?: TOptions<TextProps>;
33
53
  dropImageOptions?: TOptions<ImageProps>;
54
+ selectionOptions?: TOptions<FabricObjectProps>;
34
55
  closeSvgOptions?: CloseSvgOptions;
56
+ manualReload?: boolean;
35
57
  onDestroy?: (callback: () => void) => void;
36
58
  }
37
59
 
@@ -49,10 +71,28 @@ export declare interface FabricHookParams {
49
71
  pointerDown?: (event: FabricPointerEvent) => void;
50
72
  pointerMove?: (event: FabricPointerEvent) => void;
51
73
  pointerUp?: (event: FabricPointerEvent) => void;
74
+ selectionCreated?: (event: FabricSelectionCreatedEvent) => void;
75
+ selectionCleared?: (event: FabricSelectionClearedEvent) => void;
52
76
  }
53
77
 
54
78
  export declare type FabricPointerEvent = TPointerEventInfo<TPointerEvent>;
55
79
 
80
+ export declare type FabricSelectionClearedEvent = Partial<TEvent<TPointerEvent>> & {
81
+ deselected: FabricObject[];
82
+ };
83
+
84
+ export declare type FabricSelectionCreatedEvent = Partial<TEvent<TPointerEvent>> & {
85
+ selected: FabricObject[];
86
+ };
87
+
88
+ export declare function loadFile(file: File, password?: string, id?: string): Promise<{
89
+ pages: number;
90
+ PDFId: string;
91
+ name: string;
92
+ updateDate: number;
93
+ PDFBase64: string;
94
+ } | undefined>;
95
+
56
96
  export declare interface PDF {
57
97
  PDFId: string;
58
98
  name: string;
@@ -64,10 +104,11 @@ export declare interface PDF {
64
104
  isUpdate?: boolean;
65
105
  }
66
106
 
67
- declare const PdfCanvas: ForwardRefExoticComponent<ComponentProps & RefAttributes<PdfCanvasHandle>>;
107
+ declare const PdfCanvas: ForwardRefExoticComponent<ComponentProps & ComponentEmits & RefAttributes<PdfCanvasHandle>>;
68
108
  export default PdfCanvas;
69
109
 
70
110
  export declare interface PdfCanvasHandle {
111
+ reload: () => Promise<void>;
71
112
  addImage: (src: string, options?: TOptions<ImageProps>) => void;
72
113
  addText: (text: string, options?: TOptions<TextProps>) => void;
73
114
  clearActive: () => void;
@@ -100,7 +141,9 @@ export declare interface TCornerPoint {
100
141
  br: Point;
101
142
  }
102
143
 
103
- export declare function useFabric(id?: string): {
144
+ export declare function useFabric(params?: FabricHookParams & {
145
+ selectionOptions?: TOptions<FabricObjectProps>;
146
+ }): {
104
147
  createCanvas: () => Canvas | undefined;
105
148
  loadFile: (file: File, password?: string) => Promise<{
106
149
  pages: number;
@@ -109,10 +152,10 @@ export declare function useFabric(id?: string): {
109
152
  updateDate: number;
110
153
  PDFBase64: string;
111
154
  } | undefined>;
112
- specifyPage: ({ page, PDFBase64, scale, password }: SpecifyPageArgs) => Promise<void>;
155
+ specifyPage: (specifyPageParams: SpecifyPageArgs) => Promise<number>;
113
156
  renderImage: ({ url, scale }: RenderImageArgs) => Promise<void>;
114
- addFabric: (src: string, options?: TOptions<ImageProps>) => Promise<void>;
115
- addTextFabric: (text: string, options?: TOptions<TextProps>) => void;
157
+ addFabric: (src: string, options?: TOptions<ImageProps>, offset?: DropOffset) => Promise<void>;
158
+ addTextFabric: (text: string, options?: TOptions<TextProps>, offset?: DropOffset) => void;
116
159
  clearActive: () => void;
117
160
  deleteCanvas: () => void;
118
161
  scaleFabric: (scale: number, isCreate?: boolean) => void;