@excalidraw/excalidraw 0.18.0-6fc8502 → 0.18.0-a5d6939
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/dev/{chunk-KYBDXI6F.js → chunk-GBJ7S76A.js} +120 -260
- package/dist/dev/chunk-GBJ7S76A.js.map +7 -0
- package/dist/dev/{chunk-H7XJ5UVD.js → chunk-GIMGG4AT.js} +2 -2
- package/dist/dev/data/{image-NKFINVKH.js → image-JN3Y4CVN.js} +3 -3
- package/dist/dev/index.js +332 -229
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/subset-shared.chunk.js +1 -1
- package/dist/dev/subset-worker.chunk.js +1 -1
- package/dist/prod/{chunk-KJYFYP64.js → chunk-GKI4RZ6C.js} +1 -1
- package/dist/prod/chunk-TVF64BAY.js +33 -0
- package/dist/prod/data/image-CZ2OEVDB.js +1 -0
- package/dist/prod/index.js +14 -14
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/common/src/constants.d.ts +2 -0
- package/dist/types/common/src/utils.d.ts +4 -1
- package/dist/types/element/src/binding.d.ts +1 -2
- package/dist/types/element/src/collision.d.ts +1 -1
- package/dist/types/element/src/duplicate.d.ts +10 -13
- package/dist/types/element/src/frame.d.ts +1 -1
- package/dist/types/element/src/selection.d.ts +11 -0
- package/dist/types/element/src/textElement.d.ts +2 -1
- package/dist/types/excalidraw/components/App.d.ts +19 -5
- package/dist/types/excalidraw/eraser/index.d.ts +14 -0
- package/dist/types/excalidraw/lasso/utils.d.ts +1 -2
- package/dist/types/excalidraw/types.d.ts +4 -0
- package/dist/types/math/src/types.d.ts +1 -0
- package/package.json +1 -1
- package/dist/dev/chunk-KYBDXI6F.js.map +0 -7
- package/dist/prod/chunk-CAN5RS4P.js +0 -31
- package/dist/prod/data/image-5XD47O4X.js +0 -1
- /package/dist/dev/{chunk-H7XJ5UVD.js.map → chunk-GIMGG4AT.js.map} +0 -0
- /package/dist/dev/data/{image-NKFINVKH.js.map → image-JN3Y4CVN.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
define_import_meta_env_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GIMGG4AT.js";
|
|
4
4
|
import {
|
|
5
5
|
__publicField
|
|
6
6
|
} from "./chunk-XDFCUUT6.js";
|
|
@@ -264,7 +264,8 @@ var YOUTUBE_STATES = {
|
|
|
264
264
|
};
|
|
265
265
|
var ENV = {
|
|
266
266
|
TEST: "test",
|
|
267
|
-
DEVELOPMENT: "development"
|
|
267
|
+
DEVELOPMENT: "development",
|
|
268
|
+
PRODUCTION: "production"
|
|
268
269
|
};
|
|
269
270
|
var CLASSES = {
|
|
270
271
|
SHAPE_ACTIONS_MENU: "App-menu__left",
|
|
@@ -411,6 +412,9 @@ var DEFAULT_EXPORT_PADDING = 10;
|
|
|
411
412
|
var DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440;
|
|
412
413
|
var MAX_ALLOWED_FILE_BYTES = 4 * 1024 * 1024;
|
|
413
414
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
415
|
+
var SVG_DOCUMENT_PREAMBLE = `<?xml version="1.0" standalone="no"?>
|
|
416
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
417
|
+
`;
|
|
414
418
|
var VERSIONS = {
|
|
415
419
|
excalidraw: 2,
|
|
416
420
|
excalidrawLibrary: 2
|
|
@@ -1651,6 +1655,7 @@ var arrayToList = (array) => array.reduce((acc, curr, index) => {
|
|
|
1651
1655
|
}, []);
|
|
1652
1656
|
var isTestEnv = () => define_import_meta_env_default.MODE === ENV.TEST;
|
|
1653
1657
|
var isDevEnv = () => define_import_meta_env_default.MODE === ENV.DEVELOPMENT;
|
|
1658
|
+
var isProdEnv = () => define_import_meta_env_default.MODE === ENV.PRODUCTION;
|
|
1654
1659
|
var isServerEnv = () => typeof process !== "undefined" && true;
|
|
1655
1660
|
var wrapEvent = (name, nativeEvent) => {
|
|
1656
1661
|
return new CustomEvent(name, {
|
|
@@ -1862,6 +1867,12 @@ var escapeDoubleQuotes = (str) => {
|
|
|
1862
1867
|
return str.replace(/"/g, """);
|
|
1863
1868
|
};
|
|
1864
1869
|
var castArray = (value) => Array.isArray(value) ? value : [value];
|
|
1870
|
+
var elementCenterPoint = (element, xOffset = 0, yOffset = 0) => {
|
|
1871
|
+
const { x, y, width, height } = element;
|
|
1872
|
+
const centerXPoint = x + width / 2 + xOffset;
|
|
1873
|
+
const centerYPoint = y + height / 2 + yOffset;
|
|
1874
|
+
return pointFrom(centerXPoint, centerYPoint);
|
|
1875
|
+
};
|
|
1865
1876
|
|
|
1866
1877
|
// ../common/src/random.ts
|
|
1867
1878
|
var random = new Random(Date.now());
|
|
@@ -2434,10 +2445,7 @@ function deconstructRectanguloidElement(element, offset = 0) {
|
|
|
2434
2445
|
const sides2 = [top2, right2, bottom2, left2];
|
|
2435
2446
|
return [sides2, []];
|
|
2436
2447
|
}
|
|
2437
|
-
const center =
|
|
2438
|
-
element.x + element.width / 2,
|
|
2439
|
-
element.y + element.height / 2
|
|
2440
|
-
);
|
|
2448
|
+
const center = elementCenterPoint(element);
|
|
2441
2449
|
const r = rectangle(
|
|
2442
2450
|
pointFrom(element.x, element.y),
|
|
2443
2451
|
pointFrom(element.x + element.width, element.y + element.height)
|
|
@@ -2603,10 +2611,7 @@ function deconstructDiamondElement(element, offset = 0) {
|
|
|
2603
2611
|
);
|
|
2604
2612
|
return [[topRight, bottomRight, bottomLeft, topLeft], []];
|
|
2605
2613
|
}
|
|
2606
|
-
const center =
|
|
2607
|
-
element.x + element.width / 2,
|
|
2608
|
-
element.y + element.height / 2
|
|
2609
|
-
);
|
|
2614
|
+
const center = elementCenterPoint(element);
|
|
2610
2615
|
const [top, right, bottom, left] = [
|
|
2611
2616
|
pointFrom(element.x + topX, element.y + topY),
|
|
2612
2617
|
pointFrom(element.x + rightX, element.y + rightY),
|
|
@@ -2787,10 +2792,7 @@ var intersectElementWithLineSegment = (element, line2, offset = 0) => {
|
|
|
2787
2792
|
}
|
|
2788
2793
|
};
|
|
2789
2794
|
var intersectRectanguloidWithLineSegment = (element, l, offset = 0) => {
|
|
2790
|
-
const center =
|
|
2791
|
-
element.x + element.width / 2,
|
|
2792
|
-
element.y + element.height / 2
|
|
2793
|
-
);
|
|
2795
|
+
const center = elementCenterPoint(element);
|
|
2794
2796
|
const rotatedA = pointRotateRads(
|
|
2795
2797
|
l[0],
|
|
2796
2798
|
center,
|
|
@@ -2820,10 +2822,7 @@ var intersectRectanguloidWithLineSegment = (element, l, offset = 0) => {
|
|
|
2820
2822
|
);
|
|
2821
2823
|
};
|
|
2822
2824
|
var intersectDiamondWithLineSegment = (element, l, offset = 0) => {
|
|
2823
|
-
const center =
|
|
2824
|
-
element.x + element.width / 2,
|
|
2825
|
-
element.y + element.height / 2
|
|
2826
|
-
);
|
|
2825
|
+
const center = elementCenterPoint(element);
|
|
2827
2826
|
const rotatedA = pointRotateRads(l[0], center, -element.angle);
|
|
2828
2827
|
const rotatedB = pointRotateRads(l[1], center, -element.angle);
|
|
2829
2828
|
const [sides, curves] = deconstructDiamondElement(element, offset);
|
|
@@ -2841,10 +2840,7 @@ var intersectDiamondWithLineSegment = (element, l, offset = 0) => {
|
|
|
2841
2840
|
);
|
|
2842
2841
|
};
|
|
2843
2842
|
var intersectEllipseWithLineSegment = (element, l, offset = 0) => {
|
|
2844
|
-
const center =
|
|
2845
|
-
element.x + element.width / 2,
|
|
2846
|
-
element.y + element.height / 2
|
|
2847
|
-
);
|
|
2843
|
+
const center = elementCenterPoint(element);
|
|
2848
2844
|
const rotatedA = pointRotateRads(l[0], center, -element.angle);
|
|
2849
2845
|
const rotatedB = pointRotateRads(l[1], center, -element.angle);
|
|
2850
2846
|
return ellipseLineIntersectionPoints(
|
|
@@ -2890,10 +2886,7 @@ var distanceToBindableElement = (element, p) => {
|
|
|
2890
2886
|
}
|
|
2891
2887
|
};
|
|
2892
2888
|
var distanceToRectanguloidElement = (element, p) => {
|
|
2893
|
-
const center =
|
|
2894
|
-
element.x + element.width / 2,
|
|
2895
|
-
element.y + element.height / 2
|
|
2896
|
-
);
|
|
2889
|
+
const center = elementCenterPoint(element);
|
|
2897
2890
|
const rotatedPoint = pointRotateRads(p, center, -element.angle);
|
|
2898
2891
|
const [sides, corners] = deconstructRectanguloidElement(element);
|
|
2899
2892
|
return Math.min(
|
|
@@ -2902,10 +2895,7 @@ var distanceToRectanguloidElement = (element, p) => {
|
|
|
2902
2895
|
);
|
|
2903
2896
|
};
|
|
2904
2897
|
var distanceToDiamondElement = (element, p) => {
|
|
2905
|
-
const center =
|
|
2906
|
-
element.x + element.width / 2,
|
|
2907
|
-
element.y + element.height / 2
|
|
2908
|
-
);
|
|
2898
|
+
const center = elementCenterPoint(element);
|
|
2909
2899
|
const rotatedPoint = pointRotateRads(p, center, -element.angle);
|
|
2910
2900
|
const [sides, curves] = deconstructDiamondElement(element);
|
|
2911
2901
|
return Math.min(
|
|
@@ -2914,10 +2904,7 @@ var distanceToDiamondElement = (element, p) => {
|
|
|
2914
2904
|
);
|
|
2915
2905
|
};
|
|
2916
2906
|
var distanceToEllipseElement = (element, p) => {
|
|
2917
|
-
const center =
|
|
2918
|
-
element.x + element.width / 2,
|
|
2919
|
-
element.y + element.height / 2
|
|
2920
|
-
);
|
|
2907
|
+
const center = elementCenterPoint(element);
|
|
2921
2908
|
return ellipseDistanceFromPoint(
|
|
2922
2909
|
// Instead of rotating the ellipse, rotate the point to the inverse angle
|
|
2923
2910
|
pointRotateRads(p, center, -element.angle),
|
|
@@ -3619,13 +3606,7 @@ var getHeadingForElbowArrowSnap = (p, otherPoint, bindableElement, aabb, element
|
|
|
3619
3606
|
);
|
|
3620
3607
|
if (!distance2) {
|
|
3621
3608
|
return vectorToHeading(
|
|
3622
|
-
vectorFromPoint(
|
|
3623
|
-
p,
|
|
3624
|
-
pointFrom(
|
|
3625
|
-
bindableElement.x + bindableElement.width / 2,
|
|
3626
|
-
bindableElement.y + bindableElement.height / 2
|
|
3627
|
-
)
|
|
3628
|
-
)
|
|
3609
|
+
vectorFromPoint(p, elementCenterPoint(bindableElement))
|
|
3629
3610
|
);
|
|
3630
3611
|
}
|
|
3631
3612
|
return headingForPointFromElement(bindableElement, aabb, p);
|
|
@@ -3719,10 +3700,7 @@ var bindPointToSnapToElementOutline = (arrow, bindableElement, startOrEnd) => {
|
|
|
3719
3700
|
return edgePoint;
|
|
3720
3701
|
};
|
|
3721
3702
|
var avoidRectangularCorner = (element, p) => {
|
|
3722
|
-
const center =
|
|
3723
|
-
element.x + element.width / 2,
|
|
3724
|
-
element.y + element.height / 2
|
|
3725
|
-
);
|
|
3703
|
+
const center = elementCenterPoint(element);
|
|
3726
3704
|
const nonRotatedPoint = pointRotateRads(p, center, -element.angle);
|
|
3727
3705
|
if (nonRotatedPoint[0] < element.x && nonRotatedPoint[1] < element.y) {
|
|
3728
3706
|
if (nonRotatedPoint[1] - element.y > -FIXED_BINDING_DISTANCE) {
|
|
@@ -3793,10 +3771,7 @@ var avoidRectangularCorner = (element, p) => {
|
|
|
3793
3771
|
};
|
|
3794
3772
|
var snapToMid = (element, p, tolerance = 0.05) => {
|
|
3795
3773
|
const { x, y, width, height, angle } = element;
|
|
3796
|
-
const center =
|
|
3797
|
-
x + width / 2 - 0.1,
|
|
3798
|
-
y + height / 2 - 0.1
|
|
3799
|
-
);
|
|
3774
|
+
const center = elementCenterPoint(element, -0.1, -0.1);
|
|
3800
3775
|
const nonRotated = pointRotateRads(p, center, -angle);
|
|
3801
3776
|
const verticalThrehsold = clamp(tolerance * height, 5, 80);
|
|
3802
3777
|
const horizontalThrehsold = clamp(tolerance * width, 5, 80);
|
|
@@ -3841,10 +3816,7 @@ var updateBoundPoint = (linearElement, startOrEnd, binding, bindableElement, ele
|
|
|
3841
3816
|
startOrEnd === "startBinding" ? "start" : "end",
|
|
3842
3817
|
elementsMap
|
|
3843
3818
|
).fixedPoint;
|
|
3844
|
-
const globalMidPoint =
|
|
3845
|
-
bindableElement.x + bindableElement.width / 2,
|
|
3846
|
-
bindableElement.y + bindableElement.height / 2
|
|
3847
|
-
);
|
|
3819
|
+
const globalMidPoint = elementCenterPoint(bindableElement);
|
|
3848
3820
|
const global = pointFrom(
|
|
3849
3821
|
bindableElement.x + fixedPoint[0] * bindableElement.width,
|
|
3850
3822
|
bindableElement.y + fixedPoint[1] * bindableElement.height
|
|
@@ -3880,10 +3852,7 @@ var updateBoundPoint = (linearElement, startOrEnd, binding, bindableElement, ele
|
|
|
3880
3852
|
edgePointIndex,
|
|
3881
3853
|
elementsMap
|
|
3882
3854
|
);
|
|
3883
|
-
const center =
|
|
3884
|
-
bindableElement.x + bindableElement.width / 2,
|
|
3885
|
-
bindableElement.y + bindableElement.height / 2
|
|
3886
|
-
);
|
|
3855
|
+
const center = elementCenterPoint(bindableElement);
|
|
3887
3856
|
const interceptorLength = pointDistance(adjacentPoint, edgePointAbsolute) + pointDistance(adjacentPoint, center) + Math.max(bindableElement.width, bindableElement.height) * 2;
|
|
3888
3857
|
const intersections = [
|
|
3889
3858
|
...intersectElementWithLineSegment(
|
|
@@ -3990,13 +3959,13 @@ var getLinearElementEdgeCoors = (linearElement, startOrEnd, elementsMap) => {
|
|
|
3990
3959
|
)
|
|
3991
3960
|
);
|
|
3992
3961
|
};
|
|
3993
|
-
var fixDuplicatedBindingsAfterDuplication = (
|
|
3994
|
-
for (const
|
|
3995
|
-
if ("boundElements" in
|
|
3996
|
-
Object.assign(
|
|
3997
|
-
boundElements:
|
|
3962
|
+
var fixDuplicatedBindingsAfterDuplication = (duplicatedElements, origIdToDuplicateId, duplicateElementsMap) => {
|
|
3963
|
+
for (const duplicateElement of duplicatedElements) {
|
|
3964
|
+
if ("boundElements" in duplicateElement && duplicateElement.boundElements) {
|
|
3965
|
+
Object.assign(duplicateElement, {
|
|
3966
|
+
boundElements: duplicateElement.boundElements.reduce(
|
|
3998
3967
|
(acc, binding) => {
|
|
3999
|
-
const newBindingId =
|
|
3968
|
+
const newBindingId = origIdToDuplicateId.get(binding.id);
|
|
4000
3969
|
if (newBindingId) {
|
|
4001
3970
|
acc.push({ ...binding, id: newBindingId });
|
|
4002
3971
|
}
|
|
@@ -4006,191 +3975,46 @@ var fixDuplicatedBindingsAfterDuplication = (newElements, oldIdToDuplicatedId, d
|
|
|
4006
3975
|
)
|
|
4007
3976
|
});
|
|
4008
3977
|
}
|
|
4009
|
-
if ("containerId" in
|
|
4010
|
-
Object.assign(
|
|
4011
|
-
containerId:
|
|
3978
|
+
if ("containerId" in duplicateElement && duplicateElement.containerId) {
|
|
3979
|
+
Object.assign(duplicateElement, {
|
|
3980
|
+
containerId: origIdToDuplicateId.get(duplicateElement.containerId) ?? null
|
|
4012
3981
|
});
|
|
4013
3982
|
}
|
|
4014
|
-
if ("endBinding" in
|
|
4015
|
-
const newEndBindingId =
|
|
4016
|
-
|
|
3983
|
+
if ("endBinding" in duplicateElement && duplicateElement.endBinding) {
|
|
3984
|
+
const newEndBindingId = origIdToDuplicateId.get(
|
|
3985
|
+
duplicateElement.endBinding.elementId
|
|
4017
3986
|
);
|
|
4018
|
-
Object.assign(
|
|
3987
|
+
Object.assign(duplicateElement, {
|
|
4019
3988
|
endBinding: newEndBindingId ? {
|
|
4020
|
-
...
|
|
3989
|
+
...duplicateElement.endBinding,
|
|
4021
3990
|
elementId: newEndBindingId
|
|
4022
3991
|
} : null
|
|
4023
3992
|
});
|
|
4024
3993
|
}
|
|
4025
|
-
if ("startBinding" in
|
|
4026
|
-
const newEndBindingId =
|
|
4027
|
-
|
|
3994
|
+
if ("startBinding" in duplicateElement && duplicateElement.startBinding) {
|
|
3995
|
+
const newEndBindingId = origIdToDuplicateId.get(
|
|
3996
|
+
duplicateElement.startBinding.elementId
|
|
4028
3997
|
);
|
|
4029
|
-
Object.assign(
|
|
3998
|
+
Object.assign(duplicateElement, {
|
|
4030
3999
|
startBinding: newEndBindingId ? {
|
|
4031
|
-
...
|
|
4000
|
+
...duplicateElement.startBinding,
|
|
4032
4001
|
elementId: newEndBindingId
|
|
4033
4002
|
} : null
|
|
4034
4003
|
});
|
|
4035
4004
|
}
|
|
4036
|
-
if (isElbowArrow(
|
|
4005
|
+
if (isElbowArrow(duplicateElement)) {
|
|
4037
4006
|
Object.assign(
|
|
4038
|
-
|
|
4039
|
-
updateElbowArrowPoints(
|
|
4007
|
+
duplicateElement,
|
|
4008
|
+
updateElbowArrowPoints(duplicateElement, duplicateElementsMap, {
|
|
4040
4009
|
points: [
|
|
4041
|
-
|
|
4042
|
-
|
|
4010
|
+
duplicateElement.points[0],
|
|
4011
|
+
duplicateElement.points[duplicateElement.points.length - 1]
|
|
4043
4012
|
]
|
|
4044
4013
|
})
|
|
4045
4014
|
);
|
|
4046
4015
|
}
|
|
4047
4016
|
}
|
|
4048
4017
|
};
|
|
4049
|
-
var fixReversedBindingsForBindables = (original, duplicate, originalElements, elementsWithClones, oldIdToDuplicatedId) => {
|
|
4050
|
-
original.boundElements?.forEach((binding, idx) => {
|
|
4051
|
-
if (binding.type !== "arrow") {
|
|
4052
|
-
return;
|
|
4053
|
-
}
|
|
4054
|
-
const oldArrow = elementsWithClones.find((el) => el.id === binding.id);
|
|
4055
|
-
if (!isBindingElement(oldArrow)) {
|
|
4056
|
-
return;
|
|
4057
|
-
}
|
|
4058
|
-
if (originalElements.has(binding.id)) {
|
|
4059
|
-
const newArrowId = oldIdToDuplicatedId.get(binding.id) ?? binding.id;
|
|
4060
|
-
const newArrow = elementsWithClones.find(
|
|
4061
|
-
(el) => el.id === newArrowId
|
|
4062
|
-
);
|
|
4063
|
-
mutateElement(newArrow, {
|
|
4064
|
-
startBinding: oldArrow.startBinding?.elementId === binding.id ? {
|
|
4065
|
-
...oldArrow.startBinding,
|
|
4066
|
-
elementId: duplicate.id
|
|
4067
|
-
} : newArrow.startBinding,
|
|
4068
|
-
endBinding: oldArrow.endBinding?.elementId === binding.id ? {
|
|
4069
|
-
...oldArrow.endBinding,
|
|
4070
|
-
elementId: duplicate.id
|
|
4071
|
-
} : newArrow.endBinding
|
|
4072
|
-
});
|
|
4073
|
-
mutateElement(duplicate, {
|
|
4074
|
-
boundElements: [
|
|
4075
|
-
...(duplicate.boundElements ?? []).filter(
|
|
4076
|
-
(el) => el.id !== binding.id && el.id !== newArrowId
|
|
4077
|
-
),
|
|
4078
|
-
{
|
|
4079
|
-
type: "arrow",
|
|
4080
|
-
id: newArrowId
|
|
4081
|
-
}
|
|
4082
|
-
]
|
|
4083
|
-
});
|
|
4084
|
-
} else {
|
|
4085
|
-
mutateElement(oldArrow, {
|
|
4086
|
-
startBinding: oldArrow.startBinding?.elementId === original.id ? {
|
|
4087
|
-
...oldArrow.startBinding,
|
|
4088
|
-
elementId: duplicate.id
|
|
4089
|
-
} : oldArrow.startBinding,
|
|
4090
|
-
endBinding: oldArrow.endBinding?.elementId === original.id ? {
|
|
4091
|
-
...oldArrow.endBinding,
|
|
4092
|
-
elementId: duplicate.id
|
|
4093
|
-
} : oldArrow.endBinding
|
|
4094
|
-
});
|
|
4095
|
-
mutateElement(duplicate, {
|
|
4096
|
-
boundElements: [
|
|
4097
|
-
...duplicate.boundElements ?? [],
|
|
4098
|
-
{
|
|
4099
|
-
type: "arrow",
|
|
4100
|
-
id: oldArrow.id
|
|
4101
|
-
}
|
|
4102
|
-
]
|
|
4103
|
-
});
|
|
4104
|
-
mutateElement(original, {
|
|
4105
|
-
boundElements: original.boundElements?.filter((_, i) => i !== idx) ?? null
|
|
4106
|
-
});
|
|
4107
|
-
}
|
|
4108
|
-
});
|
|
4109
|
-
};
|
|
4110
|
-
var fixReversedBindingsForArrows = (original, duplicate, originalElements, bindingProp, oldIdToDuplicatedId, elementsWithClones) => {
|
|
4111
|
-
const oldBindableId = original[bindingProp]?.elementId;
|
|
4112
|
-
if (oldBindableId) {
|
|
4113
|
-
if (originalElements.has(oldBindableId)) {
|
|
4114
|
-
const newBindableId = oldIdToDuplicatedId.get(oldBindableId) ?? oldBindableId;
|
|
4115
|
-
const newBindable = elementsWithClones.find(
|
|
4116
|
-
(el) => el.id === newBindableId
|
|
4117
|
-
);
|
|
4118
|
-
mutateElement(duplicate, {
|
|
4119
|
-
[bindingProp]: {
|
|
4120
|
-
...original[bindingProp],
|
|
4121
|
-
elementId: newBindableId
|
|
4122
|
-
}
|
|
4123
|
-
});
|
|
4124
|
-
mutateElement(newBindable, {
|
|
4125
|
-
boundElements: [
|
|
4126
|
-
...(newBindable.boundElements ?? []).filter(
|
|
4127
|
-
(el) => el.id !== original.id && el.id !== duplicate.id
|
|
4128
|
-
),
|
|
4129
|
-
{
|
|
4130
|
-
id: duplicate.id,
|
|
4131
|
-
type: "arrow"
|
|
4132
|
-
}
|
|
4133
|
-
]
|
|
4134
|
-
});
|
|
4135
|
-
} else {
|
|
4136
|
-
const originalBindable = elementsWithClones.find(
|
|
4137
|
-
(el) => el.id === oldBindableId
|
|
4138
|
-
);
|
|
4139
|
-
if (originalBindable) {
|
|
4140
|
-
mutateElement(duplicate, {
|
|
4141
|
-
[bindingProp]: original[bindingProp]
|
|
4142
|
-
});
|
|
4143
|
-
mutateElement(original, {
|
|
4144
|
-
[bindingProp]: null
|
|
4145
|
-
});
|
|
4146
|
-
mutateElement(originalBindable, {
|
|
4147
|
-
boundElements: [
|
|
4148
|
-
...originalBindable.boundElements?.filter(
|
|
4149
|
-
(el) => el.id !== original.id
|
|
4150
|
-
) ?? [],
|
|
4151
|
-
{
|
|
4152
|
-
id: duplicate.id,
|
|
4153
|
-
type: "arrow"
|
|
4154
|
-
}
|
|
4155
|
-
]
|
|
4156
|
-
});
|
|
4157
|
-
}
|
|
4158
|
-
}
|
|
4159
|
-
}
|
|
4160
|
-
};
|
|
4161
|
-
var fixReversedBindings = (originalElements, elementsWithClones, oldIdToDuplicatedId) => {
|
|
4162
|
-
for (const original of originalElements.values()) {
|
|
4163
|
-
const duplicate = elementsWithClones.find(
|
|
4164
|
-
(el) => el.id === oldIdToDuplicatedId.get(original.id)
|
|
4165
|
-
);
|
|
4166
|
-
if (isBindableElement(original) && isBindableElement(duplicate)) {
|
|
4167
|
-
fixReversedBindingsForBindables(
|
|
4168
|
-
original,
|
|
4169
|
-
duplicate,
|
|
4170
|
-
originalElements,
|
|
4171
|
-
elementsWithClones,
|
|
4172
|
-
oldIdToDuplicatedId
|
|
4173
|
-
);
|
|
4174
|
-
} else if (isArrowElement(original) && isArrowElement(duplicate)) {
|
|
4175
|
-
fixReversedBindingsForArrows(
|
|
4176
|
-
original,
|
|
4177
|
-
duplicate,
|
|
4178
|
-
originalElements,
|
|
4179
|
-
"startBinding",
|
|
4180
|
-
oldIdToDuplicatedId,
|
|
4181
|
-
elementsWithClones
|
|
4182
|
-
);
|
|
4183
|
-
fixReversedBindingsForArrows(
|
|
4184
|
-
original,
|
|
4185
|
-
duplicate,
|
|
4186
|
-
originalElements,
|
|
4187
|
-
"endBinding",
|
|
4188
|
-
oldIdToDuplicatedId,
|
|
4189
|
-
elementsWithClones
|
|
4190
|
-
);
|
|
4191
|
-
}
|
|
4192
|
-
}
|
|
4193
|
-
};
|
|
4194
4018
|
var fixBindingsAfterDeletion = (sceneElements, deletedElements) => {
|
|
4195
4019
|
const elements = arrayToMap(sceneElements);
|
|
4196
4020
|
for (const element of deletedElements) {
|
|
@@ -4230,10 +4054,7 @@ var maxBindingGap = (element, elementWidth, elementHeight, zoom) => {
|
|
|
4230
4054
|
);
|
|
4231
4055
|
};
|
|
4232
4056
|
var determineFocusDistance = (element, a, b) => {
|
|
4233
|
-
const center =
|
|
4234
|
-
element.x + element.width / 2,
|
|
4235
|
-
element.y + element.height / 2
|
|
4236
|
-
);
|
|
4057
|
+
const center = elementCenterPoint(element);
|
|
4237
4058
|
if (pointsEqual(a, b)) {
|
|
4238
4059
|
return 0;
|
|
4239
4060
|
}
|
|
@@ -4336,10 +4157,7 @@ var determineFocusDistance = (element, a, b) => {
|
|
|
4336
4157
|
return signedDistanceRatio;
|
|
4337
4158
|
};
|
|
4338
4159
|
var determineFocusPoint = (element, focus, adjacentPoint) => {
|
|
4339
|
-
const center =
|
|
4340
|
-
element.x + element.width / 2,
|
|
4341
|
-
element.y + element.height / 2
|
|
4342
|
-
);
|
|
4160
|
+
const center = elementCenterPoint(element);
|
|
4343
4161
|
if (focus === 0) {
|
|
4344
4162
|
return center;
|
|
4345
4163
|
}
|
|
@@ -4617,10 +4435,7 @@ var getGlobalFixedPointForBindableElement = (fixedPointRatio, element) => {
|
|
|
4617
4435
|
element.x + element.width * fixedX,
|
|
4618
4436
|
element.y + element.height * fixedY
|
|
4619
4437
|
),
|
|
4620
|
-
|
|
4621
|
-
element.x + element.width / 2,
|
|
4622
|
-
element.y + element.height / 2
|
|
4623
|
-
),
|
|
4438
|
+
elementCenterPoint(element),
|
|
4624
4439
|
element.angle
|
|
4625
4440
|
);
|
|
4626
4441
|
};
|
|
@@ -6668,13 +6483,19 @@ var satisfiesWordInvariant = (word) => {
|
|
|
6668
6483
|
// ../element/src/textElement.ts
|
|
6669
6484
|
var redrawTextBoundingBox = (textElement, container, elementsMap, informMutation = true) => {
|
|
6670
6485
|
let maxWidth = void 0;
|
|
6486
|
+
if (!isProdEnv()) {
|
|
6487
|
+
invariant(
|
|
6488
|
+
!container || !isArrowElement(container) || textElement.angle === 0,
|
|
6489
|
+
"text element angle must be 0 if bound to arrow container"
|
|
6490
|
+
);
|
|
6491
|
+
}
|
|
6671
6492
|
const boundTextUpdates = {
|
|
6672
6493
|
x: textElement.x,
|
|
6673
6494
|
y: textElement.y,
|
|
6674
6495
|
text: textElement.text,
|
|
6675
6496
|
width: textElement.width,
|
|
6676
6497
|
height: textElement.height,
|
|
6677
|
-
angle: container
|
|
6498
|
+
angle: container ? isArrowElement(container) ? 0 : container.angle : textElement.angle
|
|
6678
6499
|
};
|
|
6679
6500
|
boundTextUpdates.text = textElement.text;
|
|
6680
6501
|
if (container || !textElement.autoResize) {
|
|
@@ -6892,7 +6713,10 @@ var getContainerCoords = (container) => {
|
|
|
6892
6713
|
};
|
|
6893
6714
|
};
|
|
6894
6715
|
var getTextElementAngle = (textElement, container) => {
|
|
6895
|
-
if (
|
|
6716
|
+
if (isArrowElement(container)) {
|
|
6717
|
+
return 0;
|
|
6718
|
+
}
|
|
6719
|
+
if (!container) {
|
|
6896
6720
|
return textElement.angle;
|
|
6897
6721
|
}
|
|
6898
6722
|
return container.angle;
|
|
@@ -7140,23 +6964,21 @@ var elementsOverlappingBBox = ({
|
|
|
7140
6964
|
};
|
|
7141
6965
|
|
|
7142
6966
|
// ../element/src/frame.ts
|
|
7143
|
-
var bindElementsToFramesAfterDuplication = (nextElements,
|
|
6967
|
+
var bindElementsToFramesAfterDuplication = (nextElements, origElements, origIdToDuplicateId) => {
|
|
7144
6968
|
const nextElementMap = arrayToMap(nextElements);
|
|
7145
|
-
for (const element of
|
|
6969
|
+
for (const element of origElements) {
|
|
7146
6970
|
if (element.frameId) {
|
|
7147
|
-
const nextElementId =
|
|
7148
|
-
const nextFrameId =
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
);
|
|
7159
|
-
}
|
|
6971
|
+
const nextElementId = origIdToDuplicateId.get(element.id);
|
|
6972
|
+
const nextFrameId = origIdToDuplicateId.get(element.frameId);
|
|
6973
|
+
const nextElement = nextElementId && nextElementMap.get(nextElementId);
|
|
6974
|
+
if (nextElement) {
|
|
6975
|
+
mutateElement(
|
|
6976
|
+
nextElement,
|
|
6977
|
+
{
|
|
6978
|
+
frameId: nextFrameId ?? null
|
|
6979
|
+
},
|
|
6980
|
+
false
|
|
6981
|
+
);
|
|
7160
6982
|
}
|
|
7161
6983
|
}
|
|
7162
6984
|
}
|
|
@@ -7766,6 +7588,41 @@ var makeNextSelectedElementIds = (nextSelectedElementIds, prevState) => {
|
|
|
7766
7588
|
}
|
|
7767
7589
|
return nextSelectedElementIds;
|
|
7768
7590
|
};
|
|
7591
|
+
var _getLinearElementEditor = (targetElements) => {
|
|
7592
|
+
const linears = targetElements.filter(isLinearElement);
|
|
7593
|
+
if (linears.length === 1) {
|
|
7594
|
+
const linear = linears[0];
|
|
7595
|
+
const boundElements = linear.boundElements?.map((def) => def.id) ?? [];
|
|
7596
|
+
const onlySingleLinearSelected = targetElements.every(
|
|
7597
|
+
(el) => el.id === linear.id || boundElements.includes(el.id)
|
|
7598
|
+
);
|
|
7599
|
+
if (onlySingleLinearSelected) {
|
|
7600
|
+
return new LinearElementEditor(linear);
|
|
7601
|
+
}
|
|
7602
|
+
}
|
|
7603
|
+
return null;
|
|
7604
|
+
};
|
|
7605
|
+
var getSelectionStateForElements = (targetElements, allElements, appState) => {
|
|
7606
|
+
return {
|
|
7607
|
+
selectedLinearElement: _getLinearElementEditor(targetElements),
|
|
7608
|
+
...selectGroupsForSelectedElements(
|
|
7609
|
+
{
|
|
7610
|
+
editingGroupId: appState.editingGroupId,
|
|
7611
|
+
selectedElementIds: excludeElementsInFramesFromSelection(
|
|
7612
|
+
targetElements
|
|
7613
|
+
).reduce((acc, element) => {
|
|
7614
|
+
if (!isBoundToContainer(element)) {
|
|
7615
|
+
acc[element.id] = true;
|
|
7616
|
+
}
|
|
7617
|
+
return acc;
|
|
7618
|
+
}, {})
|
|
7619
|
+
},
|
|
7620
|
+
allElements,
|
|
7621
|
+
appState,
|
|
7622
|
+
null
|
|
7623
|
+
)
|
|
7624
|
+
};
|
|
7625
|
+
};
|
|
7769
7626
|
|
|
7770
7627
|
// ../element/src/groups.ts
|
|
7771
7628
|
var selectGroup = (groupId, appState, elements) => {
|
|
@@ -9932,7 +9789,7 @@ var aabbForElement = (element, offset) => {
|
|
|
9932
9789
|
midX: element.x + element.width / 2,
|
|
9933
9790
|
midY: element.y + element.height / 2
|
|
9934
9791
|
};
|
|
9935
|
-
const center =
|
|
9792
|
+
const center = elementCenterPoint(element);
|
|
9936
9793
|
const [topLeftX, topLeftY] = pointRotateRads(
|
|
9937
9794
|
pointFrom(bbox.minX, bbox.minY),
|
|
9938
9795
|
center,
|
|
@@ -10017,7 +9874,7 @@ var cropElement = (element, transformHandle, naturalWidth, naturalHeight, pointe
|
|
|
10017
9874
|
const croppedTop = (element.crop?.y ?? 0) / naturalHeightToUncropped;
|
|
10018
9875
|
const rotatedPointer = pointRotateRads(
|
|
10019
9876
|
pointFrom(pointerX, pointerY),
|
|
10020
|
-
|
|
9877
|
+
elementCenterPoint(element),
|
|
10021
9878
|
-element.angle
|
|
10022
9879
|
);
|
|
10023
9880
|
pointerX = rotatedPointer[0];
|
|
@@ -17638,6 +17495,7 @@ var repairContainerElement = (container, elementsMap) => {
|
|
|
17638
17495
|
};
|
|
17639
17496
|
var repairBoundElement = (boundElement, elementsMap) => {
|
|
17640
17497
|
const container = boundElement.containerId ? elementsMap.get(boundElement.containerId) : null;
|
|
17498
|
+
boundElement.angle = isArrowElement(container) ? 0 : container?.angle ?? 0;
|
|
17641
17499
|
if (!container) {
|
|
17642
17500
|
boundElement.containerId = null;
|
|
17643
17501
|
return;
|
|
@@ -17883,7 +17741,7 @@ var parseFileContents = async (blob) => {
|
|
|
17883
17741
|
let contents;
|
|
17884
17742
|
if (blob.type === MIME_TYPES.png) {
|
|
17885
17743
|
try {
|
|
17886
|
-
return await (await import("./data/image-
|
|
17744
|
+
return await (await import("./data/image-JN3Y4CVN.js")).decodePngMetadata(blob);
|
|
17887
17745
|
} catch (error) {
|
|
17888
17746
|
if (error.message === "INVALID") {
|
|
17889
17747
|
throw new ImageSceneDataError(
|
|
@@ -18350,6 +18208,7 @@ export {
|
|
|
18350
18208
|
DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT,
|
|
18351
18209
|
MAX_ALLOWED_FILE_BYTES,
|
|
18352
18210
|
SVG_NS,
|
|
18211
|
+
SVG_DOCUMENT_PREAMBLE,
|
|
18353
18212
|
VERSIONS,
|
|
18354
18213
|
BOUND_TEXT_PADDING,
|
|
18355
18214
|
VERTICAL_ALIGN,
|
|
@@ -18491,6 +18350,7 @@ export {
|
|
|
18491
18350
|
isUsingAdaptiveRadius,
|
|
18492
18351
|
canApplyRoundnessTypeToElement,
|
|
18493
18352
|
getDefaultRoundnessTypeForElement,
|
|
18353
|
+
shouldTestInside,
|
|
18494
18354
|
hitElementItself,
|
|
18495
18355
|
hitElementBoundingBox,
|
|
18496
18356
|
hitElementBoundingBoxOnly,
|
|
@@ -18545,7 +18405,6 @@ export {
|
|
|
18545
18405
|
bindPointToSnapToElementOutline,
|
|
18546
18406
|
calculateFixedPointForElbowArrowBinding,
|
|
18547
18407
|
fixDuplicatedBindingsAfterDuplication,
|
|
18548
|
-
fixReversedBindings,
|
|
18549
18408
|
fixBindingsAfterDeletion,
|
|
18550
18409
|
maxBindingGap,
|
|
18551
18410
|
bindingProperties,
|
|
@@ -18599,6 +18458,7 @@ export {
|
|
|
18599
18458
|
getSelectedElements,
|
|
18600
18459
|
getTargetElements,
|
|
18601
18460
|
makeNextSelectedElementIds,
|
|
18461
|
+
getSelectionStateForElements,
|
|
18602
18462
|
selectGroup,
|
|
18603
18463
|
selectGroupsForSelectedElements,
|
|
18604
18464
|
isSelectedViaGroup,
|
|
@@ -18736,4 +18596,4 @@ export {
|
|
|
18736
18596
|
createFile,
|
|
18737
18597
|
normalizeFile
|
|
18738
18598
|
};
|
|
18739
|
-
//# sourceMappingURL=chunk-
|
|
18599
|
+
//# sourceMappingURL=chunk-GBJ7S76A.js.map
|