@yorab/react-paint 0.18.1 → 1.0.0-beta.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.
- package/README.md +266 -22
- package/dist/_chunks/canvas-CDYlr833.js +1 -0
- package/dist/_chunks/editor-BARYd5Od.js +1 -0
- package/dist/canvas/components/Canvas.d.ts +15 -3
- package/dist/canvas/components/EditTextBox.d.ts +4 -4
- package/dist/canvas/constants/app.d.ts +32 -17
- package/dist/canvas/constants/grid.d.ts +7 -0
- package/dist/canvas/constants/picture.d.ts +8 -0
- package/dist/canvas/constants/shapes.d.ts +2 -2
- package/dist/canvas/constants/tools.d.ts +12 -2
- package/dist/canvas/constants/zoom.d.ts +4 -2
- package/dist/canvas/context/PaintContext.d.ts +9 -0
- package/dist/canvas/hooks/useAnnotationsStyle.d.ts +5 -0
- package/dist/canvas/hooks/useAutoScroll.d.ts +4 -0
- package/dist/canvas/hooks/useCanvasRenderer.d.ts +17 -0
- package/dist/canvas/hooks/useDrawableCanvas.d.ts +8 -5
- package/dist/canvas/hooks/useDropPicture.d.ts +7 -0
- package/dist/canvas/hooks/useKeyboard.d.ts +6 -32
- package/dist/canvas/hooks/usePaintState.d.ts +9 -0
- package/dist/canvas/hooks/usePinchZoomAndMove.d.ts +3 -13
- package/dist/canvas/hooks/useReactPaint.d.ts +11 -163
- package/dist/canvas/hooks/useResizeObserver.d.ts +1 -0
- package/dist/canvas/hooks/useShapeEvents.d.ts +7 -0
- package/dist/canvas/hooks/useZoom.d.ts +4 -17
- package/dist/canvas/index.d.ts +24 -17
- package/dist/canvas/index.js +1 -1
- package/dist/canvas/store/createStore.d.ts +14 -0
- package/dist/canvas/store/eventEmitter.d.ts +11 -0
- package/dist/canvas/store/internal.d.ts +5 -0
- package/dist/canvas/store/paintStore.d.ts +898 -0
- package/dist/canvas/store/selectors.d.ts +855 -0
- package/dist/canvas/store/shapesReducer.d.ts +66 -0
- package/dist/canvas/store/types.d.ts +72 -0
- package/dist/canvas/types/Canvas.d.ts +19 -0
- package/dist/{src/common → canvas}/types/Mode.d.ts +8 -15
- package/dist/{common → canvas}/types/Settings.d.ts +6 -1
- package/dist/{common → canvas}/types/Shapes.d.ts +27 -21
- package/dist/canvas/types/editor.d.ts +388 -0
- package/dist/{common → canvas}/types/tools.d.ts +10 -6
- package/dist/{common → canvas}/utils/array.d.ts +2 -0
- package/dist/canvas/utils/canvas.d.ts +18 -2
- package/dist/canvas/utils/click.d.ts +17 -0
- package/dist/canvas/utils/data.d.ts +6 -5
- package/dist/canvas/utils/equality.d.ts +5 -0
- package/dist/canvas/utils/file.d.ts +36 -266
- package/dist/canvas/utils/grid.d.ts +1 -1
- package/dist/canvas/utils/intersect.d.ts +24 -14
- package/dist/canvas/utils/object.d.ts +11 -0
- package/dist/{src/common/utils/selection.d.ts → canvas/utils/selectedShapes.d.ts} +2 -2
- package/dist/canvas/utils/selection/anchors.d.ts +16 -0
- package/dist/canvas/utils/selection/groupSelection.d.ts +3 -3
- package/dist/canvas/utils/selection/lineSelection.d.ts +3 -10
- package/dist/canvas/utils/selection/rectSelection.d.ts +6 -11
- package/dist/canvas/utils/selection/selectionFrame.d.ts +2 -2
- package/dist/canvas/utils/selection.d.ts +7 -5
- package/dist/canvas/utils/shapeInput.d.ts +45 -0
- package/dist/canvas/utils/shapePatch.d.ts +10 -0
- package/dist/canvas/utils/shapes/brush.d.ts +6 -6
- package/dist/canvas/utils/shapes/circle.d.ts +5 -5
- package/dist/canvas/utils/shapes/curve.d.ts +4 -4
- package/dist/canvas/utils/shapes/ellipse.d.ts +5 -5
- package/dist/canvas/utils/shapes/group.d.ts +9 -3
- package/dist/canvas/utils/shapes/index.d.ts +31 -5
- package/dist/canvas/utils/shapes/line.d.ts +5 -5
- package/dist/canvas/utils/shapes/path.d.ts +16 -8
- package/dist/canvas/utils/shapes/picture.d.ts +7 -5
- package/dist/canvas/utils/shapes/polygon.d.ts +4 -4
- package/dist/canvas/utils/shapes/rectangle.d.ts +5 -5
- package/dist/canvas/utils/shapes/text.d.ts +12 -6
- package/dist/canvas/utils/shapes/triangle.d.ts +2 -2
- package/dist/canvas/utils/tools.d.ts +12 -3
- package/dist/canvas/utils/transform.d.ts +5 -4
- package/dist/canvas/utils/trigo.d.ts +17 -1
- package/dist/canvas/utils/util.d.ts +14 -0
- package/dist/canvas/utils/zoom.d.ts +29 -15
- package/dist/editor/components/common/Button.d.ts +0 -1
- package/dist/editor/components/common/FileInput.d.ts +0 -1
- package/dist/editor/components/common/Loading.d.ts +1 -2
- package/dist/editor/components/common/Menu.d.ts +3 -2
- package/dist/editor/components/common/Modal.d.ts +1 -2
- package/dist/editor/components/common/Panel.d.ts +1 -2
- package/dist/editor/components/common/Snackbar.d.ts +2 -3
- package/dist/editor/components/settings/ClosedPointsField.d.ts +1 -1
- package/dist/editor/components/settings/ColorField.d.ts +1 -2
- package/dist/editor/components/settings/DeleteButton.d.ts +3 -4
- package/dist/editor/components/settings/FontFamilyField.d.ts +1 -2
- package/dist/editor/components/settings/LayoutButton.d.ts +1 -2
- package/dist/editor/components/settings/Layouts.d.ts +4 -15
- package/dist/editor/components/settings/LineArrowField.d.ts +1 -2
- package/dist/editor/components/settings/LineTypeField.d.ts +2 -3
- package/dist/editor/components/settings/RangeField.d.ts +1 -2
- package/dist/editor/components/settings/SelectField.d.ts +1 -2
- package/dist/editor/components/settings/SettingsBar.d.ts +3 -18
- package/dist/editor/components/settings/ToggleField.d.ts +2 -1
- package/dist/editor/components/settings/ZoomButton.d.ts +1 -2
- package/dist/editor/components/settings/ZoomPanel.d.ts +4 -0
- package/dist/editor/components/toolbox/ActionButton.d.ts +9 -0
- package/dist/editor/components/toolbox/ContextMenu.d.ts +5 -24
- package/dist/editor/components/toolbox/ExportModal.d.ts +1 -2
- package/dist/editor/components/toolbox/LoadFileTool.d.ts +4 -4
- package/dist/editor/components/toolbox/MenuGroup.d.ts +1 -7
- package/dist/editor/components/toolbox/PictureUrlInput.d.ts +2 -2
- package/dist/editor/components/toolbox/Tool.d.ts +3 -3
- package/dist/editor/components/toolbox/Toolbar.d.ts +5 -16
- package/dist/editor/components/toolbox/ToolbarGroup.d.ts +2 -3
- package/dist/editor/constants/options.d.ts +11 -1
- package/dist/editor/constants/snackbar.d.ts +1 -1
- package/dist/editor/constants/style.d.ts +0 -9
- package/dist/editor/constants/tools.d.ts +12 -32
- package/dist/editor/editor.css +1 -0
- package/dist/editor/hooks/useDrag.d.ts +3 -3
- package/dist/editor/hooks/useMenu.d.ts +3 -2
- package/dist/editor/hooks/usePressOutside.d.ts +7 -0
- package/dist/editor/hooks/useSnackbar.d.ts +1 -1
- package/dist/editor/index.d.ts +12 -22
- package/dist/editor/index.js +1 -1
- package/dist/editor/types/tools.d.ts +7 -0
- package/dist/editor/utils/dom.d.ts +1 -0
- package/dist/editor/utils/style.d.ts +7 -1
- package/dist/editor/utils/toolbar.d.ts +1 -2
- package/dist/editor/utils/util.d.ts +5 -0
- package/dist/index.d.ts +2 -5
- package/dist/react-paint.css +1 -1
- package/dist/react-paint.js +1 -1
- package/dist/react-paint.umd.cjs +1 -1
- package/package.json +37 -26
- package/dist/_chunks/array-DuJem3vg.js +0 -1
- package/dist/_chunks/canvas-DF1RWuxW.js +0 -1
- package/dist/_chunks/editor-DuVskl0R.js +0 -1
- package/dist/canvas/context/CanvasContext.d.ts +0 -55
- package/dist/canvas/hooks/useComponent.d.ts +0 -12
- package/dist/canvas/hooks/useDoubleClick.d.ts +0 -5
- package/dist/canvas/hooks/useEventListener.d.ts +0 -2
- package/dist/canvas/hooks/useShapes.d.ts +0 -44
- package/dist/common/hooks/useDebounce.d.ts +0 -2
- package/dist/common/types/Canvas.d.ts +0 -8
- package/dist/common/types/Mode.d.ts +0 -64
- package/dist/common/types/react.d.ts +0 -6
- package/dist/common/utils/dom.d.ts +0 -1
- package/dist/common/utils/object.d.ts +0 -4
- package/dist/common/utils/selection.d.ts +0 -4
- package/dist/common/utils/util.d.ts +0 -3
- package/dist/editor/constants/grid.d.ts +0 -7
- package/dist/src/canvas/components/Canvas.d.ts +0 -4
- package/dist/src/canvas/components/EditTextBox.d.ts +0 -13
- package/dist/src/canvas/constants/app.d.ts +0 -37
- package/dist/src/canvas/constants/grid.d.ts +0 -1
- package/dist/src/canvas/constants/keyboard.d.ts +0 -27
- package/dist/src/canvas/constants/picture.d.ts +0 -1
- package/dist/src/canvas/constants/rendering.d.ts +0 -3
- package/dist/src/canvas/constants/shapes.d.ts +0 -10
- package/dist/src/canvas/constants/tools.d.ts +0 -4
- package/dist/src/canvas/constants/zoom.d.ts +0 -5
- package/dist/src/canvas/context/CanvasContext.d.ts +0 -55
- package/dist/src/canvas/hooks/useComponent.d.ts +0 -12
- package/dist/src/canvas/hooks/useDoubleClick.d.ts +0 -5
- package/dist/src/canvas/hooks/useDrawableCanvas.d.ts +0 -6
- package/dist/src/canvas/hooks/useEventListener.d.ts +0 -2
- package/dist/src/canvas/hooks/useKeyboard.d.ts +0 -33
- package/dist/src/canvas/hooks/usePinchZoomAndMove.d.ts +0 -17
- package/dist/src/canvas/hooks/useReactPaint.d.ts +0 -164
- package/dist/src/canvas/hooks/useResizeObserver.d.ts +0 -6
- package/dist/src/canvas/hooks/useShapes.d.ts +0 -44
- package/dist/src/canvas/hooks/useZoom.d.ts +0 -22
- package/dist/src/canvas/index.d.ts +0 -19
- package/dist/src/canvas/utils/canvas.d.ts +0 -15
- package/dist/src/canvas/utils/data.d.ts +0 -5
- package/dist/src/canvas/utils/file.d.ts +0 -274
- package/dist/src/canvas/utils/grid.d.ts +0 -2
- package/dist/src/canvas/utils/intersect.d.ts +0 -27
- package/dist/src/canvas/utils/selection/groupSelection.d.ts +0 -4
- package/dist/src/canvas/utils/selection/lineSelection.d.ts +0 -19
- package/dist/src/canvas/utils/selection/rectSelection.d.ts +0 -20
- package/dist/src/canvas/utils/selection/selectionFrame.d.ts +0 -3
- package/dist/src/canvas/utils/selection.d.ts +0 -12
- package/dist/src/canvas/utils/shapes/brush.d.ts +0 -21
- package/dist/src/canvas/utils/shapes/circle.d.ts +0 -18
- package/dist/src/canvas/utils/shapes/curve.d.ts +0 -17
- package/dist/src/canvas/utils/shapes/ellipse.d.ts +0 -18
- package/dist/src/canvas/utils/shapes/group.d.ts +0 -33
- package/dist/src/canvas/utils/shapes/index.d.ts +0 -35
- package/dist/src/canvas/utils/shapes/line.d.ts +0 -19
- package/dist/src/canvas/utils/shapes/path.d.ts +0 -29
- package/dist/src/canvas/utils/shapes/picture.d.ts +0 -13
- package/dist/src/canvas/utils/shapes/polygon.d.ts +0 -18
- package/dist/src/canvas/utils/shapes/rectangle.d.ts +0 -22
- package/dist/src/canvas/utils/shapes/text.d.ts +0 -27
- package/dist/src/canvas/utils/shapes/triangle.d.ts +0 -4
- package/dist/src/canvas/utils/transform.d.ts +0 -15
- package/dist/src/canvas/utils/trigo.d.ts +0 -19
- package/dist/src/canvas/utils/zoom.d.ts +0 -58
- package/dist/src/common/hooks/useDebounce.d.ts +0 -2
- package/dist/src/common/types/Canvas.d.ts +0 -8
- package/dist/src/common/types/Settings.d.ts +0 -24
- package/dist/src/common/types/Shapes.d.ts +0 -153
- package/dist/src/common/types/react.d.ts +0 -6
- package/dist/src/common/types/tools.d.ts +0 -164
- package/dist/src/common/types/utils.d.ts +0 -4
- package/dist/src/common/utils/array.d.ts +0 -2
- package/dist/src/common/utils/dom.d.ts +0 -1
- package/dist/src/common/utils/object.d.ts +0 -4
- package/dist/src/common/utils/util.d.ts +0 -3
- package/dist/src/editor/components/common/Button.d.ts +0 -16
- package/dist/src/editor/components/common/FileInput.d.ts +0 -13
- package/dist/src/editor/components/common/Loading.d.ts +0 -6
- package/dist/src/editor/components/common/Menu.d.ts +0 -10
- package/dist/src/editor/components/common/Modal.d.ts +0 -11
- package/dist/src/editor/components/common/Panel.d.ts +0 -15
- package/dist/src/editor/components/common/Snackbar.d.ts +0 -7
- package/dist/src/editor/components/settings/ClosedPointsField.d.ts +0 -10
- package/dist/src/editor/components/settings/ColorField.d.ts +0 -15
- package/dist/src/editor/components/settings/DeleteButton.d.ts +0 -8
- package/dist/src/editor/components/settings/FontFamilyField.d.ts +0 -12
- package/dist/src/editor/components/settings/LayoutButton.d.ts +0 -7
- package/dist/src/editor/components/settings/Layouts.d.ts +0 -19
- package/dist/src/editor/components/settings/LineArrowField.d.ts +0 -12
- package/dist/src/editor/components/settings/LineTypeField.d.ts +0 -16
- package/dist/src/editor/components/settings/RangeField.d.ts +0 -19
- package/dist/src/editor/components/settings/SelectField.d.ts +0 -18
- package/dist/src/editor/components/settings/SettingsBar.d.ts +0 -26
- package/dist/src/editor/components/settings/ToggleField.d.ts +0 -13
- package/dist/src/editor/components/settings/ZoomButton.d.ts +0 -8
- package/dist/src/editor/components/toolbox/ContextMenu.d.ts +0 -25
- package/dist/src/editor/components/toolbox/ExportModal.d.ts +0 -7
- package/dist/src/editor/components/toolbox/LoadFileTool.d.ts +0 -11
- package/dist/src/editor/components/toolbox/MenuGroup.d.ts +0 -27
- package/dist/src/editor/components/toolbox/PictureUrlInput.d.ts +0 -7
- package/dist/src/editor/components/toolbox/Tool.d.ts +0 -11
- package/dist/src/editor/components/toolbox/Toolbar.d.ts +0 -26
- package/dist/src/editor/components/toolbox/ToolbarGroup.d.ts +0 -14
- package/dist/src/editor/constants/grid.d.ts +0 -7
- package/dist/src/editor/constants/icons.d.ts +0 -43
- package/dist/src/editor/constants/loading.d.ts +0 -1
- package/dist/src/editor/constants/options.d.ts +0 -13
- package/dist/src/editor/constants/snackbar.d.ts +0 -7
- package/dist/src/editor/constants/style.d.ts +0 -14
- package/dist/src/editor/constants/tools.d.ts +0 -32
- package/dist/src/editor/hooks/useDrag.d.ts +0 -15
- package/dist/src/editor/hooks/useMenu.d.ts +0 -11
- package/dist/src/editor/hooks/useSnackbar.d.ts +0 -10
- package/dist/src/editor/index.d.ts +0 -25
- package/dist/src/editor/types/snackbar.d.ts +0 -7
- package/dist/src/editor/utils/style.d.ts +0 -2
- package/dist/src/editor/utils/toolbar.d.ts +0 -11
- package/dist/src/index.d.ts +0 -5
- /package/dist/{common → canvas}/types/utils.d.ts +0 -0
- /package/dist/{canvas → editor}/hooks/useDebounce.d.ts +0 -0
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { Point, SelectionType } from './Shapes';
|
|
2
|
-
export type SelectionModeDefault = {
|
|
3
|
-
mode: 'default';
|
|
4
|
-
};
|
|
5
|
-
export type SelectionModeSelectionFrame = {
|
|
6
|
-
mode: 'selectionFrame';
|
|
7
|
-
};
|
|
8
|
-
export type SelectionModeBrush = {
|
|
9
|
-
mode: 'brush';
|
|
10
|
-
};
|
|
11
|
-
export type SelectionModePreview = {
|
|
12
|
-
mode: 'preview';
|
|
13
|
-
};
|
|
14
|
-
export type SelectionModeEditText = {
|
|
15
|
-
mode: 'textedition';
|
|
16
|
-
defaultValue: string[];
|
|
17
|
-
};
|
|
18
|
-
export type SelectionModeResize<AnchorType extends Point | number = Point> = {
|
|
19
|
-
mode: 'resize';
|
|
20
|
-
cursorStartPosition: Point;
|
|
21
|
-
originalShape: SelectionType;
|
|
22
|
-
selectedShapesLengthAtMouseDown: number;
|
|
23
|
-
anchor: AnchorType;
|
|
24
|
-
};
|
|
25
|
-
export type SelectionModeRotate = {
|
|
26
|
-
mode: 'rotate';
|
|
27
|
-
cursorStartPosition: Point;
|
|
28
|
-
originalShape: SelectionType;
|
|
29
|
-
selectedShapesLengthAtMouseDown: number;
|
|
30
|
-
center: Point;
|
|
31
|
-
};
|
|
32
|
-
export type SelectionModeTranslate = {
|
|
33
|
-
mode: 'translate';
|
|
34
|
-
cursorStartPosition: Point;
|
|
35
|
-
originalShape: SelectionType;
|
|
36
|
-
selectedShapesLengthAtMouseDown: number;
|
|
37
|
-
hasBeenDuplicated: boolean;
|
|
38
|
-
dateStart: number;
|
|
39
|
-
};
|
|
40
|
-
export type SelectionModeContextMenu<AnchorType extends Point | number = Point> = {
|
|
41
|
-
mode: 'contextMenu';
|
|
42
|
-
cursorStartPosition: Point;
|
|
43
|
-
originalShape: SelectionType | undefined;
|
|
44
|
-
anchor: AnchorType | undefined;
|
|
45
|
-
};
|
|
46
|
-
export type SelectionModeData<AnchorType extends Point | number> = SelectionModeDefault | SelectionModeSelectionFrame | SelectionModeBrush | SelectionModeResize<AnchorType> | SelectionModeRotate | SelectionModeTranslate | SelectionModeEditText | SelectionModePreview | SelectionModeContextMenu<AnchorType>;
|
|
47
|
-
export type HoverModeData = {
|
|
48
|
-
outOfView?: boolean;
|
|
49
|
-
} & ({
|
|
50
|
-
mode: 'default';
|
|
51
|
-
} | {
|
|
52
|
-
mode: 'selectionFrame';
|
|
53
|
-
} | {
|
|
54
|
-
mode: 'resize';
|
|
55
|
-
anchor: Point | number;
|
|
56
|
-
} | {
|
|
57
|
-
mode: 'brush';
|
|
58
|
-
} | {
|
|
59
|
-
mode: 'rotate';
|
|
60
|
-
} | {
|
|
61
|
-
mode: 'translate';
|
|
62
|
-
} | {
|
|
63
|
-
mode: 'textedition';
|
|
64
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isEventInsideNode: (event: MouseEvent | TouchEvent, node: HTMLElement | null) => boolean;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const omit: <T extends Record<string, unknown>>(keys: (string | [string, unknown[]])[], obj: T) => T;
|
|
2
|
-
export declare const set: <T extends Record<string, any> | unknown[]>(path: string | number | (string | number)[], value: unknown, obj: T) => T;
|
|
3
|
-
export declare const mergeWith: (customMergeFn: (objValue: unknown, srcValue: unknown, key: string) => unknown, target: unknown, source: unknown) => unknown;
|
|
4
|
-
export declare const isEqual: (a: unknown, b: unknown) => boolean;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { SelectionType, ShapeEntity } from './../../common/types/Shapes';
|
|
2
|
-
import type { CustomTool } from './../../common/types/tools';
|
|
3
|
-
export declare const getSelectedShapes: (selection: SelectionType | undefined) => ShapeEntity[];
|
|
4
|
-
export declare const getSelectedShapesTools: (selection: SelectionType | undefined, availableTools: CustomTool[]) => CustomTool | undefined;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
|
-
import type { ShapeEntity } from './../../../common/types/Shapes';
|
|
3
|
-
import './EditTextBox.css';
|
|
4
|
-
type EditTextBoxType = {
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
shape: ShapeEntity<'text'>;
|
|
7
|
-
defaultValue: string[];
|
|
8
|
-
settings: UtilsSettings;
|
|
9
|
-
updateValue: (newValue: string[]) => void;
|
|
10
|
-
saveShapes: () => void;
|
|
11
|
-
};
|
|
12
|
-
declare const EditTextBox: ({ disabled, shape, defaultValue, updateValue, saveShapes, settings }: EditTextBoxType) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export default EditTextBox;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Size } from './../../../common/types/Canvas';
|
|
2
|
-
import type { ExportedDrawableShape } from './../../../common/types/Shapes';
|
|
3
|
-
import type { CustomToolInput } from './../../../common/types/tools';
|
|
4
|
-
import type { RecursivePartial } from './../../../common/types/utils';
|
|
5
|
-
export declare const APP_NAME = "react_paint";
|
|
6
|
-
export declare const DRAWCANVAS_CLASSNAME = "react-paint-canvas-drawcanvas";
|
|
7
|
-
export declare const SELECTIONCANVAS_CLASSNAME = "react-paint-canvas-selectioncanvas";
|
|
8
|
-
import type { BrushAlgo } from './../../../common/types/Settings';
|
|
9
|
-
export type { BrushAlgo, UtilsSettings } from './../../../common/types/Settings';
|
|
10
|
-
type AppOptionsType = {
|
|
11
|
-
layersManipulation: boolean;
|
|
12
|
-
grid: number;
|
|
13
|
-
canGrow: boolean;
|
|
14
|
-
canShrink: boolean;
|
|
15
|
-
availableTools: CustomToolInput[];
|
|
16
|
-
withExport: boolean;
|
|
17
|
-
withLoadAndSave: boolean;
|
|
18
|
-
withUploadPicture: boolean;
|
|
19
|
-
withUrlPicture: boolean;
|
|
20
|
-
withFrameSelection: boolean;
|
|
21
|
-
withSkeleton: boolean;
|
|
22
|
-
withContextMenu: boolean;
|
|
23
|
-
clearCallback: 'empty' | 'defaultShapes' | (() => ExportedDrawableShape[]);
|
|
24
|
-
brushAlgo: BrushAlgo;
|
|
25
|
-
isBrushShapeDoneOnMouseUp: boolean;
|
|
26
|
-
canvasSelectionPadding: number;
|
|
27
|
-
size: Size;
|
|
28
|
-
canZoom: 'never' | 'always';
|
|
29
|
-
debug: boolean;
|
|
30
|
-
};
|
|
31
|
-
export type OptionalOptions = RecursivePartial<AppOptionsType>;
|
|
32
|
-
export declare const DEFAULT_OPTIONS: AppOptionsType;
|
|
33
|
-
export declare const DEFAULT_CANVAS_OPTIONS: {
|
|
34
|
-
canvasBackgroundColor: string;
|
|
35
|
-
canvasSelectionColor: string;
|
|
36
|
-
canvasSelectionWidth: number;
|
|
37
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const GRID_ROTATION_STEPS = 18;
|
|
@@ -1,27 +0,0 @@
|
|
|
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 A: "A";
|
|
14
|
-
readonly a: "a";
|
|
15
|
-
readonly z: "z";
|
|
16
|
-
readonly Z: "Z";
|
|
17
|
-
readonly y: "y";
|
|
18
|
-
readonly Y: "Y";
|
|
19
|
-
readonly Plus: "+";
|
|
20
|
-
readonly Minus: "-";
|
|
21
|
-
readonly Zero: "0";
|
|
22
|
-
};
|
|
23
|
-
export declare const KeyboardCommand: {
|
|
24
|
-
readonly Cut: "cut";
|
|
25
|
-
readonly Copy: "copy";
|
|
26
|
-
readonly Paste: "paste";
|
|
27
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const PICTURE_DEFAULT_SIZE = 300;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Point } from './../../../common/types/Shapes';
|
|
2
|
-
export declare const SELECTION_DEFAULT_PADDING = 0;
|
|
3
|
-
export declare const SELECTION_DEFAULT_WIDTH = 2;
|
|
4
|
-
export declare const SELECTION_DEFAULT_COLOR = "blue";
|
|
5
|
-
export declare const SELECTION_ANCHOR_SIZE = 14;
|
|
6
|
-
export declare const SELECTION_ROTATED_ANCHOR_POSITION = 16;
|
|
7
|
-
export declare const SELECTION_RESIZE_ANCHOR_POSITIONS: Point[];
|
|
8
|
-
export declare const ShapeTypeArray: readonly ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle", "group"];
|
|
9
|
-
export declare const SHAPES_WITH_ROTATION: string[];
|
|
10
|
-
export declare const SHAPES_KEEPING_RATIO: string[];
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
|
-
import type { SelectionModeData } from './../../../common/types/Mode';
|
|
3
|
-
import type { Point, SelectionType, ShapeEntity } from './../../../common/types/Shapes';
|
|
4
|
-
import type { ToolsType } from './../../../common/types/tools';
|
|
5
|
-
import type React from 'react';
|
|
6
|
-
export type CanvasContextType = {
|
|
7
|
-
shapes: ShapeEntity[];
|
|
8
|
-
settings: UtilsSettings;
|
|
9
|
-
selectedShape: SelectionType | undefined;
|
|
10
|
-
hoveredShape: ShapeEntity | undefined;
|
|
11
|
-
selectionFrame: {
|
|
12
|
-
oldSelection: SelectionType | undefined;
|
|
13
|
-
frame: [Point, Point];
|
|
14
|
-
} | undefined;
|
|
15
|
-
selectionMode: SelectionModeData<number | Point>;
|
|
16
|
-
activeTool: ToolsType;
|
|
17
|
-
canvasOffsetStartData: {
|
|
18
|
-
start: Point;
|
|
19
|
-
originalOffset: Point;
|
|
20
|
-
} | undefined;
|
|
21
|
-
isInsideComponent: boolean;
|
|
22
|
-
isInsideCanvas: boolean;
|
|
23
|
-
isShiftPressed: boolean;
|
|
24
|
-
isAltPressed: boolean;
|
|
25
|
-
isSpacePressed: boolean;
|
|
26
|
-
selectionColor: string;
|
|
27
|
-
selectionWidth: number;
|
|
28
|
-
isEditMode: boolean;
|
|
29
|
-
canGrow: boolean | undefined;
|
|
30
|
-
withFrameSelection: boolean;
|
|
31
|
-
withSkeleton: boolean;
|
|
32
|
-
withContextMenu: boolean;
|
|
33
|
-
setSelectedShape: React.Dispatch<React.SetStateAction<SelectionType | undefined>>;
|
|
34
|
-
setSelectionFrame: React.Dispatch<React.SetStateAction<{
|
|
35
|
-
oldSelection: SelectionType | undefined;
|
|
36
|
-
frame: [Point, Point];
|
|
37
|
-
} | undefined>>;
|
|
38
|
-
setSelectionMode: React.Dispatch<React.SetStateAction<SelectionModeData<number | Point>>>;
|
|
39
|
-
setActiveTool: React.Dispatch<React.SetStateAction<ToolsType>>;
|
|
40
|
-
setCanvasOffsetStartData: React.Dispatch<React.SetStateAction<{
|
|
41
|
-
start: Point;
|
|
42
|
-
originalOffset: Point;
|
|
43
|
-
} | undefined>>;
|
|
44
|
-
setCanvasOffset: (offset: Point) => void;
|
|
45
|
-
setCanvasMoveAcceleration: React.Dispatch<React.SetStateAction<Point>>;
|
|
46
|
-
addShapes: (newShapes: ShapeEntity[]) => void;
|
|
47
|
-
updateSingleShape: (updatedShape: ShapeEntity[], withSave?: boolean) => void;
|
|
48
|
-
duplicateShapes: (shapesToDuplicate: ShapeEntity[]) => void;
|
|
49
|
-
saveShapes: () => void;
|
|
50
|
-
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
|
|
51
|
-
refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point, settings: UtilsSettings) => void;
|
|
52
|
-
};
|
|
53
|
-
declare const CanvasContext: React.Context<CanvasContextType | undefined>;
|
|
54
|
-
export declare const useCanvasContext: () => CanvasContextType;
|
|
55
|
-
export default CanvasContext;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
|
-
import { type RefObject } from 'react';
|
|
3
|
-
type UseComponentType = {
|
|
4
|
-
settings: UtilsSettings;
|
|
5
|
-
componentRef: RefObject<HTMLElement | null>;
|
|
6
|
-
canvasRef: RefObject<HTMLCanvasElement | null>;
|
|
7
|
-
};
|
|
8
|
-
declare const useComponent: ({ settings, componentRef, canvasRef }: UseComponentType) => {
|
|
9
|
-
isInsideComponent: boolean;
|
|
10
|
-
isInsideCanvas: boolean;
|
|
11
|
-
};
|
|
12
|
-
export default useComponent;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
|
-
import type { SelectionModeData } from './../../../common/types/Mode';
|
|
3
|
-
import type { Point, SelectionType, ShapeEntity } from './../../../common/types/Shapes';
|
|
4
|
-
import type { ToolsType } from './../../../common/types/tools';
|
|
5
|
-
type UseKeyboardType = {
|
|
6
|
-
isInsideComponent: boolean;
|
|
7
|
-
isInsideCanvas: boolean;
|
|
8
|
-
selectedShape: SelectionType | undefined;
|
|
9
|
-
pasteShapes: (shape: ShapeEntity[]) => void;
|
|
10
|
-
updateShapes: (shapes: ShapeEntity[]) => void;
|
|
11
|
-
setSelectedShape: (value: React.SetStateAction<SelectionType | undefined>) => void;
|
|
12
|
-
selectAllShapes: () => void;
|
|
13
|
-
removeShape: (shape: ShapeEntity[]) => void;
|
|
14
|
-
backwardShape: () => void;
|
|
15
|
-
forwardShape: () => void;
|
|
16
|
-
setShiftPressed: (value: React.SetStateAction<boolean>) => void;
|
|
17
|
-
setAltPressed: (value: React.SetStateAction<boolean>) => void;
|
|
18
|
-
setIsSpacePressed: (value: React.SetStateAction<boolean>) => void;
|
|
19
|
-
isEditingText: boolean;
|
|
20
|
-
setActiveTool: (tool: ToolsType) => void;
|
|
21
|
-
setSelectionMode: (mode: SelectionModeData<number | Point>) => void;
|
|
22
|
-
setSelectionFrame: (args: {
|
|
23
|
-
oldSelection: SelectionType | undefined;
|
|
24
|
-
frame: [Point, Point];
|
|
25
|
-
} | undefined) => void;
|
|
26
|
-
settings: UtilsSettings;
|
|
27
|
-
setCanvasZoom: (action: 'unzoom' | 'zoom' | 'default') => void;
|
|
28
|
-
resetZoom: () => void;
|
|
29
|
-
copiedShape: SelectionType | undefined;
|
|
30
|
-
setCopiedShape: (shape: React.SetStateAction<SelectionType | undefined>) => void;
|
|
31
|
-
};
|
|
32
|
-
declare const useKeyboard: ({ isInsideComponent, isInsideCanvas, selectedShape, isEditingText, settings, copiedShape, setCopiedShape, setSelectedShape, setActiveTool, setCanvasZoom, resetZoom, setSelectionMode, setSelectionFrame, selectAllShapes, removeShape, pasteShapes, updateShapes, backwardShape, forwardShape, setShiftPressed, setAltPressed, setIsSpacePressed }: UseKeyboardType) => {};
|
|
33
|
-
export default useKeyboard;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { CanvasSize, Size } from './../../../common/types/Canvas';
|
|
2
|
-
import type { Point } from './../../../common/types/Shapes';
|
|
3
|
-
type UsePinchZoomProps = {
|
|
4
|
-
canvasElt: HTMLElement | null;
|
|
5
|
-
canvasTransformation: {
|
|
6
|
-
offset: Point;
|
|
7
|
-
zoom: number;
|
|
8
|
-
};
|
|
9
|
-
canvasSize: CanvasSize;
|
|
10
|
-
size: Size;
|
|
11
|
-
setCanvasTransformation: (transformation: {
|
|
12
|
-
offset: Point;
|
|
13
|
-
zoom: number;
|
|
14
|
-
}) => void;
|
|
15
|
-
};
|
|
16
|
-
declare const usePinchZoomAndMove: ({ canvasElt, canvasTransformation, canvasSize, size, setCanvasTransformation }: UsePinchZoomProps) => void;
|
|
17
|
-
export default usePinchZoomAndMove;
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { type OptionalOptions, type UtilsSettings } from './../../../canvas/constants/app';
|
|
2
|
-
import { calculateTextFontSize } from './../../../canvas/utils/shapes/text';
|
|
3
|
-
import type { CanvasSize } from './../../../common/types/Canvas';
|
|
4
|
-
import type { SelectionModeData } from './../../../common/types/Mode';
|
|
5
|
-
import type { ExportedDrawableShape, Point, SelectionType, ShapeEntity, StateData } from './../../../common/types/Shapes';
|
|
6
|
-
import type { CustomTool, ToolsType } from './../../../common/types/tools';
|
|
7
|
-
import { type CSSProperties } from 'react';
|
|
8
|
-
type UseReactPaintProps = {
|
|
9
|
-
width?: number | undefined;
|
|
10
|
-
height?: number | undefined;
|
|
11
|
-
shapes?: ExportedDrawableShape[] | undefined;
|
|
12
|
-
mode?: 'editor' | 'viewer' | undefined;
|
|
13
|
-
disabled?: boolean | undefined;
|
|
14
|
-
options?: OptionalOptions | undefined;
|
|
15
|
-
};
|
|
16
|
-
export type EditorProps = {
|
|
17
|
-
shapes: ShapeEntity[];
|
|
18
|
-
addPictureShape: (fileOrUrl: File | string, maxWidth?: number, maxHeight?: number) => Promise<ShapeEntity>;
|
|
19
|
-
swapShapes: (startPositionShapeId: string, endPositionShapeId: string) => void;
|
|
20
|
-
moveShapes: (shapes: ShapeEntity[], action: 'first' | 'last' | 'forward' | 'backward') => void;
|
|
21
|
-
toggleShapeVisibility: (shapes: ShapeEntity[]) => void;
|
|
22
|
-
toggleShapeLock: (shapeGroup: ShapeEntity[]) => void;
|
|
23
|
-
canGoBackward: boolean;
|
|
24
|
-
canGoForward: boolean;
|
|
25
|
-
canClear: boolean;
|
|
26
|
-
selectedShape: SelectionType | undefined;
|
|
27
|
-
copiedShape: SelectionType | undefined;
|
|
28
|
-
setCopiedShape: React.Dispatch<React.SetStateAction<SelectionType | undefined>>;
|
|
29
|
-
pasteShapes: (shapes: ShapeEntity[]) => void;
|
|
30
|
-
saveShapes: () => void;
|
|
31
|
-
removeShape: (shapes: ShapeEntity[]) => void;
|
|
32
|
-
updateShape: (updatedShapes: ShapeEntity[], withSave?: boolean) => void;
|
|
33
|
-
duplicateShapes: (shapesToDuplicate: ShapeEntity[], translate?: boolean, selectNewOnes?: boolean) => void;
|
|
34
|
-
backwardShape: () => void;
|
|
35
|
-
forwardShape: () => void;
|
|
36
|
-
removeShapePoint: (shape: ShapeEntity<'curve' | 'polygon'>, pointIndex: number) => void;
|
|
37
|
-
transformShape: (ctx: CanvasRenderingContext2D, shapes: ShapeEntity[], center: Point, action: 'flipHorizontally' | 'flipVertically' | 'rotateClockwise' | 'rotateCounterclockwise') => void;
|
|
38
|
-
refs: {
|
|
39
|
-
canvas: React.RefObject<HTMLCanvasElement | null>;
|
|
40
|
-
editor: React.RefObject<HTMLElement | null>;
|
|
41
|
-
setEditor: (node: HTMLElement | null) => void;
|
|
42
|
-
};
|
|
43
|
-
width: number;
|
|
44
|
-
height: number;
|
|
45
|
-
selectTool: (tool: ToolsType) => void;
|
|
46
|
-
selectShapes: (shapes: ShapeEntity[]) => void;
|
|
47
|
-
selectAllShapes: () => void;
|
|
48
|
-
activeTool: ToolsType;
|
|
49
|
-
setActiveTool: React.Dispatch<React.SetStateAction<ToolsType>>;
|
|
50
|
-
setAvailableTools: React.Dispatch<React.SetStateAction<CustomTool[]>>;
|
|
51
|
-
isEditMode: boolean;
|
|
52
|
-
availableTools: CustomTool[];
|
|
53
|
-
gridGap: number;
|
|
54
|
-
setGridGap: React.Dispatch<React.SetStateAction<number>>;
|
|
55
|
-
loadFile: (file: File) => Promise<void>;
|
|
56
|
-
exportPicture: (view: 'fitToShapes' | 'defaultView' | 'currentZoom') => void;
|
|
57
|
-
exportData: () => void;
|
|
58
|
-
clearCanvas: () => void;
|
|
59
|
-
selectionMode: SelectionModeData<number | Point>;
|
|
60
|
-
setSelectionMode: React.Dispatch<React.SetStateAction<SelectionModeData<number | Point>>>;
|
|
61
|
-
settings: UtilsSettings;
|
|
62
|
-
setCanvasZoom: (action: 'unzoom' | 'zoom' | 'default') => void;
|
|
63
|
-
resetZoom: () => void;
|
|
64
|
-
buildShapesGroup: (shapes: ShapeEntity[]) => SelectionType | undefined;
|
|
65
|
-
copyShapes: (selection: SelectionType) => ShapeEntity[];
|
|
66
|
-
refreshShape: (shape: ShapeEntity) => ShapeEntity;
|
|
67
|
-
calculateTextFontSize: typeof calculateTextFontSize;
|
|
68
|
-
canvas: {
|
|
69
|
-
canGrow: boolean;
|
|
70
|
-
canShrink: boolean;
|
|
71
|
-
layersManipulation: boolean;
|
|
72
|
-
withExport: boolean;
|
|
73
|
-
withLoadAndSave: boolean;
|
|
74
|
-
withUploadPicture: boolean;
|
|
75
|
-
withUrlPicture: boolean;
|
|
76
|
-
withContextMenu: boolean;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
type CanvasProps = {
|
|
80
|
-
shapes: ShapeEntity[];
|
|
81
|
-
selectedShape: SelectionType | undefined;
|
|
82
|
-
copiedShape: SelectionType | undefined;
|
|
83
|
-
setCopiedShape: React.Dispatch<React.SetStateAction<SelectionType | undefined>>;
|
|
84
|
-
pasteShapes: (shapes: ShapeEntity[]) => void;
|
|
85
|
-
selectionFrame: {
|
|
86
|
-
oldSelection: SelectionType | undefined;
|
|
87
|
-
frame: [Point, Point];
|
|
88
|
-
} | undefined;
|
|
89
|
-
hoveredShape: ShapeEntity | undefined;
|
|
90
|
-
addShape: (newShapes: ShapeEntity[]) => void;
|
|
91
|
-
setSelectedShape: React.Dispatch<React.SetStateAction<SelectionType | undefined>>;
|
|
92
|
-
setSelectionFrame: React.Dispatch<React.SetStateAction<{
|
|
93
|
-
oldSelection: SelectionType | undefined;
|
|
94
|
-
frame: [Point, Point];
|
|
95
|
-
} | undefined>>;
|
|
96
|
-
refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point) => void;
|
|
97
|
-
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
|
|
98
|
-
removeShape: (shapes: ShapeEntity[]) => void;
|
|
99
|
-
updateShape: (updatedShapes: ShapeEntity[], withSave?: boolean) => void;
|
|
100
|
-
duplicateShapes: (shapesToDuplicate: ShapeEntity[], translate?: boolean, selectNewOnes?: boolean) => void;
|
|
101
|
-
backwardShape: () => void;
|
|
102
|
-
forwardShape: () => void;
|
|
103
|
-
saveShapes: () => void;
|
|
104
|
-
refs: {
|
|
105
|
-
canvas: React.RefObject<HTMLCanvasElement | null>;
|
|
106
|
-
editor: React.RefObject<HTMLElement | null>;
|
|
107
|
-
setEditor: (node: HTMLElement | null) => void;
|
|
108
|
-
};
|
|
109
|
-
width: number;
|
|
110
|
-
height: number;
|
|
111
|
-
selectShapes: (shapes: ShapeEntity[]) => void;
|
|
112
|
-
selectAllShapes: () => void;
|
|
113
|
-
activeTool: ToolsType;
|
|
114
|
-
setActiveTool: React.Dispatch<React.SetStateAction<ToolsType>>;
|
|
115
|
-
isEditMode: boolean;
|
|
116
|
-
settings: UtilsSettings;
|
|
117
|
-
setCanvasZoom: (action: 'unzoom' | 'zoom' | 'default') => void;
|
|
118
|
-
resetZoom: () => void;
|
|
119
|
-
setCanvasSize: React.Dispatch<React.SetStateAction<CanvasSize>>;
|
|
120
|
-
setCanvasOffset: (offset: Point) => void;
|
|
121
|
-
isInsideComponent: boolean;
|
|
122
|
-
isInsideCanvas: boolean;
|
|
123
|
-
canvas: {
|
|
124
|
-
withContextMenu: boolean;
|
|
125
|
-
withSkeleton: boolean;
|
|
126
|
-
withFrameSelection: boolean;
|
|
127
|
-
canGrow: boolean;
|
|
128
|
-
canShrink: boolean;
|
|
129
|
-
};
|
|
130
|
-
canvasOffsetStartData: {
|
|
131
|
-
start: Point;
|
|
132
|
-
originalOffset: Point;
|
|
133
|
-
} | undefined;
|
|
134
|
-
setCanvasOffsetStartData: React.Dispatch<React.SetStateAction<{
|
|
135
|
-
start: Point;
|
|
136
|
-
originalOffset: Point;
|
|
137
|
-
} | undefined>>;
|
|
138
|
-
selectionMode: SelectionModeData<number | Point>;
|
|
139
|
-
setSelectionMode: React.Dispatch<React.SetStateAction<SelectionModeData<number | Point>>>;
|
|
140
|
-
setCanvasMoveAcceleration: React.Dispatch<React.SetStateAction<Point>>;
|
|
141
|
-
isShiftPressed: boolean;
|
|
142
|
-
isAltPressed: boolean;
|
|
143
|
-
isSpacePressed: boolean;
|
|
144
|
-
setShiftPressed: React.Dispatch<React.SetStateAction<boolean>>;
|
|
145
|
-
setAltPressed: React.Dispatch<React.SetStateAction<boolean>>;
|
|
146
|
-
setIsSpacePressed: React.Dispatch<React.SetStateAction<boolean>>;
|
|
147
|
-
};
|
|
148
|
-
export type UseReactPaintReturnType = {
|
|
149
|
-
annotationsProps: {
|
|
150
|
-
style: CSSProperties;
|
|
151
|
-
};
|
|
152
|
-
editorProps: EditorProps;
|
|
153
|
-
canvasProps: CanvasProps;
|
|
154
|
-
registerEvent: (event: 'dataChanged', fn: (data: StateData, source: 'user' | 'remote') => void) => void;
|
|
155
|
-
unregisterEvent: (event: 'dataChanged', fn?: (data: StateData, source: 'user' | 'remote') => void) => void;
|
|
156
|
-
resetCanvas: (json?: ExportedDrawableShape[], clearHistory?: boolean) => void;
|
|
157
|
-
resetZoom: () => void;
|
|
158
|
-
getCurrentImage: (view: 'fitToShapes' | 'defaultView' | 'currentZoom') => string;
|
|
159
|
-
getCurrentData: () => StateData;
|
|
160
|
-
setCanvasOffset: (offset: Point) => void;
|
|
161
|
-
setCanvasZoom: (action: 'unzoom' | 'zoom' | 'default') => void;
|
|
162
|
-
};
|
|
163
|
-
declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disabled, options }?: UseReactPaintProps) => UseReactPaintReturnType;
|
|
164
|
-
export default useReactPaint;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { type UtilsSettings } from './../../../canvas/constants/app';
|
|
2
|
-
import type { Point, SelectionType, ShapeEntity, StateData } from './../../../common/types/Shapes';
|
|
3
|
-
declare const useShapes: (settings: UtilsSettings, width: number, height: number, isShiftPressed: boolean) => {
|
|
4
|
-
registerEvent: (event: "dataChanged", fn: (data: StateData, source: "user" | "remote") => void) => void;
|
|
5
|
-
unregisterEvent: (event: "dataChanged", fn?: (data: StateData, source: "user" | "remote") => void) => void;
|
|
6
|
-
shapes: ShapeEntity[];
|
|
7
|
-
shapesRef: React.RefObject<ShapeEntity[]>;
|
|
8
|
-
selectedShape: SelectionType | undefined;
|
|
9
|
-
hoveredShape: ShapeEntity | undefined;
|
|
10
|
-
selectionFrame: {
|
|
11
|
-
oldSelection: SelectionType | undefined;
|
|
12
|
-
frame: [Point, Point];
|
|
13
|
-
} | undefined;
|
|
14
|
-
setSelectionFrame: React.Dispatch<React.SetStateAction<{
|
|
15
|
-
oldSelection: SelectionType | undefined;
|
|
16
|
-
frame: [Point, Point];
|
|
17
|
-
} | undefined>>;
|
|
18
|
-
refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point) => void;
|
|
19
|
-
addShapes: (newShapes: ShapeEntity[]) => void;
|
|
20
|
-
duplicateShapes: (shapesToDuplicate: ShapeEntity[], translate?: boolean, selectNewOnes?: boolean) => void;
|
|
21
|
-
addPictureShape: (fileOrUrl: File | string, maxWidth?: number, maxHeight?: number) => Promise<ShapeEntity>;
|
|
22
|
-
swapShapes: (startPositionShapeId: string, endPositionShapeId: string) => void;
|
|
23
|
-
moveShapes: (shapes: ShapeEntity[], action: "first" | "last" | "forward" | "backward") => void;
|
|
24
|
-
saveShapes: () => void;
|
|
25
|
-
setSelectedShape: React.Dispatch<React.SetStateAction<SelectionType | undefined>>;
|
|
26
|
-
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
|
|
27
|
-
toggleShapeVisibility: (shapes: ShapeEntity[]) => void;
|
|
28
|
-
toggleShapeLock: (shapeGroup: ShapeEntity[]) => void;
|
|
29
|
-
removeShape: (shapes: ShapeEntity[]) => void;
|
|
30
|
-
updateShape: (updatedShapes: ShapeEntity[], withSave?: boolean) => void;
|
|
31
|
-
transformShape: (ctx: CanvasRenderingContext2D, shapes: ShapeEntity[], center: Point, action: "flipHorizontally" | "flipVertically" | "rotateClockwise" | "rotateCounterclockwise") => void;
|
|
32
|
-
backwardShape: () => void;
|
|
33
|
-
forwardShape: () => void;
|
|
34
|
-
clearShapes: (shapesToInit: ShapeEntity[], options: {
|
|
35
|
-
clearHistory: boolean;
|
|
36
|
-
source: "user" | "remote";
|
|
37
|
-
}) => void;
|
|
38
|
-
canGoBackward: boolean;
|
|
39
|
-
canGoForward: boolean;
|
|
40
|
-
canClear: boolean;
|
|
41
|
-
copiedShape: SelectionType | undefined;
|
|
42
|
-
setCopiedShape: React.Dispatch<React.SetStateAction<SelectionType | undefined>>;
|
|
43
|
-
};
|
|
44
|
-
export default useShapes;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { CanvasSize, Size } from './../../../common/types/Canvas';
|
|
2
|
-
import type { Point } from './../../../common/types/Shapes';
|
|
3
|
-
type UseZoomProps = {
|
|
4
|
-
canvasSize: CanvasSize;
|
|
5
|
-
size: Size;
|
|
6
|
-
canvasElt: HTMLCanvasElement | null;
|
|
7
|
-
zoomEnabled: boolean;
|
|
8
|
-
};
|
|
9
|
-
declare const useZoom: ({ canvasSize, size, zoomEnabled, canvasElt }: UseZoomProps) => {
|
|
10
|
-
setCanvasTransformation: import("react").Dispatch<import("react").SetStateAction<{
|
|
11
|
-
offset: Point;
|
|
12
|
-
zoom: number;
|
|
13
|
-
}>>;
|
|
14
|
-
setCanvasOffset: (newOffset: Point) => void;
|
|
15
|
-
setCanvasZoom: (action: "unzoom" | "zoom" | "default") => void;
|
|
16
|
-
resetZoom: () => void;
|
|
17
|
-
canvasTransformation: {
|
|
18
|
-
offset: Point;
|
|
19
|
-
zoom: number;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export default useZoom;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { UseReactPaintReturnType } from './../../canvas/hooks/useReactPaint';
|
|
2
|
-
import { type CSSProperties } from 'react';
|
|
3
|
-
import './index.css';
|
|
4
|
-
type AppProps = {
|
|
5
|
-
canvasProps: UseReactPaintReturnType['canvasProps'];
|
|
6
|
-
className?: string;
|
|
7
|
-
style?: CSSProperties;
|
|
8
|
-
options?: {
|
|
9
|
-
canvasBackgroundColor?: string | undefined;
|
|
10
|
-
canvasSelectionColor?: string | undefined;
|
|
11
|
-
canvasSelectionWidth?: number | undefined;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
declare const App: ({ options, className, style, canvasProps }: AppProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export default App;
|
|
16
|
-
export type { OptionalOptions } from './../../canvas/constants/app';
|
|
17
|
-
export { DEFAULT_OPTIONS } from './../../canvas/constants/app';
|
|
18
|
-
export { default as useReactPaint } from './../../canvas/hooks/useReactPaint';
|
|
19
|
-
export type { ExportedDrawableShape as DrawableShape, StateData } from './../../common/types/Shapes';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
|
-
import type { Point, StyleShape } from './../../../common/types/Shapes';
|
|
3
|
-
export declare const initCanvasContext: (ctx: CanvasRenderingContext2D) => void;
|
|
4
|
-
export declare const updateCanvasContext: (ctx: CanvasRenderingContext2D, style?: {
|
|
5
|
-
fillColor?: string;
|
|
6
|
-
opacity?: number;
|
|
7
|
-
strokeColor?: string;
|
|
8
|
-
lineWidth?: number;
|
|
9
|
-
lineDash?: number;
|
|
10
|
-
lineCap?: CanvasLineCap;
|
|
11
|
-
shadowColor?: string;
|
|
12
|
-
shadowBlur?: number;
|
|
13
|
-
}) => void;
|
|
14
|
-
export declare const transformCanvas: (ctx: CanvasRenderingContext2D, settings: UtilsSettings, rotation?: number, translation?: Point) => void;
|
|
15
|
-
export declare const drawPathWithFillAndStroke: (ctx: CanvasRenderingContext2D, path: Path2D, style?: Pick<StyleShape, "fillColor" | "strokeColor">) => void;
|