feat(transcription): add block-level comment threads with quote support
Some checks failed
CI / Unit & Component Tests (push) Has been cancelled
CI / Backend Unit Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Unit & Component Tests (pull_request) Failing after 1m33s
CI / Backend Unit Tests (pull_request) Failing after 2m47s
CI / E2E Tests (pull_request) Failing after 19m44s

TranscriptionBlock.svelte:
- "Kommentieren" button opens expandable comment thread per block
- Text selection in textarea captured as quoted text (> "...") prefix
- Quote hint "Text markieren für Zitat" shown when block is active/focused
- Comment thread uses existing CommentThread with blockId prop

CommentThread.svelte:
- Add blockId prop for block-level comments URL routing
- Add quotedText prop — pre-fills comment input with markdown blockquote
- commentsBase now supports 3 URL patterns: document, annotation, block

TranscriptionEditView.svelte:
- Pass canComment + currentUserId through to block components

3 new frontend tests:
- Kommentieren button present
- Quote hint shown when active
- Quote hint hidden when inactive

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-05 21:05:39 +02:00
parent da43cadb0a
commit 8c26876345
5 changed files with 126 additions and 6 deletions

View File

@@ -1,15 +1,19 @@
<script lang="ts">
import { m } from '$lib/paraglide/messages.js';
import CommentThread from './CommentThread.svelte';
type SaveState = 'idle' | 'saving' | 'saved' | 'fading' | 'error';
type Props = {
blockId: string;
documentId: string;
blockNumber: number;
text: string;
label: string | null;
active: boolean;
saveState: SaveState;
canComment: boolean;
currentUserId: string | null;
onTextChange: (text: string) => void;
onFocus: () => void;
onDeleteClick: () => void;
@@ -18,22 +22,30 @@ type Props = {
let {
blockId,
documentId,
blockNumber,
text,
label = null,
active,
saveState,
canComment,
currentUserId,
onTextChange,
onFocus,
onDeleteClick,
onRetry
}: Props = $props();
let commentOpen = $state(false);
let selectedQuote = $state<string | null>(null);
let textareaEl = $state<HTMLTextAreaElement | null>(null);
let leftBorderClass = $derived(
saveState === 'error' ? 'border-l-2 border-error' : active ? 'border-l-2 border-turquoise' : ''
);
function autoresize(node: HTMLTextAreaElement) {
textareaEl = node;
function resize() {
node.style.height = 'auto';
node.style.height = `${node.scrollHeight}px`;
@@ -45,7 +57,9 @@ function autoresize(node: HTMLTextAreaElement) {
update() {
resize();
},
destroy() {}
destroy() {
textareaEl = null;
}
};
}
@@ -59,6 +73,19 @@ function handleDelete() {
onDeleteClick();
}
}
function captureSelectionAndOpenComments() {
if (textareaEl) {
const start = textareaEl.selectionStart;
const end = textareaEl.selectionEnd;
if (start !== end) {
selectedQuote = textareaEl.value.substring(start, end);
} else {
selectedQuote = null;
}
}
commentOpen = true;
}
</script>
<div
@@ -93,7 +120,22 @@ function handleDelete() {
></textarea>
<!-- Footer -->
<div class="flex items-center justify-end border-t border-line pt-2">
<div class="flex items-center justify-between border-t border-line pt-2">
<div class="flex flex-col gap-1">
<button
type="button"
class="text-xs font-medium text-ink-2 transition-colors hover:text-ink"
onclick={captureSelectionAndOpenComments}
>
{m.transcription_block_comment_btn()}
</button>
{#if active}
<span class="text-xs text-ink-3">
{m.transcription_block_quote_hint()}
</span>
{/if}
</div>
<div class="flex items-center gap-2">
<!-- Save state indicator -->
{#if saveState === 'saving'}
@@ -143,5 +185,35 @@ function handleDelete() {
</button>
</div>
</div>
<!-- Comment thread (expandable) -->
{#if commentOpen}
<div class="mt-3 border-t border-line pt-3">
<div class="mb-2 flex items-center justify-between">
<span class="font-sans text-xs font-semibold text-ink-2">
{m.comment_section_title()}
</span>
<button
type="button"
class="font-sans text-xs text-ink-3 transition-colors hover:text-ink"
onclick={() => {
commentOpen = false;
selectedQuote = null;
}}
>
{m.comment_panel_close()}
</button>
</div>
<CommentThread
documentId={documentId}
blockId={blockId}
loadOnMount={true}
canComment={canComment}
currentUserId={currentUserId}
canAdmin={false}
quotedText={selectedQuote}
/>
</div>
{/if}
</div>
</div>