Barrierefreiheit in App und Redaktion, Vorlesen ausgebaut

Vorlesen:
- „Seite vorlesen“ in der Kopfzeile auf jeder Seite, dazu im Artikel
- satzweise mit Markierung des gelesenen Satzes (CSS Highlight API),
  mitscrollend; Steuerleiste mit Pause, Satz zurück/vor, langsam, Stopp
- Satzgrenzen folgen der Darstellung; Bedienelemente werden übersprungen

Barrierefreiheit (axe-core, WCAG 2.2 AA – jetzt ohne Befund):
- Kontraste von Hilfstext und Status-Schrift angehoben, keine
  Transparenz mehr bei erledigten Einträgen
- Fehlerseiten mit Titel und Hauptbereich (App, Redaktion, allgemein)
- Überschriften-Hierarchie in der Meldungsliste
- Text-Editor mit zugänglichem Namen, eindeutige Seitenleisten,
  beschriftete Symbol-Buttons, ausreichend große Tippflächen
- Redaktion: Sprunglink zum Inhalt, Schriftgröße/Farbschema unter
  „Mein Konto“; Redaktionskalender in voller Breite

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-30 16:26:45 +00:00
parent ded828ddef
commit 0d35dc9d29
21 changed files with 369 additions and 54 deletions

View file

