feat: ability to debug the state of fractional indices (#8235)

This commit is contained in:
Marcel Mraz 2024-07-30 10:03:27 +02:00 committed by GitHub
parent 7b36de0476
commit d0a380758e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 122 additions and 10 deletions

View file

@ -274,9 +274,17 @@ class Scene {
: Array.from(nextElements.values());
const nextFrameLikes: ExcalidrawFrameLikeElement[] = [];
if (import.meta.env.DEV || import.meta.env.MODE === ENV.TEST) {
// throw on invalid indices in test / dev to potentially detect cases were we forgot to sync moved elements
validateFractionalIndices(_nextElements.map((x) => x.index));
if (
import.meta.env.DEV ||
import.meta.env.MODE === ENV.TEST ||
window?.DEBUG_FRACTIONAL_INDICES
) {
validateFractionalIndices(_nextElements, {
// validate everything
includeBoundTextValidation: true,
// throw only in dev & test, to remain functional on `DEBUG_FRACTIONAL_INDICES`
shouldThrow: import.meta.env.DEV || import.meta.env.MODE === ENV.TEST,
});
}
this.elements = syncInvalidIndices(_nextElements);