diff --git a/frontend/public/locales/en-GB/translation.toml b/frontend/public/locales/en-GB/translation.toml index 0c3b50619..772064c5f 100644 --- a/frontend/public/locales/en-GB/translation.toml +++ b/frontend/public/locales/en-GB/translation.toml @@ -4879,6 +4879,9 @@ applyRedactions = "Apply Redactions" applyWarning = "⚠️ Permanent application, cannot be undone and the data underneath will be deleted" boxRedaction = "Box draw redaction" colourPicker = "Colour Picker" +colorLabel = "Redaction Colour" +active = "Redaction Mode Active" +activate = "Activate Redaction Tool" controlsTitle = "Manual Redaction Controls" convertPDFToImageLabel = "Convert PDF to PDF-Image (Used to remove text behind the box)" export = "Export" diff --git a/frontend/src/core/components/tools/redact/ManualRedactionControls.tsx b/frontend/src/core/components/tools/redact/ManualRedactionControls.tsx index e522db943..4c0fa41ef 100644 --- a/frontend/src/core/components/tools/redact/ManualRedactionControls.tsx +++ b/frontend/src/core/components/tools/redact/ManualRedactionControls.tsx @@ -1,8 +1,7 @@ import { useTranslation } from 'react-i18next'; import { useEffect, useRef, useCallback } from 'react'; -import { Button, Stack, Text, Group, Divider } from '@mantine/core'; -import HighlightAltIcon from '@mui/icons-material/HighlightAlt'; -import CropFreeIcon from '@mui/icons-material/CropFree'; +import { Button, Stack, Text, Divider, ColorInput } from '@mantine/core'; +import AutoFixHighIcon from '@mui/icons-material/AutoFixHigh'; import { useRedaction, useRedactionMode } from '@app/contexts/RedactionContext'; import { useViewer } from '@app/contexts/ViewerContext'; import { useSignature } from '@app/contexts/SignatureContext'; @@ -19,8 +18,8 @@ export default function ManualRedactionControls({ disabled = false }: ManualReda const { t } = useTranslation(); // Use our RedactionContext which bridges to EmbedPDF - const { activateTextSelection, activateMarquee, redactionsApplied, setActiveType } = useRedaction(); - const { pendingCount, activeType, isBridgeReady } = useRedactionMode(); + const { activateManualRedact, redactionsApplied, setActiveType, setManualRedactColor } = useRedaction(); + const { pendingCount, activeType, isBridgeReady, isRedacting, manualRedactColor } = useRedactionMode(); // Get viewer context to manage annotation mode and save changes const { isAnnotationMode, setAnnotationMode, applyChanges, activeFileIndex } = useViewer(); @@ -28,9 +27,8 @@ export default function ManualRedactionControls({ disabled = false }: ManualReda // Get signature context to deactivate annotation tools when switching to redaction const { signatureApiRef } = useSignature(); - // Check which tool is active based on activeType - const isSelectionActive = activeType === 'redactSelection'; - const isMarqueeActive = activeType === 'marqueeRedact'; + // Check if redaction mode is active + const isRedactActive = isRedacting; // Track if we've auto-activated for the current bridge session const hasAutoActivated = useRef(false); @@ -47,12 +45,12 @@ export default function ManualRedactionControls({ disabled = false }: ManualReda const timer = setTimeout(() => { // Deactivate annotation mode to show redaction layer setAnnotationMode(false); - // Pre-select the Mark Text tool - activateTextSelection(); + // Pre-select the Redaction tool + activateManualRedact(); }, 150); return () => clearTimeout(timer); } - }, [isBridgeReady, disabled, activateTextSelection, setAnnotationMode]); + }, [isBridgeReady, disabled, activateManualRedact, setAnnotationMode]); // Reset auto-activation flag when disabled changes or bridge becomes not ready useEffect(() => { @@ -68,18 +66,16 @@ export default function ManualRedactionControls({ disabled = false }: ManualReda prevFileIndexRef.current = activeFileIndex; // Reset active type to null when switching files - // This makes both buttons appear unselected, requiring the user to re-click - // which ensures proper activation on the new PDF - if (isSelectionActive || isMarqueeActive) { + if (activeType) { setActiveType(null); } // Reset auto-activation flag so new file can auto-activate hasAutoActivated.current = false; } - }, [activeFileIndex, isSelectionActive, isMarqueeActive, setActiveType]); + }, [activeFileIndex, activeType, setActiveType]); - const handleSelectionClick = () => { + const handleRedactClick = () => { // Deactivate annotation mode and tools to switch to redaction layer if (isAnnotationMode) { setAnnotationMode(false); @@ -93,34 +89,7 @@ export default function ManualRedactionControls({ disabled = false }: ManualReda } } - if (isSelectionActive && !isAnnotationMode) { - // If already active and not coming from annotation mode, switch to marquee - activateMarquee(); - } else { - activateTextSelection(); - } - }; - - const handleMarqueeClick = () => { - // Deactivate annotation mode and tools to switch to redaction layer - if (isAnnotationMode) { - setAnnotationMode(false); - // Deactivate any active annotation tools (like draw) - if (signatureApiRef?.current) { - try { - signatureApiRef.current.deactivateTools(); - } catch (error) { - console.log('Unable to deactivate annotation tools:', error); - } - } - } - - if (isMarqueeActive && !isAnnotationMode) { - // If already active and not coming from annotation mode, switch to selection - activateTextSelection(); - } else { - activateMarquee(); - } + activateManualRedact(); }; // Handle saving changes - this will apply pending redactions and save to file @@ -149,43 +118,27 @@ export default function ManualRedactionControls({ disabled = false }: ManualReda {t('redact.manual.instructions', 'Select text or draw areas on the PDF to mark content for redaction.')} - - {/* Mark Text Selection Tool */} - + - {/* Mark Area (Marquee) Tool */} - - + {/* Save Changes Button - applies pending redactions and saves to file */}