@excalidraw/element 0.18.0-de715913e → 0.18.0-ec07091
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 +772 -513
- package/dist/dev/index.js.map +4 -4
- package/dist/prod/index.js +14 -14
- package/dist/types/common/src/constants.d.ts +20 -4
- package/dist/types/common/src/utils.d.ts +3 -0
- package/dist/types/element/src/bounds.d.ts +1 -1
- package/dist/types/element/src/delta.d.ts +2 -2
- 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 +3 -2
- 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 +10 -8
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +2 -1
- package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
- 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/InlineIcon.d.ts +3 -1
- package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
- package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -0
- package/dist/types/excalidraw/components/TextField.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 +3 -7
- package/dist/types/excalidraw/data/types.d.ts +4 -1
- package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
- package/dist/types/excalidraw/types.d.ts +5 -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
|
);
|
|
@@ -7234,6 +7276,28 @@ var bindPointToSnapToElementOutline = (arrow, bindableElement, startOrEnd, eleme
|
|
|
7234
7276
|
intersector,
|
|
7235
7277
|
FIXED_BINDING_DISTANCE
|
|
7236
7278
|
).sort(pointDistanceSq)[0];
|
|
7279
|
+
if (!intersection) {
|
|
7280
|
+
const anotherPoint = pointFrom8(
|
|
7281
|
+
!isHorizontal ? center[0] : snapPoint[0],
|
|
7282
|
+
isHorizontal ? center[1] : snapPoint[1]
|
|
7283
|
+
);
|
|
7284
|
+
const anotherIntersector = lineSegment4(
|
|
7285
|
+
anotherPoint,
|
|
7286
|
+
pointFromVector5(
|
|
7287
|
+
vectorScale6(
|
|
7288
|
+
vectorNormalize3(vectorFromPoint6(snapPoint, anotherPoint)),
|
|
7289
|
+
Math.max(bindableElement.width, bindableElement.height) * 2
|
|
7290
|
+
),
|
|
7291
|
+
anotherPoint
|
|
7292
|
+
)
|
|
7293
|
+
);
|
|
7294
|
+
intersection = intersectElementWithLineSegment(
|
|
7295
|
+
bindableElement,
|
|
7296
|
+
elementsMap,
|
|
7297
|
+
anotherIntersector,
|
|
7298
|
+
FIXED_BINDING_DISTANCE
|
|
7299
|
+
).sort(pointDistanceSq)[0];
|
|
7300
|
+
}
|
|
7237
7301
|
} else {
|
|
7238
7302
|
intersection = intersectElementWithLineSegment(
|
|
7239
7303
|
bindableElement,
|
|
@@ -7261,24 +7325,24 @@ var bindPointToSnapToElementOutline = (arrow, bindableElement, startOrEnd, eleme
|
|
|
7261
7325
|
};
|
|
7262
7326
|
var avoidRectangularCorner = (element, elementsMap, p) => {
|
|
7263
7327
|
const center = elementCenterPoint(element, elementsMap);
|
|
7264
|
-
const nonRotatedPoint =
|
|
7328
|
+
const nonRotatedPoint = pointRotateRads7(p, center, -element.angle);
|
|
7265
7329
|
if (nonRotatedPoint[0] < element.x && nonRotatedPoint[1] < element.y) {
|
|
7266
7330
|
if (nonRotatedPoint[1] - element.y > -FIXED_BINDING_DISTANCE) {
|
|
7267
|
-
return
|
|
7268
|
-
|
|
7331
|
+
return pointRotateRads7(
|
|
7332
|
+
pointFrom8(element.x - FIXED_BINDING_DISTANCE, element.y),
|
|
7269
7333
|
center,
|
|
7270
7334
|
element.angle
|
|
7271
7335
|
);
|
|
7272
7336
|
}
|
|
7273
|
-
return
|
|
7274
|
-
|
|
7337
|
+
return pointRotateRads7(
|
|
7338
|
+
pointFrom8(element.x, element.y - FIXED_BINDING_DISTANCE),
|
|
7275
7339
|
center,
|
|
7276
7340
|
element.angle
|
|
7277
7341
|
);
|
|
7278
7342
|
} else if (nonRotatedPoint[0] < element.x && nonRotatedPoint[1] > element.y + element.height) {
|
|
7279
7343
|
if (nonRotatedPoint[0] - element.x > -FIXED_BINDING_DISTANCE) {
|
|
7280
|
-
return
|
|
7281
|
-
|
|
7344
|
+
return pointRotateRads7(
|
|
7345
|
+
pointFrom8(
|
|
7282
7346
|
element.x,
|
|
7283
7347
|
element.y + element.height + FIXED_BINDING_DISTANCE
|
|
7284
7348
|
),
|
|
@@ -7286,15 +7350,15 @@ var avoidRectangularCorner = (element, elementsMap, p) => {
|
|
|
7286
7350
|
element.angle
|
|
7287
7351
|
);
|
|
7288
7352
|
}
|
|
7289
|
-
return
|
|
7290
|
-
|
|
7353
|
+
return pointRotateRads7(
|
|
7354
|
+
pointFrom8(element.x - FIXED_BINDING_DISTANCE, element.y + element.height),
|
|
7291
7355
|
center,
|
|
7292
7356
|
element.angle
|
|
7293
7357
|
);
|
|
7294
7358
|
} else if (nonRotatedPoint[0] > element.x + element.width && nonRotatedPoint[1] > element.y + element.height) {
|
|
7295
7359
|
if (nonRotatedPoint[0] - element.x < element.width + FIXED_BINDING_DISTANCE) {
|
|
7296
|
-
return
|
|
7297
|
-
|
|
7360
|
+
return pointRotateRads7(
|
|
7361
|
+
pointFrom8(
|
|
7298
7362
|
element.x + element.width,
|
|
7299
7363
|
element.y + element.height + FIXED_BINDING_DISTANCE
|
|
7300
7364
|
),
|
|
@@ -7302,8 +7366,8 @@ var avoidRectangularCorner = (element, elementsMap, p) => {
|
|
|
7302
7366
|
element.angle
|
|
7303
7367
|
);
|
|
7304
7368
|
}
|
|
7305
|
-
return
|
|
7306
|
-
|
|
7369
|
+
return pointRotateRads7(
|
|
7370
|
+
pointFrom8(
|
|
7307
7371
|
element.x + element.width + FIXED_BINDING_DISTANCE,
|
|
7308
7372
|
element.y + element.height
|
|
7309
7373
|
),
|
|
@@ -7312,8 +7376,8 @@ var avoidRectangularCorner = (element, elementsMap, p) => {
|
|
|
7312
7376
|
);
|
|
7313
7377
|
} else if (nonRotatedPoint[0] > element.x + element.width && nonRotatedPoint[1] < element.y) {
|
|
7314
7378
|
if (nonRotatedPoint[0] - element.x < element.width + FIXED_BINDING_DISTANCE) {
|
|
7315
|
-
return
|
|
7316
|
-
|
|
7379
|
+
return pointRotateRads7(
|
|
7380
|
+
pointFrom8(
|
|
7317
7381
|
element.x + element.width,
|
|
7318
7382
|
element.y - FIXED_BINDING_DISTANCE
|
|
7319
7383
|
),
|
|
@@ -7321,8 +7385,8 @@ var avoidRectangularCorner = (element, elementsMap, p) => {
|
|
|
7321
7385
|
element.angle
|
|
7322
7386
|
);
|
|
7323
7387
|
}
|
|
7324
|
-
return
|
|
7325
|
-
|
|
7388
|
+
return pointRotateRads7(
|
|
7389
|
+
pointFrom8(element.x + element.width + FIXED_BINDING_DISTANCE, element.y),
|
|
7326
7390
|
center,
|
|
7327
7391
|
element.angle
|
|
7328
7392
|
);
|
|
@@ -7332,62 +7396,62 @@ var avoidRectangularCorner = (element, elementsMap, p) => {
|
|
|
7332
7396
|
var snapToMid = (element, elementsMap, p, tolerance = 0.05) => {
|
|
7333
7397
|
const { x, y, width, height, angle } = element;
|
|
7334
7398
|
const center = elementCenterPoint(element, elementsMap, -0.1, -0.1);
|
|
7335
|
-
const nonRotated =
|
|
7399
|
+
const nonRotated = pointRotateRads7(p, center, -angle);
|
|
7336
7400
|
const verticalThreshold = clamp3(tolerance * height, 5, 80);
|
|
7337
7401
|
const horizontalThreshold = clamp3(tolerance * width, 5, 80);
|
|
7338
7402
|
if (nonRotated[0] <= x + width / 2 && nonRotated[1] > center[1] - verticalThreshold && nonRotated[1] < center[1] + verticalThreshold) {
|
|
7339
|
-
return
|
|
7340
|
-
|
|
7403
|
+
return pointRotateRads7(
|
|
7404
|
+
pointFrom8(x - FIXED_BINDING_DISTANCE, center[1]),
|
|
7341
7405
|
center,
|
|
7342
7406
|
angle
|
|
7343
7407
|
);
|
|
7344
7408
|
} else if (nonRotated[1] <= y + height / 2 && nonRotated[0] > center[0] - horizontalThreshold && nonRotated[0] < center[0] + horizontalThreshold) {
|
|
7345
|
-
return
|
|
7346
|
-
|
|
7409
|
+
return pointRotateRads7(
|
|
7410
|
+
pointFrom8(center[0], y - FIXED_BINDING_DISTANCE),
|
|
7347
7411
|
center,
|
|
7348
7412
|
angle
|
|
7349
7413
|
);
|
|
7350
7414
|
} else if (nonRotated[0] >= x + width / 2 && nonRotated[1] > center[1] - verticalThreshold && nonRotated[1] < center[1] + verticalThreshold) {
|
|
7351
|
-
return
|
|
7352
|
-
|
|
7415
|
+
return pointRotateRads7(
|
|
7416
|
+
pointFrom8(x + width + FIXED_BINDING_DISTANCE, center[1]),
|
|
7353
7417
|
center,
|
|
7354
7418
|
angle
|
|
7355
7419
|
);
|
|
7356
7420
|
} else if (nonRotated[1] >= y + height / 2 && nonRotated[0] > center[0] - horizontalThreshold && nonRotated[0] < center[0] + horizontalThreshold) {
|
|
7357
|
-
return
|
|
7358
|
-
|
|
7421
|
+
return pointRotateRads7(
|
|
7422
|
+
pointFrom8(center[0], y + height + FIXED_BINDING_DISTANCE),
|
|
7359
7423
|
center,
|
|
7360
7424
|
angle
|
|
7361
7425
|
);
|
|
7362
7426
|
} else if (element.type === "diamond") {
|
|
7363
7427
|
const distance3 = FIXED_BINDING_DISTANCE;
|
|
7364
|
-
const topLeft =
|
|
7428
|
+
const topLeft = pointFrom8(
|
|
7365
7429
|
x + width / 4 - distance3,
|
|
7366
7430
|
y + height / 4 - distance3
|
|
7367
7431
|
);
|
|
7368
|
-
const topRight =
|
|
7432
|
+
const topRight = pointFrom8(
|
|
7369
7433
|
x + 3 * width / 4 + distance3,
|
|
7370
7434
|
y + height / 4 - distance3
|
|
7371
7435
|
);
|
|
7372
|
-
const bottomLeft =
|
|
7436
|
+
const bottomLeft = pointFrom8(
|
|
7373
7437
|
x + width / 4 - distance3,
|
|
7374
7438
|
y + 3 * height / 4 + distance3
|
|
7375
7439
|
);
|
|
7376
|
-
const bottomRight =
|
|
7440
|
+
const bottomRight = pointFrom8(
|
|
7377
7441
|
x + 3 * width / 4 + distance3,
|
|
7378
7442
|
y + 3 * height / 4 + distance3
|
|
7379
7443
|
);
|
|
7380
7444
|
if (pointDistance4(topLeft, nonRotated) < Math.max(horizontalThreshold, verticalThreshold)) {
|
|
7381
|
-
return
|
|
7445
|
+
return pointRotateRads7(topLeft, center, angle);
|
|
7382
7446
|
}
|
|
7383
7447
|
if (pointDistance4(topRight, nonRotated) < Math.max(horizontalThreshold, verticalThreshold)) {
|
|
7384
|
-
return
|
|
7448
|
+
return pointRotateRads7(topRight, center, angle);
|
|
7385
7449
|
}
|
|
7386
7450
|
if (pointDistance4(bottomLeft, nonRotated) < Math.max(horizontalThreshold, verticalThreshold)) {
|
|
7387
|
-
return
|
|
7451
|
+
return pointRotateRads7(bottomLeft, center, angle);
|
|
7388
7452
|
}
|
|
7389
7453
|
if (pointDistance4(bottomRight, nonRotated) < Math.max(horizontalThreshold, verticalThreshold)) {
|
|
7390
|
-
return
|
|
7454
|
+
return pointRotateRads7(bottomRight, center, angle);
|
|
7391
7455
|
}
|
|
7392
7456
|
}
|
|
7393
7457
|
return p;
|
|
@@ -7407,11 +7471,11 @@ var updateBoundPoint = (linearElement, startOrEnd, binding, bindableElement, ele
|
|
|
7407
7471
|
elementsMap
|
|
7408
7472
|
).fixedPoint;
|
|
7409
7473
|
const globalMidPoint = elementCenterPoint(bindableElement, elementsMap);
|
|
7410
|
-
const global2 =
|
|
7474
|
+
const global2 = pointFrom8(
|
|
7411
7475
|
bindableElement.x + fixedPoint[0] * bindableElement.width,
|
|
7412
7476
|
bindableElement.y + fixedPoint[1] * bindableElement.height
|
|
7413
7477
|
);
|
|
7414
|
-
const rotatedGlobal =
|
|
7478
|
+
const rotatedGlobal = pointRotateRads7(
|
|
7415
7479
|
global2,
|
|
7416
7480
|
globalMidPoint,
|
|
7417
7481
|
bindableElement.angle
|
|
@@ -7501,11 +7565,11 @@ var calculateFixedPointForElbowArrowBinding = (linearElement, hoveredElement, st
|
|
|
7501
7565
|
startOrEnd,
|
|
7502
7566
|
elementsMap
|
|
7503
7567
|
);
|
|
7504
|
-
const globalMidPoint =
|
|
7568
|
+
const globalMidPoint = pointFrom8(
|
|
7505
7569
|
bounds[0] + (bounds[2] - bounds[0]) / 2,
|
|
7506
7570
|
bounds[1] + (bounds[3] - bounds[1]) / 2
|
|
7507
7571
|
);
|
|
7508
|
-
const nonRotatedSnappedGlobalPoint =
|
|
7572
|
+
const nonRotatedSnappedGlobalPoint = pointRotateRads7(
|
|
7509
7573
|
snappedPoint,
|
|
7510
7574
|
globalMidPoint,
|
|
7511
7575
|
-hoveredElement.angle
|
|
@@ -7638,7 +7702,7 @@ var newBoundElements = (boundElements, idsToRemove, elementsToAdd = []) => {
|
|
|
7638
7702
|
return nextBoundElements;
|
|
7639
7703
|
};
|
|
7640
7704
|
var bindingBorderTest = (element, { x, y }, elementsMap, zoom, fullShape) => {
|
|
7641
|
-
const p =
|
|
7705
|
+
const p = pointFrom8(x, y);
|
|
7642
7706
|
const threshold = maxBindingGap(element, element.width, element.height, zoom);
|
|
7643
7707
|
const shouldTestInside2 = (
|
|
7644
7708
|
// disable fullshape snapping for frame elements so we
|
|
@@ -7680,8 +7744,8 @@ var determineFocusDistance = (element, elementsMap, a2, b2) => {
|
|
|
7680
7744
|
if (pointsEqual5(a2, b2)) {
|
|
7681
7745
|
return 0;
|
|
7682
7746
|
}
|
|
7683
|
-
const rotatedA =
|
|
7684
|
-
const rotatedB =
|
|
7747
|
+
const rotatedA = pointRotateRads7(a2, center, -element.angle);
|
|
7748
|
+
const rotatedB = pointRotateRads7(b2, center, -element.angle);
|
|
7685
7749
|
const sign = Math.sign(
|
|
7686
7750
|
vectorCross3(
|
|
7687
7751
|
vectorFromPoint6(rotatedB, a2),
|
|
@@ -7700,70 +7764,70 @@ var determineFocusDistance = (element, elementsMap, a2, b2) => {
|
|
|
7700
7764
|
);
|
|
7701
7765
|
const axes = element.type === "diamond" ? [
|
|
7702
7766
|
lineSegment4(
|
|
7703
|
-
|
|
7704
|
-
|
|
7767
|
+
pointFrom8(element.x + element.width / 2, element.y),
|
|
7768
|
+
pointFrom8(
|
|
7705
7769
|
element.x + element.width / 2,
|
|
7706
7770
|
element.y + element.height
|
|
7707
7771
|
)
|
|
7708
7772
|
),
|
|
7709
7773
|
lineSegment4(
|
|
7710
|
-
|
|
7711
|
-
|
|
7774
|
+
pointFrom8(element.x, element.y + element.height / 2),
|
|
7775
|
+
pointFrom8(
|
|
7712
7776
|
element.x + element.width,
|
|
7713
7777
|
element.y + element.height / 2
|
|
7714
7778
|
)
|
|
7715
7779
|
)
|
|
7716
7780
|
] : [
|
|
7717
7781
|
lineSegment4(
|
|
7718
|
-
|
|
7719
|
-
|
|
7782
|
+
pointFrom8(element.x, element.y),
|
|
7783
|
+
pointFrom8(
|
|
7720
7784
|
element.x + element.width,
|
|
7721
7785
|
element.y + element.height
|
|
7722
7786
|
)
|
|
7723
7787
|
),
|
|
7724
7788
|
lineSegment4(
|
|
7725
|
-
|
|
7726
|
-
|
|
7789
|
+
pointFrom8(element.x + element.width, element.y),
|
|
7790
|
+
pointFrom8(element.x, element.y + element.height)
|
|
7727
7791
|
)
|
|
7728
7792
|
];
|
|
7729
7793
|
const interceptees = element.type === "diamond" ? [
|
|
7730
7794
|
lineSegment4(
|
|
7731
|
-
|
|
7795
|
+
pointFrom8(
|
|
7732
7796
|
element.x + element.width / 2,
|
|
7733
7797
|
element.y - element.height
|
|
7734
7798
|
),
|
|
7735
|
-
|
|
7799
|
+
pointFrom8(
|
|
7736
7800
|
element.x + element.width / 2,
|
|
7737
7801
|
element.y + element.height * 2
|
|
7738
7802
|
)
|
|
7739
7803
|
),
|
|
7740
7804
|
lineSegment4(
|
|
7741
|
-
|
|
7805
|
+
pointFrom8(
|
|
7742
7806
|
element.x - element.width,
|
|
7743
7807
|
element.y + element.height / 2
|
|
7744
7808
|
),
|
|
7745
|
-
|
|
7809
|
+
pointFrom8(
|
|
7746
7810
|
element.x + element.width * 2,
|
|
7747
7811
|
element.y + element.height / 2
|
|
7748
7812
|
)
|
|
7749
7813
|
)
|
|
7750
7814
|
] : [
|
|
7751
7815
|
lineSegment4(
|
|
7752
|
-
|
|
7816
|
+
pointFrom8(
|
|
7753
7817
|
element.x - element.width,
|
|
7754
7818
|
element.y - element.height
|
|
7755
7819
|
),
|
|
7756
|
-
|
|
7820
|
+
pointFrom8(
|
|
7757
7821
|
element.x + element.width * 2,
|
|
7758
7822
|
element.y + element.height * 2
|
|
7759
7823
|
)
|
|
7760
7824
|
),
|
|
7761
7825
|
lineSegment4(
|
|
7762
|
-
|
|
7826
|
+
pointFrom8(
|
|
7763
7827
|
element.x + element.width * 2,
|
|
7764
7828
|
element.y - element.height
|
|
7765
7829
|
),
|
|
7766
|
-
|
|
7830
|
+
pointFrom8(
|
|
7767
7831
|
element.x - element.width,
|
|
7768
7832
|
element.y + element.height * 2
|
|
7769
7833
|
)
|
|
@@ -7784,30 +7848,30 @@ var determineFocusPoint = (element, elementsMap, focus, adjacentPoint) => {
|
|
|
7784
7848
|
return center;
|
|
7785
7849
|
}
|
|
7786
7850
|
const candidates = (element.type === "diamond" ? [
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7851
|
+
pointFrom8(element.x, element.y + element.height / 2),
|
|
7852
|
+
pointFrom8(element.x + element.width / 2, element.y),
|
|
7853
|
+
pointFrom8(
|
|
7790
7854
|
element.x + element.width,
|
|
7791
7855
|
element.y + element.height / 2
|
|
7792
7856
|
),
|
|
7793
|
-
|
|
7857
|
+
pointFrom8(
|
|
7794
7858
|
element.x + element.width / 2,
|
|
7795
7859
|
element.y + element.height
|
|
7796
7860
|
)
|
|
7797
7861
|
] : [
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7862
|
+
pointFrom8(element.x, element.y),
|
|
7863
|
+
pointFrom8(element.x + element.width, element.y),
|
|
7864
|
+
pointFrom8(
|
|
7801
7865
|
element.x + element.width,
|
|
7802
7866
|
element.y + element.height
|
|
7803
7867
|
),
|
|
7804
|
-
|
|
7868
|
+
pointFrom8(element.x, element.y + element.height)
|
|
7805
7869
|
]).map(
|
|
7806
7870
|
(p) => pointFromVector5(
|
|
7807
7871
|
vectorScale6(vectorFromPoint6(p, center), Math.abs(focus)),
|
|
7808
7872
|
center
|
|
7809
7873
|
)
|
|
7810
|
-
).map((p) =>
|
|
7874
|
+
).map((p) => pointRotateRads7(p, center, element.angle));
|
|
7811
7875
|
const selected = [
|
|
7812
7876
|
vectorCross3(
|
|
7813
7877
|
vectorFromPoint6(adjacentPoint, candidates[0]),
|
|
@@ -8052,8 +8116,8 @@ var BindableElement = class {
|
|
|
8052
8116
|
};
|
|
8053
8117
|
var getGlobalFixedPointForBindableElement = (fixedPointRatio, element, elementsMap) => {
|
|
8054
8118
|
const [fixedX, fixedY] = normalizeFixedPoint(fixedPointRatio);
|
|
8055
|
-
return
|
|
8056
|
-
|
|
8119
|
+
return pointRotateRads7(
|
|
8120
|
+
pointFrom8(
|
|
8057
8121
|
element.x + element.width * fixedX,
|
|
8058
8122
|
element.y + element.height * fixedY
|
|
8059
8123
|
),
|
|
@@ -8068,7 +8132,7 @@ var getGlobalFixedPoints = (arrow, elementsMap) => {
|
|
|
8068
8132
|
arrow.startBinding.fixedPoint,
|
|
8069
8133
|
startElement,
|
|
8070
8134
|
elementsMap
|
|
8071
|
-
) :
|
|
8135
|
+
) : pointFrom8(
|
|
8072
8136
|
arrow.x + arrow.points[0][0],
|
|
8073
8137
|
arrow.y + arrow.points[0][1]
|
|
8074
8138
|
);
|
|
@@ -8076,7 +8140,7 @@ var getGlobalFixedPoints = (arrow, elementsMap) => {
|
|
|
8076
8140
|
arrow.endBinding.fixedPoint,
|
|
8077
8141
|
endElement,
|
|
8078
8142
|
elementsMap
|
|
8079
|
-
) :
|
|
8143
|
+
) : pointFrom8(
|
|
8080
8144
|
arrow.x + arrow.points[arrow.points.length - 1][0],
|
|
8081
8145
|
arrow.y + arrow.points[arrow.points.length - 1][1]
|
|
8082
8146
|
);
|
|
@@ -8106,7 +8170,7 @@ var getNormalizedPoints = ({
|
|
|
8106
8170
|
const offsetY = points[0][1];
|
|
8107
8171
|
return {
|
|
8108
8172
|
points: points.map((p) => {
|
|
8109
|
-
return
|
|
8173
|
+
return pointFrom9(p[0] - offsetX, p[1] - offsetY);
|
|
8110
8174
|
}),
|
|
8111
8175
|
offsetX,
|
|
8112
8176
|
offsetY
|
|
@@ -8130,7 +8194,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8130
8194
|
isEditing;
|
|
8131
8195
|
constructor(element, elementsMap, isEditing = false) {
|
|
8132
8196
|
this.elementId = element.id;
|
|
8133
|
-
if (!pointsEqual6(element.points[0],
|
|
8197
|
+
if (!pointsEqual6(element.points[0], pointFrom9(0, 0))) {
|
|
8134
8198
|
console.error("Linear element is not normalized", Error().stack);
|
|
8135
8199
|
mutateElement(
|
|
8136
8200
|
element,
|
|
@@ -8244,7 +8308,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8244
8308
|
element,
|
|
8245
8309
|
elementsMap,
|
|
8246
8310
|
referencePoint,
|
|
8247
|
-
|
|
8311
|
+
pointFrom9(scenePointerX, scenePointerY),
|
|
8248
8312
|
event[KEYS2.CTRL_OR_CMD] ? null : app.getEffectiveGridSize(),
|
|
8249
8313
|
customLineAngle
|
|
8250
8314
|
);
|
|
@@ -8255,7 +8319,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8255
8319
|
[
|
|
8256
8320
|
selectedIndex,
|
|
8257
8321
|
{
|
|
8258
|
-
point:
|
|
8322
|
+
point: pointFrom9(
|
|
8259
8323
|
width + referencePoint[0],
|
|
8260
8324
|
height + referencePoint[1]
|
|
8261
8325
|
),
|
|
@@ -8285,7 +8349,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8285
8349
|
scenePointerX - linearElementEditor.pointerOffset.x,
|
|
8286
8350
|
scenePointerY - linearElementEditor.pointerOffset.y,
|
|
8287
8351
|
event[KEYS2.CTRL_OR_CMD] ? null : app.getEffectiveGridSize()
|
|
8288
|
-
) :
|
|
8352
|
+
) : pointFrom9(
|
|
8289
8353
|
element.points[pointIndex][0] + deltaX,
|
|
8290
8354
|
element.points[pointIndex][1] + deltaY
|
|
8291
8355
|
);
|
|
@@ -8498,11 +8562,11 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8498
8562
|
const existingSegmentMidpointHitCoords = linearElementEditor.segmentMidPointHoveredCoords;
|
|
8499
8563
|
if (existingSegmentMidpointHitCoords) {
|
|
8500
8564
|
const distance3 = pointDistance5(
|
|
8501
|
-
|
|
8565
|
+
pointFrom9(
|
|
8502
8566
|
existingSegmentMidpointHitCoords[0],
|
|
8503
8567
|
existingSegmentMidpointHitCoords[1]
|
|
8504
8568
|
),
|
|
8505
|
-
|
|
8569
|
+
pointFrom9(scenePointer.x, scenePointer.y)
|
|
8506
8570
|
);
|
|
8507
8571
|
if (distance3 <= threshold) {
|
|
8508
8572
|
return existingSegmentMidpointHitCoords;
|
|
@@ -8518,7 +8582,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8518
8582
|
if (midPoints[index] !== null) {
|
|
8519
8583
|
const distance3 = pointDistance5(
|
|
8520
8584
|
midPoints[index],
|
|
8521
|
-
|
|
8585
|
+
pointFrom9(scenePointer.x, scenePointer.y)
|
|
8522
8586
|
);
|
|
8523
8587
|
if (distance3 <= threshold) {
|
|
8524
8588
|
return midPoints[index];
|
|
@@ -8557,7 +8621,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8557
8621
|
"Invalid segment index while calculating elbow arrow mid point"
|
|
8558
8622
|
);
|
|
8559
8623
|
const p = pointCenter2(element.points[index - 1], element.points[index]);
|
|
8560
|
-
return
|
|
8624
|
+
return pointFrom9(element.x + p[0], element.y + p[1]);
|
|
8561
8625
|
}
|
|
8562
8626
|
const [lines, curves] = deconstructLinearOrFreeDrawElement2(element);
|
|
8563
8627
|
invariant6(
|
|
@@ -8697,12 +8761,12 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8697
8761
|
const [x1, y1, x2, y2] = getElementAbsoluteCoords2(element, elementsMap);
|
|
8698
8762
|
const cx = (x1 + x2) / 2;
|
|
8699
8763
|
const cy = (y1 + y2) / 2;
|
|
8700
|
-
const targetPoint = clickedPointIndex > -1 &&
|
|
8701
|
-
|
|
8764
|
+
const targetPoint = clickedPointIndex > -1 && pointRotateRads8(
|
|
8765
|
+
pointFrom9(
|
|
8702
8766
|
element.x + element.points[clickedPointIndex][0],
|
|
8703
8767
|
element.y + element.points[clickedPointIndex][1]
|
|
8704
8768
|
),
|
|
8705
|
-
|
|
8769
|
+
pointFrom9(cx, cy),
|
|
8706
8770
|
element.angle
|
|
8707
8771
|
);
|
|
8708
8772
|
const nextSelectedPointsIndices = clickedPointIndex > -1 || event.shiftKey ? event.shiftKey || linearElementEditor.selectedPointsIndices?.includes(clickedPointIndex) ? normalizeSelectedPoints([
|
|
@@ -8768,10 +8832,10 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8768
8832
|
element,
|
|
8769
8833
|
elementsMap,
|
|
8770
8834
|
lastCommittedPoint,
|
|
8771
|
-
|
|
8835
|
+
pointFrom9(scenePointerX, scenePointerY),
|
|
8772
8836
|
event[KEYS2.CTRL_OR_CMD] ? null : app.getEffectiveGridSize()
|
|
8773
8837
|
);
|
|
8774
|
-
newPoint =
|
|
8838
|
+
newPoint = pointFrom9(
|
|
8775
8839
|
width + lastCommittedPoint[0],
|
|
8776
8840
|
height + lastCommittedPoint[1]
|
|
8777
8841
|
);
|
|
@@ -8811,9 +8875,9 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8811
8875
|
const cx = (x1 + x2) / 2;
|
|
8812
8876
|
const cy = (y1 + y2) / 2;
|
|
8813
8877
|
const { x, y } = element;
|
|
8814
|
-
return
|
|
8815
|
-
|
|
8816
|
-
|
|
8878
|
+
return pointRotateRads8(
|
|
8879
|
+
pointFrom9(x + p[0], y + p[1]),
|
|
8880
|
+
pointFrom9(cx, cy),
|
|
8817
8881
|
element.angle
|
|
8818
8882
|
);
|
|
8819
8883
|
}
|
|
@@ -8824,9 +8888,9 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8824
8888
|
const cy = (y1 + y2) / 2;
|
|
8825
8889
|
return element.points.map((p) => {
|
|
8826
8890
|
const { x, y } = element;
|
|
8827
|
-
return
|
|
8828
|
-
|
|
8829
|
-
|
|
8891
|
+
return pointRotateRads8(
|
|
8892
|
+
pointFrom9(x + p[0], y + p[1]),
|
|
8893
|
+
pointFrom9(cx, cy),
|
|
8830
8894
|
element.angle
|
|
8831
8895
|
);
|
|
8832
8896
|
});
|
|
@@ -8838,15 +8902,15 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8838
8902
|
const cy = (y1 + y2) / 2;
|
|
8839
8903
|
const p = element.points[index];
|
|
8840
8904
|
const { x, y } = element;
|
|
8841
|
-
return p ?
|
|
8842
|
-
|
|
8843
|
-
|
|
8905
|
+
return p ? pointRotateRads8(
|
|
8906
|
+
pointFrom9(x + p[0], y + p[1]),
|
|
8907
|
+
pointFrom9(cx, cy),
|
|
8844
8908
|
element.angle
|
|
8845
|
-
) :
|
|
8909
|
+
) : pointRotateRads8(pointFrom9(x, y), pointFrom9(cx, cy), element.angle);
|
|
8846
8910
|
}
|
|
8847
8911
|
static pointFromAbsoluteCoords(element, absoluteCoords, elementsMap) {
|
|
8848
8912
|
if (isElbowArrow(element)) {
|
|
8849
|
-
return
|
|
8913
|
+
return pointFrom9(
|
|
8850
8914
|
absoluteCoords[0] - element.x,
|
|
8851
8915
|
absoluteCoords[1] - element.y
|
|
8852
8916
|
);
|
|
@@ -8854,12 +8918,12 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8854
8918
|
const [x1, y1, x2, y2] = getElementAbsoluteCoords2(element, elementsMap);
|
|
8855
8919
|
const cx = (x1 + x2) / 2;
|
|
8856
8920
|
const cy = (y1 + y2) / 2;
|
|
8857
|
-
const [x, y] =
|
|
8858
|
-
|
|
8859
|
-
|
|
8921
|
+
const [x, y] = pointRotateRads8(
|
|
8922
|
+
pointFrom9(absoluteCoords[0], absoluteCoords[1]),
|
|
8923
|
+
pointFrom9(cx, cy),
|
|
8860
8924
|
-element.angle
|
|
8861
8925
|
);
|
|
8862
|
-
return
|
|
8926
|
+
return pointFrom9(x - element.x, y - element.y);
|
|
8863
8927
|
}
|
|
8864
8928
|
static getPointIndexUnderCursor(element, elementsMap, zoom, x, y) {
|
|
8865
8929
|
const pointHandles = _LinearElementEditor.getPointsGlobalCoordinates(
|
|
@@ -8869,7 +8933,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8869
8933
|
let idx = pointHandles.length;
|
|
8870
8934
|
while (--idx > -1) {
|
|
8871
8935
|
const p = pointHandles[idx];
|
|
8872
|
-
if (pointDistance5(
|
|
8936
|
+
if (pointDistance5(pointFrom9(x, y), pointFrom9(p[0], p[1])) * zoom.value < // +1px to account for outline stroke
|
|
8873
8937
|
_LinearElementEditor.POINT_HANDLE_SIZE + 1) {
|
|
8874
8938
|
return idx;
|
|
8875
8939
|
}
|
|
@@ -8881,12 +8945,12 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8881
8945
|
const [x1, y1, x2, y2] = getElementAbsoluteCoords2(element, elementsMap);
|
|
8882
8946
|
const cx = (x1 + x2) / 2;
|
|
8883
8947
|
const cy = (y1 + y2) / 2;
|
|
8884
|
-
const [rotatedX, rotatedY] =
|
|
8885
|
-
|
|
8886
|
-
|
|
8948
|
+
const [rotatedX, rotatedY] = pointRotateRads8(
|
|
8949
|
+
pointFrom9(pointerOnGrid[0], pointerOnGrid[1]),
|
|
8950
|
+
pointFrom9(cx, cy),
|
|
8887
8951
|
-element.angle
|
|
8888
8952
|
);
|
|
8889
|
-
return
|
|
8953
|
+
return pointFrom9(rotatedX - element.x, rotatedY - element.y);
|
|
8890
8954
|
}
|
|
8891
8955
|
/**
|
|
8892
8956
|
* Normalizes line points so that the start point is at [0,0]. This is
|
|
@@ -8935,7 +8999,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8935
8999
|
pointAddedToEnd = true;
|
|
8936
9000
|
}
|
|
8937
9001
|
acc.push(
|
|
8938
|
-
nextPoint ?
|
|
9002
|
+
nextPoint ? pointFrom9((p[0] + nextPoint[0]) / 2, (p[1] + nextPoint[1]) / 2) : pointFrom9(p[0], p[1])
|
|
8939
9003
|
);
|
|
8940
9004
|
nextSelectedIndices.push(indexCursor + 1);
|
|
8941
9005
|
++indexCursor;
|
|
@@ -8951,7 +9015,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8951
9015
|
/* @__PURE__ */ new Map([
|
|
8952
9016
|
[
|
|
8953
9017
|
element.points.length - 1,
|
|
8954
|
-
{ point:
|
|
9018
|
+
{ point: pointFrom9(lastPoint[0] + 30, lastPoint[1] + 30) }
|
|
8955
9019
|
]
|
|
8956
9020
|
])
|
|
8957
9021
|
);
|
|
@@ -8971,7 +9035,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8971
9035
|
});
|
|
8972
9036
|
const isPolygon = isLineElement(element) && element.polygon;
|
|
8973
9037
|
if (isPolygon && (isUncommittedPoint || pointIndices.includes(0) || pointIndices.includes(element.points.length - 1))) {
|
|
8974
|
-
nextPoints[0] =
|
|
9038
|
+
nextPoints[0] = pointFrom9(
|
|
8975
9039
|
nextPoints[nextPoints.length - 1][0],
|
|
8976
9040
|
nextPoints[nextPoints.length - 1][1]
|
|
8977
9041
|
);
|
|
@@ -8992,7 +9056,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
8992
9056
|
static addPoints(element, scene, addedPoints) {
|
|
8993
9057
|
const nextPoints = [...element.points, ...addedPoints];
|
|
8994
9058
|
if (isLineElement(element) && element.polygon) {
|
|
8995
|
-
nextPoints[0] =
|
|
9059
|
+
nextPoints[0] = pointFrom9(
|
|
8996
9060
|
nextPoints[nextPoints.length - 1][0],
|
|
8997
9061
|
nextPoints[nextPoints.length - 1][1]
|
|
8998
9062
|
);
|
|
@@ -9017,7 +9081,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9017
9081
|
const lastPointUpdate = pointUpdates.get(points.length - 1);
|
|
9018
9082
|
if (firstPointUpdate) {
|
|
9019
9083
|
pointUpdates.set(points.length - 1, {
|
|
9020
|
-
point:
|
|
9084
|
+
point: pointFrom9(
|
|
9021
9085
|
firstPointUpdate.point[0],
|
|
9022
9086
|
firstPointUpdate.point[1]
|
|
9023
9087
|
),
|
|
@@ -9025,19 +9089,19 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9025
9089
|
});
|
|
9026
9090
|
} else if (lastPointUpdate) {
|
|
9027
9091
|
pointUpdates.set(0, {
|
|
9028
|
-
point:
|
|
9092
|
+
point: pointFrom9(lastPointUpdate.point[0], lastPointUpdate.point[1]),
|
|
9029
9093
|
isDragging: lastPointUpdate.isDragging
|
|
9030
9094
|
});
|
|
9031
9095
|
}
|
|
9032
9096
|
}
|
|
9033
|
-
const updatedOriginPoint = pointUpdates.get(0)?.point ??
|
|
9097
|
+
const updatedOriginPoint = pointUpdates.get(0)?.point ?? pointFrom9(0, 0);
|
|
9034
9098
|
const [offsetX, offsetY] = updatedOriginPoint;
|
|
9035
9099
|
const nextPoints = isElbowArrow(element) ? [
|
|
9036
9100
|
pointUpdates.get(0)?.point ?? points[0],
|
|
9037
9101
|
pointUpdates.get(points.length - 1)?.point ?? points[points.length - 1]
|
|
9038
9102
|
] : points.map((p, idx) => {
|
|
9039
9103
|
const current = pointUpdates.get(idx)?.point ?? p;
|
|
9040
|
-
return
|
|
9104
|
+
return pointFrom9(
|
|
9041
9105
|
current[0] - offsetX,
|
|
9042
9106
|
current[1] - offsetY
|
|
9043
9107
|
);
|
|
@@ -9071,8 +9135,8 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9071
9135
|
}
|
|
9072
9136
|
const origin = linearElementEditor.pointerDownState.origin;
|
|
9073
9137
|
const dist = pointDistance5(
|
|
9074
|
-
|
|
9075
|
-
|
|
9138
|
+
pointFrom9(origin.x, origin.y),
|
|
9139
|
+
pointFrom9(pointerCoords.x, pointerCoords.y)
|
|
9076
9140
|
);
|
|
9077
9141
|
if (!appState.selectedLinearElement?.isEditing && dist < DRAGGING_THRESHOLD / appState.zoom.value) {
|
|
9078
9142
|
return false;
|
|
@@ -9140,9 +9204,9 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9140
9204
|
const prevCenterY = (prevCoords[1] + prevCoords[3]) / 2;
|
|
9141
9205
|
const dX = prevCenterX - nextCenterX;
|
|
9142
9206
|
const dY = prevCenterY - nextCenterY;
|
|
9143
|
-
const rotatedOffset =
|
|
9144
|
-
|
|
9145
|
-
|
|
9207
|
+
const rotatedOffset = pointRotateRads8(
|
|
9208
|
+
pointFrom9(offsetX, offsetY),
|
|
9209
|
+
pointFrom9(dX, dY),
|
|
9146
9210
|
element.angle
|
|
9147
9211
|
);
|
|
9148
9212
|
scene.mutateElement(element, {
|
|
@@ -9177,9 +9241,9 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9177
9241
|
gridY,
|
|
9178
9242
|
customLineAngle
|
|
9179
9243
|
);
|
|
9180
|
-
return
|
|
9181
|
-
|
|
9182
|
-
|
|
9244
|
+
return pointRotateRads8(
|
|
9245
|
+
pointFrom9(width, height),
|
|
9246
|
+
pointFrom9(0, 0),
|
|
9183
9247
|
-element.angle
|
|
9184
9248
|
);
|
|
9185
9249
|
}
|
|
@@ -9224,34 +9288,34 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9224
9288
|
);
|
|
9225
9289
|
const boundTextX2 = boundTextX1 + boundTextElement.width;
|
|
9226
9290
|
const boundTextY2 = boundTextY1 + boundTextElement.height;
|
|
9227
|
-
const centerPoint =
|
|
9228
|
-
const topLeftRotatedPoint =
|
|
9229
|
-
|
|
9291
|
+
const centerPoint = pointFrom9(cx, cy);
|
|
9292
|
+
const topLeftRotatedPoint = pointRotateRads8(
|
|
9293
|
+
pointFrom9(x1, y1),
|
|
9230
9294
|
centerPoint,
|
|
9231
9295
|
element.angle
|
|
9232
9296
|
);
|
|
9233
|
-
const topRightRotatedPoint =
|
|
9234
|
-
|
|
9297
|
+
const topRightRotatedPoint = pointRotateRads8(
|
|
9298
|
+
pointFrom9(x2, y1),
|
|
9235
9299
|
centerPoint,
|
|
9236
9300
|
element.angle
|
|
9237
9301
|
);
|
|
9238
|
-
const counterRotateBoundTextTopLeft =
|
|
9239
|
-
|
|
9302
|
+
const counterRotateBoundTextTopLeft = pointRotateRads8(
|
|
9303
|
+
pointFrom9(boundTextX1, boundTextY1),
|
|
9240
9304
|
centerPoint,
|
|
9241
9305
|
-element.angle
|
|
9242
9306
|
);
|
|
9243
|
-
const counterRotateBoundTextTopRight =
|
|
9244
|
-
|
|
9307
|
+
const counterRotateBoundTextTopRight = pointRotateRads8(
|
|
9308
|
+
pointFrom9(boundTextX2, boundTextY1),
|
|
9245
9309
|
centerPoint,
|
|
9246
9310
|
-element.angle
|
|
9247
9311
|
);
|
|
9248
|
-
const counterRotateBoundTextBottomLeft =
|
|
9249
|
-
|
|
9312
|
+
const counterRotateBoundTextBottomLeft = pointRotateRads8(
|
|
9313
|
+
pointFrom9(boundTextX1, boundTextY2),
|
|
9250
9314
|
centerPoint,
|
|
9251
9315
|
-element.angle
|
|
9252
9316
|
);
|
|
9253
|
-
const counterRotateBoundTextBottomRight =
|
|
9254
|
-
|
|
9317
|
+
const counterRotateBoundTextBottomRight = pointRotateRads8(
|
|
9318
|
+
pointFrom9(boundTextX2, boundTextY2),
|
|
9255
9319
|
centerPoint,
|
|
9256
9320
|
-element.angle
|
|
9257
9321
|
);
|
|
@@ -9367,11 +9431,11 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9367
9431
|
);
|
|
9368
9432
|
fixedSegments[index] = {
|
|
9369
9433
|
index,
|
|
9370
|
-
start:
|
|
9434
|
+
start: pointFrom9(
|
|
9371
9435
|
!isHorizontal ? x - element.x : element.points[index - 1][0],
|
|
9372
9436
|
isHorizontal ? y - element.y : element.points[index - 1][1]
|
|
9373
9437
|
),
|
|
9374
|
-
end:
|
|
9438
|
+
end: pointFrom9(
|
|
9375
9439
|
!isHorizontal ? x - element.x : element.points[index][0],
|
|
9376
9440
|
isHorizontal ? y - element.y : element.points[index][1]
|
|
9377
9441
|
)
|
|
@@ -9383,7 +9447,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
9383
9447
|
scene.mutateElement(element, {
|
|
9384
9448
|
fixedSegments: nextFixedSegments
|
|
9385
9449
|
});
|
|
9386
|
-
const point =
|
|
9450
|
+
const point = pointFrom9(
|
|
9387
9451
|
element.x + (element.fixedSegments[offset].start[0] + element.fixedSegments[offset].end[0]) / 2,
|
|
9388
9452
|
element.y + (element.fixedSegments[offset].start[1] + element.fixedSegments[offset].end[1]) / 2
|
|
9389
9453
|
);
|
|
@@ -9421,7 +9485,7 @@ var normalizeSelectedPoints = (points) => {
|
|
|
9421
9485
|
// src/frame.ts
|
|
9422
9486
|
init_define_import_meta_env();
|
|
9423
9487
|
import { arrayToMap as arrayToMap5 } from "@excalidraw/common";
|
|
9424
|
-
import { isPointWithinBounds as isPointWithinBounds2, pointFrom as
|
|
9488
|
+
import { isPointWithinBounds as isPointWithinBounds2, pointFrom as pointFrom11 } from "@excalidraw/math";
|
|
9425
9489
|
|
|
9426
9490
|
// ../utils/src/bbox.ts
|
|
9427
9491
|
init_define_import_meta_env();
|
|
@@ -9472,24 +9536,24 @@ import {
|
|
|
9472
9536
|
} from "@excalidraw/element";
|
|
9473
9537
|
import {
|
|
9474
9538
|
rangeIncludesValue,
|
|
9475
|
-
pointFrom as
|
|
9476
|
-
pointRotateRads as
|
|
9539
|
+
pointFrom as pointFrom10,
|
|
9540
|
+
pointRotateRads as pointRotateRads9,
|
|
9477
9541
|
rangeInclusive
|
|
9478
9542
|
} from "@excalidraw/math";
|
|
9479
9543
|
var getNonLinearElementRelativePoints = (element) => {
|
|
9480
9544
|
if (element.type === "diamond") {
|
|
9481
9545
|
return [
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9546
|
+
pointFrom10(element.width / 2, 0),
|
|
9547
|
+
pointFrom10(element.width, element.height / 2),
|
|
9548
|
+
pointFrom10(element.width / 2, element.height),
|
|
9549
|
+
pointFrom10(0, element.height / 2)
|
|
9486
9550
|
];
|
|
9487
9551
|
}
|
|
9488
9552
|
return [
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9553
|
+
pointFrom10(0, 0),
|
|
9554
|
+
pointFrom10(0 + element.width, 0),
|
|
9555
|
+
pointFrom10(0 + element.width, element.height),
|
|
9556
|
+
pointFrom10(0, element.height)
|
|
9493
9557
|
];
|
|
9494
9558
|
};
|
|
9495
9559
|
var getElementRelativePoints = (element) => {
|
|
@@ -9523,9 +9587,9 @@ var getMinMaxPoints = (points) => {
|
|
|
9523
9587
|
var getRotatedBBox = (element) => {
|
|
9524
9588
|
const points = getElementRelativePoints(element);
|
|
9525
9589
|
const { cx, cy } = getMinMaxPoints(points);
|
|
9526
|
-
const centerPoint =
|
|
9590
|
+
const centerPoint = pointFrom10(cx, cy);
|
|
9527
9591
|
const rotatedPoints = points.map(
|
|
9528
|
-
(p) =>
|
|
9592
|
+
(p) => pointRotateRads9(p, centerPoint, element.angle)
|
|
9529
9593
|
);
|
|
9530
9594
|
const { minX, minY, maxX, maxY } = getMinMaxPoints(rotatedPoints);
|
|
9531
9595
|
return [
|
|
@@ -10089,9 +10153,9 @@ var elementOverlapsWithFrame = (element, frame, elementsMap) => {
|
|
|
10089
10153
|
var isCursorInFrame = (cursorCoords, frame, elementsMap) => {
|
|
10090
10154
|
const [fx1, fy1, fx2, fy2] = getElementAbsoluteCoords2(frame, elementsMap);
|
|
10091
10155
|
return isPointWithinBounds2(
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10156
|
+
pointFrom11(fx1, fy1),
|
|
10157
|
+
pointFrom11(cursorCoords.x, cursorCoords.y),
|
|
10158
|
+
pointFrom11(fx2, fy2)
|
|
10095
10159
|
);
|
|
10096
10160
|
};
|
|
10097
10161
|
var groupsAreAtLeastIntersectingTheFrame = (elements, groupIds, frame) => {
|
|
@@ -11155,6 +11219,58 @@ function getFreeDrawPath2D(element) {
|
|
|
11155
11219
|
return pathsCache.get(element);
|
|
11156
11220
|
}
|
|
11157
11221
|
function getFreeDrawSvgPath(element) {
|
|
11222
|
+
return getSvgPathFromStroke(getFreedrawOutlinePoints(element));
|
|
11223
|
+
}
|
|
11224
|
+
function getFreedrawOutlineAsSegments(element, points, elementsMap) {
|
|
11225
|
+
const bounds = getElementBounds(
|
|
11226
|
+
{
|
|
11227
|
+
...element,
|
|
11228
|
+
angle: 0
|
|
11229
|
+
},
|
|
11230
|
+
elementsMap
|
|
11231
|
+
);
|
|
11232
|
+
const center = pointFrom12(
|
|
11233
|
+
(bounds[0] + bounds[2]) / 2,
|
|
11234
|
+
(bounds[1] + bounds[3]) / 2
|
|
11235
|
+
);
|
|
11236
|
+
invariant7(points.length >= 2, "Freepath outline must have at least 2 points");
|
|
11237
|
+
return points.slice(2).reduce(
|
|
11238
|
+
(acc, curr) => {
|
|
11239
|
+
acc.push(
|
|
11240
|
+
lineSegment5(
|
|
11241
|
+
acc[acc.length - 1][1],
|
|
11242
|
+
pointRotateRads10(
|
|
11243
|
+
pointFrom12(curr[0] + element.x, curr[1] + element.y),
|
|
11244
|
+
center,
|
|
11245
|
+
element.angle
|
|
11246
|
+
)
|
|
11247
|
+
)
|
|
11248
|
+
);
|
|
11249
|
+
return acc;
|
|
11250
|
+
},
|
|
11251
|
+
[
|
|
11252
|
+
lineSegment5(
|
|
11253
|
+
pointRotateRads10(
|
|
11254
|
+
pointFrom12(
|
|
11255
|
+
points[0][0] + element.x,
|
|
11256
|
+
points[0][1] + element.y
|
|
11257
|
+
),
|
|
11258
|
+
center,
|
|
11259
|
+
element.angle
|
|
11260
|
+
),
|
|
11261
|
+
pointRotateRads10(
|
|
11262
|
+
pointFrom12(
|
|
11263
|
+
points[1][0] + element.x,
|
|
11264
|
+
points[1][1] + element.y
|
|
11265
|
+
),
|
|
11266
|
+
center,
|
|
11267
|
+
element.angle
|
|
11268
|
+
)
|
|
11269
|
+
)
|
|
11270
|
+
]
|
|
11271
|
+
);
|
|
11272
|
+
}
|
|
11273
|
+
function getFreedrawOutlinePoints(element) {
|
|
11158
11274
|
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
11275
|
const options = {
|
|
11160
11276
|
simulatePressure: element.simulatePressure,
|
|
@@ -11167,7 +11283,7 @@ function getFreeDrawSvgPath(element) {
|
|
|
11167
11283
|
last: !!element.lastCommittedPoint
|
|
11168
11284
|
// LastCommittedPoint is added on pointerup
|
|
11169
11285
|
};
|
|
11170
|
-
return
|
|
11286
|
+
return ae(inputPoints, options);
|
|
11171
11287
|
}
|
|
11172
11288
|
function med(A2, B2) {
|
|
11173
11289
|
return [(A2[0] + B2[0]) / 2, (A2[1] + B2[1]) / 2];
|
|
@@ -11450,26 +11566,26 @@ var generateLinearCollisionShape = (element) => {
|
|
|
11450
11566
|
switch (element.type) {
|
|
11451
11567
|
case "line":
|
|
11452
11568
|
case "arrow": {
|
|
11453
|
-
const points = element.points.length ? element.points : [
|
|
11569
|
+
const points = element.points.length ? element.points : [pointFrom13(0, 0)];
|
|
11454
11570
|
if (isElbowArrow(element)) {
|
|
11455
11571
|
return generator.path(generateElbowArrowShape(points, 16), options).sets[0].ops;
|
|
11456
11572
|
} else if (!element.roundness) {
|
|
11457
11573
|
return points.map((point, idx) => {
|
|
11458
|
-
const p =
|
|
11459
|
-
|
|
11574
|
+
const p = pointRotateRads11(
|
|
11575
|
+
pointFrom13(element.x + point[0], element.y + point[1]),
|
|
11460
11576
|
center,
|
|
11461
11577
|
element.angle
|
|
11462
11578
|
);
|
|
11463
11579
|
return {
|
|
11464
11580
|
op: idx === 0 ? "move" : "lineTo",
|
|
11465
|
-
data:
|
|
11581
|
+
data: pointFrom13(p[0] - element.x, p[1] - element.y)
|
|
11466
11582
|
};
|
|
11467
11583
|
});
|
|
11468
11584
|
}
|
|
11469
11585
|
return generator.curve(points, options).sets[0].ops.slice(0, element.points.length).map((op, i) => {
|
|
11470
11586
|
if (i === 0) {
|
|
11471
|
-
const p =
|
|
11472
|
-
|
|
11587
|
+
const p = pointRotateRads11(
|
|
11588
|
+
pointFrom13(
|
|
11473
11589
|
element.x + op.data[0],
|
|
11474
11590
|
element.y + op.data[1]
|
|
11475
11591
|
),
|
|
@@ -11478,30 +11594,30 @@ var generateLinearCollisionShape = (element) => {
|
|
|
11478
11594
|
);
|
|
11479
11595
|
return {
|
|
11480
11596
|
op: "move",
|
|
11481
|
-
data:
|
|
11597
|
+
data: pointFrom13(p[0] - element.x, p[1] - element.y)
|
|
11482
11598
|
};
|
|
11483
11599
|
}
|
|
11484
11600
|
return {
|
|
11485
11601
|
op: "bcurveTo",
|
|
11486
11602
|
data: [
|
|
11487
|
-
|
|
11488
|
-
|
|
11603
|
+
pointRotateRads11(
|
|
11604
|
+
pointFrom13(
|
|
11489
11605
|
element.x + op.data[0],
|
|
11490
11606
|
element.y + op.data[1]
|
|
11491
11607
|
),
|
|
11492
11608
|
center,
|
|
11493
11609
|
element.angle
|
|
11494
11610
|
),
|
|
11495
|
-
|
|
11496
|
-
|
|
11611
|
+
pointRotateRads11(
|
|
11612
|
+
pointFrom13(
|
|
11497
11613
|
element.x + op.data[2],
|
|
11498
11614
|
element.y + op.data[3]
|
|
11499
11615
|
),
|
|
11500
11616
|
center,
|
|
11501
11617
|
element.angle
|
|
11502
11618
|
),
|
|
11503
|
-
|
|
11504
|
-
|
|
11619
|
+
pointRotateRads11(
|
|
11620
|
+
pointFrom13(
|
|
11505
11621
|
element.x + op.data[4],
|
|
11506
11622
|
element.y + op.data[5]
|
|
11507
11623
|
),
|
|
@@ -11509,7 +11625,7 @@ var generateLinearCollisionShape = (element) => {
|
|
|
11509
11625
|
element.angle
|
|
11510
11626
|
)
|
|
11511
11627
|
].map(
|
|
11512
|
-
(p) =>
|
|
11628
|
+
(p) => pointFrom13(p[0] - element.x, p[1] - element.y)
|
|
11513
11629
|
).flat()
|
|
11514
11630
|
};
|
|
11515
11631
|
});
|
|
@@ -11524,8 +11640,8 @@ var generateLinearCollisionShape = (element) => {
|
|
|
11524
11640
|
);
|
|
11525
11641
|
return generator.curve(simplifiedPoints, options).sets[0].ops.slice(0, element.points.length).map((op, i) => {
|
|
11526
11642
|
if (i === 0) {
|
|
11527
|
-
const p =
|
|
11528
|
-
|
|
11643
|
+
const p = pointRotateRads11(
|
|
11644
|
+
pointFrom13(
|
|
11529
11645
|
element.x + op.data[0],
|
|
11530
11646
|
element.y + op.data[1]
|
|
11531
11647
|
),
|
|
@@ -11534,30 +11650,30 @@ var generateLinearCollisionShape = (element) => {
|
|
|
11534
11650
|
);
|
|
11535
11651
|
return {
|
|
11536
11652
|
op: "move",
|
|
11537
|
-
data:
|
|
11653
|
+
data: pointFrom13(p[0] - element.x, p[1] - element.y)
|
|
11538
11654
|
};
|
|
11539
11655
|
}
|
|
11540
11656
|
return {
|
|
11541
11657
|
op: "bcurveTo",
|
|
11542
11658
|
data: [
|
|
11543
|
-
|
|
11544
|
-
|
|
11659
|
+
pointRotateRads11(
|
|
11660
|
+
pointFrom13(
|
|
11545
11661
|
element.x + op.data[0],
|
|
11546
11662
|
element.y + op.data[1]
|
|
11547
11663
|
),
|
|
11548
11664
|
center,
|
|
11549
11665
|
element.angle
|
|
11550
11666
|
),
|
|
11551
|
-
|
|
11552
|
-
|
|
11667
|
+
pointRotateRads11(
|
|
11668
|
+
pointFrom13(
|
|
11553
11669
|
element.x + op.data[2],
|
|
11554
11670
|
element.y + op.data[3]
|
|
11555
11671
|
),
|
|
11556
11672
|
center,
|
|
11557
11673
|
element.angle
|
|
11558
11674
|
),
|
|
11559
|
-
|
|
11560
|
-
|
|
11675
|
+
pointRotateRads11(
|
|
11676
|
+
pointFrom13(
|
|
11561
11677
|
element.x + op.data[4],
|
|
11562
11678
|
element.y + op.data[5]
|
|
11563
11679
|
),
|
|
@@ -11565,7 +11681,7 @@ var generateLinearCollisionShape = (element) => {
|
|
|
11565
11681
|
element.angle
|
|
11566
11682
|
)
|
|
11567
11683
|
].map(
|
|
11568
|
-
(p) =>
|
|
11684
|
+
(p) => pointFrom13(p[0] - element.x, p[1] - element.y)
|
|
11569
11685
|
).flat()
|
|
11570
11686
|
};
|
|
11571
11687
|
});
|
|
@@ -11662,7 +11778,7 @@ var generateElementShape = (element, generator, {
|
|
|
11662
11778
|
case "arrow": {
|
|
11663
11779
|
let shape;
|
|
11664
11780
|
const options = generateRoughOptions(element);
|
|
11665
|
-
const points = element.points.length ? element.points : [
|
|
11781
|
+
const points = element.points.length ? element.points : [pointFrom13(0, 0)];
|
|
11666
11782
|
if (isElbowArrow(element)) {
|
|
11667
11783
|
if (!points.every(
|
|
11668
11784
|
(point) => Math.abs(point[0]) <= 1e6 && Math.abs(point[1]) <= 1e6
|
|
@@ -11824,14 +11940,14 @@ var getElementShape = (element, elementsMap) => {
|
|
|
11824
11940
|
return shouldTestInside(element) ? getClosedCurveShape(
|
|
11825
11941
|
element,
|
|
11826
11942
|
roughShape,
|
|
11827
|
-
|
|
11943
|
+
pointFrom13(element.x, element.y),
|
|
11828
11944
|
element.angle,
|
|
11829
|
-
|
|
11945
|
+
pointFrom13(cx, cy)
|
|
11830
11946
|
) : getCurveShape(
|
|
11831
11947
|
roughShape,
|
|
11832
|
-
|
|
11948
|
+
pointFrom13(element.x, element.y),
|
|
11833
11949
|
element.angle,
|
|
11834
|
-
|
|
11950
|
+
pointFrom13(cx, cy)
|
|
11835
11951
|
);
|
|
11836
11952
|
}
|
|
11837
11953
|
case "ellipse":
|
|
@@ -11840,7 +11956,7 @@ var getElementShape = (element, elementsMap) => {
|
|
|
11840
11956
|
const [, , , , cx, cy] = getElementAbsoluteCoords2(element, elementsMap);
|
|
11841
11957
|
return getFreedrawShape(
|
|
11842
11958
|
element,
|
|
11843
|
-
|
|
11959
|
+
pointFrom13(cx, cy),
|
|
11844
11960
|
shouldTestInside(element)
|
|
11845
11961
|
);
|
|
11846
11962
|
}
|
|
@@ -11859,9 +11975,9 @@ var toggleLinePolygonState = (element, nextPolygonState) => {
|
|
|
11859
11975
|
firstPoint[1] - lastPoint[1]
|
|
11860
11976
|
);
|
|
11861
11977
|
if (distance3 > LINE_POLYGON_POINT_MERGE_DISTANCE || updatedPoints.length < 4) {
|
|
11862
|
-
updatedPoints.push(
|
|
11978
|
+
updatedPoints.push(pointFrom13(firstPoint[0], firstPoint[1]));
|
|
11863
11979
|
} else {
|
|
11864
|
-
updatedPoints[updatedPoints.length - 1] =
|
|
11980
|
+
updatedPoints[updatedPoints.length - 1] = pointFrom13(
|
|
11865
11981
|
firstPoint[0],
|
|
11866
11982
|
firstPoint[1]
|
|
11867
11983
|
);
|
|
@@ -11915,9 +12031,9 @@ var ElementBounds = class _ElementBounds {
|
|
|
11915
12031
|
if (isFreeDrawElement(element)) {
|
|
11916
12032
|
const [minX, minY, maxX, maxY] = getBoundsFromPoints(
|
|
11917
12033
|
element.points.map(
|
|
11918
|
-
([x, y]) =>
|
|
11919
|
-
|
|
11920
|
-
|
|
12034
|
+
([x, y]) => pointRotateRads12(
|
|
12035
|
+
pointFrom14(x, y),
|
|
12036
|
+
pointFrom14(cx - element.x, cy - element.y),
|
|
11921
12037
|
element.angle
|
|
11922
12038
|
)
|
|
11923
12039
|
)
|
|
@@ -11931,24 +12047,24 @@ var ElementBounds = class _ElementBounds {
|
|
|
11931
12047
|
} else if (isLinearElement(element)) {
|
|
11932
12048
|
bounds = getLinearElementRotatedBounds(element, cx, cy, elementsMap);
|
|
11933
12049
|
} else if (element.type === "diamond") {
|
|
11934
|
-
const [x11, y11] =
|
|
11935
|
-
|
|
11936
|
-
|
|
12050
|
+
const [x11, y11] = pointRotateRads12(
|
|
12051
|
+
pointFrom14(cx, y1),
|
|
12052
|
+
pointFrom14(cx, cy),
|
|
11937
12053
|
element.angle
|
|
11938
12054
|
);
|
|
11939
|
-
const [x12, y12] =
|
|
11940
|
-
|
|
11941
|
-
|
|
12055
|
+
const [x12, y12] = pointRotateRads12(
|
|
12056
|
+
pointFrom14(cx, y2),
|
|
12057
|
+
pointFrom14(cx, cy),
|
|
11942
12058
|
element.angle
|
|
11943
12059
|
);
|
|
11944
|
-
const [x22, y22] =
|
|
11945
|
-
|
|
11946
|
-
|
|
12060
|
+
const [x22, y22] = pointRotateRads12(
|
|
12061
|
+
pointFrom14(x1, cy),
|
|
12062
|
+
pointFrom14(cx, cy),
|
|
11947
12063
|
element.angle
|
|
11948
12064
|
);
|
|
11949
|
-
const [x21, y21] =
|
|
11950
|
-
|
|
11951
|
-
|
|
12065
|
+
const [x21, y21] = pointRotateRads12(
|
|
12066
|
+
pointFrom14(x2, cy),
|
|
12067
|
+
pointFrom14(cx, cy),
|
|
11952
12068
|
element.angle
|
|
11953
12069
|
);
|
|
11954
12070
|
const minX = Math.min(x11, x12, x22, x21);
|
|
@@ -11965,24 +12081,24 @@ var ElementBounds = class _ElementBounds {
|
|
|
11965
12081
|
const hh = Math.hypot(h * cos, w * sin);
|
|
11966
12082
|
bounds = [cx - ww, cy - hh, cx + ww, cy + hh];
|
|
11967
12083
|
} else {
|
|
11968
|
-
const [x11, y11] =
|
|
11969
|
-
|
|
11970
|
-
|
|
12084
|
+
const [x11, y11] = pointRotateRads12(
|
|
12085
|
+
pointFrom14(x1, y1),
|
|
12086
|
+
pointFrom14(cx, cy),
|
|
11971
12087
|
element.angle
|
|
11972
12088
|
);
|
|
11973
|
-
const [x12, y12] =
|
|
11974
|
-
|
|
11975
|
-
|
|
12089
|
+
const [x12, y12] = pointRotateRads12(
|
|
12090
|
+
pointFrom14(x1, y2),
|
|
12091
|
+
pointFrom14(cx, cy),
|
|
11976
12092
|
element.angle
|
|
11977
12093
|
);
|
|
11978
|
-
const [x22, y22] =
|
|
11979
|
-
|
|
11980
|
-
|
|
12094
|
+
const [x22, y22] = pointRotateRads12(
|
|
12095
|
+
pointFrom14(x2, y2),
|
|
12096
|
+
pointFrom14(cx, cy),
|
|
11981
12097
|
element.angle
|
|
11982
12098
|
);
|
|
11983
|
-
const [x21, y21] =
|
|
11984
|
-
|
|
11985
|
-
|
|
12099
|
+
const [x21, y21] = pointRotateRads12(
|
|
12100
|
+
pointFrom14(x2, y1),
|
|
12101
|
+
pointFrom14(cx, cy),
|
|
11986
12102
|
element.angle
|
|
11987
12103
|
);
|
|
11988
12104
|
const minX = Math.min(x11, x12, x22, x21);
|
|
@@ -12036,20 +12152,38 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
12036
12152
|
element,
|
|
12037
12153
|
elementsMap
|
|
12038
12154
|
);
|
|
12039
|
-
const center =
|
|
12155
|
+
const center = pointFrom14(cx, cy);
|
|
12040
12156
|
if (shape.type === "polycurve") {
|
|
12041
12157
|
const curves = shape.data;
|
|
12042
|
-
const
|
|
12043
|
-
|
|
12158
|
+
const pointsOnCurves = curves.map(
|
|
12159
|
+
(curve4) => pointsOnBezierCurves(curve4, 10)
|
|
12160
|
+
);
|
|
12044
12161
|
const segments = [];
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12162
|
+
if (isLineElement(element) && !element.polygon || isArrowElement(element)) {
|
|
12163
|
+
for (const points of pointsOnCurves) {
|
|
12164
|
+
let i = 0;
|
|
12165
|
+
while (i < points.length - 1) {
|
|
12166
|
+
segments.push(
|
|
12167
|
+
lineSegment6(
|
|
12168
|
+
pointFrom14(points[i][0], points[i][1]),
|
|
12169
|
+
pointFrom14(points[i + 1][0], points[i + 1][1])
|
|
12170
|
+
)
|
|
12171
|
+
);
|
|
12172
|
+
i++;
|
|
12173
|
+
}
|
|
12174
|
+
}
|
|
12175
|
+
} else {
|
|
12176
|
+
const points = pointsOnCurves.flat();
|
|
12177
|
+
let i = 0;
|
|
12178
|
+
while (i < points.length - 1) {
|
|
12179
|
+
segments.push(
|
|
12180
|
+
lineSegment6(
|
|
12181
|
+
pointFrom14(points[i][0], points[i][1]),
|
|
12182
|
+
pointFrom14(points[i + 1][0], points[i + 1][1])
|
|
12183
|
+
)
|
|
12184
|
+
);
|
|
12185
|
+
i++;
|
|
12186
|
+
}
|
|
12053
12187
|
}
|
|
12054
12188
|
return segments;
|
|
12055
12189
|
} else if (shape.type === "polyline") {
|
|
@@ -12069,10 +12203,10 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
12069
12203
|
const container = getContainerElement(element, elementsMap);
|
|
12070
12204
|
if (container && isLinearElement(container)) {
|
|
12071
12205
|
const segments2 = [
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12206
|
+
lineSegment6(pointFrom14(x1, y1), pointFrom14(x2, y1)),
|
|
12207
|
+
lineSegment6(pointFrom14(x2, y1), pointFrom14(x2, y2)),
|
|
12208
|
+
lineSegment6(pointFrom14(x2, y2), pointFrom14(x1, y2)),
|
|
12209
|
+
lineSegment6(pointFrom14(x1, y2), pointFrom14(x1, y1))
|
|
12076
12210
|
];
|
|
12077
12211
|
return segments2;
|
|
12078
12212
|
}
|
|
@@ -12080,7 +12214,7 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
12080
12214
|
const points = shape.data;
|
|
12081
12215
|
const segments = [];
|
|
12082
12216
|
for (let i = 0; i < points.length - 1; i++) {
|
|
12083
|
-
segments.push(
|
|
12217
|
+
segments.push(lineSegment6(points[i], points[i + 1]));
|
|
12084
12218
|
}
|
|
12085
12219
|
return segments;
|
|
12086
12220
|
} else if (shape.type === "ellipse") {
|
|
@@ -12095,16 +12229,16 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
12095
12229
|
[cx, y2],
|
|
12096
12230
|
[x1, cy],
|
|
12097
12231
|
[x2, cy]
|
|
12098
|
-
].map((point) =>
|
|
12232
|
+
].map((point) => pointRotateRads12(point, center, element.angle));
|
|
12099
12233
|
return [
|
|
12100
|
-
|
|
12101
|
-
|
|
12102
|
-
|
|
12103
|
-
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
|
|
12107
|
-
|
|
12234
|
+
lineSegment6(nw, ne),
|
|
12235
|
+
lineSegment6(sw, se2),
|
|
12236
|
+
lineSegment6(nw, sw),
|
|
12237
|
+
lineSegment6(ne, se2),
|
|
12238
|
+
lineSegment6(nw, e),
|
|
12239
|
+
lineSegment6(sw, e),
|
|
12240
|
+
lineSegment6(ne, w),
|
|
12241
|
+
lineSegment6(se2, w)
|
|
12108
12242
|
];
|
|
12109
12243
|
};
|
|
12110
12244
|
var _isRectanguloidElement = (element) => {
|
|
@@ -12112,9 +12246,9 @@ var _isRectanguloidElement = (element) => {
|
|
|
12112
12246
|
};
|
|
12113
12247
|
var getRotatedSides = (sides, center, angle) => {
|
|
12114
12248
|
return sides.map((side) => {
|
|
12115
|
-
return
|
|
12116
|
-
|
|
12117
|
-
|
|
12249
|
+
return lineSegment6(
|
|
12250
|
+
pointRotateRads12(side[0], center, angle),
|
|
12251
|
+
pointRotateRads12(side[1], center, angle)
|
|
12118
12252
|
);
|
|
12119
12253
|
});
|
|
12120
12254
|
};
|
|
@@ -12124,14 +12258,14 @@ var getSegmentsOnCurve = (curve4, center, angle) => {
|
|
|
12124
12258
|
const segments = [];
|
|
12125
12259
|
while (i < points.length - 1) {
|
|
12126
12260
|
segments.push(
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
12261
|
+
lineSegment6(
|
|
12262
|
+
pointRotateRads12(
|
|
12263
|
+
pointFrom14(points[i][0], points[i][1]),
|
|
12130
12264
|
center,
|
|
12131
12265
|
angle
|
|
12132
12266
|
),
|
|
12133
|
-
|
|
12134
|
-
|
|
12267
|
+
pointRotateRads12(
|
|
12268
|
+
pointFrom14(points[i + 1][0], points[i + 1][1]),
|
|
12135
12269
|
center,
|
|
12136
12270
|
angle
|
|
12137
12271
|
)
|
|
@@ -12142,7 +12276,7 @@ var getSegmentsOnCurve = (curve4, center, angle) => {
|
|
|
12142
12276
|
return segments;
|
|
12143
12277
|
};
|
|
12144
12278
|
var getSegmentsOnEllipse = (ellipse4) => {
|
|
12145
|
-
const center =
|
|
12279
|
+
const center = pointFrom14(
|
|
12146
12280
|
ellipse4.x + ellipse4.width / 2,
|
|
12147
12281
|
ellipse4.y + ellipse4.height / 2
|
|
12148
12282
|
);
|
|
@@ -12156,12 +12290,12 @@ var getSegmentsOnEllipse = (ellipse4) => {
|
|
|
12156
12290
|
const t = i * deltaT;
|
|
12157
12291
|
const x = center[0] + a2 * Math.cos(t);
|
|
12158
12292
|
const y = center[1] + b2 * Math.sin(t);
|
|
12159
|
-
points.push(
|
|
12293
|
+
points.push(pointRotateRads12(pointFrom14(x, y), center, ellipse4.angle));
|
|
12160
12294
|
}
|
|
12161
12295
|
for (let i = 0; i < points.length - 1; i++) {
|
|
12162
|
-
segments.push(
|
|
12296
|
+
segments.push(lineSegment6(points[i], points[i + 1]));
|
|
12163
12297
|
}
|
|
12164
|
-
segments.push(
|
|
12298
|
+
segments.push(lineSegment6(points[points.length - 1], points[0]));
|
|
12165
12299
|
return segments;
|
|
12166
12300
|
};
|
|
12167
12301
|
var getRectangleBoxAbsoluteCoords = (boxSceneCoords) => {
|
|
@@ -12239,17 +12373,17 @@ var getCubicBezierCurveBound = (p0, p1, p2, p3) => {
|
|
|
12239
12373
|
return [minX, minY, maxX, maxY];
|
|
12240
12374
|
};
|
|
12241
12375
|
var getMinMaxXYFromCurvePathOps = (ops, transformXY) => {
|
|
12242
|
-
let currentP =
|
|
12376
|
+
let currentP = pointFrom14(0, 0);
|
|
12243
12377
|
const { minX, minY, maxX, maxY } = ops.reduce(
|
|
12244
12378
|
(limits, { op, data }) => {
|
|
12245
12379
|
if (op === "move") {
|
|
12246
12380
|
const p = pointFromArray3(data);
|
|
12247
|
-
|
|
12381
|
+
invariant8(p != null, "Op data is not a point");
|
|
12248
12382
|
currentP = p;
|
|
12249
12383
|
} else if (op === "bcurveTo") {
|
|
12250
|
-
const _p1 =
|
|
12251
|
-
const _p2 =
|
|
12252
|
-
const _p3 =
|
|
12384
|
+
const _p1 = pointFrom14(data[0], data[1]);
|
|
12385
|
+
const _p2 = pointFrom14(data[2], data[3]);
|
|
12386
|
+
const _p3 = pointFrom14(data[4], data[5]);
|
|
12253
12387
|
const p1 = transformXY ? transformXY(_p1) : _p1;
|
|
12254
12388
|
const p2 = transformXY ? transformXY(_p2) : _p2;
|
|
12255
12389
|
const p3 = transformXY ? transformXY(_p3) : _p3;
|
|
@@ -12330,18 +12464,18 @@ var getArrowheadPoints = (element, shape, position, arrowhead) => {
|
|
|
12330
12464
|
}
|
|
12331
12465
|
const index = position === "start" ? 1 : ops.length - 1;
|
|
12332
12466
|
const data = ops[index].data;
|
|
12333
|
-
|
|
12334
|
-
const p3 =
|
|
12335
|
-
const p2 =
|
|
12336
|
-
const p1 =
|
|
12467
|
+
invariant8(data.length === 6, "Op data length is not 6");
|
|
12468
|
+
const p3 = pointFrom14(data[4], data[5]);
|
|
12469
|
+
const p2 = pointFrom14(data[2], data[3]);
|
|
12470
|
+
const p1 = pointFrom14(data[0], data[1]);
|
|
12337
12471
|
const prevOp = ops[index - 1];
|
|
12338
|
-
let p0 =
|
|
12472
|
+
let p0 = pointFrom14(0, 0);
|
|
12339
12473
|
if (prevOp.op === "move") {
|
|
12340
12474
|
const p = pointFromArray3(prevOp.data);
|
|
12341
|
-
|
|
12475
|
+
invariant8(p != null, "Op data is not a point");
|
|
12342
12476
|
p0 = p;
|
|
12343
12477
|
} else if (prevOp.op === "bcurveTo") {
|
|
12344
|
-
p0 =
|
|
12478
|
+
p0 = pointFrom14(prevOp.data[4], prevOp.data[5]);
|
|
12345
12479
|
}
|
|
12346
12480
|
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
12481
|
const [x2, y2] = position === "start" ? p0 : p3;
|
|
@@ -12366,26 +12500,26 @@ var getArrowheadPoints = (element, shape, position, arrowhead) => {
|
|
|
12366
12500
|
}
|
|
12367
12501
|
const angle = getArrowheadAngle(arrowhead);
|
|
12368
12502
|
if (arrowhead === "crowfoot_many" || arrowhead === "crowfoot_one_or_many") {
|
|
12369
|
-
const [x32, y32] =
|
|
12370
|
-
|
|
12371
|
-
|
|
12503
|
+
const [x32, y32] = pointRotateRads12(
|
|
12504
|
+
pointFrom14(x2, y2),
|
|
12505
|
+
pointFrom14(xs, ys),
|
|
12372
12506
|
degreesToRadians(-angle)
|
|
12373
12507
|
);
|
|
12374
|
-
const [x42, y42] =
|
|
12375
|
-
|
|
12376
|
-
|
|
12508
|
+
const [x42, y42] = pointRotateRads12(
|
|
12509
|
+
pointFrom14(x2, y2),
|
|
12510
|
+
pointFrom14(xs, ys),
|
|
12377
12511
|
degreesToRadians(angle)
|
|
12378
12512
|
);
|
|
12379
12513
|
return [xs, ys, x32, y32, x42, y42];
|
|
12380
12514
|
}
|
|
12381
|
-
const [x3, y3] =
|
|
12382
|
-
|
|
12383
|
-
|
|
12515
|
+
const [x3, y3] = pointRotateRads12(
|
|
12516
|
+
pointFrom14(xs, ys),
|
|
12517
|
+
pointFrom14(x2, y2),
|
|
12384
12518
|
-angle * Math.PI / 180
|
|
12385
12519
|
);
|
|
12386
|
-
const [x4, y4] =
|
|
12387
|
-
|
|
12388
|
-
|
|
12520
|
+
const [x4, y4] = pointRotateRads12(
|
|
12521
|
+
pointFrom14(xs, ys),
|
|
12522
|
+
pointFrom14(x2, y2),
|
|
12389
12523
|
degreesToRadians(angle)
|
|
12390
12524
|
);
|
|
12391
12525
|
if (arrowhead === "diamond" || arrowhead === "diamond_outline") {
|
|
@@ -12393,16 +12527,16 @@ var getArrowheadPoints = (element, shape, position, arrowhead) => {
|
|
|
12393
12527
|
let oy;
|
|
12394
12528
|
if (position === "start") {
|
|
12395
12529
|
const [px, py] = element.points.length > 1 ? element.points[1] : [0, 0];
|
|
12396
|
-
[ox, oy] =
|
|
12397
|
-
|
|
12398
|
-
|
|
12530
|
+
[ox, oy] = pointRotateRads12(
|
|
12531
|
+
pointFrom14(x2 + minSize * 2, y2),
|
|
12532
|
+
pointFrom14(x2, y2),
|
|
12399
12533
|
Math.atan2(py - y2, px - x2)
|
|
12400
12534
|
);
|
|
12401
12535
|
} else {
|
|
12402
12536
|
const [px, py] = element.points.length > 1 ? element.points[element.points.length - 2] : [0, 0];
|
|
12403
|
-
[ox, oy] =
|
|
12404
|
-
|
|
12405
|
-
|
|
12537
|
+
[ox, oy] = pointRotateRads12(
|
|
12538
|
+
pointFrom14(x2 - minSize * 2, y2),
|
|
12539
|
+
pointFrom14(x2, y2),
|
|
12406
12540
|
Math.atan2(y2 - py, x2 - px)
|
|
12407
12541
|
);
|
|
12408
12542
|
}
|
|
@@ -12431,9 +12565,9 @@ var getLinearElementRotatedBounds = (element, cx, cy, elementsMap) => {
|
|
|
12431
12565
|
const boundTextElement = getBoundTextElement(element, elementsMap);
|
|
12432
12566
|
if (element.points.length < 2) {
|
|
12433
12567
|
const [pointX, pointY] = element.points[0];
|
|
12434
|
-
const [x, y] =
|
|
12435
|
-
|
|
12436
|
-
|
|
12568
|
+
const [x, y] = pointRotateRads12(
|
|
12569
|
+
pointFrom14(element.x + pointX, element.y + pointY),
|
|
12570
|
+
pointFrom14(cx, cy),
|
|
12437
12571
|
element.angle
|
|
12438
12572
|
);
|
|
12439
12573
|
let coords2 = [x, y, x, y];
|
|
@@ -12456,9 +12590,9 @@ var getLinearElementRotatedBounds = (element, cx, cy, elementsMap) => {
|
|
|
12456
12590
|
const cachedShape = ShapeCache.get(element)?.[0];
|
|
12457
12591
|
const shape = cachedShape ?? generateLinearElementShape(element);
|
|
12458
12592
|
const ops = getCurvePathOps(shape);
|
|
12459
|
-
const transformXY = ([x, y]) =>
|
|
12460
|
-
|
|
12461
|
-
|
|
12593
|
+
const transformXY = ([x, y]) => pointRotateRads12(
|
|
12594
|
+
pointFrom14(element.x + x, element.y + y),
|
|
12595
|
+
pointFrom14(cx, cy),
|
|
12462
12596
|
element.angle
|
|
12463
12597
|
);
|
|
12464
12598
|
const res = getMinMaxXYFromCurvePathOps(ops, transformXY);
|
|
@@ -12569,8 +12703,8 @@ var getClosestElementBounds = (elements, from) => {
|
|
|
12569
12703
|
elements.forEach((element) => {
|
|
12570
12704
|
const [x1, y1, x2, y2] = getElementBounds(element, elementsMap);
|
|
12571
12705
|
const distance3 = pointDistance7(
|
|
12572
|
-
|
|
12573
|
-
|
|
12706
|
+
pointFrom14((x1 + x2) / 2, (y1 + y2) / 2),
|
|
12707
|
+
pointFrom14(from.x, from.y)
|
|
12574
12708
|
);
|
|
12575
12709
|
if (distance3 < minDistance) {
|
|
12576
12710
|
minDistance = distance3;
|
|
@@ -12606,7 +12740,7 @@ var getVisibleSceneBounds = ({
|
|
|
12606
12740
|
-scrollY + height / zoom.value
|
|
12607
12741
|
];
|
|
12608
12742
|
};
|
|
12609
|
-
var getCenterForBounds = (bounds) =>
|
|
12743
|
+
var getCenterForBounds = (bounds) => pointFrom14(
|
|
12610
12744
|
bounds[0] + (bounds[2] - bounds[0]) / 2,
|
|
12611
12745
|
bounds[1] + (bounds[3] - bounds[1]) / 2
|
|
12612
12746
|
);
|
|
@@ -12620,23 +12754,23 @@ var aabbForElement = (element, elementsMap, offset) => {
|
|
|
12620
12754
|
midY: element.y + element.height / 2
|
|
12621
12755
|
};
|
|
12622
12756
|
const center = elementCenterPoint(element, elementsMap);
|
|
12623
|
-
const [topLeftX, topLeftY] =
|
|
12624
|
-
|
|
12757
|
+
const [topLeftX, topLeftY] = pointRotateRads12(
|
|
12758
|
+
pointFrom14(bbox.minX, bbox.minY),
|
|
12625
12759
|
center,
|
|
12626
12760
|
element.angle
|
|
12627
12761
|
);
|
|
12628
|
-
const [topRightX, topRightY] =
|
|
12629
|
-
|
|
12762
|
+
const [topRightX, topRightY] = pointRotateRads12(
|
|
12763
|
+
pointFrom14(bbox.maxX, bbox.minY),
|
|
12630
12764
|
center,
|
|
12631
12765
|
element.angle
|
|
12632
12766
|
);
|
|
12633
|
-
const [bottomRightX, bottomRightY] =
|
|
12634
|
-
|
|
12767
|
+
const [bottomRightX, bottomRightY] = pointRotateRads12(
|
|
12768
|
+
pointFrom14(bbox.maxX, bbox.maxY),
|
|
12635
12769
|
center,
|
|
12636
12770
|
element.angle
|
|
12637
12771
|
);
|
|
12638
|
-
const [bottomLeftX, bottomLeftY] =
|
|
12639
|
-
|
|
12772
|
+
const [bottomLeftX, bottomLeftY] = pointRotateRads12(
|
|
12773
|
+
pointFrom14(bbox.minX, bbox.maxY),
|
|
12640
12774
|
center,
|
|
12641
12775
|
element.angle
|
|
12642
12776
|
);
|
|
@@ -12668,7 +12802,7 @@ var doBoundsIntersect = (bounds1, bounds2) => {
|
|
|
12668
12802
|
};
|
|
12669
12803
|
var elementCenterPoint = (element, elementsMap, xOffset = 0, yOffset = 0) => {
|
|
12670
12804
|
const [x, y] = getCenterForBounds(getElementBounds(element, elementsMap));
|
|
12671
|
-
return
|
|
12805
|
+
return pointFrom14(x + xOffset, y + yOffset);
|
|
12672
12806
|
};
|
|
12673
12807
|
|
|
12674
12808
|
// src/sizeHelpers.ts
|
|
@@ -13495,7 +13629,7 @@ var EphemeralIncrement = class extends StoreIncrement {
|
|
|
13495
13629
|
this.change = change;
|
|
13496
13630
|
}
|
|
13497
13631
|
};
|
|
13498
|
-
var StoreDelta = class {
|
|
13632
|
+
var StoreDelta = class _StoreDelta {
|
|
13499
13633
|
constructor(id, elements, appState) {
|
|
13500
13634
|
this.id = id;
|
|
13501
13635
|
this.elements = elements;
|
|
@@ -13541,12 +13675,15 @@ var StoreDelta = class {
|
|
|
13541
13675
|
return new this(id, elements, appState);
|
|
13542
13676
|
}
|
|
13543
13677
|
/**
|
|
13544
|
-
* Squash the passed
|
|
13678
|
+
* Squash the passed deltas into the aggregated delta instance.
|
|
13545
13679
|
*/
|
|
13546
|
-
squash(
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13680
|
+
static squash(...deltas) {
|
|
13681
|
+
const aggregatedDelta = _StoreDelta.empty();
|
|
13682
|
+
for (const delta of deltas) {
|
|
13683
|
+
aggregatedDelta.elements.squash(delta.elements);
|
|
13684
|
+
aggregatedDelta.appState.squash(delta.appState);
|
|
13685
|
+
}
|
|
13686
|
+
return aggregatedDelta;
|
|
13550
13687
|
}
|
|
13551
13688
|
/**
|
|
13552
13689
|
* Inverse store delta, creates new instance of `StoreDelta`.
|
|
@@ -13583,6 +13720,9 @@ var StoreDelta = class {
|
|
|
13583
13720
|
}
|
|
13584
13721
|
);
|
|
13585
13722
|
}
|
|
13723
|
+
static empty() {
|
|
13724
|
+
return _StoreDelta.create(ElementsDelta.empty(), AppStateDelta.empty());
|
|
13725
|
+
}
|
|
13586
13726
|
isEmpty() {
|
|
13587
13727
|
return this.elements.isEmpty() && this.appState.isEmpty();
|
|
13588
13728
|
}
|
|
@@ -14651,18 +14791,18 @@ var Delta = class _Delta {
|
|
|
14651
14791
|
/**
|
|
14652
14792
|
* Merges two deltas into a new one.
|
|
14653
14793
|
*/
|
|
14654
|
-
static merge(delta1, delta2, delta3) {
|
|
14794
|
+
static merge(delta1, delta2, delta3 = _Delta.empty()) {
|
|
14655
14795
|
return _Delta.create(
|
|
14656
|
-
{ ...delta1.deleted, ...delta2.deleted, ...delta3
|
|
14657
|
-
{ ...delta1.inserted, ...delta2.inserted, ...delta3
|
|
14796
|
+
{ ...delta1.deleted, ...delta2.deleted, ...delta3.deleted },
|
|
14797
|
+
{ ...delta1.inserted, ...delta2.inserted, ...delta3.inserted }
|
|
14658
14798
|
);
|
|
14659
14799
|
}
|
|
14660
14800
|
/**
|
|
14661
14801
|
* Merges deleted and inserted object partials.
|
|
14662
14802
|
*/
|
|
14663
|
-
static mergeObjects(prev, added, removed) {
|
|
14803
|
+
static mergeObjects(prev, added, removed = {}) {
|
|
14664
14804
|
const cloned = { ...prev };
|
|
14665
|
-
for (const key of Object.keys(removed
|
|
14805
|
+
for (const key of Object.keys(removed)) {
|
|
14666
14806
|
delete cloned[key];
|
|
14667
14807
|
}
|
|
14668
14808
|
return { ...cloned, ...added };
|
|
@@ -14906,6 +15046,9 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14906
15046
|
return new _AppStateDelta(inversedDelta);
|
|
14907
15047
|
}
|
|
14908
15048
|
squash(delta) {
|
|
15049
|
+
if (delta.isEmpty()) {
|
|
15050
|
+
return this;
|
|
15051
|
+
}
|
|
14909
15052
|
const mergedDeletedSelectedElementIds = Delta.mergeObjects(
|
|
14910
15053
|
this.delta.deleted.selectedElementIds ?? {},
|
|
14911
15054
|
delta.delta.deleted.selectedElementIds ?? {}
|
|
@@ -14914,36 +15057,54 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14914
15057
|
this.delta.inserted.selectedElementIds ?? {},
|
|
14915
15058
|
delta.delta.inserted.selectedElementIds ?? {}
|
|
14916
15059
|
);
|
|
15060
|
+
const mergedDeletedSelectedGroupIds = Delta.mergeObjects(
|
|
15061
|
+
this.delta.deleted.selectedGroupIds ?? {},
|
|
15062
|
+
delta.delta.deleted.selectedGroupIds ?? {}
|
|
15063
|
+
);
|
|
14917
15064
|
const mergedInsertedSelectedGroupIds = Delta.mergeObjects(
|
|
14918
15065
|
this.delta.inserted.selectedGroupIds ?? {},
|
|
14919
15066
|
delta.delta.inserted.selectedGroupIds ?? {}
|
|
14920
15067
|
);
|
|
14921
|
-
const
|
|
14922
|
-
this.delta.deleted.
|
|
14923
|
-
delta.delta.deleted.
|
|
15068
|
+
const mergedDeletedLockedMultiSelections = Delta.mergeObjects(
|
|
15069
|
+
this.delta.deleted.lockedMultiSelections ?? {},
|
|
15070
|
+
delta.delta.deleted.lockedMultiSelections ?? {}
|
|
14924
15071
|
);
|
|
14925
|
-
const
|
|
14926
|
-
{
|
|
14927
|
-
|
|
14928
|
-
|
|
14929
|
-
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
|
|
14933
|
-
|
|
15072
|
+
const mergedInsertedLockedMultiSelections = Delta.mergeObjects(
|
|
15073
|
+
this.delta.inserted.lockedMultiSelections ?? {},
|
|
15074
|
+
delta.delta.inserted.lockedMultiSelections ?? {}
|
|
15075
|
+
);
|
|
15076
|
+
const mergedInserted = {};
|
|
15077
|
+
const mergedDeleted = {};
|
|
15078
|
+
if (Object.keys(mergedDeletedSelectedElementIds).length || Object.keys(mergedInsertedSelectedElementIds).length) {
|
|
15079
|
+
mergedDeleted.selectedElementIds = mergedDeletedSelectedElementIds;
|
|
15080
|
+
mergedInserted.selectedElementIds = mergedInsertedSelectedElementIds;
|
|
15081
|
+
}
|
|
15082
|
+
if (Object.keys(mergedDeletedSelectedGroupIds).length || Object.keys(mergedInsertedSelectedGroupIds).length) {
|
|
15083
|
+
mergedDeleted.selectedGroupIds = mergedDeletedSelectedGroupIds;
|
|
15084
|
+
mergedInserted.selectedGroupIds = mergedInsertedSelectedGroupIds;
|
|
15085
|
+
}
|
|
15086
|
+
if (Object.keys(mergedDeletedLockedMultiSelections).length || Object.keys(mergedInsertedLockedMultiSelections).length) {
|
|
15087
|
+
mergedDeleted.lockedMultiSelections = mergedDeletedLockedMultiSelections;
|
|
15088
|
+
mergedInserted.lockedMultiSelections = mergedInsertedLockedMultiSelections;
|
|
15089
|
+
}
|
|
15090
|
+
this.delta = Delta.merge(
|
|
15091
|
+
this.delta,
|
|
15092
|
+
delta.delta,
|
|
15093
|
+
Delta.create(mergedDeleted, mergedInserted)
|
|
14934
15094
|
);
|
|
14935
|
-
this.delta = Delta.merge(this.delta, delta.delta, mergedDelta);
|
|
14936
15095
|
return this;
|
|
14937
15096
|
}
|
|
14938
15097
|
applyTo(appState, nextElements) {
|
|
14939
15098
|
try {
|
|
14940
15099
|
const {
|
|
14941
15100
|
selectedElementIds: deletedSelectedElementIds = {},
|
|
14942
|
-
selectedGroupIds: deletedSelectedGroupIds = {}
|
|
15101
|
+
selectedGroupIds: deletedSelectedGroupIds = {},
|
|
15102
|
+
lockedMultiSelections: deletedLockedMultiSelections = {}
|
|
14943
15103
|
} = this.delta.deleted;
|
|
14944
15104
|
const {
|
|
14945
15105
|
selectedElementIds: insertedSelectedElementIds = {},
|
|
14946
15106
|
selectedGroupIds: insertedSelectedGroupIds = {},
|
|
15107
|
+
lockedMultiSelections: insertedLockedMultiSelections = {},
|
|
14947
15108
|
selectedLinearElement: insertedSelectedLinearElement,
|
|
14948
15109
|
...directlyApplicablePartial
|
|
14949
15110
|
} = this.delta.inserted;
|
|
@@ -14957,6 +15118,11 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14957
15118
|
insertedSelectedGroupIds,
|
|
14958
15119
|
deletedSelectedGroupIds
|
|
14959
15120
|
);
|
|
15121
|
+
const mergedLockedMultiSelections = Delta.mergeObjects(
|
|
15122
|
+
appState.lockedMultiSelections,
|
|
15123
|
+
insertedLockedMultiSelections,
|
|
15124
|
+
deletedLockedMultiSelections
|
|
15125
|
+
);
|
|
14960
15126
|
const selectedLinearElement = insertedSelectedLinearElement && nextElements.has(insertedSelectedLinearElement.elementId) ? new LinearElementEditor(
|
|
14961
15127
|
nextElements.get(
|
|
14962
15128
|
insertedSelectedLinearElement.elementId
|
|
@@ -14969,6 +15135,7 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
14969
15135
|
...directlyApplicablePartial,
|
|
14970
15136
|
selectedElementIds: mergedSelectedElementIds,
|
|
14971
15137
|
selectedGroupIds: mergedSelectedGroupIds,
|
|
15138
|
+
lockedMultiSelections: mergedLockedMultiSelections,
|
|
14972
15139
|
selectedLinearElement: typeof insertedSelectedLinearElement !== "undefined" ? selectedLinearElement : appState.selectedLinearElement
|
|
14973
15140
|
};
|
|
14974
15141
|
const constainsVisibleChanges = this.filterInvisibleChanges(
|
|
@@ -15172,12 +15339,6 @@ var AppStateDelta = class _AppStateDelta {
|
|
|
15172
15339
|
"lockedMultiSelections",
|
|
15173
15340
|
(prevValue) => prevValue ?? {}
|
|
15174
15341
|
);
|
|
15175
|
-
Delta.diffObjects(
|
|
15176
|
-
deleted,
|
|
15177
|
-
inserted,
|
|
15178
|
-
"activeLockedId",
|
|
15179
|
-
(prevValue) => prevValue ?? null
|
|
15180
|
-
);
|
|
15181
15342
|
} catch (e) {
|
|
15182
15343
|
console.error(`Couldn't postprocess appstate change deltas.`);
|
|
15183
15344
|
if (isTestEnv8() || isDevEnv7()) {
|
|
@@ -15256,13 +15417,17 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15256
15417
|
static satisfiesCommmonInvariants = ({
|
|
15257
15418
|
deleted,
|
|
15258
15419
|
inserted
|
|
15259
|
-
}) =>
|
|
15260
|
-
Number.isInteger(deleted.version) && Number.isInteger(inserted.version) && // versions should be positive, zero included
|
|
15420
|
+
}) => !!// versions are required integers
|
|
15421
|
+
(Number.isInteger(deleted.version) && Number.isInteger(inserted.version) && // versions should be positive, zero included
|
|
15261
15422
|
deleted.version >= 0 && inserted.version >= 0 && // versions should never be the same
|
|
15262
15423
|
deleted.version !== inserted.version);
|
|
15424
|
+
static satisfiesUniqueInvariants = (elementsDelta, id) => {
|
|
15425
|
+
const { added, removed, updated } = elementsDelta;
|
|
15426
|
+
return [added[id], removed[id], updated[id]].filter(Boolean).length === 1;
|
|
15427
|
+
};
|
|
15263
15428
|
static validate(elementsDelta, type, satifiesSpecialInvariants) {
|
|
15264
15429
|
for (const [id, delta] of Object.entries(elementsDelta[type])) {
|
|
15265
|
-
if (!this.satisfiesCommmonInvariants(delta) || !satifiesSpecialInvariants(delta)) {
|
|
15430
|
+
if (!this.satisfiesCommmonInvariants(delta) || !this.satisfiesUniqueInvariants(elementsDelta, id) || !satifiesSpecialInvariants(delta)) {
|
|
15266
15431
|
console.error(
|
|
15267
15432
|
`Broken invariant for "${type}" delta, element "${id}", delta:`,
|
|
15268
15433
|
delta
|
|
@@ -15302,6 +15467,8 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15302
15467
|
);
|
|
15303
15468
|
if (!prevElement.isDeleted) {
|
|
15304
15469
|
removed[prevElement.id] = delta;
|
|
15470
|
+
} else {
|
|
15471
|
+
updated[prevElement.id] = delta;
|
|
15305
15472
|
}
|
|
15306
15473
|
}
|
|
15307
15474
|
}
|
|
@@ -15323,6 +15490,8 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15323
15490
|
);
|
|
15324
15491
|
if (!nextElement.isDeleted) {
|
|
15325
15492
|
added[nextElement.id] = delta;
|
|
15493
|
+
} else {
|
|
15494
|
+
updated[nextElement.id] = delta;
|
|
15326
15495
|
}
|
|
15327
15496
|
continue;
|
|
15328
15497
|
}
|
|
@@ -15344,13 +15513,7 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15344
15513
|
}
|
|
15345
15514
|
continue;
|
|
15346
15515
|
}
|
|
15347
|
-
|
|
15348
|
-
const strippedInserted = _ElementsDelta.stripVersionProps(
|
|
15349
|
-
delta.inserted
|
|
15350
|
-
);
|
|
15351
|
-
if (Delta.isInnerDifferent(strippedDeleted, strippedInserted, true)) {
|
|
15352
|
-
updated[nextElement.id] = delta;
|
|
15353
|
-
}
|
|
15516
|
+
updated[nextElement.id] = delta;
|
|
15354
15517
|
}
|
|
15355
15518
|
}
|
|
15356
15519
|
return _ElementsDelta.create(added, removed, updated);
|
|
@@ -15426,13 +15589,7 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15426
15589
|
} else {
|
|
15427
15590
|
latestDelta = delta;
|
|
15428
15591
|
}
|
|
15429
|
-
|
|
15430
|
-
latestDelta.deleted
|
|
15431
|
-
);
|
|
15432
|
-
const strippedInserted = _ElementsDelta.stripVersionProps(
|
|
15433
|
-
latestDelta.inserted
|
|
15434
|
-
);
|
|
15435
|
-
if (Delta.isInnerDifferent(strippedDeleted, strippedInserted)) {
|
|
15592
|
+
if (Delta.isInnerDifferent(latestDelta.deleted, latestDelta.inserted)) {
|
|
15436
15593
|
modifiedDeltas[id] = latestDelta;
|
|
15437
15594
|
}
|
|
15438
15595
|
}
|
|
@@ -15503,8 +15660,11 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15503
15660
|
}
|
|
15504
15661
|
}
|
|
15505
15662
|
squash(delta) {
|
|
15663
|
+
if (delta.isEmpty()) {
|
|
15664
|
+
return this;
|
|
15665
|
+
}
|
|
15506
15666
|
const { added, removed, updated } = delta;
|
|
15507
|
-
|
|
15667
|
+
const mergeBoundElements = (prevDelta, nextDelta) => {
|
|
15508
15668
|
const mergedDeletedBoundElements = Delta.mergeArrays(
|
|
15509
15669
|
prevDelta.deleted.boundElements ?? [],
|
|
15510
15670
|
nextDelta.deleted.boundElements ?? [],
|
|
@@ -15517,6 +15677,9 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15517
15677
|
void 0,
|
|
15518
15678
|
(x) => x.id
|
|
15519
15679
|
) ?? [];
|
|
15680
|
+
if (!mergedDeletedBoundElements.length && !mergedInsertedBoundElements.length) {
|
|
15681
|
+
return;
|
|
15682
|
+
}
|
|
15520
15683
|
return Delta.create(
|
|
15521
15684
|
{
|
|
15522
15685
|
boundElements: mergedDeletedBoundElements
|
|
@@ -15525,34 +15688,50 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15525
15688
|
boundElements: mergedInsertedBoundElements
|
|
15526
15689
|
}
|
|
15527
15690
|
);
|
|
15528
|
-
}
|
|
15691
|
+
};
|
|
15529
15692
|
for (const [id, nextDelta] of Object.entries(added)) {
|
|
15530
|
-
const prevDelta = this.added[id];
|
|
15693
|
+
const prevDelta = this.added[id] ?? this.removed[id] ?? this.updated[id];
|
|
15531
15694
|
if (!prevDelta) {
|
|
15532
15695
|
this.added[id] = nextDelta;
|
|
15533
15696
|
} else {
|
|
15534
15697
|
const mergedDelta = mergeBoundElements(prevDelta, nextDelta);
|
|
15698
|
+
delete this.removed[id];
|
|
15699
|
+
delete this.updated[id];
|
|
15535
15700
|
this.added[id] = Delta.merge(prevDelta, nextDelta, mergedDelta);
|
|
15536
15701
|
}
|
|
15537
15702
|
}
|
|
15538
15703
|
for (const [id, nextDelta] of Object.entries(removed)) {
|
|
15539
|
-
const prevDelta = this.removed[id];
|
|
15704
|
+
const prevDelta = this.added[id] ?? this.removed[id] ?? this.updated[id];
|
|
15540
15705
|
if (!prevDelta) {
|
|
15541
15706
|
this.removed[id] = nextDelta;
|
|
15542
15707
|
} else {
|
|
15543
15708
|
const mergedDelta = mergeBoundElements(prevDelta, nextDelta);
|
|
15709
|
+
delete this.added[id];
|
|
15710
|
+
delete this.updated[id];
|
|
15544
15711
|
this.removed[id] = Delta.merge(prevDelta, nextDelta, mergedDelta);
|
|
15545
15712
|
}
|
|
15546
15713
|
}
|
|
15547
15714
|
for (const [id, nextDelta] of Object.entries(updated)) {
|
|
15548
|
-
const prevDelta = this.updated[id];
|
|
15715
|
+
const prevDelta = this.added[id] ?? this.removed[id] ?? this.updated[id];
|
|
15549
15716
|
if (!prevDelta) {
|
|
15550
15717
|
this.updated[id] = nextDelta;
|
|
15551
15718
|
} else {
|
|
15552
15719
|
const mergedDelta = mergeBoundElements(prevDelta, nextDelta);
|
|
15553
|
-
|
|
15720
|
+
const updatedDelta = Delta.merge(prevDelta, nextDelta, mergedDelta);
|
|
15721
|
+
if (prevDelta === this.added[id]) {
|
|
15722
|
+
this.added[id] = updatedDelta;
|
|
15723
|
+
} else if (prevDelta === this.removed[id]) {
|
|
15724
|
+
this.removed[id] = updatedDelta;
|
|
15725
|
+
} else {
|
|
15726
|
+
this.updated[id] = updatedDelta;
|
|
15727
|
+
}
|
|
15554
15728
|
}
|
|
15555
15729
|
}
|
|
15730
|
+
if (isTestEnv8() || isDevEnv7()) {
|
|
15731
|
+
_ElementsDelta.validate(this, "added", _ElementsDelta.satisfiesAddition);
|
|
15732
|
+
_ElementsDelta.validate(this, "removed", _ElementsDelta.satisfiesRemoval);
|
|
15733
|
+
_ElementsDelta.validate(this, "updated", _ElementsDelta.satisfiesUpdate);
|
|
15734
|
+
}
|
|
15556
15735
|
return this;
|
|
15557
15736
|
}
|
|
15558
15737
|
static createApplier = (prevElements, nextElements, snapshot, flags, options) => (deltas) => {
|
|
@@ -15851,10 +16030,6 @@ var ElementsDelta = class _ElementsDelta {
|
|
|
15851
16030
|
const { id, updated, ...strippedPartial } = partial;
|
|
15852
16031
|
return strippedPartial;
|
|
15853
16032
|
}
|
|
15854
|
-
static stripVersionProps(partial) {
|
|
15855
|
-
const { version, versionNonce, ...strippedPartial } = partial;
|
|
15856
|
-
return strippedPartial;
|
|
15857
|
-
}
|
|
15858
16033
|
};
|
|
15859
16034
|
|
|
15860
16035
|
// src/distribute.ts
|
|
@@ -16858,8 +17033,8 @@ var embeddableURLValidator = (url, validateEmbeddable) => {
|
|
|
16858
17033
|
|
|
16859
17034
|
// src/flowchart.ts
|
|
16860
17035
|
init_define_import_meta_env();
|
|
16861
|
-
import { KEYS as KEYS3, invariant as
|
|
16862
|
-
import { pointFrom as
|
|
17036
|
+
import { KEYS as KEYS3, invariant as invariant9, toBrandedType as toBrandedType2 } from "@excalidraw/common";
|
|
17037
|
+
import { pointFrom as pointFrom15 } from "@excalidraw/math";
|
|
16863
17038
|
var VERTICAL_OFFSET = 100;
|
|
16864
17039
|
var HORIZONTAL_OFFSET = 100;
|
|
16865
17040
|
var getLinkDirectionFromKey = (key) => {
|
|
@@ -16888,7 +17063,7 @@ var getNodeRelatives = (type, node, elementsMap, direction) => {
|
|
|
16888
17063
|
if (!relative) {
|
|
16889
17064
|
return acc;
|
|
16890
17065
|
}
|
|
16891
|
-
|
|
17066
|
+
invariant9(
|
|
16892
17067
|
isBindableElement(relative),
|
|
16893
17068
|
"not an ExcalidrawBindableElement"
|
|
16894
17069
|
);
|
|
@@ -17004,7 +17179,7 @@ var addNewNode = (element, appState, direction, scene) => {
|
|
|
17004
17179
|
fillStyle: element.fillStyle,
|
|
17005
17180
|
strokeStyle: element.strokeStyle
|
|
17006
17181
|
});
|
|
17007
|
-
|
|
17182
|
+
invariant9(
|
|
17008
17183
|
isFlowchartNodeElement(nextNode),
|
|
17009
17184
|
"not an ExcalidrawFlowchartNodeElement"
|
|
17010
17185
|
);
|
|
@@ -17062,7 +17237,7 @@ var addNewNodes = (startNode, appState, direction, scene, numberOfNodes) => {
|
|
|
17062
17237
|
fillStyle: startNode.fillStyle,
|
|
17063
17238
|
strokeStyle: startNode.strokeStyle
|
|
17064
17239
|
});
|
|
17065
|
-
|
|
17240
|
+
invariant9(
|
|
17066
17241
|
isFlowchartNodeElement(nextNode),
|
|
17067
17242
|
"not an ExcalidrawFlowchartNodeElement"
|
|
17068
17243
|
);
|
|
@@ -17139,7 +17314,7 @@ var createBindingArrow = (startBindingElement, endBindingElement, direction, app
|
|
|
17139
17314
|
strokeWidth: startBindingElement.strokeWidth,
|
|
17140
17315
|
opacity: startBindingElement.opacity,
|
|
17141
17316
|
roughness: startBindingElement.roughness,
|
|
17142
|
-
points: [
|
|
17317
|
+
points: [pointFrom15(0, 0), pointFrom15(endX, endY)],
|
|
17143
17318
|
elbowed: true
|
|
17144
17319
|
});
|
|
17145
17320
|
const elementsMap = scene.getNonDeletedElementsMap();
|
|
@@ -17288,7 +17463,7 @@ var FlowChartCreator = class {
|
|
|
17288
17463
|
}
|
|
17289
17464
|
if (startNode.frameId) {
|
|
17290
17465
|
const frame = elementsMap.get(startNode.frameId);
|
|
17291
|
-
|
|
17466
|
+
invariant9(
|
|
17292
17467
|
frame && isFrameElement(frame),
|
|
17293
17468
|
"not an ExcalidrawFrameElement"
|
|
17294
17469
|
);
|
|
@@ -17423,13 +17598,80 @@ var normalizeSVG = (SVGString) => {
|
|
|
17423
17598
|
}
|
|
17424
17599
|
};
|
|
17425
17600
|
|
|
17601
|
+
// src/positionElementsOnGrid.ts
|
|
17602
|
+
init_define_import_meta_env();
|
|
17603
|
+
var positionElementsOnGrid = (elements, centerX, centerY, padding = 50) => {
|
|
17604
|
+
if (!elements || elements.length === 0) {
|
|
17605
|
+
return [];
|
|
17606
|
+
}
|
|
17607
|
+
const res = [];
|
|
17608
|
+
const atomicUnits = Array.isArray(elements[0]) ? elements : elements.map((element) => [element]);
|
|
17609
|
+
const numUnits = atomicUnits.length;
|
|
17610
|
+
const numColumns = Math.max(1, Math.ceil(Math.sqrt(numUnits)));
|
|
17611
|
+
const rows = [];
|
|
17612
|
+
for (let i = 0; i < numUnits; i += numColumns) {
|
|
17613
|
+
rows.push(atomicUnits.slice(i, i + numColumns));
|
|
17614
|
+
}
|
|
17615
|
+
let totalGridActualHeight = 0;
|
|
17616
|
+
const rowProperties = rows.map((rowUnits) => {
|
|
17617
|
+
let rowWidth = 0;
|
|
17618
|
+
let maxUnitHeightInRow = 0;
|
|
17619
|
+
const unitBounds = rowUnits.map((unit) => {
|
|
17620
|
+
const [minX, minY, maxX, maxY] = getCommonBounds(unit);
|
|
17621
|
+
return {
|
|
17622
|
+
elements: unit,
|
|
17623
|
+
bounds: [minX, minY, maxX, maxY],
|
|
17624
|
+
width: maxX - minX,
|
|
17625
|
+
height: maxY - minY
|
|
17626
|
+
};
|
|
17627
|
+
});
|
|
17628
|
+
unitBounds.forEach((unitBound, index) => {
|
|
17629
|
+
rowWidth += unitBound.width;
|
|
17630
|
+
if (index < unitBounds.length - 1) {
|
|
17631
|
+
rowWidth += padding;
|
|
17632
|
+
}
|
|
17633
|
+
if (unitBound.height > maxUnitHeightInRow) {
|
|
17634
|
+
maxUnitHeightInRow = unitBound.height;
|
|
17635
|
+
}
|
|
17636
|
+
});
|
|
17637
|
+
totalGridActualHeight += maxUnitHeightInRow;
|
|
17638
|
+
return {
|
|
17639
|
+
unitBounds,
|
|
17640
|
+
width: rowWidth,
|
|
17641
|
+
maxHeight: maxUnitHeightInRow
|
|
17642
|
+
};
|
|
17643
|
+
});
|
|
17644
|
+
const totalGridHeightWithPadding = totalGridActualHeight + Math.max(0, rows.length - 1) * padding;
|
|
17645
|
+
let currentY = centerY - totalGridHeightWithPadding / 2;
|
|
17646
|
+
rowProperties.forEach((rowProp) => {
|
|
17647
|
+
const { unitBounds, width: rowWidth, maxHeight: rowMaxHeight } = rowProp;
|
|
17648
|
+
let currentX = centerX - rowWidth / 2;
|
|
17649
|
+
unitBounds.forEach((unitBound) => {
|
|
17650
|
+
const [originalMinX, originalMinY] = unitBound.bounds;
|
|
17651
|
+
const offsetX = currentX - originalMinX;
|
|
17652
|
+
const offsetY = currentY - originalMinY;
|
|
17653
|
+
unitBound.elements.forEach((element) => {
|
|
17654
|
+
res.push(
|
|
17655
|
+
newElementWith(element, {
|
|
17656
|
+
x: element.x + offsetX,
|
|
17657
|
+
y: element.y + offsetY
|
|
17658
|
+
})
|
|
17659
|
+
);
|
|
17660
|
+
});
|
|
17661
|
+
currentX += unitBound.width + padding;
|
|
17662
|
+
});
|
|
17663
|
+
currentY += rowMaxHeight + padding;
|
|
17664
|
+
});
|
|
17665
|
+
return res;
|
|
17666
|
+
};
|
|
17667
|
+
|
|
17426
17668
|
// src/resizeElements.ts
|
|
17427
17669
|
init_define_import_meta_env();
|
|
17428
17670
|
import {
|
|
17429
17671
|
pointCenter as pointCenter3,
|
|
17430
17672
|
normalizeRadians as normalizeRadians2,
|
|
17431
|
-
pointFrom as
|
|
17432
|
-
pointRotateRads as
|
|
17673
|
+
pointFrom as pointFrom16,
|
|
17674
|
+
pointRotateRads as pointRotateRads13
|
|
17433
17675
|
} from "@excalidraw/math";
|
|
17434
17676
|
import {
|
|
17435
17677
|
MIN_FONT_SIZE,
|
|
@@ -17557,7 +17799,16 @@ var rotateSingleElement = (element, scene, pointerX, pointerY, shouldRotateWithD
|
|
|
17557
17799
|
if (boundTextElementId) {
|
|
17558
17800
|
const textElement = scene.getElement(boundTextElementId);
|
|
17559
17801
|
if (textElement && !isArrowElement(element)) {
|
|
17560
|
-
|
|
17802
|
+
const { x, y } = computeBoundTextPosition(
|
|
17803
|
+
element,
|
|
17804
|
+
textElement,
|
|
17805
|
+
scene.getNonDeletedElementsMap()
|
|
17806
|
+
);
|
|
17807
|
+
scene.mutateElement(textElement, {
|
|
17808
|
+
angle,
|
|
17809
|
+
x,
|
|
17810
|
+
y
|
|
17811
|
+
});
|
|
17561
17812
|
}
|
|
17562
17813
|
}
|
|
17563
17814
|
};
|
|
@@ -17594,7 +17845,7 @@ var resizeSingleTextElement = (origElement, element, scene, transformHandleType,
|
|
|
17594
17845
|
return;
|
|
17595
17846
|
}
|
|
17596
17847
|
if (transformHandleType.includes("n") || transformHandleType.includes("s")) {
|
|
17597
|
-
const previousOrigin =
|
|
17848
|
+
const previousOrigin = pointFrom16(origElement.x, origElement.y);
|
|
17598
17849
|
const newOrigin = getResizedOrigin(
|
|
17599
17850
|
previousOrigin,
|
|
17600
17851
|
origElement.width,
|
|
@@ -17635,7 +17886,7 @@ var resizeSingleTextElement = (origElement, element, scene, transformHandleType,
|
|
|
17635
17886
|
element.lineHeight
|
|
17636
17887
|
);
|
|
17637
17888
|
const newHeight = metrics2.height;
|
|
17638
|
-
const previousOrigin =
|
|
17889
|
+
const previousOrigin = pointFrom16(origElement.x, origElement.y);
|
|
17639
17890
|
const newOrigin = getResizedOrigin(
|
|
17640
17891
|
previousOrigin,
|
|
17641
17892
|
origElement.width,
|
|
@@ -17671,9 +17922,9 @@ var rotateMultipleElements = (originalElements, elements, scene, pointerX, point
|
|
|
17671
17922
|
const cx = (x1 + x2) / 2;
|
|
17672
17923
|
const cy = (y1 + y2) / 2;
|
|
17673
17924
|
const origAngle = originalElements.get(element.id)?.angle ?? element.angle;
|
|
17674
|
-
const [rotatedCX, rotatedCY] =
|
|
17675
|
-
|
|
17676
|
-
|
|
17925
|
+
const [rotatedCX, rotatedCY] = pointRotateRads13(
|
|
17926
|
+
pointFrom16(cx, cy),
|
|
17927
|
+
pointFrom16(centerX, centerY),
|
|
17677
17928
|
centerAngle + origAngle - element.angle
|
|
17678
17929
|
);
|
|
17679
17930
|
const updates = isElbowArrow(element) ? {
|
|
@@ -17690,9 +17941,14 @@ var rotateMultipleElements = (originalElements, elements, scene, pointerX, point
|
|
|
17690
17941
|
});
|
|
17691
17942
|
const boundText = getBoundTextElement(element, elementsMap);
|
|
17692
17943
|
if (boundText && !isArrowElement(element)) {
|
|
17944
|
+
const { x, y } = computeBoundTextPosition(
|
|
17945
|
+
element,
|
|
17946
|
+
boundText,
|
|
17947
|
+
elementsMap
|
|
17948
|
+
);
|
|
17693
17949
|
scene.mutateElement(boundText, {
|
|
17694
|
-
x
|
|
17695
|
-
y
|
|
17950
|
+
x,
|
|
17951
|
+
y,
|
|
17696
17952
|
angle: normalizeRadians2(centerAngle + origAngle)
|
|
17697
17953
|
});
|
|
17698
17954
|
}
|
|
@@ -17705,44 +17961,44 @@ var getResizeOffsetXY = (transformHandleType, selectedElements, elementsMap, x,
|
|
|
17705
17961
|
const cx = (x1 + x2) / 2;
|
|
17706
17962
|
const cy = (y1 + y2) / 2;
|
|
17707
17963
|
const angle = selectedElements.length === 1 ? selectedElements[0].angle : 0;
|
|
17708
|
-
[x, y] =
|
|
17709
|
-
|
|
17710
|
-
|
|
17964
|
+
[x, y] = pointRotateRads13(
|
|
17965
|
+
pointFrom16(x, y),
|
|
17966
|
+
pointFrom16(cx, cy),
|
|
17711
17967
|
-angle
|
|
17712
17968
|
);
|
|
17713
17969
|
switch (transformHandleType) {
|
|
17714
17970
|
case "n":
|
|
17715
|
-
return
|
|
17716
|
-
|
|
17717
|
-
|
|
17971
|
+
return pointRotateRads13(
|
|
17972
|
+
pointFrom16(x - (x1 + x2) / 2, y - y1),
|
|
17973
|
+
pointFrom16(0, 0),
|
|
17718
17974
|
angle
|
|
17719
17975
|
);
|
|
17720
17976
|
case "s":
|
|
17721
|
-
return
|
|
17722
|
-
|
|
17723
|
-
|
|
17977
|
+
return pointRotateRads13(
|
|
17978
|
+
pointFrom16(x - (x1 + x2) / 2, y - y2),
|
|
17979
|
+
pointFrom16(0, 0),
|
|
17724
17980
|
angle
|
|
17725
17981
|
);
|
|
17726
17982
|
case "w":
|
|
17727
|
-
return
|
|
17728
|
-
|
|
17729
|
-
|
|
17983
|
+
return pointRotateRads13(
|
|
17984
|
+
pointFrom16(x - x1, y - (y1 + y2) / 2),
|
|
17985
|
+
pointFrom16(0, 0),
|
|
17730
17986
|
angle
|
|
17731
17987
|
);
|
|
17732
17988
|
case "e":
|
|
17733
|
-
return
|
|
17734
|
-
|
|
17735
|
-
|
|
17989
|
+
return pointRotateRads13(
|
|
17990
|
+
pointFrom16(x - x2, y - (y1 + y2) / 2),
|
|
17991
|
+
pointFrom16(0, 0),
|
|
17736
17992
|
angle
|
|
17737
17993
|
);
|
|
17738
17994
|
case "nw":
|
|
17739
|
-
return
|
|
17995
|
+
return pointRotateRads13(pointFrom16(x - x1, y - y1), pointFrom16(0, 0), angle);
|
|
17740
17996
|
case "ne":
|
|
17741
|
-
return
|
|
17997
|
+
return pointRotateRads13(pointFrom16(x - x2, y - y1), pointFrom16(0, 0), angle);
|
|
17742
17998
|
case "sw":
|
|
17743
|
-
return
|
|
17999
|
+
return pointRotateRads13(pointFrom16(x - x1, y - y2), pointFrom16(0, 0), angle);
|
|
17744
18000
|
case "se":
|
|
17745
|
-
return
|
|
18001
|
+
return pointRotateRads13(pointFrom16(x - x2, y - y2), pointFrom16(0, 0), angle);
|
|
17746
18002
|
default:
|
|
17747
18003
|
return [0, 0];
|
|
17748
18004
|
}
|
|
@@ -17905,10 +18161,10 @@ var resizeSingleElement = (nextWidth, nextHeight, latestElement, origElement, or
|
|
|
17905
18161
|
nextHeight,
|
|
17906
18162
|
true
|
|
17907
18163
|
);
|
|
17908
|
-
let previousOrigin =
|
|
18164
|
+
let previousOrigin = pointFrom16(origElement.x, origElement.y);
|
|
17909
18165
|
if (isLinearElement(origElement)) {
|
|
17910
18166
|
const [x1, y1] = getElementBounds(origElement, originalElementsMap);
|
|
17911
|
-
previousOrigin =
|
|
18167
|
+
previousOrigin = pointFrom16(x1, y1);
|
|
17912
18168
|
}
|
|
17913
18169
|
const newOrigin = getResizedOrigin(
|
|
17914
18170
|
previousOrigin,
|
|
@@ -17931,7 +18187,7 @@ var resizeSingleElement = (nextWidth, nextHeight, latestElement, origElement, or
|
|
|
17931
18187
|
newOrigin.x += scaledX;
|
|
17932
18188
|
newOrigin.y += scaledY;
|
|
17933
18189
|
rescaledPoints.points = rescaledPoints.points.map(
|
|
17934
|
-
(p) =>
|
|
18190
|
+
(p) => pointFrom16(p[0] - scaledX, p[1] - scaledY)
|
|
17935
18191
|
);
|
|
17936
18192
|
}
|
|
17937
18193
|
if (nextWidth < 0) {
|
|
@@ -17994,11 +18250,11 @@ var getNextSingleWidthAndHeightFromPointer = (latestElement, origElement, handle
|
|
|
17994
18250
|
origElement.height,
|
|
17995
18251
|
true
|
|
17996
18252
|
);
|
|
17997
|
-
const startTopLeft =
|
|
17998
|
-
const startBottomRight =
|
|
18253
|
+
const startTopLeft = pointFrom16(x1, y1);
|
|
18254
|
+
const startBottomRight = pointFrom16(x2, y2);
|
|
17999
18255
|
const startCenter = pointCenter3(startTopLeft, startBottomRight);
|
|
18000
|
-
const rotatedPointer =
|
|
18001
|
-
|
|
18256
|
+
const rotatedPointer = pointRotateRads13(
|
|
18257
|
+
pointFrom16(pointerX, pointerY),
|
|
18002
18258
|
startCenter,
|
|
18003
18259
|
-origElement.angle
|
|
18004
18260
|
);
|
|
@@ -18356,9 +18612,9 @@ var resizeMultipleElements = (selectedElements, elementsMap, handleDirection, sc
|
|
|
18356
18612
|
// src/resizeTest.ts
|
|
18357
18613
|
init_define_import_meta_env();
|
|
18358
18614
|
import {
|
|
18359
|
-
pointFrom as
|
|
18615
|
+
pointFrom as pointFrom18,
|
|
18360
18616
|
pointOnLineSegment,
|
|
18361
|
-
pointRotateRads as
|
|
18617
|
+
pointRotateRads as pointRotateRads15
|
|
18362
18618
|
} from "@excalidraw/math";
|
|
18363
18619
|
import { SIDE_RESIZING_THRESHOLD } from "@excalidraw/common";
|
|
18364
18620
|
|
|
@@ -18369,7 +18625,7 @@ import {
|
|
|
18369
18625
|
isAndroid,
|
|
18370
18626
|
isIOS
|
|
18371
18627
|
} from "@excalidraw/common";
|
|
18372
|
-
import { pointFrom as
|
|
18628
|
+
import { pointFrom as pointFrom17, pointRotateRads as pointRotateRads14 } from "@excalidraw/math";
|
|
18373
18629
|
var transformHandleSizes = {
|
|
18374
18630
|
mouse: 8,
|
|
18375
18631
|
pen: 16,
|
|
@@ -18410,9 +18666,9 @@ var OMIT_SIDES_FOR_LINE_BACKSLASH = {
|
|
|
18410
18666
|
w: true
|
|
18411
18667
|
};
|
|
18412
18668
|
var generateTransformHandle = (x, y, width, height, cx, cy, angle) => {
|
|
18413
|
-
const [xx, yy] =
|
|
18414
|
-
|
|
18415
|
-
|
|
18669
|
+
const [xx, yy] = pointRotateRads14(
|
|
18670
|
+
pointFrom17(x + width / 2, y + height / 2),
|
|
18671
|
+
pointFrom17(cx, cy),
|
|
18416
18672
|
angle
|
|
18417
18673
|
);
|
|
18418
18674
|
return [xx - width / 2, yy - height / 2, width, height];
|
|
@@ -18629,14 +18885,14 @@ var resizeTest = (element, elementsMap, appState, x, y, zoom, pointerType, devic
|
|
|
18629
18885
|
const SPACING = isImageElement(element) ? 0 : SIDE_RESIZING_THRESHOLD / zoom.value;
|
|
18630
18886
|
const ZOOMED_SIDE_RESIZING_THRESHOLD = SIDE_RESIZING_THRESHOLD / zoom.value;
|
|
18631
18887
|
const sides = getSelectionBorders(
|
|
18632
|
-
|
|
18633
|
-
|
|
18634
|
-
|
|
18888
|
+
pointFrom18(x1 - SPACING, y1 - SPACING),
|
|
18889
|
+
pointFrom18(x2 + SPACING, y2 + SPACING),
|
|
18890
|
+
pointFrom18(cx, cy),
|
|
18635
18891
|
element.angle
|
|
18636
18892
|
);
|
|
18637
18893
|
for (const [dir, side] of Object.entries(sides)) {
|
|
18638
18894
|
if (pointOnLineSegment(
|
|
18639
|
-
|
|
18895
|
+
pointFrom18(x, y),
|
|
18640
18896
|
side,
|
|
18641
18897
|
ZOOMED_SIDE_RESIZING_THRESHOLD
|
|
18642
18898
|
)) {
|
|
@@ -18685,14 +18941,14 @@ var getTransformHandleTypeFromCoords = ([x1, y1, x2, y2], scenePointerX, scenePo
|
|
|
18685
18941
|
const cy = (y1 + y2) / 2;
|
|
18686
18942
|
const SPACING = SIDE_RESIZING_THRESHOLD / zoom.value;
|
|
18687
18943
|
const sides = getSelectionBorders(
|
|
18688
|
-
|
|
18689
|
-
|
|
18690
|
-
|
|
18944
|
+
pointFrom18(x1 - SPACING, y1 - SPACING),
|
|
18945
|
+
pointFrom18(x2 + SPACING, y2 + SPACING),
|
|
18946
|
+
pointFrom18(cx, cy),
|
|
18691
18947
|
0
|
|
18692
18948
|
);
|
|
18693
18949
|
for (const [dir, side] of Object.entries(sides)) {
|
|
18694
18950
|
if (pointOnLineSegment(
|
|
18695
|
-
|
|
18951
|
+
pointFrom18(scenePointerX, scenePointerY),
|
|
18696
18952
|
side,
|
|
18697
18953
|
SPACING
|
|
18698
18954
|
)) {
|
|
@@ -18749,10 +19005,10 @@ var getCursorForResizingElement = (resizingElement) => {
|
|
|
18749
19005
|
return cursor ? `${cursor}-resize` : "";
|
|
18750
19006
|
};
|
|
18751
19007
|
var getSelectionBorders = ([x1, y1], [x2, y2], center, angle) => {
|
|
18752
|
-
const topLeft =
|
|
18753
|
-
const topRight =
|
|
18754
|
-
const bottomLeft =
|
|
18755
|
-
const bottomRight =
|
|
19008
|
+
const topLeft = pointRotateRads15(pointFrom18(x1, y1), center, angle);
|
|
19009
|
+
const topRight = pointRotateRads15(pointFrom18(x2, y1), center, angle);
|
|
19010
|
+
const bottomLeft = pointRotateRads15(pointFrom18(x1, y2), center, angle);
|
|
19011
|
+
const bottomRight = pointRotateRads15(pointFrom18(x2, y2), center, angle);
|
|
18756
19012
|
return {
|
|
18757
19013
|
n: [topLeft, topRight],
|
|
18758
19014
|
e: [topRight, bottomRight],
|
|
@@ -19293,6 +19549,8 @@ export {
|
|
|
19293
19549
|
getFrameLikeTitle,
|
|
19294
19550
|
getFreeDrawPath2D,
|
|
19295
19551
|
getFreeDrawSvgPath,
|
|
19552
|
+
getFreedrawOutlineAsSegments,
|
|
19553
|
+
getFreedrawOutlinePoints,
|
|
19296
19554
|
getGlobalFixedPointForBindableElement,
|
|
19297
19555
|
getGlobalFixedPoints,
|
|
19298
19556
|
getHeadingForElbowArrowSnap,
|
|
@@ -19458,6 +19716,7 @@ export {
|
|
|
19458
19716
|
parseTokens,
|
|
19459
19717
|
pathsCache,
|
|
19460
19718
|
pointInsideBounds,
|
|
19719
|
+
positionElementsOnGrid,
|
|
19461
19720
|
redrawTextBoundingBox,
|
|
19462
19721
|
refreshTextDimensions,
|
|
19463
19722
|
removeAllElementsFromFrame,
|