Fix for propergating events causing multiple redaction boxes

This commit is contained in:
Connor Yoh 2025-04-09 16:11:51 +01:00
parent 18d9f8767b
commit 95edb92869

View File

@ -317,11 +317,27 @@ window.addEventListener('load', (e) => {
redactionsPaletteContainer.onclick = (e) => redactionsPalette.click();
function clearSelection() {
if (window.getSelection) {
if (window.getSelection().empty) {
// Chrome
window.getSelection().empty();
} else if (window.getSelection().removeAllRanges) {
// Firefox
window.getSelection().removeAllRanges();
}
} else if (document.selection) {
// IE?
document.selection.empty();
}
}
viewer.onmouseup = (e) => {
if (redactionMode !== RedactionModes.TEXT) return;
const containsText = window.getSelection() && window.getSelection().toString() != '';
if(containsText){
redactTextSelection();
clearSelection();
}
};
@ -427,21 +443,6 @@ window.addEventListener('load', (e) => {
clearSelection();
}
function clearSelection() {
if (window.getSelection) {
if (window.getSelection().empty) {
// Chrome
window.getSelection().empty();
} else if (window.getSelection().removeAllRanges) {
// Firefox
window.getSelection().removeAllRanges();
}
} else if (document.selection) {
// IE?
document.selection.empty();
}
}
function _handleDrawRedactionBtnClick(e) {
if (drawRedactionBtn.classList.contains('toggled')) {
resetDrawRedactions();