import { useZoom } from "../zoomPlugin/ZoomContext.js"; import { useRedactContext } from "./RedactContext.js"; import { normRect } from "./useRedactTool.js"; /** * Canvas-area overlay for the redact tool. * Uses an SVG layer over the image for drawing; blur preview uses SVG feGaussianBlur * so the live preview matches the final applied output. */ export function RedactOverlay() { let { imageUrl, rects, drawing, displaySize, handleImageLoad, startDrawing, updateDrawing, finishDrawing, deleteRect, } = useRedactContext(); let { zoom } = useZoom(); let inProgress = drawing ? normRect(drawing) : null; function onPointerDown(e: React.PointerEvent) { e.currentTarget.setPointerCapture(e.pointerId); let b = e.currentTarget.getBoundingClientRect(); startDrawing((e.clientX - b.left) / zoom, (e.clientY - b.top) / zoom); } function onPointerMove(e: React.PointerEvent) { if (!(e.buttons & 1)) return; let b = e.currentTarget.getBoundingClientRect(); updateDrawing((e.clientX - b.left) / zoom, (e.clientY - b.top) / zoom); } return (
{displaySize.width > 0 && ( {rects.map((_, i) => ( ))} {inProgress && ( )} {/* Blur each confirmed rect using the real image, clipped to the rect */} {rects.map((r, i) => ( {/* Semi-opaque overlay to prevent text from being readable through the blur */} {/* Dashed border + invisible hit area for deletion */} { e.stopPropagation(); deleteRect(i); }} /> ))} {/* In-progress rect */} {inProgress && ( <> )} )}
); }