mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
add history.shouldCreateEntry resolver (#1622)
This commit is contained in:
parent
22f7945c70
commit
d2ae18995c
11 changed files with 1349 additions and 3449 deletions
|
@ -10,13 +10,13 @@ Object {
|
|||
"isDeleted": false,
|
||||
"opacity": 100,
|
||||
"roughness": 1,
|
||||
"seed": 2019559783,
|
||||
"seed": 401146281,
|
||||
"strokeColor": "#000000",
|
||||
"strokeStyle": "solid",
|
||||
"strokeWidth": 1,
|
||||
"type": "rectangle",
|
||||
"version": 4,
|
||||
"versionNonce": 1150084233,
|
||||
"versionNonce": 2019559783,
|
||||
"width": 30,
|
||||
"x": 30,
|
||||
"y": 20,
|
||||
|
@ -39,7 +39,7 @@ Object {
|
|||
"strokeWidth": 1,
|
||||
"type": "rectangle",
|
||||
"version": 5,
|
||||
"versionNonce": 1014066025,
|
||||
"versionNonce": 1116226695,
|
||||
"width": 30,
|
||||
"x": -10,
|
||||
"y": 60,
|
||||
|
@ -62,7 +62,7 @@ Object {
|
|||
"strokeWidth": 1,
|
||||
"type": "rectangle",
|
||||
"version": 3,
|
||||
"versionNonce": 401146281,
|
||||
"versionNonce": 453191,
|
||||
"width": 30,
|
||||
"x": 0,
|
||||
"y": 40,
|
||||
|
|
|
@ -34,7 +34,7 @@ Object {
|
|||
"strokeWidth": 1,
|
||||
"type": "arrow",
|
||||
"version": 7,
|
||||
"versionNonce": 1116226695,
|
||||
"versionNonce": 1150084233,
|
||||
"width": 70,
|
||||
"x": 30,
|
||||
"y": 30,
|
||||
|
@ -75,7 +75,7 @@ Object {
|
|||
"strokeWidth": 1,
|
||||
"type": "line",
|
||||
"version": 7,
|
||||
"versionNonce": 1116226695,
|
||||
"versionNonce": 1150084233,
|
||||
"width": 70,
|
||||
"x": 30,
|
||||
"y": 30,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -16,7 +16,7 @@ Object {
|
|||
"strokeWidth": 1,
|
||||
"type": "rectangle",
|
||||
"version": 3,
|
||||
"versionNonce": 1150084233,
|
||||
"versionNonce": 401146281,
|
||||
"width": 30,
|
||||
"x": 29,
|
||||
"y": 47,
|
||||
|
@ -39,7 +39,7 @@ Object {
|
|||
"strokeWidth": 1,
|
||||
"type": "rectangle",
|
||||
"version": 3,
|
||||
"versionNonce": 1150084233,
|
||||
"versionNonce": 401146281,
|
||||
"width": 30,
|
||||
"x": 29,
|
||||
"y": 47,
|
||||
|
|
|
@ -162,6 +162,11 @@ const getSelectedElement = (): ExcalidrawElement => {
|
|||
return selectedElements[0];
|
||||
};
|
||||
|
||||
function getStateHistory() {
|
||||
// @ts-ignore
|
||||
return h.history.stateHistory;
|
||||
}
|
||||
|
||||
type HandlerRectanglesRet = keyof ReturnType<typeof handlerRectangles>;
|
||||
const getResizeHandles = () => {
|
||||
const rects = handlerRectangles(
|
||||
|
@ -569,6 +574,46 @@ describe("regression tests", () => {
|
|||
expect(h.elements.filter((element) => !element.isDeleted).length).toBe(2);
|
||||
});
|
||||
|
||||
it("noop interaction after undo shouldn't create history entry", () => {
|
||||
// NOTE: this will fail if this test case is run in isolation. There's
|
||||
// some leaking state or race conditions in initialization/teardown
|
||||
// (couldn't figure out)
|
||||
expect(getStateHistory().length).toBe(0);
|
||||
|
||||
clickTool("rectangle");
|
||||
pointerDown(10, 10);
|
||||
pointerMove(20, 20);
|
||||
pointerUp();
|
||||
|
||||
clickTool("rectangle");
|
||||
pointerDown(30, 10);
|
||||
pointerMove(40, 20);
|
||||
pointerUp();
|
||||
|
||||
expect(getStateHistory().length).toBe(2);
|
||||
|
||||
keyPress("z", true);
|
||||
expect(getStateHistory().length).toBe(1);
|
||||
|
||||
// clicking an element shouldn't addu to history
|
||||
pointerDown(10, 10);
|
||||
pointerUp();
|
||||
expect(getStateHistory().length).toBe(1);
|
||||
|
||||
keyPress("z", true, true);
|
||||
expect(getStateHistory().length).toBe(2);
|
||||
|
||||
// clicking an element shouldn't addu to history
|
||||
pointerDown(10, 10);
|
||||
pointerUp();
|
||||
expect(getStateHistory().length).toBe(2);
|
||||
|
||||
// same for clicking the element just redo-ed
|
||||
pointerDown(30, 10);
|
||||
pointerUp();
|
||||
expect(getStateHistory().length).toBe(2);
|
||||
});
|
||||
|
||||
it("zoom hotkeys", () => {
|
||||
expect(h.state.zoom).toBe(1);
|
||||
fireEvent.keyDown(document, { code: "Equal", ctrlKey: true });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue