mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
fix: repair invalid binding on restore & fix type check (#8133)
This commit is contained in:
parent
d2f67e619f
commit
4dc4590f24
3 changed files with 24 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
||||||
import type {
|
import type {
|
||||||
ExcalidrawElement,
|
ExcalidrawElement,
|
||||||
ExcalidrawElementType,
|
ExcalidrawElementType,
|
||||||
|
ExcalidrawLinearElement,
|
||||||
ExcalidrawSelectionElement,
|
ExcalidrawSelectionElement,
|
||||||
ExcalidrawTextElement,
|
ExcalidrawTextElement,
|
||||||
FontFamilyValues,
|
FontFamilyValues,
|
||||||
|
@ -21,7 +22,11 @@ import {
|
||||||
isInvisiblySmallElement,
|
isInvisiblySmallElement,
|
||||||
refreshTextDimensions,
|
refreshTextDimensions,
|
||||||
} from "../element";
|
} from "../element";
|
||||||
import { isTextElement, isUsingAdaptiveRadius } from "../element/typeChecks";
|
import {
|
||||||
|
isLinearElement,
|
||||||
|
isTextElement,
|
||||||
|
isUsingAdaptiveRadius,
|
||||||
|
} from "../element/typeChecks";
|
||||||
import { randomId } from "../random";
|
import { randomId } from "../random";
|
||||||
import {
|
import {
|
||||||
DEFAULT_FONT_FAMILY,
|
DEFAULT_FONT_FAMILY,
|
||||||
|
@ -460,6 +465,21 @@ export const restoreElements = (
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isLinearElement(element)) {
|
||||||
|
if (
|
||||||
|
element.startBinding &&
|
||||||
|
!restoredElementsMap.has(element.startBinding.elementId)
|
||||||
|
) {
|
||||||
|
(element as Mutable<ExcalidrawLinearElement>).startBinding = null;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
element.endBinding &&
|
||||||
|
!restoredElementsMap.has(element.endBinding.elementId)
|
||||||
|
) {
|
||||||
|
(element as Mutable<ExcalidrawLinearElement>).endBinding = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return restoredElements;
|
return restoredElements;
|
||||||
|
|
|
@ -188,10 +188,8 @@ const getOriginalBindingIfStillCloseOfLinearElementEdge = (
|
||||||
? linearElement.startBinding?.elementId
|
? linearElement.startBinding?.elementId
|
||||||
: linearElement.endBinding?.elementId;
|
: linearElement.endBinding?.elementId;
|
||||||
if (elementId) {
|
if (elementId) {
|
||||||
const element = elementsMap.get(
|
const element = elementsMap.get(elementId);
|
||||||
elementId,
|
if (isBindableElement(element) && bindingBorderTest(element, coors, app)) {
|
||||||
) as NonDeleted<ExcalidrawBindableElement>;
|
|
||||||
if (bindingBorderTest(element, coors, app)) {
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ export const isBindingElementType = (
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isBindableElement = (
|
export const isBindableElement = (
|
||||||
element: ExcalidrawElement | null,
|
element: ExcalidrawElement | null | undefined,
|
||||||
includeLocked = true,
|
includeLocked = true,
|
||||||
): element is ExcalidrawBindableElement => {
|
): element is ExcalidrawBindableElement => {
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Add table
Reference in a new issue