From 03800a45e073a71dd6a2b2b4aa49ed504554332c Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 28 Mar 2023 17:13:37 +0530 Subject: [PATCH] Allow Ctrl+Z to undo the removal of images/tasks --- ui/index.html | 2 +- ui/media/js/main.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ui/index.html b/ui/index.html index 6c067aeb..0bf90733 100644 --- a/ui/index.html +++ b/ui/index.html @@ -298,7 +298,7 @@
- diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 781bb480..7507ba7f 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -278,6 +278,9 @@ function undoableRemove(element, doubleUndo=false) { function undoRemove() { let data = undoBuffer.pop() + if (!data) { + return + } if (data.next == null) { data.parent.appendChild(data.element) } else { @@ -294,6 +297,12 @@ function undoRemove() { undoButton.addEventListener('click', () => { undoRemove() }) +document.addEventListener('keydown', function(e) { + if (e.ctrlKey && e.key === 'z' && e.target == document.body) { + undoRemove() + } +}) + function showImages(reqBody, res, outputContainer, livePreview) { let imageItemElements = outputContainer.querySelectorAll('.imgItem') if(typeof res != 'object') return