@excalidraw/element 0.18.0-9036812b6 → 0.18.0-91c7748
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/index.js +843 -514
- package/dist/dev/index.js.map +4 -4
- package/dist/prod/index.js +14 -14
- package/dist/types/common/src/constants.d.ts +19 -4
- package/dist/types/common/src/utils.d.ts +1 -0
- package/dist/types/element/src/Scene.d.ts +6 -2
- package/dist/types/element/src/bounds.d.ts +1 -1
- package/dist/types/element/src/delta.d.ts +6 -3
- package/dist/types/element/src/index.d.ts +1 -0
- package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
- package/dist/types/element/src/renderElement.d.ts +4 -1
- package/dist/types/element/src/store.d.ts +6 -1
- package/dist/types/element/src/textElement.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +6 -3
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +29 -15
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +12 -6
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +6 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionExport.d.ts +18 -9
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionFrame.d.ts +8 -4
- package/dist/types/excalidraw/actions/actionGroup.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +3 -2
- package/dist/types/excalidraw/actions/actionLink.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +6 -3
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +4 -2
- package/dist/types/excalidraw/actions/actionProperties.d.ts +48 -24
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionStyles.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +2 -1
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +2 -1
- package/dist/types/excalidraw/actions/index.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +1 -1
- package/dist/types/excalidraw/appState.d.ts +1 -0
- package/dist/types/excalidraw/clipboard.d.ts +64 -1
- package/dist/types/excalidraw/components/Actions.d.ts +8 -1
- package/dist/types/excalidraw/components/App.d.ts +11 -8
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +2 -1
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +2 -1
- package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
- package/dist/types/excalidraw/components/icons.d.ts +6 -0
- package/dist/types/excalidraw/components/shapes.d.ts +129 -1
- package/dist/types/excalidraw/data/blob.d.ts +1 -5
- package/dist/types/excalidraw/data/restore.d.ts +6 -1
- package/dist/types/excalidraw/data/types.d.ts +4 -1
- package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
- package/dist/types/excalidraw/index.d.ts +1 -1
- package/dist/types/excalidraw/types.d.ts +6 -1
- package/dist/types/math/src/segment.d.ts +1 -0
- package/package.json +3 -3
package/dist/dev/index.js
CHANGED
|
@@ -2261,17 +2261,17 @@ var rough_default = {
|
|
|
2261
2261
|
// src/bounds.ts
|
|
2262
2262
|
import {
|
|
2263
2263
|
arrayToMap as arrayToMap6,
|
|
2264
|
-
invariant as
|
|
2264
|
+
invariant as invariant8,
|
|
2265
2265
|
rescalePoints,
|
|
2266
2266
|
sizeOf
|
|
2267
2267
|
} from "@excalidraw/common";
|
|
2268
2268
|
import {
|
|
2269
2269
|
degreesToRadians,
|
|
2270
|
-
lineSegment as
|
|
2270
|
+
lineSegment as lineSegment6,
|
|
2271
2271
|
pointDistance as pointDistance7,
|
|
2272
|
-
pointFrom as
|
|
2272
|
+
pointFrom as pointFrom14,
|
|
2273
2273
|
pointFromArray as pointFromArray3,
|
|
2274
|
-
pointRotateRads as
|
|
2274
|
+
pointRotateRads as pointRotateRads12
|
|
2275
2275
|
} from "@excalidraw/math";
|
|
2276
2276
|
|
|
2277
2277
|
// ../utils/src/shape.ts
|
|
@@ -2448,9 +2448,9 @@ var getClosedCurveShape = (element, roughShape, startingPoint = pointFrom(0, 0),
|
|
|
2448
2448
|
// src/shape.ts
|
|
2449
2449
|
init_define_import_meta_env();
|
|
2450
2450
|
import {
|
|
2451
|
-
pointFrom as
|
|
2451
|
+
pointFrom as pointFrom13,
|
|
2452
2452
|
pointDistance as pointDistance6,
|
|
2453
|
-
pointRotateRads as
|
|
2453
|
+
pointRotateRads as pointRotateRads11
|
|
2454
2454
|
} from "@excalidraw/math";
|
|
2455
2455
|
import {
|
|
2456
2456
|
ROUGHNESS,
|
|
@@ -2627,7 +2627,12 @@ function ae(e, t = {}) {
|
|
|
2627
2627
|
}
|
|
2628
2628
|
|
|
2629
2629
|
// src/renderElement.ts
|
|
2630
|
-
import {
|
|
2630
|
+
import {
|
|
2631
|
+
isRightAngleRads,
|
|
2632
|
+
lineSegment as lineSegment5,
|
|
2633
|
+
pointFrom as pointFrom12,
|
|
2634
|
+
pointRotateRads as pointRotateRads10
|
|
2635
|
+
} from "@excalidraw/math";
|
|
2631
2636
|
import {
|
|
2632
2637
|
BOUND_TEXT_PADDING as BOUND_TEXT_PADDING3,
|
|
2633
2638
|
DEFAULT_REDUCED_GLOBAL_ALPHA,
|
|
@@ -2638,7 +2643,8 @@ import {
|
|
|
2638
2643
|
distance as distance2,
|
|
2639
2644
|
getFontString as getFontString3,
|
|
2640
2645
|
isRTL,
|
|
2641
|
-
getVerticalOffset
|
|
2646
|
+
getVerticalOffset,
|
|
2647
|
+
invariant as invariant7
|
|
2642
2648
|
} from "@excalidraw/common";
|
|
2643
2649
|
|
|
2644
2650
|
// src/cropElement.ts
|
|
@@ -3103,8 +3109,8 @@ var getFlipAdjustedCropPosition = (element, natural = false) => {
|
|
|
3103
3109
|
init_define_import_meta_env();
|
|
3104
3110
|
import {
|
|
3105
3111
|
pointCenter as pointCenter2,
|
|
3106
|
-
pointFrom as
|
|
3107
|
-
pointRotateRads as
|
|
3112
|
+
pointFrom as pointFrom9,
|
|
3113
|
+
pointRotateRads as pointRotateRads8,
|
|
3108
3114
|
pointsEqual as pointsEqual6,
|
|
3109
3115
|
pointDistance as pointDistance5,
|
|
3110
3116
|
vectorFromPoint as vectorFromPoint7,
|
|
@@ -3138,8 +3144,8 @@ import {
|
|
|
3138
3144
|
} from "@excalidraw/common";
|
|
3139
3145
|
import {
|
|
3140
3146
|
lineSegment as lineSegment4,
|
|
3141
|
-
pointFrom as
|
|
3142
|
-
pointRotateRads as
|
|
3147
|
+
pointFrom as pointFrom8,
|
|
3148
|
+
pointRotateRads as pointRotateRads7,
|
|
3143
3149
|
vectorFromPoint as vectorFromPoint6,
|
|
3144
3150
|
pointDistanceSq,
|
|
3145
3151
|
clamp as clamp3,
|
|
@@ -3161,9 +3167,9 @@ import {
|
|
|
3161
3167
|
isPointWithinBounds,
|
|
3162
3168
|
lineSegment as lineSegment3,
|
|
3163
3169
|
lineSegmentIntersectionPoints,
|
|
3164
|
-
pointFrom as
|
|
3170
|
+
pointFrom as pointFrom5,
|
|
3165
3171
|
pointFromVector as pointFromVector3,
|
|
3166
|
-
pointRotateRads as
|
|
3172
|
+
pointRotateRads as pointRotateRads5,
|
|
3167
3173
|
pointsEqual as pointsEqual2,
|
|
3168
3174
|
vectorFromPoint as vectorFromPoint3,
|
|
3169
3175
|
vectorNormalize as vectorNormalize2,
|
|
@@ -3711,6 +3717,7 @@ import {
|
|
|
3711
3717
|
isProdEnv,
|
|
3712
3718
|
invariant as invariant2
|
|
3713
3719
|
} from "@excalidraw/common";
|
|
3720
|
+
import { pointFrom as pointFrom4, pointRotateRads as pointRotateRads3 } from "@excalidraw/math";
|
|
3714
3721
|
|
|
3715
3722
|
// src/containerCache.ts
|
|
3716
3723
|
init_define_import_meta_env();
|
|
@@ -4390,6 +4397,22 @@ var computeBoundTextPosition = (container, boundTextElement, elementsMap) => {
|
|
|
4390
4397
|
} else {
|
|
4391
4398
|
x = containerCoords.x + (maxContainerWidth / 2 - boundTextElement.width / 2);
|
|
4392
4399
|
}
|
|
4400
|
+
const angle = container.angle ?? 0;
|
|
4401
|
+
if (angle !== 0) {
|
|
4402
|
+
const contentCenter = pointFrom4(
|
|
4403
|
+
containerCoords.x + maxContainerWidth / 2,
|
|
4404
|
+
containerCoords.y + maxContainerHeight / 2
|
|
4405
|
+
);
|
|
4406
|
+
const textCenter = pointFrom4(
|
|
4407
|
+
x + boundTextElement.width / 2,
|
|
4408
|
+
y + boundTextElement.height / 2
|
|
4409
|
+
);
|
|
4410
|
+
const [rx, ry] = pointRotateRads3(textCenter, contentCenter, angle);
|
|
4411
|
+
return {
|
|
4412
|
+
x: rx - boundTextElement.width / 2,
|
|
4413
|
+
y: ry - boundTextElement.height / 2
|
|
4414
|
+
};
|
|
4415
|
+
}
|
|
4393
4416
|
return { x, y };
|
|
4394
4417
|
};
|
|
4395
4418
|
var getBoundTextElementId = (container) => {
|
|
@@ -4573,7 +4596,7 @@ init_define_import_meta_env();
|
|
|
4573
4596
|
import {
|
|
4574
4597
|
curvePointDistance,
|
|
4575
4598
|
distanceToLineSegment,
|
|
4576
|
-
pointRotateRads as
|
|
4599
|
+
pointRotateRads as pointRotateRads4
|
|
4577
4600
|
} from "@excalidraw/math";
|
|
4578
4601
|
import { ellipse as ellipse2, ellipseDistanceFromPoint } from "@excalidraw/math/ellipse";
|
|
4579
4602
|
var distanceToElement = (element, elementsMap, p) => {
|
|
@@ -4599,7 +4622,7 @@ var distanceToElement = (element, elementsMap, p) => {
|
|
|
4599
4622
|
};
|
|
4600
4623
|
var distanceToRectanguloidElement = (element, elementsMap, p) => {
|
|
4601
4624
|
const center = elementCenterPoint(element, elementsMap);
|
|
4602
|
-
const rotatedPoint =
|
|
4625
|
+
const rotatedPoint = pointRotateRads4(p, center, -element.angle);
|
|
4603
4626
|
const [sides, corners] = deconstructRectanguloidElement(element);
|
|
4604
4627
|
return Math.min(
|
|
4605
4628
|
...sides.map((s) => distanceToLineSegment(rotatedPoint, s)),
|
|
@@ -4608,7 +4631,7 @@ var distanceToRectanguloidElement = (element, elementsMap, p) => {
|
|
|
4608
4631
|
};
|
|
4609
4632
|
var distanceToDiamondElement = (element, elementsMap, p) => {
|
|
4610
4633
|
const center = elementCenterPoint(element, elementsMap);
|
|
4611
|
-
const rotatedPoint =
|
|
4634
|
+
const rotatedPoint = pointRotateRads4(p, center, -element.angle);
|
|
4612
4635
|
const [sides, curves] = deconstructDiamondElement(element);
|
|
4613
4636
|
return Math.min(
|
|
4614
4637
|
...sides.map((s) => distanceToLineSegment(rotatedPoint, s)),
|
|
@@ -4619,7 +4642,7 @@ var distanceToEllipseElement = (element, elementsMap, p) => {
|
|
|
4619
4642
|
const center = elementCenterPoint(element, elementsMap);
|
|
4620
4643
|
return ellipseDistanceFromPoint(
|
|
4621
4644
|
// Instead of rotating the ellipse, rotate the point to the inverse angle
|
|
4622
|
-
|
|
4645
|
+
pointRotateRads4(p, center, -element.angle),
|
|
4623
4646
|
ellipse2(center, element.width / 2, element.height / 2)
|
|
4624
4647
|
);
|
|
4625
4648
|
};
|
|
@@ -4653,22 +4676,22 @@ var hitElementItself = ({
|
|
|
4653
4676
|
frameNameBound = null
|
|
4654
4677
|
}) => {
|
|
4655
4678
|
const hitFrameName = frameNameBound ? isPointWithinBounds(
|
|
4656
|
-
|
|
4679
|
+
pointFrom5(frameNameBound.x - threshold, frameNameBound.y - threshold),
|
|
4657
4680
|
point,
|
|
4658
|
-
|
|
4681
|
+
pointFrom5(
|
|
4659
4682
|
frameNameBound.x + frameNameBound.width + threshold,
|
|
4660
4683
|
frameNameBound.y + frameNameBound.height + threshold
|
|
4661
4684
|
)
|
|
4662
4685
|
) : false;
|
|
4663
4686
|
const bounds = getElementBounds(element, elementsMap, true);
|
|
4664
4687
|
const hitBounds = isPointWithinBounds(
|
|
4665
|
-
|
|
4666
|
-
|
|
4688
|
+
pointFrom5(bounds[0] - threshold, bounds[1] - threshold),
|
|
4689
|
+
pointRotateRads5(
|
|
4667
4690
|
point,
|
|
4668
4691
|
getCenterForBounds(bounds),
|
|
4669
4692
|
-element.angle
|
|
4670
4693
|
),
|
|
4671
|
-
|
|
4694
|
+
pointFrom5(bounds[2] + threshold, bounds[3] + threshold)
|
|
4672
4695
|
);
|
|
4673
4696
|
if (!hitBounds && !hitFrameName) {
|
|
4674
4697
|
return false;
|
|
@@ -4686,7 +4709,7 @@ var hitElementBoundingBox = (point, element, elementsMap, tolerance = 0) => {
|
|
|
4686
4709
|
y1 -= tolerance;
|
|
4687
4710
|
x2 += tolerance;
|
|
4688
4711
|
y2 += tolerance;
|
|
4689
|
-
return isPointWithinBounds(
|
|
4712
|
+
return isPointWithinBounds(pointFrom5(x1, y1), point, pointFrom5(x2, y2));
|
|
4690
4713
|
};
|
|
4691
4714
|
var hitElementBoundingBoxOnly = (hitArgs, elementsMap) => !hitElementItself(hitArgs) && // bound text is considered part of the element (even if it's outside the bounding box)
|
|
4692
4715
|
!hitElementBoundText(hitArgs.point, hitArgs.element, elementsMap) && hitElementBoundingBox(hitArgs.point, hitArgs.element, elementsMap);
|
|
@@ -4770,7 +4793,7 @@ var curveIntersections = (curves, segment, intersections, center, angle, onlyFir
|
|
|
4770
4793
|
const hits = curveIntersectLineSegment(c, segment);
|
|
4771
4794
|
if (hits.length > 0) {
|
|
4772
4795
|
for (const j of hits) {
|
|
4773
|
-
intersections.push(
|
|
4796
|
+
intersections.push(pointRotateRads5(j, center, angle));
|
|
4774
4797
|
}
|
|
4775
4798
|
if (onlyFirst) {
|
|
4776
4799
|
return intersections;
|
|
@@ -4783,7 +4806,7 @@ var lineIntersections = (lines, segment, intersections, center, angle, onlyFirst
|
|
|
4783
4806
|
for (const l2 of lines) {
|
|
4784
4807
|
const intersection = lineSegmentIntersectionPoints(l2, segment);
|
|
4785
4808
|
if (intersection) {
|
|
4786
|
-
intersections.push(
|
|
4809
|
+
intersections.push(pointRotateRads5(intersection, center, angle));
|
|
4787
4810
|
if (onlyFirst) {
|
|
4788
4811
|
return intersections;
|
|
4789
4812
|
}
|
|
@@ -4826,12 +4849,12 @@ var intersectLinearOrFreeDrawWithLineSegment = (element, segment, onlyFirst = fa
|
|
|
4826
4849
|
};
|
|
4827
4850
|
var intersectRectanguloidWithLineSegment = (element, elementsMap, segment, offset = 0, onlyFirst = false) => {
|
|
4828
4851
|
const center = elementCenterPoint(element, elementsMap);
|
|
4829
|
-
const rotatedA =
|
|
4852
|
+
const rotatedA = pointRotateRads5(
|
|
4830
4853
|
segment[0],
|
|
4831
4854
|
center,
|
|
4832
4855
|
-element.angle
|
|
4833
4856
|
);
|
|
4834
|
-
const rotatedB =
|
|
4857
|
+
const rotatedB = pointRotateRads5(
|
|
4835
4858
|
segment[1],
|
|
4836
4859
|
center,
|
|
4837
4860
|
-element.angle
|
|
@@ -4862,8 +4885,8 @@ var intersectRectanguloidWithLineSegment = (element, elementsMap, segment, offse
|
|
|
4862
4885
|
};
|
|
4863
4886
|
var intersectDiamondWithLineSegment = (element, elementsMap, l2, offset = 0, onlyFirst = false) => {
|
|
4864
4887
|
const center = elementCenterPoint(element, elementsMap);
|
|
4865
|
-
const rotatedA =
|
|
4866
|
-
const rotatedB =
|
|
4888
|
+
const rotatedA = pointRotateRads5(l2[0], center, -element.angle);
|
|
4889
|
+
const rotatedB = pointRotateRads5(l2[1], center, -element.angle);
|
|
4867
4890
|
const rotatedIntersector = lineSegment3(rotatedA, rotatedB);
|
|
4868
4891
|
const [sides, corners] = deconstructDiamondElement(element, offset);
|
|
4869
4892
|
const intersections = [];
|
|
@@ -4890,12 +4913,12 @@ var intersectDiamondWithLineSegment = (element, elementsMap, l2, offset = 0, onl
|
|
|
4890
4913
|
};
|
|
4891
4914
|
var intersectEllipseWithLineSegment = (element, elementsMap, l2, offset = 0) => {
|
|
4892
4915
|
const center = elementCenterPoint(element, elementsMap);
|
|
4893
|
-
const rotatedA =
|
|
4894
|
-
const rotatedB =
|
|
4916
|
+
const rotatedA = pointRotateRads5(l2[0], center, -element.angle);
|
|
4917
|
+
const rotatedB = pointRotateRads5(l2[1], center, -element.angle);
|
|
4895
4918
|
return ellipseSegmentInterceptPoints(
|
|
4896
4919
|
ellipse3(center, element.width / 2 + offset, element.height / 2 + offset),
|
|
4897
4920
|
lineSegment3(rotatedA, rotatedB)
|
|
4898
|
-
).map((p) =>
|
|
4921
|
+
).map((p) => pointRotateRads5(p, center, element.angle));
|
|
4899
4922
|
};
|
|
4900
4923
|
var isPointOnElementOutline = (point, element, elementsMap, tolerance = 1) => distanceToElement(element, elementsMap, point) <= tolerance;
|
|
4901
4924
|
var isPointInElement = (point, element, elementsMap) => {
|
|
@@ -4903,10 +4926,10 @@ var isPointInElement = (point, element, elementsMap) => {
|
|
|
4903
4926
|
return false;
|
|
4904
4927
|
}
|
|
4905
4928
|
const [x1, y1, x2, y2] = getElementBounds(element, elementsMap);
|
|
4906
|
-
if (!isPointWithinBounds(
|
|
4929
|
+
if (!isPointWithinBounds(pointFrom5(x1, y1), point, pointFrom5(x2, y2))) {
|
|
4907
4930
|
return false;
|
|
4908
4931
|
}
|
|
4909
|
-
const center =
|
|
4932
|
+
const center = pointFrom5((x1 + x2) / 2, (y1 + y2) / 2);
|
|
4910
4933
|
const otherPoint = pointFromVector3(
|
|
4911
4934
|
vectorScale3(
|
|
4912
4935
|
vectorNormalize2(vectorFromPoint3(point, center, 0.1)),
|
|
@@ -4927,9 +4950,9 @@ var isPointInElement = (point, element, elementsMap) => {
|
|
|
4927
4950
|
init_define_import_meta_env();
|
|
4928
4951
|
import { invariant as invariant3, isDevEnv as isDevEnv2, isTestEnv as isTestEnv3 } from "@excalidraw/common";
|
|
4929
4952
|
import {
|
|
4930
|
-
pointFrom as
|
|
4953
|
+
pointFrom as pointFrom6,
|
|
4931
4954
|
pointFromVector as pointFromVector4,
|
|
4932
|
-
pointRotateRads as
|
|
4955
|
+
pointRotateRads as pointRotateRads6,
|
|
4933
4956
|
pointScaleFromOrigin,
|
|
4934
4957
|
pointsEqual as pointsEqual3,
|
|
4935
4958
|
triangleIncludesPoint,
|
|
@@ -4975,8 +4998,8 @@ var headingForPointFromDiamondElement = (element, aabb, point) => {
|
|
|
4975
4998
|
const top = pointFromVector4(
|
|
4976
4999
|
vectorScale4(
|
|
4977
5000
|
vectorFromPoint4(
|
|
4978
|
-
|
|
4979
|
-
|
|
5001
|
+
pointRotateRads6(
|
|
5002
|
+
pointFrom6(element.x + element.width / 2, element.y),
|
|
4980
5003
|
midPoint,
|
|
4981
5004
|
element.angle
|
|
4982
5005
|
),
|
|
@@ -4989,8 +5012,8 @@ var headingForPointFromDiamondElement = (element, aabb, point) => {
|
|
|
4989
5012
|
const right = pointFromVector4(
|
|
4990
5013
|
vectorScale4(
|
|
4991
5014
|
vectorFromPoint4(
|
|
4992
|
-
|
|
4993
|
-
|
|
5015
|
+
pointRotateRads6(
|
|
5016
|
+
pointFrom6(
|
|
4994
5017
|
element.x + element.width,
|
|
4995
5018
|
element.y + element.height / 2
|
|
4996
5019
|
),
|
|
@@ -5006,8 +5029,8 @@ var headingForPointFromDiamondElement = (element, aabb, point) => {
|
|
|
5006
5029
|
const bottom = pointFromVector4(
|
|
5007
5030
|
vectorScale4(
|
|
5008
5031
|
vectorFromPoint4(
|
|
5009
|
-
|
|
5010
|
-
|
|
5032
|
+
pointRotateRads6(
|
|
5033
|
+
pointFrom6(
|
|
5011
5034
|
element.x + element.width / 2,
|
|
5012
5035
|
element.y + element.height
|
|
5013
5036
|
),
|
|
@@ -5023,8 +5046,8 @@ var headingForPointFromDiamondElement = (element, aabb, point) => {
|
|
|
5023
5046
|
const left = pointFromVector4(
|
|
5024
5047
|
vectorScale4(
|
|
5025
5048
|
vectorFromPoint4(
|
|
5026
|
-
|
|
5027
|
-
|
|
5049
|
+
pointRotateRads6(
|
|
5050
|
+
pointFrom6(element.x, element.y + element.height / 2),
|
|
5028
5051
|
midPoint,
|
|
5029
5052
|
element.angle
|
|
5030
5053
|
),
|
|
@@ -5090,22 +5113,22 @@ var headingForPointFromElement = (element, aabb, p) => {
|
|
|
5090
5113
|
return headingForPointFromDiamondElement(element, aabb, p);
|
|
5091
5114
|
}
|
|
5092
5115
|
const topLeft = pointScaleFromOrigin(
|
|
5093
|
-
|
|
5116
|
+
pointFrom6(aabb[0], aabb[1]),
|
|
5094
5117
|
midPoint,
|
|
5095
5118
|
SEARCH_CONE_MULTIPLIER
|
|
5096
5119
|
);
|
|
5097
5120
|
const topRight = pointScaleFromOrigin(
|
|
5098
|
-
|
|
5121
|
+
pointFrom6(aabb[2], aabb[1]),
|
|
5099
5122
|
midPoint,
|
|
5100
5123
|
SEARCH_CONE_MULTIPLIER
|
|
5101
5124
|
);
|
|
5102
5125
|
const bottomLeft = pointScaleFromOrigin(
|
|
5103
|
-
|
|
5126
|
+
pointFrom6(aabb[0], aabb[3]),
|
|
5104
5127
|
midPoint,
|
|
5105
5128
|
SEARCH_CONE_MULTIPLIER
|
|
5106
5129
|
);
|
|
5107
5130
|
const bottomRight = pointScaleFromOrigin(
|
|
5108
|
-
|
|
5131
|
+
pointFrom6(aabb[2], aabb[3]),
|
|
5109
5132
|
midPoint,
|
|
5110
5133
|
SEARCH_CONE_MULTIPLIER
|
|
5111
5134
|
);
|
|
@@ -5138,7 +5161,7 @@ init_define_import_meta_env();
|
|
|
5138
5161
|
import {
|
|
5139
5162
|
clamp as clamp2,
|
|
5140
5163
|
pointDistance as pointDistance3,
|
|
5141
|
-
pointFrom as
|
|
5164
|
+
pointFrom as pointFrom7,
|
|
5142
5165
|
pointScaleFromOrigin as pointScaleFromOrigin2,
|
|
5143
5166
|
pointsEqual as pointsEqual4,
|
|
5144
5167
|
pointTranslate,
|
|
@@ -5162,7 +5185,7 @@ var handleSegmentRenormalization = (arrow, elementsMap) => {
|
|
|
5162
5185
|
const nextFixedSegments = arrow.fixedSegments ? arrow.fixedSegments.slice() : null;
|
|
5163
5186
|
if (nextFixedSegments) {
|
|
5164
5187
|
const _nextPoints = [];
|
|
5165
|
-
arrow.points.map((p) =>
|
|
5188
|
+
arrow.points.map((p) => pointFrom7(arrow.x + p[0], arrow.y + p[1])).forEach((p, i, points) => {
|
|
5166
5189
|
if (i < 2) {
|
|
5167
5190
|
return _nextPoints.push(p);
|
|
5168
5191
|
}
|
|
@@ -5180,7 +5203,7 @@ var handleSegmentRenormalization = (arrow, elementsMap) => {
|
|
|
5180
5203
|
) ?? -1;
|
|
5181
5204
|
const segmentIdx = nextFixedSegments?.findIndex((segment) => segment.index === i) ?? -1;
|
|
5182
5205
|
if (segmentIdx !== -1) {
|
|
5183
|
-
nextFixedSegments[segmentIdx].start =
|
|
5206
|
+
nextFixedSegments[segmentIdx].start = pointFrom7(
|
|
5184
5207
|
points[i - 2][0] - arrow.x,
|
|
5185
5208
|
points[i - 2][1] - arrow.y
|
|
5186
5209
|
);
|
|
@@ -5222,7 +5245,7 @@ var handleSegmentRenormalization = (arrow, elementsMap) => {
|
|
|
5222
5245
|
});
|
|
5223
5246
|
const isHorizontal = headingForPointIsHorizontal(p, points[i - 1]);
|
|
5224
5247
|
return nextPoints.push(
|
|
5225
|
-
|
|
5248
|
+
pointFrom7(
|
|
5226
5249
|
!isHorizontal ? points[i - 2][0] : p[0],
|
|
5227
5250
|
isHorizontal ? points[i - 2][1] : p[1]
|
|
5228
5251
|
)
|
|
@@ -5243,7 +5266,7 @@ var handleSegmentRenormalization = (arrow, elementsMap) => {
|
|
|
5243
5266
|
arrow,
|
|
5244
5267
|
elementsMap,
|
|
5245
5268
|
nextPoints.map(
|
|
5246
|
-
(p) =>
|
|
5269
|
+
(p) => pointFrom7(p[0] - arrow.x, p[1] - arrow.y)
|
|
5247
5270
|
)
|
|
5248
5271
|
)
|
|
5249
5272
|
) ?? []
|
|
@@ -5312,8 +5335,8 @@ var handleSegmentRelease = (arrow, fixedSegments, elementsMap) => {
|
|
|
5312
5335
|
},
|
|
5313
5336
|
elementsMap,
|
|
5314
5337
|
[
|
|
5315
|
-
|
|
5316
|
-
|
|
5338
|
+
pointFrom7(0, 0),
|
|
5339
|
+
pointFrom7(
|
|
5317
5340
|
arrow.x + (nextSegment?.start[0] ?? arrow.points[arrow.points.length - 1][0]) - x,
|
|
5318
5341
|
arrow.y + (nextSegment?.start[1] ?? arrow.points[arrow.points.length - 1][1]) - y
|
|
5319
5342
|
)
|
|
@@ -5338,11 +5361,16 @@ var handleSegmentRelease = (arrow, fixedSegments, elementsMap) => {
|
|
|
5338
5361
|
null,
|
|
5339
5362
|
null
|
|
5340
5363
|
);
|
|
5364
|
+
if (!restoredPoints || restoredPoints.length < 2) {
|
|
5365
|
+
throw new Error(
|
|
5366
|
+
"Property 'points' is required in the update returned by normalizeArrowElementUpdate()"
|
|
5367
|
+
);
|
|
5368
|
+
}
|
|
5341
5369
|
const nextPoints = [];
|
|
5342
5370
|
if (prevSegment) {
|
|
5343
5371
|
for (let i = 0; i < prevSegment.index; i++) {
|
|
5344
5372
|
nextPoints.push(
|
|
5345
|
-
|
|
5373
|
+
pointFrom7(
|
|
5346
5374
|
arrow.x + arrow.points[i][0],
|
|
5347
5375
|
arrow.y + arrow.points[i][1]
|
|
5348
5376
|
)
|
|
@@ -5351,7 +5379,7 @@ var handleSegmentRelease = (arrow, fixedSegments, elementsMap) => {
|
|
|
5351
5379
|
}
|
|
5352
5380
|
restoredPoints.forEach((p) => {
|
|
5353
5381
|
nextPoints.push(
|
|
5354
|
-
|
|
5382
|
+
pointFrom7(
|
|
5355
5383
|
arrow.x + (prevSegment ? prevSegment.end[0] : 0) + p[0],
|
|
5356
5384
|
arrow.y + (prevSegment ? prevSegment.end[1] : 0) + p[1]
|
|
5357
5385
|
)
|
|
@@ -5360,7 +5388,7 @@ var handleSegmentRelease = (arrow, fixedSegments, elementsMap) => {
|
|
|
5360
5388
|
if (nextSegment) {
|
|
5361
5389
|
for (let i = nextSegment.index; i < arrow.points.length; i++) {
|
|
5362
5390
|
nextPoints.push(
|
|
5363
|
-
|
|
5391
|
+
pointFrom7(
|
|
5364
5392
|
arrow.x + arrow.points[i][0],
|
|
5365
5393
|
arrow.y + arrow.points[i][1]
|
|
5366
5394
|
)
|
|
@@ -5431,7 +5459,7 @@ var handleSegmentMove = (arrow, fixedSegments, startHeading, endHeading, hovered
|
|
|
5431
5459
|
const startIsHorizontal = headingIsHorizontal(startHeading);
|
|
5432
5460
|
const startIsPositive = startIsHorizontal ? compareHeading(startHeading, HEADING_RIGHT) : compareHeading(startHeading, HEADING_DOWN);
|
|
5433
5461
|
const padding = startIsPositive ? segmentIsTooShort ? segmentLength / 2 : BASE_PADDING : segmentIsTooShort ? -segmentLength / 2 : -BASE_PADDING;
|
|
5434
|
-
fixedSegments[activelyModifiedSegmentIdx].start =
|
|
5462
|
+
fixedSegments[activelyModifiedSegmentIdx].start = pointFrom7(
|
|
5435
5463
|
fixedSegments[activelyModifiedSegmentIdx].start[0] + (startIsHorizontal ? padding : 0),
|
|
5436
5464
|
fixedSegments[activelyModifiedSegmentIdx].start[1] + (!startIsHorizontal ? padding : 0)
|
|
5437
5465
|
);
|
|
@@ -5440,24 +5468,24 @@ var handleSegmentMove = (arrow, fixedSegments, startHeading, endHeading, hovered
|
|
|
5440
5468
|
const endIsHorizontal = headingIsHorizontal(endHeading);
|
|
5441
5469
|
const endIsPositive = endIsHorizontal ? compareHeading(endHeading, HEADING_RIGHT) : compareHeading(endHeading, HEADING_DOWN);
|
|
5442
5470
|
const padding = endIsPositive ? segmentIsTooShort ? segmentLength / 2 : BASE_PADDING : segmentIsTooShort ? -segmentLength / 2 : -BASE_PADDING;
|
|
5443
|
-
fixedSegments[activelyModifiedSegmentIdx].end =
|
|
5471
|
+
fixedSegments[activelyModifiedSegmentIdx].end = pointFrom7(
|
|
5444
5472
|
fixedSegments[activelyModifiedSegmentIdx].end[0] + (endIsHorizontal ? padding : 0),
|
|
5445
5473
|
fixedSegments[activelyModifiedSegmentIdx].end[1] + (!endIsHorizontal ? padding : 0)
|
|
5446
5474
|
);
|
|
5447
5475
|
}
|
|
5448
5476
|
const nextFixedSegments = fixedSegments.map((segment) => ({
|
|
5449
5477
|
...segment,
|
|
5450
|
-
start:
|
|
5478
|
+
start: pointFrom7(
|
|
5451
5479
|
arrow.x + segment.start[0],
|
|
5452
5480
|
arrow.y + segment.start[1]
|
|
5453
5481
|
),
|
|
5454
|
-
end:
|
|
5482
|
+
end: pointFrom7(
|
|
5455
5483
|
arrow.x + segment.end[0],
|
|
5456
5484
|
arrow.y + segment.end[1]
|
|
5457
5485
|
)
|
|
5458
5486
|
}));
|
|
5459
5487
|
const newPoints = arrow.points.map(
|
|
5460
|
-
(p, i) =>
|
|
5488
|
+
(p, i) => pointFrom7(arrow.x + p[0], arrow.y + p[1])
|
|
5461
5489
|
);
|
|
5462
5490
|
const startIdx = nextFixedSegments[activelyModifiedSegmentIdx].index - 1;
|
|
5463
5491
|
const endIdx = nextFixedSegments[activelyModifiedSegmentIdx].index;
|
|
@@ -5503,14 +5531,14 @@ var handleSegmentMove = (arrow, fixedSegments, startHeading, endHeading, hovered
|
|
|
5503
5531
|
if (firstSegmentIdx === -1 && startIdx === 0) {
|
|
5504
5532
|
const startIsHorizontal = hoveredStartElement ? headingIsHorizontal(startHeading) : headingForPointIsHorizontal(newPoints[1], newPoints[0]);
|
|
5505
5533
|
newPoints.unshift(
|
|
5506
|
-
|
|
5534
|
+
pointFrom7(
|
|
5507
5535
|
startIsHorizontal ? start[0] : arrow.x + arrow.points[0][0],
|
|
5508
5536
|
!startIsHorizontal ? start[1] : arrow.y + arrow.points[0][1]
|
|
5509
5537
|
)
|
|
5510
5538
|
);
|
|
5511
5539
|
if (hoveredStartElement) {
|
|
5512
5540
|
newPoints.unshift(
|
|
5513
|
-
|
|
5541
|
+
pointFrom7(
|
|
5514
5542
|
arrow.x + arrow.points[0][0],
|
|
5515
5543
|
arrow.y + arrow.points[0][1]
|
|
5516
5544
|
)
|
|
@@ -5523,14 +5551,14 @@ var handleSegmentMove = (arrow, fixedSegments, startHeading, endHeading, hovered
|
|
|
5523
5551
|
if (lastSegmentIdx === -1 && endIdx === arrow.points.length - 1) {
|
|
5524
5552
|
const endIsHorizontal = headingIsHorizontal(endHeading);
|
|
5525
5553
|
newPoints.push(
|
|
5526
|
-
|
|
5554
|
+
pointFrom7(
|
|
5527
5555
|
endIsHorizontal ? end[0] : arrow.x + arrow.points[arrow.points.length - 1][0],
|
|
5528
5556
|
!endIsHorizontal ? end[1] : arrow.y + arrow.points[arrow.points.length - 1][1]
|
|
5529
5557
|
)
|
|
5530
5558
|
);
|
|
5531
5559
|
if (hoveredEndElement) {
|
|
5532
5560
|
newPoints.push(
|
|
5533
|
-
|
|
5561
|
+
pointFrom7(
|
|
5534
5562
|
arrow.x + arrow.points[arrow.points.length - 1][0],
|
|
5535
5563
|
arrow.y + arrow.points[arrow.points.length - 1][1]
|
|
5536
5564
|
)
|
|
@@ -5541,11 +5569,11 @@ var handleSegmentMove = (arrow, fixedSegments, startHeading, endHeading, hovered
|
|
|
5541
5569
|
newPoints,
|
|
5542
5570
|
nextFixedSegments.map((segment) => ({
|
|
5543
5571
|
...segment,
|
|
5544
|
-
start:
|
|
5572
|
+
start: pointFrom7(
|
|
5545
5573
|
segment.start[0] - arrow.x,
|
|
5546
5574
|
segment.start[1] - arrow.y
|
|
5547
5575
|
),
|
|
5548
|
-
end:
|
|
5576
|
+
end: pointFrom7(
|
|
5549
5577
|
segment.end[0] - arrow.x,
|
|
5550
5578
|
segment.end[1] - arrow.y
|
|
5551
5579
|
)
|
|
@@ -5560,18 +5588,18 @@ var handleEndpointDrag = (arrow, updatedPoints, fixedSegments, startHeading, end
|
|
|
5560
5588
|
let startIsSpecial = arrow.startIsSpecial ?? null;
|
|
5561
5589
|
let endIsSpecial = arrow.endIsSpecial ?? null;
|
|
5562
5590
|
const globalUpdatedPoints = updatedPoints.map(
|
|
5563
|
-
(p, i) => i === 0 ?
|
|
5591
|
+
(p, i) => i === 0 ? pointFrom7(arrow.x + p[0], arrow.y + p[1]) : i === updatedPoints.length - 1 ? pointFrom7(arrow.x + p[0], arrow.y + p[1]) : pointFrom7(
|
|
5564
5592
|
arrow.x + arrow.points[i][0],
|
|
5565
5593
|
arrow.y + arrow.points[i][1]
|
|
5566
5594
|
)
|
|
5567
5595
|
);
|
|
5568
5596
|
const nextFixedSegments = fixedSegments.map((segment) => ({
|
|
5569
5597
|
...segment,
|
|
5570
|
-
start:
|
|
5598
|
+
start: pointFrom7(
|
|
5571
5599
|
arrow.x + (segment.start[0] - updatedPoints[0][0]),
|
|
5572
5600
|
arrow.y + (segment.start[1] - updatedPoints[0][1])
|
|
5573
5601
|
),
|
|
5574
|
-
end:
|
|
5602
|
+
end: pointFrom7(
|
|
5575
5603
|
arrow.x + (segment.end[0] - updatedPoints[0][0]),
|
|
5576
5604
|
arrow.y + (segment.end[1] - updatedPoints[0][1])
|
|
5577
5605
|
)
|
|
@@ -5583,8 +5611,13 @@ var handleEndpointDrag = (arrow, updatedPoints, fixedSegments, startHeading, end
|
|
|
5583
5611
|
newPoints.push(globalUpdatedPoints[newPoints.length + offset]);
|
|
5584
5612
|
}
|
|
5585
5613
|
{
|
|
5586
|
-
const secondPoint = globalUpdatedPoints
|
|
5587
|
-
const thirdPoint = globalUpdatedPoints
|
|
5614
|
+
const secondPoint = globalUpdatedPoints.at(startIsSpecial ? 2 : 1);
|
|
5615
|
+
const thirdPoint = globalUpdatedPoints.at(startIsSpecial ? 3 : 2);
|
|
5616
|
+
if (!secondPoint || !thirdPoint) {
|
|
5617
|
+
throw new Error(
|
|
5618
|
+
`Second and third points must exist when handling endpoint drag (${startIsSpecial})`
|
|
5619
|
+
);
|
|
5620
|
+
}
|
|
5588
5621
|
const startIsHorizontal = headingIsHorizontal(startHeading);
|
|
5589
5622
|
const secondIsHorizontal = headingIsHorizontal(
|
|
5590
5623
|
vectorToHeading(vectorFromPoint5(secondPoint, thirdPoint))
|
|
@@ -5592,13 +5625,13 @@ var handleEndpointDrag = (arrow, updatedPoints, fixedSegments, startHeading, end
|
|
|
5592
5625
|
if (hoveredStartElement && startIsHorizontal === secondIsHorizontal) {
|
|
5593
5626
|
const positive = startIsHorizontal ? compareHeading(startHeading, HEADING_RIGHT) : compareHeading(startHeading, HEADING_DOWN);
|
|
5594
5627
|
newPoints.unshift(
|
|
5595
|
-
|
|
5628
|
+
pointFrom7(
|
|
5596
5629
|
!secondIsHorizontal ? thirdPoint[0] : startGlobalPoint[0] + (positive ? BASE_PADDING : -BASE_PADDING),
|
|
5597
5630
|
secondIsHorizontal ? thirdPoint[1] : startGlobalPoint[1] + (positive ? BASE_PADDING : -BASE_PADDING)
|
|
5598
5631
|
)
|
|
5599
5632
|
);
|
|
5600
5633
|
newPoints.unshift(
|
|
5601
|
-
|
|
5634
|
+
pointFrom7(
|
|
5602
5635
|
startIsHorizontal ? startGlobalPoint[0] + (positive ? BASE_PADDING : -BASE_PADDING) : startGlobalPoint[0],
|
|
5603
5636
|
!startIsHorizontal ? startGlobalPoint[1] + (positive ? BASE_PADDING : -BASE_PADDING) : startGlobalPoint[1]
|
|
5604
5637
|
)
|
|
@@ -5613,7 +5646,7 @@ var handleEndpointDrag = (arrow, updatedPoints, fixedSegments, startHeading, end
|
|
|
5613
5646
|
}
|
|
5614
5647
|
} else {
|
|
5615
5648
|
newPoints.unshift(
|
|
5616
|
-
|
|
5649
|
+
pointFrom7(
|
|
5617
5650
|
!secondIsHorizontal ? secondPoint[0] : startGlobalPoint[0],
|
|
5618
5651
|
secondIsHorizontal ? secondPoint[1] : startGlobalPoint[1]
|
|
5619
5652
|
)
|
|
@@ -5630,8 +5663,17 @@ var handleEndpointDrag = (arrow, updatedPoints, fixedSegments, startHeading, end
|
|
|
5630
5663
|
newPoints.unshift(startGlobalPoint);
|
|
5631
5664
|
}
|
|
5632
5665
|
{
|
|
5633
|
-
const secondToLastPoint = globalUpdatedPoints
|
|
5634
|
-
|
|
5666
|
+
const secondToLastPoint = globalUpdatedPoints.at(
|
|
5667
|
+
globalUpdatedPoints.length - (endIsSpecial ? 3 : 2)
|
|
5668
|
+
);
|
|
5669
|
+
const thirdToLastPoint = globalUpdatedPoints.at(
|
|
5670
|
+
globalUpdatedPoints.length - (endIsSpecial ? 4 : 3)
|
|
5671
|
+
);
|
|
5672
|
+
if (!secondToLastPoint || !thirdToLastPoint) {
|
|
5673
|
+
throw new Error(
|
|
5674
|
+
`Second and third to last points must exist when handling endpoint drag (${endIsSpecial})`
|
|
5675
|
+
);
|
|
5676
|
+
}
|
|
5635
5677
|
const endIsHorizontal = headingIsHorizontal(endHeading);
|
|
5636
5678
|
const secondIsHorizontal = headingForPointIsHorizontal(
|
|
5637
5679
|
thirdToLastPoint,
|
|
@@ -5640,13 +5682,13 @@ var handleEndpointDrag = (arrow, updatedPoints, fixedSegments, startHeading, end
|
|
|
5640
5682
|
if (hoveredEndElement && endIsHorizontal === secondIsHorizontal) {
|
|
5641
5683
|
const positive = endIsHorizontal ? compareHeading(endHeading, HEADING_RIGHT) : compareHeading(endHeading, HEADING_DOWN);
|
|
5642
5684
|
newPoints.push(
|
|
5643
|
-
|
|
5685
|
+
pointFrom7(
|
|
5644
5686
|
!secondIsHorizontal ? thirdToLastPoint[0] : endGlobalPoint[0] + (positive ? BASE_PADDING : -BASE_PADDING),
|
|
5645
5687
|
secondIsHorizontal ? thirdToLastPoint[1] : endGlobalPoint[1] + (positive ? BASE_PADDING : -BASE_PADDING)
|
|
5646
5688
|
)
|
|
5647
5689
|
);
|
|
5648
5690
|
newPoints.push(
|
|
5649
|
-
|
|
5691
|
+
pointFrom7(
|
|
5650
5692
|
endIsHorizontal ? endGlobalPoint[0] + (positive ? BASE_PADDING : -BASE_PADDING) : endGlobalPoint[0],
|
|
5651
5693
|
!endIsHorizontal ? endGlobalPoint[1] + (positive ? BASE_PADDING : -BASE_PADDING) : endGlobalPoint[1]
|
|
5652
5694
|
)
|
|
@@ -5656,7 +5698,7 @@ var handleEndpointDrag = (arrow, updatedPoints, fixedSegments, startHeading, end
|
|
|
5656
5698
|
}
|
|
5657
5699
|
} else {
|
|
5658
5700
|
newPoints.push(
|
|
5659
|
-
|
|
5701
|
+
pointFrom7(
|
|
5660
5702
|
!secondIsHorizontal ? secondToLastPoint[0] : endGlobalPoint[0],
|
|
5661
5703
|
secondIsHorizontal ? secondToLastPoint[1] : endGlobalPoint[1]
|
|
5662
5704
|
)
|
|
@@ -5675,11 +5717,11 @@ var handleEndpointDrag = (arrow, updatedPoints, fixedSegments, startHeading, end
|
|
|
5675
5717
|
end: newPoints[index]
|
|
5676
5718
|
})).map((segment) => ({
|
|
5677
5719
|
...segment,
|
|
5678
|
-
start:
|
|
5720
|
+
start: pointFrom7(
|
|
5679
5721
|
segment.start[0] - startGlobalPoint[0],
|
|
5680
5722
|
segment.start[1] - startGlobalPoint[1]
|
|
5681
5723
|
),
|
|
5682
|
-
end:
|
|
5724
|
+
end: pointFrom7(
|
|
5683
5725
|
segment.end[0] - startGlobalPoint[0],
|
|
5684
5726
|
segment.end[1] - startGlobalPoint[1]
|
|
5685
5727
|
)
|
|
@@ -5741,7 +5783,7 @@ var updateElbowArrowPoints = (arrow, elementsMap, updates, options) => {
|
|
|
5741
5783
|
if (startBinding && !startElement && areUpdatedPointsValid || endBinding && !endElement && areUpdatedPointsValid || elementsMap.size === 0 && areUpdatedPointsValid || Object.keys(restOfTheUpdates).length === 0 && (startElement?.id !== startBinding?.elementId || endElement?.id !== endBinding?.elementId)) {
|
|
5742
5784
|
return normalizeArrowElementUpdate(
|
|
5743
5785
|
updatedPoints.map(
|
|
5744
|
-
(p) =>
|
|
5786
|
+
(p) => pointFrom7(arrow.x + p[0], arrow.y + p[1])
|
|
5745
5787
|
),
|
|
5746
5788
|
arrow.fixedSegments,
|
|
5747
5789
|
arrow.startIsSpecial,
|
|
@@ -5773,7 +5815,7 @@ var updateElbowArrowPoints = (arrow, elementsMap, updates, options) => {
|
|
|
5773
5815
|
if (elementsMap.size === 0 && areUpdatedPointsValid) {
|
|
5774
5816
|
return normalizeArrowElementUpdate(
|
|
5775
5817
|
updatedPoints.map(
|
|
5776
|
-
(p) =>
|
|
5818
|
+
(p) => pointFrom7(arrow.x + p[0], arrow.y + p[1])
|
|
5777
5819
|
),
|
|
5778
5820
|
arrow.fixedSegments,
|
|
5779
5821
|
arrow.startIsSpecial,
|
|
@@ -5786,7 +5828,7 @@ var updateElbowArrowPoints = (arrow, elementsMap, updates, options) => {
|
|
|
5786
5828
|
if (updates.startBinding === arrow.startBinding && updates.endBinding === arrow.endBinding && (updates.points ?? []).every(
|
|
5787
5829
|
(p, i) => pointsEqual4(
|
|
5788
5830
|
p,
|
|
5789
|
-
arrow.points[i] ??
|
|
5831
|
+
arrow.points[i] ?? pointFrom7(Infinity, Infinity)
|
|
5790
5832
|
)
|
|
5791
5833
|
) && areUpdatedPointsValid) {
|
|
5792
5834
|
return {};
|
|
@@ -6280,13 +6322,13 @@ var calculateGrid = (aabbs, start, startHeading, end, endHeading, common) => {
|
|
|
6280
6322
|
var getDonglePosition = (bounds, heading, p) => {
|
|
6281
6323
|
switch (heading) {
|
|
6282
6324
|
case HEADING_UP:
|
|
6283
|
-
return
|
|
6325
|
+
return pointFrom7(p[0], bounds[1]);
|
|
6284
6326
|
case HEADING_RIGHT:
|
|
6285
|
-
return
|
|
6327
|
+
return pointFrom7(bounds[2], p[1]);
|
|
6286
6328
|
case HEADING_DOWN:
|
|
6287
|
-
return
|
|
6329
|
+
return pointFrom7(p[0], bounds[3]);
|
|
6288
6330
|
}
|
|
6289
|
-
return
|
|
6331
|
+
return pointFrom7(bounds[0], p[1]);
|
|
6290
6332
|
};
|
|
6291
6333
|
var estimateSegmentCount = (start, end, startHeading, endHeading) => {
|
|
6292
6334
|
if (endHeading === HEADING_RIGHT) {
|
|
@@ -6454,7 +6496,7 @@ var normalizeArrowElementUpdate = (global2, nextFixedSegments, startIsSpecial, e
|
|
|
6454
6496
|
);
|
|
6455
6497
|
}
|
|
6456
6498
|
points = points.map(
|
|
6457
|
-
([x, y]) =>
|
|
6499
|
+
([x, y]) => pointFrom7(clamp2(x, -1e6, 1e6), clamp2(y, -1e6, 1e6))
|
|
6458
6500
|
);
|
|
6459
6501
|
return {
|
|
6460
6502
|
points,
|
|
@@ -7192,7 +7234,7 @@ var bindPointToSnapToElementOutline = (arrow, bindableElement, startOrEnd, eleme
|
|
|
7192
7234
|
}
|
|
7193
7235
|
const aabb = aabbForElement(bindableElement, elementsMap);
|
|
7194
7236
|
const localP = arrow.points[startOrEnd === "start" ? 0 : arrow.points.length - 1];
|
|
7195
|
-
const globalP =
|
|
7237
|
+
const globalP = pointFrom8(
|
|
7196
7238
|
arrow.x + localP[0],
|
|
7197
7239
|
arrow.y + localP[1]
|
|
7198
7240
|
);
|
|
@@ -7200,8 +7242,8 @@ var bindPointToSnapToElementOutline = (arrow, bindableElement, startOrEnd, eleme
|
|
|
7200
7242
|
const elbowed = isElbowArrow(arrow);
|
|
7201
7243
|
const center = getCenterForBounds(aabb);
|
|
7202
7244
|
const adjacentPointIdx = startOrEnd === "start" ? 1 : arrow.points.length - 2;
|
|
7203
|
-
const adjacentPoint =
|
|
7204
|
-
|
|
7245
|
+
const adjacentPoint = pointRotateRads7(
|
|
7246
|
+
pointFrom8(
|
|
7205
7247
|
arrow.x + arrow.points[adjacentPointIdx][0],
|
|
7206
7248
|
arrow.y + arrow.points[adjacentPointIdx][1]
|
|
7207
7249
|
),
|
|
@@ -7214,7 +7256,7 @@ var bindPointToSnapToElementOutline = (arrow, bindableElement, startOrEnd, eleme
|
|
|
7214
7256
|
headingForPointFromElement(bindableElement, aabb, globalP)
|
|
7215
7257
|
);
|
|
7216
7258
|
const snapPoint = snapToMid(bindableElement, elementsMap, edgePoint);
|
|
7217
|
-
const otherPoint =
|
|
7259
|
+
const otherPoint = pointFrom8(
|
|
7218
7260
|
isHorizontal ? center[0] : snapPoint[0],
|
|
7219
7261
|
!isHorizontal ? center[1] : snapPoint[1]
|
|
7220
7262
|
);
|
|
@@ -7261,24 +7303,24 @@ var bindPointToSnapToElementOutline = (arrow, bindableElement, startOrEnd, eleme
|
|
|
7261
7303
|
};
|
|
7262
7304
|
var avoidRectangularCorner = (element, elementsMap, p) => {
|
|
7263
7305
|
const center = elementCenterPoint(element, elementsMap);
|
|
7264
|
-
const nonRotatedPoint =
|
|
7306
|
+
const nonRotatedPoint = pointRotateRads7(p, center, -element.angle);
|
|
7265
7307
|
if (nonRotatedPoint[0] < element.x && nonRotatedPoint[1] < element.y) {
|
|
7266
7308
|
if (nonRotatedPoint[1] - element.y > -FIXED_BINDING_DISTANCE) {
|
|
7267
|
-
return
|
|
7268
|
-
|
|
7309
|
+
return pointRotateRads7(
|
|
7310
|
+
pointFrom8(element.x - FIXED_BINDING_DISTANCE, element.y),
|
|
7269
7311
|
center,
|
|
7270
7312
|
element.angle
|
|
7271
7313
|
);
|
|
7272
7314
|
}
|
|
7273
|
-
return
|
|
7274
|
-
|
|
7315
|
+
return pointRotateRads7(
|
|
7316
|
+
pointFrom8(element.x, element.y - FIXED_BINDING_DISTANCE),
|
|
7275
7317
|
center,
|
|
7276
7318
|
element.angle
|
|
7277
7319
|
);
|
|
7278
7320
|
} else if (nonRotatedPoint[0] < element.x && nonRotatedPoint[1] > element.y + element.height) {
|
|
7279
7321
|
if (nonRotatedPoint[0] - element.x > -FIXED_BINDING_DISTANCE) {
|
|
7280
|
-
return
|
|
7281
|
-
|
|
7322
|
+
return pointRotateRads7(
|
|
7323
|
+
pointFrom8(
|
|
7282
7324
|
element.x,
|
|
7283
7325
|
element.y + element.height + FIXED_BINDING_DISTANCE
|
|
7284
7326
|
),
|
|
@@ -7286,15 +7328,15 @@ var avoidRectangularCorner = (element, elementsMap, p) => {
|
|
|
7286
7328
|
element.angle
|
|
7287
7329
|
);
|
|
7288
7330
|
}
|
|
7289
|
-
return
|
|
7290
|
-
|
|
7331
|
+
return pointRotateRads7(
|
|
7332
|
+
pointFrom8(element.x - FIXED_BINDING_DISTANCE, element.y + element.height),
|
|
7291
7333
|
center,
|
|
7292
7334
|
element.angle
|
|
7293
7335
|
);
|
|
7294
7336
|
} else if (nonRotatedPoint[0] > element.x + element.width && nonRotatedPoint[1] > element.y + element.height) {
|
|
7295
7337
|
if (nonRotatedPoint[0] - element.x < element.width + FIXED_BINDING_DISTANCE) {
|
|
7296
|
-
return
|
|
7297
|
-
|
|
7338
|
+
return pointRotateRads7(
|
|
7339
|
+
pointFrom8(
|
|
7298
7340
|
element.x + element.width,
|
|
7299
7341
|
element.y + element.height + FIXED_BINDING_DISTANCE
|
|
7300
7342
|
),
|
|
@@ -7302,8 +7344,8 @@ var avoidRectangularCorner = (element, elementsMap, p) => {
|
|
|
7302
7344
|
element.angle
|
|
7303
7345
|
);
|
|
7304
7346
|
}
|
|
7305
|
-
return
|
|
7306
|
-
|
|
7347
|
+
return pointRotateRads7(
|
|
7348
|
+
pointFrom8(
|
|
7307
7349
|
element.x + element.width + FIXED_BINDING_DISTANCE,
|
|
7308
7350
|
element.y + element.height
|
|
7309
7351
|
),
|
|
@@ -7312,8 +7354,8 @@ var avoidRectangularCorner = (element, elementsMap, p) => {
|
|
|
7312
7354
|
);
|
|
7313
7355
|
} else if (nonRotatedPoint[0] > element.x + element.width && nonRotatedPoint[1] < element.y) {
|
|
7314
7356
|
if (nonRotatedPoint[0] - element.x < element.width + FIXED_BINDING_DISTANCE) {
|
|
7315
|
-
return
|
|
7316
|
-
|
|
7357
|
+
return pointRotateRads7(
|
|
7358
|
+
pointFrom8(
|
|
7317
7359
|
element.x + element.width,
|
|
7318
7360
|
element.y - FIXED_BINDING_DISTANCE
|
|
7319
7361
|
),
|
|
@@ -7321,8 +7363,8 @@ var avoidRectangularCorner = (element, elementsMap, p) => {
|
|
|
7321
7363
|
element.angle
|
|
7322
7364
|
);
|
|
7323
7365
|
}
|
|
7324
|
-
return
|
|
7325
|
-
|
|
7366
|
+
return pointRotateRads7(
|
|
7367
|
+
pointFrom8(element.x + element.width + FIXED_BINDING_DISTANCE, element.y),
|
|
7326
7368
|
center,
|
|
7327
7369
|
element.angle
|
|
7328
7370
|
);
|
|
@@ -7332,62 +7374,62 @@ var avoidRectangularCorner = (element, elementsMap, p) => {
|
|
|
7332
7374
|
var snapToMid = (element, elementsMap, p, tolerance = 0.05) => {
|
|
7333
7375
|
const { x, y, width, height, angle } = element;
|
|
7334
7376
|
const center = elementCenterPoint(element, elementsMap, -0.1, -0.1);
|
|
7335
|
-
const nonRotated =
|
|
7377
|
+
const nonRotated = pointRotateRads7(p, center, -angle);
|
|
7336
7378
|
const verticalThreshold = clamp3(tolerance * height, 5, 80);
|
|
7337
7379
|
const horizontalThreshold = clamp3(tolerance * width, 5, 80);
|
|
7338
7380
|
if (nonRotated[0] <= x + width / 2 && nonRotated[1] > center[1] - verticalThreshold && nonRotated[1] < center[1] + verticalThreshold) {
|
|
7339
|
-
return
|
|
7340
|
-
|
|
7381
|
+
return pointRotateRads7(
|
|
7382
|
+
pointFrom8(x - FIXED_BINDING_DISTANCE, center[1]),
|
|
7341
7383
|
center,
|
|
7342
7384
|
angle
|
|
7343
7385
|
);
|
|
7344
7386
|
} else if (nonRotated[1] <= y + height / 2 && nonRotated[0] > center[0] - horizontalThreshold && nonRotated[0] < center[0] + horizontalThreshold) {
|
|
7345
|
-
return
|
|
7346
|
-
|
|
7387
|
+
return pointRotateRads7(
|
|
7388
|
+
pointFrom8(center[0], y - FIXED_BINDING_DISTANCE),
|
|
7347
7389
|
center,
|
|
7348
7390
|
angle
|
|
7349
7391
|
);
|
|
7350
7392
|
} else if (nonRotated[0] >= x + width / 2 && nonRotated[1] > center[1] - verticalThreshold && nonRotated[1] < center[1] + verticalThreshold) {
|
|
7351
|
-
return
|
|
7352
|
-
|
|
7393
|
+
return pointRotateRads7(
|
|
7394
|
+
pointFrom8(x + width + FIXED_BINDING_DISTANCE, center[1]),
|
|
7353
7395
|
center,
|
|
7354
7396
|
angle
|
|
7355
7397
|
);
|
|
7356
7398
|
} else if (nonRotated[1] >= y + height / 2 && nonRotated[0] > center[0] - horizontalThreshold && nonRotated[0] < center[0] + horizontalThreshold) {
|
|
7357
|
-
return
|
|
7358
|
-
|
|
7399
|
+
return pointRotateRads7(
|
|
7400
|
+
pointFrom8(center[0], y + height + FIXED_BINDING_DISTANCE),
|
|
7359
7401
|
center,
|
|
7360
7402
|
angle
|
|
7361
7403
|
);
|
|
7362
7404
|
} else if (element.type === "diamond") {
|
|
7363
7405
|
const distance3 = FIXED_BINDING_DISTANCE;
|
|
7364
|
-
const topLeft =
|
|
7406
|
+
const topLeft = pointFrom8(
|
|
7365
7407
|
x + width / 4 - distance3,
|
|
7366
7408
|
y + height / 4 - distance3
|
|
7367
7409
|
);
|
|
7368
|
-
const topRight =
|
|
7410
|
+
const topRight = pointFrom8(
|
|
7369
7411
|
x + 3 * width / 4 + distance3,
|
|
7370
7412
|
y + height / 4 - distance3
|
|
7371
7413
|
);
|
|
7372
|
-
const bottomLeft =
|
|
7414
|
+
const bottomLeft = pointFrom8(
|
|
7373
7415
|
x + width / 4 - distance3,
|
|
7374
7416
|
y + 3 * height / 4 + distance3
|
|
7375
7417
|
);
|
|
7376
|
-
const bottomRight =
|
|
7418
|
+
const bottomRight = pointFrom8(
|
|
7377
7419
|
x + 3 * width / 4 + distance3,
|
|
7378
7420
|
y + 3 * height / 4 + distance3
|
|
7379
7421
|
);
|
|
7380
7422
|
if (pointDistance4(topLeft, nonRotated) < Math.max(horizontalThreshold, verticalThreshold)) {
|
|
7381
|
-
return
|
|
7423
|
+
return pointRotateRads7(topLeft, center, angle);
|
|
7382
7424
|
}
|
|
7383
7425
|
if (pointDistance4(topRight, nonRotated) < Math.max(horizontalThreshold, verticalThreshold)) {
|
|
7384
|
-
return
|
|
7426
|
+
return pointRotateRads7(topRight, center, angle);
|
|
7385
7427
|
}
|
|
7386
7428
|
if (pointDistance4(bottomLeft, nonRotated) < Math.max(horizontalThreshold, verticalThreshold)) {
|
|
7387
|
-
return
|
|
7429
|
+
return pointRotateRads7(bottomLeft, center, angle);
|
|
7388
7430
|
}
|
|
7389
7431
|
if (pointDistance4(bottomRight, nonRotated) < Math.max(horizontalThreshold, verticalThreshold)) {
|
|
7390
|
-
return
|
|
7432
|
+
return pointRotateRads7(bottomRight, center, angle);
|
|
7391
7433
|
}
|
|
7392
7434
|
}
|
|
7393
7435
|
return p;
|
|
@@ -7407,11 +7449,11 @@ var updateBoundPoint = (linearElement, startOrEnd, binding, bindableElement, ele
|
|
|
7407
7449
|
elementsMap
|
|
7408
7450
|
).fixedPoint;
|
|
7409
7451
|
const globalMidPoint = elementCenterPoint(bindableElement, elementsMap);
|
|
7410
|
-
const global2 =
|
|
7452
|
+
const global2 = pointFrom8(
|
|
7411
7453
|
bindableElement.x + fixedPoint[0] * bindableElement.width,
|
|
7412
7454
|
bindableElement.y + fixedPoint[1] * bindableElement.height
|
|
7413
7455
|
);
|
|
7414
|
-
const rotatedGlobal =
|
|
7456
|
+
const rotatedGlobal = pointRotateRads7(
|
|
7415
7457
|
global2,
|
|
7416
7458
|
globalMidPoint,
|
|
7417
7459
|
bindableElement.angle
|
|
@@ -7501,11 +7543,11 @@ var calculateFixedPointForElbowArrowBinding = (linearElement, hoveredElement, st
|
|
|
7501
7543
|
startOrEnd,
|
|
7502
7544
|
elementsMap
|
|
7503
7545
|
);
|
|
7504
|
-
const globalMidPoint =
|
|
7546
|
+
const globalMidPoint = pointFrom8(
|
|
7505
7547
|
bounds[0] + (bounds[2] - bounds[0]) / 2,
|
|
7506
7548
|
bounds[1] + (bounds[3] - bounds[1]) / 2
|
|
7507
7549
|
);
|
|
7508
|
-
const nonRotatedSnappedGlobalPoint =
|
|
7550
|
+
const nonRotatedSnappedGlobalPoint = pointRotateRads7(
|
|
7509
7551
|
snappedPoint,
|
|
7510
7552
|
globalMidPoint,
|
|
7511
7553
|
-hoveredElement.angle
|
|
@@ -7638,7 +7680,7 @@ var newBoundElements = (boundElements, idsToRemove, elementsToAdd = []) => {
|
|
|
7638
7680
|
return nextBoundElements;
|
|
7639
7681
|
};
|
|
7640
7682
|
var bindingBorderTest = (element, { x, y }, elementsMap, zoom, fullShape) => {
|
|
7641
|
-
const p =
|
|
7683
|
+
const p = pointFrom8(x, y);
|
|
7642
7684
|
const threshold = maxBindingGap(element, element.width, element.height, zoom);
|
|
7643
7685
|
const shouldTestInside2 = (
|
|
7644
7686
|
// disable fullshape snapping for frame elements so we
|
|
@@ -7680,8 +7722,8 @@ var determineFocusDistance = (element, elementsMap, a2, b2) => {
|
|
|
7680
7722
|
if (pointsEqual5(a2, b2)) {
|
|
7681
7723
|
return 0;
|
|
7682
7724
|
}
|
|
7683
|
-
const rotatedA =
|
|
7684
|
-
const rotatedB =
|
|
7725
|
+
const rotatedA = pointRotateRads7(a2, center, -element.angle);
|
|
7726
|
+
const rotatedB = pointRotateRads7(b2, center, -element.angle);
|
|
7685
7727
|
const sign = Math.sign(
|
|
7686
7728
|
vectorCross3(
|
|
7687
7729
|
vectorFromPoint6(rotatedB, a2),
|
|
@@ -7700,70 +7742,70 @@ var determineFocusDistance = (element, elementsMap, a2, b2) => {
|
|
|
7700
7742
|
);
|
|
7701
7743
|
const axes = element.type === "diamond" ? [
|
|
7702
7744
|
lineSegment4(
|
|
7703
|
-
|
|
7704
|
-
|
|
7745
|
+
pointFrom8(element.x + element.width / 2, element.y),
|
|
7746
|
+
pointFrom8(
|
|
7705
7747
|
element.x + element.width / 2,
|
|
7706
7748
|
element.y + element.height
|
|
7707
7749
|
)
|
|
7708
7750
|
),
|
|
7709
7751
|
lineSegment4(
|
|
7710
|
-
|
|
7711
|
-
|
|
7752
|
+
pointFrom8(element.x, element.y + element.height / 2),
|
|
7753
|
+
pointFrom8(
|
|
7712
7754
|
element.x + element.width,
|
|
7713
7755
|
element.y + element.height / 2
|
|
7714
7756
|
)
|
|
7715
7757
|
)
|
|
7716
7758
|
] : [
|
|
7717
7759
|
lineSegment4(
|
|
7718
|
-
|
|
7719
|
-
|
|
7760
|
+
pointFrom8(element.x, element.y),
|
|
7761
|
+
pointFrom8(
|
|
7720
7762
|
element.x + element.width,
|
|
7721
7763
|
element.y + element.height
|
|
7722
7764
|
)
|
|
7723
7765
|
),
|
|
7724
7766
|
lineSegment4(
|
|
7725
|
-
|
|
7726
|
-
|
|
7767
|
+
pointFrom8(element.x + element.width, element.y),
|
|
7768
|
+
pointFrom8(element.x, element.y + element.height)
|
|
7727
7769
|
)
|
|
7728
7770
|
];
|
|
7729
7771
|
const interceptees = element.type === "diamond" ? [
|
|
7730
7772
|
lineSegment4(
|
|
7731
|
-
|
|
7773
|
+
pointFrom8(
|
|
7732
7774
|
element.x + element.width / 2,
|
|
7733
7775
|
element.y - element.height
|
|
7734
7776
|
),
|
|
7735
|
-
|
|
7777
|
+
pointFrom8(
|
|
7736
7778
|
element.x + element.width / 2,
|
|
7737
7779
|
element.y + element.height * 2
|
|
7738
7780
|
)
|
|
7739
7781
|
),
|
|
7740
7782
|
lineSegment4(
|
|
7741
|
-
|
|
7783
|
+
pointFrom8(
|
|
7742
7784
|
element.x - element.width,
|
|
7743
7785
|
element.y + element.height / 2
|
|
7744
7786
|
),
|
|
7745
|
-
|
|
7787
|
+
pointFrom8(
|
|
7746
7788
|
element.x + element.width * 2,
|
|
7747
7789
|
element.y + element.height / 2
|
|
7748
7790
|
)
|
|
7749
7791
|
)
|
|
7750
7792
|
] : [
|
|
7751
7793
|
lineSegment4(
|
|
7752
|
-
|
|
7794
|
+
pointFrom8(
|
|
7753
7795
|
element.x - element.width,
|
|
7754
7796
|
element.y - element.height
|
|
7755
7797
|
),
|
|
7756
|
-
|
|
7798
|
+
pointFrom8(
|
|
7757
7799
|
element.x + element.width * 2,
|
|
7758
7800
|
element.y + element.height * 2
|
|
7759
7801
|
)
|
|
7760
7802
|
),
|
|
7761
7803
|
lineSegment4(
|
|
7762
|
-
|
|
7804
|
+
pointFrom8(
|
|
7763
7805
|
element.x + element.width * 2,
|
|
7764
7806
|
element.y - element.height
|
|
7765
7807
|
),
|
|
7766
|
-
|
|
7808
|
+
pointFrom8(
|
|
7767
7809
|
element.x - element.width,
|
|
7768
7810
|
element.y + element.height * 2
|
|
7769
7811
|
)
|
|
@@ -7784,30 +7826,30 @@ var determineFocusPoint = (element, elementsMap, focus, adjacentPoint) => {
|
|
|
7784
7826
|
return center;
|
|
7785
7827
|
}
|
|
7786
7828
|
const candidates = (element.type === "diamond" ? [
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7829
|
+
pointFrom8(element.x, element.y + element.height / 2),
|
|
7830
|
+
pointFrom8(element.x + element.width / 2, element.y),
|
|
7831
|
+
pointFrom8(
|
|
7790
7832
|
element.x + element.width,
|
|
7791
7833
|
element.y + element.height / 2
|
|
7792
7834
|
),
|
|
7793
|
-
|
|
7835
|
+
pointFrom8(
|
|
7794
7836
|
element.x + element.width / 2,
|
|
7795
7837
|
element.y + element.height
|
|
7796
7838
|
)
|
|
7797
7839
|
] : [
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7840
|
+
pointFrom8(element.x, element.y),
|
|
7841
|
+
pointFrom8(element.x + element.width, element.y),
|
|
7842
|
+
pointFrom8(
|
|
7801
7843
|
element.x + element.width,
|
|
7802
7844
|
element.y + element.height
|
|
7803
7845
|
),
|
|
7804
|
-
|
|
7846
|
+
pointFrom8(element.x, element.y + element.height)
|
|
7805
7847
|
]).map(
|
|
7806
7848
|
(p) => pointFromVector5(
|
|
7807
7849
|
vectorScale6(vectorFromPoint6(p, center), Math.abs(focus)),
|
|
7808
7850
|
center
|
|
7809
7851
|
)
|
|
7810
|
-
).map((p) =>
|
|
7852
|
+
).map((p) => pointRotateRads7(p, center, element.angle));
|
|
7811
7853
|
const selected = [
|
|
7812
7854
|
vectorCross3(
|
|
7813
7855
|
vectorFromPoint6(adjacentPoint, candidates[0]),
|
|
@@ -8052,8 +8094,8 @@ var BindableElement = class {
|
|
|
8052
8094
|
};
|
|
8053
8095
|
var getGlobalFixedPointForBindableElement = (fixedPointRatio, element, elementsMap) => {
|
|
8054
8096
|
const [fixedX, fixedY] = normalizeFixedPoint(fixedPointRatio);
|
|
8055
|
-
return
|
|
8056
|
-
|
|
8097
|
+
return pointRotateRads7(
|
|
8098
|
+
pointFrom8(
|
|
8057
8099
|
element.x + element.width * fixedX,
|
|
8058
8100
|
element.y + element.height * fixedY
|
|
8059
8101
|
),
|
|
@@ -8068,7 +8110,7 @@ var getGlobalFixedPoints = (arrow, elementsMap) => {
|
|
|
8068
8110
|
arrow.startBinding.fixedPoint,
|
|
8069
8111
|
startElement,
|
|
8070
8112
|
elementsMap
|
|
8071
|
-
) :
|
|
8113
|
+
) : pointFrom8(
|
|
8072
8114
|
arrow.x + arrow.points[0][0],
|
|
8073
8115
|
arrow.y + arrow.points[0][1]
|
|
8074
8116
|
);
|
|
@@ -8076,7 +8118,7 @@ var getGlobalFixedPoints = (arrow, elementsMap) => {
|
|
|
8076
8118
|
arrow.endBinding.fixedPoint,
|
|
8077
8119
|
endElement,
|
|
8078
8120
|
elementsMap
|
|
8079
|
-
) :
|
|
8121
|
+
) : pointFrom8(
|
|
8080
8122
|
arrow.x + arrow.points[arrow.points.length - 1][0],
|
|
8081
8123
|
arrow.y + arrow.points[arrow.points.length - 1][1]
|
|
8082
8124
|
);
|
|
@@ -8106,7 +8148,7 @@ var getNormalizedPoints = ({
|
|
|
8106
8148
|
const offsetY = points[0][1];
|
|
8107
8149
|
return {
|
|
8108
8150
|
points: points.map((p) => {
|
|
8109
|
-
return
|
|
8151
|
+
return pointFrom9(p[0] - offsetX, p[1] - offsetY);
|
|
8110
8152
|
}),
|
|
8111
8153
|
offsetX,
|
|
8112
8154
|
offsetY
|
|
@@ -8130,7 +8172,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8130
8172
|
isEditing;
|
|
8131
8173
|
constructor(element, elementsMap, isEditing = false) {
|
|
8132
8174
|
this.elementId = element.id;
|
|
8133
|
-
if (!pointsEqual6(element.points[0],
|
|
8175
|
+
if (!pointsEqual6(element.points[0], pointFrom9(0, 0))) {
|
|
8134
8176
|
console.error("Linear element is not normalized", Error().stack);
|
|
8135
8177
|
mutateElement(
|
|
8136
8178
|
element,
|
|
@@ -8244,7 +8286,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8244
8286
|
element,
|
|
8245
8287
|
elementsMap,
|
|
8246
8288
|
referencePoint,
|
|
8247
|
-
|
|
8289
|
+
pointFrom9(scenePointerX, scenePointerY),
|
|
8248
8290
|
event[KEYS2.CTRL_OR_CMD] ? null : app.getEffectiveGridSize(),
|
|
8249
8291
|
customLineAngle
|
|
8250
8292
|
);
|
|
@@ -8255,7 +8297,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8255
8297
|
[
|
|
8256
8298
|
selectedIndex,
|
|
8257
8299
|
{
|
|
8258
|
-
point:
|
|
8300
|
+
point: pointFrom9(
|
|
8259
8301
|
width + referencePoint[0],
|
|
8260
8302
|
height + referencePoint[1]
|
|
8261
8303
|
),
|
|
@@ -8285,7 +8327,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8285
8327
|
scenePointerX - linearElementEditor.pointerOffset.x,
|
|
8286
8328
|
scenePointerY - linearElementEditor.pointerOffset.y,
|
|
8287
8329
|
event[KEYS2.CTRL_OR_CMD] ? null : app.getEffectiveGridSize()
|
|
8288
|
-
) :
|
|
8330
|
+
) : pointFrom9(
|
|
8289
8331
|
element.points[pointIndex][0] + deltaX,
|
|
8290
8332
|
element.points[pointIndex][1] + deltaY
|
|
8291
8333
|
);
|
|
@@ -8498,11 +8540,11 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8498
8540
|
const existingSegmentMidpointHitCoords = linearElementEditor.segmentMidPointHoveredCoords;
|
|
8499
8541
|
if (existingSegmentMidpointHitCoords) {
|
|
8500
8542
|
const distance3 = pointDistance5(
|
|
8501
|
-
|
|
8543
|
+
pointFrom9(
|
|
8502
8544
|
existingSegmentMidpointHitCoords[0],
|
|
8503
8545
|
existingSegmentMidpointHitCoords[1]
|
|
8504
8546
|
),
|
|
8505
|
-
|
|
8547
|
+
pointFrom9(scenePointer.x, scenePointer.y)
|
|
8506
8548
|
);
|
|
8507
8549
|
if (distance3 <= threshold) {
|
|
8508
8550
|
return existingSegmentMidpointHitCoords;
|
|
@@ -8518,7 +8560,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8518
8560
|
if (midPoints[index] !== null) {
|
|
8519
8561
|
const distance3 = pointDistance5(
|
|
8520
8562
|
midPoints[index],
|
|
8521
|
-
|
|
8563
|
+
pointFrom9(scenePointer.x, scenePointer.y)
|
|
8522
8564
|
);
|
|
8523
8565
|
if (distance3 <= threshold) {
|
|
8524
8566
|
return midPoints[index];
|
|
@@ -8557,7 +8599,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8557
8599
|
"Invalid segment index while calculating elbow arrow mid point"
|
|
8558
8600
|
);
|
|
8559
8601
|
const p = pointCenter2(element.points[index - 1], element.points[index]);
|
|
8560
|
-
return
|
|
8602
|
+
return pointFrom9(element.x + p[0], element.y + p[1]);
|
|
8561
8603
|
}
|
|
8562
8604
|
const [lines, curves] = deconstructLinearOrFreeDrawElement2(element);
|
|
8563
8605
|
invariant6(
|
|
@@ -8697,12 +8739,12 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8697
8739
|
const [x1, y1, x2, y2] = getElementAbsoluteCoords2(element, elementsMap);
|
|
8698
8740
|
const cx = (x1 + x2) / 2;
|
|
8699
8741
|
const cy = (y1 + y2) / 2;
|
|
8700
|
-
const targetPoint = clickedPointIndex > -1 &&
|
|
8701
|
-
|
|
8742
|
+
const targetPoint = clickedPointIndex > -1 && pointRotateRads8(
|
|
8743
|
+
pointFrom9(
|
|
8702
8744
|
element.x + element.points[clickedPointIndex][0],
|
|
8703
8745
|
element.y + element.points[clickedPointIndex][1]
|
|
8704
8746
|
),
|
|
8705
|
-
|
|
8747
|
+
pointFrom9(cx, cy),
|
|
8706
8748
|
element.angle
|
|
8707
8749
|
);
|
|
8708
8750
|
const nextSelectedPointsIndices = clickedPointIndex > -1 || event.shiftKey ? event.shiftKey || linearElementEditor.selectedPointsIndices?.includes(clickedPointIndex) ? normalizeSelectedPoints([
|
|
@@ -8768,10 +8810,10 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8768
8810
|
element,
|
|
8769
8811
|
elementsMap,
|
|
8770
8812
|
lastCommittedPoint,
|
|
8771
|
-
|
|
8813
|
+
pointFrom9(scenePointerX, scenePointerY),
|
|
8772
8814
|
event[KEYS2.CTRL_OR_CMD] ? null : app.getEffectiveGridSize()
|
|
8773
8815
|
);
|
|
8774
|
-
newPoint =
|
|
8816
|
+
newPoint = pointFrom9(
|
|
8775
8817
|
width + lastCommittedPoint[0],
|
|
8776
8818
|
height + lastCommittedPoint[1]
|
|
8777
8819
|
);
|
|
@@ -8811,9 +8853,9 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8811
8853
|
const cx = (x1 + x2) / 2;
|
|
8812
8854
|
const cy = (y1 + y2) / 2;
|
|
8813
8855
|
const { x, y } = element;
|
|
8814
|
-
return
|
|
8815
|
-
|
|
8816
|
-
|
|
8856
|
+
return pointRotateRads8(
|
|
8857
|
+
pointFrom9(x + p[0], y + p[1]),
|
|
8858
|
+
pointFrom9(cx, cy),
|
|
8817
8859
|
element.angle
|
|
8818
8860
|
);
|
|
8819
8861
|
}
|
|
@@ -8824,9 +8866,9 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8824
8866
|
const cy = (y1 + y2) / 2;
|
|
8825
8867
|
return element.points.map((p) => {
|
|
8826
8868
|
const { x, y } = element;
|
|
8827
|
-
return
|
|
8828
|
-
|
|
8829
|
-
|
|
8869
|
+
return pointRotateRads8(
|
|
8870
|
+
pointFrom9(x + p[0], y + p[1]),
|
|
8871
|
+
pointFrom9(cx, cy),
|
|
8830
8872
|
element.angle
|
|
8831
8873
|
);
|
|
8832
8874
|
});
|
|
@@ -8838,15 +8880,15 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8838
8880
|
const cy = (y1 + y2) / 2;
|
|
8839
8881
|
const p = element.points[index];
|
|
8840
8882
|
const { x, y } = element;
|
|
8841
|
-
return p ?
|
|
8842
|
-
|
|
8843
|
-
|
|
8883
|
+
return p ? pointRotateRads8(
|
|
8884
|
+
pointFrom9(x + p[0], y + p[1]),
|
|
8885
|
+
pointFrom9(cx, cy),
|
|
8844
8886
|
element.angle
|
|
8845
|
-
) :
|
|
8887
|
+
) : pointRotateRads8(pointFrom9(x, y), pointFrom9(cx, cy), element.angle);
|
|
8846
8888
|
}
|
|
8847
8889
|
static pointFromAbsoluteCoords(element, absoluteCoords, elementsMap) {
|
|
8848
8890
|
if (isElbowArrow(element)) {
|
|
8849
|
-
return
|
|
8891
|
+
return pointFrom9(
|
|
8850
8892
|
absoluteCoords[0] - element.x,
|
|
8851
8893
|
absoluteCoords[1] - element.y
|
|
8852
8894
|
);
|
|
@@ -8854,12 +8896,12 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8854
8896
|
const [x1, y1, x2, y2] = getElementAbsoluteCoords2(element, elementsMap);
|
|
8855
8897
|
const cx = (x1 + x2) / 2;
|
|
8856
8898
|
const cy = (y1 + y2) / 2;
|
|
8857
|
-
const [x, y] =
|
|
8858
|
-
|
|
8859
|
-
|
|
8899
|
+
const [x, y] = pointRotateRads8(
|
|
8900
|
+
pointFrom9(absoluteCoords[0], absoluteCoords[1]),
|
|
8901
|
+
pointFrom9(cx, cy),
|
|
8860
8902
|
-element.angle
|
|
8861
8903
|
);
|
|
8862
|
-
return
|
|
8904
|
+
return pointFrom9(x - element.x, y - element.y);
|
|
8863
8905
|
}
|
|
8864
8906
|
static getPointIndexUnderCursor(element, elementsMap, zoom, x, y) {
|
|
8865
8907
|
const pointHandles = _LinearElementEditor.getPointsGlobalCoordinates(
|
|
@@ -8869,7 +8911,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8869
8911
|
let idx = pointHandles.length;
|
|
8870
8912
|
while (--idx > -1) {
|
|
8871
8913
|
const p = pointHandles[idx];
|
|
8872
|
-
if (pointDistance5(
|
|
8914
|
+
if (pointDistance5(pointFrom9(x, y), pointFrom9(p[0], p[1])) * zoom.value < // +1px to account for outline stroke
|
|
8873
8915
|
_LinearElementEditor.POINT_HANDLE_SIZE + 1) {
|
|
8874
8916
|
return idx;
|
|
8875
8917
|
}
|
|
@@ -8881,12 +8923,12 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8881
8923
|
const [x1, y1, x2, y2] = getElementAbsoluteCoords2(element, elementsMap);
|
|
8882
8924
|
const cx = (x1 + x2) / 2;
|
|
8883
8925
|
const cy = (y1 + y2) / 2;
|
|
8884
|
-
const [rotatedX, rotatedY] =
|
|
8885
|
-
|
|
8886
|
-
|
|
8926
|
+
const [rotatedX, rotatedY] = pointRotateRads8(
|
|
8927
|
+
pointFrom9(pointerOnGrid[0], pointerOnGrid[1]),
|
|
8928
|
+
pointFrom9(cx, cy),
|
|
8887
8929
|
-element.angle
|
|
8888
8930
|
);
|
|
8889
|
-
return
|
|
8931
|
+
return pointFrom9(rotatedX - element.x, rotatedY - element.y);
|
|
8890
8932
|
}
|
|
8891
8933
|
/**
|
|
8892
8934
|
* Normalizes line points so that the start point is at [0,0]. This is
|
|
@@ -8935,7 +8977,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8935
8977
|
pointAddedToEnd = true;
|
|
8936
8978
|
}
|
|
8937
8979
|
acc.push(
|
|
8938
|
-
nextPoint ?
|
|
8980
|
+
nextPoint ? pointFrom9((p[0] + nextPoint[0]) / 2, (p[1] + nextPoint[1]) / 2) : pointFrom9(p[0], p[1])
|
|
8939
8981
|
);
|
|
8940
8982
|
nextSelectedIndices.push(indexCursor + 1);
|
|
8941
8983
|
++indexCursor;
|
|
@@ -8951,7 +8993,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8951
8993
|
/* @__PURE__ */ new Map([
|
|
8952
8994
|
[
|
|
8953
8995
|
element.points.length - 1,
|
|
8954
|
-
{ point:
|
|
8996
|
+
{ point: pointFrom9(lastPoint[0] + 30, lastPoint[1] + 30) }
|
|
8955
8997
|
]
|
|
8956
8998
|
])
|
|
8957
8999
|
);
|
|
@@ -8971,7 +9013,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8971
9013
|
});
|
|
8972
9014
|
const isPolygon = isLineElement(element) && element.polygon;
|
|
8973
9015
|
if (isPolygon && (isUncommittedPoint || pointIndices.includes(0) || pointIndices.includes(element.points.length - 1))) {
|
|
8974
|
-
nextPoints[0] =
|
|
9016
|
+
nextPoints[0] = pointFrom9(
|
|
8975
9017
|
nextPoints[nextPoints.length - 1][0],
|
|
8976
9018
|
nextPoints[nextPoints.length - 1][1]
|
|
8977
9019
|
);
|
|
@@ -8992,7 +9034,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8992
9034
|
static addPoints(element, scene, addedPoints) {
|
|
8993
9035
|
const nextPoints = [...element.points, ...addedPoints];
|
|
8994
9036
|
if (isLineElement(element) && element.polygon) {
|
|
8995
|
-
nextPoints[0] =
|
|
9037
|
+
nextPoints[0] = pointFrom9(
|
|
8996
9038
|
nextPoints[nextPoints.length - 1][0],
|
|
8997
9039
|
nextPoints[nextPoints.length - 1][1]
|
|
8998
9040
|
);
|
|
@@ -9017,7 +9059,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9017
9059
|
const lastPointUpdate = pointUpdates.get(points.length - 1);
|
|
9018
9060
|
if (firstPointUpdate) {
|
|
9019
9061
|
pointUpdates.set(points.length - 1, {
|
|
9020
|
-
point:
|
|
9062
|
+
point: pointFrom9(
|
|
9021
9063
|
firstPointUpdate.point[0],
|
|
9022
9064
|
firstPointUpdate.point[1]
|
|
9023
9065
|
),
|
|
@@ -9025,19 +9067,19 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9025
9067
|
});
|
|
9026
9068
|
} else if (lastPointUpdate) {
|
|
9027
9069
|
pointUpdates.set(0, {
|
|
9028
|
-
point:
|
|
9070
|
+
point: pointFrom9(lastPointUpdate.point[0], lastPointUpdate.point[1]),
|
|
9029
9071
|
isDragging: lastPointUpdate.isDragging
|
|
9030
9072
|
});
|
|
9031
9073
|
}
|
|
9032
9074
|
}
|
|
9033
|
-
const updatedOriginPoint = pointUpdates.get(0)?.point ??
|
|
9075
|
+
const updatedOriginPoint = pointUpdates.get(0)?.point ?? pointFrom9(0, 0);
|
|
9034
9076
|
const [offsetX, offsetY] = updatedOriginPoint;
|
|
9035
9077
|
const nextPoints = isElbowArrow(element) ? [
|
|
9036
9078
|
pointUpdates.get(0)?.point ?? points[0],
|
|
9037
9079
|
pointUpdates.get(points.length - 1)?.point ?? points[points.length - 1]
|
|
9038
9080
|
] : points.map((p, idx) => {
|
|
9039
9081
|
const current = pointUpdates.get(idx)?.point ?? p;
|
|
9040
|
-
return
|
|
9082
|
+
return pointFrom9(
|
|
9041
9083
|
current[0] - offsetX,
|
|
9042
9084
|
current[1] - offsetY
|
|
9043
9085
|
);
|
|
@@ -9071,8 +9113,8 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9071
9113
|
}
|
|
9072
9114
|
const origin = linearElementEditor.pointerDownState.origin;
|
|
9073
9115
|
const dist = pointDistance5(
|
|
9074
|
-
|
|
9075
|
-
|
|
9116
|
+
pointFrom9(origin.x, origin.y),
|
|
9117
|
+
pointFrom9(pointerCoords.x, pointerCoords.y)
|
|
9076
9118
|
);
|
|
9077
9119
|
if (!appState.selectedLinearElement?.isEditing && dist < DRAGGING_THRESHOLD / appState.zoom.value) {
|
|
9078
9120
|
return false;
|
|
@@ -9140,9 +9182,9 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9140
9182
|
const prevCenterY = (prevCoords[1] + prevCoords[3]) / 2;
|
|
9141
9183
|
const dX = prevCenterX - nextCenterX;
|
|
9142
9184
|
const dY = prevCenterY - nextCenterY;
|
|
9143
|
-
const rotatedOffset =
|
|
9144
|
-
|
|
9145
|
-
|
|
9185
|
+
const rotatedOffset = pointRotateRads8(
|
|
9186
|
+
pointFrom9(offsetX, offsetY),
|
|
9187
|
+
pointFrom9(dX, dY),
|
|
9146
9188
|
element.angle
|
|
9147
9189
|
);
|
|
9148
9190
|
scene.mutateElement(element, {
|
|
@@ -9177,9 +9219,9 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9177
9219
|
gridY,
|
|
9178
9220
|
customLineAngle
|
|
9179
9221
|
);
|
|
9180
|
-
return
|
|
9181
|
-
|
|
9182
|
-
|
|
9222
|
+
return pointRotateRads8(
|
|
9223
|
+
pointFrom9(width, height),
|
|
9224
|
+
pointFrom9(0, 0),
|
|
9183
9225
|
-element.angle
|
|
9184
9226
|
);
|
|
9185
9227
|
}
|
|
@@ -9224,34 +9266,34 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9224
9266
|
);
|
|
9225
9267
|
const boundTextX2 = boundTextX1 + boundTextElement.width;
|
|
9226
9268
|
const boundTextY2 = boundTextY1 + boundTextElement.height;
|
|
9227
|
-
const centerPoint =
|
|
9228
|
-
const topLeftRotatedPoint =
|
|
9229
|
-
|
|
9269
|
+
const centerPoint = pointFrom9(cx, cy);
|
|
9270
|
+
const topLeftRotatedPoint = pointRotateRads8(
|
|
9271
|
+
pointFrom9(x1, y1),
|
|
9230
9272
|
centerPoint,
|
|
9231
9273
|
element.angle
|
|
9232
9274
|
);
|
|
9233
|
-
const topRightRotatedPoint =
|
|
9234
|
-
|
|
9275
|
+
const topRightRotatedPoint = pointRotateRads8(
|
|
9276
|
+
pointFrom9(x2, y1),
|
|
9235
9277
|
centerPoint,
|
|
9236
9278
|
element.angle
|
|
9237
9279
|
);
|
|
9238
|
-
const counterRotateBoundTextTopLeft =
|
|
9239
|
-
|
|
9280
|
+
const counterRotateBoundTextTopLeft = pointRotateRads8(
|
|
9281
|
+
pointFrom9(boundTextX1, boundTextY1),
|
|
9240
9282
|
centerPoint,
|
|
9241
9283
|
-element.angle
|
|
9242
9284
|
);
|
|
9243
|
-
const counterRotateBoundTextTopRight =
|
|
9244
|
-
|
|
9285
|
+
const counterRotateBoundTextTopRight = pointRotateRads8(
|
|
9286
|
+
pointFrom9(boundTextX2, boundTextY1),
|
|
9245
9287
|
centerPoint,
|
|
9246
9288
|
-element.angle
|
|
9247
9289
|
);
|
|
9248
|
-
const counterRotateBoundTextBottomLeft =
|
|
9249
|
-
|
|
9290
|
+
const counterRotateBoundTextBottomLeft = pointRotateRads8(
|
|
9291
|
+
pointFrom9(boundTextX1, boundTextY2),
|
|
9250
9292
|
centerPoint,
|
|
9251
9293
|
-element.angle
|
|
9252
9294
|
);
|
|
9253
|
-
const counterRotateBoundTextBottomRight =
|
|
9254
|
-
|
|
9295
|
+
const counterRotateBoundTextBottomRight = pointRotateRads8(
|
|
9296
|
+
pointFrom9(boundTextX2, boundTextY2),
|
|
9255
9297
|
centerPoint,
|
|
9256
9298
|
-element.angle
|
|
9257
9299
|
);
|
|
@@ -9367,11 +9409,11 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9367
9409
|
);
|
|
9368
9410
|
fixedSegments[index] = {
|
|
9369
9411
|
index,
|
|
9370
|
-
start:
|
|
9412
|
+
start: pointFrom9(
|
|
9371
9413
|
!isHorizontal ? x - element.x : element.points[index - 1][0],
|
|
9372
9414
|
isHorizontal ? y - element.y : element.points[index - 1][1]
|
|
9373
9415
|
),
|
|
9374
|
-
end:
|
|
9416
|
+
end: pointFrom9(
|
|
9375
9417
|
!isHorizontal ? x - element.x : element.points[index][0],
|
|
9376
9418
|
isHorizontal ? y - element.y : element.points[index][1]
|
|
9377
9419
|
)
|
|
@@ -9383,7 +9425,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9383
9425
|
scene.mutateElement(element, {
|
|
9384
9426
|
fixedSegments: nextFixedSegments
|
|
9385
9427
|
});
|
|
9386
|
-
const point =
|
|
9428
|
+
const point = pointFrom9(
|
|
9387
9429
|
element.x + (element.fixedSegments[offset].start[0] + element.fixedSegments[offset].end[0]) / 2,
|
|
9388
9430
|
element.y + (element.fixedSegments[offset].start[1] + element.fixedSegments[offset].end[1]) / 2
|
|
9389
9431
|
);
|
|
@@ -9421,7 +9463,7 @@ var normalizeSelectedPoints = (points) => {
|
|
|
9421
9463
|
// src/frame.ts
|
|
9422
9464
|
init_define_import_meta_env();
|
|
9423
9465
|
import { arrayToMap as arrayToMap5 } from "@excalidraw/common";
|
|
9424
|
-
import { isPointWithinBounds as isPointWithinBounds2, pointFrom as
|
|
9466
|
+
import { isPointWithinBounds as isPointWithinBounds2, pointFrom as pointFrom11 } from "@excalidraw/math";
|
|
9425
9467
|
|
|
9426
9468
|
// ../utils/src/bbox.ts
|
|
9427
9469
|
init_define_import_meta_env();
|
|
@@ -9472,24 +9514,24 @@ import {
|
|
|
9472
9514
|
} from "@excalidraw/element";
|
|
9473
9515
|
import {
|
|
9474
9516
|
rangeIncludesValue,
|
|
9475
|
-
pointFrom as
|
|
9476
|
-
pointRotateRads as
|
|
9517
|
+
pointFrom as pointFrom10,
|
|
9518
|
+
pointRotateRads as pointRotateRads9,
|
|
9477
9519
|
rangeInclusive
|
|
9478
9520
|
} from "@excalidraw/math";
|
|
9479
9521
|
var getNonLinearElementRelativePoints = (element) => {
|
|
9480
9522
|
if (element.type === "diamond") {
|
|
9481
9523
|
return [
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9524
|
+
pointFrom10(element.width / 2, 0),
|
|
9525
|
+
pointFrom10(element.width, element.height / 2),
|
|
9526
|
+
pointFrom10(element.width / 2, element.height),
|
|
9527
|
+
pointFrom10(0, element.height / 2)
|
|
9486
9528
|
];
|
|
9487
9529
|
}
|
|
9488
9530
|
return [
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9531
|
+
pointFrom10(0, 0),
|
|
9532
|
+
pointFrom10(0 + element.width, 0),
|
|
9533
|
+
pointFrom10(0 + element.width, element.height),
|
|
9534
|
+
pointFrom10(0, element.height)
|
|
9493
9535
|
];
|
|
9494
9536
|
};
|
|
9495
9537
|
var getElementRelativePoints = (element) => {
|
|
@@ -9523,9 +9565,9 @@ var getMinMaxPoints = (points) => {
|
|
|
9523
9565
|
var getRotatedBBox = (element) => {
|
|
9524
9566
|
const points = getElementRelativePoints(element);
|
|
9525
9567
|
const { cx, cy } = getMinMaxPoints(points);
|
|
9526
|
-
const centerPoint =
|
|
9568
|
+
const centerPoint = pointFrom10(cx, cy);
|
|
9527
9569
|
const rotatedPoints = points.map(
|
|
9528
|
-
(p) =>
|
|
9570
|
+
(p) => pointRotateRads9(p, centerPoint, element.angle)
|
|
9529
9571
|
);
|
|
9530
9572
|
const { minX, minY, maxX, maxY } = getMinMaxPoints(rotatedPoints);
|
|
9531
9573
|
return [
|
|
@@ -10089,9 +10131,9 @@ var elementOverlapsWithFrame = (element, frame, elementsMap) => {
|
|
|
10089
10131
|
var isCursorInFrame = (cursorCoords, frame, elementsMap) => {
|
|
10090
10132
|
const [fx1, fy1, fx2, fy2] = getElementAbsoluteCoords2(frame, elementsMap);
|
|
10091
10133
|
return isPointWithinBounds2(
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10134
|
+
pointFrom11(fx1, fy1),
|
|
10135
|
+
pointFrom11(cursorCoords.x, cursorCoords.y),
|
|
10136
|
+
pointFrom11(fx2, fy2)
|
|
10095
10137
|
);
|
|
10096
10138
|
};
|
|
10097
10139
|
var groupsAreAtLeastIntersectingTheFrame = (elements, groupIds, frame) => {
|
|
@@ -11155,6 +11197,58 @@ function getFreeDrawPath2D(element) {
|
|
|
11155
11197
|
return pathsCache.get(element);
|
|
11156
11198
|
}
|
|
11157
11199
|
function getFreeDrawSvgPath(element) {
|
|
11200
|
+
return getSvgPathFromStroke(getFreedrawOutlinePoints(element));
|
|
11201
|
+
}
|
|
11202
|
+
function getFreedrawOutlineAsSegments(element, points, elementsMap) {
|
|
11203
|
+
const bounds = getElementBounds(
|
|
11204
|
+
{
|
|
11205
|
+
...element,
|
|
11206
|
+
angle: 0
|
|
11207
|
+
},
|
|
11208
|
+
elementsMap
|
|
11209
|
+
);
|
|
11210
|
+
const center = pointFrom12(
|
|
11211
|
+
(bounds[0] + bounds[2]) / 2,
|
|
11212
|
+
(bounds[1] + bounds[3]) / 2
|
|
11213
|
+
);
|
|
11214
|
+
invariant7(points.length >= 2, "Freepath outline must have at least 2 points");
|
|
11215
|
+
return points.slice(2).reduce(
|
|
11216
|
+
(acc, curr) => {
|
|
11217
|
+
acc.push(
|
|
11218
|
+
lineSegment5(
|
|
11219
|
+
acc[acc.length - 1][1],
|
|
11220
|
+
pointRotateRads10(
|
|
11221
|
+
pointFrom12(curr[0] + element.x, curr[1] + element.y),
|
|
11222
|
+
center,
|
|
11223
|
+
element.angle
|
|
11224
|
+
)
|
|
11225
|
+
)
|
|
11226
|
+
);
|
|
11227
|
+
return acc;
|
|
11228
|
+
},
|
|
11229
|
+
[
|
|
11230
|
+
lineSegment5(
|
|
11231
|
+
pointRotateRads10(
|
|
11232
|
+
pointFrom12(
|
|
11233
|
+
points[0][0] + element.x,
|
|
11234
|
+
points[0][1] + element.y
|
|
11235
|
+
),
|
|
11236
|
+
center,
|
|
11237
|
+
element.angle
|
|
11238
|
+
),
|
|
11239
|
+
pointRotateRads10(
|
|
11240
|
+
pointFrom12(
|
|
11241
|
+
points[1][0] + element.x,
|
|
11242
|
+
points[1][1] + element.y
|
|
11243
|
+
),
|
|
11244
|
+
center,
|
|
11245
|
+
element.angle
|
|
11246
|
+
)
|
|
11247
|
+
)
|
|
11248
|
+
]
|
|
11249
|
+
);
|
|
11250
|
+
}
|
|
11251
|
+
function getFreedrawOutlinePoints(element) {
|
|
11158
11252
|
const inputPoints = element.simulatePressure ? element.points : element.points.length ? element.points.map(([x, y], i) => [x, y, element.pressures[i]]) : [[0, 0, 0.5]];
|
|
11159
11253
|
const options = {
|
|
11160
11254
|
simulatePressure: element.simulatePressure,
|
|
@@ -11167,7 +11261,7 @@ function getFreeDrawSvgPath(element) {
|
|
|
11167
11261
|
last: !!element.lastCommittedPoint
|
|
11168
11262
|
// LastCommittedPoint is added on pointerup
|
|
11169
11263
|
};
|
|
11170
|
-
return
|
|
11264
|
+
return ae(inputPoints, options);
|
|
11171
11265
|
}
|
|
11172
11266
|
function med(A2, B2) {
|
|
11173
11267
|
return [(A2[0] + B2[0]) / 2, (A2[1] + B2[1]) / 2];
|
|
@@ -11450,26 +11544,26 @@ var generateLinearCollisionShape = (element) => {
|
|
|
11450
11544
|
switch (element.type) {
|
|
11451
11545
|
case "line":
|
|
11452
11546
|
case "arrow": {
|
|
11453
|
-
const points = element.points.length ? element.points : [
|
|
11547
|
+
const points = element.points.length ? element.points : [pointFrom13(0, 0)];
|
|
11454
11548
|
if (isElbowArrow(element)) {
|
|
11455
11549
|
return generator.path(generateElbowArrowShape(points, 16), options).sets[0].ops;
|
|
11456
11550
|
} else if (!element.roundness) {
|
|
11457
11551
|
return points.map((point, idx) => {
|
|
11458
|
-
const p =
|
|
11459
|
-
|
|
11552
|
+
const p = pointRotateRads11(
|
|
11553
|
+
pointFrom13(element.x + point[0], element.y + point[1]),
|
|
11460
11554
|
center,
|
|
11461
11555
|
element.angle
|
|
11462
11556
|
);
|
|
11463
11557
|
return {
|
|
11464
11558
|
op: idx === 0 ? "move" : "lineTo",
|
|
11465
|
-
data:
|
|
11559
|
+
data: pointFrom13(p[0] - element.x, p[1] - element.y)
|
|
11466
11560
|
};
|
|
11467
11561
|
});
|
|
11468
11562
|
}
|
|
11469
11563
|
return generator.curve(points, options).sets[0].ops.slice(0, element.points.length).map((op, i) => {
|
|
11470
11564
|
if (i === 0) {
|
|
11471
|
-
const p =
|
|
11472
|
-
|
|
11565
|
+
const p = pointRotateRads11(
|
|
11566
|
+
pointFrom13(
|
|
11473
11567
|
element.x + op.data[0],
|
|
11474
11568
|
element.y + op.data[1]
|
|
11475
11569
|
),
|
|
@@ -11478,30 +11572,30 @@ var generateLinearCollisionShape = (element) => {
|
|
|
11478
11572
|
);
|
|
11479
11573
|
return {
|
|
11480
11574
|
op: "move",
|
|
11481
|
-
data:
|
|
11575
|
+
data: pointFrom13(p[0] - element.x, p[1] - element.y)
|
|
11482
11576
|
};
|
|
11483
11577
|
}
|
|
11484
11578
|
return {
|
|
11485
11579
|
op: "bcurveTo",
|
|
11486
11580
|
data: [
|
|
11487
|
-
|
|
11488
|
-
|
|
11581
|
+
pointRotateRads11(
|
|
11582
|
+
pointFrom13(
|
|
11489
11583
|
element.x + op.data[0],
|
|
11490
11584
|
element.y + op.data[1]
|
|
11491
11585
|
),
|
|
11492
11586
|
center,
|
|
11493
11587
|
element.angle
|
|
11494
11588
|
),
|
|
11495
|
-
|
|
11496
|
-
|
|
11589
|
+
pointRotateRads11(
|
|
11590
|
+
pointFrom13(
|
|
11497
11591
|
element.x + op.data[2],
|
|
11498
11592
|
element.y + op.data[3]
|
|
11499
11593
|
),
|
|
11500
11594
|
center,
|
|
11501
11595
|
element.angle
|
|
11502
11596
|
),
|
|
11503
|
-
|
|
11504
|
-
|
|
11597
|
+
pointRotateRads11(
|
|
11598
|
+
pointFrom13(
|
|
11505
11599
|
element.x + op.data[4],
|
|
11506
11600
|
element.y + op.data[5]
|
|
11507
11601
|
),
|
|
@@ -11509,7 +11603,7 @@ var generateLinearCollisionShape = (element) => {
|
|
|
11509
11603
|
element.angle
|
|
11510
11604
|
)
|
|
11511
11605
|
].map(
|
|
11512
|
-
(p) =>
|
|
11606
|
+
(p) => pointFrom13(p[0] - element.x, p[1] - element.y)
|
|
11513
11607
|
).flat()
|
|
11514
11608
|
};
|
|
11515
11609
|
});
|
|
@@ -11524,8 +11618,8 @@ var generateLinearCollisionShape = (element) => {
|
|
|
11524
11618
|
);
|
|
11525
11619
|
return generator.curve(simplifiedPoints, options).sets[0].ops.slice(0, element.points.length).map((op, i) => {
|
|
11526
11620
|
if (i === 0) {
|
|
11527
|
-
const p =
|
|
11528
|
-
|
|
11621
|
+
const p = pointRotateRads11(
|
|
11622
|
+
pointFrom13(
|
|
11529
11623
|
element.x + op.data[0],
|
|
11530
11624
|
element.y + op.data[1]
|
|
11531
11625
|
),
|
|
@@ -11534,30 +11628,30 @@ var generateLinearCollisionShape = (element) => {
|
|
|
11534
11628
|
);
|
|
11535
11629
|
return {
|
|
11536
11630
|
op: "move",
|
|
11537
|
-
data:
|
|
11631
|
+
data: pointFrom13(p[0] - element.x, p[1] - element.y)
|
|
11538
11632
|
};
|
|
11539
11633
|
}
|
|
11540
11634
|
return {
|
|
11541
11635
|
op: "bcurveTo",
|
|
11542
11636
|
data: [
|
|
11543
|
-
|
|
11544
|
-
|
|
11637
|
+
pointRotateRads11(
|
|
11638
|
+
pointFrom13(
|
|
11545
11639
|
element.x + op.data[0],
|
|
11546
11640
|
element.y + op.data[1]
|
|
11547
11641
|
),
|
|
11548
11642
|
center,
|
|
11549
11643
|
element.angle
|
|
11550
11644
|
),
|
|
11551
|
-
|
|
11552
|
-
|
|
11645
|
+
pointRotateRads11(
|
|
11646
|
+
pointFrom13(
|
|
11553
11647
|
element.x + op.data[2],
|
|
11554
11648
|
element.y + op.data[3]
|
|
11555
11649
|
),
|
|
11556
11650
|
center,
|
|
11557
11651
|
element.angle
|
|
11558
11652
|
),
|
|
11559
|
-
|
|
11560
|
-
|
|
11653
|
+
pointRotateRads11(
|
|
11654
|
+
pointFrom13(
|
|
11561
11655
|
element.x + op.data[4],
|
|
11562
11656
|
element.y + op.data[5]
|
|
11563
11657
|
),
|
|
@@ -11565,7 +11659,7 @@ var generateLinearCollisionShape = (element) => {
|
|
|
11565
11659
|
element.angle
|
|
11566
11660
|
)
|
|
11567
11661
|
].map(
|
|
11568
|
-
(p) =>
|
|
11662
|
+
(p) => pointFrom13(p[0] - element.x, p[1] - element.y)
|
|
11569
11663
|
).flat()
|
|
11570
11664
|
};
|
|
11571
11665
|
});
|
|
@@ -11662,7 +11756,7 @@ var generateElementShape = (element, generator, {
|
|
|
11662
11756
|
case "arrow": {
|
|
11663
11757
|
let shape;
|
|
11664
11758
|
const options = generateRoughOptions(element);
|
|
11665
|
-
const points = element.points.length ? element.points : [
|
|
11759
|
+
const points = element.points.length ? element.points : [pointFrom13(0, 0)];
|
|
11666
11760
|
if (isElbowArrow(element)) {
|
|
11667
11761
|
if (!points.every(
|
|
11668
11762
|
(point) => Math.abs(point[0]) <= 1e6 && Math.abs(point[1]) <= 1e6
|
|
@@ -11824,14 +11918,14 @@ var getElementShape = (element, elementsMap) => {
|
|
|
11824
11918
|
return shouldTestInside(element) ? getClosedCurveShape(
|
|
11825
11919
|
element,
|
|
11826
11920
|
roughShape,
|
|
11827
|
-
|
|
11921
|
+
pointFrom13(element.x, element.y),
|
|
11828
11922
|
element.angle,
|
|
11829
|
-
|
|
11923
|
+
pointFrom13(cx, cy)
|
|
11830
11924
|
) : getCurveShape(
|
|
11831
11925
|
roughShape,
|
|
11832
|
-
|
|
11926
|
+
pointFrom13(element.x, element.y),
|
|
11833
11927
|
element.angle,
|
|
11834
|
-
|
|
11928
|
+
pointFrom13(cx, cy)
|
|
11835
11929
|
);
|
|
11836
11930
|
}
|
|
11837
11931
|
case "ellipse":
|
|
@@ -11840,7 +11934,7 @@ var getElementShape = (element, elementsMap) => {
|
|
|
11840
11934
|
const [, , , , cx, cy] = getElementAbsoluteCoords2(element, elementsMap);
|
|
11841
11935
|
return getFreedrawShape(
|
|
11842
11936
|
element,
|
|
11843
|
-
|
|
11937
|
+
pointFrom13(cx, cy),
|
|
11844
11938
|
shouldTestInside(element)
|
|
11845
11939
|
);
|
|
11846
11940
|
}
|
|
@@ -11859,9 +11953,9 @@ var toggleLinePolygonState = (element, nextPolygonState) => {
|
|
|
11859
11953
|
firstPoint[1] - lastPoint[1]
|
|
11860
11954
|
);
|
|
11861
11955
|
if (distance3 > LINE_POLYGON_POINT_MERGE_DISTANCE || updatedPoints.length < 4) {
|
|
11862
|
-
updatedPoints.push(
|
|
11956
|
+
updatedPoints.push(pointFrom13(firstPoint[0], firstPoint[1]));
|
|
11863
11957
|
} else {
|
|
11864
|
-
updatedPoints[updatedPoints.length - 1] =
|
|
11958
|
+
updatedPoints[updatedPoints.length - 1] = pointFrom13(
|
|
11865
11959
|
firstPoint[0],
|
|
11866
11960
|
firstPoint[1]
|
|
11867
11961
|
);
|
|
@@ -11915,9 +12009,9 @@ var ElementBounds = class _ElementBounds {
|
|
|
11915
12009
|
if (isFreeDrawElement(element)) {
|
|
11916
12010
|
const [minX, minY, maxX, maxY] = getBoundsFromPoints(
|
|
11917
12011
|
element.points.map(
|
|
11918
|
-
([x, y]) =>
|
|
11919
|
-
|
|
11920
|
-
|
|
12012
|
+
([x, y]) => pointRotateRads12(
|
|
12013
|
+
pointFrom14(x, y),
|
|
12014
|
+
pointFrom14(cx - element.x, cy - element.y),
|
|
11921
12015
|
element.angle
|
|
11922
12016
|
)
|
|
11923
12017
|
)
|
|
@@ -11931,24 +12025,24 @@ var ElementBounds = class _ElementBounds {
|
|
|
11931
12025
|
} else if (isLinearElement(element)) {
|
|
11932
12026
|
bounds = getLinearElementRotatedBounds(element, cx, cy, elementsMap);
|
|
11933
12027
|
} else if (element.type === "diamond") {
|
|
11934
|
-
const [x11, y11] =
|
|
11935
|
-
|
|
11936
|
-
|
|
12028
|
+
const [x11, y11] = pointRotateRads12(
|
|
12029
|
+
pointFrom14(cx, y1),
|
|
12030
|
+
pointFrom14(cx, cy),
|
|
11937
12031
|
element.angle
|
|
11938
12032
|
);
|
|
11939
|
-
const [x12, y12] =
|
|
11940
|
-
|
|
11941
|
-
|
|
12033
|
+
const [x12, y12] = pointRotateRads12(
|
|
12034
|
+
pointFrom14(cx, y2),
|
|
12035
|
+
pointFrom14(cx, cy),
|
|
11942
12036
|
element.angle
|
|
11943
12037
|
);
|
|
11944
|
-
const [x22, y22] =
|
|
11945
|
-
|
|
11946
|
-
|
|
12038
|
+
const [x22, y22] = pointRotateRads12(
|
|
12039
|
+
pointFrom14(x1, cy),
|
|
12040
|
+
pointFrom14(cx, cy),
|
|
11947
12041
|
element.angle
|
|
11948
12042
|
);
|
|
11949
|
-
const [x21, y21] =
|
|
11950
|
-
|
|
11951
|
-
|
|
12043
|
+
const [x21, y21] = pointRotateRads12(
|
|
12044
|
+
pointFrom14(x2, cy),
|
|
12045
|
+
pointFrom14(cx, cy),
|
|
11952
12046
|
element.angle
|
|
11953
12047
|
);
|
|
11954
12048
|
const minX = Math.min(x11, x12, x22, x21);
|
|
@@ -11965,24 +12059,24 @@ var ElementBounds = class _ElementBounds {
|
|
|
11965
12059
|
const hh = Math.hypot(h * cos, w * sin);
|
|
11966
12060
|
bounds = [cx - ww, cy - hh, cx + ww, cy + hh];
|
|
11967
12061
|
} else {
|
|
11968
|
-
const [x11, y11] =
|
|
11969
|
-
|
|
11970
|
-
|
|
12062
|
+
const [x11, y11] = pointRotateRads12(
|
|
12063
|
+
pointFrom14(x1, y1),
|
|
12064
|
+
pointFrom14(cx, cy),
|
|
11971
12065
|
element.angle
|
|
11972
12066
|
);
|
|
11973
|
-
const [x12, y12] =
|
|
11974
|
-
|
|
11975
|
-
|
|
12067
|
+
const [x12, y12] = pointRotateRads12(
|
|
12068
|
+
pointFrom14(x1, y2),
|
|
12069
|
+
pointFrom14(cx, cy),
|
|
11976
12070
|
element.angle
|
|
11977
12071
|
);
|
|
11978
|
-
const [x22, y22] =
|
|
11979
|
-
|
|
11980
|
-
|
|
12072
|
+
const [x22, y22] = pointRotateRads12(
|
|
12073
|
+
pointFrom14(x2, y2),
|
|
12074
|
+
pointFrom14(cx, cy),
|
|
11981
12075
|
element.angle
|
|
11982
12076
|
);
|
|
11983
|
-
const [x21, y21] =
|
|
11984
|
-
|
|
11985
|
-
|
|
12077
|
+
const [x21, y21] = pointRotateRads12(
|
|
12078
|
+
pointFrom14(x2, y1),
|
|
12079
|
+
pointFrom14(cx, cy),
|
|
11986
12080
|
element.angle
|
|
11987
12081
|
);
|
|
11988
12082
|
const minX = Math.min(x11, x12, x22, x21);
|
|
@@ -12036,7 +12130,7 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
12036
12130
|
element,
|
|
12037
12131
|
elementsMap
|
|
12038
12132
|
);
|
|
12039
|
-
const center =
|
|
12133
|
+
const center = pointFrom14(cx, cy);
|
|
12040
12134
|
if (shape.type === "polycurve") {
|
|
12041
12135
|
const curves = shape.data;
|
|
12042
12136
|
const points = curves.map((curve4) => pointsOnBezierCurves(curve4, 10)).flat();
|
|
@@ -12044,9 +12138,9 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
12044
12138
|
const segments = [];
|
|
12045
12139
|
while (i < points.length - 1) {
|
|
12046
12140
|
segments.push(
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12141
|
+
lineSegment6(
|
|
12142
|
+
pointFrom14(points[i][0], points[i][1]),
|
|
12143
|
+
pointFrom14(points[i + 1][0], points[i + 1][1])
|
|
12050
12144
|
)
|
|
12051
12145
|
);
|
|
12052
12146
|
i++;
|
|
@@ -12069,10 +12163,10 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
12069
12163
|
const container = getContainerElement(element, elementsMap);
|
|
12070
12164
|
if (container && isLinearElement(container)) {
|
|
12071
12165
|
const segments2 = [
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12166
|
+
lineSegment6(pointFrom14(x1, y1), pointFrom14(x2, y1)),
|
|
12167
|
+
lineSegment6(pointFrom14(x2, y1), pointFrom14(x2, y2)),
|
|
12168
|
+
lineSegment6(pointFrom14(x2, y2), pointFrom14(x1, y2)),
|
|
12169
|
+
lineSegment6(pointFrom14(x1, y2), pointFrom14(x1, y1))
|
|
12076
12170
|
];
|
|
12077
12171
|
return segments2;
|
|
12078
12172
|
}
|
|
@@ -12080,7 +12174,7 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
12080
12174
|
const points = shape.data;
|
|
12081
12175
|
const segments = [];
|
|
12082
12176
|
for (let i = 0; i < points.length - 1; i++) {
|
|
12083
|
-
segments.push(
|
|
12177
|
+
segments.push(lineSegment6(points[i], points[i + 1]));
|
|
12084
12178
|
}
|
|
12085
12179
|
return segments;
|
|
12086
12180
|
} else if (shape.type === "ellipse") {
|
|
@@ -12095,16 +12189,16 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
12095
12189
|
[cx, y2],
|
|
12096
12190
|
[x1, cy],
|
|
12097
12191
|
[x2, cy]
|
|
12098
|
-
].map((point) =>
|
|
12192
|
+
].map((point) => pointRotateRads12(point, center, element.angle));
|
|
12099
12193
|
return [
|
|
12100
|
-
|
|
12101
|
-
|
|
12102
|
-
|
|
12103
|
-
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12194
|
+
lineSegment6(nw, ne),
|
|
12195
|
+
lineSegment6(sw, se2),
|
|
12196
|
+
lineSegment6(nw, sw),
|
|
12197
|
+
lineSegment6(ne, se2),
|
|
12198
|
+
lineSegment6(nw, e),
|
|
12199
|
+
lineSegment6(sw, e),
|
|
12200
|
+
lineSegment6(ne, w),
|
|
12201
|
+
lineSegment6(se2, w)
|
|
12108
12202
|
];
|
|
12109
12203
|
};
|
|
12110
12204
|
var _isRectanguloidElement = (element) => {
|
|
@@ -12112,9 +12206,9 @@ var _isRectanguloidElement = (element) => {
|
|
|
12112
12206
|
};
|
|
12113
12207
|
var getRotatedSides = (sides, center, angle) => {
|
|
12114
12208
|
return sides.map((side) => {
|
|
12115
|
-
return
|
|
12116
|
-
|
|
12117
|
-
|
|
12209
|
+
return lineSegment6(
|
|
12210
|
+
pointRotateRads12(side[0], center, angle),
|
|
12211
|
+
pointRotateRads12(side[1], center, angle)
|
|
12118
12212
|
);
|
|
12119
12213
|
});
|
|
12120
12214
|
};
|
|
@@ -12124,14 +12218,14 @@ var getSegmentsOnCurve = (curve4, center, angle) => {
|
|
|
12124
12218
|
const segments = [];
|
|
12125
12219
|
while (i < points.length - 1) {
|
|
12126
12220
|
segments.push(
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
12221
|
+
lineSegment6(
|
|
12222
|
+
pointRotateRads12(
|
|
12223
|
+
pointFrom14(points[i][0], points[i][1]),
|
|
12130
12224
|
center,
|
|
12131
12225
|
angle
|
|
12132
12226
|
),
|
|
12133
|
-
|
|
12134
|
-
|
|
12227
|
+
pointRotateRads12(
|
|
12228
|
+
pointFrom14(points[i + 1][0], points[i + 1][1]),
|
|
12135
12229
|
center,
|
|
12136
12230
|
angle
|
|
12137
12231
|
)
|
|
@@ -12142,7 +12236,7 @@ var getSegmentsOnCurve = (curve4, center, angle) => {
|
|
|
12142
12236
|
return segments;
|
|
12143
12237
|
};
|
|
12144
12238
|
var getSegmentsOnEllipse = (ellipse4) => {
|
|
12145
|
-
const center =
|
|
12239
|
+
const center = pointFrom14(
|
|
12146
12240
|
ellipse4.x + ellipse4.width / 2,
|
|
12147
12241
|
ellipse4.y + ellipse4.height / 2
|
|
12148
12242
|
);
|
|
@@ -12156,12 +12250,12 @@ var getSegmentsOnEllipse = (ellipse4) => {
|
|
|
12156
12250
|
const t = i * deltaT;
|
|
12157
12251
|
const x = center[0] + a2 * Math.cos(t);
|
|
12158
12252
|
const y = center[1] + b2 * Math.sin(t);
|
|
12159
|
-
points.push(
|
|
12253
|
+
points.push(pointRotateRads12(pointFrom14(x, y), center, ellipse4.angle));
|
|
12160
12254
|
}
|
|
12161
12255
|
for (let i = 0; i < points.length - 1; i++) {
|
|
12162
|
-
segments.push(
|
|
12256
|
+
segments.push(lineSegment6(points[i], points[i + 1]));
|
|
12163
12257
|
}
|
|
12164
|
-
segments.push(
|
|
12258
|
+
segments.push(lineSegment6(points[points.length - 1], points[0]));
|
|
12165
12259
|
return segments;
|
|
12166
12260
|
};
|
|
12167
12261
|
var getRectangleBoxAbsoluteCoords = (boxSceneCoords) => {
|
|
@@ -12239,17 +12333,17 @@ var getCubicBezierCurveBound = (p0, p1, p2, p3) => {
|
|
|
12239
12333
|
return [minX, minY, maxX, maxY];
|
|
12240
12334
|
};
|
|
12241
12335
|
var getMinMaxXYFromCurvePathOps = (ops, transformXY) => {
|
|
12242
|
-
let currentP =
|
|
12336
|
+
let currentP = pointFrom14(0, 0);
|
|
12243
12337
|
const { minX, minY, maxX, maxY } = ops.reduce(
|
|
12244
12338
|
(limits, { op, data }) => {
|
|
12245
12339
|
if (op === "move") {
|
|
12246
12340
|
const p = pointFromArray3(data);
|
|
12247
|
-
|
|
12341
|
+
invariant8(p != null, "Op data is not a point");
|
|
12248
12342
|
currentP = p;
|
|
12249
12343
|
} else if (op === "bcurveTo") {
|
|
12250
|
-
const _p1 =
|
|
12251
|
-
const _p2 =
|
|
12252
|
-
const _p3 =
|
|
12344
|
+
const _p1 = pointFrom14(data[0], data[1]);
|
|
12345
|
+
const _p2 = pointFrom14(data[2], data[3]);
|
|
12346
|
+
const _p3 = pointFrom14(data[4], data[5]);
|
|
12253
12347
|
const p1 = transformXY ? transformXY(_p1) : _p1;
|
|
12254
12348
|
const p2 = transformXY ? transformXY(_p2) : _p2;
|
|
12255
12349
|
const p3 = transformXY ? transformXY(_p3) : _p3;
|
|
@@ -12330,18 +12424,18 @@ var getArrowheadPoints = (element, shape, position, arrowhead) => {
|
|
|
12330
12424
|
}
|
|
12331
12425
|
const index = position === "start" ? 1 : ops.length - 1;
|
|
12332
12426
|
const data = ops[index].data;
|
|
12333
|
-
|
|
12334
|
-
const p3 =
|
|
12335
|
-
const p2 =
|
|
12336
|
-
const p1 =
|
|
12427
|
+
invariant8(data.length === 6, "Op data length is not 6");
|
|
12428
|
+
const p3 = pointFrom14(data[4], data[5]);
|
|
12429
|
+
const p2 = pointFrom14(data[2], data[3]);
|
|
12430
|
+
const p1 = pointFrom14(data[0], data[1]);
|
|
12337
12431
|
const prevOp = ops[index - 1];
|
|
12338
|
-
let p0 =
|
|
12432
|
+
let p0 = pointFrom14(0, 0);
|
|
12339
12433
|
if (prevOp.op === "move") {
|
|
12340
12434
|
const p = pointFromArray3(prevOp.data);
|
|
12341
|
-
|
|
12435
|
+
invariant8(p != null, "Op data is not a point");
|
|
12342
12436
|
p0 = p;
|
|
12343
12437
|
} else if (prevOp.op === "bcurveTo") {
|
|
12344
|
-
p0 =
|
|
12438
|
+
p0 = pointFrom14(prevOp.data[4], prevOp.data[5]);
|
|
12345
12439
|
}
|
|
12346
12440
|
const equation = (t, idx) => Math.pow(1 - t, 3) * p3[idx] + 3 * t * Math.pow(1 - t, 2) * p2[idx] + 3 * Math.pow(t, 2) * (1 - t) * p1[idx] + p0[idx] * Math.pow(t, 3);
|
|
12347
12441
|
const [x2, y2] = position === "start" ? p0 : p3;
|
|
@@ -12366,26 +12460,26 @@ var getArrowheadPoints = (element, shape, position, arrowhead) => {
|
|
|
12366
12460
|
}
|
|
12367
12461
|
const angle = getArrowheadAngle(arrowhead);
|
|
12368
12462
|
if (arrowhead === "crowfoot_many" || arrowhead === "crowfoot_one_or_many") {
|
|
12369
|
-
const [x32, y32] =
|
|
12370
|
-
|
|
12371
|
-
|
|
12463
|
+
const [x32, y32] = pointRotateRads12(
|
|
12464
|
+
pointFrom14(x2, y2),
|
|
12465
|
+
pointFrom14(xs, ys),
|
|
12372
12466
|
degreesToRadians(-angle)
|
|
12373
12467
|
);
|
|
12374
|
-
const [x42, y42] =
|
|
12375
|
-
|
|
12376
|
-
|
|
12468
|
+
const [x42, y42] = pointRotateRads12(
|
|
12469
|
+
pointFrom14(x2, y2),
|
|
12470
|
+
pointFrom14(xs, ys),
|
|
12377
12471
|
degreesToRadians(angle)
|
|
12378
12472
|
);
|
|
12379
12473
|
return [xs, ys, x32, y32, x42, y42];
|
|
12380
12474
|
}
|
|
12381
|
-
const [x3, y3] =
|
|
12382
|
-
|
|
12383
|
-
|
|
12475
|
+
const [x3, y3] = pointRotateRads12(
|
|
12476
|
+
pointFrom14(xs, ys),
|
|
12477
|
+
pointFrom14(x2, y2),
|
|
12384
12478
|
-angle * Math.PI / 180
|
|
12385
12479
|
);
|
|
12386
|
-
const [x4, y4] =
|
|
12387
|
-
|
|
12388
|
-
|
|
12480
|
+
const [x4, y4] = pointRotateRads12(
|
|
12481
|
+
pointFrom14(xs, ys),
|
|
12482
|
+
pointFrom14(x2, y2),
|
|
12389
12483
|
degreesToRadians(angle)
|
|
12390
12484
|
);
|
|
12391
12485
|
if (arrowhead === "diamond" || arrowhead === "diamond_outline") {
|
|
@@ -12393,16 +12487,16 @@ var getArrowheadPoints = (element, shape, position, arrowhead) => {
|
|
|
12393
12487
|
let oy;
|
|
12394
12488
|
if (position === "start") {
|
|
12395
12489
|
const [px, py] = element.points.length > 1 ? element.points[1] : [0, 0];
|
|
12396
|
-
[ox, oy] =
|
|
12397
|
-
|
|
12398
|
-
|
|
12490
|
+
[ox, oy] = pointRotateRads12(
|
|
12491
|
+
pointFrom14(x2 + minSize * 2, y2),
|
|
12492
|
+
pointFrom14(x2, y2),
|
|
12399
12493
|
Math.atan2(py - y2, px - x2)
|
|
12400
12494
|
);
|
|
12401
12495
|
} else {
|
|
12402
12496
|
const [px, py] = element.points.length > 1 ? element.points[element.points.length - 2] : [0, 0];
|
|
12403
|
-
[ox, oy] =
|
|
12404
|
-
|
|
12405
|
-
|
|
12497
|
+
[ox, oy] = pointRotateRads12(
|
|
12498
|
+
pointFrom14(x2 - minSize * 2, y2),
|
|
12499
|
+
pointFrom14(x2, y2),
|
|
12406
12500
|
Math.atan2(y2 - py, x2 - px)
|
|
12407
12501
|
);
|
|
12408
12502
|
}
|
|
@@ -12431,9 +12525,9 @@ var getLinearElementRotatedBounds = (element, cx, cy, elementsMap) => {
|
|
|
12431
12525
|
const boundTextElement = getBoundTextElement(element, elementsMap);
|
|
12432
12526
|
if (element.points.length < 2) {
|
|
12433
12527
|
const [pointX, pointY] = element.points[0];
|
|
12434
|
-
const [x, y] =
|
|
12435
|
-
|
|
12436
|
-
|
|
12528
|
+
const [x, y] = pointRotateRads12(
|
|
12529
|
+
pointFrom14(element.x + pointX, element.y + pointY),
|
|
12530
|
+
pointFrom14(cx, cy),
|
|
12437
12531
|
element.angle
|
|
12438
12532
|
);
|
|
12439
12533
|
let coords2 = [x, y, x, y];
|
|
@@ -12456,9 +12550,9 @@ var getLinearElementRotatedBounds = (element, cx, cy, elementsMap) => {
|
|
|
12456
12550
|
const cachedShape = ShapeCache.get(element)?.[0];
|
|
12457
12551
|
const shape = cachedShape ?? generateLinearElementShape(element);
|
|
12458
12552
|
const ops = getCurvePathOps(shape);
|
|
12459
|
-
const transformXY = ([x, y]) =>
|
|
12460
|
-
|
|
12461
|
-
|
|
12553
|
+
const transformXY = ([x, y]) => pointRotateRads12(
|
|
12554
|
+
pointFrom14(element.x + x, element.y + y),
|
|
12555
|
+
pointFrom14(cx, cy),
|
|
12462
12556
|
element.angle
|
|
12463
12557
|
);
|
|
12464
12558
|
const res = getMinMaxXYFromCurvePathOps(ops, transformXY);
|
|
@@ -12569,8 +12663,8 @@ var getClosestElementBounds = (elements, from) => {
|
|
|
12569
12663
|
elements.forEach((element) => {
|
|
12570
12664
|
const [x1, y1, x2, y2] = getElementBounds(element, elementsMap);
|
|
12571
12665
|
const distance3 = pointDistance7(
|
|
12572
|
-
|
|
12573
|
-
|
|
12666
|
+
pointFrom14((x1 + x2) / 2, (y1 + y2) / 2),
|
|
12667
|
+
pointFrom14(from.x, from.y)
|
|
12574
12668
|
);
|
|
12575
12669
|
if (distance3 < minDistance) {
|
|
12576
12670
|
minDistance = distance3;
|
|
@@ -12606,7 +12700,7 @@ var getVisibleSceneBounds = ({
|
|
|
12606
12700
|
-scrollY + height / zoom.value
|
|
12607
12701
|
];
|
|
12608
12702
|
};
|
|
12609
|
-
var getCenterForBounds = (bounds) =>
|
|
12703
|
+
var getCenterForBounds = (bounds) => pointFrom14(
|
|
12610
12704
|
bounds[0] + (bounds[2] - bounds[0]) / 2,
|
|
12611
12705
|
bounds[1] + (bounds[3] - bounds[1]) / 2
|
|
12612
12706
|
);
|
|
@@ -12620,23 +12714,23 @@ var aabbForElement = (element, elementsMap, offset) => {
|
|
|
12620
12714
|
midY: element.y + element.height / 2
|
|
12621
12715
|
};
|
|
12622
12716
|
const center = elementCenterPoint(element, elementsMap);
|
|
12623
|
-
const [topLeftX, topLeftY] =
|
|
12624
|
-
|
|
12717
|
+
const [topLeftX, topLeftY] = pointRotateRads12(
|
|
12718
|
+
pointFrom14(bbox.minX, bbox.minY),
|
|
12625
12719
|
center,
|
|
12626
12720
|
element.angle
|
|
12627
12721
|
);
|
|
12628
|
-
const [topRightX, topRightY] =
|
|
12629
|
-
|
|
12722
|
+
const [topRightX, topRightY] = pointRotateRads12(
|
|
12723
|
+
pointFrom14(bbox.maxX, bbox.minY),
|
|
12630
12724
|
center,
|
|
12631
12725
|
element.angle
|
|
12632
12726
|
);
|
|
12633
|
-
const [bottomRightX, bottomRightY] =
|
|
12634
|
-
|
|
12727
|
+
const [bottomRightX, bottomRightY] = pointRotateRads12(
|
|
12728
|
+
pointFrom14(bbox.maxX, bbox.maxY),
|
|
12635
12729
|
center,
|
|
12636
12730
|
element.angle
|
|
12637
12731
|
);
|
|
12638
|
-
const [bottomLeftX, bottomLeftY] =
|
|
12639
|
-
|
|
12732
|
+
const [bottomLeftX, bottomLeftY] = pointRotateRads12(
|
|
12733
|
+
pointFrom14(bbox.minX, bbox.maxY),
|
|
12640
12734
|
center,
|
|
12641
12735
|
element.angle
|
|
12642
12736
|
);
|
|
@@ -12668,7 +12762,7 @@ var doBoundsIntersect = (bounds1, bounds2) => {
|
|
|
12668
12762
|
};
|
|
12669
12763
|
var elementCenterPoint = (element, elementsMap, xOffset = 0, yOffset = 0) => {
|
|
12670
12764
|
const [x, y] = getCenterForBounds(getElementBounds(element, elementsMap));
|
|
12671
|
-
return
|
|
12765
|
+
return pointFrom14(x + xOffset, y + yOffset);
|
|
12672
12766
|
};
|
|
12673
12767
|
|
|
12674
12768
|
// src/sizeHelpers.ts
|
|
@@ -13495,7 +13589,7 @@ var EphemeralIncrement = class extends StoreIncrement {
|
|
|
13495
13589
|
this.change = change;
|
|
13496
13590
|
}
|
|
13497
13591
|
};
|
|
13498
|
-
var StoreDelta = class {
|
|
13592
|
+
var StoreDelta = class _StoreDelta {
|
|
13499
13593
|
constructor(id, elements, appState) {
|
|
13500
13594
|
this.id = id;
|
|
13501
13595
|
this.elements = elements;
|
|
@@ -13533,10 +13627,23 @@ var StoreDelta = class {
|
|
|
13533
13627
|
*/
|
|
13534
13628
|
static load({
|
|
13535
13629
|
id,
|
|
13536
|
-
elements: { added, removed, updated }
|
|
13630
|
+
elements: { added, removed, updated },
|
|
13631
|
+
appState: { delta: appStateDelta }
|
|
13537
13632
|
}) {
|
|
13538
13633
|
const elements = ElementsDelta.create(added, removed, updated);
|
|
13539
|
-
|
|
13634
|
+
const appState = AppStateDelta.create(appStateDelta);
|
|
13635
|
+
return new this(id, elements, appState);
|
|
13636
|
+
}
|
|
13637
|
+
/**
|
|
13638
|
+
* Squash the passed deltas into the aggregated delta instance.
|
|
13639
|
+
*/
|
|
13640
|
+
static squash(...deltas) {
|
|
13641
|
+
const aggregatedDelta = _StoreDelta.empty();
|
|
13642
|
+
for (const delta of deltas) {
|
|
13643
|
+
aggregatedDelta.elements.squash(delta.elements);
|
|
13644
|
+
aggregatedDelta.appState.squash(delta.appState);
|
|
13645
|
+
}
|
|
13646
|
+
return aggregatedDelta;
|
|
13540
13647
|
}
|
|
13541
13648
|
/**
|
|
13542
13649
|
* Inverse store delta, creates new instance of `StoreDelta`.
|
|
@@ -13547,9 +13654,7 @@ var StoreDelta = class {
|
|
|
13547
13654
|
/**
|
|
13548
13655
|
* Apply the delta to the passed elements and appState, does not modify the snapshot.
|
|
13549
13656
|
*/
|
|
13550
|
-
static applyTo(delta, elements, appState, options
|
|
13551
|
-
excludedProperties: /* @__PURE__ */ new Set()
|
|
13552
|
-
}) {
|
|
13657
|
+
static applyTo(delta, elements, appState, options) {
|
|
13553
13658
|
const [nextElements, elementsContainVisibleChange] = delta.elements.applyTo(
|
|
13554
13659
|
elements,
|
|
13555
13660
|
StoreSnapshot.empty().elements,
|
|
@@ -13575,6 +13680,9 @@ var StoreDelta = class {
|
|
|
13575
13680
|
}
|
|
13576
13681
|
);
|
|
13577
13682
|
}
|
|
13683
|
+
static empty() {
|
|
13684
|
+
return _StoreDelta.create(ElementsDelta.empty(), AppStateDelta.empty());
|
|
13685
|
+
}
|
|
13578
13686
|
isEmpty() {
|
|
13579
13687
|
return this.elements.isEmpty() && this.appState.isEmpty();
|
|
13580
13688
|
}
|
|
@@ -14398,9 +14506,9 @@ var Scene = class {
|
|
|
14398
14506
|
getFramesIncludingDeleted() {
|
|
14399
14507
|
return this.frames;
|
|
14400
14508
|
}
|
|
14401
|
-
constructor(elements = null) {
|
|
14509
|
+
constructor(elements = null, options) {
|
|
14402
14510
|
if (elements) {
|
|
14403
|
-
this.replaceAllElements(elements);
|
|
14511
|
+
this.replaceAllElements(elements, options);
|
|
14404
14512
|
}
|
|
14405
14513
|
}
|
|
14406
14514
|
getSelectedElements(opts) {
|
|
@@ -14465,10 +14573,12 @@ var Scene = class {
|
|
|
14465
14573
|
}
|
|
14466
14574
|
return didChange;
|
|
14467
14575
|
}
|
|
14468
|
-
replaceAllElements(nextElements) {
|
|
14576
|
+
replaceAllElements(nextElements, options) {
|
|
14469
14577
|
const _nextElements = toArray(nextElements);
|
|
14470
14578
|
const nextFrameLikes = [];
|
|
14471
|
-
|
|
14579
|
+
if (!options?.skipValidation) {
|
|
14580
|
+
validateIndicesThrottled(_nextElements);
|
|
14581
|
+
}
|
|
14472
14582
|
this.elements = syncInvalidIndices2(_nextElements);
|
|
14473
14583
|
this.elementsMap.clear();
|
|
14474
14584
|
this.elements.forEach((element) => {
|
|
@@ -14641,16 +14751,16 @@ var Delta = class _Delta {
|
|
|
14641
14751
|
/**
|
|
14642
14752
|
* Merges two deltas into a new one.
|
|
14643
14753
|
*/
|
|
14644
|
-
static merge(delta1, delta2) {
|
|
14754
|
+
static merge(delta1, delta2, delta3 = _Delta.empty()) {
|
|
14645
14755
|
return _Delta.create(
|
|
14646
|
-
{ ...delta1.deleted, ...delta2.deleted },
|
|
14647
|
-
{ ...delta1.inserted, ...delta2.inserted }
|
|
14756
|
+
{ ...delta1.deleted, ...delta2.deleted, ...delta3.deleted },
|
|
14757
|
+
{ ...delta1.inserted, ...delta2.inserted, ...delta3.inserted }
|
|
14648
14758
|
);
|
|
14649
14759
|
}
|
|
14650
14760
|
/**
|
|
14651
14761
|
* Merges deleted and inserted object partials.
|
|
14652
14762
|
*/
|
|
14653
|
-
static mergeObjects(prev, added, removed) {
|
|
14763
|
+
static mergeObjects(prev, added, removed = {}) {
|
|
14654
14764
|
const cloned = { ...prev };
|
|
14655
14765
|
for (const key of Object.keys(removed)) {
|
|
14656
14766
|
delete cloned[key];
|
|
@@ -14871,6 +14981,9 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14871
14981
|
constructor(delta) {
|
|
14872
14982
|
this.delta = delta;
|
|
14873
14983
|
}
|
|
14984
|
+
static create(delta) {
|
|
14985
|
+
return new _AppStateDelta(delta);
|
|
14986
|
+
}
|
|
14874
14987
|
static calculate(prevAppState, nextAppState) {
|
|
14875
14988
|
const delta = Delta.calculate(
|
|
14876
14989
|
prevAppState,
|
|
@@ -14893,18 +15006,65 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14893
15006
|
return new _AppStateDelta(inversedDelta);
|
|
14894
15007
|
}
|
|
14895
15008
|
squash(delta) {
|
|
14896
|
-
|
|
15009
|
+
if (delta.isEmpty()) {
|
|
15010
|
+
return this;
|
|
15011
|
+
}
|
|
15012
|
+
const mergedDeletedSelectedElementIds = Delta.mergeObjects(
|
|
15013
|
+
this.delta.deleted.selectedElementIds ?? {},
|
|
15014
|
+
delta.delta.deleted.selectedElementIds ?? {}
|
|
15015
|
+
);
|
|
15016
|
+
const mergedInsertedSelectedElementIds = Delta.mergeObjects(
|
|
15017
|
+
this.delta.inserted.selectedElementIds ?? {},
|
|
15018
|
+
delta.delta.inserted.selectedElementIds ?? {}
|
|
15019
|
+
);
|
|
15020
|
+
const mergedDeletedSelectedGroupIds = Delta.mergeObjects(
|
|
15021
|
+
this.delta.deleted.selectedGroupIds ?? {},
|
|
15022
|
+
delta.delta.deleted.selectedGroupIds ?? {}
|
|
15023
|
+
);
|
|
15024
|
+
const mergedInsertedSelectedGroupIds = Delta.mergeObjects(
|
|
15025
|
+
this.delta.inserted.selectedGroupIds ?? {},
|
|
15026
|
+
delta.delta.inserted.selectedGroupIds ?? {}
|
|
15027
|
+
);
|
|
15028
|
+
const mergedDeletedLockedMultiSelections = Delta.mergeObjects(
|
|
15029
|
+
this.delta.deleted.lockedMultiSelections ?? {},
|
|
15030
|
+
delta.delta.deleted.lockedMultiSelections ?? {}
|
|
15031
|
+
);
|
|
15032
|
+
const mergedInsertedLockedMultiSelections = Delta.mergeObjects(
|
|
15033
|
+
this.delta.inserted.lockedMultiSelections ?? {},
|
|
15034
|
+
delta.delta.inserted.lockedMultiSelections ?? {}
|
|
15035
|
+
);
|
|
15036
|
+
const mergedInserted = {};
|
|
15037
|
+
const mergedDeleted = {};
|
|
15038
|
+
if (Object.keys(mergedDeletedSelectedElementIds).length || Object.keys(mergedInsertedSelectedElementIds).length) {
|
|
15039
|
+
mergedDeleted.selectedElementIds = mergedDeletedSelectedElementIds;
|
|
15040
|
+
mergedInserted.selectedElementIds = mergedInsertedSelectedElementIds;
|
|
15041
|
+
}
|
|
15042
|
+
if (Object.keys(mergedDeletedSelectedGroupIds).length || Object.keys(mergedInsertedSelectedGroupIds).length) {
|
|
15043
|
+
mergedDeleted.selectedGroupIds = mergedDeletedSelectedGroupIds;
|
|
15044
|
+
mergedInserted.selectedGroupIds = mergedInsertedSelectedGroupIds;
|
|
15045
|
+
}
|
|
15046
|
+
if (Object.keys(mergedDeletedLockedMultiSelections).length || Object.keys(mergedInsertedLockedMultiSelections).length) {
|
|
15047
|
+
mergedDeleted.lockedMultiSelections = mergedDeletedLockedMultiSelections;
|
|
15048
|
+
mergedInserted.lockedMultiSelections = mergedInsertedLockedMultiSelections;
|
|
15049
|
+
}
|
|
15050
|
+
this.delta = Delta.merge(
|
|
15051
|
+
this.delta,
|
|
15052
|
+
delta.delta,
|
|
15053
|
+
Delta.create(mergedDeleted, mergedInserted)
|
|
15054
|
+
);
|
|
14897
15055
|
return this;
|
|
14898
15056
|
}
|
|
14899
15057
|
applyTo(appState, nextElements) {
|
|
14900
15058
|
try {
|
|
14901
15059
|
const {
|
|
14902
15060
|
selectedElementIds: deletedSelectedElementIds = {},
|
|
14903
|
-
selectedGroupIds: deletedSelectedGroupIds = {}
|
|
15061
|
+
selectedGroupIds: deletedSelectedGroupIds = {},
|
|
15062
|
+
lockedMultiSelections: deletedLockedMultiSelections = {}
|
|
14904
15063
|
} = this.delta.deleted;
|
|
14905
15064
|
const {
|
|
14906
15065
|
selectedElementIds: insertedSelectedElementIds = {},
|
|
14907
15066
|
selectedGroupIds: insertedSelectedGroupIds = {},
|
|
15067
|
+
lockedMultiSelections: insertedLockedMultiSelections = {},
|
|
14908
15068
|
selectedLinearElement: insertedSelectedLinearElement,
|
|
14909
15069
|
...directlyApplicablePartial
|
|
14910
15070
|
} = this.delta.inserted;
|
|
@@ -14918,6 +15078,11 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14918
15078
|
insertedSelectedGroupIds,
|
|
14919
15079
|
deletedSelectedGroupIds
|
|
14920
15080
|
);
|
|
15081
|
+
const mergedLockedMultiSelections = Delta.mergeObjects(
|
|
15082
|
+
appState.lockedMultiSelections,
|
|
15083
|
+
insertedLockedMultiSelections,
|
|
15084
|
+
deletedLockedMultiSelections
|
|
15085
|
+
);
|
|
14921
15086
|
const selectedLinearElement = insertedSelectedLinearElement && nextElements.has(insertedSelectedLinearElement.elementId) ? new LinearElementEditor(
|
|
14922
15087
|
nextElements.get(
|
|
14923
15088
|
insertedSelectedLinearElement.elementId
|
|
@@ -14930,6 +15095,7 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14930
15095
|
...directlyApplicablePartial,
|
|
14931
15096
|
selectedElementIds: mergedSelectedElementIds,
|
|
14932
15097
|
selectedGroupIds: mergedSelectedGroupIds,
|
|
15098
|
+
lockedMultiSelections: mergedLockedMultiSelections,
|
|
14933
15099
|
selectedLinearElement: typeof insertedSelectedLinearElement !== "undefined" ? selectedLinearElement : appState.selectedLinearElement
|
|
14934
15100
|
};
|
|
14935
15101
|
const constainsVisibleChanges = this.filterInvisibleChanges(
|
|
@@ -15133,12 +15299,6 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
15133
15299
|
"lockedMultiSelections",
|
|
15134
15300
|
(prevValue) => prevValue ?? {}
|
|
15135
15301
|
);
|
|
15136
|
-
Delta.diffObjects(
|
|
15137
|
-
deleted,
|
|
15138
|
-
inserted,
|
|
15139
|
-
"activeLockedId",
|
|
15140
|
-
(prevValue) => prevValue ?? null
|
|
15141
|
-
);
|
|
15142
15302
|
} catch (e) {
|
|
15143
15303
|
console.error(`Couldn't postprocess appstate change deltas.`);
|
|
15144
15304
|
if (isTestEnv8() || isDevEnv7()) {
|
|
@@ -15217,13 +15377,17 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15217
15377
|
static satisfiesCommmonInvariants = ({
|
|
15218
15378
|
deleted,
|
|
15219
15379
|
inserted
|
|
15220
|
-
}) =>
|
|
15221
|
-
Number.isInteger(deleted.version) && Number.isInteger(inserted.version) && // versions should be positive, zero included
|
|
15380
|
+
}) => !!// versions are required integers
|
|
15381
|
+
(Number.isInteger(deleted.version) && Number.isInteger(inserted.version) && // versions should be positive, zero included
|
|
15222
15382
|
deleted.version >= 0 && inserted.version >= 0 && // versions should never be the same
|
|
15223
15383
|
deleted.version !== inserted.version);
|
|
15384
|
+
static satisfiesUniqueInvariants = (elementsDelta, id) => {
|
|
15385
|
+
const { added, removed, updated } = elementsDelta;
|
|
15386
|
+
return [added[id], removed[id], updated[id]].filter(Boolean).length === 1;
|
|
15387
|
+
};
|
|
15224
15388
|
static validate(elementsDelta, type, satifiesSpecialInvariants) {
|
|
15225
15389
|
for (const [id, delta] of Object.entries(elementsDelta[type])) {
|
|
15226
|
-
if (!this.satisfiesCommmonInvariants(delta) || !satifiesSpecialInvariants(delta)) {
|
|
15390
|
+
if (!this.satisfiesCommmonInvariants(delta) || !this.satisfiesUniqueInvariants(elementsDelta, id) || !satifiesSpecialInvariants(delta)) {
|
|
15227
15391
|
console.error(
|
|
15228
15392
|
`Broken invariant for "${type}" delta, element "${id}", delta:`,
|
|
15229
15393
|
delta
|
|
@@ -15250,7 +15414,7 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15250
15414
|
for (const prevElement of prevElements.values()) {
|
|
15251
15415
|
const nextElement = nextElements.get(prevElement.id);
|
|
15252
15416
|
if (!nextElement) {
|
|
15253
|
-
const deleted = { ...prevElement
|
|
15417
|
+
const deleted = { ...prevElement };
|
|
15254
15418
|
const inserted = {
|
|
15255
15419
|
isDeleted: true,
|
|
15256
15420
|
version: prevElement.version + 1,
|
|
@@ -15261,7 +15425,11 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15261
15425
|
inserted,
|
|
15262
15426
|
_ElementsDelta.stripIrrelevantProps
|
|
15263
15427
|
);
|
|
15264
|
-
|
|
15428
|
+
if (!prevElement.isDeleted) {
|
|
15429
|
+
removed[prevElement.id] = delta;
|
|
15430
|
+
} else {
|
|
15431
|
+
updated[prevElement.id] = delta;
|
|
15432
|
+
}
|
|
15265
15433
|
}
|
|
15266
15434
|
}
|
|
15267
15435
|
for (const nextElement of nextElements.values()) {
|
|
@@ -15273,15 +15441,18 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15273
15441
|
versionNonce: randomInteger4()
|
|
15274
15442
|
};
|
|
15275
15443
|
const inserted = {
|
|
15276
|
-
...nextElement
|
|
15277
|
-
isDeleted: false
|
|
15444
|
+
...nextElement
|
|
15278
15445
|
};
|
|
15279
15446
|
const delta = Delta.create(
|
|
15280
15447
|
deleted,
|
|
15281
15448
|
inserted,
|
|
15282
15449
|
_ElementsDelta.stripIrrelevantProps
|
|
15283
15450
|
);
|
|
15284
|
-
|
|
15451
|
+
if (!nextElement.isDeleted) {
|
|
15452
|
+
added[nextElement.id] = delta;
|
|
15453
|
+
} else {
|
|
15454
|
+
updated[nextElement.id] = delta;
|
|
15455
|
+
}
|
|
15285
15456
|
continue;
|
|
15286
15457
|
}
|
|
15287
15458
|
if (prevElement.versionNonce !== nextElement.versionNonce) {
|
|
@@ -15302,9 +15473,7 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15302
15473
|
}
|
|
15303
15474
|
continue;
|
|
15304
15475
|
}
|
|
15305
|
-
|
|
15306
|
-
updated[nextElement.id] = delta;
|
|
15307
|
-
}
|
|
15476
|
+
updated[nextElement.id] = delta;
|
|
15308
15477
|
}
|
|
15309
15478
|
}
|
|
15310
15479
|
return _ElementsDelta.create(added, removed, updated);
|
|
@@ -15394,26 +15563,30 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15394
15563
|
// redistribute the deltas as `isDeleted` could have been updated
|
|
15395
15564
|
});
|
|
15396
15565
|
}
|
|
15397
|
-
applyTo(elements, snapshot = StoreSnapshot.empty().elements, options
|
|
15398
|
-
excludedProperties: /* @__PURE__ */ new Set()
|
|
15399
|
-
}) {
|
|
15566
|
+
applyTo(elements, snapshot = StoreSnapshot.empty().elements, options) {
|
|
15400
15567
|
let nextElements = new Map(elements);
|
|
15401
15568
|
let changedElements;
|
|
15402
15569
|
const flags = {
|
|
15403
15570
|
containsVisibleDifference: false,
|
|
15404
|
-
containsZindexDifference: false
|
|
15571
|
+
containsZindexDifference: false,
|
|
15572
|
+
applyDirection: void 0
|
|
15405
15573
|
};
|
|
15406
15574
|
try {
|
|
15407
15575
|
const applyDeltas = _ElementsDelta.createApplier(
|
|
15576
|
+
elements,
|
|
15408
15577
|
nextElements,
|
|
15409
15578
|
snapshot,
|
|
15410
|
-
|
|
15411
|
-
|
|
15579
|
+
flags,
|
|
15580
|
+
options
|
|
15412
15581
|
);
|
|
15413
15582
|
const addedElements = applyDeltas(this.added);
|
|
15414
15583
|
const removedElements = applyDeltas(this.removed);
|
|
15415
15584
|
const updatedElements = applyDeltas(this.updated);
|
|
15416
|
-
const affectedElements = this.resolveConflicts(
|
|
15585
|
+
const affectedElements = this.resolveConflicts(
|
|
15586
|
+
elements,
|
|
15587
|
+
nextElements,
|
|
15588
|
+
flags.applyDirection
|
|
15589
|
+
);
|
|
15417
15590
|
changedElements = new Map([
|
|
15418
15591
|
...addedElements,
|
|
15419
15592
|
...removedElements,
|
|
@@ -15433,9 +15606,7 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15433
15606
|
changedElements,
|
|
15434
15607
|
flags
|
|
15435
15608
|
);
|
|
15436
|
-
|
|
15437
|
-
_ElementsDelta.redrawTextBoundingBoxes(tempScene, changedElements);
|
|
15438
|
-
_ElementsDelta.redrawBoundArrows(tempScene, changedElements);
|
|
15609
|
+
_ElementsDelta.redrawElements(nextElements, changedElements);
|
|
15439
15610
|
} catch (e) {
|
|
15440
15611
|
console.error(
|
|
15441
15612
|
`Couldn't mutate elements after applying elements change`,
|
|
@@ -15449,34 +15620,81 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15449
15620
|
}
|
|
15450
15621
|
}
|
|
15451
15622
|
squash(delta) {
|
|
15623
|
+
if (delta.isEmpty()) {
|
|
15624
|
+
return this;
|
|
15625
|
+
}
|
|
15452
15626
|
const { added, removed, updated } = delta;
|
|
15627
|
+
const mergeBoundElements = (prevDelta, nextDelta) => {
|
|
15628
|
+
const mergedDeletedBoundElements = Delta.mergeArrays(
|
|
15629
|
+
prevDelta.deleted.boundElements ?? [],
|
|
15630
|
+
nextDelta.deleted.boundElements ?? [],
|
|
15631
|
+
void 0,
|
|
15632
|
+
(x) => x.id
|
|
15633
|
+
) ?? [];
|
|
15634
|
+
const mergedInsertedBoundElements = Delta.mergeArrays(
|
|
15635
|
+
prevDelta.inserted.boundElements ?? [],
|
|
15636
|
+
nextDelta.inserted.boundElements ?? [],
|
|
15637
|
+
void 0,
|
|
15638
|
+
(x) => x.id
|
|
15639
|
+
) ?? [];
|
|
15640
|
+
if (!mergedDeletedBoundElements.length && !mergedInsertedBoundElements.length) {
|
|
15641
|
+
return;
|
|
15642
|
+
}
|
|
15643
|
+
return Delta.create(
|
|
15644
|
+
{
|
|
15645
|
+
boundElements: mergedDeletedBoundElements
|
|
15646
|
+
},
|
|
15647
|
+
{
|
|
15648
|
+
boundElements: mergedInsertedBoundElements
|
|
15649
|
+
}
|
|
15650
|
+
);
|
|
15651
|
+
};
|
|
15453
15652
|
for (const [id, nextDelta] of Object.entries(added)) {
|
|
15454
|
-
const prevDelta = this.added[id];
|
|
15653
|
+
const prevDelta = this.added[id] ?? this.removed[id] ?? this.updated[id];
|
|
15455
15654
|
if (!prevDelta) {
|
|
15456
15655
|
this.added[id] = nextDelta;
|
|
15457
15656
|
} else {
|
|
15458
|
-
|
|
15657
|
+
const mergedDelta = mergeBoundElements(prevDelta, nextDelta);
|
|
15658
|
+
delete this.removed[id];
|
|
15659
|
+
delete this.updated[id];
|
|
15660
|
+
this.added[id] = Delta.merge(prevDelta, nextDelta, mergedDelta);
|
|
15459
15661
|
}
|
|
15460
15662
|
}
|
|
15461
15663
|
for (const [id, nextDelta] of Object.entries(removed)) {
|
|
15462
|
-
const prevDelta = this.removed[id];
|
|
15664
|
+
const prevDelta = this.added[id] ?? this.removed[id] ?? this.updated[id];
|
|
15463
15665
|
if (!prevDelta) {
|
|
15464
15666
|
this.removed[id] = nextDelta;
|
|
15465
15667
|
} else {
|
|
15466
|
-
|
|
15668
|
+
const mergedDelta = mergeBoundElements(prevDelta, nextDelta);
|
|
15669
|
+
delete this.added[id];
|
|
15670
|
+
delete this.updated[id];
|
|
15671
|
+
this.removed[id] = Delta.merge(prevDelta, nextDelta, mergedDelta);
|
|
15467
15672
|
}
|
|
15468
15673
|
}
|
|
15469
15674
|
for (const [id, nextDelta] of Object.entries(updated)) {
|
|
15470
|
-
const prevDelta = this.updated[id];
|
|
15675
|
+
const prevDelta = this.added[id] ?? this.removed[id] ?? this.updated[id];
|
|
15471
15676
|
if (!prevDelta) {
|
|
15472
15677
|
this.updated[id] = nextDelta;
|
|
15473
15678
|
} else {
|
|
15474
|
-
|
|
15679
|
+
const mergedDelta = mergeBoundElements(prevDelta, nextDelta);
|
|
15680
|
+
const updatedDelta = Delta.merge(prevDelta, nextDelta, mergedDelta);
|
|
15681
|
+
if (prevDelta === this.added[id]) {
|
|
15682
|
+
this.added[id] = updatedDelta;
|
|
15683
|
+
} else if (prevDelta === this.removed[id]) {
|
|
15684
|
+
this.removed[id] = updatedDelta;
|
|
15685
|
+
} else {
|
|
15686
|
+
this.updated[id] = updatedDelta;
|
|
15687
|
+
}
|
|
15475
15688
|
}
|
|
15476
15689
|
}
|
|
15690
|
+
if (isTestEnv8() || isDevEnv7()) {
|
|
15691
|
+
_ElementsDelta.validate(this, "added", _ElementsDelta.satisfiesAddition);
|
|
15692
|
+
_ElementsDelta.validate(this, "removed", _ElementsDelta.satisfiesRemoval);
|
|
15693
|
+
_ElementsDelta.validate(this, "updated", _ElementsDelta.satisfiesUpdate);
|
|
15694
|
+
}
|
|
15477
15695
|
return this;
|
|
15478
15696
|
}
|
|
15479
|
-
static createApplier = (nextElements, snapshot,
|
|
15697
|
+
static createApplier = (prevElements, nextElements, snapshot, flags, options) => (deltas) => {
|
|
15480
15698
|
const getElement = _ElementsDelta.createGetter(
|
|
15481
15699
|
nextElements,
|
|
15482
15700
|
snapshot,
|
|
@@ -15485,14 +15703,20 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15485
15703
|
return Object.entries(deltas).reduce((acc, [id, delta]) => {
|
|
15486
15704
|
const element = getElement(id, delta.inserted);
|
|
15487
15705
|
if (element) {
|
|
15488
|
-
const
|
|
15706
|
+
const nextElement = _ElementsDelta.applyDelta(
|
|
15489
15707
|
element,
|
|
15490
15708
|
delta,
|
|
15491
|
-
|
|
15492
|
-
|
|
15709
|
+
flags,
|
|
15710
|
+
options
|
|
15493
15711
|
);
|
|
15494
|
-
nextElements.set(
|
|
15495
|
-
acc.set(
|
|
15712
|
+
nextElements.set(nextElement.id, nextElement);
|
|
15713
|
+
acc.set(nextElement.id, nextElement);
|
|
15714
|
+
if (!flags.applyDirection) {
|
|
15715
|
+
const prevElement = prevElements.get(id);
|
|
15716
|
+
if (prevElement) {
|
|
15717
|
+
flags.applyDirection = prevElement.version > nextElement.version ? "backward" : "forward";
|
|
15718
|
+
}
|
|
15719
|
+
}
|
|
15496
15720
|
}
|
|
15497
15721
|
return acc;
|
|
15498
15722
|
}, /* @__PURE__ */ new Map());
|
|
@@ -15517,13 +15741,13 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15517
15741
|
}
|
|
15518
15742
|
return element;
|
|
15519
15743
|
};
|
|
15520
|
-
static applyDelta(element, delta,
|
|
15744
|
+
static applyDelta(element, delta, flags, options) {
|
|
15521
15745
|
const directlyApplicablePartial = {};
|
|
15522
15746
|
for (const key of Object.keys(delta.inserted)) {
|
|
15523
15747
|
if (key === "boundElements") {
|
|
15524
15748
|
continue;
|
|
15525
15749
|
}
|
|
15526
|
-
if (options
|
|
15750
|
+
if (options?.excludedProperties?.has(key)) {
|
|
15527
15751
|
continue;
|
|
15528
15752
|
}
|
|
15529
15753
|
const value = delta.inserted[key];
|
|
@@ -15551,7 +15775,7 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15551
15775
|
if (!flags.containsZindexDifference) {
|
|
15552
15776
|
flags.containsZindexDifference = delta.deleted.index !== delta.inserted.index;
|
|
15553
15777
|
}
|
|
15554
|
-
return newElementWith(element, directlyApplicablePartial);
|
|
15778
|
+
return newElementWith(element, directlyApplicablePartial, true);
|
|
15555
15779
|
}
|
|
15556
15780
|
/**
|
|
15557
15781
|
* Check for visible changes regardless of whether they were removed, added or updated.
|
|
@@ -15576,25 +15800,32 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15576
15800
|
*
|
|
15577
15801
|
* @returns all elements affected by the conflict resolution
|
|
15578
15802
|
*/
|
|
15579
|
-
resolveConflicts(prevElements, nextElements) {
|
|
15803
|
+
resolveConflicts(prevElements, nextElements, applyDirection = "forward") {
|
|
15580
15804
|
const nextAffectedElements = /* @__PURE__ */ new Map();
|
|
15581
15805
|
const updater = (element, updates) => {
|
|
15582
15806
|
const nextElement = nextElements.get(element.id);
|
|
15583
15807
|
if (!nextElement) {
|
|
15584
15808
|
return;
|
|
15585
15809
|
}
|
|
15810
|
+
const prevElement = prevElements.get(element.id);
|
|
15811
|
+
const nextVersion = applyDirection === "forward" ? nextElement.version + 1 : nextElement.version - 1;
|
|
15812
|
+
const elementUpdates = updates;
|
|
15586
15813
|
let affectedElement;
|
|
15587
|
-
if (
|
|
15814
|
+
if (prevElement === nextElement) {
|
|
15588
15815
|
affectedElement = newElementWith(
|
|
15589
15816
|
nextElement,
|
|
15590
|
-
|
|
15817
|
+
{
|
|
15818
|
+
...elementUpdates,
|
|
15819
|
+
version: nextVersion
|
|
15820
|
+
},
|
|
15821
|
+
true
|
|
15591
15822
|
);
|
|
15592
15823
|
} else {
|
|
15593
|
-
affectedElement = mutateElement(
|
|
15594
|
-
|
|
15595
|
-
|
|
15596
|
-
|
|
15597
|
-
);
|
|
15824
|
+
affectedElement = mutateElement(nextElement, nextElements, {
|
|
15825
|
+
...elementUpdates,
|
|
15826
|
+
// don't modify the version further, if it's already different
|
|
15827
|
+
version: prevElement?.version !== nextElement.version ? nextElement.version : nextVersion
|
|
15828
|
+
});
|
|
15598
15829
|
}
|
|
15599
15830
|
nextAffectedElements.set(affectedElement.id, affectedElement);
|
|
15600
15831
|
nextElements.set(affectedElement.id, affectedElement);
|
|
@@ -15657,6 +15888,20 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15657
15888
|
);
|
|
15658
15889
|
BindableElement.rebindAffected(nextElements, nextElement(), updater);
|
|
15659
15890
|
}
|
|
15891
|
+
static redrawElements(nextElements, changedElements) {
|
|
15892
|
+
try {
|
|
15893
|
+
const tempScene = new Scene(nextElements, { skipValidation: true });
|
|
15894
|
+
_ElementsDelta.redrawTextBoundingBoxes(tempScene, changedElements);
|
|
15895
|
+
_ElementsDelta.redrawBoundArrows(tempScene, changedElements);
|
|
15896
|
+
} catch (e) {
|
|
15897
|
+
console.error(`Couldn't redraw elements`, e);
|
|
15898
|
+
if (isTestEnv8() || isDevEnv7()) {
|
|
15899
|
+
throw e;
|
|
15900
|
+
}
|
|
15901
|
+
} finally {
|
|
15902
|
+
return nextElements;
|
|
15903
|
+
}
|
|
15904
|
+
}
|
|
15660
15905
|
static redrawTextBoundingBoxes(scene, changed) {
|
|
15661
15906
|
const elements = scene.getNonDeletedElementsMap();
|
|
15662
15907
|
const boxesToRedraw = /* @__PURE__ */ new Map();
|
|
@@ -16748,8 +16993,8 @@ var embeddableURLValidator = (url, validateEmbeddable) => {
|
|
|
16748
16993
|
|
|
16749
16994
|
// src/flowchart.ts
|
|
16750
16995
|
init_define_import_meta_env();
|
|
16751
|
-
import { KEYS as KEYS3, invariant as
|
|
16752
|
-
import { pointFrom as
|
|
16996
|
+
import { KEYS as KEYS3, invariant as invariant9, toBrandedType as toBrandedType2 } from "@excalidraw/common";
|
|
16997
|
+
import { pointFrom as pointFrom15 } from "@excalidraw/math";
|
|
16753
16998
|
var VERTICAL_OFFSET = 100;
|
|
16754
16999
|
var HORIZONTAL_OFFSET = 100;
|
|
16755
17000
|
var getLinkDirectionFromKey = (key) => {
|
|
@@ -16778,7 +17023,7 @@ var getNodeRelatives = (type, node, elementsMap, direction) => {
|
|
|
16778
17023
|
if (!relative) {
|
|
16779
17024
|
return acc;
|
|
16780
17025
|
}
|
|
16781
|
-
|
|
17026
|
+
invariant9(
|
|
16782
17027
|
isBindableElement(relative),
|
|
16783
17028
|
"not an ExcalidrawBindableElement"
|
|
16784
17029
|
);
|
|
@@ -16894,7 +17139,7 @@ var addNewNode = (element, appState, direction, scene) => {
|
|
|
16894
17139
|
fillStyle: element.fillStyle,
|
|
16895
17140
|
strokeStyle: element.strokeStyle
|
|
16896
17141
|
});
|
|
16897
|
-
|
|
17142
|
+
invariant9(
|
|
16898
17143
|
isFlowchartNodeElement(nextNode),
|
|
16899
17144
|
"not an ExcalidrawFlowchartNodeElement"
|
|
16900
17145
|
);
|
|
@@ -16952,7 +17197,7 @@ var addNewNodes = (startNode, appState, direction, scene, numberOfNodes) => {
|
|
|
16952
17197
|
fillStyle: startNode.fillStyle,
|
|
16953
17198
|
strokeStyle: startNode.strokeStyle
|
|
16954
17199
|
});
|
|
16955
|
-
|
|
17200
|
+
invariant9(
|
|
16956
17201
|
isFlowchartNodeElement(nextNode),
|
|
16957
17202
|
"not an ExcalidrawFlowchartNodeElement"
|
|
16958
17203
|
);
|
|
@@ -17029,7 +17274,7 @@ var createBindingArrow = (startBindingElement, endBindingElement, direction, app
|
|
|
17029
17274
|
strokeWidth: startBindingElement.strokeWidth,
|
|
17030
17275
|
opacity: startBindingElement.opacity,
|
|
17031
17276
|
roughness: startBindingElement.roughness,
|
|
17032
|
-
points: [
|
|
17277
|
+
points: [pointFrom15(0, 0), pointFrom15(endX, endY)],
|
|
17033
17278
|
elbowed: true
|
|
17034
17279
|
});
|
|
17035
17280
|
const elementsMap = scene.getNonDeletedElementsMap();
|
|
@@ -17178,7 +17423,7 @@ var FlowChartCreator = class {
|
|
|
17178
17423
|
}
|
|
17179
17424
|
if (startNode.frameId) {
|
|
17180
17425
|
const frame = elementsMap.get(startNode.frameId);
|
|
17181
|
-
|
|
17426
|
+
invariant9(
|
|
17182
17427
|
frame && isFrameElement(frame),
|
|
17183
17428
|
"not an ExcalidrawFrameElement"
|
|
17184
17429
|
);
|
|
@@ -17313,13 +17558,80 @@ var normalizeSVG = (SVGString) => {
|
|
|
17313
17558
|
}
|
|
17314
17559
|
};
|
|
17315
17560
|
|
|
17561
|
+
// src/positionElementsOnGrid.ts
|
|
17562
|
+
init_define_import_meta_env();
|
|
17563
|
+
var positionElementsOnGrid = (elements, centerX, centerY, padding = 50) => {
|
|
17564
|
+
if (!elements || elements.length === 0) {
|
|
17565
|
+
return [];
|
|
17566
|
+
}
|
|
17567
|
+
const res = [];
|
|
17568
|
+
const atomicUnits = Array.isArray(elements[0]) ? elements : elements.map((element) => [element]);
|
|
17569
|
+
const numUnits = atomicUnits.length;
|
|
17570
|
+
const numColumns = Math.max(1, Math.ceil(Math.sqrt(numUnits)));
|
|
17571
|
+
const rows = [];
|
|
17572
|
+
for (let i = 0; i < numUnits; i += numColumns) {
|
|
17573
|
+
rows.push(atomicUnits.slice(i, i + numColumns));
|
|
17574
|
+
}
|
|
17575
|
+
let totalGridActualHeight = 0;
|
|
17576
|
+
const rowProperties = rows.map((rowUnits) => {
|
|
17577
|
+
let rowWidth = 0;
|
|
17578
|
+
let maxUnitHeightInRow = 0;
|
|
17579
|
+
const unitBounds = rowUnits.map((unit) => {
|
|
17580
|
+
const [minX, minY, maxX, maxY] = getCommonBounds(unit);
|
|
17581
|
+
return {
|
|
17582
|
+
elements: unit,
|
|
17583
|
+
bounds: [minX, minY, maxX, maxY],
|
|
17584
|
+
width: maxX - minX,
|
|
17585
|
+
height: maxY - minY
|
|
17586
|
+
};
|
|
17587
|
+
});
|
|
17588
|
+
unitBounds.forEach((unitBound, index) => {
|
|
17589
|
+
rowWidth += unitBound.width;
|
|
17590
|
+
if (index < unitBounds.length - 1) {
|
|
17591
|
+
rowWidth += padding;
|
|
17592
|
+
}
|
|
17593
|
+
if (unitBound.height > maxUnitHeightInRow) {
|
|
17594
|
+
maxUnitHeightInRow = unitBound.height;
|
|
17595
|
+
}
|
|
17596
|
+
});
|
|
17597
|
+
totalGridActualHeight += maxUnitHeightInRow;
|
|
17598
|
+
return {
|
|
17599
|
+
unitBounds,
|
|
17600
|
+
width: rowWidth,
|
|
17601
|
+
maxHeight: maxUnitHeightInRow
|
|
17602
|
+
};
|
|
17603
|
+
});
|
|
17604
|
+
const totalGridHeightWithPadding = totalGridActualHeight + Math.max(0, rows.length - 1) * padding;
|
|
17605
|
+
let currentY = centerY - totalGridHeightWithPadding / 2;
|
|
17606
|
+
rowProperties.forEach((rowProp) => {
|
|
17607
|
+
const { unitBounds, width: rowWidth, maxHeight: rowMaxHeight } = rowProp;
|
|
17608
|
+
let currentX = centerX - rowWidth / 2;
|
|
17609
|
+
unitBounds.forEach((unitBound) => {
|
|
17610
|
+
const [originalMinX, originalMinY] = unitBound.bounds;
|
|
17611
|
+
const offsetX = currentX - originalMinX;
|
|
17612
|
+
const offsetY = currentY - originalMinY;
|
|
17613
|
+
unitBound.elements.forEach((element) => {
|
|
17614
|
+
res.push(
|
|
17615
|
+
newElementWith(element, {
|
|
17616
|
+
x: element.x + offsetX,
|
|
17617
|
+
y: element.y + offsetY
|
|
17618
|
+
})
|
|
17619
|
+
);
|
|
17620
|
+
});
|
|
17621
|
+
currentX += unitBound.width + padding;
|
|
17622
|
+
});
|
|
17623
|
+
currentY += rowMaxHeight + padding;
|
|
17624
|
+
});
|
|
17625
|
+
return res;
|
|
17626
|
+
};
|
|
17627
|
+
|
|
17316
17628
|
// src/resizeElements.ts
|
|
17317
17629
|
init_define_import_meta_env();
|
|
17318
17630
|
import {
|
|
17319
17631
|
pointCenter as pointCenter3,
|
|
17320
17632
|
normalizeRadians as normalizeRadians2,
|
|
17321
|
-
pointFrom as
|
|
17322
|
-
pointRotateRads as
|
|
17633
|
+
pointFrom as pointFrom16,
|
|
17634
|
+
pointRotateRads as pointRotateRads13
|
|
17323
17635
|
} from "@excalidraw/math";
|
|
17324
17636
|
import {
|
|
17325
17637
|
MIN_FONT_SIZE,
|
|
@@ -17447,7 +17759,16 @@ var rotateSingleElement = (element, scene, pointerX, pointerY, shouldRotateWithD
|
|
|
17447
17759
|
if (boundTextElementId) {
|
|
17448
17760
|
const textElement = scene.getElement(boundTextElementId);
|
|
17449
17761
|
if (textElement && !isArrowElement(element)) {
|
|
17450
|
-
|
|
17762
|
+
const { x, y } = computeBoundTextPosition(
|
|
17763
|
+
element,
|
|
17764
|
+
textElement,
|
|
17765
|
+
scene.getNonDeletedElementsMap()
|
|
17766
|
+
);
|
|
17767
|
+
scene.mutateElement(textElement, {
|
|
17768
|
+
angle,
|
|
17769
|
+
x,
|
|
17770
|
+
y
|
|
17771
|
+
});
|
|
17451
17772
|
}
|
|
17452
17773
|
}
|
|
17453
17774
|
};
|
|
@@ -17484,7 +17805,7 @@ var resizeSingleTextElement = (origElement, element, scene, transformHandleType,
|
|
|
17484
17805
|
return;
|
|
17485
17806
|
}
|
|
17486
17807
|
if (transformHandleType.includes("n") || transformHandleType.includes("s")) {
|
|
17487
|
-
const previousOrigin =
|
|
17808
|
+
const previousOrigin = pointFrom16(origElement.x, origElement.y);
|
|
17488
17809
|
const newOrigin = getResizedOrigin(
|
|
17489
17810
|
previousOrigin,
|
|
17490
17811
|
origElement.width,
|
|
@@ -17525,7 +17846,7 @@ var resizeSingleTextElement = (origElement, element, scene, transformHandleType,
|
|
|
17525
17846
|
element.lineHeight
|
|
17526
17847
|
);
|
|
17527
17848
|
const newHeight = metrics2.height;
|
|
17528
|
-
const previousOrigin =
|
|
17849
|
+
const previousOrigin = pointFrom16(origElement.x, origElement.y);
|
|
17529
17850
|
const newOrigin = getResizedOrigin(
|
|
17530
17851
|
previousOrigin,
|
|
17531
17852
|
origElement.width,
|
|
@@ -17561,9 +17882,9 @@ var rotateMultipleElements = (originalElements, elements, scene, pointerX, point
|
|
|
17561
17882
|
const cx = (x1 + x2) / 2;
|
|
17562
17883
|
const cy = (y1 + y2) / 2;
|
|
17563
17884
|
const origAngle = originalElements.get(element.id)?.angle ?? element.angle;
|
|
17564
|
-
const [rotatedCX, rotatedCY] =
|
|
17565
|
-
|
|
17566
|
-
|
|
17885
|
+
const [rotatedCX, rotatedCY] = pointRotateRads13(
|
|
17886
|
+
pointFrom16(cx, cy),
|
|
17887
|
+
pointFrom16(centerX, centerY),
|
|
17567
17888
|
centerAngle + origAngle - element.angle
|
|
17568
17889
|
);
|
|
17569
17890
|
const updates = isElbowArrow(element) ? {
|
|
@@ -17580,9 +17901,14 @@ var rotateMultipleElements = (originalElements, elements, scene, pointerX, point
|
|
|
17580
17901
|
});
|
|
17581
17902
|
const boundText = getBoundTextElement(element, elementsMap);
|
|
17582
17903
|
if (boundText && !isArrowElement(element)) {
|
|
17904
|
+
const { x, y } = computeBoundTextPosition(
|
|
17905
|
+
element,
|
|
17906
|
+
boundText,
|
|
17907
|
+
elementsMap
|
|
17908
|
+
);
|
|
17583
17909
|
scene.mutateElement(boundText, {
|
|
17584
|
-
x
|
|
17585
|
-
y
|
|
17910
|
+
x,
|
|
17911
|
+
y,
|
|
17586
17912
|
angle: normalizeRadians2(centerAngle + origAngle)
|
|
17587
17913
|
});
|
|
17588
17914
|
}
|
|
@@ -17595,44 +17921,44 @@ var getResizeOffsetXY = (transformHandleType, selectedElements, elementsMap, x,
|
|
|
17595
17921
|
const cx = (x1 + x2) / 2;
|
|
17596
17922
|
const cy = (y1 + y2) / 2;
|
|
17597
17923
|
const angle = selectedElements.length === 1 ? selectedElements[0].angle : 0;
|
|
17598
|
-
[x, y] =
|
|
17599
|
-
|
|
17600
|
-
|
|
17924
|
+
[x, y] = pointRotateRads13(
|
|
17925
|
+
pointFrom16(x, y),
|
|
17926
|
+
pointFrom16(cx, cy),
|
|
17601
17927
|
-angle
|
|
17602
17928
|
);
|
|
17603
17929
|
switch (transformHandleType) {
|
|
17604
17930
|
case "n":
|
|
17605
|
-
return
|
|
17606
|
-
|
|
17607
|
-
|
|
17931
|
+
return pointRotateRads13(
|
|
17932
|
+
pointFrom16(x - (x1 + x2) / 2, y - y1),
|
|
17933
|
+
pointFrom16(0, 0),
|
|
17608
17934
|
angle
|
|
17609
17935
|
);
|
|
17610
17936
|
case "s":
|
|
17611
|
-
return
|
|
17612
|
-
|
|
17613
|
-
|
|
17937
|
+
return pointRotateRads13(
|
|
17938
|
+
pointFrom16(x - (x1 + x2) / 2, y - y2),
|
|
17939
|
+
pointFrom16(0, 0),
|
|
17614
17940
|
angle
|
|
17615
17941
|
);
|
|
17616
17942
|
case "w":
|
|
17617
|
-
return
|
|
17618
|
-
|
|
17619
|
-
|
|
17943
|
+
return pointRotateRads13(
|
|
17944
|
+
pointFrom16(x - x1, y - (y1 + y2) / 2),
|
|
17945
|
+
pointFrom16(0, 0),
|
|
17620
17946
|
angle
|
|
17621
17947
|
);
|
|
17622
17948
|
case "e":
|
|
17623
|
-
return
|
|
17624
|
-
|
|
17625
|
-
|
|
17949
|
+
return pointRotateRads13(
|
|
17950
|
+
pointFrom16(x - x2, y - (y1 + y2) / 2),
|
|
17951
|
+
pointFrom16(0, 0),
|
|
17626
17952
|
angle
|
|
17627
17953
|
);
|
|
17628
17954
|
case "nw":
|
|
17629
|
-
return
|
|
17955
|
+
return pointRotateRads13(pointFrom16(x - x1, y - y1), pointFrom16(0, 0), angle);
|
|
17630
17956
|
case "ne":
|
|
17631
|
-
return
|
|
17957
|
+
return pointRotateRads13(pointFrom16(x - x2, y - y1), pointFrom16(0, 0), angle);
|
|
17632
17958
|
case "sw":
|
|
17633
|
-
return
|
|
17959
|
+
return pointRotateRads13(pointFrom16(x - x1, y - y2), pointFrom16(0, 0), angle);
|
|
17634
17960
|
case "se":
|
|
17635
|
-
return
|
|
17961
|
+
return pointRotateRads13(pointFrom16(x - x2, y - y2), pointFrom16(0, 0), angle);
|
|
17636
17962
|
default:
|
|
17637
17963
|
return [0, 0];
|
|
17638
17964
|
}
|
|
@@ -17795,10 +18121,10 @@ var resizeSingleElement = (nextWidth, nextHeight, latestElement, origElement, or
|
|
|
17795
18121
|
nextHeight,
|
|
17796
18122
|
true
|
|
17797
18123
|
);
|
|
17798
|
-
let previousOrigin =
|
|
18124
|
+
let previousOrigin = pointFrom16(origElement.x, origElement.y);
|
|
17799
18125
|
if (isLinearElement(origElement)) {
|
|
17800
18126
|
const [x1, y1] = getElementBounds(origElement, originalElementsMap);
|
|
17801
|
-
previousOrigin =
|
|
18127
|
+
previousOrigin = pointFrom16(x1, y1);
|
|
17802
18128
|
}
|
|
17803
18129
|
const newOrigin = getResizedOrigin(
|
|
17804
18130
|
previousOrigin,
|
|
@@ -17821,7 +18147,7 @@ var resizeSingleElement = (nextWidth, nextHeight, latestElement, origElement, or
|
|
|
17821
18147
|
newOrigin.x += scaledX;
|
|
17822
18148
|
newOrigin.y += scaledY;
|
|
17823
18149
|
rescaledPoints.points = rescaledPoints.points.map(
|
|
17824
|
-
(p) =>
|
|
18150
|
+
(p) => pointFrom16(p[0] - scaledX, p[1] - scaledY)
|
|
17825
18151
|
);
|
|
17826
18152
|
}
|
|
17827
18153
|
if (nextWidth < 0) {
|
|
@@ -17884,11 +18210,11 @@ var getNextSingleWidthAndHeightFromPointer = (latestElement, origElement, handle
|
|
|
17884
18210
|
origElement.height,
|
|
17885
18211
|
true
|
|
17886
18212
|
);
|
|
17887
|
-
const startTopLeft =
|
|
17888
|
-
const startBottomRight =
|
|
18213
|
+
const startTopLeft = pointFrom16(x1, y1);
|
|
18214
|
+
const startBottomRight = pointFrom16(x2, y2);
|
|
17889
18215
|
const startCenter = pointCenter3(startTopLeft, startBottomRight);
|
|
17890
|
-
const rotatedPointer =
|
|
17891
|
-
|
|
18216
|
+
const rotatedPointer = pointRotateRads13(
|
|
18217
|
+
pointFrom16(pointerX, pointerY),
|
|
17892
18218
|
startCenter,
|
|
17893
18219
|
-origElement.angle
|
|
17894
18220
|
);
|
|
@@ -18246,9 +18572,9 @@ var resizeMultipleElements = (selectedElements, elementsMap, handleDirection, sc
|
|
|
18246
18572
|
// src/resizeTest.ts
|
|
18247
18573
|
init_define_import_meta_env();
|
|
18248
18574
|
import {
|
|
18249
|
-
pointFrom as
|
|
18575
|
+
pointFrom as pointFrom18,
|
|
18250
18576
|
pointOnLineSegment,
|
|
18251
|
-
pointRotateRads as
|
|
18577
|
+
pointRotateRads as pointRotateRads15
|
|
18252
18578
|
} from "@excalidraw/math";
|
|
18253
18579
|
import { SIDE_RESIZING_THRESHOLD } from "@excalidraw/common";
|
|
18254
18580
|
|
|
@@ -18259,7 +18585,7 @@ import {
|
|
|
18259
18585
|
isAndroid,
|
|
18260
18586
|
isIOS
|
|
18261
18587
|
} from "@excalidraw/common";
|
|
18262
|
-
import { pointFrom as
|
|
18588
|
+
import { pointFrom as pointFrom17, pointRotateRads as pointRotateRads14 } from "@excalidraw/math";
|
|
18263
18589
|
var transformHandleSizes = {
|
|
18264
18590
|
mouse: 8,
|
|
18265
18591
|
pen: 16,
|
|
@@ -18300,9 +18626,9 @@ var OMIT_SIDES_FOR_LINE_BACKSLASH = {
|
|
|
18300
18626
|
w: true
|
|
18301
18627
|
};
|
|
18302
18628
|
var generateTransformHandle = (x, y, width, height, cx, cy, angle) => {
|
|
18303
|
-
const [xx, yy] =
|
|
18304
|
-
|
|
18305
|
-
|
|
18629
|
+
const [xx, yy] = pointRotateRads14(
|
|
18630
|
+
pointFrom17(x + width / 2, y + height / 2),
|
|
18631
|
+
pointFrom17(cx, cy),
|
|
18306
18632
|
angle
|
|
18307
18633
|
);
|
|
18308
18634
|
return [xx - width / 2, yy - height / 2, width, height];
|
|
@@ -18519,14 +18845,14 @@ var resizeTest = (element, elementsMap, appState, x, y, zoom, pointerType, devic
|
|
|
18519
18845
|
const SPACING = isImageElement(element) ? 0 : SIDE_RESIZING_THRESHOLD / zoom.value;
|
|
18520
18846
|
const ZOOMED_SIDE_RESIZING_THRESHOLD = SIDE_RESIZING_THRESHOLD / zoom.value;
|
|
18521
18847
|
const sides = getSelectionBorders(
|
|
18522
|
-
|
|
18523
|
-
|
|
18524
|
-
|
|
18848
|
+
pointFrom18(x1 - SPACING, y1 - SPACING),
|
|
18849
|
+
pointFrom18(x2 + SPACING, y2 + SPACING),
|
|
18850
|
+
pointFrom18(cx, cy),
|
|
18525
18851
|
element.angle
|
|
18526
18852
|
);
|
|
18527
18853
|
for (const [dir, side] of Object.entries(sides)) {
|
|
18528
18854
|
if (pointOnLineSegment(
|
|
18529
|
-
|
|
18855
|
+
pointFrom18(x, y),
|
|
18530
18856
|
side,
|
|
18531
18857
|
ZOOMED_SIDE_RESIZING_THRESHOLD
|
|
18532
18858
|
)) {
|
|
@@ -18575,14 +18901,14 @@ var getTransformHandleTypeFromCoords = ([x1, y1, x2, y2], scenePointerX, scenePo
|
|
|
18575
18901
|
const cy = (y1 + y2) / 2;
|
|
18576
18902
|
const SPACING = SIDE_RESIZING_THRESHOLD / zoom.value;
|
|
18577
18903
|
const sides = getSelectionBorders(
|
|
18578
|
-
|
|
18579
|
-
|
|
18580
|
-
|
|
18904
|
+
pointFrom18(x1 - SPACING, y1 - SPACING),
|
|
18905
|
+
pointFrom18(x2 + SPACING, y2 + SPACING),
|
|
18906
|
+
pointFrom18(cx, cy),
|
|
18581
18907
|
0
|
|
18582
18908
|
);
|
|
18583
18909
|
for (const [dir, side] of Object.entries(sides)) {
|
|
18584
18910
|
if (pointOnLineSegment(
|
|
18585
|
-
|
|
18911
|
+
pointFrom18(scenePointerX, scenePointerY),
|
|
18586
18912
|
side,
|
|
18587
18913
|
SPACING
|
|
18588
18914
|
)) {
|
|
@@ -18639,10 +18965,10 @@ var getCursorForResizingElement = (resizingElement) => {
|
|
|
18639
18965
|
return cursor ? `${cursor}-resize` : "";
|
|
18640
18966
|
};
|
|
18641
18967
|
var getSelectionBorders = ([x1, y1], [x2, y2], center, angle) => {
|
|
18642
|
-
const topLeft =
|
|
18643
|
-
const topRight =
|
|
18644
|
-
const bottomLeft =
|
|
18645
|
-
const bottomRight =
|
|
18968
|
+
const topLeft = pointRotateRads15(pointFrom18(x1, y1), center, angle);
|
|
18969
|
+
const topRight = pointRotateRads15(pointFrom18(x2, y1), center, angle);
|
|
18970
|
+
const bottomLeft = pointRotateRads15(pointFrom18(x1, y2), center, angle);
|
|
18971
|
+
const bottomRight = pointRotateRads15(pointFrom18(x2, y2), center, angle);
|
|
18646
18972
|
return {
|
|
18647
18973
|
n: [topLeft, topRight],
|
|
18648
18974
|
e: [topRight, bottomRight],
|
|
@@ -19183,6 +19509,8 @@ export {
|
|
|
19183
19509
|
getFrameLikeTitle,
|
|
19184
19510
|
getFreeDrawPath2D,
|
|
19185
19511
|
getFreeDrawSvgPath,
|
|
19512
|
+
getFreedrawOutlineAsSegments,
|
|
19513
|
+
getFreedrawOutlinePoints,
|
|
19186
19514
|
getGlobalFixedPointForBindableElement,
|
|
19187
19515
|
getGlobalFixedPoints,
|
|
19188
19516
|
getHeadingForElbowArrowSnap,
|
|
@@ -19348,6 +19676,7 @@ export {
|
|
|
19348
19676
|
parseTokens,
|
|
19349
19677
|
pathsCache,
|
|
19350
19678
|
pointInsideBounds,
|
|
19679
|
+
positionElementsOnGrid,
|
|
19351
19680
|
redrawTextBoundingBox,
|
|
19352
19681
|
refreshTextDimensions,
|
|
19353
19682
|
removeAllElementsFromFrame,
|