From 239aea30b479e9c0d24c140d41a1c91c219122f1 Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Fri, 28 May 2021 15:43:35 +0100 Subject: [PATCH] moves undo / redo --- state/state.ts | 2 ++ utils/utils.ts | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/state/state.ts b/state/state.ts index 35e7064da..11a0998dd 100644 --- a/state/state.ts +++ b/state/state.ts @@ -258,6 +258,8 @@ const state = createState({ do: "createShape", to: "draw.editing", }, + UNDO: { do: "undo" }, + REDO: { do: "redo" }, }, }, editing: { diff --git a/utils/utils.ts b/utils/utils.ts index 9765048f5..a106bfcdf 100644 --- a/utils/utils.ts +++ b/utils/utils.ts @@ -978,11 +978,18 @@ export function getBoundsFromPoints(points: number[][]): Bounds { let maxX = -Infinity let maxY = -Infinity - for (let [x, y] of points) { - minX = Math.min(x, minX) - minY = Math.min(y, minY) - maxX = Math.max(x, maxX) - maxY = Math.max(y, maxY) + if (points.length === 0) { + minX = 0 + minY = 0 + maxX = 1 + maxY = 1 + } else { + for (let [x, y] of points) { + minX = Math.min(x, minX) + minY = Math.min(y, minY) + maxX = Math.max(x, maxX) + maxY = Math.max(y, maxY) + } } return {