mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-07-18 10:11:24 +00:00
Remove panning from undo stack (#483)
This commit is contained in:
@@ -23,12 +23,13 @@ import {
|
|||||||
useAreas,
|
useAreas,
|
||||||
useNotes,
|
useNotes,
|
||||||
useLayout,
|
useLayout,
|
||||||
|
useSaveState,
|
||||||
} from "../../hooks";
|
} from "../../hooks";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useEventListener } from "usehooks-ts";
|
import { useEventListener } from "usehooks-ts";
|
||||||
import { areFieldsCompatible } from "../../utils/utils";
|
import { areFieldsCompatible } from "../../utils/utils";
|
||||||
import { getRectFromEndpoints, isInsideRect } from "../../utils/rect";
|
import { getRectFromEndpoints, isInsideRect } from "../../utils/rect";
|
||||||
import { noteWidth } from "../../data/constants";
|
import { noteWidth, State } from "../../data/constants";
|
||||||
|
|
||||||
export default function Canvas() {
|
export default function Canvas() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -42,6 +43,7 @@ export default function Canvas() {
|
|||||||
|
|
||||||
const { tables, updateTable, relationships, addRelationship, database } =
|
const { tables, updateTable, relationships, addRelationship, database } =
|
||||||
useDiagram();
|
useDiagram();
|
||||||
|
const { setSaveState } = useSaveState();
|
||||||
const { areas, updateArea } = useAreas();
|
const { areas, updateArea } = useAreas();
|
||||||
const { notes, updateNote } = useNotes();
|
const { notes, updateNote } = useNotes();
|
||||||
const { layout } = useLayout();
|
const { layout } = useLayout();
|
||||||
@@ -540,19 +542,7 @@ export default function Canvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (panning.isPanning && didPan()) {
|
if (panning.isPanning && didPan()) {
|
||||||
setUndoStack((prev) => [
|
setSaveState(State.SAVING);
|
||||||
...prev,
|
|
||||||
{
|
|
||||||
action: Action.PAN,
|
|
||||||
undo: { x: panning.panStart.x, y: panning.panStart.y },
|
|
||||||
redo: transform.pan,
|
|
||||||
message: t("move_element", {
|
|
||||||
coords: `(${transform?.pan.x}, ${transform?.pan.y})`,
|
|
||||||
name: "diagram",
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
setRedoStack([]);
|
|
||||||
setSelectedElement((prev) => ({
|
setSelectedElement((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
element: ObjectType.NONE,
|
element: ObjectType.NONE,
|
||||||
|
@@ -297,12 +297,6 @@ export default function ControlPanel({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setRedoStack((prev) => [...prev, a]);
|
setRedoStack((prev) => [...prev, a]);
|
||||||
} else if (a.action === Action.PAN) {
|
|
||||||
setTransform((prev) => ({
|
|
||||||
...prev,
|
|
||||||
pan: a.undo,
|
|
||||||
}));
|
|
||||||
setRedoStack((prev) => [...prev, a]);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -477,12 +471,6 @@ export default function ControlPanel({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setUndoStack((prev) => [...prev, a]);
|
setUndoStack((prev) => [...prev, a]);
|
||||||
} else if (a.action === Action.PAN) {
|
|
||||||
setTransform((prev) => ({
|
|
||||||
...prev,
|
|
||||||
pan: a.redo,
|
|
||||||
}));
|
|
||||||
setUndoStack((prev) => [...prev, a]);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -59,7 +59,6 @@ export const Action = {
|
|||||||
MOVE: 1,
|
MOVE: 1,
|
||||||
DELETE: 2,
|
DELETE: 2,
|
||||||
EDIT: 3,
|
EDIT: 3,
|
||||||
PAN: 4,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const State = {
|
export const State = {
|
||||||
|
Reference in New Issue
Block a user