From 3742fa9f0c3118de1c23bf27198975eea62e09bb Mon Sep 17 00:00:00 2001 From: Hikaru Y Date: Sun, 10 Sep 2023 12:26:41 +0900 Subject: [PATCH] Fix some issues with undo/redo in mask editor (#2649) Issues: - The `change` event was not dispatched in MaskEditor.svelte when an undo/redo was performed. Therefore, if the user then closed the editor or switched to another note without performing an operation that would cause the `change` event to be dispatched, the undone or redone changes were not saved to DB. - When `IOMode.kind === "edit"` (i.e., Edit Current or Browse), the beginning of the undo history was a blank canvas, not a canvas with existing masks. Therefore, if you continued to undo to the beginning of the history, the masks that existed when you opened the editor would be lost, and they would not be restored even when you performed a redo. - In the 'Add' dialog, the undo history was not reset when starting to create a new IO note after adding an IO note. Also add a small UI improvement: The undo/redo buttons are now disabled when there is no action to undo/redo. --- ts/image-occlusion/MaskEditor.svelte | 12 ++ ts/image-occlusion/Toolbar.svelte | 9 +- ts/image-occlusion/mask-editor.ts | 6 +- ts/image-occlusion/tools/tool-ellipse.ts | 6 +- ts/image-occlusion/tools/tool-polygon.ts | 9 +- ts/image-occlusion/tools/tool-rect.ts | 6 +- ts/image-occlusion/tools/tool-undo-redo.ts | 146 ++++++++++++++------- 7 files changed, 126 insertions(+), 68 deletions(-) diff --git a/ts/image-occlusion/MaskEditor.svelte b/ts/image-occlusion/MaskEditor.svelte index c6c74532f..a89625923 100644 --- a/ts/image-occlusion/MaskEditor.svelte +++ b/ts/image-occlusion/MaskEditor.svelte @@ -2,6 +2,16 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> + +