From 30bcc38c0498aaae0463ef5544660ab175888b17 Mon Sep 17 00:00:00 2001 From: Reece Browne <74901996+reecebrowne@users.noreply.github.com> Date: Mon, 24 Nov 2025 13:37:35 +0000 Subject: [PATCH 1/2] Feature/v2/add text (#4951) Refactor sign to separate out add text and add image functions. Implement add text as standalone tool --- .../public/locales/en-GB/translation.json | 59 ++++- .../annotation/shared/DrawingCanvas.tsx | 1 - .../annotation/shared/TextInputWithFont.tsx | 21 +- .../tools/sign/SavedSignaturesSection.tsx | 55 ++-- .../components/tools/sign/SignSettings.tsx | 229 ++++++++++------ .../core/components/viewer/EmbedPdfViewer.tsx | 7 +- .../components/viewer/SignatureAPIBridge.tsx | 65 ++++- .../viewer/StampPlacementOverlay.tsx | 171 ++++++++++++ .../core/data/useTranslatedToolRegistry.tsx | 13 + .../hooks/tools/sign/useSavedSignatures.ts | 7 +- frontend/src/core/tools/AddText.tsx | 12 + frontend/src/core/tools/Sign.tsx | 214 +-------------- .../src/core/tools/stamp/createStampTool.tsx | 249 ++++++++++++++++++ frontend/src/core/types/toolId.ts | 2 +- frontend/src/core/utils/urlMapping.ts | 1 + 15 files changed, 780 insertions(+), 326 deletions(-) create mode 100644 frontend/src/core/components/viewer/StampPlacementOverlay.tsx create mode 100644 frontend/src/core/tools/AddText.tsx create mode 100644 frontend/src/core/tools/stamp/createStampTool.tsx diff --git a/frontend/public/locales/en-GB/translation.json b/frontend/public/locales/en-GB/translation.json index 1942cdb2a0..ba09ada234 100644 --- a/frontend/public/locales/en-GB/translation.json +++ b/frontend/public/locales/en-GB/translation.json @@ -855,6 +855,11 @@ "overlay-pdfs": { "desc": "Overlay one PDF on top of another", "title": "Overlay PDFs" + }, + "addText": { + "tags": "text,annotation,label", + "title": "Add Text", + "desc": "Add custom text anywhere in your PDF" } }, "landing": { @@ -2152,8 +2157,8 @@ "colorPickerTitle": "Choose stroke colour" }, "text": { - "name": "Signer Name", - "placeholder": "Enter your full name", + "name": "Text", + "placeholder": "Enter text", "fontLabel": "Font", "fontSizeLabel": "Font size", "fontSizePlaceholder": "Type or select font size (8-200)", @@ -2421,8 +2426,12 @@ "selection": { "originalEditedTitle": "Select Original and Edited PDFs" }, - "original": { "label": "Original PDF" }, - "edited": { "label": "Edited PDF" }, + "original": { + "label": "Original PDF" + }, + "edited": { + "label": "Edited PDF" + }, "swap": { "confirmTitle": "Re-run comparison?", "confirmBody": "This will rerun the tool. Are you sure you want to swap the order of Original and Edited?", @@ -5751,5 +5760,45 @@ "pleaseLoginAgain": "Please login again.", "accessDenied": "Access Denied", "insufficientPermissions": "You do not have permission to perform this action." + }, + "addText": { + "title": "Add Text", + "header": "Add text to PDFs", + "text": { + "name": "Text content", + "placeholder": "Enter the text you want to add", + "fontLabel": "Font", + "fontSizeLabel": "Font size", + "fontSizePlaceholder": "Type or select font size (8-200)", + "colorLabel": "Text colour" + }, + "steps": { + "configure": "Configure Text" + }, + "step": { + "createDesc": "Enter the text you want to add", + "place": "Place text", + "placeDesc": "Click on the PDF to add your text" + }, + "instructions": { + "title": "How to add text", + "text": "After entering your text above, click anywhere on the PDF to place it.", + "paused": "Placement paused", + "resumeHint": "Resume placement to click and add your text.", + "noSignature": "Enter text above to enable placement." + }, + "mode": { + "move": "Move Text", + "place": "Place Text", + "pause": "Pause placement", + "resume": "Resume placement" + }, + "results": { + "title": "Add Text Results" + }, + "error": { + "failed": "An error occurred while adding text to the PDF." + }, + "tags": "text,annotation,label" } -} +} \ No newline at end of file diff --git a/frontend/src/core/components/annotation/shared/DrawingCanvas.tsx b/frontend/src/core/components/annotation/shared/DrawingCanvas.tsx index cf13532f17..7e3324a97b 100644 --- a/frontend/src/core/components/annotation/shared/DrawingCanvas.tsx +++ b/frontend/src/core/components/annotation/shared/DrawingCanvas.tsx @@ -206,7 +206,6 @@ export const DrawingCanvas: React.FC = ({ if (!initialSignatureData) { ctx.clearRect(0, 0, canvas.width, canvas.height); setSavedSignatureData(null); - return; } diff --git a/frontend/src/core/components/annotation/shared/TextInputWithFont.tsx b/frontend/src/core/components/annotation/shared/TextInputWithFont.tsx index c700d4d056..c93a89be00 100644 --- a/frontend/src/core/components/annotation/shared/TextInputWithFont.tsx +++ b/frontend/src/core/components/annotation/shared/TextInputWithFont.tsx @@ -15,6 +15,7 @@ interface TextInputWithFontProps { disabled?: boolean; label?: string; placeholder?: string; + onAnyChange?: () => void; } export const TextInputWithFont: React.FC = ({ @@ -28,7 +29,8 @@ export const TextInputWithFont: React.FC = ({ onTextColorChange, disabled = false, label, - placeholder + placeholder, + onAnyChange }) => { const { t } = useTranslation(); const [fontSizeInput, setFontSizeInput] = useState(fontSize.toString()); @@ -67,7 +69,10 @@ export const TextInputWithFont: React.FC = ({ label={label || t('sign.text.name', 'Signer name')} placeholder={placeholder || t('sign.text.placeholder', 'Enter your full name')} value={text} - onChange={(e) => onTextChange(e.target.value)} + onChange={(e) => { + onTextChange(e.target.value); + onAnyChange?.(); + }} disabled={disabled} required /> @@ -76,7 +81,10 @@ export const TextInputWithFont: React.FC = ({