@ -15,20 +15,36 @@ Tablet und Desktop.
- Termine & Schließzeiten, gruppiert nach Monat, mit Kalender-Abo (`/termine.ics`)
- Ansprechpartner-Verzeichnis, Kontaktformular, Volltextsuche
- **Barrierearm:** klare Schrift (Montserrat, selbst gehostet), 3 Schriftgrößen, Hell/Dunkel,
**Vorlesen**-Funktion, **Leichte Sprache** pro Seite/Meldung
**Leichte Sprache** pro Seite/Meldung
- **Vorlesen** jeder Seite (Knopf in der Kopfzeile) oder eines Artikels: satzweise, der gelesene Satz
wird markiert und mitgescrollt, mit Pause, Satz vor/zurück und langsamem Tempo
- Merkliste (lokal auf dem Gerät), Teilen, offline lesbar, als App installierbar
- Keine Werbung, kein Tracking, keine externen Schriften oder CDNs
**Redaktion (`/admin`)**
- Übersicht, Meldungen (Entwurf, geplante Veröffentlichung, anheften), Seitenbaum, Termine,
Startseiten-Kacheln, Ansprechpartner, Mediathek, Postfach
- **Redaktionskalender** fürs Team: Planungen mit Status (Idee → In Arbeit → Zur Freigabe → Geplant →
Erledigt), Zuständigkeit, Frist, Notizen und Kommentaren; Monatsansicht mit Meldungen und Terminen,
Board nach Status, Liste; Ziehen & Ablegen (mit Tastatur-Alternative), Ideenspeicher,
„Meldung daraus erstellen“, „Meine Aufgaben“ auf der Übersicht
- **Ansprechpartner** einmal anlegen und in beliebig vielen Seiten und Meldungen verwenden – mit Suche,
Reihenfolge, Anlegen direkt aus dem Auswahlfeld und „Verwendet in“
- Meldungen (Entwurf, geplante Veröffentlichung, anheften), Seitenbaum, Termine,
Startseiten-Bereiche, Mediathek, Postfach
- Text-Editor mit Formatierungen, Links und Bildern
- Bilder werden automatisch gedreht, verkleinert und als WebP gespeichert
- Rollen: **Redakteur** (Inhalte) und **Administrator** (zusätzlich Benutzer & Einstellungen)
- Einstellungen: App-Name, Logo, Farbpaar (Haupt- und Akzentfarbe), Titelbild, Texte, Impressum,
Datenschutz – das App-Symbol wird daraus automatisch erzeugt
## Barrierefreiheit
App und Redaktion werden mit [axe-core](https://github.com/dequelabs/axe-core) gegen WCAG 2.2 AA geprüft
(hell und dunkel, Handy und Desktop) – aktuell ohne Befund. Dazu u. a.: Sprunglinks zum Inhalt,
sichtbarer Tastaturfokus, beschriftete Bedienelemente, Ansagen für Screenreader bei Änderungen,
Tastatur-Alternativen zu Ziehen & Ablegen, `prefers-reduced-motion`, Kontrast ≥ 4,5 : 1.
Schriftgröße und Farbschema lassen sich auch in der Redaktion einstellen (Mein Konto).
## Technik
SvelteKit 2 (Svelte 5) · Tailwind CSS 4 · SQLite (better-sqlite3) mit Drizzle ORM · sharp · Tiptap.

View file

@ -15,8 +15,9 @@
/* ruhige Flächen: Lavendel, aus der Markenfarbe abgeleitet */
--surface-2: color-mix(in oklab, var(--brand) 8%, white);
--ink: color-mix(in oklab, var(--brand) 92%, black);
--ink-2: color-mix(in oklab, var(--brand) 40%, #5d6073);
--ink-3: color-mix(in oklab, var(--brand) 22%, #7f84a3);
--ink-2: color-mix(in oklab, var(--brand) 40%, #50536a);
/* Hilfstext: mindestens 4,5:1 auch auf Lavendel-Flächen (WCAG AA) */
--ink-3: color-mix(in oklab, var(--brand) 25%, #5f6386);
--line: color-mix(in oklab, var(--brand) 13%, white);
--shadow: 0 1px 2px rgb(20 16 60 / 0.05), 0 8px 24px -12px rgb(20 16 60 / 0.14);
--shadow-lg: 0 2px 6px rgb(20 16 60 / 0.06), 0 24px 48px -20px rgb(20 16 60 / 0.3);
@ -35,7 +36,7 @@
--surface-2: #242050;
--ink: #efedfb;
--ink-2: #bdb9dc;
--ink-3: #8f8bb8;
--ink-3: #a19dc9;
--line: #302b63;
--shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px -12px rgb(0 0 0 / 0.6);
--shadow-lg: 0 2px 6px rgb(0 0 0 / 0.3), 0 24px 48px -20px rgb(0 0 0 / 0.75);
@ -54,7 +55,7 @@
--surface-2: #242050;
--ink: #efedfb;
--ink-2: #bdb9dc;
--ink-3: #8f8bb8;
--ink-3: #a19dc9;
--line: #302b63;
--shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px -12px rgb(0 0 0 / 0.6);
--shadow-lg: 0 2px 6px rgb(0 0 0 / 0.3), 0 24px 48px -20px rgb(0 0 0 / 0.75);
@ -113,8 +114,9 @@
.tone-slate { --tone: #56647a; }
[class*='tone-'] {
--tone-soft: color-mix(in oklab, var(--tone) 12%, var(--surface));
--tone-ink: color-mix(in oklab, var(--tone) 85%, var(--ink));
--tone-soft: color-mix(in oklab, var(--tone) 10%, var(--surface));
/* dunkel genug für 4,5:1 auf der hellen Tönung */
--tone-ink: color-mix(in oklab, var(--tone) 68%, #120f2e);
}
:root[data-theme='dark'] [class*='tone-'] {
--tone-soft: color-mix(in oklab, var(--tone) 26%, var(--surface));
@ -284,6 +286,14 @@
}
}
/* Satz, der gerade vorgelesen wird */
::highlight(vorlesen) {
background-color: var(--accent-soft);
color: var(--ink);
text-decoration: underline 3px var(--accent);
text-underline-offset: 4px;
}
@utility safe-bottom {
padding-bottom: env(safe-area-inset-bottom);
}

View file

@ -45,7 +45,7 @@
>
<div class="grid xl:grid-cols-[1fr_20rem] gap-6 items-start">
<div class="space-y-6 min-w-0">{@render children()}</div>
{#if aside}<aside class="space-y-6 xl:sticky xl:top-6">{@render aside()}</aside>{/if}
{#if aside}<aside aria-label="Weitere Angaben" class="space-y-6 xl:sticky xl:top-6">{@render aside()}</aside>{/if}
</div>
<div class="sticky bottom-0 -mx-4 sm:-mx-8 mt-8 px-4 sm:px-8 py-3 bg-bg/85 backdrop-blur border-t border-line flex items-center gap-2 z-20">

View file

@ -34,8 +34,8 @@
</div>
</div>
{/each}
<button type="button" onclick={() => (open = true)} class="aspect-square rounded-xl border-2 border-dashed border-line hover:border-brand text-ink-3 hover:text-brand-ink grid place-items-center">
<Plus class="size-7" />
<button type="button" aria-label="Bilder zur Galerie hinzufügen" onclick={() => (open = true)} class="aspect-square rounded-xl border-2 border-dashed border-line hover:border-brand text-ink-3 hover:text-brand-ink grid place-items-center">
<Plus class="size-7" aria-hidden="true" />
</button>
</div>
</div>

View file

@ -32,7 +32,7 @@
</button>
{/each}
</div>
<button type="button" class="text-sm font-bold text-brand-ink mt-2" onclick={() => (showAll = !showAll)}>
<button type="button" class="text-sm font-bold text-brand-ink mt-2 min-h-8 px-1 -mx-1 rounded-lg hover:bg-surface-2" onclick={() => (showAll = !showAll)}>
{showAll ? 'Weniger anzeigen' : 'Alle Symbole anzeigen'}
</button>
</fieldset>

View file

@ -47,7 +47,14 @@
],
content: value,
editorProps: {
attributes: { class: 'rich focus:outline-none px-4 py-3', style: `min-height:${minHeight}` }
attributes: {
class: 'rich focus:outline-none px-4 py-3',
style: `min-height:${minHeight}`,
role: 'textbox',
'aria-multiline': 'true',
'aria-label': label,
...(hint ? { 'aria-description': hint } : {})
}
},
onTransaction: () => tick++,
onUpdate: ({ editor }) => {

View file

@ -36,11 +36,11 @@
}
</script>
<div class="flex gap-4 overflow-x-auto pb-4 -mx-4 px-4 sm:mx-0 sm:px-0 snap-x">
<div class="flex gap-4 overflow-x-auto pb-4 -mx-4 px-4 sm:mx-0 sm:px-0 snap-x 2xl:grid 2xl:grid-cols-5 2xl:overflow-visible">
{#each columns as col (col.status)}
<section
aria-labelledby="col-{col.status}"
class="tone-{STATUS_TONE[col.status]} snap-start shrink-0 w-72 rounded-2xl bg-surface-2 p-3 transition-colors {dropTarget === col.status ? 'outline-2 outline-dashed outline-tone bg-tone-soft' : ''}"
class="tone-{STATUS_TONE[col.status]} snap-start shrink-0 w-72 2xl:w-auto rounded-2xl bg-surface-2 p-3 transition-colors {dropTarget === col.status ? 'outline-2 outline-dashed outline-tone bg-tone-soft' : ''}"
ondragover={(e) => {
if (!e.dataTransfer?.types.includes('application/x-redaktion')) return;
e.preventDefault();

View file

@ -51,10 +51,10 @@
ondragstart={dragstart}
onclick={() => onopen(entry)}
aria-label={label}
class="tone-{STATUS_TONE[entry.status]} group w-full text-left rounded-lg bg-surface border border-line border-l-4 border-l-tone px-2 py-1.5 hover:border-brand/40 hover:shadow-card transition cursor-grab active:cursor-grabbing {entry.status === 'done' ? 'opacity-60' : ''}"
class="tone-{STATUS_TONE[entry.status]} group w-full text-left rounded-lg bg-surface border border-line border-l-4 border-l-tone px-2 py-1.5 hover:border-brand/40 hover:shadow-card transition cursor-grab active:cursor-grabbing {entry.status === 'done' ? 'bg-surface-2' : ''}"
>
<span class="flex items-start gap-1.5">
<span class="flex-1 min-w-0 text-[0.8rem] font-semibold leading-snug {compact ? 'line-clamp-2' : ''} {entry.status === 'done' ? 'line-through' : ''}">{entry.title}</span>
<span class="flex-1 min-w-0 text-[0.8rem] font-semibold leading-snug {compact ? 'line-clamp-2' : ''} {entry.status === 'done' ? 'line-through text-ink-2' : ''}">{entry.title}</span>
{#if assignee}
<span class="grid place-items-center size-5 rounded-full bg-brand text-on-brand text-[0.6rem] font-bold shrink-0" aria-hidden="true" title={assignee.name}>{assignee.initials}</span>
{/if}

View file

@ -1,43 +1,21 @@
<script lang="ts">
import { onMount, onDestroy } from 'svelte';
import Volume2 from '@lucide/svelte/icons/volume-2';
import Square from '@lucide/svelte/icons/square';
import Bookmark from '@lucide/svelte/icons/bookmark';
import BookmarkCheck from '@lucide/svelte/icons/bookmark-check';
import Share2 from '@lucide/svelte/icons/share-2';
import { favorites } from '$lib/favorites.svelte';
import { speech } from '$lib/speech.svelte';
import type { Favorite } from '$lib/types';
let { target, favorite }: { target: string; favorite?: Favorite } = $props();
let canSpeak = $state(false);
let speaking = $state(false);
let shared = $state(false);
const reading = $derived(speech.active);
onMount(() => (canSpeak = 'speechSynthesis' in window));
onDestroy(() => speaking && speechSynthesis.cancel());
/** Liest den Inhalt des Elements #target vor – satzweise, damit lange Texte nicht abbrechen. */
function toggleSpeak() {
if (speaking) {
speechSynthesis.cancel();
speaking = false;
return;
}
const el = document.getElementById(target);
if (!el) return;
const sentences = (el.innerText.match(/[^.!?\n]+[.!?]*/g) ?? []).map((s) => s.trim()).filter(Boolean);
const voice = speechSynthesis.getVoices().find((v) => v.lang.startsWith('de'));
speechSynthesis.cancel();
sentences.forEach((s, i) => {
const u = new SpeechSynthesisUtterance(s);
u.lang = 'de-DE';
u.rate = 0.95;
if (voice) u.voice = voice;
if (i === sentences.length - 1) u.onend = () => (speaking = false);
speechSynthesis.speak(u);
});
speaking = sentences.length > 0;
if (speech.active) speech.stop();
else speech.start(target, 'Text');
}
async function share() {
@ -59,9 +37,9 @@
</script>
<div class="flex flex-wrap gap-2">
{#if canSpeak}
<button type="button" class="btn btn-sm {speaking ? 'btn-primary' : 'btn-soft'}" onclick={toggleSpeak} aria-pressed={speaking}>
{#if speaking}<Square class="size-4" /> Stopp{:else}<Volume2 class="size-4" /> Vorlesen{/if}
{#if speech.supported}
<button type="button" class="btn btn-sm {reading ? 'btn-primary' : 'btn-soft'}" onclick={toggleSpeak} aria-pressed={reading}>
{#if reading}<Square class="size-4" /> Stopp{:else}<Volume2 class="size-4" /> Vorlesen{/if}
</button>
{/if}
{#if favorite}

View file

@ -18,7 +18,7 @@
{:else}
<!-- Platzhalter, bis in den Einstellungen ein Titelbild gewählt ist -->
<div class="absolute inset-0 bg-[linear-gradient(135deg,var(--brand)_0%,color-mix(in_oklab,var(--brand)_60%,var(--accent))_100%)]">
<p class="absolute left-5 top-5 lg:left-8 lg:top-7 inline-flex items-center gap-2 rounded-full bg-white/10 px-3 py-1.5 text-xs font-semibold text-white/75">
<p data-nicht-vorlesen class="absolute left-5 top-5 lg:left-8 lg:top-7 inline-flex items-center gap-2 rounded-full bg-white/10 px-3 py-1.5 text-xs font-semibold text-white/75">
<ImageIcon class="size-4" /> Platzhalter für das Titelbild
</p>
</div>

View file

@ -4,7 +4,8 @@
import { relative } from '$lib/dates';
import type { PostCard } from '$lib/types';
let { post, variant = 'card' }: { post: PostCard; variant?: 'card' | 'row' } = $props();
/** level: Überschriften-Ebene passend zur Seite (h2 in Listen direkt unter dem h1, sonst h3) */
let { post, variant = 'card', level = 3 }: { post: PostCard; variant?: 'card' | 'row'; level?: 2 | 3 } = $props();
</script>
{#if variant === 'card'}
@ -25,7 +26,7 @@
{#if post.pinned}<Pin class="size-3.5" aria-label="Angeheftet" />{/if}
{relative(post.publishedAt)}
</p>
<h3 class="text-xl text-brand-ink mt-1.5 group-hover:underline decoration-2 underline-offset-4 decoration-accent">{post.title}</h3>
<svelte:element this={`h${level}`} class="text-xl font-bold text-brand-ink mt-1.5 group-hover:underline decoration-2 underline-offset-4 decoration-accent">{post.title}</svelte:element>
{#if post.teaser}<p class="text-ink-2 mt-2 line-clamp-3">{post.teaser}</p>{/if}
</a>
{:else}
@ -39,7 +40,7 @@
</div>
<div class="min-w-0">
<p class="eyebrow !text-accent-ink !text-[0.7rem]">{relative(post.publishedAt)}</p>
<h3 class="text-[1.05rem] text-brand-ink leading-snug mt-1 line-clamp-2 group-hover:underline decoration-accent underline-offset-4">{post.title}</h3>
<svelte:element this={`h${level}`} class="text-[1.05rem] font-bold text-brand-ink leading-snug mt-1 line-clamp-2 group-hover:underline decoration-accent underline-offset-4">{post.title}</svelte:element>
{#if post.teaser}<p class="text-sm text-ink-2 mt-1 line-clamp-2">{post.teaser}</p>{/if}
</div>
</a>

View file

@ -5,7 +5,7 @@
import BookHeart from '@lucide/svelte/icons/book-heart';
import { prefs } from '$lib/prefs.svelte';
let { compact = false }: { compact?: boolean } = $props();
let { compact = false, easy = true }: { compact?: boolean; easy?: boolean } = $props();
const themes = [
{ value: 'light', label: 'Hell', icon: Sun },
@ -22,6 +22,7 @@
<div class="space-y-5">
<!-- Leichte Sprache -->
{#if easy}
<label class="flex items-center gap-3 cursor-pointer">
<span class="grid place-items-center size-10 rounded-xl bg-brand-soft text-brand-ink shrink-0">
<BookHeart class="size-5" />
@ -40,6 +41,7 @@
onchange={(e) => prefs.set({ easy: e.currentTarget.checked })}
/>
</label>
{/if}
<fieldset>
<legend class="font-semibold mb-2">Schriftgröße</legend>

View file

@ -0,0 +1,54 @@
<script lang="ts">
import { onMount } from 'svelte';
import { afterNavigate } from '$app/navigation';
import Pause from '@lucide/svelte/icons/pause';
import Play from '@lucide/svelte/icons/play';
import Square from '@lucide/svelte/icons/square';
import SkipBack from '@lucide/svelte/icons/skip-back';
import SkipForward from '@lucide/svelte/icons/skip-forward';
import Snail from '@lucide/svelte/icons/snail';
import { speech } from '$lib/speech.svelte';
onMount(() => {
speech.init();
return () => speech.stop();
});
// Beim Seitenwechsel aufhören
afterNavigate(({ from }) => from && speech.stop());
</script>
{#if speech.active}
<div
role="region"
aria-label="Vorlesen"
class="fixed inset-x-3 bottom-[5.5rem] lg:bottom-6 z-40 mx-auto max-w-md rounded-full bg-brand text-on-brand shadow-float pl-5 pr-2 py-2 flex items-center gap-1"
data-nicht-vorlesen
>
<p class="flex-1 min-w-0 text-sm font-semibold leading-tight" aria-live="polite">
<span class="block truncate">{speech.paused ? 'Pausiert' : 'Liest vor …'}</span>
<span class="block text-xs font-medium opacity-80">Satz {speech.index + 1} von {speech.total}</span>
</p>
<button type="button" class="grid place-items-center size-10 rounded-full hover:bg-white/15" aria-label="Vorheriger Satz" onclick={() => speech.step(-1)}>
<SkipBack class="size-5" />
</button>
<button type="button" class="grid place-items-center size-11 rounded-full bg-white text-brand hover:bg-white/90" aria-label={speech.paused ? 'Weiter vorlesen' : 'Pause'} onclick={() => speech.togglePause()}>
{#if speech.paused}<Play class="size-5 ml-0.5" />{:else}<Pause class="size-5" />{/if}
</button>
<button type="button" class="grid place-items-center size-10 rounded-full hover:bg-white/15" aria-label="Nächster Satz" onclick={() => speech.step(1)}>
<SkipForward class="size-5" />
</button>
<button
type="button"
class="grid place-items-center size-10 rounded-full transition {speech.slow ? 'bg-white/25' : 'hover:bg-white/15'}"
aria-label="Langsam vorlesen"
aria-pressed={speech.slow}
title="Langsamer"
onclick={() => speech.toggleRate()}
>
<Snail class="size-5" />
</button>
<button type="button" class="grid place-items-center size-10 rounded-full hover:bg-white/15" aria-label="Vorlesen beenden" onclick={() => speech.stop()}>
<Square class="size-4" fill="currentColor" />
</button>
</div>
{/if}

189
src/lib/speech.svelte.ts Normal file
View file

@ -0,0 +1,189 @@
/**
* Vorlesen mit der Sprachausgabe des Geräts (Web Speech API).
* Liest einen Bereich satzweise vor und markiert den aktuellen Satz
* (CSS Custom Highlight API), damit man mitlesen kann.
*/
type Sentence = { text: string; range: Range | null };
const RATE_KEY = 'wa_speech_rate';
const HIGHLIGHT = 'vorlesen';
/** Text-Knoten, die vorgelesen werden (ohne versteckte Elemente und Bedienelemente) */
function textNodes(root: Element): Text[] {
const skip = 'script, style, noscript, button, nav, [aria-hidden="true"], [hidden], .sr-only, [data-nicht-vorlesen]';
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
acceptNode: (n) => {
const el = n.parentElement;
if (!el || el.closest(skip) || !n.textContent?.trim()) return NodeFilter.FILTER_REJECT;
const style = getComputedStyle(el);
return style.display === 'none' || style.visibility === 'hidden' ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT;
}
});
const nodes: Text[] = [];
while (walker.nextNode()) nodes.push(walker.currentNode as Text);
return nodes;
}
/** Zerlegt den Bereich in Sätze inkl. Textbereich (Range) für die Markierung */
function sentencesOf(root: Element): Sentence[] {
const nodes = textNodes(root);
// Alles, was auf dem Bildschirm als eigener Block erscheint, endet mit einer Satzgrenze
const blockOf = (n: Text) => {
for (let el = n.parentElement; el && el !== root; el = el.parentElement) {
if (!getComputedStyle(el).display.startsWith('inline')) return el;
}
return root;
};
let full = '';
const map: { node: Text; start: number }[] = [];
let prevBlock: Element | null = null;
for (const node of nodes) {
const block = blockOf(node);
if (prevBlock && block !== prevBlock) full += '\n';
prevBlock = block;
map.push({ node, start: full.length });
full += node.textContent;
}
const locate = (pos: number) => {
let i = map.length - 1;
while (i > 0 && map[i].start > pos) i--;
const { node, start } = map[i];
return { node, offset: Math.min(Math.max(pos - start, 0), node.length) };
};
const out: Sentence[] = [];
const re = /[^.!?\n]+(?:[.!?]+["“”»)]*|\n|$)/g;
let m: RegExpExecArray | null;
while ((m = re.exec(full))) {
const raw = m[0];
const text = raw.replace(/\s+/g, ' ').trim();
if (!text) {
if (m.index === re.lastIndex) re.lastIndex++;
continue;
}
const lead = raw.length - raw.trimStart().length;
const s = m.index + lead;
const e = m.index + raw.trimEnd().length;
let range: Range | null = null;
try {
const a = locate(s);
const b = locate(e);
range = document.createRange();
range.setStart(a.node, a.offset);
range.setEnd(b.node, b.offset);
} catch {
range = null;
}
out.push({ text, range });
}
return out;
}
class Speech {
supported = $state(false);
active = $state(false);
paused = $state(false);
index = $state(0);
total = $state(0);
slow = $state(false);
label = $state('');
#sentences: Sentence[] = [];
#run = 0;
init() {
this.supported = typeof window !== 'undefined' && 'speechSynthesis' in window;
try {
this.slow = localStorage.getItem(RATE_KEY) === 'slow';
} catch {
/* ohne Speicher */
}
}
/** Liest das Element mit der ID `targetId` vor (Standard: Hauptinhalt) */
start(targetId = 'inhalt', label = 'Seite') {
const root = document.getElementById(targetId);
if (!root || !this.supported) return;
this.stop();
this.#sentences = sentencesOf(root);
if (!this.#sentences.length) return;
this.label = label;
this.total = this.#sentences.length;
this.active = true;
this.paused = false;
this.#speakFrom(0);
}
#speakFrom(i: number) {
const run = ++this.#run;
speechSynthesis.cancel();
const voice = speechSynthesis.getVoices().find((v) => v.lang.startsWith('de'));
for (let k = i; k < this.#sentences.length; k++) {
const u = new SpeechSynthesisUtterance(this.#sentences[k].text);
u.lang = 'de-DE';
u.rate = this.slow ? 0.75 : 0.95;
if (voice) u.voice = voice;
u.onstart = () => {
if (run !== this.#run) return;
this.index = k;
this.#highlight(k);
};
if (k === this.#sentences.length - 1) u.onend = () => run === this.#run && this.stop();
speechSynthesis.speak(u);
}
}
#highlight(k: number) {
const range = this.#sentences[k]?.range;
if (!range) return;
if ('highlights' in CSS) CSS.highlights.set(HIGHLIGHT, new Highlight(range));
const r = range.getBoundingClientRect();
const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
if (r.top < 90 || r.bottom > innerHeight - 140)
scrollBy({ top: r.top - innerHeight / 3, behavior: reduce ? 'auto' : 'smooth' });
}
togglePause() {
if (!this.active) return;
if (this.paused) {
// Neu ab aktuellem Satz – zuverlässiger als resume() auf allen Geräten
this.paused = false;
this.#speakFrom(this.index);
} else {
this.paused = true;
this.#run++;
speechSynthesis.cancel();
}
}
step(delta: number) {
if (!this.active) return;
const next = Math.min(Math.max(this.index + delta, 0), this.total - 1);
this.index = next;
this.#highlight(next);
if (!this.paused) this.#speakFrom(next);
}
toggleRate() {
this.slow = !this.slow;
try {
localStorage.setItem(RATE_KEY, this.slow ? 'slow' : 'normal');
} catch {
/* ohne Speicher */
}
if (this.active && !this.paused) this.#speakFrom(this.index);
}
stop() {
this.#run++;
if (this.supported) speechSynthesis.cancel();
if (typeof CSS !== 'undefined' && 'highlights' in CSS) CSS.highlights.delete(HIGHLIGHT);
this.active = false;
this.paused = false;
this.index = 0;
this.total = 0;
}
}
export const speech = new Speech();

View file

@ -3,6 +3,8 @@
import CircleHelp from '@lucide/svelte/icons/circle-help';
</script>
<svelte:head><title>{page.status === 404 ? 'Nicht gefunden' : 'Fehler'}</title></svelte:head>
<div class="max-w-md mx-auto text-center py-16 flex flex-col items-center gap-4">
<div class="grid place-items-center size-20 rounded-3xl bg-brand-soft text-brand"><CircleHelp class="size-10" /></div>
<h1 class="text-3xl sm:text-4xl text-brand-ink">{page.status === 404 ? 'Nicht gefunden' : 'Hoppla!'}</h1>

View file

@ -7,6 +7,9 @@
import Bookmark from '@lucide/svelte/icons/bookmark';
import Menu from '@lucide/svelte/icons/menu';
import Search from '@lucide/svelte/icons/search';
import Volume2 from '@lucide/svelte/icons/volume-2';
import ReadAloudBar from '$lib/components/ReadAloudBar.svelte';
import { speech } from '$lib/speech.svelte';
import MenuSheet from '$lib/components/MenuSheet.svelte';
import { favorites } from '$lib/favorites.svelte';
@ -67,6 +70,17 @@
{/each}
</nav>
{#if speech.supported}
<button
type="button"
class="btn btn-icon {speech.active ? 'btn-primary' : 'btn-ghost text-brand-ink'}"
aria-label={speech.active ? 'Vorlesen beenden' : 'Seite vorlesen'}
aria-pressed={speech.active}
onclick={() => (speech.active ? speech.stop() : speech.start('inhalt'))}
>
<Volume2 class="size-6" strokeWidth={2.25} />
</button>
{/if}
<a href="/suche" class="btn btn-ghost btn-icon text-brand-ink" aria-label="Suche">
<Search class="size-6" strokeWidth={2.25} />
</a>
@ -120,4 +134,6 @@
</div>
</nav>
<ReadAloudBar />
<MenuSheet bind:open={menuOpen} pages={data.menuPages} website={data.website} />

View file

@ -14,7 +14,7 @@
{#if data.items.length}
<div class="grid md:grid-cols-2 lg:grid-cols-3 gap-x-6 gap-y-10">
{#each data.items as p (p.id)}
<PostCard post={p} />
<PostCard post={p} level={2} />
{/each}
</div>

13
src/routes/+error.svelte Normal file
View file

@ -0,0 +1,13 @@
<script lang="ts">
import { page } from '$app/state';
</script>
<svelte:head><title>{page.status === 404 ? 'Nicht gefunden' : 'Fehler'}</title></svelte:head>
<main class="min-h-dvh grid place-items-center p-6 bg-bg">
<div class="max-w-md text-center space-y-4">
<h1 class="text-3xl font-bold text-brand-ink">{page.status === 404 ? 'Nicht gefunden' : 'Da ist etwas schiefgelaufen'}</h1>
<p class="text-ink-2">{page.error?.message ?? 'Bitte versuche es noch einmal.'}</p>
<a href="/" class="btn btn-primary">Zur Startseite</a>
</div>
</main>

View file

@ -0,0 +1,13 @@
<script lang="ts">
import { page } from '$app/state';
import CircleAlert from '@lucide/svelte/icons/circle-alert';
</script>
<svelte:head><title>{page.status === 404 ? 'Nicht gefunden' : 'Fehler'} · Redaktion</title></svelte:head>
<div class="max-w-md py-16 flex flex-col items-start gap-4">
<span class="grid place-items-center size-14 rounded-full bg-surface-2 text-brand-ink"><CircleAlert class="size-7" /></span>
<h1 class="text-2xl font-bold">{page.status === 404 ? 'Nicht gefunden' : 'Da ist etwas schiefgelaufen'}</h1>
<p class="text-ink-2">{page.error?.message ?? 'Bitte versuche es noch einmal.'}</p>
<a href="/admin" class="btn btn-primary">Zur Übersicht</a>
</div>

View file

@ -65,6 +65,8 @@
<svelte:head><title>Redaktion · {data.brand.appName}</title></svelte:head>
<a href="#inhalt" class="sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-[60] btn btn-primary">Zum Inhalt springen</a>
<div class="min-h-dvh lg:grid lg:grid-cols-[16rem_1fr]">
<!-- Mobile Kopfzeile -->
<header class="lg:hidden sticky top-0 z-30 flex items-center gap-3 h-14 px-3 bg-surface border-b border-line">
@ -77,6 +79,7 @@
{/if}
<aside
aria-label="Seitenleiste"
class="fixed lg:sticky top-0 z-50 h-dvh w-64 flex flex-col bg-surface border-r border-line transition-transform lg:translate-x-0 {navOpen ? 'translate-x-0' : '-translate-x-full'}"
>
<div class="flex items-center gap-3 px-4 h-16 border-b border-line">
@ -134,7 +137,11 @@
</div>
</aside>
<main class="min-w-0 px-4 sm:px-8 py-6 sm:py-8 max-w-6xl w-full">
<main
id="inhalt"
tabindex="-1"
class="min-w-0 px-4 sm:px-8 py-6 sm:py-8 w-full focus:outline-none {page.url.pathname.startsWith('/admin/redaktion') ? 'max-w-[110rem]' : 'max-w-6xl'}"
>
{@render children()}
</main>
</div>

View file

@ -2,12 +2,19 @@
import PageHeader from '$lib/admin/PageHeader.svelte';
import EditForm from '$lib/admin/EditForm.svelte';
import Panel from '$lib/admin/Panel.svelte';
import PrefsControls from '$lib/components/PrefsControls.svelte';
let { data } = $props();
</script>
<PageHeader title="Mein Konto" description={data.user.email} />
<section class="card p-5 sm:p-6 mb-6 max-w-2xl" aria-labelledby="anzeige">
<h2 id="anzeige" class="text-lg font-bold">Anzeige</h2>
<p class="text-sm text-ink-3 mb-5">Gilt für dieses Gerät – in der Redaktion und in der App. Wird sofort übernommen.</p>
<PrefsControls easy={false} />
</section>
<EditForm>
<Panel>
<div class="max-w-md">