@yorab/react-paint 0.7.5 → 0.8.0
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/dist/components/App.d.ts +20 -0
- package/dist/components/Canvas.d.ts +38 -0
- package/dist/components/common/Button.d.ts +16 -0
- package/dist/components/common/Loading.d.ts +7 -0
- package/dist/components/common/Modal.d.ts +10 -0
- package/dist/components/common/Panel.d.ts +13 -0
- package/dist/components/common/Snackbar.d.ts +8 -0
- package/dist/components/settings/ColorField.d.ts +15 -0
- package/dist/components/settings/DeleteButton.d.ts +9 -0
- package/dist/components/settings/FontFamilyField.d.ts +12 -0
- package/dist/components/settings/LayoutButton.d.ts +8 -0
- package/dist/components/settings/Layouts.d.ts +19 -0
- package/dist/components/settings/LineArrowField.d.ts +12 -0
- package/dist/components/settings/LineTypeField.d.ts +16 -0
- package/dist/components/settings/PointsNumberField.d.ts +13 -0
- package/dist/components/settings/RangeField.d.ts +18 -0
- package/dist/components/settings/SelectField.d.ts +18 -0
- package/dist/components/settings/SettingsBar.d.ts +19 -0
- package/dist/components/settings/ToggleField.d.ts +12 -0
- package/dist/components/toolbox/EditTextBox.d.ts +14 -0
- package/dist/components/toolbox/LoadFileTool.d.ts +12 -0
- package/dist/components/toolbox/MenuGroup.d.ts +35 -0
- package/dist/components/toolbox/PictureUrlInput.d.ts +8 -0
- package/dist/components/toolbox/Tool.d.ts +12 -0
- package/dist/components/toolbox/Toolbar.d.ts +27 -0
- package/dist/components/toolbox/ToolbarGroup.d.ts +18 -0
- package/dist/constants/app.d.ts +41 -0
- package/dist/constants/icons.d.ts +41 -0
- package/dist/constants/loading.d.ts +1 -0
- package/dist/constants/picture.d.ts +1 -0
- package/dist/constants/shapes.d.ts +8 -0
- package/dist/constants/snackbar.d.ts +7 -0
- package/dist/constants/style.d.ts +17 -0
- package/dist/constants/tools.d.ts +32 -0
- package/dist/hooks/useComponent.d.ts +9 -0
- package/dist/hooks/useDoubleClick.d.ts +5 -0
- package/dist/hooks/useDrag.d.ts +15 -0
- package/dist/hooks/useDrawableCanvas.d.ts +37 -0
- package/dist/hooks/useKeyboard.d.ts +18 -0
- package/dist/hooks/useResizeObserver.d.ts +7 -0
- package/dist/hooks/useShapes.d.ts +22 -0
- package/dist/hooks/useSnackbar.d.ts +10 -0
- package/dist/react-paint.css +1 -0
- package/dist/react-paint.js +9109 -0
- package/dist/react-paint.umd.cjs +53 -0
- package/dist/types/Mode.d.ts +43 -0
- package/dist/types/Shapes.d.ts +112 -0
- package/dist/types/snackbar.d.ts +7 -0
- package/dist/types/tools.d.ts +124 -0
- package/dist/types/utils.d.ts +3 -0
- package/dist/utils/canvas.d.ts +10 -0
- package/dist/utils/data.d.ts +225 -0
- package/dist/utils/dom.d.ts +1 -0
- package/dist/utils/file.d.ts +10 -0
- package/dist/utils/intersect.d.ts +6 -0
- package/dist/utils/migration.d.ts +165 -0
- package/dist/utils/selection.d.ts +7 -0
- package/dist/utils/shapes/brush.d.ts +55 -0
- package/dist/utils/shapes/circle.d.ts +13 -0
- package/dist/utils/shapes/curve.d.ts +11 -0
- package/dist/utils/shapes/default.d.ts +10 -0
- package/dist/utils/shapes/ellipse.d.ts +13 -0
- package/dist/utils/shapes/grid.d.ts +3 -0
- package/dist/utils/shapes/index.d.ts +245 -0
- package/dist/utils/shapes/line.d.ts +23 -0
- package/dist/utils/shapes/picture.d.ts +6 -0
- package/dist/utils/shapes/polygon.d.ts +11 -0
- package/dist/utils/shapes/rectangle.d.ts +26 -0
- package/dist/utils/shapes/text.d.ts +48 -0
- package/dist/utils/shapes/triangle.d.ts +2 -0
- package/dist/utils/string.d.ts +3 -0
- package/dist/utils/style.d.ts +2 -0
- package/dist/utils/toolbar.d.ts +13 -0
- package/dist/utils/transform.d.ts +8 -0
- package/dist/utils/trigo.d.ts +10 -0
- package/package.json +51 -56
- package/dist/components/App.js +0 -496
- package/dist/components/Canvas.js +0 -194
- package/dist/components/common/Button.js +0 -88
- package/dist/components/common/Loading.js +0 -57
- package/dist/components/common/Modal.js +0 -46
- package/dist/components/common/Panel.js +0 -43
- package/dist/components/common/Snackbar.js +0 -68
- package/dist/components/settings/ColorField.js +0 -125
- package/dist/components/settings/DeleteButton.js +0 -37
- package/dist/components/settings/FontFamilyField.js +0 -67
- package/dist/components/settings/LayoutButton.js +0 -39
- package/dist/components/settings/Layouts.js +0 -214
- package/dist/components/settings/LineArrowField.js +0 -67
- package/dist/components/settings/LineTypeField.js +0 -65
- package/dist/components/settings/PointsNumberField.js +0 -45
- package/dist/components/settings/RangeField.js +0 -82
- package/dist/components/settings/SelectField.js +0 -81
- package/dist/components/settings/SettingsBar.js +0 -383
- package/dist/components/settings/ToggleField.js +0 -49
- package/dist/components/toolbox/EditTextBox.js +0 -138
- package/dist/components/toolbox/LoadFileTool.js +0 -58
- package/dist/components/toolbox/MenuGroup.js +0 -173
- package/dist/components/toolbox/PictureUrlInput.js +0 -68
- package/dist/components/toolbox/Tool.js +0 -41
- package/dist/components/toolbox/Toolbar.js +0 -203
- package/dist/components/toolbox/ToolbarGroup.js +0 -134
- package/dist/constants/app.js +0 -51
- package/dist/constants/icons.js +0 -88
- package/dist/constants/loading.js +0 -8
- package/dist/constants/picture.js +0 -8
- package/dist/constants/shapes.js +0 -20
- package/dist/constants/snackbar.js +0 -15
- package/dist/constants/style.js +0 -35
- package/dist/constants/tools.js +0 -424
- package/dist/hooks/useComponent.js +0 -47
- package/dist/hooks/useDoubleClick.js +0 -46
- package/dist/hooks/useDrag.js +0 -92
- package/dist/hooks/useDrawableCanvas.js +0 -230
- package/dist/hooks/useKeyboard.js +0 -142
- package/dist/hooks/useResizeObserver.js +0 -42
- package/dist/hooks/useShapes.js +0 -184
- package/dist/hooks/useSnackbar.js +0 -56
- package/dist/styles.css +0 -91
- package/dist/types/Mode.js +0 -5
- package/dist/types/Shapes.js +0 -5
- package/dist/types/snackbar.js +0 -5
- package/dist/types/tools.js +0 -5
- package/dist/types/utils.js +0 -5
- package/dist/utils/canvas.js +0 -49
- package/dist/utils/data.js +0 -49
- package/dist/utils/dom.js +0 -12
- package/dist/utils/file.js +0 -171
- package/dist/utils/intersect.js +0 -122
- package/dist/utils/migration.js +0 -59
- package/dist/utils/selection.js +0 -86
- package/dist/utils/shapes/brush.js +0 -135
- package/dist/utils/shapes/circle.js +0 -93
- package/dist/utils/shapes/curve.js +0 -55
- package/dist/utils/shapes/default.js +0 -73
- package/dist/utils/shapes/ellipse.js +0 -101
- package/dist/utils/shapes/grid.js +0 -36
- package/dist/utils/shapes/index.js +0 -341
- package/dist/utils/shapes/line.js +0 -179
- package/dist/utils/shapes/picture.js +0 -103
- package/dist/utils/shapes/polygon.js +0 -69
- package/dist/utils/shapes/rectangle.js +0 -100
- package/dist/utils/shapes/text.js +0 -128
- package/dist/utils/shapes/triangle.js +0 -24
- package/dist/utils/string.js +0 -36
- package/dist/utils/style.js +0 -46
- package/dist/utils/toolbar.js +0 -78
- package/dist/utils/transform.js +0 -109
- package/dist/utils/trigo.js +0 -42
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { ShapeTypeArray } from '../constants/shapes';
|
|
2
|
+
export type ShapeType = typeof ShapeTypeArray[number];
|
|
3
|
+
export type Point = [number, number];
|
|
4
|
+
export type StyledShape = {
|
|
5
|
+
visible?: boolean;
|
|
6
|
+
locked?: boolean;
|
|
7
|
+
style?: {
|
|
8
|
+
fillColor?: string;
|
|
9
|
+
globalAlpha?: number;
|
|
10
|
+
strokeColor?: string;
|
|
11
|
+
lineWidth?: number;
|
|
12
|
+
lineDash?: number;
|
|
13
|
+
lineArrow?: number;
|
|
14
|
+
pointsCount?: number;
|
|
15
|
+
fontFamily?: string;
|
|
16
|
+
fontItalic?: boolean;
|
|
17
|
+
fontBold?: boolean;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
type Drawable = {
|
|
21
|
+
id: string;
|
|
22
|
+
toolId?: string;
|
|
23
|
+
rotation: number;
|
|
24
|
+
};
|
|
25
|
+
export type Rect = StyledShape & {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
31
|
+
export type Square = Rect;
|
|
32
|
+
export type StoredPicture = Rect & {
|
|
33
|
+
src: string;
|
|
34
|
+
};
|
|
35
|
+
export type Picture = StoredPicture & {
|
|
36
|
+
img: HTMLImageElement;
|
|
37
|
+
};
|
|
38
|
+
export type Text = Rect & {
|
|
39
|
+
value: string[];
|
|
40
|
+
fontSize: number;
|
|
41
|
+
};
|
|
42
|
+
export type Line = StyledShape & {
|
|
43
|
+
points: [Point, Point];
|
|
44
|
+
};
|
|
45
|
+
export type Triangle = StyledShape & {
|
|
46
|
+
points: [Point, Point, Point];
|
|
47
|
+
};
|
|
48
|
+
export type Polygon = StyledShape & {
|
|
49
|
+
points: Point[];
|
|
50
|
+
};
|
|
51
|
+
export type Curve = StyledShape & {
|
|
52
|
+
points: Point[];
|
|
53
|
+
};
|
|
54
|
+
export type Brush = StyledShape & {
|
|
55
|
+
points: Point[][];
|
|
56
|
+
};
|
|
57
|
+
export type Circle = StyledShape & {
|
|
58
|
+
x: number;
|
|
59
|
+
y: number;
|
|
60
|
+
radius: number;
|
|
61
|
+
};
|
|
62
|
+
export type Ellipse = StyledShape & {
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
radiusX: number;
|
|
66
|
+
radiusY: number;
|
|
67
|
+
};
|
|
68
|
+
export type DrawableRect = Rect & Drawable & {
|
|
69
|
+
type: 'rect';
|
|
70
|
+
};
|
|
71
|
+
export type DrawableSquare = Square & Drawable & {
|
|
72
|
+
type: 'square';
|
|
73
|
+
};
|
|
74
|
+
export type DrawablePictureJson = StoredPicture & Drawable & {
|
|
75
|
+
type: 'picture';
|
|
76
|
+
};
|
|
77
|
+
export type DrawablePicture = Picture & Drawable & {
|
|
78
|
+
type: 'picture';
|
|
79
|
+
};
|
|
80
|
+
export type DrawableText = Text & Drawable & {
|
|
81
|
+
type: 'text';
|
|
82
|
+
};
|
|
83
|
+
export type DrawableLine = Line & Drawable & {
|
|
84
|
+
type: 'line';
|
|
85
|
+
};
|
|
86
|
+
export type DrawablePolygon = Polygon & Drawable & {
|
|
87
|
+
type: 'polygon';
|
|
88
|
+
};
|
|
89
|
+
export type DrawableCurve = Curve & Drawable & {
|
|
90
|
+
type: 'curve';
|
|
91
|
+
};
|
|
92
|
+
export type DrawableBrush = Brush & Drawable & {
|
|
93
|
+
type: 'brush';
|
|
94
|
+
};
|
|
95
|
+
export type DrawableCircle = Circle & Drawable & {
|
|
96
|
+
type: 'circle';
|
|
97
|
+
};
|
|
98
|
+
export type DrawableEllipse = Ellipse & Drawable & {
|
|
99
|
+
type: 'ellipse';
|
|
100
|
+
};
|
|
101
|
+
export type DrawableShape = DrawableRect | DrawableSquare | DrawablePicture | DrawableText | DrawableLine | DrawablePolygon | DrawableCurve | DrawableBrush | DrawableCircle | DrawableEllipse;
|
|
102
|
+
export type DrawableShapeJson = {
|
|
103
|
+
translation?: Point;
|
|
104
|
+
} & (DrawableRect | DrawableSquare | DrawablePictureJson | DrawableText | DrawableLine | DrawableCurve | DrawablePolygon | DrawableBrush | DrawableCircle | DrawableEllipse);
|
|
105
|
+
export type ExportDataType = {
|
|
106
|
+
shapes: DrawableShapeJson[];
|
|
107
|
+
config?: {
|
|
108
|
+
width: number;
|
|
109
|
+
height: number;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { ShapeType } from './Shapes';
|
|
2
|
+
export type CustomToolInput = {
|
|
3
|
+
id: string;
|
|
4
|
+
type: ShapeType;
|
|
5
|
+
icon?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
settings?: ToolsSettingsType<ShapeType>;
|
|
8
|
+
};
|
|
9
|
+
export type CustomTool = {
|
|
10
|
+
id: string;
|
|
11
|
+
icon: string;
|
|
12
|
+
label: string;
|
|
13
|
+
} & ({
|
|
14
|
+
type: 'brush';
|
|
15
|
+
settings: ToolsSettingsType<'brush'>;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'circle';
|
|
18
|
+
settings: ToolsSettingsType<'circle'>;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'ellipse';
|
|
21
|
+
settings: ToolsSettingsType<'ellipse'>;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'rect';
|
|
24
|
+
settings: ToolsSettingsType<'rect'>;
|
|
25
|
+
} | {
|
|
26
|
+
type: 'square';
|
|
27
|
+
settings: ToolsSettingsType<'square'>;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'line';
|
|
30
|
+
settings: ToolsSettingsType<'line'>;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'polygon';
|
|
33
|
+
settings: ToolsSettingsType<'polygon'>;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'curve';
|
|
36
|
+
settings: ToolsSettingsType<'curve'>;
|
|
37
|
+
} | {
|
|
38
|
+
type: 'text';
|
|
39
|
+
settings: ToolsSettingsType<'text'>;
|
|
40
|
+
} | {
|
|
41
|
+
type: 'picture';
|
|
42
|
+
settings: ToolsSettingsType<'picture'>;
|
|
43
|
+
});
|
|
44
|
+
export type SettingsOpacity = {
|
|
45
|
+
opacity: {
|
|
46
|
+
min: number;
|
|
47
|
+
max: number;
|
|
48
|
+
step: number;
|
|
49
|
+
default: number;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export type SettingsStrokeColor = {
|
|
53
|
+
strokeColor: {
|
|
54
|
+
values: string[];
|
|
55
|
+
default: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export type SettingsFillColor = {
|
|
59
|
+
fillColor: {
|
|
60
|
+
values: string[];
|
|
61
|
+
default: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export type SettingsLineWidth = {
|
|
65
|
+
lineWidth: {
|
|
66
|
+
min: number;
|
|
67
|
+
max: number;
|
|
68
|
+
step: number;
|
|
69
|
+
default: number;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export type SettingsLineDash = {
|
|
73
|
+
lineDash: {
|
|
74
|
+
values: number[];
|
|
75
|
+
default: number;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export type SettingsLineArrow = {
|
|
79
|
+
lineArrow: {
|
|
80
|
+
values: number[];
|
|
81
|
+
default: number;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export type SettingsFont = {
|
|
85
|
+
fontFamily: {
|
|
86
|
+
values: string[];
|
|
87
|
+
default: string;
|
|
88
|
+
};
|
|
89
|
+
fontBold: {
|
|
90
|
+
values: boolean[];
|
|
91
|
+
default: boolean;
|
|
92
|
+
};
|
|
93
|
+
fontItalic: {
|
|
94
|
+
values: boolean[];
|
|
95
|
+
default: boolean;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
export type SettingsPointsCount = {
|
|
99
|
+
pointsCount: {
|
|
100
|
+
min: number;
|
|
101
|
+
max: number;
|
|
102
|
+
step: number;
|
|
103
|
+
default: number;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
export type ToolsRectSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash;
|
|
107
|
+
export type ToolsSquareSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash;
|
|
108
|
+
export type ToolsCircleSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash;
|
|
109
|
+
export type ToolsEllipseSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash;
|
|
110
|
+
export type ToolsTextSettings = SettingsOpacity & SettingsStrokeColor & SettingsFont;
|
|
111
|
+
export type ToolsLineSettings = SettingsOpacity & SettingsStrokeColor & SettingsLineWidth & SettingsLineDash & SettingsLineArrow;
|
|
112
|
+
export type ToolsBrushSettings = SettingsOpacity & SettingsStrokeColor & SettingsLineWidth & SettingsLineDash;
|
|
113
|
+
export type ToolsPolygonSettings = SettingsOpacity & SettingsStrokeColor & SettingsFillColor & SettingsLineWidth & SettingsLineDash & SettingsPointsCount;
|
|
114
|
+
export type ToolsCurveSettings = SettingsOpacity & SettingsStrokeColor & SettingsFillColor & SettingsLineWidth & SettingsLineDash & SettingsPointsCount;
|
|
115
|
+
export type ToolsPictureSettings = SettingsOpacity;
|
|
116
|
+
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 'picture' ? ToolsPictureSettings : unknown;
|
|
117
|
+
export type ActionsType = 'selection' | 'undo' | 'redo' | 'clear' | 'export' | 'loadfile' | 'savefile' | 'move' | 'uploadpicture' | 'addurlpicture';
|
|
118
|
+
export type ActionsTool = {
|
|
119
|
+
id: string;
|
|
120
|
+
type: ActionsType;
|
|
121
|
+
icon: string;
|
|
122
|
+
label: string;
|
|
123
|
+
};
|
|
124
|
+
export type ToolsType = CustomTool | ActionsTool;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Point } from '../types/Shapes';
|
|
2
|
+
export declare const initCanvasContext: (ctx: CanvasRenderingContext2D) => void;
|
|
3
|
+
export declare const updateCanvasContext: (ctx: CanvasRenderingContext2D, style?: {
|
|
4
|
+
fillColor?: string;
|
|
5
|
+
globalAlpha?: number;
|
|
6
|
+
strokeColor?: string;
|
|
7
|
+
lineWidth?: number;
|
|
8
|
+
lineDash?: number;
|
|
9
|
+
}) => void;
|
|
10
|
+
export declare const transformCanvas: (ctx: CanvasRenderingContext2D, responsiveScale: number, canvasOffset: Point, rotation: number, translation: Point) => void;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import type { DrawableShape, DrawableShapeJson, ExportDataType } from '../types/Shapes';
|
|
2
|
+
export declare const cleanShapesBeforeExport: (shapes: DrawableShape[]) => DrawableShapeJson[];
|
|
3
|
+
export declare const buildDataToExport: (shapes: DrawableShape[], width: number, height: number) => ExportDataType;
|
|
4
|
+
export declare const addDefaultAndTempShapeProps: (shape: DrawableShape) => {
|
|
5
|
+
id: string;
|
|
6
|
+
visible?: boolean | undefined;
|
|
7
|
+
locked?: boolean | undefined;
|
|
8
|
+
style?: {
|
|
9
|
+
fillColor?: string | undefined;
|
|
10
|
+
globalAlpha?: number | undefined;
|
|
11
|
+
strokeColor?: string | undefined;
|
|
12
|
+
lineWidth?: number | undefined;
|
|
13
|
+
lineDash?: number | undefined;
|
|
14
|
+
lineArrow?: number | undefined;
|
|
15
|
+
pointsCount?: number | undefined;
|
|
16
|
+
fontFamily?: string | undefined;
|
|
17
|
+
fontItalic?: boolean | undefined;
|
|
18
|
+
fontBold?: boolean | undefined;
|
|
19
|
+
} | undefined;
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
toolId?: string | undefined;
|
|
25
|
+
rotation: number;
|
|
26
|
+
type: "rect";
|
|
27
|
+
} | {
|
|
28
|
+
id: string;
|
|
29
|
+
visible?: boolean | undefined;
|
|
30
|
+
locked?: boolean | undefined;
|
|
31
|
+
style?: {
|
|
32
|
+
fillColor?: string | undefined;
|
|
33
|
+
globalAlpha?: number | undefined;
|
|
34
|
+
strokeColor?: string | undefined;
|
|
35
|
+
lineWidth?: number | undefined;
|
|
36
|
+
lineDash?: number | undefined;
|
|
37
|
+
lineArrow?: number | undefined;
|
|
38
|
+
pointsCount?: number | undefined;
|
|
39
|
+
fontFamily?: string | undefined;
|
|
40
|
+
fontItalic?: boolean | undefined;
|
|
41
|
+
fontBold?: boolean | undefined;
|
|
42
|
+
} | undefined;
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
toolId?: string | undefined;
|
|
48
|
+
rotation: number;
|
|
49
|
+
type: "square";
|
|
50
|
+
} | {
|
|
51
|
+
id: string;
|
|
52
|
+
visible?: boolean | undefined;
|
|
53
|
+
locked?: boolean | undefined;
|
|
54
|
+
style?: {
|
|
55
|
+
fillColor?: string | undefined;
|
|
56
|
+
globalAlpha?: number | undefined;
|
|
57
|
+
strokeColor?: string | undefined;
|
|
58
|
+
lineWidth?: number | undefined;
|
|
59
|
+
lineDash?: number | undefined;
|
|
60
|
+
lineArrow?: number | undefined;
|
|
61
|
+
pointsCount?: number | undefined;
|
|
62
|
+
fontFamily?: string | undefined;
|
|
63
|
+
fontItalic?: boolean | undefined;
|
|
64
|
+
fontBold?: boolean | undefined;
|
|
65
|
+
} | undefined;
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
70
|
+
src: string;
|
|
71
|
+
img: HTMLImageElement;
|
|
72
|
+
toolId?: string | undefined;
|
|
73
|
+
rotation: number;
|
|
74
|
+
type: "picture";
|
|
75
|
+
} | {
|
|
76
|
+
id: string;
|
|
77
|
+
visible?: boolean | undefined;
|
|
78
|
+
locked?: boolean | undefined;
|
|
79
|
+
style?: {
|
|
80
|
+
fillColor?: string | undefined;
|
|
81
|
+
globalAlpha?: number | undefined;
|
|
82
|
+
strokeColor?: string | undefined;
|
|
83
|
+
lineWidth?: number | undefined;
|
|
84
|
+
lineDash?: number | undefined;
|
|
85
|
+
lineArrow?: number | undefined;
|
|
86
|
+
pointsCount?: number | undefined;
|
|
87
|
+
fontFamily?: string | undefined;
|
|
88
|
+
fontItalic?: boolean | undefined;
|
|
89
|
+
fontBold?: boolean | undefined;
|
|
90
|
+
} | undefined;
|
|
91
|
+
x: number;
|
|
92
|
+
y: number;
|
|
93
|
+
width: number;
|
|
94
|
+
height: number;
|
|
95
|
+
value: string[];
|
|
96
|
+
fontSize: number;
|
|
97
|
+
toolId?: string | undefined;
|
|
98
|
+
rotation: number;
|
|
99
|
+
type: "text";
|
|
100
|
+
} | {
|
|
101
|
+
id: string;
|
|
102
|
+
visible?: boolean | undefined;
|
|
103
|
+
locked?: boolean | undefined;
|
|
104
|
+
style?: {
|
|
105
|
+
fillColor?: string | undefined;
|
|
106
|
+
globalAlpha?: number | undefined;
|
|
107
|
+
strokeColor?: string | undefined;
|
|
108
|
+
lineWidth?: number | undefined;
|
|
109
|
+
lineDash?: number | undefined;
|
|
110
|
+
lineArrow?: number | undefined;
|
|
111
|
+
pointsCount?: number | undefined;
|
|
112
|
+
fontFamily?: string | undefined;
|
|
113
|
+
fontItalic?: boolean | undefined;
|
|
114
|
+
fontBold?: boolean | undefined;
|
|
115
|
+
} | undefined;
|
|
116
|
+
points: [import("../types/Shapes").Point, import("../types/Shapes").Point];
|
|
117
|
+
toolId?: string | undefined;
|
|
118
|
+
rotation: number;
|
|
119
|
+
type: "line";
|
|
120
|
+
} | {
|
|
121
|
+
id: string;
|
|
122
|
+
visible?: boolean | undefined;
|
|
123
|
+
locked?: boolean | undefined;
|
|
124
|
+
style?: {
|
|
125
|
+
fillColor?: string | undefined;
|
|
126
|
+
globalAlpha?: number | undefined;
|
|
127
|
+
strokeColor?: string | undefined;
|
|
128
|
+
lineWidth?: number | undefined;
|
|
129
|
+
lineDash?: number | undefined;
|
|
130
|
+
lineArrow?: number | undefined;
|
|
131
|
+
pointsCount?: number | undefined;
|
|
132
|
+
fontFamily?: string | undefined;
|
|
133
|
+
fontItalic?: boolean | undefined;
|
|
134
|
+
fontBold?: boolean | undefined;
|
|
135
|
+
} | undefined;
|
|
136
|
+
points: import("../types/Shapes").Point[];
|
|
137
|
+
toolId?: string | undefined;
|
|
138
|
+
rotation: number;
|
|
139
|
+
type: "polygon";
|
|
140
|
+
} | {
|
|
141
|
+
id: string;
|
|
142
|
+
visible?: boolean | undefined;
|
|
143
|
+
locked?: boolean | undefined;
|
|
144
|
+
style?: {
|
|
145
|
+
fillColor?: string | undefined;
|
|
146
|
+
globalAlpha?: number | undefined;
|
|
147
|
+
strokeColor?: string | undefined;
|
|
148
|
+
lineWidth?: number | undefined;
|
|
149
|
+
lineDash?: number | undefined;
|
|
150
|
+
lineArrow?: number | undefined;
|
|
151
|
+
pointsCount?: number | undefined;
|
|
152
|
+
fontFamily?: string | undefined;
|
|
153
|
+
fontItalic?: boolean | undefined;
|
|
154
|
+
fontBold?: boolean | undefined;
|
|
155
|
+
} | undefined;
|
|
156
|
+
points: import("../types/Shapes").Point[];
|
|
157
|
+
toolId?: string | undefined;
|
|
158
|
+
rotation: number;
|
|
159
|
+
type: "curve";
|
|
160
|
+
} | {
|
|
161
|
+
id: string;
|
|
162
|
+
visible?: boolean | undefined;
|
|
163
|
+
locked?: boolean | undefined;
|
|
164
|
+
style?: {
|
|
165
|
+
fillColor?: string | undefined;
|
|
166
|
+
globalAlpha?: number | undefined;
|
|
167
|
+
strokeColor?: string | undefined;
|
|
168
|
+
lineWidth?: number | undefined;
|
|
169
|
+
lineDash?: number | undefined;
|
|
170
|
+
lineArrow?: number | undefined;
|
|
171
|
+
pointsCount?: number | undefined;
|
|
172
|
+
fontFamily?: string | undefined;
|
|
173
|
+
fontItalic?: boolean | undefined;
|
|
174
|
+
fontBold?: boolean | undefined;
|
|
175
|
+
} | undefined;
|
|
176
|
+
points: import("../types/Shapes").Point[][];
|
|
177
|
+
toolId?: string | undefined;
|
|
178
|
+
rotation: number;
|
|
179
|
+
type: "brush";
|
|
180
|
+
} | {
|
|
181
|
+
id: string;
|
|
182
|
+
visible?: boolean | undefined;
|
|
183
|
+
locked?: boolean | undefined;
|
|
184
|
+
style?: {
|
|
185
|
+
fillColor?: string | undefined;
|
|
186
|
+
globalAlpha?: number | undefined;
|
|
187
|
+
strokeColor?: string | undefined;
|
|
188
|
+
lineWidth?: number | undefined;
|
|
189
|
+
lineDash?: number | undefined;
|
|
190
|
+
lineArrow?: number | undefined;
|
|
191
|
+
pointsCount?: number | undefined;
|
|
192
|
+
fontFamily?: string | undefined;
|
|
193
|
+
fontItalic?: boolean | undefined;
|
|
194
|
+
fontBold?: boolean | undefined;
|
|
195
|
+
} | undefined;
|
|
196
|
+
x: number;
|
|
197
|
+
y: number;
|
|
198
|
+
radius: number;
|
|
199
|
+
toolId?: string | undefined;
|
|
200
|
+
rotation: number;
|
|
201
|
+
type: "circle";
|
|
202
|
+
} | {
|
|
203
|
+
id: string;
|
|
204
|
+
visible?: boolean | undefined;
|
|
205
|
+
locked?: boolean | undefined;
|
|
206
|
+
style?: {
|
|
207
|
+
fillColor?: string | undefined;
|
|
208
|
+
globalAlpha?: number | undefined;
|
|
209
|
+
strokeColor?: string | undefined;
|
|
210
|
+
lineWidth?: number | undefined;
|
|
211
|
+
lineDash?: number | undefined;
|
|
212
|
+
lineArrow?: number | undefined;
|
|
213
|
+
pointsCount?: number | undefined;
|
|
214
|
+
fontFamily?: string | undefined;
|
|
215
|
+
fontItalic?: boolean | undefined;
|
|
216
|
+
fontBold?: boolean | undefined;
|
|
217
|
+
} | undefined;
|
|
218
|
+
x: number;
|
|
219
|
+
y: number;
|
|
220
|
+
radiusX: number;
|
|
221
|
+
radiusY: number;
|
|
222
|
+
toolId?: string | undefined;
|
|
223
|
+
rotation: number;
|
|
224
|
+
type: "ellipse";
|
|
225
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isEventInsideNode: (event: MouseEvent | TouchEvent, node: HTMLElement | null) => boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DrawableShape, ExportDataType, Point } from '../types/Shapes';
|
|
2
|
+
export declare const addSizeAndConvertSvgToObjectUrl: (svgFileContent: string) => string;
|
|
3
|
+
export declare const isSvg: (fileOrUrl: File | string) => boolean;
|
|
4
|
+
export declare const fetchAndStringify: (url: string) => Promise<string>;
|
|
5
|
+
export declare const downloadFile: (content: string, fileName: string) => void;
|
|
6
|
+
export declare const getBase64Image: (img: HTMLImageElement) => string;
|
|
7
|
+
export declare const getCanvasImage: (shapes: DrawableShape[], canvasOffset: Point, width: number, height: number, selectionPadding: number) => string;
|
|
8
|
+
export declare const encodeShapesInString: (shapes: DrawableShape[], width: number, height: number) => string;
|
|
9
|
+
export declare const decodeJson: (file: File) => Promise<unknown>;
|
|
10
|
+
export declare const decodeImportedData: (shapesForJson: ExportDataType) => Promise<DrawableShape[]>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HoverModeData } from '../types/Mode';
|
|
2
|
+
import type { Point, DrawableShape } from '../types/Shapes';
|
|
3
|
+
export declare const getCursorPosition: (e: MouseEvent | TouchEvent, canvas: HTMLCanvasElement | null, givenWidth: number, givenHeight: number, scaleRatio?: number) => Point;
|
|
4
|
+
export declare const getPointPositionAfterCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point, [canvasOffsetX, canvasOffsetY]: Point) => Point;
|
|
5
|
+
export declare const getPointPositionBeforeCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point, [canvasOffsetX, canvasOffsetY]: Point) => Point;
|
|
6
|
+
export declare const checkPositionIntersection: (shape: DrawableShape, position: Point, canvasOffset: Point, selectionPadding: number, currentScale?: number, checkAnchors?: boolean) => false | HoverModeData;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { DrawableShapeJson, Point } from '../types/Shapes';
|
|
2
|
+
export declare const migrateShapesV065: (shapes: DrawableShapeJson[]) => (({
|
|
3
|
+
translation?: Point | undefined;
|
|
4
|
+
} & import("../types/Shapes").StyledShape & {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
} & {
|
|
10
|
+
id: string;
|
|
11
|
+
toolId?: string | undefined;
|
|
12
|
+
rotation: number;
|
|
13
|
+
} & {
|
|
14
|
+
type: "rect";
|
|
15
|
+
}) | ({
|
|
16
|
+
translation?: Point | undefined;
|
|
17
|
+
} & import("../types/Shapes").StyledShape & {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
} & {
|
|
23
|
+
id: string;
|
|
24
|
+
toolId?: string | undefined;
|
|
25
|
+
rotation: number;
|
|
26
|
+
} & {
|
|
27
|
+
type: "square";
|
|
28
|
+
}) | ({
|
|
29
|
+
translation?: Point | undefined;
|
|
30
|
+
} & import("../types/Shapes").StyledShape & {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
} & {
|
|
36
|
+
src: string;
|
|
37
|
+
} & {
|
|
38
|
+
id: string;
|
|
39
|
+
toolId?: string | undefined;
|
|
40
|
+
rotation: number;
|
|
41
|
+
} & {
|
|
42
|
+
type: "picture";
|
|
43
|
+
}) | ({
|
|
44
|
+
translation?: Point | undefined;
|
|
45
|
+
} & import("../types/Shapes").StyledShape & {
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
} & {
|
|
51
|
+
value: string[];
|
|
52
|
+
fontSize: number;
|
|
53
|
+
} & {
|
|
54
|
+
id: string;
|
|
55
|
+
toolId?: string | undefined;
|
|
56
|
+
rotation: number;
|
|
57
|
+
} & {
|
|
58
|
+
type: "text";
|
|
59
|
+
}) | ({
|
|
60
|
+
translation?: Point | undefined;
|
|
61
|
+
} & import("../types/Shapes").StyledShape & {
|
|
62
|
+
points: [Point, Point];
|
|
63
|
+
} & {
|
|
64
|
+
id: string;
|
|
65
|
+
toolId?: string | undefined;
|
|
66
|
+
rotation: number;
|
|
67
|
+
} & {
|
|
68
|
+
type: "line";
|
|
69
|
+
}) | ({
|
|
70
|
+
translation?: Point | undefined;
|
|
71
|
+
} & import("../types/Shapes").StyledShape & {
|
|
72
|
+
points: Point[];
|
|
73
|
+
} & {
|
|
74
|
+
id: string;
|
|
75
|
+
toolId?: string | undefined;
|
|
76
|
+
rotation: number;
|
|
77
|
+
} & {
|
|
78
|
+
type: "polygon";
|
|
79
|
+
}) | ({
|
|
80
|
+
translation?: Point | undefined;
|
|
81
|
+
} & import("../types/Shapes").StyledShape & {
|
|
82
|
+
points: Point[];
|
|
83
|
+
} & {
|
|
84
|
+
id: string;
|
|
85
|
+
toolId?: string | undefined;
|
|
86
|
+
rotation: number;
|
|
87
|
+
} & {
|
|
88
|
+
type: "curve";
|
|
89
|
+
}) | ({
|
|
90
|
+
translation?: Point | undefined;
|
|
91
|
+
} & import("../types/Shapes").StyledShape & {
|
|
92
|
+
points: Point[][];
|
|
93
|
+
} & {
|
|
94
|
+
id: string;
|
|
95
|
+
toolId?: string | undefined;
|
|
96
|
+
rotation: number;
|
|
97
|
+
} & {
|
|
98
|
+
type: "brush";
|
|
99
|
+
}) | ({
|
|
100
|
+
translation?: Point | undefined;
|
|
101
|
+
} & import("../types/Shapes").StyledShape & {
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
radius: number;
|
|
105
|
+
} & {
|
|
106
|
+
id: string;
|
|
107
|
+
toolId?: string | undefined;
|
|
108
|
+
rotation: number;
|
|
109
|
+
} & {
|
|
110
|
+
type: "circle";
|
|
111
|
+
}) | ({
|
|
112
|
+
translation?: Point | undefined;
|
|
113
|
+
} & import("../types/Shapes").StyledShape & {
|
|
114
|
+
x: number;
|
|
115
|
+
y: number;
|
|
116
|
+
radiusX: number;
|
|
117
|
+
radiusY: number;
|
|
118
|
+
} & {
|
|
119
|
+
id: string;
|
|
120
|
+
toolId?: string | undefined;
|
|
121
|
+
rotation: number;
|
|
122
|
+
} & {
|
|
123
|
+
type: "ellipse";
|
|
124
|
+
}) | {
|
|
125
|
+
x: number;
|
|
126
|
+
y: number;
|
|
127
|
+
style?: {
|
|
128
|
+
fillColor?: string | undefined;
|
|
129
|
+
globalAlpha?: number | undefined;
|
|
130
|
+
strokeColor?: string | undefined;
|
|
131
|
+
lineWidth?: number | undefined;
|
|
132
|
+
lineDash?: number | undefined;
|
|
133
|
+
lineArrow?: number | undefined;
|
|
134
|
+
pointsCount?: number | undefined;
|
|
135
|
+
fontFamily?: string | undefined;
|
|
136
|
+
fontItalic?: boolean | undefined;
|
|
137
|
+
fontBold?: boolean | undefined;
|
|
138
|
+
} | undefined;
|
|
139
|
+
type: "rect" | "square" | "circle" | "ellipse" | "picture";
|
|
140
|
+
rotation: number;
|
|
141
|
+
toolId?: string | undefined;
|
|
142
|
+
id: string;
|
|
143
|
+
visible?: boolean | undefined;
|
|
144
|
+
locked?: boolean | undefined;
|
|
145
|
+
} | {
|
|
146
|
+
points: Point[];
|
|
147
|
+
style?: {
|
|
148
|
+
fillColor?: string | undefined;
|
|
149
|
+
globalAlpha?: number | undefined;
|
|
150
|
+
strokeColor?: string | undefined;
|
|
151
|
+
lineWidth?: number | undefined;
|
|
152
|
+
lineDash?: number | undefined;
|
|
153
|
+
lineArrow?: number | undefined;
|
|
154
|
+
pointsCount?: number | undefined;
|
|
155
|
+
fontFamily?: string | undefined;
|
|
156
|
+
fontItalic?: boolean | undefined;
|
|
157
|
+
fontBold?: boolean | undefined;
|
|
158
|
+
} | undefined;
|
|
159
|
+
type: "polygon" | "curve";
|
|
160
|
+
rotation: number;
|
|
161
|
+
toolId?: string | undefined;
|
|
162
|
+
id: string;
|
|
163
|
+
visible?: boolean | undefined;
|
|
164
|
+
locked?: boolean | undefined;
|
|
165
|
+
} | undefined)[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HoverModeData, SelectionModeData } from '../types/Mode';
|
|
2
|
+
import type { Point, DrawableShape } from '../types/Shapes';
|
|
3
|
+
export declare const getNewSelectionData: (hoverMode: HoverModeData, selectedShape: DrawableShape, cursorPosition: Point, selectionPadding: number) => SelectionModeData<Point | number> | undefined;
|
|
4
|
+
export declare const selectShape: (shapes: DrawableShape[], cursorPosition: Point, currentScale: number, canvasOffset: Point, selectedShape: DrawableShape | undefined, selectionPadding: number) => {
|
|
5
|
+
mode: SelectionModeData<Point | number>;
|
|
6
|
+
shape: DrawableShape | undefined;
|
|
7
|
+
};
|