From b21778b3d18c24706c3e2f7e60b5982d68a3e223 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 5 Apr 2026 20:22:35 +0200 Subject: [PATCH] refactor(types): extract TranscriptionBlockData to shared types Move duplicated type definition from TranscriptionEditView.svelte and +page.svelte into $lib/types.ts for single source of truth. Fixes @Felix: "Consider extracting the TranscriptionBlockData type" Co-Authored-By: Claude Sonnet 4.6 --- .../src/lib/components/TranscriptionEditView.svelte | 11 +---------- frontend/src/lib/types.ts | 10 ++++++++++ frontend/src/routes/documents/[id]/+page.svelte | 11 +---------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/frontend/src/lib/components/TranscriptionEditView.svelte b/frontend/src/lib/components/TranscriptionEditView.svelte index 77a2f742..08d2652f 100644 --- a/frontend/src/lib/components/TranscriptionEditView.svelte +++ b/frontend/src/lib/components/TranscriptionEditView.svelte @@ -2,16 +2,7 @@ import { m } from '$lib/paraglide/messages.js'; import { SvelteMap } from 'svelte/reactivity'; import TranscriptionBlock from './TranscriptionBlock.svelte'; - -type TranscriptionBlockData = { - id: string; - annotationId: string; - documentId: string; - text: string; - label: string | null; - sortOrder: number; - version: number; -}; +import type { TranscriptionBlockData } from '$lib/types'; type SaveState = 'idle' | 'saving' | 'saved' | 'error'; diff --git a/frontend/src/lib/types.ts b/frontend/src/lib/types.ts index a2144e40..490f5352 100644 --- a/frontend/src/lib/types.ts +++ b/frontend/src/lib/types.ts @@ -27,6 +27,16 @@ export type Comment = { export type DocumentPanelTab = 'metadata' | 'transcription' | 'discussion' | 'history'; +export type TranscriptionBlockData = { + id: string; + annotationId: string; + documentId: string; + text: string; + label: string | null; + sortOrder: number; + version: number; +}; + export type Annotation = { id: string; documentId: string; diff --git a/frontend/src/routes/documents/[id]/+page.svelte b/frontend/src/routes/documents/[id]/+page.svelte index c95dc4de..e71593e0 100644 --- a/frontend/src/routes/documents/[id]/+page.svelte +++ b/frontend/src/routes/documents/[id]/+page.svelte @@ -5,6 +5,7 @@ import DocumentTopBar from '$lib/components/DocumentTopBar.svelte'; import DocumentViewer from '$lib/components/DocumentViewer.svelte'; import AnnotationSidePanel from '$lib/components/AnnotationSidePanel.svelte'; import TranscriptionEditView from '$lib/components/TranscriptionEditView.svelte'; +import type { TranscriptionBlockData } from '$lib/types'; let { data } = $props(); @@ -65,16 +66,6 @@ let activeAnnotationPage = $state(null); // ── Transcription blocks ───────────────────────────────────────────────────── -type TranscriptionBlockData = { - id: string; - annotationId: string; - documentId: string; - text: string; - label: string | null; - sortOrder: number; - version: number; -}; - let transcriptionBlocks = $state([]); async function loadTranscriptionBlocks() {