diff --git a/packages/element/src/Shape.ts b/packages/element/src/Shape.ts index 4def419574..583c3f4afb 100644 --- a/packages/element/src/Shape.ts +++ b/packages/element/src/Shape.ts @@ -437,26 +437,12 @@ export const _generateElementShape = ( : [pointFrom(0, 0)]; if (isElbowArrow(element)) { - // NOTE (mtolmacs): Temporary fix for extremely big arrow shapes - if ( - !points.every( - (point) => Math.abs(point[0]) <= 1e6 && Math.abs(point[1]) <= 1e6, - ) - ) { - console.error( - `Elbow arrow with extreme point positions detected. Arrow not rendered.`, - element.id, - JSON.stringify(points), - ); - shape = []; - } else { - shape = [ - generator.path( - generateElbowArrowShape(points, 16), - generateRoughOptions(element, true), - ), - ]; - } + shape = [ + generator.path( + generateElbowArrowShape(points, 16), + generateRoughOptions(element, true), + ), + ]; } else if (!element.roundness) { // curve is always the first element // this simplifies finding the curve for an element diff --git a/packages/element/src/elbowArrow.ts b/packages/element/src/elbowArrow.ts index a028403b3d..eaf8f108bb 100644 --- a/packages/element/src/elbowArrow.ts +++ b/packages/element/src/elbowArrow.ts @@ -20,6 +20,7 @@ import { tupleToCoors, getSizeFromPoints, isDevEnv, + isTestEnv, } from "@excalidraw/common"; import type { AppState } from "@excalidraw/excalidraw/types"; @@ -875,8 +876,6 @@ const handleEndpointDrag = ( ); }; -const MAX_POS = 1e6; - /** * */ @@ -897,51 +896,7 @@ export const updateElbowArrowPoints = ( return { points: updates.points ?? arrow.points }; } - // NOTE (mtolmacs): This is a temporary check to ensure that the incoming elbow - // arrow size is valid. This check will be removed once the issue is identified - if ( - arrow.x < -MAX_POS || - arrow.x > MAX_POS || - arrow.y < -MAX_POS || - arrow.y > MAX_POS || - arrow.x + (updates?.points?.[updates?.points?.length - 1]?.[0] ?? 0) < - -MAX_POS || - arrow.x + (updates?.points?.[updates?.points?.length - 1]?.[0] ?? 0) > - MAX_POS || - arrow.y + (updates?.points?.[updates?.points?.length - 1]?.[1] ?? 0) < - -MAX_POS || - arrow.y + (updates?.points?.[updates?.points?.length - 1]?.[1] ?? 0) > - MAX_POS || - arrow.x + (arrow?.points?.[arrow?.points?.length - 1]?.[0] ?? 0) < - -MAX_POS || - arrow.x + (arrow?.points?.[arrow?.points?.length - 1]?.[0] ?? 0) > - MAX_POS || - arrow.y + (arrow?.points?.[arrow?.points?.length - 1]?.[1] ?? 0) < - -MAX_POS || - arrow.y + (arrow?.points?.[arrow?.points?.length - 1]?.[1] ?? 0) > MAX_POS - ) { - console.error( - "Elbow arrow (or update) is outside reasonable bounds (> 1e6)", - { - arrow, - updates, - }, - ); - } - // @ts-ignore See above note - arrow.x = clamp(arrow.x, -MAX_POS, MAX_POS); - // @ts-ignore See above note - arrow.y = clamp(arrow.y, -MAX_POS, MAX_POS); - if (updates.points) { - updates.points = updates.points.map(([x, y]) => - pointFrom( - clamp(x, -MAX_POS, MAX_POS), - clamp(y, -MAX_POS, MAX_POS), - ), - ); - } - - if (!import.meta.env.PROD) { + if (isDevEnv() || isTestEnv()) { invariant( !updates.points || updates.points.length >= 2, "Updated point array length must match the arrow point length, contain " + @@ -2120,29 +2075,6 @@ const normalizeArrowElementUpdate = ( ), ); - // NOTE (mtolmacs): This is a temporary check to see if the normalization - // creates an overly large arrow. This should be removed once we have an answer. - if ( - offsetX < -MAX_POS || - offsetX > MAX_POS || - offsetY < -MAX_POS || - offsetY > MAX_POS || - offsetX + points[points.length - 1][0] < -MAX_POS || - offsetY + points[points.length - 1][0] > MAX_POS || - offsetX + points[points.length - 1][1] < -MAX_POS || - offsetY + points[points.length - 1][1] > MAX_POS - ) { - console.error( - "Elbow arrow normalization is outside reasonable bounds (> 1e6)", - { - x: offsetX, - y: offsetY, - points, - ...getSizeFromPoints(points), - }, - ); - } - points = points.map(([x, y]) => pointFrom(clamp(x, -1e6, 1e6), clamp(y, -1e6, 1e6)), ); diff --git a/packages/excalidraw/data/restore.ts b/packages/excalidraw/data/restore.ts index 4f050c922e..c7e143ee87 100644 --- a/packages/excalidraw/data/restore.ts +++ b/packages/excalidraw/data/restore.ts @@ -20,10 +20,6 @@ import { } from "@excalidraw/common"; import { getNonDeletedElements } from "@excalidraw/element"; import { normalizeFixedPoint } from "@excalidraw/element/binding"; -import { - updateElbowArrowPoints, - validateElbowPoints, -} from "@excalidraw/element/elbowArrow"; import { LinearElementEditor } from "@excalidraw/element/linearElementEditor"; import { bumpVersion } from "@excalidraw/element/mutateElement"; import { getContainerElement } from "@excalidraw/element/textElement"; @@ -57,7 +53,6 @@ import type { ExcalidrawTextElement, FixedPointBinding, FontFamilyValues, - NonDeletedSceneElementsMap, OrderedExcalidrawElement, PointBinding, StrokeRoundness, @@ -585,73 +580,7 @@ export const restoreElements = ( } } - // NOTE (mtolmacs): Temporary fix for extremely large arrows - // Need to iterate again so we have attached text nodes in elementsMap - return restoredElements.map((element) => { - if ( - isElbowArrow(element) && - element.startBinding == null && - element.endBinding == null && - !validateElbowPoints(element.points) - ) { - return { - ...element, - ...updateElbowArrowPoints( - element, - restoredElementsMap as NonDeletedSceneElementsMap, - { - points: [ - pointFrom(0, 0), - element.points[element.points.length - 1], - ], - }, - ), - index: element.index, - }; - } - - if ( - isElbowArrow(element) && - element.startBinding && - element.endBinding && - element.startBinding.elementId === element.endBinding.elementId && - element.points.length > 1 && - element.points.some( - ([rx, ry]) => Math.abs(rx) > 1e6 || Math.abs(ry) > 1e6, - ) - ) { - console.error("Fixing self-bound elbow arrow", element.id); - const boundElement = restoredElementsMap.get( - element.startBinding.elementId, - ); - if (!boundElement) { - console.error( - "Bound element not found", - element.startBinding.elementId, - ); - return element; - } - - return { - ...element, - x: boundElement.x + boundElement.width / 2, - y: boundElement.y - 5, - width: boundElement.width, - height: boundElement.height, - points: [ - pointFrom(0, 0), - pointFrom(0, -10), - pointFrom(boundElement.width / 2 + 5, -10), - pointFrom( - boundElement.width / 2 + 5, - boundElement.height / 2 + 5, - ), - ], - }; - } - - return element; - }); + return restoredElements; }; const coalesceAppStateValue = < diff --git a/packages/utils/src/shape.ts b/packages/utils/src/shape.ts index b750c232e7..9034d4a825 100644 --- a/packages/utils/src/shape.ts +++ b/packages/utils/src/shape.ts @@ -195,11 +195,6 @@ export const getEllipseShape = ( }; export const getCurvePathOps = (shape: Drawable): Op[] => { - // NOTE (mtolmacs): Temporary fix for extremely large elements - if (!shape) { - return []; - } - for (const set of shape.sets) { if (set.type === "path") { return set.ops;