mirror of
https://github.com/excalidraw/excalidraw
synced 2025-07-25 13:58:22 +08:00
feat: do not break polygon on point delete inside line editor (#9580)
* feat: do not break polygon on point delete inside line editor * fix: polygon point highlighting when selected point == 0
This commit is contained in:
@ -1290,24 +1290,19 @@ export class LinearElementEditor {
|
||||
app.state.editingLinearElement?.lastUncommittedPoint ===
|
||||
element.points[element.points.length - 1];
|
||||
|
||||
const isPolygon = isLineElement(element) && element.polygon;
|
||||
|
||||
// break polygon if deleting start/end point
|
||||
if (
|
||||
isPolygon &&
|
||||
// don't disable polygon if cleaning up uncommitted point
|
||||
!isUncommittedPoint &&
|
||||
(pointIndices.includes(0) ||
|
||||
pointIndices.includes(element.points.length - 1))
|
||||
) {
|
||||
app.scene.mutateElement(element, { polygon: false });
|
||||
}
|
||||
|
||||
const nextPoints = element.points.filter((_, idx) => {
|
||||
return !pointIndices.includes(idx);
|
||||
});
|
||||
|
||||
if (isUncommittedPoint && isLineElement(element) && element.polygon) {
|
||||
const isPolygon = isLineElement(element) && element.polygon;
|
||||
|
||||
// keep polygon intact if deleting start/end point or uncommitted point
|
||||
if (
|
||||
isPolygon &&
|
||||
(isUncommittedPoint ||
|
||||
pointIndices.includes(0) ||
|
||||
pointIndices.includes(element.points.length - 1))
|
||||
) {
|
||||
nextPoints[0] = pointFrom(
|
||||
nextPoints[nextPoints.length - 1][0],
|
||||
nextPoints[nextPoints.length - 1][1],
|
||||
|
Reference in New Issue
Block a user