diff --git a/src/main/resources/static/js/redact.js b/src/main/resources/static/js/redact.js index b3c746495..c5411470a 100644 --- a/src/main/resources/static/js/redact.js +++ b/src/main/resources/static/js/redact.js @@ -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();