Merge pull request #862 from JeLuF/dragfix

Fix task reordering
This commit is contained in:
cmdr2 2023-02-12 14:40:21 +05:30 committed by GitHub
commit 04e8458ce2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -528,7 +528,7 @@ function dragOverHandler(ev) {
ev.dataTransfer.dropEffect = "copy"
let img = new Image()
img.src = location.host + '/media/images/favicon-32x32.png'
img.src = '//' + location.host + '/media/images/favicon-32x32.png'
ev.dataTransfer.setDragImage(img, 16, 16)
}

View File

@ -79,7 +79,7 @@ imagePreview.addEventListener('drop', function(ev) {
}
ev.preventDefault()
let moveTarget = ev.target
while (moveTarget && typeof moveTarget === 'object' && moveTarget.parentNode !== imagePreview) {
while (moveTarget && typeof moveTarget === 'object' && moveTarget.parentNode !== imagePreviewContent) {
moveTarget = moveTarget.parentNode
}
if (moveTarget === initialText || moveTarget === previewTools) {
@ -89,17 +89,17 @@ imagePreview.addEventListener('drop', function(ev) {
return
}
if (moveTarget) {
const childs = Array.from(imagePreview.children)
const childs = Array.from(imagePreviewContent.children)
if (moveTarget.nextSibling && childs.indexOf(movedTask) < childs.indexOf(moveTarget)) {
// Move after the target if lower than current position.
moveTarget = moveTarget.nextSibling
}
}
const newNode = imagePreview.insertBefore(movedTask, moveTarget || previewTools.nextSibling)
const newNode = imagePreviewContent.insertBefore(movedTask, moveTarget || previewTools.nextSibling)
if (newNode === movedTask) {
return
}
imagePreview.removeChild(movedTask)
imagePreviewContent.removeChild(movedTask)
const task = htmlTaskMap.get(movedTask)
if (task) {
htmlTaskMap.delete(movedTask)