Merge remote-tracking branch 'origin/release' into danieljgeiger-mathjax-maint-stage

This commit is contained in:
Daniel J. Geiger 2024-07-26 20:02:06 -05:00
commit 629cd307fd
205 changed files with 10358 additions and 2742 deletions

View file

@ -1,6 +1,7 @@
import type {
ExcalidrawElement,
ExcalidrawElementType,
ExcalidrawLinearElement,
ExcalidrawSelectionElement,
ExcalidrawTextElement,
FontFamilyValues,
@ -21,7 +22,12 @@ import {
isInvisiblySmallElement,
refreshTextDimensions,
} from "../element";
import { isTextElement, isUsingAdaptiveRadius } from "../element/typeChecks";
import {
isArrowElement,
isLinearElement,
isTextElement,
isUsingAdaptiveRadius,
} from "../element/typeChecks";
import { randomId } from "../random";
import {
DEFAULT_FONT_FAMILY,
@ -38,13 +44,11 @@ import { bumpVersion } from "../element/mutateElement";
import { getUpdatedTimestamp, updateActiveTool } from "../utils";
import { arrayToMap } from "../utils";
import type { MarkOptional, Mutable } from "../utility-types";
import {
detectLineHeight,
getContainerElement,
getDefaultLineHeight,
} from "../element/textElement";
import { detectLineHeight, getContainerElement } from "../element/textElement";
import { normalizeLink } from "./url";
import { syncInvalidIndices } from "../fractionalIndex";
import { getSizeFromPoints } from "../points";
import { getLineHeight } from "../fonts";
type RestoredAppState = Omit<
AppState,
@ -203,7 +207,7 @@ const restoreElement = (
detectLineHeight(element)
: // no element height likely means programmatic use, so default
// to a fixed line height
getDefaultLineHeight(element.fontFamily));
getLineHeight(element.fontFamily));
element = restoreElementWithProperties(element, {
fontSize,
fontFamily,
@ -212,7 +216,7 @@ const restoreElement = (
verticalAlign: element.verticalAlign || DEFAULT_VERTICAL_ALIGN,
containerId: element.containerId ?? null,
originalText: element.originalText || text,
autoResize: element.autoResize ?? true,
lineHeight,
});
@ -274,6 +278,7 @@ const restoreElement = (
points,
x,
y,
...getSizeFromPoints(points),
});
}
@ -462,6 +467,23 @@ export const restoreElements = (
),
);
}
if (isLinearElement(element)) {
if (
element.startBinding &&
(!restoredElementsMap.has(element.startBinding.elementId) ||
!isArrowElement(element))
) {
(element as Mutable<ExcalidrawLinearElement>).startBinding = null;
}
if (
element.endBinding &&
(!restoredElementsMap.has(element.endBinding.elementId) ||
!isArrowElement(element))
) {
(element as Mutable<ExcalidrawLinearElement>).endBinding = null;
}
}
}
return restoredElements;