2025-09-08 11:09:11 +01:00
|
|
|
import { Stack, Divider, Text, NumberInput, Group, ColorInput } from "@mantine/core";
|
2025-09-08 10:18:45 +01:00
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import { RedactParameters } from "../../../hooks/tools/redact/useRedactParameters";
|
2025-09-08 11:09:11 +01:00
|
|
|
import WordsToRedactInput from "./WordsToRedactInput";
|
2025-09-08 10:18:45 +01:00
|
|
|
|
|
|
|
interface AutomaticRedactSettingsProps {
|
|
|
|
parameters: RedactParameters;
|
|
|
|
onParameterChange: <K extends keyof RedactParameters>(key: K, value: RedactParameters[K]) => void;
|
|
|
|
disabled?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
const AutomaticRedactSettings = ({ parameters, onParameterChange, disabled = false }: AutomaticRedactSettingsProps) => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Stack gap="md">
|
|
|
|
<Divider ml='-md' />
|
|
|
|
|
2025-09-08 11:09:11 +01:00
|
|
|
{/* Words to Redact */}
|
|
|
|
<WordsToRedactInput
|
|
|
|
wordsToRedact={parameters.wordsToRedact}
|
|
|
|
onWordsChange={(words) => onParameterChange('wordsToRedact', words)}
|
|
|
|
disabled={disabled}
|
|
|
|
/>
|
2025-09-08 10:18:45 +01:00
|
|
|
|
|
|
|
<Divider />
|
|
|
|
|
2025-09-08 11:09:11 +01:00
|
|
|
{/* Redaction Settings */}
|
2025-09-08 10:18:45 +01:00
|
|
|
<Stack gap="sm">
|
|
|
|
<Text size="sm" fw={500}>
|
2025-09-08 11:09:11 +01:00
|
|
|
{t('redact.auto.settings', 'Redaction Settings')}
|
2025-09-08 10:18:45 +01:00
|
|
|
</Text>
|
|
|
|
|
2025-09-08 11:09:11 +01:00
|
|
|
{/* Box Color */}
|
|
|
|
<Stack gap="sm">
|
2025-09-08 12:00:32 +01:00
|
|
|
<Text size="sm">{t('redact.auto.colorLabel', 'Box Colour')}</Text>
|
|
|
|
<ColorInput
|
|
|
|
value={parameters.redactColor}
|
|
|
|
onChange={(value) => onParameterChange('redactColor', value)}
|
|
|
|
disabled={disabled}
|
|
|
|
size="sm"
|
|
|
|
/>
|
|
|
|
</Stack>
|
|
|
|
|
|
|
|
{/* Box Padding */}
|
|
|
|
<Stack gap="sm">
|
|
|
|
<Text size="sm">{t('redact.auto.paddingLabel', 'Box Padding')}</Text>
|
|
|
|
<NumberInput
|
|
|
|
value={parameters.customPadding}
|
|
|
|
onChange={(value) => onParameterChange('customPadding', typeof value === 'number' ? value : 0.1)}
|
|
|
|
min={0}
|
|
|
|
max={10}
|
|
|
|
step={0.1}
|
|
|
|
disabled={disabled}
|
|
|
|
size="sm"
|
|
|
|
placeholder="0.1"
|
|
|
|
/>
|
2025-09-08 11:09:11 +01:00
|
|
|
</Stack>
|
2025-09-08 10:18:45 +01:00
|
|
|
|
2025-09-08 11:09:11 +01:00
|
|
|
{/* Use Regex */}
|
2025-09-08 10:18:45 +01:00
|
|
|
<label
|
|
|
|
style={{ display: 'flex', alignItems: 'center', gap: '8px' }}
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
checked={parameters.useRegex}
|
|
|
|
onChange={(e) => onParameterChange('useRegex', e.target.checked)}
|
|
|
|
disabled={disabled}
|
|
|
|
/>
|
|
|
|
<Text size="sm">{t('redact.auto.useRegexLabel', 'Use Regex')}</Text>
|
|
|
|
</label>
|
|
|
|
|
2025-09-08 11:09:11 +01:00
|
|
|
{/* Whole Word Search */}
|
2025-09-08 10:18:45 +01:00
|
|
|
<label
|
|
|
|
style={{ display: 'flex', alignItems: 'center', gap: '8px' }}
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
checked={parameters.wholeWordSearch}
|
|
|
|
onChange={(e) => onParameterChange('wholeWordSearch', e.target.checked)}
|
|
|
|
disabled={disabled}
|
|
|
|
/>
|
|
|
|
<Text size="sm">{t('redact.auto.wholeWordSearchLabel', 'Whole Word Search')}</Text>
|
|
|
|
</label>
|
|
|
|
|
2025-09-08 11:09:11 +01:00
|
|
|
{/* Convert PDF to PDF-Image */}
|
2025-09-08 10:18:45 +01:00
|
|
|
<label
|
|
|
|
style={{ display: 'flex', alignItems: 'center', gap: '8px' }}
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
checked={parameters.convertPDFToImage}
|
|
|
|
onChange={(e) => onParameterChange('convertPDFToImage', e.target.checked)}
|
|
|
|
disabled={disabled}
|
|
|
|
/>
|
|
|
|
<Text size="sm">{t('redact.auto.convertPDFToImageLabel', 'Convert PDF to PDF-Image (Used to remove text behind the box)')}</Text>
|
|
|
|
</label>
|
|
|
|
</Stack>
|
|
|
|
</Stack>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default AutomaticRedactSettings;
|