diff --git a/packages/element/tests/__snapshots__/linearElementEditor.test.tsx.snap b/packages/element/tests/__snapshots__/linearElementEditor.test.tsx.snap index 35e940d32e..67639e5bde 100644 --- a/packages/element/tests/__snapshots__/linearElementEditor.test.tsx.snap +++ b/packages/element/tests/__snapshots__/linearElementEditor.test.tsx.snap @@ -44,3 +44,14 @@ exports[`Test Linear Elements > Test bound text element > should resize and posi "Online whiteboard collaboration made easy" `; + +exports[`Test Linear Elements > Test bound text element > should wrap the bound text when arrow bound container moves 1`] = ` +"Online whiteboard +collaboration made easy" +`; + +exports[`Test Linear Elements > Test bound text element > should wrap the bound text when arrow bound container moves 2`] = ` +"Online whiteboard +collaboration made +easy" +`; diff --git a/packages/element/tests/elbowArrow.test.tsx b/packages/element/tests/elbowArrow.test.tsx index 7eece3d2b3..8b2f4c8b0e 100644 --- a/packages/element/tests/elbowArrow.test.tsx +++ b/packages/element/tests/elbowArrow.test.tsx @@ -197,11 +197,11 @@ describe("elbow arrow routing", () => { points: [pointFrom(0, 0), pointFrom(90, 200)], }); - expect(arrow.points).toEqual([ + expect(arrow.points).toCloselyEqualPoints([ [0, 0], - [44, 0], - [44, 200], - [88, 200], + [39, 0], + [39, 200], + [78, 200], ]); }); }); @@ -251,11 +251,11 @@ describe("elbow arrow ui", () => { expect(arrow.type).toBe("arrow"); expect(arrow.elbowed).toBe(true); - expect(arrow.points).toEqual([ + expect(arrow.points).toCloselyEqualPoints([ [0, 0], - [44, 0], - [44, 200], - [88, 200], + [39, 0], + [39, 200], + [78, 200], ]); }); @@ -295,11 +295,11 @@ describe("elbow arrow ui", () => { expect(arrow.points.map((point) => point.map(Math.round))).toEqual([ [0, 0], - [36, 0], - [36, 90], - [28, 90], - [28, 164], - [101, 164], + [31, 0], + [31, 90], + [23, 90], + [23, 161], + [92, 161], ]); }); @@ -351,11 +351,11 @@ describe("elbow arrow ui", () => { expect(duplicatedArrow.id).not.toBe(originalArrowId); expect(duplicatedArrow.type).toBe("arrow"); expect(duplicatedArrow.elbowed).toBe(true); - expect(duplicatedArrow.points).toEqual([ + expect(duplicatedArrow.points).toCloselyEqualPoints([ [0, 0], - [44, 0], - [44, 200], - [88, 200], + [39, 0], + [39, 200], + [78, 200], ]); expect(arrow.startBinding).not.toBe(null); expect(arrow.endBinding).not.toBe(null); @@ -405,11 +405,11 @@ describe("elbow arrow ui", () => { expect(duplicatedArrow.id).not.toBe(originalArrowId); expect(duplicatedArrow.type).toBe("arrow"); expect(duplicatedArrow.elbowed).toBe(true); - expect(duplicatedArrow.points).toEqual([ + expect(duplicatedArrow.points).toCloselyEqualPoints([ [0, 0], [0, 100], - [88, 100], - [88, 200], + [78, 100], + [78, 200], ]); }); }); diff --git a/packages/element/tests/linearElementEditor.test.tsx b/packages/element/tests/linearElementEditor.test.tsx index be5ff26d95..5759c591dd 100644 --- a/packages/element/tests/linearElementEditor.test.tsx +++ b/packages/element/tests/linearElementEditor.test.tsx @@ -1317,7 +1317,7 @@ describe("Test Linear Elements", () => { const textElement = h.elements[2] as ExcalidrawTextElementWithContainer; expect(arrow.endBinding?.elementId).toBe(rect.id); - expect(arrow.width).toBeCloseTo(404); + expect(arrow.width).toBeCloseTo(399); expect(rect.x).toBe(400); expect(rect.y).toBe(0); expect( @@ -1336,7 +1336,7 @@ describe("Test Linear Elements", () => { mouse.downAt(rect.x, rect.y); mouse.moveTo(200, 0); mouse.upAt(200, 0); - expect(arrow.width).toBeCloseTo(204); + expect(arrow.width).toBeCloseTo(199); expect(rect.x).toBe(200); expect(rect.y).toBe(0); expect(handleBindTextResizeSpy).toHaveBeenCalledWith( diff --git a/packages/element/tests/resize.test.tsx b/packages/element/tests/resize.test.tsx index d3146e9fec..7582a5e3c2 100644 --- a/packages/element/tests/resize.test.tsx +++ b/packages/element/tests/resize.test.tsx @@ -510,12 +510,12 @@ describe("arrow element", () => { h.state, )[0] as ExcalidrawElbowArrowElement; - expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.06); + expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.115); expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75); UI.resize(rectangle, "se", [-200, -150]); - expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.06); + expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.115); expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75); }); @@ -538,11 +538,11 @@ describe("arrow element", () => { h.state, )[0] as ExcalidrawElbowArrowElement; - expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.06); + expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.115); expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75); UI.resize([rectangle, arrow], "nw", [300, 350]); - expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(-0.06); + expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(-0.115); expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.25); }); }); @@ -1350,8 +1350,8 @@ describe("multiple selection", () => { expect(boundArrow.x).toBeCloseTo(380 * scaleX); expect(boundArrow.y).toBeCloseTo(240 * scaleY); - expect(boundArrow.points[1][0]).toBeCloseTo(63.4035); - expect(boundArrow.points[1][1]).toBeCloseTo(-84.538); + expect(boundArrow.points[1][0]).toBeCloseTo(59.7979); + expect(boundArrow.points[1][1]).toBeCloseTo(-79.7305); expect(arrowLabelPos.x + arrowLabel.width / 2).toBeCloseTo( boundArrow.x + boundArrow.points[1][0] / 2, diff --git a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap index c002cbd459..2daabc8720 100644 --- a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap +++ b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap @@ -123,12 +123,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl { "angle": 0, "backgroundColor": "transparent", - "boundElements": [ - { - "id": "id4", - "type": "arrow", - }, - ], + "boundElements": [], "customData": undefined, "fillStyle": "solid", "frameId": null, @@ -147,7 +142,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 7, + "version": 13, "width": 100, "x": -100, "y": -50, @@ -158,12 +153,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl { "angle": 0, "backgroundColor": "transparent", - "boundElements": [ - { - "id": "id4", - "type": "arrow", - }, - ], + "boundElements": [], "customData": undefined, "fillStyle": "solid", "frameId": null, @@ -182,7 +172,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 6, + "version": 9, "width": 100, "x": 100, "y": -50, @@ -198,17 +188,17 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "elbowed": false, "endArrowhead": "arrow", "endBinding": { - "elementId": "id1", + "elementId": "id15", "fixedPoint": [ - "0.41019", - "0.58981", + "0.50000", + 1, ], "mode": "orbit", }, "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": "2.03061", + "height": "106.79573", "id": "id4", "index": "a2", "isDeleted": false, @@ -222,8 +212,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl 0, ], [ - "78.00000", - "-2.03061", + "89.00000", + "106.79573", ], ], "roughness": 1, @@ -231,23 +221,16 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "type": 2, }, "startArrowhead": null, - "startBinding": { - "elementId": "id0", - "fixedPoint": [ - "0.63636", - "0.63636", - ], - "mode": "orbit", - }, + "startBinding": null, "strokeColor": "#1e1e1e", "strokeStyle": "solid", "strokeWidth": 2, "type": "arrow", "updated": 1, - "version": 19, - "width": "78.00000", - "x": 11, - "y": "12.36576", + "version": 34, + "width": "89.00000", + "x": 0, + "y": 0, } `; @@ -255,7 +238,12 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl { "angle": 0, "backgroundColor": "transparent", - "boundElements": [], + "boundElements": [ + { + "id": "id4", + "type": "arrow", + }, + ], "customData": undefined, "fillStyle": "solid", "frameId": null, @@ -274,7 +262,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 4, + "version": 10, "width": 50, "x": 100, "y": 100, @@ -283,9 +271,214 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and the arrow got bound to a different element in the meantime > [end of test] number of elements 1`] = `4`; -exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and the arrow got bound to a different element in the meantime > [end of test] number of renders 1`] = `16`; +exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and the arrow got bound to a different element in the meantime > [end of test] number of renders 1`] = `22`; -exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and the arrow got bound to a different element in the meantime > [end of test] redo stack 1`] = `[]`; +exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and the arrow got bound to a different element in the meantime > [end of test] redo stack 1`] = ` +[ + { + "appState": AppStateDelta { + "delta": Delta { + "deleted": {}, + "inserted": {}, + }, + }, + "elements": { + "added": {}, + "removed": {}, + "updated": { + "id0": { + "deleted": { + "version": 12, + }, + "inserted": { + "version": 11, + }, + }, + "id1": { + "deleted": { + "boundElements": [], + "version": 9, + }, + "inserted": { + "boundElements": [ + { + "id": "id4", + "type": "arrow", + }, + ], + "version": 8, + }, + }, + "id15": { + "deleted": { + "boundElements": [ + { + "id": "id4", + "type": "arrow", + }, + ], + "version": 9, + }, + "inserted": { + "boundElements": [], + "version": 8, + }, + }, + "id4": { + "deleted": { + "endBinding": { + "elementId": "id15", + "fixedPoint": [ + "0.50000", + 1, + ], + "mode": "orbit", + }, + "height": "66.30324", + "points": [ + [ + 0, + 0, + ], + [ + "78.47830", + "66.30324", + ], + ], + "startBinding": { + "elementId": "id0", + "fixedPoint": [ + "0.63636", + "0.63636", + ], + "mode": "orbit", + }, + "version": 33, + "width": "78.47830", + "y": "53.20079", + }, + "inserted": { + "endBinding": { + "elementId": "id1", + "fixedPoint": [ + "0.41019", + "0.58981", + ], + "mode": "orbit", + }, + "height": "2.04467", + "points": [ + [ + 0, + 0, + ], + [ + "78.00000", + "-2.04467", + ], + ], + "startBinding": { + "elementId": "id0", + "fixedPoint": [ + "0.63636", + "0.63636", + ], + "mode": "orbit", + }, + "version": 30, + "width": "78.00000", + "y": "12.38727", + }, + }, + }, + }, + "id": "id22", + }, + { + "appState": AppStateDelta { + "delta": Delta { + "deleted": {}, + "inserted": {}, + }, + }, + "elements": { + "added": {}, + "removed": {}, + "updated": { + "id0": { + "deleted": { + "boundElements": [], + "version": 13, + }, + "inserted": { + "boundElements": [ + { + "id": "id4", + "type": "arrow", + }, + ], + "version": 12, + }, + }, + "id15": { + "deleted": { + "version": 10, + }, + "inserted": { + "version": 9, + }, + }, + "id4": { + "deleted": { + "height": "106.79573", + "points": [ + [ + 0, + 0, + ], + [ + "89.00000", + "106.79573", + ], + ], + "startBinding": null, + "version": 34, + "width": "89.00000", + "x": 0, + "y": 0, + }, + "inserted": { + "height": "66.30324", + "points": [ + [ + 0, + 0, + ], + [ + "78.47830", + "66.30324", + ], + ], + "startBinding": { + "elementId": "id0", + "fixedPoint": [ + "0.63636", + "0.63636", + ], + "mode": "orbit", + }, + "version": 33, + "width": "78.47830", + "x": "10.52170", + "y": "53.20079", + }, + }, + }, + }, + "id": "id23", + }, +] +`; exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and the arrow got bound to a different element in the meantime > [end of test] undo stack 1`] = ` [ @@ -440,208 +633,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl }, "id": "id6", }, - { - "appState": AppStateDelta { - "delta": Delta { - "deleted": {}, - "inserted": {}, - }, - }, - "elements": { - "added": {}, - "removed": {}, - "updated": { - "id0": { - "deleted": { - "boundElements": [ - { - "id": "id4", - "type": "arrow", - }, - ], - "version": 6, - }, - "inserted": { - "boundElements": [], - "version": 5, - }, - }, - "id15": { - "deleted": { - "version": 3, - }, - "inserted": { - "version": 2, - }, - }, - "id4": { - "deleted": { - "height": "57.11798", - "points": [ - [ - 0, - 0, - ], - [ - 78, - "57.11798", - ], - ], - "startBinding": { - "elementId": "id0", - "fixedPoint": [ - "0.63636", - "0.63636", - ], - "mode": "orbit", - }, - "version": 16, - "width": 78, - "x": 11, - "y": "48.31989", - }, - "inserted": { - "height": 0, - "points": [ - [ - 0, - 0, - ], - [ - 100, - 0, - ], - ], - "startBinding": null, - "version": 13, - "width": 100, - "x": 0, - "y": 0, - }, - }, - }, - }, - "id": "id16", - }, - { - "appState": AppStateDelta { - "delta": Delta { - "deleted": {}, - "inserted": {}, - }, - }, - "elements": { - "added": {}, - "removed": {}, - "updated": { - "id0": { - "deleted": { - "version": 7, - }, - "inserted": { - "version": 6, - }, - }, - "id1": { - "deleted": { - "boundElements": [ - { - "id": "id4", - "type": "arrow", - }, - ], - "version": 6, - }, - "inserted": { - "boundElements": [], - "version": 5, - }, - }, - "id15": { - "deleted": { - "boundElements": [], - "version": 4, - }, - "inserted": { - "boundElements": [ - { - "id": "id4", - "type": "arrow", - }, - ], - "version": 3, - }, - }, - "id4": { - "deleted": { - "endBinding": { - "elementId": "id1", - "fixedPoint": [ - "0.41019", - "0.58981", - ], - "mode": "orbit", - }, - "height": "2.03061", - "points": [ - [ - 0, - 0, - ], - [ - "78.00000", - "-2.03061", - ], - ], - "startBinding": { - "elementId": "id0", - "fixedPoint": [ - "0.63636", - "0.63636", - ], - "mode": "orbit", - }, - "version": 19, - "width": "78.00000", - "y": "12.36576", - }, - "inserted": { - "endBinding": { - "elementId": "id15", - "fixedPoint": [ - "0.50000", - 1, - ], - "mode": "orbit", - }, - "height": "57.11798", - "points": [ - [ - 0, - 0, - ], - [ - 78, - "57.11798", - ], - ], - "startBinding": { - "elementId": "id0", - "fixedPoint": [ - "0.63636", - "0.63636", - ], - "mode": "orbit", - }, - "version": 16, - "width": 78, - "y": "48.31989", - }, - }, - }, - }, - "id": "id17", - }, ] `; @@ -768,12 +759,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl { "angle": 0, "backgroundColor": "transparent", - "boundElements": [ - { - "id": "id4", - "type": "arrow", - }, - ], + "boundElements": [], "customData": undefined, "fillStyle": "solid", "frameId": null, @@ -792,7 +778,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 8, + "version": 14, "width": 100, "x": 150, "y": -50, @@ -803,12 +789,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl { "angle": 0, "backgroundColor": "transparent", - "boundElements": [ - { - "id": "id4", - "type": "arrow", - }, - ], + "boundElements": [], "customData": undefined, "fillStyle": "solid", "frameId": null, @@ -827,7 +808,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 6, + "version": 9, "width": 100, "x": 150, "y": -50, @@ -842,18 +823,11 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "customData": undefined, "elbowed": false, "endArrowhead": "arrow", - "endBinding": { - "elementId": "id1", - "fixedPoint": [ - "0.41092", - "0.58908", - ], - "mode": "orbit", - }, + "endBinding": null, "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": "10.92646", + "height": 0, "id": "id4", "index": "a2", "isDeleted": false, @@ -867,8 +841,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl 0, ], [ - "52.09230", - "10.92646", + 100, + 0, ], ], "roughness": 1, @@ -876,31 +850,199 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "type": 2, }, "startArrowhead": null, - "startBinding": { - "elementId": "id0", - "fixedPoint": [ - "0.63636", - "0.63636", - ], - "mode": "orbit", - }, + "startBinding": null, "strokeColor": "#1e1e1e", "strokeStyle": "solid", "strokeWidth": 2, "type": "arrow", "updated": 1, - "version": 20, - "width": "52.09230", - "x": "139.00000", - "y": "-2.01876", + "version": 30, + "width": 100, + "x": 150, + "y": 0, } `; exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and there are no conflicting updates in the meantime > [end of test] number of elements 1`] = `3`; -exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and there are no conflicting updates in the meantime > [end of test] number of renders 1`] = `18`; +exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and there are no conflicting updates in the meantime > [end of test] number of renders 1`] = `24`; -exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and there are no conflicting updates in the meantime > [end of test] redo stack 1`] = `[]`; +exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and there are no conflicting updates in the meantime > [end of test] redo stack 1`] = ` +[ + { + "appState": AppStateDelta { + "delta": Delta { + "deleted": {}, + "inserted": {}, + }, + }, + "elements": { + "added": {}, + "removed": {}, + "updated": { + "id0": { + "deleted": { + "version": 13, + }, + "inserted": { + "version": 12, + }, + }, + "id1": { + "deleted": { + "boundElements": [], + "version": 9, + }, + "inserted": { + "boundElements": [ + { + "id": "id4", + "type": "arrow", + }, + ], + "version": 8, + }, + }, + "id4": { + "deleted": { + "endBinding": null, + "height": "4.68000", + "points": [ + [ + 0, + 0, + ], + [ + "-39.00000", + "-4.68000", + ], + ], + "startBinding": { + "elementId": "id0", + "fixedPoint": [ + "0.63636", + "0.63636", + ], + "mode": "orbit", + }, + "version": 29, + "width": "39.00000", + "y": "4.68000", + }, + "inserted": { + "endBinding": { + "elementId": "id1", + "fixedPoint": [ + "0.41092", + "0.58908", + ], + "mode": "orbit", + }, + "height": "10.92646", + "points": [ + [ + 0, + 0, + ], + [ + "52.09230", + "10.92646", + ], + ], + "startBinding": { + "elementId": "id0", + "fixedPoint": [ + "0.63636", + "0.63636", + ], + "mode": "orbit", + }, + "version": 27, + "width": "52.09230", + "y": "-2.01876", + }, + }, + }, + }, + "id": "id21", + }, + { + "appState": AppStateDelta { + "delta": Delta { + "deleted": {}, + "inserted": {}, + }, + }, + "elements": { + "added": {}, + "removed": {}, + "updated": { + "id0": { + "deleted": { + "boundElements": [], + "version": 14, + }, + "inserted": { + "boundElements": [ + { + "id": "id4", + "type": "arrow", + }, + ], + "version": 13, + }, + }, + "id4": { + "deleted": { + "height": 0, + "points": [ + [ + 0, + 0, + ], + [ + 100, + 0, + ], + ], + "startBinding": null, + "version": 30, + "width": 100, + "x": 150, + "y": 0, + }, + "inserted": { + "height": "4.68000", + "points": [ + [ + 0, + 0, + ], + [ + "-39.00000", + "-4.68000", + ], + ], + "startBinding": { + "elementId": "id0", + "fixedPoint": [ + "0.63636", + "0.63636", + ], + "mode": "orbit", + }, + "version": 29, + "width": "39.00000", + "x": 139, + "y": "4.68000", + }, + }, + }, + }, + "id": "id22", + }, +] +`; exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and there are no conflicting updates in the meantime > [end of test] undo stack 1`] = ` [ @@ -1055,178 +1197,6 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl }, "id": "id6", }, - { - "appState": AppStateDelta { - "delta": Delta { - "deleted": {}, - "inserted": {}, - }, - }, - "elements": { - "added": {}, - "removed": {}, - "updated": { - "id0": { - "deleted": { - "boundElements": [ - { - "id": "id4", - "type": "arrow", - }, - ], - "version": 7, - }, - "inserted": { - "boundElements": [], - "version": 6, - }, - }, - "id4": { - "deleted": { - "height": "4.68000", - "points": [ - [ - 0, - 0, - ], - [ - -39, - "-4.68000", - ], - ], - "startBinding": { - "elementId": "id0", - "fixedPoint": [ - "0.63636", - "0.63636", - ], - "mode": "orbit", - }, - "version": 17, - "width": 39, - "x": 139, - "y": "4.68000", - }, - "inserted": { - "height": 0, - "points": [ - [ - 0, - 0, - ], - [ - 100, - 0, - ], - ], - "startBinding": null, - "version": 15, - "width": 100, - "x": 150, - "y": 0, - }, - }, - }, - }, - "id": "id15", - }, - { - "appState": AppStateDelta { - "delta": Delta { - "deleted": {}, - "inserted": {}, - }, - }, - "elements": { - "added": {}, - "removed": {}, - "updated": { - "id0": { - "deleted": { - "version": 8, - }, - "inserted": { - "version": 7, - }, - }, - "id1": { - "deleted": { - "boundElements": [ - { - "id": "id4", - "type": "arrow", - }, - ], - "version": 6, - }, - "inserted": { - "boundElements": [], - "version": 5, - }, - }, - "id4": { - "deleted": { - "endBinding": { - "elementId": "id1", - "fixedPoint": [ - "0.41092", - "0.58908", - ], - "mode": "orbit", - }, - "height": "10.92646", - "points": [ - [ - 0, - 0, - ], - [ - "52.09230", - "10.92646", - ], - ], - "startBinding": { - "elementId": "id0", - "fixedPoint": [ - "0.63636", - "0.63636", - ], - "mode": "orbit", - }, - "version": 20, - "width": "52.09230", - "y": "-2.01876", - }, - "inserted": { - "endBinding": null, - "height": "4.68000", - "points": [ - [ - 0, - 0, - ], - [ - -39, - "-4.68000", - ], - ], - "startBinding": { - "elementId": "id0", - "fixedPoint": [ - "0.63636", - "0.63636", - ], - "mode": "orbit", - }, - "version": 17, - "width": 39, - "y": "4.68000", - }, - }, - }, - }, - "id": "id16", - }, ] `; diff --git a/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap index 556a41c35b..fcbb29342f 100644 --- a/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap +++ b/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap @@ -95,3 +95,141 @@ exports[`move element > rectangle 5`] = ` "y": 40, } `; + +exports[`move element > rectangles with binding arrow 5`] = ` +{ + "angle": 0, + "backgroundColor": "transparent", + "boundElements": [ + { + "id": "id6", + "type": "arrow", + }, + ], + "customData": undefined, + "fillStyle": "solid", + "frameId": null, + "groupIds": [], + "height": 100, + "id": "id0", + "index": "a0", + "isDeleted": false, + "link": null, + "locked": false, + "opacity": 100, + "roughness": 1, + "roundness": null, + "seed": 1278240551, + "strokeColor": "#1e1e1e", + "strokeStyle": "solid", + "strokeWidth": 2, + "type": "rectangle", + "updated": 1, + "version": 4, + "versionNonce": 760410951, + "width": 100, + "x": 0, + "y": 0, +} +`; + +exports[`move element > rectangles with binding arrow 6`] = ` +{ + "angle": 0, + "backgroundColor": "transparent", + "boundElements": [ + { + "id": "id6", + "type": "arrow", + }, + ], + "customData": undefined, + "fillStyle": "solid", + "frameId": null, + "groupIds": [], + "height": 300, + "id": "id3", + "index": "a1", + "isDeleted": false, + "link": null, + "locked": false, + "opacity": 100, + "roughness": 1, + "roundness": null, + "seed": 1116226695, + "strokeColor": "#1e1e1e", + "strokeStyle": "solid", + "strokeWidth": 2, + "type": "rectangle", + "updated": 1, + "version": 7, + "versionNonce": 651223591, + "width": 300, + "x": 201, + "y": 2, +} +`; + +exports[`move element > rectangles with binding arrow 7`] = ` +{ + "angle": 0, + "backgroundColor": "transparent", + "boundElements": null, + "customData": undefined, + "elbowed": false, + "endArrowhead": "arrow", + "endBinding": { + "elementId": "id3", + "fixedPoint": [ + "-0.03667", + "0.43000", + ], + "mode": "orbit", + }, + "fillStyle": "solid", + "frameId": null, + "groupIds": [], + "height": "79.99025", + "id": "id6", + "index": "a2", + "isDeleted": false, + "link": null, + "locked": false, + "moveMidPointsWithElement": false, + "opacity": 100, + "points": [ + [ + 0, + 0, + ], + [ + "79.00000", + "79.99025", + ], + ], + "roughness": 1, + "roundness": { + "type": 2, + }, + "seed": 23633383, + "startArrowhead": null, + "startBinding": { + "elementId": "id0", + "fixedPoint": [ + "1.11000", + "0.51010", + ], + "mode": "orbit", + }, + "strokeColor": "#1e1e1e", + "strokeStyle": "solid", + "strokeWidth": 2, + "type": "arrow", + "updated": 1, + "version": 14, + "versionNonce": 348321737, + "width": "79.00000", + "x": "111.00000", + "y": "51.00987", +} +`; diff --git a/packages/excalidraw/tests/history.test.tsx b/packages/excalidraw/tests/history.test.tsx index 68bbb63a05..59def50ee7 100644 --- a/packages/excalidraw/tests/history.test.tsx +++ b/packages/excalidraw/tests/history.test.tsx @@ -4626,7 +4626,7 @@ describe("history", () => { }), endBinding: expect.objectContaining({ elementId: rect2.id, - fixedPoint: [0.4109529004289598, 0.5890470995710405], + fixedPoint: [0.41092297821765383, 0.5890770217823459], mode: "orbit", }), }), @@ -4770,7 +4770,7 @@ describe("history", () => { // rebound with previous rectangle endBinding: expect.objectContaining({ elementId: rect2.id, - fixedPoint: [0.4106696643494561, 0.5893303356505437], + fixedPoint: [0.41019091151895054, 0.5898090884810496], mode: "orbit", }), }), diff --git a/packages/excalidraw/tests/move.test.tsx b/packages/excalidraw/tests/move.test.tsx index ac6b05008d..0a04762cd8 100644 --- a/packages/excalidraw/tests/move.test.tsx +++ b/packages/excalidraw/tests/move.test.tsx @@ -110,8 +110,8 @@ describe("move element", () => { expect(h.state.selectedElementIds[rectB.id]).toBeTruthy(); expect([rectA.x, rectA.y]).toEqual([0, 0]); expect([rectB.x, rectB.y]).toEqual([200, 0]); - expect([[arrow.x, arrow.y]]).toCloselyEqualPoints([[106, 46.011]], 0); - expect([[arrow.width, arrow.height]]).toCloselyEqualPoints([[88, 88]], 0); + expect([[arrow.x, arrow.y]]).toCloselyEqualPoints([[111, 51.0098]], 0); + expect([[arrow.width, arrow.height]]).toCloselyEqualPoints([[78, 78]], 0); renderInteractiveScene.mockClear(); renderStaticScene.mockClear(); @@ -129,11 +129,8 @@ describe("move element", () => { expect(h.state.selectedElementIds[rectB.id]).toBeTruthy(); expect([rectA.x, rectA.y]).toEqual([0, 0]); expect([rectB.x, rectB.y]).toEqual([201, 2]); - expect([[arrow.x, arrow.y]]).toCloselyEqualPoints([[106, 46]], 0); - expect([[arrow.width, arrow.height]]).toCloselyEqualPoints( - [[89, 90.033]], - 0, - ); + expect([[arrow.x, arrow.y]]).toCloselyEqualPoints([[111, 51]], 0); + expect([[arrow.width, arrow.height]]).toCloselyEqualPoints([[79, 80]], 0); h.elements.forEach((element) => expect(element).toMatchSnapshot()); }); diff --git a/packages/excalidraw/tests/rotate.test.tsx b/packages/excalidraw/tests/rotate.test.tsx index 285672aa8f..47f7e469e4 100644 --- a/packages/excalidraw/tests/rotate.test.tsx +++ b/packages/excalidraw/tests/rotate.test.tsx @@ -80,6 +80,6 @@ test("unselected bound arrows update when rotating their target elements", async expect(textArrow.x).toEqual(360); expect(textArrow.y).toEqual(300); expect(textArrow.points[0]).toEqual([0, 0]); - expect(textArrow.points[1][0]).toBeCloseTo(-98.86, 0); - expect(textArrow.points[1][1]).toBeCloseTo(-123.65, 0); + expect(textArrow.points[1][0]).toBeCloseTo(-95.74, 0); + expect(textArrow.points[1][1]).toBeCloseTo(-119.7354, 0); });