@component-hook/pdf-canvas 1.0.5-alpha.2 → 1.0.5-alpha.4

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.
@@ -10,6 +10,8 @@ import { SerializedObjectProps } from 'fabric';
10
10
  import { TEvent } from 'fabric';
11
11
  import { TextProps } from 'fabric';
12
12
  import { TOptions } from 'fabric';
13
+ import { TPointerEvent } from 'fabric';
14
+ import { TPointerEventInfo } from 'fabric';
13
15
 
14
16
  export declare interface CloseSvgOptions {
15
17
  stroke: string;
@@ -40,6 +42,17 @@ export declare interface CreateCloseFabricArgs {
40
42
  uuid?: number;
41
43
  }
42
44
 
45
+ export declare type DropOffset = Record<'x' | 'y', number>;
46
+
47
+ export declare interface FabricHookParams {
48
+ id: string;
49
+ pointerDown?: (event: FabricPointerEvent) => void;
50
+ pointerMove?: (event: FabricPointerEvent) => void;
51
+ pointerUp?: (event: FabricPointerEvent) => void;
52
+ }
53
+
54
+ export declare type FabricPointerEvent = TPointerEventInfo<TPointerEvent>;
55
+
43
56
  export declare interface PDF {
44
57
  PDFId: string;
45
58
  name: string;
@@ -13,10 +13,12 @@ import { SerializedObjectProps } from 'fabric';
13
13
  import { TEvent } from 'fabric';
14
14
  import { TextProps } from 'fabric';
15
15
  import { TOptions } from 'fabric';
16
+ import { TPointerEvent } from 'fabric';
17
+ import { TPointerEventInfo } from 'fabric';
16
18
 
17
- declare function addImage(src: string, options?: TOptions<ImageProps>, size?: Record<'width' | 'height', number>): void;
19
+ declare function addImage(src: string, options?: TOptions<ImageProps>, offset?: DropOffset): void;
18
20
 
19
- declare function addText(text: string, options?: TOptions<TextProps>): void;
21
+ declare function addText(text: string, options?: TOptions<TextProps>, offset?: DropOffset): void;
20
22
 
21
23
  export declare interface CloseSvgOptions {
22
24
  stroke: string;
@@ -54,8 +56,14 @@ clearActive: () => void;
54
56
  deleteCanvas: () => void;
55
57
  canvasRef: Ref<HTMLCanvasElement | null, HTMLCanvasElement | null>;
56
58
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
59
+ pointerDown: (event: TPointerEventInfo<TPointerEvent>) => any;
60
+ pointerMove: (event: TPointerEventInfo<TPointerEvent>) => any;
61
+ pointerUp: (event: TPointerEventInfo<TPointerEvent>) => any;
57
62
  loaded: () => any;
58
63
  }, string, PublicProps, Readonly<ComponentProps> & Readonly<{
64
+ onPointerDown?: ((event: TPointerEventInfo<TPointerEvent>) => any) | undefined;
65
+ onPointerMove?: ((event: TPointerEventInfo<TPointerEvent>) => any) | undefined;
66
+ onPointerUp?: ((event: TPointerEventInfo<TPointerEvent>) => any) | undefined;
59
67
  onLoaded?: (() => any) | undefined;
60
68
  }>, {
61
69
  page: number;
@@ -71,6 +79,17 @@ canvasRef: HTMLCanvasElement;
71
79
  }, HTMLDivElement>;
72
80
  export default _default;
73
81
 
82
+ export declare type DropOffset = Record<'x' | 'y', number>;
83
+
84
+ export declare interface FabricHookParams {
85
+ id: string;
86
+ pointerDown?: (event: FabricPointerEvent) => void;
87
+ pointerMove?: (event: FabricPointerEvent) => void;
88
+ pointerUp?: (event: FabricPointerEvent) => void;
89
+ }
90
+
91
+ export declare type FabricPointerEvent = TPointerEventInfo<TPointerEvent>;
92
+
74
93
  export declare interface PDF {
75
94
  PDFId: string;
76
95
  name: string;
@@ -107,7 +126,7 @@ export declare interface TCornerPoint {
107
126
  br: Point;
108
127
  }
109
128
 
110
- export declare function useFabric(id?: string): {
129
+ export declare function useFabric(params?: FabricHookParams): {
111
130
  createCanvas: () => Canvas | undefined;
112
131
  loadFile: (file: File, password?: string) => Promise<{
113
132
  pages: number;
@@ -118,8 +137,8 @@ export declare function useFabric(id?: string): {
118
137
  } | undefined>;
119
138
  specifyPage: ({ page, PDFBase64, scale, password }: SpecifyPageArgs) => Promise<void>;
120
139
  renderImage: ({ url, scale }: RenderImageArgs) => Promise<void>;
121
- addFabric: (src: string, options?: TOptions<ImageProps>, size?: Record<"width" | "height", number>) => Promise<void>;
122
- addTextFabric: (text: string, options?: TOptions<TextProps>) => void;
140
+ addFabric: (src: string, options?: TOptions<ImageProps>, offset?: DropOffset) => Promise<void>;
141
+ addTextFabric: (text: string, options?: TOptions<TextProps>, offset?: DropOffset) => void;
123
142
  clearActive: () => void;
124
143
  deleteCanvas: () => void;
125
144
  scaleFabric: (scale: number, isCreate?: boolean) => void;