From c9b4e6dad4f1f70fc3ba185b9a4df2c2526493d4 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 24 Mar 2026 22:59:53 +0100 Subject: [PATCH] feat(frontend): add annotation visibility toggle to PDF toolbar Eye/eye-slash button in the PDF controls bar lets the user hide all annotation highlights to read the document unobstructed and show them again with one click. - Button only renders when at least one annotation exists - Active state (hidden) highlighted with brand-mint/bg-white/10 so the current state is always clear - i18n keys added for de/en/es Co-Authored-By: Claude Sonnet 4.6 --- frontend/messages/de.json | 4 +- frontend/messages/en.json | 4 +- frontend/messages/es.json | 4 +- frontend/src/lib/components/PdfViewer.svelte | 69 +++++++++++++++++--- 4 files changed, 69 insertions(+), 12 deletions(-) diff --git a/frontend/messages/de.json b/frontend/messages/de.json index 6004793b..6d663f90 100644 --- a/frontend/messages/de.json +++ b/frontend/messages/de.json @@ -258,5 +258,7 @@ "doc_panel_annotate": "Annotieren", "doc_panel_annotate_stop": "Fertig", "doc_panel_annotation_thread_title": "Annotation", - "doc_panel_discussion_annotation_tab": "Annotation · Seite {page}" + "doc_panel_discussion_annotation_tab": "Annotation · Seite {page}", + "pdf_annotations_show": "Annotierungen anzeigen", + "pdf_annotations_hide": "Annotierungen verbergen" } diff --git a/frontend/messages/en.json b/frontend/messages/en.json index c4669686..92ce9ceb 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -258,5 +258,7 @@ "doc_panel_annotate": "Annotate", "doc_panel_annotate_stop": "Done", "doc_panel_annotation_thread_title": "Annotation", - "doc_panel_discussion_annotation_tab": "Annotation · Page {page}" + "doc_panel_discussion_annotation_tab": "Annotation · Page {page}", + "pdf_annotations_show": "Show annotations", + "pdf_annotations_hide": "Hide annotations" } diff --git a/frontend/messages/es.json b/frontend/messages/es.json index 7e9ff8e8..8e3dd84b 100644 --- a/frontend/messages/es.json +++ b/frontend/messages/es.json @@ -258,5 +258,7 @@ "doc_panel_annotate": "Anotar", "doc_panel_annotate_stop": "Listo", "doc_panel_annotation_thread_title": "Anotación", - "doc_panel_discussion_annotation_tab": "Anotación · Página {page}" + "doc_panel_discussion_annotation_tab": "Anotación · Página {page}", + "pdf_annotations_show": "Mostrar anotaciones", + "pdf_annotations_hide": "Ocultar anotaciones" } diff --git a/frontend/src/lib/components/PdfViewer.svelte b/frontend/src/lib/components/PdfViewer.svelte index 5f15bc9a..6c3deb33 100644 --- a/frontend/src/lib/components/PdfViewer.svelte +++ b/frontend/src/lib/components/PdfViewer.svelte @@ -3,6 +3,7 @@ import { onMount } from 'svelte'; import { SvelteMap } from 'svelte/reactivity'; import type { PDFDocumentProxy, PDFPageProxy, RenderTask } from 'pdfjs-dist'; import AnnotationLayer from './AnnotationLayer.svelte'; +import { m } from '$lib/paraglide/messages.js'; let { url, @@ -55,6 +56,7 @@ type Annotation = { let annotations = $state([]); let annotateColor = $state('#ffff00'); let commentCounts = new SvelteMap(); +let showAnnotations = $state(true); onMount(async () => { // Dynamic import keeps pdfjs out of the SSR bundle entirely @@ -403,6 +405,53 @@ function zoomOut() { {/if} + + {#if annotations.length > 0} + + {/if} +
{#if loading} @@ -424,15 +473,17 @@ function zoomOut() { class="textLayer" style="position: absolute; top: 0; left: 0; overflow: hidden; pointer-events: none; line-height: 1;" >
- a.pageNumber === currentPage)} - canAnnotate={annotateMode} - color={annotateColor} - onDraw={handleAnnotationDraw} - onDelete={handleAnnotationDelete} - commentCounts={Object.fromEntries(commentCounts)} - onAnnotationClick={handleAnnotationClick} - /> + {#if showAnnotations} + a.pageNumber === currentPage)} + canAnnotate={annotateMode} + color={annotateColor} + onDraw={handleAnnotationDraw} + onDelete={handleAnnotationDelete} + commentCounts={Object.fromEntries(commentCounts)} + onAnnotationClick={handleAnnotationClick} + /> + {/if} {/if}