revert: remove bound-arrows from frames (#7190)

This commit is contained in:
David Luzar 2023-10-25 10:39:19 +02:00 committed by GitHub
parent 71ad3c5356
commit 104f64f1dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 81 deletions

View file

@ -43,7 +43,6 @@ import {
measureBaseline,
} from "../element/textElement";
import { normalizeLink } from "./url";
import { isValidFrameChild } from "../frame";
type RestoredAppState = Omit<
AppState,
@ -397,7 +396,7 @@ const repairBoundElement = (
};
/**
* resets `frameId` if no longer applicable.
* Remove an element's frameId if its containing frame is non-existent
*
* NOTE mutates elements.
*/
@ -405,16 +404,12 @@ const repairFrameMembership = (
element: Mutable<ExcalidrawElement>,
elementsMap: Map<string, Mutable<ExcalidrawElement>>,
) => {
if (!element.frameId) {
return;
}
if (element.frameId) {
const containingFrame = elementsMap.get(element.frameId);
if (
!isValidFrameChild(element) ||
// target frame not exists
!elementsMap.get(element.frameId)
) {
element.frameId = null;
if (!containingFrame) {
element.frameId = null;
}
}
};
@ -458,8 +453,6 @@ export const restoreElements = (
// repair binding. Mutates elements.
const restoredElementsMap = arrayToMap(restoredElements);
for (const element of restoredElements) {
// repair frame membership *after* bindings we do in restoreElement()
// since we rely on bindings to be correct
if (element.frameId) {
repairFrameMembership(element, restoredElementsMap);
}