@yorab/react-paint 0.14.0 → 0.15.1

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.
Files changed (44) hide show
  1. package/README.md +46 -283
  2. package/dist/canvas/components/Canvas.d.ts +2 -0
  3. package/dist/canvas/components/EditTextBox.d.ts +2 -2
  4. package/dist/canvas/constants/app.d.ts +2 -0
  5. package/dist/canvas/constants/keyboard.d.ts +24 -0
  6. package/dist/canvas/hooks/useComponent.d.ts +3 -1
  7. package/dist/canvas/hooks/useDebounce.d.ts +2 -0
  8. package/dist/canvas/hooks/useDrawableCanvas.d.ts +3 -1
  9. package/dist/canvas/hooks/useKeyboard.d.ts +5 -1
  10. package/dist/canvas/hooks/useReactPaint.d.ts +1847 -8
  11. package/dist/canvas/hooks/useShapes.d.ts +1379 -4
  12. package/dist/canvas/index.d.ts +3 -3
  13. package/dist/canvas/utils/data.d.ts +2 -2
  14. package/dist/canvas/utils/file.d.ts +233 -4
  15. package/dist/canvas/utils/intersect.d.ts +4 -4
  16. package/dist/canvas/utils/selection/groupSelection.d.ts +2 -2
  17. package/dist/canvas/utils/selection/lineSelection.d.ts +6 -2
  18. package/dist/canvas/utils/selection/rectSelection.d.ts +9 -4
  19. package/dist/canvas/utils/selection.d.ts +1 -1
  20. package/dist/canvas/utils/shapes/brush.d.ts +14 -11
  21. package/dist/canvas/utils/shapes/circle.d.ts +13 -9
  22. package/dist/canvas/utils/shapes/curve.d.ts +15 -10
  23. package/dist/canvas/utils/shapes/ellipse.d.ts +13 -9
  24. package/dist/canvas/utils/shapes/index.d.ts +19 -10
  25. package/dist/canvas/utils/shapes/line.d.ts +13 -8
  26. package/dist/canvas/utils/shapes/path.d.ts +18 -2
  27. package/dist/canvas/utils/shapes/picture.d.ts +13 -9
  28. package/dist/canvas/utils/shapes/polygon.d.ts +14 -8
  29. package/dist/canvas/utils/shapes/rectangle.d.ts +54 -9
  30. package/dist/canvas/utils/shapes/text.d.ts +12 -7
  31. package/dist/canvas/utils/shapes/triangle.d.ts +4 -3
  32. package/dist/canvas/utils/trigo.d.ts +1 -1
  33. package/dist/common/types/Mode.d.ts +1 -0
  34. package/dist/common/types/Shapes.d.ts +63 -26
  35. package/dist/common/types/utils.d.ts +1 -1
  36. package/dist/editor/components/common/Button.d.ts +2 -2
  37. package/dist/editor/components/common/FileInput.d.ts +13 -0
  38. package/dist/editor/components/settings/RangeField.d.ts +2 -1
  39. package/dist/editor/components/settings/SettingsBar.d.ts +2 -1
  40. package/dist/editor/index.d.ts +11 -11
  41. package/dist/react-paint.css +1 -1
  42. package/dist/react-paint.js +1362 -1312
  43. package/dist/react-paint.umd.cjs +1 -1
  44. package/package.json +19 -15
package/README.md CHANGED
@@ -1,25 +1,46 @@
1
1
  # React Paint
2
2
 
3
- An open-source canvas-based library for React used for image annotation or as a digital whiteboard
3
+ An open-source canvas-based library for React used for image annotation or as a digital whiteboard.
4
4
 
5
5
  ## Features
6
6
 
7
+ - **Rich Drawing Tools** - Brush, shapes (rectangles, circles, ellipses, polygons, curves), lines, text, and picture support
8
+ - **Interactive Canvas** - Full support for zoom, pan, pinch gestures, and infinite or fixed-size canvases
9
+ - **Shape Manipulation** - Select, move, resize, rotate, and transform shapes with intuitive controls
10
+ - **Customizable Styling** - Control colors, line widths, opacity, line styles, arrows, and fonts
11
+ - **Layer Management** - Built-in layer manipulation panel for organizing your drawings
12
+ - **Export & Import** - Export to PNG images or save/load your work as JSON data
13
+ - **Event System** - Listen to data changes and integrate with your application state
14
+ - **Flexible Configuration** - Extensive options to customize behavior and appearance
15
+ - **TypeScript Support** - Fully typed for better developer experience
7
16
 
8
- ## Quick start
17
+ ## Quick Start
18
+
19
+ ### Installation
9
20
 
10
21
  ```bash
11
- npm i @yorab/react-paint
22
+ npm install @yorab/react-paint
23
+ ```
24
+
25
+ **Note:** React Paint requires `react` and `react-dom` (version 18.x) as peer dependencies.
26
+
27
+ ### Import Styles
28
+
29
+ Don't forget to import the CSS file in your application:
30
+
31
+ ```tsx
32
+ import '@yorab/react-paint/react-paint.css'
12
33
  ```
13
- Note : react-paint needs <a href="https://www.npmjs.com/package/react">react</a> and <a href="https://www.npmjs.com/package/react-dom">react-dom</a> packages to work properly
14
34
 
15
35
  ## Usage
16
36
 
17
- ### Basic usage
37
+ ### Basic Usage
18
38
 
19
39
  ```tsx
20
40
  import { Canvas, Editor, useReactPaint } from '@yorab/react-paint'
41
+ import '@yorab/react-paint/react-paint.css'
21
42
 
22
- const BasicUsage = () => {
43
+ function MyPaintApp() {
23
44
  const { editorProps, canvasProps } = useReactPaint()
24
45
 
25
46
  return (
@@ -30,13 +51,14 @@ const BasicUsage = () => {
30
51
  }
31
52
  ```
32
53
 
33
- ### Advanced usage
54
+ ### Advanced Usage
34
55
 
35
56
  ```tsx
36
57
  import { useEffect, useState } from 'react'
37
58
  import { Canvas, Editor, useReactPaint, type DrawableShape, type StateData } from '@yorab/react-paint'
59
+ import '@yorab/react-paint/react-paint.css'
38
60
 
39
- const SHAPES_INIT = [
61
+ const SHAPES_INIT: DrawableShape[] = [
40
62
  {
41
63
  type: 'rect',
42
64
  x: 300,
@@ -51,14 +73,14 @@ const SHAPES_INIT = [
51
73
  lineWidth: 1,
52
74
  lineDash: 0,
53
75
  lineArrow: 0,
54
- closedPoints: 1,
76
+ closedPoints: 1,
55
77
  fontFamily: 'serif'
56
78
  }
57
79
  }
58
80
  ]
59
81
 
60
- const AdvancedUsage = () => {
61
- const [shapes, setShapes] = useState<DrawableShape[] | undefined>(SHAPES_INIT) // keep shapes state for internal use
82
+ function AdvancedPaintApp() {
83
+ const [shapes, setShapes] = useState<DrawableShape[] | undefined>(SHAPES_INIT)
62
84
 
63
85
  const { editorProps, canvasProps, registerEvent, unregisterEvent } = useReactPaint({
64
86
  width: 1920,
@@ -100,282 +122,23 @@ const AdvancedUsage = () => {
100
122
  }
101
123
  ```
102
124
 
103
- ### Other usages
104
-
105
- you will find other usages in <a href="https://github.com/YoRab/react-paint-editor/tree/main/stories">stories</a>
106
-
107
- ### API
108
-
109
- #### `useReactPaint`
110
-
111
- ##### Parameters
112
-
113
- | Parameter | Type | Description | Default value |
114
- | :--- | :--- | :--- | :--- |
115
- | `width` | `number` | *Optional*. Canvas width in px | `1000` |
116
- | `height` | `number` | *Optional*. Canvas height in px | `600` |
117
- | `shapes` | [`DrawableShape[]`](####drawableshape) | *Optional*. Array of shapes used to init the canvas | `undefined` |
118
- | `mode` | `editor\|viewer` | *Optional*. `editor` lets you interact with the canvas and editor. `viewer` hides the editor and makes the canvas read-only| `editor` |
119
- | `disabled` | `boolean` | *Optional*. Global parameter used to prevent interaction with every element in the editor or canvas | `false` |
120
- | `options` | [`OptionalOptions`](####optionaloptions) | *Optional*. Set of options to customize available features | See [`OptionalOptions`]((####optionaloptions)) |
121
-
122
-
123
- ##### Returns
124
-
125
- | Parameter | Type | Description |
126
- | :--- | :--- | :--- |
127
- | `canvasProps` | `object` | Set of properties to forward to Canvas component |
128
- | `editorProps` | `object` | Set of properties to forward to Editor component |
129
- | `registerEvent` | `(event: "dataChanged", listener: (data: StateData, source: 'user' \| 'remote') => void) => void` | registerEvent is used to register a listener for special events triggered by react-paint. The only currently available event is `dataChanged`. `source` indicates the origin of the state update |
130
- | `unregisterEvent` | `(event: "dataChanged", listener?: ((data: StateData, source: 'user' \| 'remote') => void) \| undefined) => void` | unregisterEvent is used to unregister a listener previously registered. Omitting listener will result in unregistering every listeners for the the given event |
131
- | `resetCanvas` | `(shapes: DrawableShape[], clearHistory?: boolean) => Promise<void>` | reset canvas with the given shapes. use `[]` or `undefined` to clear the canvas. Set `false` to `clearHistory` to prevent history stack to be cleared |
132
- | `getCurrentImage` | `(view: 'defaultView' \| 'currentZoom' \| 'fitToShapes') => string` | Returns a data URL containing the content of the current canvas as a PNG image. `defaultView` will export a picture with dimensions based on canvas and no zoom. `currentZoom` will export a picture with dimensions based on canvas and current zoom and offset. `fitToShapes` will export a picture containing all drawn shapes. |
133
- | `getCurrentData` | `() => StateData` | Returns the current state of the canvas |
134
-
135
- #### `OptionalOptions`
136
-
137
- | Parameter | Type | Description | Default value |
138
- | :--- | :--- | :--- | :--- |
139
- | `layersManipulation` | `boolean` | *Optional*. Show panel to manipulate layers | `true` |
140
- | `grid` | `number` | *Optional*. Size in px for grid cells. Set to 0 to hide grid | `0` |
141
- | `canGrow` | `boolean` | *Optional*. Allow canvas to upscale and grow to fit container | `false` |
142
- | `canShrink` | `boolean` | *Optional*. Allow canvas to downscale and shrink to fit container | `true` |
143
- | `withExport` | `boolean` | *Optional*. Show button to manually export to PNG | `true` |
144
- | `withLoadAndSave` | `boolean` | *Optional*.Show button to manually save or load data | `true` |
145
- | `withUploadPicture` | `boolean` | *Optional*. Show button to add picture shape stored in base64 | `true` |
146
- | `withUrlPicture` | `boolean` | *Optional*.Show button to add picture shape with only the url stored. Need connectivity to be displayed | `false` |
147
- | `withFrameSelection` | `boolean` | *Optional*.Enable frame selection | `true` |
148
- | `withSkeleton` | `boolean` | *Optional*. Display skeleton when hovering shape | `false` |
149
- | `clearCallback` | `'empty' \| 'defaultShapes' \| (() => DrawableShape[])` | *Optional*. Set clear button behavior. `empty` clear all shapes, `defaultShapes` uses shapes given in props. It is also possible to set a function returning an array of shapes | `empty` |
150
- | `brushAlgo` | `'simple' \| 'quadratic'` | *Optional*. Choose which algorithm to display brush shape. `simple` displays path as is, `quadratic` uses quadratic bézier curves | `simple` |
151
- | `isBrushShapeDoneOnMouseUp` | `boolean` | *Optional*. Choose whether drawing brush shape after releasing mouse should create a new shape or not | `true` |
152
- | `canvasSelectionPadding` | `boolean` | *Optional*. Padding between shape and selection frame | `0` |
153
- | `availableTools` | `CustomToolInput[]` | *Optional*. List of available tools. See CustomTool for more details | `` |
154
- | `size` | `'fixed' \| 'infinite'` | *Optional*. Choose canvas size mode. `fixed` canvas is bound within its width and height, `infinite` canvas has no bound | `fixed` |
155
- | `canZoom` | `'never' \| 'always'` | *Optional*. Choose wether zoom is available `never` zoom is not available, `always` zoom is available | `never` |
156
-
157
-
158
-
159
-
160
- #### Canvas
161
-
162
- ##### Parameters
163
-
164
- | Parameter | Type | Description | Default value |
165
- | :--- | :--- | :--- | :--- |
166
- | `canvasProps` | `object` | **Required**. Set of properties coming from useReactPaint | |
167
- | `className` | `string` | *Optional*. Classname for canvas parent node | `undefined` |
168
- | `style` | `CSSProperties` | *Optional*. css properties to inject to canvas parent node | `undefined` |
169
- | `options` | `{canvasBackgroundColor?: string; canvasSelectionColor?: string; canvasSelectionWidth?: number}` | *Optional*. Set of properties to use to customize canvas style | `{canvasBackgroundColor: 'white'; canvasSelectionColor: 'blue'; canvasSelectionWidth: 2}` |
170
-
171
-
172
- #### Editor
173
-
174
- ##### Parameters
175
-
176
- | Parameter | Type | Description | Default value |
177
- | :--- | :--- | :--- | :--- |
178
- | `editorProps` | `object` | **Required**. Set of properties coming from useReactPaint | |
179
- | `children` | `ReactNode` | **Required**. Need Canvas component to work properly | |
180
- | `className` | `string` | *Optional*. Classname for canvas parent node | `undefined` |
181
- | `style` | `CSSProperties` | *Optional*. css properties to inject to canvas parent node | `undefined` |
182
- | `options` | `{ toolbarBackgroundColor?: string; dividerColor?: string; fontRadius?: number; fontDisabledColor?: string; fontDisabledBackgroundColor?: string; fontColor?: string; fontBackgroundColor?: string; fontSelectedColor?: string; fontSelectedBackgroundColor?: string; fontHoverColor?: string; fontHoverBackgroundColor?: string; }` | *Optional*. Set of properties to use to customize editor style | ` { toolbarBackgroundColor: 'white', dividerColor: '#36418129', fontRadius: 8, fontDisabledColor: '#3641812b', fontDisabledBackgroundColor: 'transparent', fontColor: '#364181', fontBackgroundColor: 'transparent', fontSelectedColor: 'white', fontSelectedBackgroundColor: '#364181', fontHoverColor: '#364181', fontHoverBackgroundColor: '#afd8d8'}` |
183
-
184
- ### Types
185
-
186
- #### `DrawableShape`
187
- #### `StateData`
188
-
189
- #### `CustomTool`
190
-
191
- ```
192
- type CustomTool = {
193
- id: string
194
- icon: string
195
- label: string
196
- } & (
197
- | {
198
- type: 'brush'
199
- settings: ToolsSettingsType<'brush'>
200
- }
201
- | {
202
- type: 'circle'
203
- settings: ToolsSettingsType<'circle'>
204
- }
205
- | {
206
- type: 'ellipse'
207
- settings: ToolsSettingsType<'ellipse'>
208
- }
209
- | {
210
- type: 'rect'
211
- settings: ToolsSettingsType<'rect'>
212
- }
213
- | {
214
- type: 'square'
215
- settings: ToolsSettingsType<'square'>
216
- }
217
- | {
218
- type: 'line'
219
- settings: ToolsSettingsType<'line'>
220
- }
221
- | {
222
- type: 'polygon'
223
- settings: ToolsSettingsType<'polygon'>
224
- }
225
- | {
226
- type: 'curve'
227
- settings: ToolsSettingsType<'curve'>
228
- }
229
- | {
230
- type: 'text'
231
- settings: ToolsSettingsType<'text'>
232
- }
233
- | {
234
- type: 'picture'
235
- settings: ToolsSettingsType<'picture'>
236
- }
237
- )
238
-
239
- type SettingsOpacity = {
240
- opacity: {
241
- min: number
242
- max: number
243
- step: number
244
- default: number
245
- hidden?: boolean
246
- }
247
- }
248
-
249
- type SettingsStrokeColor = {
250
- strokeColor: {
251
- values: string[]
252
- default: string
253
- hidden?: boolean
254
- }
255
- }
256
-
257
- type SettingsFillColor = {
258
- fillColor: {
259
- values: string[]
260
- default: string
261
- hidden?: boolean
262
- }
263
- }
264
-
265
- type SettingsLineWidth = {
266
- lineWidth: {
267
- min: number
268
- max: number
269
- step: number
270
- default: number
271
- hidden?: boolean
272
- }
273
- }
274
-
275
- type SettingsLineDash = {
276
- lineDash: {
277
- values: number[]
278
- default: number
279
- hidden?: boolean
280
- }
281
- }
282
-
283
- type SettingsLineArrow = {
284
- lineArrow: {
285
- values: number[]
286
- default: number
287
- hidden?: boolean
288
- }
289
- }
290
-
291
- type SettingsFont = {
292
- fontFamily: {
293
- values: string[]
294
- default: string
295
- hidden?: boolean
296
- }
297
- fontBold: {
298
- values: boolean[]
299
- default: boolean
300
- hidden?: boolean
301
- }
302
- fontItalic: {
303
- values: boolean[]
304
- default: boolean
305
- hidden?: boolean
306
- }
307
- }
308
-
309
- type SettingsClosedPoints = {
310
- closedPoints: {
311
- default: number
312
- hidden?: boolean
313
- }
314
- }
315
-
316
- type ToolsRectSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash
317
-
318
- type ToolsSquareSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash
125
+ ## Documentation
319
126
 
320
- type ToolsCircleSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash
127
+ For complete documentation, API reference, examples, and interactive demos, visit our **Storybook**:
321
128
 
322
- type ToolsEllipseSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash
323
-
324
- type ToolsTextSettings = SettingsOpacity & SettingsStrokeColor & SettingsFont
325
-
326
- type ToolsLineSettings = SettingsOpacity & SettingsStrokeColor & SettingsLineWidth & SettingsLineDash & SettingsLineArrow
327
-
328
- type ToolsBrushSettings = SettingsOpacity & SettingsStrokeColor & SettingsLineWidth & SettingsLineDash
329
-
330
- type ToolsPolygonSettings = SettingsOpacity &
331
- SettingsStrokeColor &
332
- SettingsFillColor &
333
- SettingsLineWidth &
334
- SettingsLineDash &
335
- SettingsClosedPoints
336
-
337
- type ToolsCurveSettings = SettingsOpacity &
338
- SettingsStrokeColor &
339
- SettingsFillColor &
340
- SettingsLineWidth &
341
- SettingsLineDash &
342
- SettingsClosedPoints
343
-
344
- type ToolsTriangleSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash
345
-
346
- type ToolsPictureSettings = SettingsOpacity
347
-
348
- type ToolsSettingsType<T extends ShapeType> = T extends 'rect'
349
- ? ToolsRectSettings
350
- : T extends 'square'
351
- ? ToolsSquareSettings
352
- : T extends 'circle'
353
- ? ToolsCircleSettings
354
- : T extends 'ellipse'
355
- ? ToolsEllipseSettings
356
- : T extends 'text'
357
- ? ToolsTextSettings
358
- : T extends 'line'
359
- ? ToolsLineSettings
360
- : T extends 'brush'
361
- ? ToolsBrushSettings
362
- : T extends 'polygon'
363
- ? ToolsPolygonSettings
364
- : T extends 'curve'
365
- ? ToolsCurveSettings
366
- : T extends 'triangle'
367
- ? ToolsTriangleSettings
368
- : T extends 'picture'
369
- ? ToolsPictureSettings
370
- : never
371
-
372
- ```
129
+ **[📚 View Storybook Documentation](https://yorab.github.io/react-paint-editor/)**
373
130
 
374
- ## Changelog
375
- https://github.com/YoRab/react-paint-editor/blob/main/Changelog.md
131
+ The Storybook includes:
132
+ - Getting started guide
133
+ - Complete API reference
134
+ - Interactive playground
135
+ - Usage examples
136
+ - Configuration options
376
137
 
377
- ## License
378
- <a href="https://github.com/YoRab/react-paint-editor/blob/main/LICENSE.txt">MIT</a>
138
+ ## Resources
379
139
 
140
+ - [Changelog](https://github.com/YoRab/react-paint-editor/blob/main/Changelog.md)
141
+ - [License](https://github.com/YoRab/react-paint-editor/blob/main/LICENSE.txt) (MIT)
142
+ - [GitHub Repository](https://github.com/YoRab/react-paint-editor)
380
143
 
381
144
  ## Contributing
@@ -11,6 +11,7 @@ type DrawerType = {
11
11
  settings: UtilsSettings;
12
12
  isEditMode: boolean;
13
13
  shapes: ShapeEntity[];
14
+ duplicateShapes: (shapesToDuplicate: ShapeEntity[]) => void;
14
15
  saveShapes: () => void;
15
16
  addShapes: (newShape: ShapeEntity[]) => void;
16
17
  updateSingleShape: (updatedShape: ShapeEntity[], withSave?: boolean) => void;
@@ -43,6 +44,7 @@ type DrawerType = {
43
44
  setSelectionMode: React.Dispatch<React.SetStateAction<SelectionModeData<number | Point>>>;
44
45
  isShiftPressed: boolean;
45
46
  isAltPressed: boolean;
47
+ isSpacePressed: boolean;
46
48
  withFrameSelection: boolean;
47
49
  withSkeleton: boolean;
48
50
  setCanvasMoveAcceleration: React.Dispatch<React.SetStateAction<Point>>;
@@ -1,9 +1,9 @@
1
1
  import type { UtilsSettings } from './../../canvas/constants/app';
2
- import type { DrawableShape } from './../../common/types/Shapes';
2
+ import type { ShapeEntity } from './../../common/types/Shapes';
3
3
  import './EditTextBox.css';
4
4
  type EditTextBoxType = {
5
5
  disabled?: boolean;
6
- shape: DrawableShape<'text'>;
6
+ shape: ShapeEntity<'text'>;
7
7
  defaultValue: string[];
8
8
  settings: UtilsSettings;
9
9
  updateValue: (newValue: string[]) => void;
@@ -26,6 +26,7 @@ export type UtilsSettings = {
26
26
  zoom: boolean;
27
27
  edition: boolean;
28
28
  };
29
+ debug: boolean;
29
30
  };
30
31
  type AppOptionsType = {
31
32
  layersManipulation: boolean;
@@ -45,6 +46,7 @@ type AppOptionsType = {
45
46
  canvasSelectionPadding: number;
46
47
  size: Size;
47
48
  canZoom: 'never' | 'always';
49
+ debug: boolean;
48
50
  };
49
51
  export type OptionalOptions = RecursivePartial<AppOptionsType>;
50
52
  export declare const DEFAULT_OPTIONS: AppOptionsType;
@@ -0,0 +1,24 @@
1
+ export declare const KeyboardCode: {
2
+ readonly ArrowUp: "ArrowUp";
3
+ readonly ArrowDown: "ArrowDown";
4
+ readonly ArrowLeft: "ArrowLeft";
5
+ readonly ArrowRight: "ArrowRight";
6
+ readonly Delete: "Delete";
7
+ readonly Backspace: "Backspace";
8
+ readonly Escape: "Escape";
9
+ readonly Shift: "Shift";
10
+ readonly Alt: "Alt";
11
+ readonly Option: "Option";
12
+ readonly Space: " ";
13
+ readonly z: "z";
14
+ readonly Z: "Z";
15
+ readonly y: "y";
16
+ readonly Y: "Y";
17
+ readonly Plus: "+";
18
+ readonly Minus: "-";
19
+ readonly Zero: "0";
20
+ };
21
+ export declare const KeyboardCommand: {
22
+ readonly Copy: "copy";
23
+ readonly Paste: "paste";
24
+ };
@@ -3,8 +3,10 @@ import { type RefObject } from 'react';
3
3
  type UseComponentType = {
4
4
  settings: UtilsSettings;
5
5
  componentRef: RefObject<HTMLElement | null>;
6
+ canvasRef: RefObject<HTMLCanvasElement | null>;
6
7
  };
7
- declare const useComponent: ({ settings, componentRef }: UseComponentType) => {
8
+ declare const useComponent: ({ settings, componentRef, canvasRef }: UseComponentType) => {
8
9
  isInsideComponent: boolean;
10
+ isInsideCanvas: boolean;
9
11
  };
10
12
  export default useComponent;
@@ -0,0 +1,2 @@
1
+ declare const useDebounce: <T extends (...args: any[]) => void>(callback: T, delay?: number) => (...args: Parameters<T>) => void;
2
+ export default useDebounce;
@@ -14,6 +14,7 @@ type UseCanvasType = {
14
14
  setActiveTool: React.Dispatch<React.SetStateAction<ToolsType>>;
15
15
  refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
16
16
  refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point, settings: UtilsSettings) => void;
17
+ duplicateShapes: (shapesToDuplicate: ShapeEntity[]) => void;
17
18
  canvasOffsetStartData: {
18
19
  start: Point;
19
20
  originalOffset: Point;
@@ -36,8 +37,9 @@ type UseCanvasType = {
36
37
  isAltPressed: boolean;
37
38
  withFrameSelection: boolean;
38
39
  settings: UtilsSettings;
40
+ isSpacePressed: boolean;
39
41
  };
40
- declare const useDrawableCanvas: ({ addShapes, drawCanvasRef, setActiveTool, refreshHoveredShape, shapes, selectionMode, activeTool, isInsideComponent, setCanvasOffset, selectedShape, canvasOffsetStartData, refreshSelectedShapes, setSelectedShape, setSelectionFrame, setCanvasOffsetStartData, updateSingleShape, saveShapes, setSelectionMode, setCanvasMoveAcceleration, settings, isShiftPressed, isAltPressed, withFrameSelection }: UseCanvasType) => {
42
+ declare const useDrawableCanvas: ({ addShapes, drawCanvasRef, setActiveTool, refreshHoveredShape, shapes, selectionMode, activeTool, isInsideComponent, setCanvasOffset, selectedShape, canvasOffsetStartData, refreshSelectedShapes, setSelectedShape, setSelectionFrame, setCanvasOffsetStartData, updateSingleShape, duplicateShapes, saveShapes, setSelectionMode, setCanvasMoveAcceleration, settings, isShiftPressed, isAltPressed, withFrameSelection, isSpacePressed }: UseCanvasType) => {
41
43
  hoverMode: HoverModeData;
42
44
  };
43
45
  export default useDrawableCanvas;
@@ -4,6 +4,7 @@ import type { Point, SelectionType, ShapeEntity } from './../../common/types/Sha
4
4
  import type { ToolsType } from './../../common/types/tools';
5
5
  type UseKeyboardType = {
6
6
  isInsideComponent: boolean;
7
+ isInsideCanvas: boolean;
7
8
  selectedShape: SelectionType | undefined;
8
9
  pasteShapes: (shape: ShapeEntity[]) => void;
9
10
  updateShapes: (shapes: ShapeEntity[]) => void;
@@ -13,6 +14,7 @@ type UseKeyboardType = {
13
14
  forwardShape: () => void;
14
15
  setShiftPressed: (value: React.SetStateAction<boolean>) => void;
15
16
  setAltPressed: (value: React.SetStateAction<boolean>) => void;
17
+ setIsSpacePressed: (value: React.SetStateAction<boolean>) => void;
16
18
  isEditingText: boolean;
17
19
  setActiveTool: (tool: ToolsType) => void;
18
20
  setSelectionMode: (mode: SelectionModeData<number | Point>) => void;
@@ -21,6 +23,8 @@ type UseKeyboardType = {
21
23
  frame: [Point, Point];
22
24
  } | undefined) => void;
23
25
  settings: UtilsSettings;
26
+ setCanvasZoom: (action: 'unzoom' | 'zoom' | 'default') => void;
27
+ resetZoom: () => void;
24
28
  };
25
- declare const useKeyboard: ({ isInsideComponent, selectedShape, isEditingText, settings, setSelectedShape, setActiveTool, setSelectionMode, setSelectionFrame, removeShape, pasteShapes, updateShapes, backwardShape, forwardShape, setShiftPressed, setAltPressed }: UseKeyboardType) => {};
29
+ declare const useKeyboard: ({ isInsideComponent, isInsideCanvas, selectedShape, isEditingText, settings, setSelectedShape, setActiveTool, setCanvasZoom, resetZoom, setSelectionMode, setSelectionFrame, removeShape, pasteShapes, updateShapes, backwardShape, forwardShape, setShiftPressed, setAltPressed, setIsSpacePressed }: UseKeyboardType) => {};
26
30
  export default useKeyboard;