diff --git a/unredact/app.py b/unredact/app.py index 6b6c3b9..012a717 100644 --- a/unredact/app.py +++ b/unredact/app.py @@ -17,7 +17,7 @@ from PIL import Image, ImageFont from sse_starlette.sse import EventSourceResponse from unredact.pipeline.rasterize import rasterize_pdf -from unredact.pipeline.detect_redactions import detect_redactions, spot_redaction +from unredact.pipeline.detect_redactions import spot_redaction from unredact.pipeline.ocr import ocr_page from unredact.pipeline.font_detect import detect_font_for_line, CANDIDATE_FONTS, _find_font_path from unredact.pipeline.solver import build_constraint, SolveResult diff --git a/unredact/static/app.js b/unredact/static/app.js index 7dedc60..4d24206 100644 --- a/unredact/static/app.js +++ b/unredact/static/app.js @@ -915,6 +915,18 @@ rightPanel.addEventListener("dblclick", async (e) => { const data = await resp.json(); const box = data.box; + + // De-duplicate: if a redaction with the same box already exists, just activate it + const existingDup = Object.values(state.redactions).find(r => + r.page === state.currentPage && + Math.abs(r.x - box.x) < 3 && Math.abs(r.y - box.y) < 3 && + Math.abs(r.w - box.w) < 3 && Math.abs(r.h - box.h) < 3 + ); + if (existingDup) { + activateRedaction(existingDup.id); + return; + } + const id = "m" + Date.now().toString(36); state.redactions[id] = {