drakosfire
commited on
Commit
•
b5f325d
1
Parent(s):
234b455
refactored, call unlockTextareas one time at end of handleDragEnd
Browse files- scripts.js +9 -6
scripts.js
CHANGED
@@ -433,6 +433,8 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
433 |
document.querySelectorAll('.highlight-page').forEach(el => el.classList.remove('highlight-page'));
|
434 |
document.querySelectorAll('.highlight-block').forEach(el => el.classList.remove('highlight-block'));
|
435 |
document.querySelectorAll('.highlight-block-top').forEach(el => el.classList.remove('highlight-block-top'));
|
|
|
|
|
436 |
}
|
437 |
|
438 |
function handleDragOver(e) {
|
@@ -499,7 +501,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
499 |
// Ensure the original block exists before proceeding
|
500 |
if (!originalBlock || !newPage) {
|
501 |
console.error(`Block with ID ${blockId} on page ${originalPageId} not found`);
|
502 |
-
|
503 |
return;
|
504 |
}
|
505 |
|
@@ -531,11 +533,11 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
531 |
if (offset > bounding.height / 2) {
|
532 |
console.log('Inserting after the target');
|
533 |
target.parentNode.insertBefore(newBlockContent, target.nextSibling);
|
534 |
-
|
535 |
} else {
|
536 |
console.log('Inserting before the target');
|
537 |
target.parentNode.insertBefore(newBlockContent, target);
|
538 |
-
|
539 |
}
|
540 |
|
541 |
// Remove highlight borders
|
@@ -544,7 +546,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
544 |
} else {
|
545 |
console.log('No valid drop target found, appending to the end');
|
546 |
newPage.querySelector('.block.monster.frame.wide').appendChild(newBlockContent);
|
547 |
-
|
548 |
}
|
549 |
|
550 |
// Remove the original block from the original container
|
@@ -800,7 +802,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
800 |
// Remove the "over" class and reset the background image
|
801 |
trashArea.classList.remove('over');
|
802 |
trashArea.style.backgroundImage = "url('./closed-mimic-trashcan.png')";
|
803 |
-
|
804 |
initializeTextareaResizing();
|
805 |
}
|
806 |
|
@@ -868,7 +870,8 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
868 |
}
|
869 |
|
870 |
|
871 |
-
|
|
|
872 |
pageContainer.addEventListener('dragover', handleDragOver);
|
873 |
pageContainer.addEventListener('drop', handleDrop);
|
874 |
|
|
|
433 |
document.querySelectorAll('.highlight-page').forEach(el => el.classList.remove('highlight-page'));
|
434 |
document.querySelectorAll('.highlight-block').forEach(el => el.classList.remove('highlight-block'));
|
435 |
document.querySelectorAll('.highlight-block-top').forEach(el => el.classList.remove('highlight-block-top'));
|
436 |
+
unlockTextareas()
|
437 |
+
|
438 |
}
|
439 |
|
440 |
function handleDragOver(e) {
|
|
|
501 |
// Ensure the original block exists before proceeding
|
502 |
if (!originalBlock || !newPage) {
|
503 |
console.error(`Block with ID ${blockId} on page ${originalPageId} not found`);
|
504 |
+
|
505 |
return;
|
506 |
}
|
507 |
|
|
|
533 |
if (offset > bounding.height / 2) {
|
534 |
console.log('Inserting after the target');
|
535 |
target.parentNode.insertBefore(newBlockContent, target.nextSibling);
|
536 |
+
|
537 |
} else {
|
538 |
console.log('Inserting before the target');
|
539 |
target.parentNode.insertBefore(newBlockContent, target);
|
540 |
+
|
541 |
}
|
542 |
|
543 |
// Remove highlight borders
|
|
|
546 |
} else {
|
547 |
console.log('No valid drop target found, appending to the end');
|
548 |
newPage.querySelector('.block.monster.frame.wide').appendChild(newBlockContent);
|
549 |
+
|
550 |
}
|
551 |
|
552 |
// Remove the original block from the original container
|
|
|
802 |
// Remove the "over" class and reset the background image
|
803 |
trashArea.classList.remove('over');
|
804 |
trashArea.style.backgroundImage = "url('./closed-mimic-trashcan.png')";
|
805 |
+
|
806 |
initializeTextareaResizing();
|
807 |
}
|
808 |
|
|
|
870 |
}
|
871 |
|
872 |
|
873 |
+
blockContainer.addEventListener('dragover', handleDragOver);
|
874 |
+
blockContainer.addEventListener('drop', handleDrop);
|
875 |
pageContainer.addEventListener('dragover', handleDragOver);
|
876 |
pageContainer.addEventListener('drop', handleDrop);
|
877 |
|