chore: release @excalidraw/excalidraw@18.0.0 🎉 (#9127)

This commit is contained in:
Marcel Mraz
2025-02-28 16:49:09 +01:00
committed by GitHub
parent 392118bf26
commit ecef5d12f4
232 changed files with 3412 additions and 2851 deletions
+80 -80
View File
@@ -46,9 +46,9 @@ import { vi } from "vitest";
import { queryByText } from "@testing-library/react";
import { HistoryEntry } from "../history";
import { AppStateChange, ElementsChange } from "../change";
import { Snapshot, StoreAction } from "../store";
import type { LocalPoint, Radians } from "../../math";
import { pointFrom } from "../../math";
import { Snapshot, CaptureUpdateAction } from "../store";
import type { LocalPoint, Radians } from "@excalidraw/math";
import { pointFrom } from "@excalidraw/math";
const { h } = window;
@@ -182,7 +182,7 @@ describe("history", () => {
API.updateScene({
elements: [rect1, rect2],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
expect(API.getUndoStack().length).toBe(1);
@@ -194,7 +194,7 @@ describe("history", () => {
API.updateScene({
elements: [rect1, rect2],
storeAction: StoreAction.CAPTURE, // even though the flag is on, same elements are passed, nothing to commit
captureUpdate: CaptureUpdateAction.IMMEDIATELY, // even though the flag is on, same elements are passed, nothing to commit
});
expect(API.getUndoStack().length).toBe(1);
expect(API.getRedoStack().length).toBe(0);
@@ -562,7 +562,7 @@ describe("history", () => {
appState: {
name: "New name",
},
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
expect(API.getUndoStack().length).toBe(1);
@@ -573,7 +573,7 @@ describe("history", () => {
appState: {
viewBackgroundColor: "#000",
},
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
expect(API.getUndoStack().length).toBe(2);
expect(API.getRedoStack().length).toBe(0);
@@ -586,7 +586,7 @@ describe("history", () => {
name: "New name",
viewBackgroundColor: "#000",
},
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
expect(API.getUndoStack().length).toBe(2);
expect(API.getRedoStack().length).toBe(0);
@@ -1293,7 +1293,7 @@ describe("history", () => {
API.updateScene({
elements: [rect1, text, rect2],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
// bind text1 to rect1
@@ -1847,7 +1847,7 @@ describe("history", () => {
strokeColor: blue,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -1885,7 +1885,7 @@ describe("history", () => {
strokeColor: yellow,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -1933,7 +1933,7 @@ describe("history", () => {
backgroundColor: yellow,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
// At this point our entry gets updated from `red` -> `blue` into `red` -> `yellow`
@@ -1949,7 +1949,7 @@ describe("history", () => {
backgroundColor: violet,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
// At this point our (inversed) entry gets updated from `red` -> `yellow` into `violet` -> `yellow`
@@ -1994,7 +1994,7 @@ describe("history", () => {
API.updateScene({
elements: [rect, diamond],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
// Connect the arrow
@@ -2043,7 +2043,7 @@ describe("history", () => {
} as FixedPointBinding,
},
],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
Keyboard.undo();
@@ -2058,7 +2058,7 @@ describe("history", () => {
}
: el,
),
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -2082,7 +2082,7 @@ describe("history", () => {
// Initialize scene
API.updateScene({
elements: [rect1, rect2],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
// Simulate local update
@@ -2091,7 +2091,7 @@ describe("history", () => {
newElementWith(h.elements[0], { groupIds: ["A"] }),
newElementWith(h.elements[1], { groupIds: ["A"] }),
],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
const rect3 = API.createElement({ type: "rectangle", groupIds: ["B"] });
@@ -2105,7 +2105,7 @@ describe("history", () => {
rect3,
rect4,
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -2151,7 +2151,7 @@ describe("history", () => {
] as LocalPoint[],
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo(); // undo `actionFinalize`
@@ -2246,7 +2246,7 @@ describe("history", () => {
isDeleted: false, // undeletion might happen due to concurrency between clients
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
expect(API.getSelectedElements()).toEqual([]);
@@ -2323,7 +2323,7 @@ describe("history", () => {
isDeleted: true,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
expect(h.elements).toEqual([
@@ -2385,7 +2385,7 @@ describe("history", () => {
isDeleted: true,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -2461,7 +2461,7 @@ describe("history", () => {
isDeleted: true,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -2500,7 +2500,7 @@ describe("history", () => {
isDeleted: false,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.redo();
@@ -2546,7 +2546,7 @@ describe("history", () => {
// Simulate remote update
API.updateScene({
elements: [rect1, rect2],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.withModifierKeys({ ctrl: true }, () => {
@@ -2556,7 +2556,7 @@ describe("history", () => {
// Simulate remote update
API.updateScene({
elements: [h.elements[0], h.elements[1], rect3, rect4],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.withModifierKeys({ ctrl: true }, () => {
@@ -2577,7 +2577,7 @@ describe("history", () => {
isDeleted: true,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -2602,7 +2602,7 @@ describe("history", () => {
isDeleted: false,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.redo();
@@ -2613,7 +2613,7 @@ describe("history", () => {
// Simulate remote update
API.updateScene({
elements: [h.elements[0], h.elements[1], rect3, rect4],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.redo();
@@ -2659,7 +2659,7 @@ describe("history", () => {
isDeleted: true,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -2680,7 +2680,7 @@ describe("history", () => {
}),
h.elements[1],
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -2723,7 +2723,7 @@ describe("history", () => {
isDeleted: true,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -2766,7 +2766,7 @@ describe("history", () => {
h.elements[0],
h.elements[1],
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
expect(API.getUndoStack().length).toBe(2);
@@ -2805,7 +2805,7 @@ describe("history", () => {
h.elements[0],
h.elements[1],
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
expect(API.getUndoStack().length).toBe(2);
@@ -2856,7 +2856,7 @@ describe("history", () => {
h.elements[0], // rect2
h.elements[1], // rect1
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -2886,7 +2886,7 @@ describe("history", () => {
h.elements[0], // rect3
h.elements[2], // rect1
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -2916,7 +2916,7 @@ describe("history", () => {
// Simulate remote update
API.updateScene({
elements: [...h.elements, rect],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
mouse.moveTo(60, 60);
@@ -2968,7 +2968,7 @@ describe("history", () => {
// // Simulate remote update
API.updateScene({
elements: [...h.elements, rect3],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
mouse.moveTo(100, 100);
@@ -3058,7 +3058,7 @@ describe("history", () => {
// Simulate remote update
API.updateScene({
elements: [...h.elements, rect3],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
mouse.moveTo(100, 100);
@@ -3235,7 +3235,7 @@ describe("history", () => {
// Initialize the scene
API.updateScene({
elements: [container, text],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
// Simulate local update
@@ -3248,7 +3248,7 @@ describe("history", () => {
containerId: container.id,
}),
],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
Keyboard.undo();
@@ -3279,7 +3279,7 @@ describe("history", () => {
x: h.elements[1].x + 10,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
runTwice(() => {
@@ -3322,7 +3322,7 @@ describe("history", () => {
// Initialize the scene
API.updateScene({
elements: [container, text],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
// Simulate local update
@@ -3335,7 +3335,7 @@ describe("history", () => {
containerId: container.id,
}),
],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
Keyboard.undo();
@@ -3369,7 +3369,7 @@ describe("history", () => {
remoteText,
h.elements[1],
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
runTwice(() => {
@@ -3425,7 +3425,7 @@ describe("history", () => {
// Initialize the scene
API.updateScene({
elements: [container, text],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
// Simulate local update
@@ -3438,7 +3438,7 @@ describe("history", () => {
containerId: container.id,
}),
],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
Keyboard.undo();
@@ -3475,7 +3475,7 @@ describe("history", () => {
containerId: remoteContainer.id,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
runTwice(() => {
@@ -3533,7 +3533,7 @@ describe("history", () => {
// Simulate local update
API.updateScene({
elements: [container],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
// Simulate remote update
@@ -3544,7 +3544,7 @@ describe("history", () => {
}),
newElementWith(text, { containerId: container.id }),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
runTwice(() => {
@@ -3594,7 +3594,7 @@ describe("history", () => {
// Simulate local update
API.updateScene({
elements: [text],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
// Simulate remote update
@@ -3605,7 +3605,7 @@ describe("history", () => {
}),
newElementWith(text, { containerId: container.id }),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
runTwice(() => {
@@ -3654,7 +3654,7 @@ describe("history", () => {
// Simulate local update
API.updateScene({
elements: [container],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
// Simulate remote update
@@ -3667,7 +3667,7 @@ describe("history", () => {
containerId: container.id,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -3704,7 +3704,7 @@ describe("history", () => {
// rebinding the container with a new text element!
remoteText,
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
runTwice(() => {
@@ -3761,7 +3761,7 @@ describe("history", () => {
// Simulate local update
API.updateScene({
elements: [text],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
// Simulate remote update
@@ -3774,7 +3774,7 @@ describe("history", () => {
containerId: container.id,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.undo();
@@ -3811,7 +3811,7 @@ describe("history", () => {
containerId: container.id,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
runTwice(() => {
@@ -3867,7 +3867,7 @@ describe("history", () => {
// Simulate local update
API.updateScene({
elements: [container],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
// Simulate remote update
@@ -3881,7 +3881,7 @@ describe("history", () => {
isDeleted: true,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
runTwice(() => {
@@ -3924,7 +3924,7 @@ describe("history", () => {
// Simulate local update
API.updateScene({
elements: [text],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
// Simulate remote update
@@ -3938,7 +3938,7 @@ describe("history", () => {
containerId: container.id,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
runTwice(() => {
@@ -3981,7 +3981,7 @@ describe("history", () => {
// Initialize the scene
API.updateScene({
elements: [container],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
// Simulate local update
@@ -3993,7 +3993,7 @@ describe("history", () => {
angle: 90 as Radians,
}),
],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
Keyboard.undo();
@@ -4006,7 +4006,7 @@ describe("history", () => {
}),
newElementWith(text, { containerId: container.id }),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
expect(h.elements).toEqual([
@@ -4099,7 +4099,7 @@ describe("history", () => {
// Initialize the scene
API.updateScene({
elements: [text],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
// Simulate local update
@@ -4111,7 +4111,7 @@ describe("history", () => {
angle: 90 as Radians,
}),
],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
Keyboard.undo();
@@ -4126,7 +4126,7 @@ describe("history", () => {
containerId: container.id,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
expect(API.getUndoStack().length).toBe(0);
@@ -4217,7 +4217,7 @@ describe("history", () => {
// Simulate local update
API.updateScene({
elements: [rect1, rect2],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
mouse.reset();
@@ -4304,7 +4304,7 @@ describe("history", () => {
x: h.elements[1].x + 50,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
runTwice(() => {
@@ -4444,7 +4444,7 @@ describe("history", () => {
}),
remoteContainer,
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
runTwice(() => {
@@ -4549,7 +4549,7 @@ describe("history", () => {
boundElements: [{ id: arrow.id, type: "arrow" }],
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
runTwice(() => {
@@ -4626,7 +4626,7 @@ describe("history", () => {
// Simulate local update
API.updateScene({
elements: [arrow],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
// Simulate remote update
@@ -4653,7 +4653,7 @@ describe("history", () => {
boundElements: [{ id: arrow.id, type: "arrow" }],
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
runTwice(() => {
@@ -4783,7 +4783,7 @@ describe("history", () => {
newElementWith(h.elements[1], { x: 500, y: -500 }),
h.elements[2],
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.redo();
@@ -4853,13 +4853,13 @@ describe("history", () => {
// Initialize the scene
API.updateScene({
elements: [frame],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
// Simulate local update
API.updateScene({
elements: [rect, h.elements[0]],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
// Simulate local update
@@ -4870,7 +4870,7 @@ describe("history", () => {
}),
h.elements[1],
],
storeAction: StoreAction.CAPTURE,
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
});
Keyboard.undo();
@@ -4914,7 +4914,7 @@ describe("history", () => {
isDeleted: true,
}),
],
storeAction: StoreAction.UPDATE,
captureUpdate: CaptureUpdateAction.NEVER,
});
Keyboard.redo();