Text based redaction configured by default

Redaction applied as soon as text highlighted
Removed  Apply button
This commit is contained in:
Connor Yoh 2025-04-09 15:04:26 +01:00
parent ec77123789
commit 9c1e04425f
3 changed files with 12 additions and 55 deletions

View File

@ -172,26 +172,6 @@ html {
height: 0; height: 0;
} }
#apply-redaction {
height: var(--toolButton-height);
width: var(--toolButton-width);
border-radius: var(--toolButton-border-radius);
}
#apply-redaction[disabled=true], #apply-redaction:disabled:not([disabled=false]) {
color: rgb(147, 149, 153);
box-shadow: none !important;
}
#apply-redaction:is(:hover):not([disabled=true], :disabled:not([disabled=false])) {
cursor: pointer;
background-color: rgba(6, 114, 197, 0.82);
color: rgb(14, 12, 12);
outline:rgba(6, 114, 197, 0.82) !important;
border-color: rgba(6, 114, 197, 0.82) !important;
}
.toolbar-btn-hover:hover { .toolbar-btn-hover:hover {
cursor: pointer; cursor: pointer;
background-color: rgba(6, 114, 197, 0.82) !important; background-color: rgba(6, 114, 197, 0.82) !important;
@ -200,15 +180,6 @@ html {
border-color: rgba(6, 114, 197, 0.82) !important; border-color: rgba(6, 114, 197, 0.82) !important;
} }
#apply-redaction-icon {
font-size: var(--toolButton-icon-font-size);
}
#apply-redaction > span {
user-select: none;
pointer-events: none;
}
#pageRedactColor, input[data-for=pageRedactColor] { #pageRedactColor, input[data-for=pageRedactColor] {
flex: 1; flex: 1;
padding: 1px; padding: 1px;

View File

@ -206,8 +206,6 @@ window.addEventListener('load', (e) => {
let redactionsPaletteContainer = document.getElementById('redactionsPaletteContainer'); let redactionsPaletteContainer = document.getElementById('redactionsPaletteContainer');
let applyRedactionBtn = document.getElementById('apply-redaction');
let redactedPagesDetails = { let redactedPagesDetails = {
numbers: new Set(), numbers: new Set(),
ranges: new Set(), ranges: new Set(),
@ -249,7 +247,6 @@ window.addEventListener('load', (e) => {
displayFieldErrorMessages(input, errors); displayFieldErrorMessages(input, errors);
} else { } else {
pageBasedRedactionOverlay.classList.add('d-none'); pageBasedRedactionOverlay.classList.add('d-none');
applyRedactionBtn.removeAttribute('disabled');
input.classList.remove('is-valid'); input.classList.remove('is-valid');
let totalPagesCount = PDFViewerApplication.pdfViewer.pagesCount; let totalPagesCount = PDFViewerApplication.pdfViewer.pagesCount;
@ -323,16 +320,9 @@ window.addEventListener('load', (e) => {
viewer.onmouseup = (e) => { viewer.onmouseup = (e) => {
if (redactionMode !== RedactionModes.TEXT) return; if (redactionMode !== RedactionModes.TEXT) return;
const containsText = window.getSelection() && window.getSelection().toString() != ''; const containsText = window.getSelection() && window.getSelection().toString() != '';
applyRedactionBtn.disabled = !containsText; if(containsText){
}; redactTextSelection();
applyRedactionBtn.onclick = (e) => {
if (redactionMode !== RedactionModes.TEXT) {
applyRedactionBtn.disabled = true;
return;
} }
redactTextSelection();
applyRedactionBtn.disabled = true;
}; };
redactionsPaletteInput.onchange = (e) => { redactionsPaletteInput.onchange = (e) => {
@ -413,26 +403,28 @@ window.addEventListener('load', (e) => {
}; };
initDraw(layer, redactionsContainer); initDraw(layer, redactionsContainer);
enableTextRedactionMode();
function _handleTextSelectionRedactionBtnClick(e) { function _handleTextSelectionRedactionBtnClick(e) {
if (textSelectionRedactionBtn.classList.contains('toggled')) { if (textSelectionRedactionBtn.classList.contains('toggled')) {
resetTextSelection(); resetTextSelection();
} else { } else {
resetDrawRedactions(); enableTextRedactionMode();
textSelectionRedactionBtn.classList.add('toggled');
redactionMode = RedactionModes.TEXT;
const containsText = window.getSelection() && window.getSelection().toString() != '';
applyRedactionBtn.disabled = !containsText;
applyRedactionBtn.classList.remove('d-none');
} }
} }
function enableTextRedactionMode() {
if(!textSelectionRedactionBtn.classList.contains('toggled')){
textSelectionRedactionBtn.classList.add('toggled');
}
resetDrawRedactions();
redactionMode = RedactionModes.TEXT;
};
function resetTextSelection() { function resetTextSelection() {
textSelectionRedactionBtn.classList.remove('toggled'); textSelectionRedactionBtn.classList.remove('toggled');
redactionMode = RedactionModes.NONE; redactionMode = RedactionModes.NONE;
clearSelection(); clearSelection();
applyRedactionBtn.disabled = true;
applyRedactionBtn.classList.add('d-none');
} }
function clearSelection() { function clearSelection() {
@ -791,7 +783,6 @@ window.addEventListener('load', (e) => {
} }
_setRedactionsInput(redactions); _setRedactionsInput(redactions);
applyRedactionBtn.disabled = true;
} }
function _scaleToDisplay(value) { function _scaleToDisplay(value) {

View File

@ -453,11 +453,6 @@
<input type="color" name="color-picker"> <input type="color" name="color-picker">
</label> </label>
</button> </button>
<button id="apply-redaction" th:title="#{redact.applyChanges}" class="btn-success d-none" disabled>
<span id="apply-redaction-icon" class="material-symbols-rounded">
check
</span>
</button>
</div> </div>
<div id="toolbarViewerRight"> <div id="toolbarViewerRight">
<div class="splitToolbarButton"> <div class="splitToolbarButton">