-
+
+
{#if activeAnnotationId}
-
-
+
+ {m.doc_panel_tab_discussion()}
+ {#if docCommentCount > 0}
+
+ {docCommentCount}
+
+ {/if}
+
+
+
+ {/if}
+
+
+
+ {#if !activeAnnotationId || activeSubTab === 'document'}
+
+ (docCommentCount = count)}
+ />
+ {:else}
+
{#key activeAnnotationId}
onAnnotationCommentCountChange?.(activeAnnotationId, count)}
/>
{/key}
-
- {/if}
-
-
-
- {#if activeAnnotationId}
-
- {m.comment_section_title()}
-
{/if}
-
diff --git a/frontend/src/lib/components/PdfViewer.svelte b/frontend/src/lib/components/PdfViewer.svelte
index 2ac3e6b2..5f15bc9a 100644
--- a/frontend/src/lib/components/PdfViewer.svelte
+++ b/frontend/src/lib/components/PdfViewer.svelte
@@ -9,12 +9,14 @@ let {
documentId = '',
annotateMode = $bindable(false),
activeAnnotationId = $bindable
(null),
+ activeAnnotationPage = $bindable(null),
onAnnotationClick
}: {
url: string;
documentId?: string;
annotateMode?: boolean;
activeAnnotationId?: string | null;
+ activeAnnotationPage?: number | null;
onAnnotationClick?: (id: string) => void;
} = $props();
@@ -213,6 +215,7 @@ async function handleAnnotationDraw(rect: { x: number; y: number; width: number;
const created: Annotation = await res.json();
annotations = [...annotations, created];
activeAnnotationId = created.id;
+ activeAnnotationPage = created.pageNumber;
onAnnotationClick?.(created.id);
}
} catch {
@@ -236,6 +239,8 @@ async function handleAnnotationDelete(annotationId: string) {
function handleAnnotationClick(id: string) {
activeAnnotationId = id;
+ const ann = annotations.find((a) => a.id === id);
+ activeAnnotationPage = ann?.pageNumber ?? null;
onAnnotationClick?.(id);
}
diff --git a/frontend/src/routes/documents/[id]/+page.svelte b/frontend/src/routes/documents/[id]/+page.svelte
index d2f96141..e5c820d6 100644
--- a/frontend/src/routes/documents/[id]/+page.svelte
+++ b/frontend/src/routes/documents/[id]/+page.svelte
@@ -56,6 +56,7 @@ async function loadFile(id: string) {
let annotateMode = $state(false);
let activeAnnotationId = $state(null);
+let activeAnnotationPage = $state(null);
// When an annotation is clicked, open the Diskussion tab.
$effect(() => {
@@ -97,6 +98,19 @@ onMount(() => {
}
localStorageRestored = true;
+
+ function onKeyDown(e: KeyboardEvent) {
+ if (e.key === 'Escape') {
+ if (activeAnnotationId) {
+ activeAnnotationId = null;
+ activeAnnotationPage = null;
+ } else if (panelOpen) {
+ panelOpen = false;
+ }
+ }
+ }
+ document.addEventListener('keydown', onKeyDown);
+ return () => document.removeEventListener('keydown', onKeyDown);
});
// Persist panel state whenever it changes (after initial restore).
@@ -129,6 +143,7 @@ $effect(() => {
error={fileError}
bind:annotateMode={annotateMode}
bind:activeAnnotationId={activeAnnotationId}
+ bind:activeAnnotationPage={activeAnnotationPage}
onAnnotationClick={(id) => {
activeAnnotationId = id;
}}
@@ -146,4 +161,9 @@ $effect(() => {
bind:height={panelHeight}
bind:activeTab={activeTab}
activeAnnotationId={activeAnnotationId}
+ activeAnnotationPage={activeAnnotationPage}
+ onClearAnnotation={() => {
+ activeAnnotationId = null;
+ activeAnnotationPage = null;
+ }}
/>