@myoc/element 0.19.517 → 0.19.519
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 +540 -542
- package/dist/dev/index.js.map +4 -4
- package/dist/prod/index.js +14 -14
- package/dist/types/common/src/colors.d.ts +1 -1
- package/dist/types/element/src/bounds.d.ts +18 -1
- package/dist/types/element/src/visualdebug.d.ts +1 -2
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +2 -0
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +11 -0
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +2 -0
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +2 -0
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionExport.d.ts +2 -0
- package/dist/types/excalidraw/actions/actionFrame.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionGroup.d.ts +2 -0
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionLink.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionMenu.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionProperties.d.ts +2 -0
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionStyles.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +3 -2
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +1 -0
- package/dist/types/excalidraw/components/App.d.ts +1 -0
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +7 -4
- package/dist/types/excalidraw/data/blob.d.ts +1 -0
- package/dist/types/excalidraw/data/json.d.ts +1 -0
- package/dist/types/excalidraw/types.d.ts +8 -0
- package/dist/types/utils/src/index.d.ts +1 -2
- package/package.json +4 -4
- package/dist/types/utils/src/bbox.d.ts +0 -9
- package/dist/types/utils/src/withinBounds.d.ts +0 -19
package/dist/dev/index.js
CHANGED
|
@@ -3869,11 +3869,11 @@ import {
|
|
|
3869
3869
|
} from "@excalidraw/common";
|
|
3870
3870
|
import {
|
|
3871
3871
|
degreesToRadians,
|
|
3872
|
-
lineSegment as
|
|
3872
|
+
lineSegment as lineSegment6,
|
|
3873
3873
|
pointDistance as pointDistance7,
|
|
3874
|
-
pointFrom as
|
|
3874
|
+
pointFrom as pointFrom13,
|
|
3875
3875
|
pointFromArray as pointFromArray3,
|
|
3876
|
-
pointRotateRads as
|
|
3876
|
+
pointRotateRads as pointRotateRads12
|
|
3877
3877
|
} from "@excalidraw/math";
|
|
3878
3878
|
|
|
3879
3879
|
// ../utils/src/shape.ts
|
|
@@ -4215,9 +4215,9 @@ function ae(e, t = {}) {
|
|
|
4215
4215
|
|
|
4216
4216
|
// src/shape.ts
|
|
4217
4217
|
import {
|
|
4218
|
-
pointFrom as
|
|
4218
|
+
pointFrom as pointFrom12,
|
|
4219
4219
|
pointDistance as pointDistance6,
|
|
4220
|
-
pointRotateRads as
|
|
4220
|
+
pointRotateRads as pointRotateRads11
|
|
4221
4221
|
} from "@excalidraw/math";
|
|
4222
4222
|
import {
|
|
4223
4223
|
ROUGHNESS,
|
|
@@ -4233,9 +4233,9 @@ import {
|
|
|
4233
4233
|
init_define_import_meta_env();
|
|
4234
4234
|
import {
|
|
4235
4235
|
isRightAngleRads,
|
|
4236
|
-
lineSegment as
|
|
4237
|
-
pointFrom as
|
|
4238
|
-
pointRotateRads as
|
|
4236
|
+
lineSegment as lineSegment5,
|
|
4237
|
+
pointFrom as pointFrom11,
|
|
4238
|
+
pointRotateRads as pointRotateRads10
|
|
4239
4239
|
} from "@excalidraw/math";
|
|
4240
4240
|
import {
|
|
4241
4241
|
BOUND_TEXT_PADDING as BOUND_TEXT_PADDING3,
|
|
@@ -4716,11 +4716,11 @@ var getFlipAdjustedCropPosition = (element, natural = false) => {
|
|
|
4716
4716
|
init_define_import_meta_env();
|
|
4717
4717
|
import {
|
|
4718
4718
|
pointCenter as pointCenter2,
|
|
4719
|
-
pointFrom as
|
|
4720
|
-
pointRotateRads as
|
|
4719
|
+
pointFrom as pointFrom10,
|
|
4720
|
+
pointRotateRads as pointRotateRads9,
|
|
4721
4721
|
pointsEqual as pointsEqual6,
|
|
4722
4722
|
pointDistance as pointDistance5,
|
|
4723
|
-
vectorFromPoint as
|
|
4723
|
+
vectorFromPoint as vectorFromPoint8,
|
|
4724
4724
|
curveLength,
|
|
4725
4725
|
curvePointAtLength
|
|
4726
4726
|
} from "@excalidraw/math";
|
|
@@ -10338,10 +10338,10 @@ var normalizeFixedPoint = (fixedPoint) => {
|
|
|
10338
10338
|
if (!isFixedPoint(fixedPoint)) {
|
|
10339
10339
|
return [0.5001, 0.5001];
|
|
10340
10340
|
}
|
|
10341
|
-
const
|
|
10342
|
-
if (Math.abs(fixedPoint[0] - 0.5) <
|
|
10341
|
+
const EPSILON = 1e-4;
|
|
10342
|
+
if (Math.abs(fixedPoint[0] - 0.5) < EPSILON || Math.abs(fixedPoint[1] - 0.5) < EPSILON) {
|
|
10343
10343
|
return fixedPoint.map(
|
|
10344
|
-
(ratio) => Math.abs(ratio - 0.5) <
|
|
10344
|
+
(ratio) => Math.abs(ratio - 0.5) < EPSILON ? 0.5001 : ratio
|
|
10345
10345
|
);
|
|
10346
10346
|
}
|
|
10347
10347
|
return fixedPoint;
|
|
@@ -10707,52 +10707,15 @@ init_define_import_meta_env();
|
|
|
10707
10707
|
// src/selection.ts
|
|
10708
10708
|
init_define_import_meta_env();
|
|
10709
10709
|
import { arrayToMap as arrayToMap5, isShallowEqual } from "@excalidraw/common";
|
|
10710
|
-
import {
|
|
10711
|
-
lineSegment as lineSegment5,
|
|
10712
|
-
pointFrom as pointFrom10,
|
|
10713
|
-
pointRotateRads as pointRotateRads9
|
|
10714
|
-
} from "@excalidraw/math";
|
|
10715
10710
|
|
|
10716
10711
|
// src/frame.ts
|
|
10717
10712
|
init_define_import_meta_env();
|
|
10718
10713
|
import { arrayToMap as arrayToMap4 } from "@excalidraw/common";
|
|
10719
|
-
import { isPointWithinBounds as isPointWithinBounds2, pointFrom as pointFrom9 } from "@excalidraw/math";
|
|
10720
|
-
|
|
10721
|
-
// ../utils/src/bbox.ts
|
|
10722
|
-
init_define_import_meta_env();
|
|
10723
10714
|
import {
|
|
10724
|
-
|
|
10725
|
-
|
|
10715
|
+
isPointWithinBounds as isPointWithinBounds2,
|
|
10716
|
+
pointFrom as pointFrom9,
|
|
10717
|
+
segmentsIntersectAt as segmentsIntersectAt2
|
|
10726
10718
|
} from "@excalidraw/math";
|
|
10727
|
-
function getBBox(line2) {
|
|
10728
|
-
return [
|
|
10729
|
-
Math.min(line2[0][0], line2[1][0]),
|
|
10730
|
-
Math.min(line2[0][1], line2[1][1]),
|
|
10731
|
-
Math.max(line2[0][0], line2[1][0]),
|
|
10732
|
-
Math.max(line2[0][1], line2[1][1])
|
|
10733
|
-
];
|
|
10734
|
-
}
|
|
10735
|
-
function doBBoxesIntersect(a2, b2) {
|
|
10736
|
-
return a2[0] <= b2[2] && a2[2] >= b2[0] && a2[1] <= b2[3] && a2[3] >= b2[1];
|
|
10737
|
-
}
|
|
10738
|
-
var EPSILON = 1e-6;
|
|
10739
|
-
function isPointOnLine(l2, p) {
|
|
10740
|
-
const p1 = vectorFromPoint8(l2[1], l2[0]);
|
|
10741
|
-
const p2 = vectorFromPoint8(p, l2[0]);
|
|
10742
|
-
const r = vectorCross3(p1, p2);
|
|
10743
|
-
return Math.abs(r) < EPSILON;
|
|
10744
|
-
}
|
|
10745
|
-
function isPointRightOfLine(l2, p) {
|
|
10746
|
-
const p1 = vectorFromPoint8(l2[1], l2[0]);
|
|
10747
|
-
const p2 = vectorFromPoint8(p, l2[0]);
|
|
10748
|
-
return vectorCross3(p1, p2) < 0;
|
|
10749
|
-
}
|
|
10750
|
-
function isLineSegmentTouchingOrCrossingLine(a2, b2) {
|
|
10751
|
-
return isPointOnLine(a2, b2[0]) || isPointOnLine(a2, b2[1]) || (isPointRightOfLine(a2, b2[0]) ? !isPointRightOfLine(a2, b2[1]) : isPointRightOfLine(a2, b2[1]));
|
|
10752
|
-
}
|
|
10753
|
-
function doLineSegmentsIntersect(a2, b2) {
|
|
10754
|
-
return doBBoxesIntersect(getBBox(a2), getBBox(b2)) && isLineSegmentTouchingOrCrossingLine(a2, b2) && isLineSegmentTouchingOrCrossingLine(b2, a2);
|
|
10755
|
-
}
|
|
10756
10719
|
|
|
10757
10720
|
// src/fractionalIndex.ts
|
|
10758
10721
|
init_define_import_meta_env();
|
|
@@ -11025,7 +10988,7 @@ function isElementIntersectingFrame(element, frame, elementsMap) {
|
|
|
11025
10988
|
const elementLineSegments = getElementLineSegments(element, elementsMap);
|
|
11026
10989
|
const intersecting = frameLineSegments.some(
|
|
11027
10990
|
(frameLineSegment) => elementLineSegments.some(
|
|
11028
|
-
(elementLineSegment) =>
|
|
10991
|
+
(elementLineSegment) => segmentsIntersectAt2(frameLineSegment, elementLineSegment)
|
|
11029
10992
|
)
|
|
11030
10993
|
);
|
|
11031
10994
|
return intersecting;
|
|
@@ -11598,197 +11561,14 @@ var getElementsWithinSelection = (elements, selection, elementsMap, excludeEleme
|
|
|
11598
11561
|
selectionX2,
|
|
11599
11562
|
selectionY2
|
|
11600
11563
|
];
|
|
11601
|
-
|
|
11602
|
-
|
|
11603
|
-
|
|
11604
|
-
|
|
11605
|
-
|
|
11606
|
-
|
|
11607
|
-
|
|
11608
|
-
|
|
11609
|
-
),
|
|
11610
|
-
lineSegment5(
|
|
11611
|
-
pointFrom10(selectionX2, selectionY2),
|
|
11612
|
-
pointFrom10(selectionX1, selectionY2)
|
|
11613
|
-
),
|
|
11614
|
-
lineSegment5(
|
|
11615
|
-
pointFrom10(selectionX1, selectionY2),
|
|
11616
|
-
pointFrom10(selectionX1, selectionY1)
|
|
11617
|
-
)
|
|
11618
|
-
];
|
|
11619
|
-
const framesInSelection = excludeElementsInFrames ? /* @__PURE__ */ new Set() : null;
|
|
11620
|
-
const groups = {};
|
|
11621
|
-
const elementsInSelection = /* @__PURE__ */ new Set();
|
|
11622
|
-
for (const element of elements) {
|
|
11623
|
-
if (shouldIgnoreElementFromSelection(element)) {
|
|
11624
|
-
continue;
|
|
11625
|
-
}
|
|
11626
|
-
const groupId = element.groupIds.at(-1);
|
|
11627
|
-
if (groupId) {
|
|
11628
|
-
if (!groups[groupId]) {
|
|
11629
|
-
groups[groupId] = [];
|
|
11630
|
-
}
|
|
11631
|
-
groups[groupId].push(element);
|
|
11632
|
-
}
|
|
11633
|
-
const strokeWidth = element.strokeWidth;
|
|
11634
|
-
let labelAABB = null;
|
|
11635
|
-
let elementAABB = getElementBounds(element, elementsMap);
|
|
11636
|
-
elementAABB = [
|
|
11637
|
-
elementAABB[0] - strokeWidth / 2,
|
|
11638
|
-
elementAABB[1] - strokeWidth / 2,
|
|
11639
|
-
elementAABB[2] + strokeWidth / 2,
|
|
11640
|
-
elementAABB[3] + strokeWidth / 2
|
|
11641
|
-
];
|
|
11642
|
-
const boundTextElement = isArrowElement(element) && getBoundTextElement(element, elementsMap);
|
|
11643
|
-
if (boundTextElement) {
|
|
11644
|
-
const { x, y } = LinearElementEditor.getBoundTextElementPosition(
|
|
11645
|
-
element,
|
|
11646
|
-
boundTextElement,
|
|
11647
|
-
elementsMap
|
|
11648
|
-
);
|
|
11649
|
-
labelAABB = [
|
|
11650
|
-
x,
|
|
11651
|
-
y,
|
|
11652
|
-
x + boundTextElement.width,
|
|
11653
|
-
y + boundTextElement.height
|
|
11654
|
-
];
|
|
11655
|
-
}
|
|
11656
|
-
const associatedFrame = getContainingFrame(element, elementsMap);
|
|
11657
|
-
if (associatedFrame && elementOverlapsWithFrame(element, associatedFrame, elementsMap)) {
|
|
11658
|
-
const frameAABB = getElementBounds(associatedFrame, elementsMap);
|
|
11659
|
-
elementAABB = [
|
|
11660
|
-
Math.max(elementAABB[0], frameAABB[0]),
|
|
11661
|
-
Math.max(elementAABB[1], frameAABB[1]),
|
|
11662
|
-
Math.min(elementAABB[2], frameAABB[2]),
|
|
11663
|
-
Math.min(elementAABB[3], frameAABB[3])
|
|
11664
|
-
];
|
|
11665
|
-
labelAABB = labelAABB ? [
|
|
11666
|
-
Math.max(labelAABB[0], frameAABB[0]),
|
|
11667
|
-
Math.max(labelAABB[1], frameAABB[1]),
|
|
11668
|
-
Math.min(labelAABB[2], frameAABB[2]),
|
|
11669
|
-
Math.min(labelAABB[3], frameAABB[3])
|
|
11670
|
-
] : null;
|
|
11671
|
-
}
|
|
11672
|
-
const commonAABB2 = labelAABB ? [
|
|
11673
|
-
Math.min(labelAABB[0], elementAABB[0]),
|
|
11674
|
-
Math.min(labelAABB[1], elementAABB[1]),
|
|
11675
|
-
Math.max(labelAABB[2], elementAABB[2]),
|
|
11676
|
-
Math.max(labelAABB[3], elementAABB[3])
|
|
11677
|
-
] : elementAABB;
|
|
11678
|
-
if (boundsContainBounds(selectionBounds, commonAABB2)) {
|
|
11679
|
-
if (framesInSelection && isFrameLikeElement(element)) {
|
|
11680
|
-
framesInSelection.add(element.id);
|
|
11681
|
-
}
|
|
11682
|
-
elementsInSelection.add(element);
|
|
11683
|
-
continue;
|
|
11684
|
-
}
|
|
11685
|
-
if (boxSelectionMode === "overlap" && labelAABB && doBoundsIntersect(selectionBounds, labelAABB)) {
|
|
11686
|
-
elementsInSelection.add(element);
|
|
11687
|
-
continue;
|
|
11688
|
-
}
|
|
11689
|
-
if (boxSelectionMode === "overlap" && doBoundsIntersect(selectionBounds, elementAABB)) {
|
|
11690
|
-
let hasIntersection = false;
|
|
11691
|
-
if (isLinearElement(element) || isFreeDrawElement(element)) {
|
|
11692
|
-
const center = elementCenterPoint(element, elementsMap);
|
|
11693
|
-
hasIntersection = element.points.some((point) => {
|
|
11694
|
-
const rotatedPoint = pointRotateRads9(
|
|
11695
|
-
pointFrom10(element.x + point[0], element.y + point[1]),
|
|
11696
|
-
center,
|
|
11697
|
-
element.angle
|
|
11698
|
-
);
|
|
11699
|
-
return pointInsideBounds(rotatedPoint, selectionBounds);
|
|
11700
|
-
});
|
|
11701
|
-
} else {
|
|
11702
|
-
const nonRotatedElementBounds = getElementBounds(
|
|
11703
|
-
element,
|
|
11704
|
-
elementsMap,
|
|
11705
|
-
true
|
|
11706
|
-
);
|
|
11707
|
-
const center = elementCenterPoint(element, elementsMap);
|
|
11708
|
-
hasIntersection = [
|
|
11709
|
-
pointRotateRads9(
|
|
11710
|
-
pointFrom10(
|
|
11711
|
-
(nonRotatedElementBounds[0] + nonRotatedElementBounds[2]) / 2,
|
|
11712
|
-
nonRotatedElementBounds[1]
|
|
11713
|
-
),
|
|
11714
|
-
center,
|
|
11715
|
-
element.angle
|
|
11716
|
-
),
|
|
11717
|
-
pointRotateRads9(
|
|
11718
|
-
pointFrom10(
|
|
11719
|
-
nonRotatedElementBounds[2],
|
|
11720
|
-
(nonRotatedElementBounds[1] + nonRotatedElementBounds[3]) / 2
|
|
11721
|
-
),
|
|
11722
|
-
center,
|
|
11723
|
-
element.angle
|
|
11724
|
-
),
|
|
11725
|
-
pointRotateRads9(
|
|
11726
|
-
pointFrom10(
|
|
11727
|
-
(nonRotatedElementBounds[0] + nonRotatedElementBounds[2]) / 2,
|
|
11728
|
-
nonRotatedElementBounds[3]
|
|
11729
|
-
),
|
|
11730
|
-
center,
|
|
11731
|
-
element.angle
|
|
11732
|
-
),
|
|
11733
|
-
pointRotateRads9(
|
|
11734
|
-
pointFrom10(
|
|
11735
|
-
nonRotatedElementBounds[0],
|
|
11736
|
-
(nonRotatedElementBounds[1] + nonRotatedElementBounds[3]) / 2
|
|
11737
|
-
),
|
|
11738
|
-
center,
|
|
11739
|
-
element.angle
|
|
11740
|
-
)
|
|
11741
|
-
].some((point) => {
|
|
11742
|
-
return pointInsideBounds(
|
|
11743
|
-
pointRotateRads9(point, center, element.angle),
|
|
11744
|
-
selectionBounds
|
|
11745
|
-
);
|
|
11746
|
-
});
|
|
11747
|
-
}
|
|
11748
|
-
if (!hasIntersection) {
|
|
11749
|
-
hasIntersection = selectionEdges.some(
|
|
11750
|
-
(selectionEdge) => intersectElementWithLineSegment(
|
|
11751
|
-
element,
|
|
11752
|
-
elementsMap,
|
|
11753
|
-
selectionEdge,
|
|
11754
|
-
strokeWidth / 2,
|
|
11755
|
-
true
|
|
11756
|
-
// Stop at first hit for better performance
|
|
11757
|
-
).length > 0
|
|
11758
|
-
);
|
|
11759
|
-
}
|
|
11760
|
-
if (hasIntersection) {
|
|
11761
|
-
if (framesInSelection && isFrameLikeElement(element)) {
|
|
11762
|
-
framesInSelection.add(element.id);
|
|
11763
|
-
}
|
|
11764
|
-
elementsInSelection.add(element);
|
|
11765
|
-
continue;
|
|
11766
|
-
}
|
|
11767
|
-
}
|
|
11768
|
-
}
|
|
11769
|
-
if (framesInSelection) {
|
|
11770
|
-
elementsInSelection.forEach((element) => {
|
|
11771
|
-
if (element.frameId && framesInSelection.has(element.frameId)) {
|
|
11772
|
-
elementsInSelection.delete(element);
|
|
11773
|
-
}
|
|
11774
|
-
});
|
|
11775
|
-
}
|
|
11776
|
-
if (boxSelectionMode === "overlap") {
|
|
11777
|
-
Array.from(elementsInSelection).forEach((element) => {
|
|
11778
|
-
const groupId = element.groupIds.at(-1);
|
|
11779
|
-
const group = groupId ? groups[groupId] : null;
|
|
11780
|
-
group?.forEach((groupElement) => elementsInSelection.add(groupElement));
|
|
11781
|
-
});
|
|
11782
|
-
} else if (boxSelectionMode === "contain") {
|
|
11783
|
-
elementsInSelection.forEach((element) => {
|
|
11784
|
-
const groupId = element.groupIds.at(-1);
|
|
11785
|
-
const group = groupId ? groups[groupId] : null;
|
|
11786
|
-
if (group && !group.every((groupElement) => elementsInSelection.has(groupElement))) {
|
|
11787
|
-
elementsInSelection.delete(element);
|
|
11788
|
-
}
|
|
11789
|
-
});
|
|
11790
|
-
}
|
|
11791
|
-
return elements.filter((element) => elementsInSelection.has(element));
|
|
11564
|
+
return elementsOverlappingBBox({
|
|
11565
|
+
elements,
|
|
11566
|
+
bounds: selectionBounds,
|
|
11567
|
+
elementsMap,
|
|
11568
|
+
type: boxSelectionMode,
|
|
11569
|
+
shouldIgnoreElementFromSelection,
|
|
11570
|
+
excludeElementsInFrames
|
|
11571
|
+
});
|
|
11792
11572
|
};
|
|
11793
11573
|
var getVisibleAndNonSelectedElements = (elements, selectedElements, appState, elementsMap) => {
|
|
11794
11574
|
const selectedElementsSet = new Set(
|
|
@@ -12559,7 +12339,7 @@ var getNormalizedPoints = ({
|
|
|
12559
12339
|
const offsetY = points[0][1];
|
|
12560
12340
|
return {
|
|
12561
12341
|
points: points.map((p) => {
|
|
12562
|
-
return
|
|
12342
|
+
return pointFrom10(p[0] - offsetX, p[1] - offsetY);
|
|
12563
12343
|
}),
|
|
12564
12344
|
offsetX,
|
|
12565
12345
|
offsetY
|
|
@@ -12588,7 +12368,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
12588
12368
|
pointerDownState;
|
|
12589
12369
|
constructor(element, elementsMap, isEditing = false) {
|
|
12590
12370
|
this.elementId = element.id;
|
|
12591
|
-
if (!pointsEqual6(element.points[0],
|
|
12371
|
+
if (!pointsEqual6(element.points[0], pointFrom10(0, 0))) {
|
|
12592
12372
|
console.error("Linear element is not normalized", Error().stack);
|
|
12593
12373
|
mutateElement(
|
|
12594
12374
|
element,
|
|
@@ -12687,11 +12467,11 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
12687
12467
|
element,
|
|
12688
12468
|
elementsMap,
|
|
12689
12469
|
pivotPoint,
|
|
12690
|
-
|
|
12470
|
+
pointFrom10(scenePointerX, scenePointerY),
|
|
12691
12471
|
event[KEYS.CTRL_OR_CMD] ? null : app.getEffectiveGridSize(),
|
|
12692
12472
|
customLineAngle
|
|
12693
12473
|
);
|
|
12694
|
-
const target =
|
|
12474
|
+
const target = pointFrom10(
|
|
12695
12475
|
width + pivotPoint[0],
|
|
12696
12476
|
height + pivotPoint[1]
|
|
12697
12477
|
);
|
|
@@ -12768,7 +12548,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
12768
12548
|
...linearElementEditor.initialState,
|
|
12769
12549
|
altFocusPoint: !linearElementEditor.initialState.altFocusPoint && startBindingElement && updates?.suggestedBinding?.element.id !== startBindingElement.id ? projectFixedPointOntoDiagonal(
|
|
12770
12550
|
element,
|
|
12771
|
-
|
|
12551
|
+
pointFrom10(element.x, element.y),
|
|
12772
12552
|
startBindingElement,
|
|
12773
12553
|
"start",
|
|
12774
12554
|
elementsMap,
|
|
@@ -12830,11 +12610,11 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
12830
12610
|
element,
|
|
12831
12611
|
elementsMap,
|
|
12832
12612
|
pivotPoint,
|
|
12833
|
-
|
|
12613
|
+
pointFrom10(scenePointerX, scenePointerY),
|
|
12834
12614
|
event[KEYS.CTRL_OR_CMD] ? null : app.getEffectiveGridSize(),
|
|
12835
12615
|
customLineAngle
|
|
12836
12616
|
);
|
|
12837
|
-
const target =
|
|
12617
|
+
const target = pointFrom10(
|
|
12838
12618
|
width + pivotPoint[0],
|
|
12839
12619
|
height + pivotPoint[1]
|
|
12840
12620
|
);
|
|
@@ -12928,7 +12708,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
12928
12708
|
altFocusPoint: !linearElementEditor.initialState.altFocusPoint && // We only set it once per arrow drag
|
|
12929
12709
|
isBindingElement(element) && altFocusPointBindableElement ? projectFixedPointOntoDiagonal(
|
|
12930
12710
|
element,
|
|
12931
|
-
|
|
12711
|
+
pointFrom10(element.x, element.y),
|
|
12932
12712
|
altFocusPointBindableElement,
|
|
12933
12713
|
"start",
|
|
12934
12714
|
elementsMap,
|
|
@@ -13072,11 +12852,11 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13072
12852
|
const existingSegmentMidpointHitCoords = linearElementEditor.segmentMidPointHoveredCoords;
|
|
13073
12853
|
if (existingSegmentMidpointHitCoords) {
|
|
13074
12854
|
const distance3 = pointDistance5(
|
|
13075
|
-
|
|
12855
|
+
pointFrom10(
|
|
13076
12856
|
existingSegmentMidpointHitCoords[0],
|
|
13077
12857
|
existingSegmentMidpointHitCoords[1]
|
|
13078
12858
|
),
|
|
13079
|
-
|
|
12859
|
+
pointFrom10(scenePointer.x, scenePointer.y)
|
|
13080
12860
|
);
|
|
13081
12861
|
if (distance3 <= threshold) {
|
|
13082
12862
|
return existingSegmentMidpointHitCoords;
|
|
@@ -13092,7 +12872,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13092
12872
|
if (midPoints[index] !== null) {
|
|
13093
12873
|
const distance3 = pointDistance5(
|
|
13094
12874
|
midPoints[index],
|
|
13095
|
-
|
|
12875
|
+
pointFrom10(scenePointer.x, scenePointer.y)
|
|
13096
12876
|
);
|
|
13097
12877
|
if (distance3 <= threshold) {
|
|
13098
12878
|
return midPoints[index];
|
|
@@ -13134,7 +12914,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13134
12914
|
"Invalid segment index while calculating elbow arrow mid point"
|
|
13135
12915
|
);
|
|
13136
12916
|
const p = pointCenter2(element.points[index - 1], element.points[index]);
|
|
13137
|
-
return
|
|
12917
|
+
return pointFrom10(element.x + p[0], element.y + p[1]);
|
|
13138
12918
|
}
|
|
13139
12919
|
const [lines, curves] = deconstructLinearOrFreeDrawElement(
|
|
13140
12920
|
element,
|
|
@@ -13202,7 +12982,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13202
12982
|
appState,
|
|
13203
12983
|
elementsMap
|
|
13204
12984
|
);
|
|
13205
|
-
const point =
|
|
12985
|
+
const point = pointFrom10(scenePointer.x, scenePointer.y);
|
|
13206
12986
|
let segmentMidpointIndex = null;
|
|
13207
12987
|
if (segmentMidpoint) {
|
|
13208
12988
|
segmentMidpointIndex = _LinearElementEditor.getSegmentMidPointIndex(
|
|
@@ -13261,12 +13041,12 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13261
13041
|
const [x1, y1, x2, y2] = getElementAbsoluteCoords2(element, elementsMap);
|
|
13262
13042
|
const cx = (x1 + x2) / 2;
|
|
13263
13043
|
const cy = (y1 + y2) / 2;
|
|
13264
|
-
const targetPoint = clickedPointIndex > -1 &&
|
|
13265
|
-
|
|
13044
|
+
const targetPoint = clickedPointIndex > -1 && pointRotateRads9(
|
|
13045
|
+
pointFrom10(
|
|
13266
13046
|
element.x + element.points[clickedPointIndex][0],
|
|
13267
13047
|
element.y + element.points[clickedPointIndex][1]
|
|
13268
13048
|
),
|
|
13269
|
-
|
|
13049
|
+
pointFrom10(cx, cy),
|
|
13270
13050
|
element.angle
|
|
13271
13051
|
);
|
|
13272
13052
|
const nextSelectedPointsIndices = clickedPointIndex > -1 || event.shiftKey ? event.shiftKey || linearElementEditor.selectedPointsIndices?.includes(clickedPointIndex) ? normalizeSelectedPoints([
|
|
@@ -13333,10 +13113,10 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13333
13113
|
element,
|
|
13334
13114
|
elementsMap,
|
|
13335
13115
|
anchor,
|
|
13336
|
-
|
|
13116
|
+
pointFrom10(scenePointerX, scenePointerY),
|
|
13337
13117
|
event[KEYS.CTRL_OR_CMD] ? null : app.getEffectiveGridSize()
|
|
13338
13118
|
);
|
|
13339
|
-
newPoint =
|
|
13119
|
+
newPoint = pointFrom10(width + anchor[0], height + anchor[1]);
|
|
13340
13120
|
} else {
|
|
13341
13121
|
newPoint = _LinearElementEditor.createPointAt(
|
|
13342
13122
|
element,
|
|
@@ -13373,9 +13153,9 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13373
13153
|
const cx = (x1 + x2) / 2;
|
|
13374
13154
|
const cy = (y1 + y2) / 2;
|
|
13375
13155
|
const { x, y } = element;
|
|
13376
|
-
return
|
|
13377
|
-
|
|
13378
|
-
|
|
13156
|
+
return pointRotateRads9(
|
|
13157
|
+
pointFrom10(x + p[0], y + p[1]),
|
|
13158
|
+
pointFrom10(cx, cy),
|
|
13379
13159
|
element.angle
|
|
13380
13160
|
);
|
|
13381
13161
|
}
|
|
@@ -13386,9 +13166,9 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13386
13166
|
const cy = (y1 + y2) / 2;
|
|
13387
13167
|
return element.points.map((p) => {
|
|
13388
13168
|
const { x, y } = element;
|
|
13389
|
-
return
|
|
13390
|
-
|
|
13391
|
-
|
|
13169
|
+
return pointRotateRads9(
|
|
13170
|
+
pointFrom10(x + p[0], y + p[1]),
|
|
13171
|
+
pointFrom10(cx, cy),
|
|
13392
13172
|
element.angle
|
|
13393
13173
|
);
|
|
13394
13174
|
});
|
|
@@ -13396,18 +13176,18 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13396
13176
|
static getPointAtIndexGlobalCoordinates(element, indexMaybeFromEnd, elementsMap) {
|
|
13397
13177
|
const index = indexMaybeFromEnd < 0 ? element.points.length + indexMaybeFromEnd : indexMaybeFromEnd;
|
|
13398
13178
|
const [, , , , cx, cy] = getElementAbsoluteCoords2(element, elementsMap);
|
|
13399
|
-
const center =
|
|
13179
|
+
const center = pointFrom10(cx, cy);
|
|
13400
13180
|
const p = element.points[index];
|
|
13401
13181
|
const { x, y } = element;
|
|
13402
|
-
return p ?
|
|
13403
|
-
|
|
13182
|
+
return p ? pointRotateRads9(
|
|
13183
|
+
pointFrom10(x + p[0], y + p[1]),
|
|
13404
13184
|
center,
|
|
13405
13185
|
element.angle
|
|
13406
|
-
) :
|
|
13186
|
+
) : pointRotateRads9(pointFrom10(x, y), center, element.angle);
|
|
13407
13187
|
}
|
|
13408
13188
|
static pointFromAbsoluteCoords(element, absoluteCoords, elementsMap) {
|
|
13409
13189
|
if (isElbowArrow(element)) {
|
|
13410
|
-
return
|
|
13190
|
+
return pointFrom10(
|
|
13411
13191
|
absoluteCoords[0] - element.x,
|
|
13412
13192
|
absoluteCoords[1] - element.y
|
|
13413
13193
|
);
|
|
@@ -13415,12 +13195,12 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13415
13195
|
const [x1, y1, x2, y2] = getElementAbsoluteCoords2(element, elementsMap);
|
|
13416
13196
|
const cx = (x1 + x2) / 2;
|
|
13417
13197
|
const cy = (y1 + y2) / 2;
|
|
13418
|
-
const [x, y] =
|
|
13419
|
-
|
|
13420
|
-
|
|
13198
|
+
const [x, y] = pointRotateRads9(
|
|
13199
|
+
pointFrom10(absoluteCoords[0], absoluteCoords[1]),
|
|
13200
|
+
pointFrom10(cx, cy),
|
|
13421
13201
|
-element.angle
|
|
13422
13202
|
);
|
|
13423
|
-
return
|
|
13203
|
+
return pointFrom10(x - element.x, y - element.y);
|
|
13424
13204
|
}
|
|
13425
13205
|
static getPointIndexUnderCursor(element, elementsMap, zoom, x, y) {
|
|
13426
13206
|
const pointHandles = _LinearElementEditor.getPointsGlobalCoordinates(
|
|
@@ -13430,7 +13210,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13430
13210
|
let idx = pointHandles.length;
|
|
13431
13211
|
while (--idx > -1) {
|
|
13432
13212
|
const p = pointHandles[idx];
|
|
13433
|
-
if (pointDistance5(
|
|
13213
|
+
if (pointDistance5(pointFrom10(x, y), pointFrom10(p[0], p[1])) * zoom.value < // +1px to account for outline stroke
|
|
13434
13214
|
_LinearElementEditor.POINT_HANDLE_SIZE + 1) {
|
|
13435
13215
|
return idx;
|
|
13436
13216
|
}
|
|
@@ -13442,12 +13222,12 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13442
13222
|
const [x1, y1, x2, y2] = getElementAbsoluteCoords2(element, elementsMap);
|
|
13443
13223
|
const cx = (x1 + x2) / 2;
|
|
13444
13224
|
const cy = (y1 + y2) / 2;
|
|
13445
|
-
const [rotatedX, rotatedY] =
|
|
13446
|
-
|
|
13447
|
-
|
|
13225
|
+
const [rotatedX, rotatedY] = pointRotateRads9(
|
|
13226
|
+
pointFrom10(pointerOnGrid[0], pointerOnGrid[1]),
|
|
13227
|
+
pointFrom10(cx, cy),
|
|
13448
13228
|
-element.angle
|
|
13449
13229
|
);
|
|
13450
|
-
return
|
|
13230
|
+
return pointFrom10(rotatedX - element.x, rotatedY - element.y);
|
|
13451
13231
|
}
|
|
13452
13232
|
/**
|
|
13453
13233
|
* Normalizes line points so that the start point is at [0,0]. This is
|
|
@@ -13496,7 +13276,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13496
13276
|
pointAddedToEnd = true;
|
|
13497
13277
|
}
|
|
13498
13278
|
acc.push(
|
|
13499
|
-
nextPoint ?
|
|
13279
|
+
nextPoint ? pointFrom10((p[0] + nextPoint[0]) / 2, (p[1] + nextPoint[1]) / 2) : pointFrom10(p[0], p[1])
|
|
13500
13280
|
);
|
|
13501
13281
|
nextSelectedIndices.push(indexCursor + 1);
|
|
13502
13282
|
++indexCursor;
|
|
@@ -13512,7 +13292,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13512
13292
|
/* @__PURE__ */ new Map([
|
|
13513
13293
|
[
|
|
13514
13294
|
element.points.length - 1,
|
|
13515
|
-
{ point:
|
|
13295
|
+
{ point: pointFrom10(lastPoint[0] + 30, lastPoint[1] + 30) }
|
|
13516
13296
|
]
|
|
13517
13297
|
])
|
|
13518
13298
|
);
|
|
@@ -13532,7 +13312,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13532
13312
|
});
|
|
13533
13313
|
const isPolygon = isLineElement(element) && element.polygon;
|
|
13534
13314
|
if (isPolygon && (isUncommittedPoint || pointIndices.includes(0) || pointIndices.includes(element.points.length - 1))) {
|
|
13535
|
-
nextPoints[0] =
|
|
13315
|
+
nextPoints[0] = pointFrom10(
|
|
13536
13316
|
nextPoints[nextPoints.length - 1][0],
|
|
13537
13317
|
nextPoints[nextPoints.length - 1][1]
|
|
13538
13318
|
);
|
|
@@ -13553,7 +13333,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13553
13333
|
static addPoints(element, scene, addedPoints) {
|
|
13554
13334
|
const nextPoints = [...element.points, ...addedPoints];
|
|
13555
13335
|
if (isLineElement(element) && element.polygon) {
|
|
13556
|
-
nextPoints[0] =
|
|
13336
|
+
nextPoints[0] = pointFrom10(
|
|
13557
13337
|
nextPoints[nextPoints.length - 1][0],
|
|
13558
13338
|
nextPoints[nextPoints.length - 1][1]
|
|
13559
13339
|
);
|
|
@@ -13578,7 +13358,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13578
13358
|
const lastPointUpdate = pointUpdates.get(points.length - 1);
|
|
13579
13359
|
if (firstPointUpdate) {
|
|
13580
13360
|
pointUpdates.set(points.length - 1, {
|
|
13581
|
-
point:
|
|
13361
|
+
point: pointFrom10(
|
|
13582
13362
|
firstPointUpdate.point[0],
|
|
13583
13363
|
firstPointUpdate.point[1]
|
|
13584
13364
|
),
|
|
@@ -13586,12 +13366,12 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13586
13366
|
});
|
|
13587
13367
|
} else if (lastPointUpdate) {
|
|
13588
13368
|
pointUpdates.set(0, {
|
|
13589
|
-
point:
|
|
13369
|
+
point: pointFrom10(lastPointUpdate.point[0], lastPointUpdate.point[1]),
|
|
13590
13370
|
isDragging: lastPointUpdate.isDragging
|
|
13591
13371
|
});
|
|
13592
13372
|
}
|
|
13593
13373
|
}
|
|
13594
|
-
const updatedOriginPoint = pointUpdates.get(0)?.point ??
|
|
13374
|
+
const updatedOriginPoint = pointUpdates.get(0)?.point ?? pointFrom10(0, 0);
|
|
13595
13375
|
const [offsetX, offsetY] = updatedOriginPoint;
|
|
13596
13376
|
const nextPoints = isElbowArrow(element) ? [
|
|
13597
13377
|
pointUpdates.get(0)?.point ?? points[0],
|
|
@@ -13601,7 +13381,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13601
13381
|
if (otherUpdates?.moveMidPointsWithElement && idx !== 0 && idx !== points.length - 1 && !pointUpdates.has(idx)) {
|
|
13602
13382
|
return current;
|
|
13603
13383
|
}
|
|
13604
|
-
return
|
|
13384
|
+
return pointFrom10(
|
|
13605
13385
|
current[0] - offsetX,
|
|
13606
13386
|
current[1] - offsetY
|
|
13607
13387
|
);
|
|
@@ -13638,7 +13418,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13638
13418
|
const origin = linearElementEditor.initialState.origin;
|
|
13639
13419
|
const dist = pointDistance5(
|
|
13640
13420
|
origin,
|
|
13641
|
-
|
|
13421
|
+
pointFrom10(pointerCoords.x, pointerCoords.y)
|
|
13642
13422
|
);
|
|
13643
13423
|
if (!appState.selectedLinearElement?.isEditing && dist < DRAGGING_THRESHOLD / appState.zoom.value) {
|
|
13644
13424
|
return false;
|
|
@@ -13708,9 +13488,9 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13708
13488
|
const prevCenterY = (prevCoords[1] + prevCoords[3]) / 2;
|
|
13709
13489
|
const dX = prevCenterX - nextCenterX;
|
|
13710
13490
|
const dY = prevCenterY - nextCenterY;
|
|
13711
|
-
const rotatedOffset =
|
|
13712
|
-
|
|
13713
|
-
|
|
13491
|
+
const rotatedOffset = pointRotateRads9(
|
|
13492
|
+
pointFrom10(offsetX, offsetY),
|
|
13493
|
+
pointFrom10(dX, dY),
|
|
13714
13494
|
element.angle
|
|
13715
13495
|
);
|
|
13716
13496
|
scene.mutateElement(element, {
|
|
@@ -13745,9 +13525,9 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13745
13525
|
gridY,
|
|
13746
13526
|
customLineAngle
|
|
13747
13527
|
);
|
|
13748
|
-
return
|
|
13749
|
-
|
|
13750
|
-
|
|
13528
|
+
return pointRotateRads9(
|
|
13529
|
+
pointFrom10(width, height),
|
|
13530
|
+
pointFrom10(0, 0),
|
|
13751
13531
|
-element.angle
|
|
13752
13532
|
);
|
|
13753
13533
|
}
|
|
@@ -13793,34 +13573,34 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13793
13573
|
);
|
|
13794
13574
|
const boundTextX2 = boundTextX1 + boundTextElement.width;
|
|
13795
13575
|
const boundTextY2 = boundTextY1 + boundTextElement.height;
|
|
13796
|
-
const centerPoint =
|
|
13797
|
-
const topLeftRotatedPoint =
|
|
13798
|
-
|
|
13576
|
+
const centerPoint = pointFrom10(cx, cy);
|
|
13577
|
+
const topLeftRotatedPoint = pointRotateRads9(
|
|
13578
|
+
pointFrom10(x1, y1),
|
|
13799
13579
|
centerPoint,
|
|
13800
13580
|
element.angle
|
|
13801
13581
|
);
|
|
13802
|
-
const topRightRotatedPoint =
|
|
13803
|
-
|
|
13582
|
+
const topRightRotatedPoint = pointRotateRads9(
|
|
13583
|
+
pointFrom10(x2, y1),
|
|
13804
13584
|
centerPoint,
|
|
13805
13585
|
element.angle
|
|
13806
13586
|
);
|
|
13807
|
-
const counterRotateBoundTextTopLeft =
|
|
13808
|
-
|
|
13587
|
+
const counterRotateBoundTextTopLeft = pointRotateRads9(
|
|
13588
|
+
pointFrom10(boundTextX1, boundTextY1),
|
|
13809
13589
|
centerPoint,
|
|
13810
13590
|
-element.angle
|
|
13811
13591
|
);
|
|
13812
|
-
const counterRotateBoundTextTopRight =
|
|
13813
|
-
|
|
13592
|
+
const counterRotateBoundTextTopRight = pointRotateRads9(
|
|
13593
|
+
pointFrom10(boundTextX2, boundTextY1),
|
|
13814
13594
|
centerPoint,
|
|
13815
13595
|
-element.angle
|
|
13816
13596
|
);
|
|
13817
|
-
const counterRotateBoundTextBottomLeft =
|
|
13818
|
-
|
|
13597
|
+
const counterRotateBoundTextBottomLeft = pointRotateRads9(
|
|
13598
|
+
pointFrom10(boundTextX1, boundTextY2),
|
|
13819
13599
|
centerPoint,
|
|
13820
13600
|
-element.angle
|
|
13821
13601
|
);
|
|
13822
|
-
const counterRotateBoundTextBottomRight =
|
|
13823
|
-
|
|
13602
|
+
const counterRotateBoundTextBottomRight = pointRotateRads9(
|
|
13603
|
+
pointFrom10(boundTextX2, boundTextY2),
|
|
13824
13604
|
centerPoint,
|
|
13825
13605
|
-element.angle
|
|
13826
13606
|
);
|
|
@@ -13898,7 +13678,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13898
13678
|
if (index && index > 0 && index < element.points.length) {
|
|
13899
13679
|
const isHorizontal = headingIsHorizontal(
|
|
13900
13680
|
vectorToHeading(
|
|
13901
|
-
|
|
13681
|
+
vectorFromPoint8(element.points[index], element.points[index - 1])
|
|
13902
13682
|
)
|
|
13903
13683
|
);
|
|
13904
13684
|
const fixedSegments = (element.fixedSegments ?? []).reduce(
|
|
@@ -13910,11 +13690,11 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13910
13690
|
);
|
|
13911
13691
|
fixedSegments[index] = {
|
|
13912
13692
|
index,
|
|
13913
|
-
start:
|
|
13693
|
+
start: pointFrom10(
|
|
13914
13694
|
!isHorizontal ? x - element.x : element.points[index - 1][0],
|
|
13915
13695
|
isHorizontal ? y - element.y : element.points[index - 1][1]
|
|
13916
13696
|
),
|
|
13917
|
-
end:
|
|
13697
|
+
end: pointFrom10(
|
|
13918
13698
|
!isHorizontal ? x - element.x : element.points[index][0],
|
|
13919
13699
|
isHorizontal ? y - element.y : element.points[index][1]
|
|
13920
13700
|
)
|
|
@@ -13926,7 +13706,7 @@ var LinearElementEditor = class _LinearElementEditor {
|
|
|
13926
13706
|
scene.mutateElement(element, {
|
|
13927
13707
|
fixedSegments: nextFixedSegments
|
|
13928
13708
|
});
|
|
13929
|
-
const point =
|
|
13709
|
+
const point = pointFrom10(
|
|
13930
13710
|
element.x + (element.fixedSegments[offset].start[0] + element.fixedSegments[offset].end[0]) / 2,
|
|
13931
13711
|
element.y + (element.fixedSegments[offset].start[1] + element.fixedSegments[offset].end[1]) / 2
|
|
13932
13712
|
);
|
|
@@ -13967,7 +13747,7 @@ var pointDraggingUpdates = (selectedPointsIndices, deltaX, deltaY, scenePointerX
|
|
|
13967
13747
|
return [
|
|
13968
13748
|
pointIndex,
|
|
13969
13749
|
{
|
|
13970
|
-
point:
|
|
13750
|
+
point: pointFrom10(point[0] + deltaX, point[1] + deltaY),
|
|
13971
13751
|
isDragging: true
|
|
13972
13752
|
}
|
|
13973
13753
|
];
|
|
@@ -14006,7 +13786,7 @@ var pointDraggingUpdates = (selectedPointsIndices, deltaX, deltaY, scenePointerX
|
|
|
14006
13786
|
midPoint: app.state.isMidpointSnappingEnabled ? snapToMid(
|
|
14007
13787
|
suggestedBindingElement,
|
|
14008
13788
|
elementsMap,
|
|
14009
|
-
|
|
13789
|
+
pointFrom10(
|
|
14010
13790
|
scenePointerX - linearElementEditor.pointerOffset.x,
|
|
14011
13791
|
scenePointerY - linearElementEditor.pointerOffset.y
|
|
14012
13792
|
)
|
|
@@ -14086,7 +13866,7 @@ var pointDraggingUpdates = (selectedPointsIndices, deltaX, deltaY, scenePointerX
|
|
|
14086
13866
|
updates.suggestedBinding = start2.element ? {
|
|
14087
13867
|
element: start2.element,
|
|
14088
13868
|
midPoint: getSnapOutlineMidPoint(
|
|
14089
|
-
|
|
13869
|
+
pointFrom10(
|
|
14090
13870
|
scenePointerX - linearElementEditor.pointerOffset.x,
|
|
14091
13871
|
scenePointerY - linearElementEditor.pointerOffset.y
|
|
14092
13872
|
),
|
|
@@ -14117,7 +13897,7 @@ var pointDraggingUpdates = (selectedPointsIndices, deltaX, deltaY, scenePointerX
|
|
|
14117
13897
|
updates.suggestedBinding = end.element ? {
|
|
14118
13898
|
element: end.element,
|
|
14119
13899
|
midPoint: getSnapOutlineMidPoint(
|
|
14120
|
-
|
|
13900
|
+
pointFrom10(
|
|
14121
13901
|
scenePointerX - linearElementEditor.pointerOffset.x,
|
|
14122
13902
|
scenePointerY - linearElementEditor.pointerOffset.y
|
|
14123
13903
|
),
|
|
@@ -14130,11 +13910,11 @@ var pointDraggingUpdates = (selectedPointsIndices, deltaX, deltaY, scenePointerX
|
|
|
14130
13910
|
} else if (endIsDragged) {
|
|
14131
13911
|
updates.suggestedBinding = app.state.suggestedBinding;
|
|
14132
13912
|
}
|
|
14133
|
-
const offsetStartLocalPoint = startIsDragged ?
|
|
13913
|
+
const offsetStartLocalPoint = startIsDragged ? pointFrom10(
|
|
14134
13914
|
element.points[0][0] + deltaX,
|
|
14135
13915
|
element.points[0][1] + deltaY
|
|
14136
13916
|
) : element.points[0];
|
|
14137
|
-
const offsetEndLocalPoint = endIsDragged ?
|
|
13917
|
+
const offsetEndLocalPoint = endIsDragged ? pointFrom10(
|
|
14138
13918
|
element.points[element.points.length - 1][0] + deltaX,
|
|
14139
13919
|
element.points[element.points.length - 1][1] + deltaY
|
|
14140
13920
|
) : element.points[element.points.length - 1];
|
|
@@ -14383,7 +14163,10 @@ var drawElementOnCanvas = (element, rc, context, renderConfig) => {
|
|
|
14383
14163
|
const shapes = ShapeCache.generateElementShape(element, renderConfig);
|
|
14384
14164
|
for (const shape of shapes) {
|
|
14385
14165
|
if (typeof shape === "string") {
|
|
14386
|
-
context.fillStyle =
|
|
14166
|
+
context.fillStyle = applyDarkModeFilter(
|
|
14167
|
+
element.strokeColor,
|
|
14168
|
+
renderConfig.theme === THEME.DARK
|
|
14169
|
+
);
|
|
14387
14170
|
context.fill(new Path2D(shape));
|
|
14388
14171
|
} else {
|
|
14389
14172
|
rc.draw(shape);
|
|
@@ -14491,7 +14274,10 @@ var drawElementOnCanvas = (element, rc, context, renderConfig) => {
|
|
|
14491
14274
|
context.canvas.setAttribute("dir", rtl ? "rtl" : "ltr");
|
|
14492
14275
|
context.save();
|
|
14493
14276
|
context.font = getFontString3(element);
|
|
14494
|
-
context.fillStyle =
|
|
14277
|
+
context.fillStyle = applyDarkModeFilter(
|
|
14278
|
+
element.strokeColor,
|
|
14279
|
+
renderConfig.theme === THEME.DARK
|
|
14280
|
+
);
|
|
14495
14281
|
context.textAlign = element.textAlign;
|
|
14496
14282
|
const lines = element.text.replace(/\r\n?/g, "\n").split("\n");
|
|
14497
14283
|
const horizontalOffset = element.textAlign === "center" ? element.width / 2 : element.textAlign === "right" ? element.width : 0;
|
|
@@ -14639,7 +14425,10 @@ var renderElement = (element, elementsMap, allElementsMap, rc, context, renderCo
|
|
|
14639
14425
|
);
|
|
14640
14426
|
context.fillStyle = "rgba(0, 0, 200, 0.04)";
|
|
14641
14427
|
context.lineWidth = FRAME_STYLE.strokeWidth / appState.zoom.value;
|
|
14642
|
-
context.strokeStyle =
|
|
14428
|
+
context.strokeStyle = applyDarkModeFilter(
|
|
14429
|
+
FRAME_STYLE.strokeColor,
|
|
14430
|
+
appState.theme === THEME.DARK
|
|
14431
|
+
);
|
|
14643
14432
|
if (isMagicFrameElement(element)) {
|
|
14644
14433
|
context.strokeStyle = appState.theme === THEME.LIGHT ? "#7affd7" : applyDarkModeFilter("#1d8264");
|
|
14645
14434
|
}
|
|
@@ -14842,7 +14631,7 @@ function getFreedrawOutlineAsSegments(element, points, elementsMap) {
|
|
|
14842
14631
|
},
|
|
14843
14632
|
elementsMap
|
|
14844
14633
|
);
|
|
14845
|
-
const center =
|
|
14634
|
+
const center = pointFrom11(
|
|
14846
14635
|
(bounds[0] + bounds[2]) / 2,
|
|
14847
14636
|
(bounds[1] + bounds[3]) / 2
|
|
14848
14637
|
);
|
|
@@ -14850,10 +14639,10 @@ function getFreedrawOutlineAsSegments(element, points, elementsMap) {
|
|
|
14850
14639
|
return points.slice(2).reduce(
|
|
14851
14640
|
(acc, curr) => {
|
|
14852
14641
|
acc.push(
|
|
14853
|
-
|
|
14642
|
+
lineSegment5(
|
|
14854
14643
|
acc[acc.length - 1][1],
|
|
14855
|
-
|
|
14856
|
-
|
|
14644
|
+
pointRotateRads10(
|
|
14645
|
+
pointFrom11(curr[0] + element.x, curr[1] + element.y),
|
|
14857
14646
|
center,
|
|
14858
14647
|
element.angle
|
|
14859
14648
|
)
|
|
@@ -14862,17 +14651,17 @@ function getFreedrawOutlineAsSegments(element, points, elementsMap) {
|
|
|
14862
14651
|
return acc;
|
|
14863
14652
|
},
|
|
14864
14653
|
[
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
14654
|
+
lineSegment5(
|
|
14655
|
+
pointRotateRads10(
|
|
14656
|
+
pointFrom11(
|
|
14868
14657
|
points[0][0] + element.x,
|
|
14869
14658
|
points[0][1] + element.y
|
|
14870
14659
|
),
|
|
14871
14660
|
center,
|
|
14872
14661
|
element.angle
|
|
14873
14662
|
),
|
|
14874
|
-
|
|
14875
|
-
|
|
14663
|
+
pointRotateRads10(
|
|
14664
|
+
pointFrom11(
|
|
14876
14665
|
points[1][0] + element.x,
|
|
14877
14666
|
points[1][1] + element.y
|
|
14878
14667
|
),
|
|
@@ -14967,7 +14756,7 @@ var generateRoughOptions = (element, continuousPath = false, isDarkMode = false)
|
|
|
14967
14756
|
fillWeight: element.strokeWidth / 2,
|
|
14968
14757
|
hachureGap: element.strokeWidth * 4,
|
|
14969
14758
|
roughness: adjustRoughness(element),
|
|
14970
|
-
stroke:
|
|
14759
|
+
stroke: applyDarkModeFilter2(element.strokeColor, isDarkMode),
|
|
14971
14760
|
preserveVertices: continuousPath || element.roughness < ROUGHNESS.cartoonist
|
|
14972
14761
|
};
|
|
14973
14762
|
switch (element.type) {
|
|
@@ -14977,7 +14766,7 @@ var generateRoughOptions = (element, continuousPath = false, isDarkMode = false)
|
|
|
14977
14766
|
case "diamond":
|
|
14978
14767
|
case "ellipse": {
|
|
14979
14768
|
options.fillStyle = element.fillStyle;
|
|
14980
|
-
options.fill = isTransparent3(element.backgroundColor) ? void 0 :
|
|
14769
|
+
options.fill = isTransparent3(element.backgroundColor) ? void 0 : applyDarkModeFilter2(element.backgroundColor, isDarkMode);
|
|
14981
14770
|
if (element.type === "ellipse") {
|
|
14982
14771
|
options.curveFitting = 1;
|
|
14983
14772
|
}
|
|
@@ -14987,7 +14776,7 @@ var generateRoughOptions = (element, continuousPath = false, isDarkMode = false)
|
|
|
14987
14776
|
case "freedraw": {
|
|
14988
14777
|
if (isPathALoop(element.points)) {
|
|
14989
14778
|
options.fillStyle = element.fillStyle;
|
|
14990
|
-
options.fill = element.backgroundColor === "transparent" ? void 0 :
|
|
14779
|
+
options.fill = element.backgroundColor === "transparent" ? void 0 : applyDarkModeFilter2(element.backgroundColor, isDarkMode);
|
|
14991
14780
|
}
|
|
14992
14781
|
return options;
|
|
14993
14782
|
}
|
|
@@ -15062,8 +14851,11 @@ var getArrowheadShapes = (element, shape, position, arrowhead, generator, option
|
|
|
15062
14851
|
if (arrowhead === null) {
|
|
15063
14852
|
return [];
|
|
15064
14853
|
}
|
|
15065
|
-
const strokeColor =
|
|
15066
|
-
const backgroundFillColor =
|
|
14854
|
+
const strokeColor = applyDarkModeFilter2(element.strokeColor, isDarkMode);
|
|
14855
|
+
const backgroundFillColor = applyDarkModeFilter2(
|
|
14856
|
+
canvasBackgroundColor,
|
|
14857
|
+
isDarkMode
|
|
14858
|
+
);
|
|
15067
14859
|
const cardinalityOneOrManyOffset = -0.25;
|
|
15068
14860
|
const cardinalityZeroCircleScale = 0.8;
|
|
15069
14861
|
switch (arrowhead) {
|
|
@@ -15248,26 +15040,26 @@ var generateLinearCollisionShape = (element, elementsMap) => {
|
|
|
15248
15040
|
switch (element.type) {
|
|
15249
15041
|
case "line":
|
|
15250
15042
|
case "arrow": {
|
|
15251
|
-
const points = element.points.length ? element.points : [
|
|
15043
|
+
const points = element.points.length ? element.points : [pointFrom12(0, 0)];
|
|
15252
15044
|
if (isElbowArrow(element)) {
|
|
15253
15045
|
return generator.path(generateElbowArrowShape(points, 16), options).sets[0].ops;
|
|
15254
15046
|
} else if (!element.roundness) {
|
|
15255
15047
|
return points.map((point, idx) => {
|
|
15256
|
-
const p =
|
|
15257
|
-
|
|
15048
|
+
const p = pointRotateRads11(
|
|
15049
|
+
pointFrom12(element.x + point[0], element.y + point[1]),
|
|
15258
15050
|
center,
|
|
15259
15051
|
element.angle
|
|
15260
15052
|
);
|
|
15261
15053
|
return {
|
|
15262
15054
|
op: idx === 0 ? "move" : "lineTo",
|
|
15263
|
-
data:
|
|
15055
|
+
data: pointFrom12(p[0] - element.x, p[1] - element.y)
|
|
15264
15056
|
};
|
|
15265
15057
|
});
|
|
15266
15058
|
}
|
|
15267
15059
|
return generator.curve(points, options).sets[0].ops.slice(0, element.points.length).map((op, i) => {
|
|
15268
15060
|
if (i === 0) {
|
|
15269
|
-
const p =
|
|
15270
|
-
|
|
15061
|
+
const p = pointRotateRads11(
|
|
15062
|
+
pointFrom12(
|
|
15271
15063
|
element.x + op.data[0],
|
|
15272
15064
|
element.y + op.data[1]
|
|
15273
15065
|
),
|
|
@@ -15276,30 +15068,30 @@ var generateLinearCollisionShape = (element, elementsMap) => {
|
|
|
15276
15068
|
);
|
|
15277
15069
|
return {
|
|
15278
15070
|
op: "move",
|
|
15279
|
-
data:
|
|
15071
|
+
data: pointFrom12(p[0] - element.x, p[1] - element.y)
|
|
15280
15072
|
};
|
|
15281
15073
|
}
|
|
15282
15074
|
return {
|
|
15283
15075
|
op: "bcurveTo",
|
|
15284
15076
|
data: [
|
|
15285
|
-
|
|
15286
|
-
|
|
15077
|
+
pointRotateRads11(
|
|
15078
|
+
pointFrom12(
|
|
15287
15079
|
element.x + op.data[0],
|
|
15288
15080
|
element.y + op.data[1]
|
|
15289
15081
|
),
|
|
15290
15082
|
center,
|
|
15291
15083
|
element.angle
|
|
15292
15084
|
),
|
|
15293
|
-
|
|
15294
|
-
|
|
15085
|
+
pointRotateRads11(
|
|
15086
|
+
pointFrom12(
|
|
15295
15087
|
element.x + op.data[2],
|
|
15296
15088
|
element.y + op.data[3]
|
|
15297
15089
|
),
|
|
15298
15090
|
center,
|
|
15299
15091
|
element.angle
|
|
15300
15092
|
),
|
|
15301
|
-
|
|
15302
|
-
|
|
15093
|
+
pointRotateRads11(
|
|
15094
|
+
pointFrom12(
|
|
15303
15095
|
element.x + op.data[4],
|
|
15304
15096
|
element.y + op.data[5]
|
|
15305
15097
|
),
|
|
@@ -15307,7 +15099,7 @@ var generateLinearCollisionShape = (element, elementsMap) => {
|
|
|
15307
15099
|
element.angle
|
|
15308
15100
|
)
|
|
15309
15101
|
].map(
|
|
15310
|
-
(p) =>
|
|
15102
|
+
(p) => pointFrom12(p[0] - element.x, p[1] - element.y)
|
|
15311
15103
|
).flat()
|
|
15312
15104
|
};
|
|
15313
15105
|
});
|
|
@@ -15322,8 +15114,8 @@ var generateLinearCollisionShape = (element, elementsMap) => {
|
|
|
15322
15114
|
);
|
|
15323
15115
|
return generator.curve(simplifiedPoints, options).sets[0].ops.slice(0, element.points.length).map((op, i) => {
|
|
15324
15116
|
if (i === 0) {
|
|
15325
|
-
const p =
|
|
15326
|
-
|
|
15117
|
+
const p = pointRotateRads11(
|
|
15118
|
+
pointFrom12(
|
|
15327
15119
|
element.x + op.data[0],
|
|
15328
15120
|
element.y + op.data[1]
|
|
15329
15121
|
),
|
|
@@ -15332,30 +15124,30 @@ var generateLinearCollisionShape = (element, elementsMap) => {
|
|
|
15332
15124
|
);
|
|
15333
15125
|
return {
|
|
15334
15126
|
op: "move",
|
|
15335
|
-
data:
|
|
15127
|
+
data: pointFrom12(p[0] - element.x, p[1] - element.y)
|
|
15336
15128
|
};
|
|
15337
15129
|
}
|
|
15338
15130
|
return {
|
|
15339
15131
|
op: "bcurveTo",
|
|
15340
15132
|
data: [
|
|
15341
|
-
|
|
15342
|
-
|
|
15133
|
+
pointRotateRads11(
|
|
15134
|
+
pointFrom12(
|
|
15343
15135
|
element.x + op.data[0],
|
|
15344
15136
|
element.y + op.data[1]
|
|
15345
15137
|
),
|
|
15346
15138
|
center,
|
|
15347
15139
|
element.angle
|
|
15348
15140
|
),
|
|
15349
|
-
|
|
15350
|
-
|
|
15141
|
+
pointRotateRads11(
|
|
15142
|
+
pointFrom12(
|
|
15351
15143
|
element.x + op.data[2],
|
|
15352
15144
|
element.y + op.data[3]
|
|
15353
15145
|
),
|
|
15354
15146
|
center,
|
|
15355
15147
|
element.angle
|
|
15356
15148
|
),
|
|
15357
|
-
|
|
15358
|
-
|
|
15149
|
+
pointRotateRads11(
|
|
15150
|
+
pointFrom12(
|
|
15359
15151
|
element.x + op.data[4],
|
|
15360
15152
|
element.y + op.data[5]
|
|
15361
15153
|
),
|
|
@@ -15363,7 +15155,7 @@ var generateLinearCollisionShape = (element, elementsMap) => {
|
|
|
15363
15155
|
element.angle
|
|
15364
15156
|
)
|
|
15365
15157
|
].map(
|
|
15366
|
-
(p) =>
|
|
15158
|
+
(p) => pointFrom12(p[0] - element.x, p[1] - element.y)
|
|
15367
15159
|
).flat()
|
|
15368
15160
|
};
|
|
15369
15161
|
});
|
|
@@ -15464,7 +15256,7 @@ var _generateElementShape = (element, generator, {
|
|
|
15464
15256
|
case "arrow": {
|
|
15465
15257
|
let shape;
|
|
15466
15258
|
const options = generateRoughOptions(element, false, isDarkMode);
|
|
15467
|
-
const points = element.points.length ? element.points : [
|
|
15259
|
+
const points = element.points.length ? element.points : [pointFrom12(0, 0)];
|
|
15468
15260
|
if (isElbowArrow(element)) {
|
|
15469
15261
|
if (!points.every(
|
|
15470
15262
|
(point) => Math.abs(point[0]) <= 1e6 && Math.abs(point[1]) <= 1e6
|
|
@@ -15628,14 +15420,14 @@ var getElementShape = (element, elementsMap) => {
|
|
|
15628
15420
|
return shouldTestInside(element) ? getClosedCurveShape(
|
|
15629
15421
|
element,
|
|
15630
15422
|
roughShape,
|
|
15631
|
-
|
|
15423
|
+
pointFrom12(element.x, element.y),
|
|
15632
15424
|
element.angle,
|
|
15633
|
-
|
|
15425
|
+
pointFrom12(cx, cy)
|
|
15634
15426
|
) : getCurveShape(
|
|
15635
15427
|
roughShape,
|
|
15636
|
-
|
|
15428
|
+
pointFrom12(element.x, element.y),
|
|
15637
15429
|
element.angle,
|
|
15638
|
-
|
|
15430
|
+
pointFrom12(cx, cy)
|
|
15639
15431
|
);
|
|
15640
15432
|
}
|
|
15641
15433
|
case "ellipse":
|
|
@@ -15644,7 +15436,7 @@ var getElementShape = (element, elementsMap) => {
|
|
|
15644
15436
|
const [, , , , cx, cy] = getElementAbsoluteCoords2(element, elementsMap);
|
|
15645
15437
|
return getFreedrawShape(
|
|
15646
15438
|
element,
|
|
15647
|
-
|
|
15439
|
+
pointFrom12(cx, cy),
|
|
15648
15440
|
shouldTestInside(element)
|
|
15649
15441
|
);
|
|
15650
15442
|
}
|
|
@@ -15663,9 +15455,9 @@ var toggleLinePolygonState = (element, nextPolygonState) => {
|
|
|
15663
15455
|
firstPoint[1] - lastPoint[1]
|
|
15664
15456
|
);
|
|
15665
15457
|
if (distance3 > LINE_POLYGON_POINT_MERGE_DISTANCE || updatedPoints.length < 4) {
|
|
15666
|
-
updatedPoints.push(
|
|
15458
|
+
updatedPoints.push(pointFrom12(firstPoint[0], firstPoint[1]));
|
|
15667
15459
|
} else {
|
|
15668
|
-
updatedPoints[updatedPoints.length - 1] =
|
|
15460
|
+
updatedPoints[updatedPoints.length - 1] = pointFrom12(
|
|
15669
15461
|
firstPoint[0],
|
|
15670
15462
|
firstPoint[1]
|
|
15671
15463
|
);
|
|
@@ -15758,9 +15550,9 @@ var ElementBounds = class _ElementBounds {
|
|
|
15758
15550
|
if (isFreeDrawElement(element)) {
|
|
15759
15551
|
const [minX, minY, maxX, maxY] = getBoundsFromPoints(
|
|
15760
15552
|
element.points.map(
|
|
15761
|
-
([x, y]) =>
|
|
15762
|
-
|
|
15763
|
-
|
|
15553
|
+
([x, y]) => pointRotateRads12(
|
|
15554
|
+
pointFrom13(x, y),
|
|
15555
|
+
pointFrom13(cx - element.x, cy - element.y),
|
|
15764
15556
|
element.angle
|
|
15765
15557
|
)
|
|
15766
15558
|
)
|
|
@@ -15774,24 +15566,24 @@ var ElementBounds = class _ElementBounds {
|
|
|
15774
15566
|
} else if (isLinearElement(element)) {
|
|
15775
15567
|
bounds = getLinearElementRotatedBounds(element, cx, cy, elementsMap);
|
|
15776
15568
|
} else if (element.type === "diamond") {
|
|
15777
|
-
const [x11, y11] =
|
|
15778
|
-
|
|
15779
|
-
|
|
15569
|
+
const [x11, y11] = pointRotateRads12(
|
|
15570
|
+
pointFrom13(cx, y1),
|
|
15571
|
+
pointFrom13(cx, cy),
|
|
15780
15572
|
element.angle
|
|
15781
15573
|
);
|
|
15782
|
-
const [x12, y12] =
|
|
15783
|
-
|
|
15784
|
-
|
|
15574
|
+
const [x12, y12] = pointRotateRads12(
|
|
15575
|
+
pointFrom13(cx, y2),
|
|
15576
|
+
pointFrom13(cx, cy),
|
|
15785
15577
|
element.angle
|
|
15786
15578
|
);
|
|
15787
|
-
const [x22, y22] =
|
|
15788
|
-
|
|
15789
|
-
|
|
15579
|
+
const [x22, y22] = pointRotateRads12(
|
|
15580
|
+
pointFrom13(x1, cy),
|
|
15581
|
+
pointFrom13(cx, cy),
|
|
15790
15582
|
element.angle
|
|
15791
15583
|
);
|
|
15792
|
-
const [x21, y21] =
|
|
15793
|
-
|
|
15794
|
-
|
|
15584
|
+
const [x21, y21] = pointRotateRads12(
|
|
15585
|
+
pointFrom13(x2, cy),
|
|
15586
|
+
pointFrom13(cx, cy),
|
|
15795
15587
|
element.angle
|
|
15796
15588
|
);
|
|
15797
15589
|
const minX = Math.min(x11, x12, x22, x21);
|
|
@@ -15808,24 +15600,24 @@ var ElementBounds = class _ElementBounds {
|
|
|
15808
15600
|
const hh = Math.hypot(h * cos, w * sin);
|
|
15809
15601
|
bounds = [cx - ww, cy - hh, cx + ww, cy + hh];
|
|
15810
15602
|
} else {
|
|
15811
|
-
const [x11, y11] =
|
|
15812
|
-
|
|
15813
|
-
|
|
15603
|
+
const [x11, y11] = pointRotateRads12(
|
|
15604
|
+
pointFrom13(x1, y1),
|
|
15605
|
+
pointFrom13(cx, cy),
|
|
15814
15606
|
element.angle
|
|
15815
15607
|
);
|
|
15816
|
-
const [x12, y12] =
|
|
15817
|
-
|
|
15818
|
-
|
|
15608
|
+
const [x12, y12] = pointRotateRads12(
|
|
15609
|
+
pointFrom13(x1, y2),
|
|
15610
|
+
pointFrom13(cx, cy),
|
|
15819
15611
|
element.angle
|
|
15820
15612
|
);
|
|
15821
|
-
const [x22, y22] =
|
|
15822
|
-
|
|
15823
|
-
|
|
15613
|
+
const [x22, y22] = pointRotateRads12(
|
|
15614
|
+
pointFrom13(x2, y2),
|
|
15615
|
+
pointFrom13(cx, cy),
|
|
15824
15616
|
element.angle
|
|
15825
15617
|
);
|
|
15826
|
-
const [x21, y21] =
|
|
15827
|
-
|
|
15828
|
-
|
|
15618
|
+
const [x21, y21] = pointRotateRads12(
|
|
15619
|
+
pointFrom13(x2, y1),
|
|
15620
|
+
pointFrom13(cx, cy),
|
|
15829
15621
|
element.angle
|
|
15830
15622
|
);
|
|
15831
15623
|
const minX = Math.min(x11, x12, x22, x21);
|
|
@@ -15879,7 +15671,7 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
15879
15671
|
element,
|
|
15880
15672
|
elementsMap
|
|
15881
15673
|
);
|
|
15882
|
-
const center =
|
|
15674
|
+
const center = pointFrom13(cx, cy);
|
|
15883
15675
|
if (shape.type === "polycurve") {
|
|
15884
15676
|
const curves = shape.data;
|
|
15885
15677
|
const pointsOnCurves = curves.map(
|
|
@@ -15891,9 +15683,9 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
15891
15683
|
let i = 0;
|
|
15892
15684
|
while (i < points.length - 1) {
|
|
15893
15685
|
segments.push(
|
|
15894
|
-
|
|
15895
|
-
|
|
15896
|
-
|
|
15686
|
+
lineSegment6(
|
|
15687
|
+
pointFrom13(points[i][0], points[i][1]),
|
|
15688
|
+
pointFrom13(points[i + 1][0], points[i + 1][1])
|
|
15897
15689
|
)
|
|
15898
15690
|
);
|
|
15899
15691
|
i++;
|
|
@@ -15904,9 +15696,9 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
15904
15696
|
let i = 0;
|
|
15905
15697
|
while (i < points.length - 1) {
|
|
15906
15698
|
segments.push(
|
|
15907
|
-
|
|
15908
|
-
|
|
15909
|
-
|
|
15699
|
+
lineSegment6(
|
|
15700
|
+
pointFrom13(points[i][0], points[i][1]),
|
|
15701
|
+
pointFrom13(points[i + 1][0], points[i + 1][1])
|
|
15910
15702
|
)
|
|
15911
15703
|
);
|
|
15912
15704
|
i++;
|
|
@@ -15930,10 +15722,10 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
15930
15722
|
const container = getContainerElement(element, elementsMap);
|
|
15931
15723
|
if (container && isLinearElement(container)) {
|
|
15932
15724
|
const segments2 = [
|
|
15933
|
-
|
|
15934
|
-
|
|
15935
|
-
|
|
15936
|
-
|
|
15725
|
+
lineSegment6(pointFrom13(x1, y1), pointFrom13(x2, y1)),
|
|
15726
|
+
lineSegment6(pointFrom13(x2, y1), pointFrom13(x2, y2)),
|
|
15727
|
+
lineSegment6(pointFrom13(x2, y2), pointFrom13(x1, y2)),
|
|
15728
|
+
lineSegment6(pointFrom13(x1, y2), pointFrom13(x1, y1))
|
|
15937
15729
|
];
|
|
15938
15730
|
return segments2;
|
|
15939
15731
|
}
|
|
@@ -15941,7 +15733,7 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
15941
15733
|
const points = shape.data;
|
|
15942
15734
|
const segments = [];
|
|
15943
15735
|
for (let i = 0; i < points.length - 1; i++) {
|
|
15944
|
-
segments.push(
|
|
15736
|
+
segments.push(lineSegment6(points[i], points[i + 1]));
|
|
15945
15737
|
}
|
|
15946
15738
|
return segments;
|
|
15947
15739
|
} else if (shape.type === "ellipse") {
|
|
@@ -15956,16 +15748,16 @@ var getElementLineSegments = (element, elementsMap) => {
|
|
|
15956
15748
|
[cx, y2],
|
|
15957
15749
|
[x1, cy],
|
|
15958
15750
|
[x2, cy]
|
|
15959
|
-
].map((point) =>
|
|
15751
|
+
].map((point) => pointRotateRads12(point, center, element.angle));
|
|
15960
15752
|
return [
|
|
15961
|
-
|
|
15962
|
-
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
15753
|
+
lineSegment6(nw, ne),
|
|
15754
|
+
lineSegment6(sw, se2),
|
|
15755
|
+
lineSegment6(nw, sw),
|
|
15756
|
+
lineSegment6(ne, se2),
|
|
15757
|
+
lineSegment6(nw, e),
|
|
15758
|
+
lineSegment6(sw, e),
|
|
15759
|
+
lineSegment6(ne, w),
|
|
15760
|
+
lineSegment6(se2, w)
|
|
15969
15761
|
];
|
|
15970
15762
|
};
|
|
15971
15763
|
var _isRectanguloidElement = (element) => {
|
|
@@ -15973,9 +15765,9 @@ var _isRectanguloidElement = (element) => {
|
|
|
15973
15765
|
};
|
|
15974
15766
|
var getRotatedSides = (sides, center, angle) => {
|
|
15975
15767
|
return sides.map((side) => {
|
|
15976
|
-
return
|
|
15977
|
-
|
|
15978
|
-
|
|
15768
|
+
return lineSegment6(
|
|
15769
|
+
pointRotateRads12(side[0], center, angle),
|
|
15770
|
+
pointRotateRads12(side[1], center, angle)
|
|
15979
15771
|
);
|
|
15980
15772
|
});
|
|
15981
15773
|
};
|
|
@@ -15985,14 +15777,14 @@ var getSegmentsOnCurve = (curve4, center, angle) => {
|
|
|
15985
15777
|
const segments = [];
|
|
15986
15778
|
while (i < points.length - 1) {
|
|
15987
15779
|
segments.push(
|
|
15988
|
-
|
|
15989
|
-
|
|
15990
|
-
|
|
15780
|
+
lineSegment6(
|
|
15781
|
+
pointRotateRads12(
|
|
15782
|
+
pointFrom13(points[i][0], points[i][1]),
|
|
15991
15783
|
center,
|
|
15992
15784
|
angle
|
|
15993
15785
|
),
|
|
15994
|
-
|
|
15995
|
-
|
|
15786
|
+
pointRotateRads12(
|
|
15787
|
+
pointFrom13(points[i + 1][0], points[i + 1][1]),
|
|
15996
15788
|
center,
|
|
15997
15789
|
angle
|
|
15998
15790
|
)
|
|
@@ -16003,7 +15795,7 @@ var getSegmentsOnCurve = (curve4, center, angle) => {
|
|
|
16003
15795
|
return segments;
|
|
16004
15796
|
};
|
|
16005
15797
|
var getSegmentsOnEllipse = (ellipse4) => {
|
|
16006
|
-
const center =
|
|
15798
|
+
const center = pointFrom13(
|
|
16007
15799
|
ellipse4.x + ellipse4.width / 2,
|
|
16008
15800
|
ellipse4.y + ellipse4.height / 2
|
|
16009
15801
|
);
|
|
@@ -16017,12 +15809,12 @@ var getSegmentsOnEllipse = (ellipse4) => {
|
|
|
16017
15809
|
const t = i * deltaT;
|
|
16018
15810
|
const x = center[0] + a2 * Math.cos(t);
|
|
16019
15811
|
const y = center[1] + b2 * Math.sin(t);
|
|
16020
|
-
points.push(
|
|
15812
|
+
points.push(pointRotateRads12(pointFrom13(x, y), center, ellipse4.angle));
|
|
16021
15813
|
}
|
|
16022
15814
|
for (let i = 0; i < points.length - 1; i++) {
|
|
16023
|
-
segments.push(
|
|
15815
|
+
segments.push(lineSegment6(points[i], points[i + 1]));
|
|
16024
15816
|
}
|
|
16025
|
-
segments.push(
|
|
15817
|
+
segments.push(lineSegment6(points[points.length - 1], points[0]));
|
|
16026
15818
|
return segments;
|
|
16027
15819
|
};
|
|
16028
15820
|
var getRectangleBoxAbsoluteCoords = (boxSceneCoords) => {
|
|
@@ -16100,7 +15892,7 @@ var getCubicBezierCurveBound = (p0, p1, p2, p3) => {
|
|
|
16100
15892
|
return [minX, minY, maxX, maxY];
|
|
16101
15893
|
};
|
|
16102
15894
|
var getMinMaxXYFromCurvePathOps = (ops, transformXY) => {
|
|
16103
|
-
let currentP =
|
|
15895
|
+
let currentP = pointFrom13(0, 0);
|
|
16104
15896
|
const { minX, minY, maxX, maxY } = ops.reduce(
|
|
16105
15897
|
(limits, { op, data }) => {
|
|
16106
15898
|
if (op === "move") {
|
|
@@ -16108,9 +15900,9 @@ var getMinMaxXYFromCurvePathOps = (ops, transformXY) => {
|
|
|
16108
15900
|
invariant10(p != null, "Op data is not a point");
|
|
16109
15901
|
currentP = p;
|
|
16110
15902
|
} else if (op === "bcurveTo") {
|
|
16111
|
-
const _p1 =
|
|
16112
|
-
const _p2 =
|
|
16113
|
-
const _p3 =
|
|
15903
|
+
const _p1 = pointFrom13(data[0], data[1]);
|
|
15904
|
+
const _p2 = pointFrom13(data[2], data[3]);
|
|
15905
|
+
const _p3 = pointFrom13(data[4], data[5]);
|
|
16114
15906
|
const p1 = transformXY ? transformXY(_p1) : _p1;
|
|
16115
15907
|
const p2 = transformXY ? transformXY(_p2) : _p2;
|
|
16116
15908
|
const p3 = transformXY ? transformXY(_p3) : _p3;
|
|
@@ -16201,17 +15993,17 @@ var getArrowheadPoints = (element, shape, position, arrowhead, offsetMultiplier
|
|
|
16201
15993
|
const index = position === "start" ? 1 : ops.length - 1;
|
|
16202
15994
|
const data = ops[index].data;
|
|
16203
15995
|
invariant10(data.length === 6, "Op data length is not 6");
|
|
16204
|
-
const p3 =
|
|
16205
|
-
const p2 =
|
|
16206
|
-
const p1 =
|
|
15996
|
+
const p3 = pointFrom13(data[4], data[5]);
|
|
15997
|
+
const p2 = pointFrom13(data[2], data[3]);
|
|
15998
|
+
const p1 = pointFrom13(data[0], data[1]);
|
|
16207
15999
|
const prevOp = ops[index - 1];
|
|
16208
|
-
let p0 =
|
|
16000
|
+
let p0 = pointFrom13(0, 0);
|
|
16209
16001
|
if (prevOp.op === "move") {
|
|
16210
16002
|
const p = pointFromArray3(prevOp.data);
|
|
16211
16003
|
invariant10(p != null, "Op data is not a point");
|
|
16212
16004
|
p0 = p;
|
|
16213
16005
|
} else if (prevOp.op === "bcurveTo") {
|
|
16214
|
-
p0 =
|
|
16006
|
+
p0 = pointFrom13(prevOp.data[4], prevOp.data[5]);
|
|
16215
16007
|
}
|
|
16216
16008
|
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);
|
|
16217
16009
|
const [x2, y2] = position === "start" ? p0 : p3;
|
|
@@ -16238,26 +16030,26 @@ var getArrowheadPoints = (element, shape, position, arrowhead, offsetMultiplier
|
|
|
16238
16030
|
}
|
|
16239
16031
|
const angle = getArrowheadAngle(arrowhead);
|
|
16240
16032
|
if (arrowhead === "cardinality_many" || arrowhead === "cardinality_one_or_many") {
|
|
16241
|
-
const [x32, y32] =
|
|
16242
|
-
|
|
16243
|
-
|
|
16033
|
+
const [x32, y32] = pointRotateRads12(
|
|
16034
|
+
pointFrom13(tx, ty),
|
|
16035
|
+
pointFrom13(xs, ys),
|
|
16244
16036
|
degreesToRadians(-angle)
|
|
16245
16037
|
);
|
|
16246
|
-
const [x42, y42] =
|
|
16247
|
-
|
|
16248
|
-
|
|
16038
|
+
const [x42, y42] = pointRotateRads12(
|
|
16039
|
+
pointFrom13(tx, ty),
|
|
16040
|
+
pointFrom13(xs, ys),
|
|
16249
16041
|
degreesToRadians(angle)
|
|
16250
16042
|
);
|
|
16251
16043
|
return [xs, ys, x32, y32, x42, y42];
|
|
16252
16044
|
}
|
|
16253
|
-
const [x3, y3] =
|
|
16254
|
-
|
|
16255
|
-
|
|
16045
|
+
const [x3, y3] = pointRotateRads12(
|
|
16046
|
+
pointFrom13(xs, ys),
|
|
16047
|
+
pointFrom13(tx, ty),
|
|
16256
16048
|
-angle * Math.PI / 180
|
|
16257
16049
|
);
|
|
16258
|
-
const [x4, y4] =
|
|
16259
|
-
|
|
16260
|
-
|
|
16050
|
+
const [x4, y4] = pointRotateRads12(
|
|
16051
|
+
pointFrom13(xs, ys),
|
|
16052
|
+
pointFrom13(tx, ty),
|
|
16261
16053
|
degreesToRadians(angle)
|
|
16262
16054
|
);
|
|
16263
16055
|
if (arrowhead === "diamond" || arrowhead === "diamond_outline") {
|
|
@@ -16265,16 +16057,16 @@ var getArrowheadPoints = (element, shape, position, arrowhead, offsetMultiplier
|
|
|
16265
16057
|
let oy;
|
|
16266
16058
|
if (position === "start") {
|
|
16267
16059
|
const [px, py] = element.points.length > 1 ? element.points[1] : [0, 0];
|
|
16268
|
-
[ox, oy] =
|
|
16269
|
-
|
|
16270
|
-
|
|
16060
|
+
[ox, oy] = pointRotateRads12(
|
|
16061
|
+
pointFrom13(tx + minSize * 2, ty),
|
|
16062
|
+
pointFrom13(tx, ty),
|
|
16271
16063
|
Math.atan2(py - ty, px - tx)
|
|
16272
16064
|
);
|
|
16273
16065
|
} else {
|
|
16274
16066
|
const [px, py] = element.points.length > 1 ? element.points[element.points.length - 2] : [0, 0];
|
|
16275
|
-
[ox, oy] =
|
|
16276
|
-
|
|
16277
|
-
|
|
16067
|
+
[ox, oy] = pointRotateRads12(
|
|
16068
|
+
pointFrom13(tx - minSize * 2, ty),
|
|
16069
|
+
pointFrom13(tx, ty),
|
|
16278
16070
|
Math.atan2(ty - py, tx - px)
|
|
16279
16071
|
);
|
|
16280
16072
|
}
|
|
@@ -16303,9 +16095,9 @@ var getLinearElementRotatedBounds = (element, cx, cy, elementsMap) => {
|
|
|
16303
16095
|
const boundTextElement = getBoundTextElement(element, elementsMap);
|
|
16304
16096
|
if (element.points.length < 2) {
|
|
16305
16097
|
const [pointX, pointY] = element.points[0];
|
|
16306
|
-
const [x, y] =
|
|
16307
|
-
|
|
16308
|
-
|
|
16098
|
+
const [x, y] = pointRotateRads12(
|
|
16099
|
+
pointFrom13(element.x + pointX, element.y + pointY),
|
|
16100
|
+
pointFrom13(cx, cy),
|
|
16309
16101
|
element.angle
|
|
16310
16102
|
);
|
|
16311
16103
|
let coords2 = [x, y, x, y];
|
|
@@ -16328,9 +16120,9 @@ var getLinearElementRotatedBounds = (element, cx, cy, elementsMap) => {
|
|
|
16328
16120
|
const cachedShape = ShapeCache.get(element, null)?.[0];
|
|
16329
16121
|
const shape = cachedShape ?? generateLinearElementShape(element);
|
|
16330
16122
|
const ops = getCurvePathOps(shape);
|
|
16331
|
-
const transformXY = ([x, y]) =>
|
|
16332
|
-
|
|
16333
|
-
|
|
16123
|
+
const transformXY = ([x, y]) => pointRotateRads12(
|
|
16124
|
+
pointFrom13(element.x + x, element.y + y),
|
|
16125
|
+
pointFrom13(cx, cy),
|
|
16334
16126
|
element.angle
|
|
16335
16127
|
);
|
|
16336
16128
|
const res = getMinMaxXYFromCurvePathOps(ops, transformXY);
|
|
@@ -16441,8 +16233,8 @@ var getClosestElementBounds = (elements, from) => {
|
|
|
16441
16233
|
elements.forEach((element) => {
|
|
16442
16234
|
const [x1, y1, x2, y2] = getElementBounds(element, elementsMap);
|
|
16443
16235
|
const distance3 = pointDistance7(
|
|
16444
|
-
|
|
16445
|
-
|
|
16236
|
+
pointFrom13((x1 + x2) / 2, (y1 + y2) / 2),
|
|
16237
|
+
pointFrom13(from.x, from.y)
|
|
16446
16238
|
);
|
|
16447
16239
|
if (distance3 < minDistance) {
|
|
16448
16240
|
minDistance = distance3;
|
|
@@ -16478,7 +16270,7 @@ var getVisibleSceneBounds = ({
|
|
|
16478
16270
|
-scrollY + height / zoom.value
|
|
16479
16271
|
];
|
|
16480
16272
|
};
|
|
16481
|
-
var getCenterForBounds = (bounds) =>
|
|
16273
|
+
var getCenterForBounds = (bounds) => pointFrom13(
|
|
16482
16274
|
bounds[0] + (bounds[2] - bounds[0]) / 2,
|
|
16483
16275
|
bounds[1] + (bounds[3] - bounds[1]) / 2
|
|
16484
16276
|
);
|
|
@@ -16492,23 +16284,23 @@ var aabbForElement = (element, elementsMap, offset) => {
|
|
|
16492
16284
|
midY: element.y + element.height / 2
|
|
16493
16285
|
};
|
|
16494
16286
|
const center = elementCenterPoint(element, elementsMap);
|
|
16495
|
-
const [topLeftX, topLeftY] =
|
|
16496
|
-
|
|
16287
|
+
const [topLeftX, topLeftY] = pointRotateRads12(
|
|
16288
|
+
pointFrom13(bbox.minX, bbox.minY),
|
|
16497
16289
|
center,
|
|
16498
16290
|
element.angle
|
|
16499
16291
|
);
|
|
16500
|
-
const [topRightX, topRightY] =
|
|
16501
|
-
|
|
16292
|
+
const [topRightX, topRightY] = pointRotateRads12(
|
|
16293
|
+
pointFrom13(bbox.maxX, bbox.minY),
|
|
16502
16294
|
center,
|
|
16503
16295
|
element.angle
|
|
16504
16296
|
);
|
|
16505
|
-
const [bottomRightX, bottomRightY] =
|
|
16506
|
-
|
|
16297
|
+
const [bottomRightX, bottomRightY] = pointRotateRads12(
|
|
16298
|
+
pointFrom13(bbox.maxX, bbox.maxY),
|
|
16507
16299
|
center,
|
|
16508
16300
|
element.angle
|
|
16509
16301
|
);
|
|
16510
|
-
const [bottomLeftX, bottomLeftY] =
|
|
16511
|
-
|
|
16302
|
+
const [bottomLeftX, bottomLeftY] = pointRotateRads12(
|
|
16303
|
+
pointFrom13(bbox.minX, bbox.maxY),
|
|
16512
16304
|
center,
|
|
16513
16305
|
element.angle
|
|
16514
16306
|
);
|
|
@@ -16540,19 +16332,224 @@ var doBoundsIntersect = (bounds1, bounds2) => {
|
|
|
16540
16332
|
return minX1 < maxX2 && maxX1 > minX2 && minY1 < maxY2 && maxY1 > minY2;
|
|
16541
16333
|
};
|
|
16542
16334
|
var boundsContainBounds = (outerBounds, innerBounds) => [
|
|
16543
|
-
|
|
16544
|
-
|
|
16545
|
-
|
|
16546
|
-
|
|
16335
|
+
pointFrom13(innerBounds[0], innerBounds[1]),
|
|
16336
|
+
pointFrom13(innerBounds[0], innerBounds[3]),
|
|
16337
|
+
pointFrom13(innerBounds[2], innerBounds[1]),
|
|
16338
|
+
pointFrom13(innerBounds[2], innerBounds[3])
|
|
16547
16339
|
].every((point) => pointInsideBoundsInclusive(point, outerBounds));
|
|
16340
|
+
var elementsOverlappingBBox = ({
|
|
16341
|
+
elements,
|
|
16342
|
+
elementsMap,
|
|
16343
|
+
bounds,
|
|
16344
|
+
type,
|
|
16345
|
+
excludeElementsInFrames,
|
|
16346
|
+
shouldIgnoreElementFromSelection: shouldIgnoreElementFromSelection2
|
|
16347
|
+
}) => {
|
|
16348
|
+
if (!elementsMap) {
|
|
16349
|
+
elementsMap = arrayToMap7(elements);
|
|
16350
|
+
}
|
|
16351
|
+
const selectionBounds = isExcalidrawElement(bounds) ? getElementBounds(bounds, elementsMap) : bounds;
|
|
16352
|
+
const [selectionX1, selectionY1, selectionX2, selectionY2] = selectionBounds;
|
|
16353
|
+
const selectionEdges = [
|
|
16354
|
+
lineSegment6(
|
|
16355
|
+
pointFrom13(selectionX1, selectionY1),
|
|
16356
|
+
pointFrom13(selectionX2, selectionY1)
|
|
16357
|
+
),
|
|
16358
|
+
lineSegment6(
|
|
16359
|
+
pointFrom13(selectionX2, selectionY1),
|
|
16360
|
+
pointFrom13(selectionX2, selectionY2)
|
|
16361
|
+
),
|
|
16362
|
+
lineSegment6(
|
|
16363
|
+
pointFrom13(selectionX2, selectionY2),
|
|
16364
|
+
pointFrom13(selectionX1, selectionY2)
|
|
16365
|
+
),
|
|
16366
|
+
lineSegment6(
|
|
16367
|
+
pointFrom13(selectionX1, selectionY2),
|
|
16368
|
+
pointFrom13(selectionX1, selectionY1)
|
|
16369
|
+
)
|
|
16370
|
+
];
|
|
16371
|
+
const framesInSelection = excludeElementsInFrames ? /* @__PURE__ */ new Set() : null;
|
|
16372
|
+
const groups = {};
|
|
16373
|
+
const elementsInSelection = /* @__PURE__ */ new Set();
|
|
16374
|
+
for (const element of elements) {
|
|
16375
|
+
if (shouldIgnoreElementFromSelection2?.(element)) {
|
|
16376
|
+
continue;
|
|
16377
|
+
}
|
|
16378
|
+
const groupId = element.groupIds.at(-1);
|
|
16379
|
+
if (groupId) {
|
|
16380
|
+
if (!groups[groupId]) {
|
|
16381
|
+
groups[groupId] = [];
|
|
16382
|
+
}
|
|
16383
|
+
groups[groupId].push(element);
|
|
16384
|
+
}
|
|
16385
|
+
const strokeWidth = element.strokeWidth;
|
|
16386
|
+
let labelAABB = null;
|
|
16387
|
+
let elementAABB = getElementBounds(element, elementsMap);
|
|
16388
|
+
elementAABB = [
|
|
16389
|
+
elementAABB[0] - strokeWidth / 2,
|
|
16390
|
+
elementAABB[1] - strokeWidth / 2,
|
|
16391
|
+
elementAABB[2] + strokeWidth / 2,
|
|
16392
|
+
elementAABB[3] + strokeWidth / 2
|
|
16393
|
+
];
|
|
16394
|
+
const boundTextElement = isArrowElement(element) && getBoundTextElement(element, elementsMap);
|
|
16395
|
+
if (boundTextElement) {
|
|
16396
|
+
const { x, y } = LinearElementEditor.getBoundTextElementPosition(
|
|
16397
|
+
element,
|
|
16398
|
+
boundTextElement,
|
|
16399
|
+
elementsMap
|
|
16400
|
+
);
|
|
16401
|
+
labelAABB = [
|
|
16402
|
+
x,
|
|
16403
|
+
y,
|
|
16404
|
+
x + boundTextElement.width,
|
|
16405
|
+
y + boundTextElement.height
|
|
16406
|
+
];
|
|
16407
|
+
}
|
|
16408
|
+
const associatedFrame = getContainingFrame(element, elementsMap);
|
|
16409
|
+
if (associatedFrame && elementOverlapsWithFrame(element, associatedFrame, elementsMap)) {
|
|
16410
|
+
const frameAABB = getElementBounds(associatedFrame, elementsMap);
|
|
16411
|
+
elementAABB = [
|
|
16412
|
+
Math.max(elementAABB[0], frameAABB[0]),
|
|
16413
|
+
Math.max(elementAABB[1], frameAABB[1]),
|
|
16414
|
+
Math.min(elementAABB[2], frameAABB[2]),
|
|
16415
|
+
Math.min(elementAABB[3], frameAABB[3])
|
|
16416
|
+
];
|
|
16417
|
+
labelAABB = labelAABB ? [
|
|
16418
|
+
Math.max(labelAABB[0], frameAABB[0]),
|
|
16419
|
+
Math.max(labelAABB[1], frameAABB[1]),
|
|
16420
|
+
Math.min(labelAABB[2], frameAABB[2]),
|
|
16421
|
+
Math.min(labelAABB[3], frameAABB[3])
|
|
16422
|
+
] : null;
|
|
16423
|
+
}
|
|
16424
|
+
const commonAABB2 = labelAABB ? [
|
|
16425
|
+
Math.min(labelAABB[0], elementAABB[0]),
|
|
16426
|
+
Math.min(labelAABB[1], elementAABB[1]),
|
|
16427
|
+
Math.max(labelAABB[2], elementAABB[2]),
|
|
16428
|
+
Math.max(labelAABB[3], elementAABB[3])
|
|
16429
|
+
] : elementAABB;
|
|
16430
|
+
if (boundsContainBounds(selectionBounds, commonAABB2)) {
|
|
16431
|
+
if (framesInSelection && isFrameLikeElement(element)) {
|
|
16432
|
+
framesInSelection.add(element.id);
|
|
16433
|
+
}
|
|
16434
|
+
elementsInSelection.add(element);
|
|
16435
|
+
continue;
|
|
16436
|
+
}
|
|
16437
|
+
if (type === "overlap" && labelAABB && doBoundsIntersect(selectionBounds, labelAABB)) {
|
|
16438
|
+
elementsInSelection.add(element);
|
|
16439
|
+
continue;
|
|
16440
|
+
}
|
|
16441
|
+
if (type === "overlap" && doBoundsIntersect(selectionBounds, elementAABB)) {
|
|
16442
|
+
let hasIntersection = false;
|
|
16443
|
+
if (isLinearElement(element) || isFreeDrawElement(element)) {
|
|
16444
|
+
const center = elementCenterPoint(element, elementsMap);
|
|
16445
|
+
hasIntersection = element.points.some((point) => {
|
|
16446
|
+
const rotatedPoint = pointRotateRads12(
|
|
16447
|
+
pointFrom13(element.x + point[0], element.y + point[1]),
|
|
16448
|
+
center,
|
|
16449
|
+
element.angle
|
|
16450
|
+
);
|
|
16451
|
+
return pointInsideBounds(rotatedPoint, selectionBounds);
|
|
16452
|
+
});
|
|
16453
|
+
} else {
|
|
16454
|
+
const nonRotatedElementBounds = getElementBounds(
|
|
16455
|
+
element,
|
|
16456
|
+
elementsMap,
|
|
16457
|
+
true
|
|
16458
|
+
);
|
|
16459
|
+
const center = elementCenterPoint(element, elementsMap);
|
|
16460
|
+
hasIntersection = [
|
|
16461
|
+
pointRotateRads12(
|
|
16462
|
+
pointFrom13(
|
|
16463
|
+
(nonRotatedElementBounds[0] + nonRotatedElementBounds[2]) / 2,
|
|
16464
|
+
nonRotatedElementBounds[1]
|
|
16465
|
+
),
|
|
16466
|
+
center,
|
|
16467
|
+
element.angle
|
|
16468
|
+
),
|
|
16469
|
+
pointRotateRads12(
|
|
16470
|
+
pointFrom13(
|
|
16471
|
+
nonRotatedElementBounds[2],
|
|
16472
|
+
(nonRotatedElementBounds[1] + nonRotatedElementBounds[3]) / 2
|
|
16473
|
+
),
|
|
16474
|
+
center,
|
|
16475
|
+
element.angle
|
|
16476
|
+
),
|
|
16477
|
+
pointRotateRads12(
|
|
16478
|
+
pointFrom13(
|
|
16479
|
+
(nonRotatedElementBounds[0] + nonRotatedElementBounds[2]) / 2,
|
|
16480
|
+
nonRotatedElementBounds[3]
|
|
16481
|
+
),
|
|
16482
|
+
center,
|
|
16483
|
+
element.angle
|
|
16484
|
+
),
|
|
16485
|
+
pointRotateRads12(
|
|
16486
|
+
pointFrom13(
|
|
16487
|
+
nonRotatedElementBounds[0],
|
|
16488
|
+
(nonRotatedElementBounds[1] + nonRotatedElementBounds[3]) / 2
|
|
16489
|
+
),
|
|
16490
|
+
center,
|
|
16491
|
+
element.angle
|
|
16492
|
+
)
|
|
16493
|
+
].some((point) => {
|
|
16494
|
+
return pointInsideBounds(
|
|
16495
|
+
pointRotateRads12(point, center, element.angle),
|
|
16496
|
+
selectionBounds
|
|
16497
|
+
);
|
|
16498
|
+
});
|
|
16499
|
+
}
|
|
16500
|
+
if (!hasIntersection) {
|
|
16501
|
+
hasIntersection = selectionEdges.some(
|
|
16502
|
+
(selectionEdge) => intersectElementWithLineSegment(
|
|
16503
|
+
element,
|
|
16504
|
+
elementsMap,
|
|
16505
|
+
selectionEdge,
|
|
16506
|
+
strokeWidth / 2,
|
|
16507
|
+
true
|
|
16508
|
+
// Stop at first hit for better performance
|
|
16509
|
+
).length > 0
|
|
16510
|
+
);
|
|
16511
|
+
}
|
|
16512
|
+
if (hasIntersection) {
|
|
16513
|
+
if (framesInSelection && isFrameLikeElement(element)) {
|
|
16514
|
+
framesInSelection.add(element.id);
|
|
16515
|
+
}
|
|
16516
|
+
elementsInSelection.add(element);
|
|
16517
|
+
continue;
|
|
16518
|
+
}
|
|
16519
|
+
}
|
|
16520
|
+
}
|
|
16521
|
+
if (framesInSelection) {
|
|
16522
|
+
elementsInSelection.forEach((element) => {
|
|
16523
|
+
if (element.frameId && framesInSelection.has(element.frameId)) {
|
|
16524
|
+
elementsInSelection.delete(element);
|
|
16525
|
+
}
|
|
16526
|
+
});
|
|
16527
|
+
}
|
|
16528
|
+
if (type === "overlap") {
|
|
16529
|
+
Array.from(elementsInSelection).forEach((element) => {
|
|
16530
|
+
const groupId = element.groupIds.at(-1);
|
|
16531
|
+
const group = groupId ? groups[groupId] : null;
|
|
16532
|
+
group?.forEach((groupElement) => elementsInSelection.add(groupElement));
|
|
16533
|
+
});
|
|
16534
|
+
} else if (type === "contain") {
|
|
16535
|
+
elementsInSelection.forEach((element) => {
|
|
16536
|
+
const groupId = element.groupIds.at(-1);
|
|
16537
|
+
const group = groupId ? groups[groupId] : null;
|
|
16538
|
+
if (group && !group.every((groupElement) => elementsInSelection.has(groupElement))) {
|
|
16539
|
+
elementsInSelection.delete(element);
|
|
16540
|
+
}
|
|
16541
|
+
});
|
|
16542
|
+
}
|
|
16543
|
+
return elements.filter((element) => elementsInSelection.has(element));
|
|
16544
|
+
};
|
|
16548
16545
|
var elementCenterPoint = (element, elementsMap, xOffset = 0, yOffset = 0) => {
|
|
16549
16546
|
if (isLinearElement(element) || isFreeDrawElement(element)) {
|
|
16550
16547
|
const [x1, y1, x2, y2] = getElementAbsoluteCoords2(element, elementsMap);
|
|
16551
|
-
const [x3, y3] =
|
|
16552
|
-
return
|
|
16548
|
+
const [x3, y3] = pointFrom13((x1 + x2) / 2, (y1 + y2) / 2);
|
|
16549
|
+
return pointFrom13(x3 + xOffset, y3 + yOffset);
|
|
16553
16550
|
}
|
|
16554
16551
|
const [x, y] = getCenterForBounds(getElementBounds(element, elementsMap));
|
|
16555
|
-
return
|
|
16552
|
+
return pointFrom13(x + xOffset, y + yOffset);
|
|
16556
16553
|
};
|
|
16557
16554
|
|
|
16558
16555
|
// src/sizeHelpers.ts
|
|
@@ -20936,7 +20933,7 @@ var embeddableURLValidator = (url, validateEmbeddable) => {
|
|
|
20936
20933
|
// src/flowchart.ts
|
|
20937
20934
|
init_define_import_meta_env();
|
|
20938
20935
|
import { KEYS as KEYS2, invariant as invariant11, toBrandedType as toBrandedType2 } from "@excalidraw/common";
|
|
20939
|
-
import { pointFrom as
|
|
20936
|
+
import { pointFrom as pointFrom14 } from "@excalidraw/math";
|
|
20940
20937
|
var VERTICAL_OFFSET = 100;
|
|
20941
20938
|
var HORIZONTAL_OFFSET = 100;
|
|
20942
20939
|
var getLinkDirectionFromKey = (key) => {
|
|
@@ -21216,7 +21213,7 @@ var createBindingArrow = (startBindingElement, endBindingElement, direction, app
|
|
|
21216
21213
|
strokeWidth: startBindingElement.strokeWidth,
|
|
21217
21214
|
opacity: startBindingElement.opacity,
|
|
21218
21215
|
roughness: startBindingElement.roughness,
|
|
21219
|
-
points: [
|
|
21216
|
+
points: [pointFrom14(0, 0), pointFrom14(endX, endY)],
|
|
21220
21217
|
elbowed: true
|
|
21221
21218
|
});
|
|
21222
21219
|
const elementsMap = scene.getNonDeletedElementsMap();
|
|
@@ -21404,7 +21401,7 @@ var isNodeInFlowchart = (element, elementsMap) => {
|
|
|
21404
21401
|
|
|
21405
21402
|
// src/arrows/focus.ts
|
|
21406
21403
|
init_define_import_meta_env();
|
|
21407
|
-
import { pointDistance as pointDistance8, pointFrom as
|
|
21404
|
+
import { pointDistance as pointDistance8, pointFrom as pointFrom15 } from "@excalidraw/math";
|
|
21408
21405
|
import { invariant as invariant12 } from "@excalidraw/common";
|
|
21409
21406
|
var isFocusPointVisible = (focusPoint, arrow, bindableElement, elementsMap, appState, startOrEnd, ignoreOverlap = false) => {
|
|
21410
21407
|
if (isElbowArrow(arrow) || !isBindingEnabled(appState) || arrow.points.length !== 2) {
|
|
@@ -21516,7 +21513,7 @@ var handleFocusPointDrag = (linearElementEditor, elementsMap, pointerCoords, sce
|
|
|
21516
21513
|
const isStartBinding = linearElementEditor.draggedFocusPointBinding === "start";
|
|
21517
21514
|
const binding = isStartBinding ? arrow.startBinding : arrow.endBinding;
|
|
21518
21515
|
const { x: offsetX, y: offsetY } = linearElementEditor.pointerOffset;
|
|
21519
|
-
const point =
|
|
21516
|
+
const point = pointFrom15(
|
|
21520
21517
|
pointerCoords.x - offsetX,
|
|
21521
21518
|
pointerCoords.y - offsetY
|
|
21522
21519
|
);
|
|
@@ -21599,7 +21596,7 @@ var handleFocusPointDrag = (linearElementEditor, elementsMap, pointerCoords, sce
|
|
|
21599
21596
|
}
|
|
21600
21597
|
};
|
|
21601
21598
|
var handleFocusPointPointerDown = (arrow, pointerDownState, elementsMap, appState) => {
|
|
21602
|
-
const pointerPos =
|
|
21599
|
+
const pointerPos = pointFrom15(
|
|
21603
21600
|
pointerDownState.origin.x,
|
|
21604
21601
|
pointerDownState.origin.y
|
|
21605
21602
|
);
|
|
@@ -21702,7 +21699,7 @@ var handleFocusPointPointerUp = (linearElementEditor, scene) => {
|
|
|
21702
21699
|
};
|
|
21703
21700
|
var handleFocusPointHover = (arrow, scenePointerX, scenePointerY, scene, appState) => {
|
|
21704
21701
|
const elementsMap = scene.getNonDeletedElementsMap();
|
|
21705
|
-
const pointerPos =
|
|
21702
|
+
const pointerPos = pointFrom15(scenePointerX, scenePointerY);
|
|
21706
21703
|
const hitThreshold = FOCUS_POINT_SIZE * 1.5 / appState.zoom.value;
|
|
21707
21704
|
if (arrow.startBinding?.elementId) {
|
|
21708
21705
|
const bindableElement = elementsMap.get(arrow.startBinding.elementId);
|
|
@@ -22008,8 +22005,8 @@ init_define_import_meta_env();
|
|
|
22008
22005
|
import {
|
|
22009
22006
|
pointCenter as pointCenter3,
|
|
22010
22007
|
normalizeRadians as normalizeRadians2,
|
|
22011
|
-
pointFrom as
|
|
22012
|
-
pointRotateRads as
|
|
22008
|
+
pointFrom as pointFrom16,
|
|
22009
|
+
pointRotateRads as pointRotateRads13
|
|
22013
22010
|
} from "@excalidraw/math";
|
|
22014
22011
|
import {
|
|
22015
22012
|
MIN_FONT_SIZE,
|
|
@@ -22197,7 +22194,7 @@ var resizeSingleTextElement = (origElement, element, scene, transformHandleType,
|
|
|
22197
22194
|
return;
|
|
22198
22195
|
}
|
|
22199
22196
|
if (transformHandleType.includes("n") || transformHandleType.includes("s")) {
|
|
22200
|
-
const previousOrigin =
|
|
22197
|
+
const previousOrigin = pointFrom16(origElement.x, origElement.y);
|
|
22201
22198
|
const newOrigin = getResizedOrigin(
|
|
22202
22199
|
previousOrigin,
|
|
22203
22200
|
origElement.width,
|
|
@@ -22238,7 +22235,7 @@ var resizeSingleTextElement = (origElement, element, scene, transformHandleType,
|
|
|
22238
22235
|
element.lineHeight
|
|
22239
22236
|
);
|
|
22240
22237
|
const newHeight = metrics2.height;
|
|
22241
|
-
const previousOrigin =
|
|
22238
|
+
const previousOrigin = pointFrom16(origElement.x, origElement.y);
|
|
22242
22239
|
const newOrigin = getResizedOrigin(
|
|
22243
22240
|
previousOrigin,
|
|
22244
22241
|
origElement.width,
|
|
@@ -22275,9 +22272,9 @@ var rotateMultipleElements = (originalElements, elements, scene, pointerX, point
|
|
|
22275
22272
|
const cx = (x1 + x2) / 2;
|
|
22276
22273
|
const cy = (y1 + y2) / 2;
|
|
22277
22274
|
const origAngle = originalElements.get(element.id)?.angle ?? element.angle;
|
|
22278
|
-
const [rotatedCX, rotatedCY] =
|
|
22279
|
-
|
|
22280
|
-
|
|
22275
|
+
const [rotatedCX, rotatedCY] = pointRotateRads13(
|
|
22276
|
+
pointFrom16(cx, cy),
|
|
22277
|
+
pointFrom16(centerX, centerY),
|
|
22281
22278
|
centerAngle + origAngle - element.angle
|
|
22282
22279
|
);
|
|
22283
22280
|
const updates = isElbowArrow(element) ? {
|
|
@@ -22326,44 +22323,44 @@ var getResizeOffsetXY = (transformHandleType, selectedElements, elementsMap, x,
|
|
|
22326
22323
|
const cx = (x1 + x2) / 2;
|
|
22327
22324
|
const cy = (y1 + y2) / 2;
|
|
22328
22325
|
const angle = selectedElements.length === 1 ? selectedElements[0].angle : 0;
|
|
22329
|
-
[x, y] =
|
|
22330
|
-
|
|
22331
|
-
|
|
22326
|
+
[x, y] = pointRotateRads13(
|
|
22327
|
+
pointFrom16(x, y),
|
|
22328
|
+
pointFrom16(cx, cy),
|
|
22332
22329
|
-angle
|
|
22333
22330
|
);
|
|
22334
22331
|
switch (transformHandleType) {
|
|
22335
22332
|
case "n":
|
|
22336
|
-
return
|
|
22337
|
-
|
|
22338
|
-
|
|
22333
|
+
return pointRotateRads13(
|
|
22334
|
+
pointFrom16(x - (x1 + x2) / 2, y - y1),
|
|
22335
|
+
pointFrom16(0, 0),
|
|
22339
22336
|
angle
|
|
22340
22337
|
);
|
|
22341
22338
|
case "s":
|
|
22342
|
-
return
|
|
22343
|
-
|
|
22344
|
-
|
|
22339
|
+
return pointRotateRads13(
|
|
22340
|
+
pointFrom16(x - (x1 + x2) / 2, y - y2),
|
|
22341
|
+
pointFrom16(0, 0),
|
|
22345
22342
|
angle
|
|
22346
22343
|
);
|
|
22347
22344
|
case "w":
|
|
22348
|
-
return
|
|
22349
|
-
|
|
22350
|
-
|
|
22345
|
+
return pointRotateRads13(
|
|
22346
|
+
pointFrom16(x - x1, y - (y1 + y2) / 2),
|
|
22347
|
+
pointFrom16(0, 0),
|
|
22351
22348
|
angle
|
|
22352
22349
|
);
|
|
22353
22350
|
case "e":
|
|
22354
|
-
return
|
|
22355
|
-
|
|
22356
|
-
|
|
22351
|
+
return pointRotateRads13(
|
|
22352
|
+
pointFrom16(x - x2, y - (y1 + y2) / 2),
|
|
22353
|
+
pointFrom16(0, 0),
|
|
22357
22354
|
angle
|
|
22358
22355
|
);
|
|
22359
22356
|
case "nw":
|
|
22360
|
-
return
|
|
22357
|
+
return pointRotateRads13(pointFrom16(x - x1, y - y1), pointFrom16(0, 0), angle);
|
|
22361
22358
|
case "ne":
|
|
22362
|
-
return
|
|
22359
|
+
return pointRotateRads13(pointFrom16(x - x2, y - y1), pointFrom16(0, 0), angle);
|
|
22363
22360
|
case "sw":
|
|
22364
|
-
return
|
|
22361
|
+
return pointRotateRads13(pointFrom16(x - x1, y - y2), pointFrom16(0, 0), angle);
|
|
22365
22362
|
case "se":
|
|
22366
|
-
return
|
|
22363
|
+
return pointRotateRads13(pointFrom16(x - x2, y - y2), pointFrom16(0, 0), angle);
|
|
22367
22364
|
default:
|
|
22368
22365
|
return [0, 0];
|
|
22369
22366
|
}
|
|
@@ -22526,10 +22523,10 @@ var resizeSingleElement = (nextWidth, nextHeight, latestElement, origElement, or
|
|
|
22526
22523
|
nextHeight,
|
|
22527
22524
|
true
|
|
22528
22525
|
);
|
|
22529
|
-
let previousOrigin =
|
|
22526
|
+
let previousOrigin = pointFrom16(origElement.x, origElement.y);
|
|
22530
22527
|
if (isLinearElement(origElement)) {
|
|
22531
22528
|
const [x1, y1] = getElementBounds(origElement, originalElementsMap);
|
|
22532
|
-
previousOrigin =
|
|
22529
|
+
previousOrigin = pointFrom16(x1, y1);
|
|
22533
22530
|
}
|
|
22534
22531
|
const newOrigin = getResizedOrigin(
|
|
22535
22532
|
previousOrigin,
|
|
@@ -22552,7 +22549,7 @@ var resizeSingleElement = (nextWidth, nextHeight, latestElement, origElement, or
|
|
|
22552
22549
|
newOrigin.x += scaledX;
|
|
22553
22550
|
newOrigin.y += scaledY;
|
|
22554
22551
|
rescaledPoints.points = rescaledPoints.points.map(
|
|
22555
|
-
(p) =>
|
|
22552
|
+
(p) => pointFrom16(p[0] - scaledX, p[1] - scaledY)
|
|
22556
22553
|
);
|
|
22557
22554
|
}
|
|
22558
22555
|
if (nextWidth < 0) {
|
|
@@ -22628,11 +22625,11 @@ var getNextSingleWidthAndHeightFromPointer = (latestElement, origElement, handle
|
|
|
22628
22625
|
origElement.height,
|
|
22629
22626
|
true
|
|
22630
22627
|
);
|
|
22631
|
-
const startTopLeft =
|
|
22632
|
-
const startBottomRight =
|
|
22628
|
+
const startTopLeft = pointFrom16(x1, y1);
|
|
22629
|
+
const startBottomRight = pointFrom16(x2, y2);
|
|
22633
22630
|
const startCenter = pointCenter3(startTopLeft, startBottomRight);
|
|
22634
|
-
const rotatedPointer =
|
|
22635
|
-
|
|
22631
|
+
const rotatedPointer = pointRotateRads13(
|
|
22632
|
+
pointFrom16(pointerX, pointerY),
|
|
22636
22633
|
startCenter,
|
|
22637
22634
|
-origElement.angle
|
|
22638
22635
|
);
|
|
@@ -23002,9 +22999,9 @@ var resizeMultipleElements = (selectedElements, elementsMap, handleDirection, sc
|
|
|
23002
22999
|
// src/resizeTest.ts
|
|
23003
23000
|
init_define_import_meta_env();
|
|
23004
23001
|
import {
|
|
23005
|
-
pointFrom as
|
|
23002
|
+
pointFrom as pointFrom18,
|
|
23006
23003
|
pointOnLineSegment,
|
|
23007
|
-
pointRotateRads as
|
|
23004
|
+
pointRotateRads as pointRotateRads15
|
|
23008
23005
|
} from "@excalidraw/math";
|
|
23009
23006
|
import {
|
|
23010
23007
|
SIDE_RESIZING_THRESHOLD
|
|
@@ -23015,7 +23012,7 @@ init_define_import_meta_env();
|
|
|
23015
23012
|
import {
|
|
23016
23013
|
DEFAULT_TRANSFORM_HANDLE_SPACING
|
|
23017
23014
|
} from "@excalidraw/common";
|
|
23018
|
-
import { pointFrom as
|
|
23015
|
+
import { pointFrom as pointFrom17, pointRotateRads as pointRotateRads14 } from "@excalidraw/math";
|
|
23019
23016
|
var transformHandleSizes = {
|
|
23020
23017
|
mouse: 8,
|
|
23021
23018
|
pen: 16,
|
|
@@ -23056,9 +23053,9 @@ var OMIT_SIDES_FOR_LINE_BACKSLASH = {
|
|
|
23056
23053
|
w: true
|
|
23057
23054
|
};
|
|
23058
23055
|
var generateTransformHandle = (x, y, width, height, cx, cy, angle) => {
|
|
23059
|
-
const [xx, yy] =
|
|
23060
|
-
|
|
23061
|
-
|
|
23056
|
+
const [xx, yy] = pointRotateRads14(
|
|
23057
|
+
pointFrom17(x + width / 2, y + height / 2),
|
|
23058
|
+
pointFrom17(cx, cy),
|
|
23062
23059
|
angle
|
|
23063
23060
|
);
|
|
23064
23061
|
return [xx - width / 2, yy - height / 2, width, height];
|
|
@@ -23272,14 +23269,14 @@ var resizeTest = (element, elementsMap, appState, x, y, zoom, pointerType, edito
|
|
|
23272
23269
|
const SPACING = isImageElement(element) ? 0 : SIDE_RESIZING_THRESHOLD / zoom.value;
|
|
23273
23270
|
const ZOOMED_SIDE_RESIZING_THRESHOLD = SIDE_RESIZING_THRESHOLD / zoom.value;
|
|
23274
23271
|
const sides = getSelectionBorders(
|
|
23275
|
-
|
|
23276
|
-
|
|
23277
|
-
|
|
23272
|
+
pointFrom18(x1 - SPACING, y1 - SPACING),
|
|
23273
|
+
pointFrom18(x2 + SPACING, y2 + SPACING),
|
|
23274
|
+
pointFrom18(cx, cy),
|
|
23278
23275
|
element.angle
|
|
23279
23276
|
);
|
|
23280
23277
|
for (const [dir, side] of Object.entries(sides)) {
|
|
23281
23278
|
if (pointOnLineSegment(
|
|
23282
|
-
|
|
23279
|
+
pointFrom18(x, y),
|
|
23283
23280
|
side,
|
|
23284
23281
|
ZOOMED_SIDE_RESIZING_THRESHOLD
|
|
23285
23282
|
)) {
|
|
@@ -23328,14 +23325,14 @@ var getTransformHandleTypeFromCoords = ([x1, y1, x2, y2], scenePointerX, scenePo
|
|
|
23328
23325
|
const cy = (y1 + y2) / 2;
|
|
23329
23326
|
const SPACING = SIDE_RESIZING_THRESHOLD / zoom.value;
|
|
23330
23327
|
const sides = getSelectionBorders(
|
|
23331
|
-
|
|
23332
|
-
|
|
23333
|
-
|
|
23328
|
+
pointFrom18(x1 - SPACING, y1 - SPACING),
|
|
23329
|
+
pointFrom18(x2 + SPACING, y2 + SPACING),
|
|
23330
|
+
pointFrom18(cx, cy),
|
|
23334
23331
|
0
|
|
23335
23332
|
);
|
|
23336
23333
|
for (const [dir, side] of Object.entries(sides)) {
|
|
23337
23334
|
if (pointOnLineSegment(
|
|
23338
|
-
|
|
23335
|
+
pointFrom18(scenePointerX, scenePointerY),
|
|
23339
23336
|
side,
|
|
23340
23337
|
SPACING
|
|
23341
23338
|
)) {
|
|
@@ -23392,10 +23389,10 @@ var getCursorForResizingElement = (resizingElement) => {
|
|
|
23392
23389
|
return cursor ? `${cursor}-resize` : "";
|
|
23393
23390
|
};
|
|
23394
23391
|
var getSelectionBorders = ([x1, y1], [x2, y2], center, angle) => {
|
|
23395
|
-
const topLeft =
|
|
23396
|
-
const topRight =
|
|
23397
|
-
const bottomLeft =
|
|
23398
|
-
const bottomRight =
|
|
23392
|
+
const topLeft = pointRotateRads15(pointFrom18(x1, y1), center, angle);
|
|
23393
|
+
const topRight = pointRotateRads15(pointFrom18(x2, y1), center, angle);
|
|
23394
|
+
const bottomLeft = pointRotateRads15(pointFrom18(x1, y2), center, angle);
|
|
23395
|
+
const bottomRight = pointRotateRads15(pointFrom18(x2, y2), center, angle);
|
|
23399
23396
|
return {
|
|
23400
23397
|
n: [topLeft, topRight],
|
|
23401
23398
|
e: [topRight, bottomRight],
|
|
@@ -25999,7 +25996,7 @@ var showSelectedShapeActions = (appState, elements) => Boolean(
|
|
|
25999
25996
|
|
|
26000
25997
|
// src/transform.ts
|
|
26001
25998
|
init_define_import_meta_env();
|
|
26002
|
-
import { pointFrom as
|
|
25999
|
+
import { pointFrom as pointFrom19 } from "@excalidraw/math";
|
|
26003
26000
|
import {
|
|
26004
26001
|
DEFAULT_FONT_FAMILY as DEFAULT_FONT_FAMILY3,
|
|
26005
26002
|
DEFAULT_FONT_SIZE as DEFAULT_FONT_SIZE4,
|
|
@@ -26281,7 +26278,7 @@ var convertToExcalidrawElements = (elementsSkeleton, opts) => {
|
|
|
26281
26278
|
excalidrawElement = newLinearElement({
|
|
26282
26279
|
width,
|
|
26283
26280
|
height,
|
|
26284
|
-
points: [
|
|
26281
|
+
points: [pointFrom19(0, 0), pointFrom19(width, height)],
|
|
26285
26282
|
...element
|
|
26286
26283
|
});
|
|
26287
26284
|
break;
|
|
@@ -26293,7 +26290,7 @@ var convertToExcalidrawElements = (elementsSkeleton, opts) => {
|
|
|
26293
26290
|
width,
|
|
26294
26291
|
height,
|
|
26295
26292
|
endArrowhead: "arrow",
|
|
26296
|
-
points: [
|
|
26293
|
+
points: [pointFrom19(0, 0), pointFrom19(width, height)],
|
|
26297
26294
|
...element,
|
|
26298
26295
|
type: "arrow"
|
|
26299
26296
|
});
|
|
@@ -26673,6 +26670,7 @@ export {
|
|
|
26673
26670
|
elementWithCanvasCache,
|
|
26674
26671
|
elementsAreInFrameBounds,
|
|
26675
26672
|
elementsAreInSameGroup,
|
|
26673
|
+
elementsOverlappingBBox,
|
|
26676
26674
|
embeddableURLValidator,
|
|
26677
26675
|
excludeElementsInFramesFromSelection,
|
|
26678
26676
|
filterElementsEligibleAsFrameChildren,
|