@excalidraw/excalidraw 0.17.1-3e334a6 → 0.17.1-4689a6b
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/CHANGELOG.md +1 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-M7HSOQ7X.js → chunk-23CKV3WP.js} +3 -1
- package/dist/browser/dev/excalidraw-assets-dev/chunk-23CKV3WP.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-RWZVJAQU.js → chunk-7D5BMEAB.js} +2227 -1976
- package/dist/browser/dev/excalidraw-assets-dev/chunk-7D5BMEAB.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{en-R45KN4KN.js → en-W7TECCRB.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{image-EDKQZH7Z.js → image-JKT6GXZD.js} +2 -2
- package/dist/browser/dev/index.css +20 -0
- package/dist/browser/dev/index.css.map +2 -2
- package/dist/browser/dev/index.js +766 -580
- package/dist/browser/dev/index.js.map +4 -4
- package/dist/browser/prod/excalidraw-assets/chunk-DWOM5R6H.js +55 -0
- package/dist/browser/prod/excalidraw-assets/{chunk-DIHRGRYX.js → chunk-SK23VHAR.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{en-H6IY7PV6.js → en-SMMH575S.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/image-WDEQS5RL.js +1 -0
- package/dist/browser/prod/index.css +1 -1
- package/dist/browser/prod/index.js +22 -22
- package/dist/{prod/en-N2RZZLK5.json → dev/en-CVBEBUBY.json} +2 -0
- package/dist/dev/index.css +20 -0
- package/dist/dev/index.css.map +2 -2
- package/dist/dev/index.js +2379 -2069
- package/dist/dev/index.js.map +4 -4
- package/dist/excalidraw/actions/actionBoundText.js +4 -1
- package/dist/excalidraw/actions/actionCanvas.js +3 -1
- package/dist/excalidraw/actions/actionDuplicateSelection.js +4 -0
- package/dist/excalidraw/actions/actionExport.d.ts +1 -1
- package/dist/excalidraw/actions/actionFinalize.d.ts +1 -1
- package/dist/excalidraw/actions/actionFinalize.js +3 -3
- package/dist/excalidraw/actions/actionFlip.d.ts +3 -3
- package/dist/excalidraw/actions/actionFlip.js +6 -6
- package/dist/excalidraw/actions/actionGroup.js +4 -2
- package/dist/excalidraw/actions/actionHistory.js +3 -0
- package/dist/excalidraw/actions/actionZindex.d.ts +11 -11
- package/dist/excalidraw/analytics.js +1 -1
- package/dist/excalidraw/components/App.d.ts +13 -3
- package/dist/excalidraw/components/App.js +211 -81
- package/dist/excalidraw/components/CommandPalette/CommandPalette.js +24 -10
- package/dist/excalidraw/components/DarkModeToggle.js +3 -1
- package/dist/excalidraw/components/HelpDialog.js +2 -2
- package/dist/excalidraw/components/RadioGroup.d.ts +2 -1
- package/dist/excalidraw/components/RadioGroup.js +1 -1
- package/dist/excalidraw/components/TTDDialog/MermaidToExcalidraw.js +6 -2
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +18 -0
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.js +9 -0
- package/dist/excalidraw/components/hyperlink/Hyperlink.js +3 -3
- package/dist/excalidraw/components/hyperlink/helpers.js +2 -3
- package/dist/excalidraw/components/icons.d.ts +3 -0
- package/dist/excalidraw/components/icons.js +5 -1
- package/dist/excalidraw/components/main-menu/DefaultItems.d.ts +12 -2
- package/dist/excalidraw/components/main-menu/DefaultItems.js +38 -7
- package/dist/excalidraw/constants.d.ts +0 -3
- package/dist/excalidraw/constants.js +0 -3
- package/dist/excalidraw/data/magic.js +2 -1
- package/dist/excalidraw/data/reconcile.d.ts +6 -0
- package/dist/excalidraw/data/reconcile.js +49 -0
- package/dist/excalidraw/data/restore.d.ts +3 -3
- package/dist/excalidraw/data/restore.js +5 -6
- package/dist/excalidraw/data/transform.d.ts +1 -1
- package/dist/excalidraw/data/transform.js +12 -3
- package/dist/excalidraw/element/binding.d.ts +22 -9
- package/dist/excalidraw/element/binding.js +403 -26
- package/dist/excalidraw/element/bounds.d.ts +0 -1
- package/dist/excalidraw/element/bounds.js +0 -3
- package/dist/excalidraw/element/collision.d.ts +14 -19
- package/dist/excalidraw/element/collision.js +36 -713
- package/dist/excalidraw/element/embeddable.js +18 -43
- package/dist/excalidraw/element/index.d.ts +0 -1
- package/dist/excalidraw/element/index.js +0 -1
- package/dist/excalidraw/element/linearElementEditor.d.ts +10 -10
- package/dist/excalidraw/element/linearElementEditor.js +6 -4
- package/dist/excalidraw/element/newElement.d.ts +1 -1
- package/dist/excalidraw/element/newElement.js +2 -1
- package/dist/excalidraw/element/textElement.d.ts +0 -1
- package/dist/excalidraw/element/textElement.js +0 -30
- package/dist/excalidraw/element/types.d.ts +17 -2
- package/dist/excalidraw/errors.d.ts +3 -0
- package/dist/excalidraw/errors.js +3 -0
- package/dist/excalidraw/fractionalIndex.d.ts +40 -0
- package/dist/excalidraw/fractionalIndex.js +241 -0
- package/dist/excalidraw/frame.d.ts +1 -1
- package/dist/excalidraw/hooks/useCreatePortalContainer.js +2 -1
- package/dist/excalidraw/locales/en.json +2 -0
- package/dist/excalidraw/renderer/helpers.js +2 -2
- package/dist/excalidraw/renderer/interactiveScene.js +1 -1
- package/dist/excalidraw/renderer/renderElement.js +3 -3
- package/dist/excalidraw/renderer/renderSnaps.js +2 -1
- package/dist/excalidraw/scene/Scene.d.ts +7 -6
- package/dist/excalidraw/scene/Scene.js +28 -13
- package/dist/excalidraw/scene/export.js +4 -3
- package/dist/excalidraw/types.d.ts +4 -3
- package/dist/excalidraw/utils.d.ts +1 -0
- package/dist/excalidraw/utils.js +1 -0
- package/dist/excalidraw/zindex.d.ts +2 -2
- package/dist/excalidraw/zindex.js +9 -13
- package/dist/{dev/en-N2RZZLK5.json → prod/en-CVBEBUBY.json} +2 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +36 -36
- package/dist/utils/collision.d.ts +4 -0
- package/dist/utils/collision.js +48 -0
- package/dist/utils/geometry/geometry.d.ts +71 -0
- package/dist/utils/geometry/geometry.js +674 -0
- package/dist/utils/geometry/shape.d.ts +55 -0
- package/dist/utils/geometry/shape.js +149 -0
- package/package.json +2 -1
- package/dist/browser/dev/excalidraw-assets-dev/chunk-M7HSOQ7X.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/chunk-RWZVJAQU.js.map +0 -7
- package/dist/browser/prod/excalidraw-assets/chunk-LL4GORAM.js +0 -55
- package/dist/browser/prod/excalidraw-assets/image-EFCJDJH3.js +0 -1
- /package/dist/browser/dev/excalidraw-assets-dev/{en-R45KN4KN.js.map → en-W7TECCRB.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{image-EDKQZH7Z.js.map → image-JKT6GXZD.js.map} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Point, Polygon, GeometricShape } from "./geometry/shape";
|
|
2
|
+
export declare const isPointOnShape: (point: Point, shape: GeometricShape, tolerance?: number) => boolean;
|
|
3
|
+
export declare const isPointInShape: (point: Point, shape: GeometricShape) => boolean;
|
|
4
|
+
export declare const isPointInBounds: (point: Point, bounds: Polygon) => boolean;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { pointInEllipse, pointInPolygon, pointOnCurve, pointOnEllipse, pointOnLine, pointOnPolycurve, pointOnPolygon, pointOnPolyline, close, } from "./geometry/geometry";
|
|
2
|
+
// check if the given point is considered on the given shape's border
|
|
3
|
+
export const isPointOnShape = (point, shape, tolerance = 0) => {
|
|
4
|
+
// get the distance from the given point to the given element
|
|
5
|
+
// check if the distance is within the given epsilon range
|
|
6
|
+
switch (shape.type) {
|
|
7
|
+
case "polygon":
|
|
8
|
+
return pointOnPolygon(point, shape.data, tolerance);
|
|
9
|
+
case "ellipse":
|
|
10
|
+
return pointOnEllipse(point, shape.data, tolerance);
|
|
11
|
+
case "line":
|
|
12
|
+
return pointOnLine(point, shape.data, tolerance);
|
|
13
|
+
case "polyline":
|
|
14
|
+
return pointOnPolyline(point, shape.data, tolerance);
|
|
15
|
+
case "curve":
|
|
16
|
+
return pointOnCurve(point, shape.data, tolerance);
|
|
17
|
+
case "polycurve":
|
|
18
|
+
return pointOnPolycurve(point, shape.data, tolerance);
|
|
19
|
+
default:
|
|
20
|
+
throw Error(`shape ${shape} is not implemented`);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
// check if the given point is considered inside the element's border
|
|
24
|
+
export const isPointInShape = (point, shape) => {
|
|
25
|
+
switch (shape.type) {
|
|
26
|
+
case "polygon":
|
|
27
|
+
return pointInPolygon(point, shape.data);
|
|
28
|
+
case "line":
|
|
29
|
+
return false;
|
|
30
|
+
case "curve":
|
|
31
|
+
return false;
|
|
32
|
+
case "ellipse":
|
|
33
|
+
return pointInEllipse(point, shape.data);
|
|
34
|
+
case "polyline": {
|
|
35
|
+
const polygon = close(shape.data.flat());
|
|
36
|
+
return pointInPolygon(point, polygon);
|
|
37
|
+
}
|
|
38
|
+
case "polycurve": {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
default:
|
|
42
|
+
throw Error(`shape ${shape} is not implemented`);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
// check if the given element is in the given bounds
|
|
46
|
+
export const isPointInBounds = (point, bounds) => {
|
|
47
|
+
return pointInPolygon(point, bounds);
|
|
48
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Point, Line, Polygon, Curve, Ellipse, Polycurve, Polyline } from "./shape";
|
|
2
|
+
/**
|
|
3
|
+
* utils
|
|
4
|
+
*/
|
|
5
|
+
export declare const cross: (a: Point, b: Point, o: Point) => number;
|
|
6
|
+
export declare const isClosed: (polygon: Polygon) => boolean;
|
|
7
|
+
export declare const close: (polygon: Polygon) => Polygon;
|
|
8
|
+
/**
|
|
9
|
+
* angles
|
|
10
|
+
*/
|
|
11
|
+
export declare const angleToDegrees: (angle: number) => number;
|
|
12
|
+
export declare const angleToRadians: (angle: number) => number;
|
|
13
|
+
export declare const angleReflect: (incidenceAngle: number, surfaceAngle: number) => number;
|
|
14
|
+
export declare const pointRotate: (point: Point, angle: number, origin?: Point) => Point;
|
|
15
|
+
export declare const pointTranslate: (point: Point, angle?: number, distance?: number) => Point;
|
|
16
|
+
export declare const pointInverse: (point: Point) => Point;
|
|
17
|
+
export declare const pointAdd: (pointA: Point, pointB: Point) => Point;
|
|
18
|
+
export declare const distanceToPoint: (p1: Point, p2: Point) => number;
|
|
19
|
+
/**
|
|
20
|
+
* lines
|
|
21
|
+
*/
|
|
22
|
+
export declare const lineAngle: (line: Line) => number;
|
|
23
|
+
export declare const lineLength: (line: Line) => number;
|
|
24
|
+
export declare const lineMidpoint: (line: Line) => Point;
|
|
25
|
+
export declare const lineRotate: (line: Line, angle: number, origin?: Point) => Line;
|
|
26
|
+
export declare const lineTranslate: (line: Line, angle: number, distance: number) => Point[];
|
|
27
|
+
export declare const lineInterpolate: (line: Line, clamp?: boolean) => (t: number) => Point;
|
|
28
|
+
export declare const curveToBezier: (pointsIn: readonly Point[], curveTightness?: number) => Point[];
|
|
29
|
+
export declare const curveRotate: (curve: Curve, angle: number, origin: Point) => Point[];
|
|
30
|
+
export declare const cubicBezierPoint: (t: number, controlPoints: Curve) => Point;
|
|
31
|
+
export declare const cubicBezierDistance: (point: Point, controlPoints: Curve) => number;
|
|
32
|
+
/**
|
|
33
|
+
* polygons
|
|
34
|
+
*/
|
|
35
|
+
export declare const polygonRotate: (polygon: Polygon, angle: number, origin: Point) => Point[];
|
|
36
|
+
export declare const polygonBounds: (polygon: Polygon) => [Point, Point];
|
|
37
|
+
export declare const polygonCentroid: (vertices: Point[]) => Point;
|
|
38
|
+
export declare const polygonScale: (polygon: Polygon, scale: number, origin?: Point) => Polygon;
|
|
39
|
+
export declare const polygonScaleX: (polygon: Polygon, scale: number, origin?: Point) => Polygon;
|
|
40
|
+
export declare const polygonScaleY: (polygon: Polygon, scale: number, origin?: Point) => Polygon;
|
|
41
|
+
export declare const polygonReflectX: (polygon: Polygon, reflectFactor?: number) => Point[];
|
|
42
|
+
export declare const polygonReflectY: (polygon: Polygon, reflectFactor?: number) => Point[];
|
|
43
|
+
export declare const polygonTranslate: (polygon: Polygon, angle: number, distance: number) => Point[];
|
|
44
|
+
/**
|
|
45
|
+
* ellipses
|
|
46
|
+
*/
|
|
47
|
+
export declare const ellipseAxes: (ellipse: Ellipse) => {
|
|
48
|
+
majorAxis: number;
|
|
49
|
+
minorAxis: number;
|
|
50
|
+
};
|
|
51
|
+
export declare const ellipseFocusToCenter: (ellipse: Ellipse) => number;
|
|
52
|
+
export declare const ellipseExtremes: (ellipse: Ellipse) => Point[];
|
|
53
|
+
export declare const pointRelativeToCenter: (point: Point, center: Point, angle: number) => Point;
|
|
54
|
+
export declare const pointLeftofLine: (point: Point, line: Line) => boolean;
|
|
55
|
+
export declare const pointRightofLine: (point: Point, line: Line) => boolean;
|
|
56
|
+
export declare const distanceToSegment: (point: Point, line: Line) => number;
|
|
57
|
+
export declare const pointOnLine: (point: Point, line: Line, threshold?: number) => boolean;
|
|
58
|
+
export declare const pointOnPolyline: (point: Point, polyline: Polyline, threshold?: number) => boolean;
|
|
59
|
+
export declare const lineIntersectsLine: (lineA: Line, lineB: Line) => boolean;
|
|
60
|
+
export declare const lineIntersectsPolygon: (line: Line, polygon: Polygon) => boolean;
|
|
61
|
+
export declare const pointInBezierEquation: (p0: Point, p1: Point, p2: Point, p3: Point, [mx, my]: Point, lineThreshold: number) => boolean;
|
|
62
|
+
export declare const cubicBezierEquation: (curve: Curve) => (t: number, idx: number) => number;
|
|
63
|
+
export declare const polyLineFromCurve: (curve: Curve, segments?: number) => Polyline;
|
|
64
|
+
export declare const pointOnCurve: (point: Point, curve: Curve, threshold?: number) => boolean;
|
|
65
|
+
export declare const pointOnPolycurve: (point: Point, polycurve: Polycurve, threshold?: number) => boolean;
|
|
66
|
+
export declare const pointInPolygon: (point: Point, polygon: Polygon) => boolean;
|
|
67
|
+
export declare const pointOnPolygon: (point: Point, polygon: Polygon, threshold?: number) => boolean;
|
|
68
|
+
export declare const polygonInPolygon: (polygonA: Polygon, polygonB: Polygon) => boolean;
|
|
69
|
+
export declare const polygonIntersectPolygon: (polygonA: Polygon, polygonB: Polygon) => boolean;
|
|
70
|
+
export declare const pointOnEllipse: (point: Point, ellipse: Ellipse, threshold?: number) => boolean;
|
|
71
|
+
export declare const pointInEllipse: (point: Point, ellipse: Ellipse) => boolean;
|