@yorab/react-paint 0.11.0 → 0.11.2
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 +215 -6
- package/dist/canvas/constants/app.d.ts +5 -5
- package/dist/canvas/hooks/useKeyboard.d.ts +0 -1
- package/dist/canvas/hooks/useReactPaint.d.ts +6 -19
- package/dist/canvas/hooks/useResizeObserver.d.ts +0 -1
- package/dist/canvas/hooks/useShapes.d.ts +7 -5
- package/dist/canvas/index.d.ts +2 -0
- package/dist/canvas/utils/data.d.ts +1 -1
- package/dist/canvas/utils/file.d.ts +1 -0
- package/dist/canvas/utils/selection/lineSelection.d.ts +2 -2
- 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 +5 -5
- package/dist/canvas/utils/shapes/ellipse.d.ts +5 -5
- package/dist/canvas/utils/shapes/index.d.ts +1 -1
- package/dist/canvas/utils/shapes/line.d.ts +4 -4
- package/dist/canvas/utils/shapes/path.d.ts +5 -5
- package/dist/canvas/utils/shapes/picture.d.ts +2 -2
- package/dist/canvas/utils/shapes/polygon.d.ts +5 -5
- package/dist/canvas/utils/shapes/rectangle.d.ts +1 -1
- package/dist/canvas/utils/shapes/text.d.ts +5 -5
- package/dist/canvas/utils/shapes/triangle.d.ts +2 -2
- package/dist/canvas/utils/transform.d.ts +2 -2
- package/dist/common/types/tools.d.ts +42 -4
- package/dist/index.d.ts +2 -2
- package/dist/react-paint.js +890 -990
- package/dist/react-paint.umd.cjs +1 -1
- package/package.json +16 -16
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DrawableShape, Triangle } from './../../../common/types/Shapes';
|
|
2
|
-
export declare const createTriangle: (triangle: Triangle) => DrawableShape<
|
|
3
|
-
export declare const drawTriangle: (ctx: CanvasRenderingContext2D, triangle: DrawableShape<
|
|
2
|
+
export declare const createTriangle: (triangle: Triangle) => DrawableShape<"triangle">;
|
|
3
|
+
export declare const drawTriangle: (ctx: CanvasRenderingContext2D, triangle: DrawableShape<"triangle">) => void;
|
|
@@ -9,7 +9,7 @@ export declare const roundRotationForGrid: (rotation: number, settings: UtilsSet
|
|
|
9
9
|
export declare const transformShape: (ctx: CanvasRenderingContext2D, shape: ShapeEntity, cursorPosition: Point, selectionMode: SelectionModeData<Point | number>, settings: UtilsSettings, isShiftPressed: boolean) => ShapeEntity;
|
|
10
10
|
export declare const fitContentInsideContainer: (contentWidth: number, contentHeight: number, containerWidth: number, containerHeight: number, shouldFillContainer?: boolean) => number[];
|
|
11
11
|
export declare const shortenLine: ({ line, size, direction }: {
|
|
12
|
-
line: DrawableShape<
|
|
12
|
+
line: DrawableShape<"line">;
|
|
13
13
|
size: number;
|
|
14
|
-
direction:
|
|
14
|
+
direction: "start" | "end" | "both";
|
|
15
15
|
}) => Line;
|
|
@@ -1,11 +1,39 @@
|
|
|
1
1
|
import type { ShapeType } from './Shapes';
|
|
2
2
|
export type CustomToolInput = {
|
|
3
3
|
id: string;
|
|
4
|
-
type: ShapeType;
|
|
5
4
|
icon?: string;
|
|
6
5
|
label?: string;
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
} & ({
|
|
7
|
+
type: 'brush';
|
|
8
|
+
settings: ToolsSettingsType<'brush'>;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'circle';
|
|
11
|
+
settings: ToolsSettingsType<'circle'>;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'ellipse';
|
|
14
|
+
settings: ToolsSettingsType<'ellipse'>;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'rect';
|
|
17
|
+
settings: ToolsSettingsType<'rect'>;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'square';
|
|
20
|
+
settings: ToolsSettingsType<'square'>;
|
|
21
|
+
} | {
|
|
22
|
+
type: 'line';
|
|
23
|
+
settings: ToolsSettingsType<'line'>;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'polygon';
|
|
26
|
+
settings: ToolsSettingsType<'polygon'>;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'curve';
|
|
29
|
+
settings: ToolsSettingsType<'curve'>;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'text';
|
|
32
|
+
settings: ToolsSettingsType<'text'>;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'picture';
|
|
35
|
+
settings: ToolsSettingsType<'picture'>;
|
|
36
|
+
});
|
|
9
37
|
export type CustomTool = {
|
|
10
38
|
id: string;
|
|
11
39
|
icon: string;
|
|
@@ -47,18 +75,21 @@ export type SettingsOpacity = {
|
|
|
47
75
|
max: number;
|
|
48
76
|
step: number;
|
|
49
77
|
default: number;
|
|
78
|
+
hidden?: boolean;
|
|
50
79
|
};
|
|
51
80
|
};
|
|
52
81
|
export type SettingsStrokeColor = {
|
|
53
82
|
strokeColor: {
|
|
54
83
|
values: string[];
|
|
55
84
|
default: string;
|
|
85
|
+
hidden?: boolean;
|
|
56
86
|
};
|
|
57
87
|
};
|
|
58
88
|
export type SettingsFillColor = {
|
|
59
89
|
fillColor: {
|
|
60
90
|
values: string[];
|
|
61
91
|
default: string;
|
|
92
|
+
hidden?: boolean;
|
|
62
93
|
};
|
|
63
94
|
};
|
|
64
95
|
export type SettingsLineWidth = {
|
|
@@ -67,32 +98,38 @@ export type SettingsLineWidth = {
|
|
|
67
98
|
max: number;
|
|
68
99
|
step: number;
|
|
69
100
|
default: number;
|
|
101
|
+
hidden?: boolean;
|
|
70
102
|
};
|
|
71
103
|
};
|
|
72
104
|
export type SettingsLineDash = {
|
|
73
105
|
lineDash: {
|
|
74
106
|
values: number[];
|
|
75
107
|
default: number;
|
|
108
|
+
hidden?: boolean;
|
|
76
109
|
};
|
|
77
110
|
};
|
|
78
111
|
export type SettingsLineArrow = {
|
|
79
112
|
lineArrow: {
|
|
80
113
|
values: number[];
|
|
81
114
|
default: number;
|
|
115
|
+
hidden?: boolean;
|
|
82
116
|
};
|
|
83
117
|
};
|
|
84
118
|
export type SettingsFont = {
|
|
85
119
|
fontFamily: {
|
|
86
120
|
values: string[];
|
|
87
121
|
default: string;
|
|
122
|
+
hidden?: boolean;
|
|
88
123
|
};
|
|
89
124
|
fontBold: {
|
|
90
125
|
values: boolean[];
|
|
91
126
|
default: boolean;
|
|
127
|
+
hidden?: boolean;
|
|
92
128
|
};
|
|
93
129
|
fontItalic: {
|
|
94
130
|
values: boolean[];
|
|
95
131
|
default: boolean;
|
|
132
|
+
hidden?: boolean;
|
|
96
133
|
};
|
|
97
134
|
};
|
|
98
135
|
export type SettingsPointsCount = {
|
|
@@ -101,6 +138,7 @@ export type SettingsPointsCount = {
|
|
|
101
138
|
max: number;
|
|
102
139
|
step: number;
|
|
103
140
|
default: number;
|
|
141
|
+
hidden?: boolean;
|
|
104
142
|
};
|
|
105
143
|
};
|
|
106
144
|
export type ToolsRectSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash;
|
|
@@ -114,7 +152,7 @@ export type ToolsPolygonSettings = SettingsOpacity & SettingsStrokeColor & Setti
|
|
|
114
152
|
export type ToolsCurveSettings = SettingsOpacity & SettingsStrokeColor & SettingsFillColor & SettingsLineWidth & SettingsLineDash & SettingsPointsCount;
|
|
115
153
|
export type ToolsTriangleSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash;
|
|
116
154
|
export type ToolsPictureSettings = SettingsOpacity;
|
|
117
|
-
export type ToolsSettingsType<T extends ShapeType> = T extends 'rect' ? ToolsRectSettings : T extends 'square' ? ToolsSquareSettings : T extends 'circle' ? ToolsCircleSettings : T extends 'ellipse' ? ToolsEllipseSettings : T extends 'text' ? ToolsTextSettings : T extends 'line' ? ToolsLineSettings : T extends 'brush' ? ToolsBrushSettings : T extends 'polygon' ? ToolsPolygonSettings : T extends 'curve' ? ToolsCurveSettings : T extends 'triangle' ? ToolsTriangleSettings : T extends 'picture' ? ToolsPictureSettings :
|
|
155
|
+
export type ToolsSettingsType<T extends ShapeType> = T extends 'rect' ? ToolsRectSettings : T extends 'square' ? ToolsSquareSettings : T extends 'circle' ? ToolsCircleSettings : T extends 'ellipse' ? ToolsEllipseSettings : T extends 'text' ? ToolsTextSettings : T extends 'line' ? ToolsLineSettings : T extends 'brush' ? ToolsBrushSettings : T extends 'polygon' ? ToolsPolygonSettings : T extends 'curve' ? ToolsCurveSettings : T extends 'triangle' ? ToolsTriangleSettings : T extends 'picture' ? ToolsPictureSettings : never;
|
|
118
156
|
export type ActionsType = 'selection' | 'undo' | 'redo' | 'clear' | 'export' | 'loadfile' | 'savefile' | 'move' | 'uploadpicture' | 'addurlpicture';
|
|
119
157
|
export type ActionsTool = {
|
|
120
158
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { OptionalOptions } from './canvas/constants/app';
|
|
1
2
|
import useReactPaint from './canvas/hooks/useReactPaint';
|
|
2
3
|
import Canvas from './canvas/index';
|
|
3
|
-
import Editor from './editor/index';
|
|
4
4
|
import type { DrawableShape, StateData } from './common/types/Shapes';
|
|
5
|
-
import
|
|
5
|
+
import Editor from './editor/index';
|
|
6
6
|
export { Editor, Canvas, useReactPaint, type DrawableShape, type StateData, type OptionalOptions };
|