defined split array
This commit is contained in:
parent
14bca119f7
commit
c2867c9a93
@ -285,6 +285,7 @@ const restoreElement = (
|
|||||||
points,
|
points,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
|
segmentSplitIndices: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1472,6 +1472,28 @@ export class LinearElementEditor {
|
|||||||
|
|
||||||
return coords;
|
return coords;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static toggleSegmentSplitAtIndex(
|
||||||
|
element: NonDeleted<ExcalidrawLinearElement>,
|
||||||
|
appState: AppState,
|
||||||
|
index: number,
|
||||||
|
) {
|
||||||
|
let found = false;
|
||||||
|
const splitIndices = (element.segmentSplitIndices || []).filter((idx) => {
|
||||||
|
if (idx === index) {
|
||||||
|
found = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
if (!found) {
|
||||||
|
splitIndices.push(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
mutateElement(element, {
|
||||||
|
segmentSplitIndices: splitIndices,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalizeSelectedPoints = (
|
const normalizeSelectedPoints = (
|
||||||
|
@ -374,6 +374,7 @@ export const newLinearElement = (
|
|||||||
endBinding: null,
|
endBinding: null,
|
||||||
startArrowhead: opts.startArrowhead || null,
|
startArrowhead: opts.startArrowhead || null,
|
||||||
endArrowhead: opts.endArrowhead || null,
|
endArrowhead: opts.endArrowhead || null,
|
||||||
|
segmentSplitIndices: [],
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -195,6 +195,7 @@ export type ExcalidrawLinearElement = _ExcalidrawElementBase &
|
|||||||
Readonly<{
|
Readonly<{
|
||||||
type: "line" | "arrow";
|
type: "line" | "arrow";
|
||||||
points: readonly Point[];
|
points: readonly Point[];
|
||||||
|
segmentSplitIndices: readonly number[] | null;
|
||||||
lastCommittedPoint: Point | null;
|
lastCommittedPoint: Point | null;
|
||||||
startBinding: PointBinding | null;
|
startBinding: PointBinding | null;
|
||||||
endBinding: PointBinding | null;
|
endBinding: PointBinding | null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user