Allow Ctrl+Z to undo the removal of images/tasks

This commit is contained in:
cmdr2 2023-03-28 17:13:37 +05:30
parent 9ee17ec5f1
commit 03800a45e0
2 changed files with 10 additions and 1 deletions

View File

@ -298,7 +298,7 @@
<button id="clear-all-previews" class="secondaryButton"><i class="fa-solid fa-trash-can icon"></i> Clear All</button>
<button class="tertiaryButton" id="show-download-popup"><i class="fa-solid fa-download"></i> Download images</button>
<div class="display-settings">
<button id="undo" class="displayNone tertiaryButton">
<button id="undo" class="displayNone primaryButton">
Undo <i class="fa-solid fa-rotate-left icon"></i>
<span class="simple-tooltip left">Undo last remove</span>
</button>

View File

@ -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