Editor: Auto-Fokus beim Wechsel in den Edit-Modus
Some checks failed
CI / Lint, typecheck, test (pull_request) Successful in 4m50s
CI / Build container images (pull_request) Successful in 1m16s
CI / Auth e2e pack (pull_request) Successful in 6m44s
CI / Import/export fidelity gate (pull_request) Successful in 54s
CD / Build and push images (push) Successful in 16s
CD / Deploy to Test (push) Successful in 14s
CD / Smoke tests against Test (push) Successful in 1m15s
CD / Promote to Int (push) Successful in 11s
CI / Lint, typecheck, test (push) Successful in 4m32s
CI / Build container images (push) Has been skipped
CI / Auth e2e pack (push) Failing after 5m29s
CI / Import/export fidelity gate (push) Has been skipped

Beim Umschalten in den Bearbeiten-Modus (Stift-Icon oder Shortcut „e")
landet der Cursor jetzt automatisch im Editor — bisher brauchte es einen
zusätzlichen Klick, der auf neuen/leeren Seiten zudem pixelgenau den
schmalen Inhaltsbereich treffen musste.

Effekt feuert, sobald der Editor editierbar wird (nach setEditable),
und überspringt den Fokus-Klau, wenn gerade ein Textfeld (z. B. der
Seitentitel) den Fokus hält — der Moduswechsel darf den Caret nicht aus
dem Titel reißen. TipTaps focus() stellt die letzte Auswahl wieder her
bzw. setzt den Caret an den Anfang einer leeren Seite.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0155v2aT8AG1kZDQEZiCLBWC
This commit is contained in:
Claude Fable 5 2026-07-19 11:36:17 +02:00
parent 1b0fd21254
commit 4ba4ca7ba9

View File

@ -209,6 +209,22 @@ function PageEditor({
editor?.setEditable(canEdit); editor?.setEditable(canEdit);
}, [editor, canEdit]); }, [editor, canEdit]);
// Entering edit mode drops the caret straight into the content, so writing
// starts without an extra — and on empty pages pixel-precise — click. Skip
// when a text control (e.g. the title input) already holds focus: switching
// modes must not yank the caret out of it.
useEffect(() => {
if (!editor || !canEdit) return;
const active = document.activeElement;
if (
active instanceof HTMLElement &&
(active.tagName === 'INPUT' || active.tagName === 'TEXTAREA' || active.isContentEditable)
) {
return;
}
editor.commands.focus();
}, [editor, canEdit]);
// Active plugins feed the section-style stylesheets (read + edit mode) and // Active plugins feed the section-style stylesheets (read + edit mode) and
// the toolbar's style picker (#75). Offline the query fails silently and // the toolbar's style picker (#75). Offline the query fails silently and
// sections render with neutral styling — content stays intact. // sections render with neutral styling — content stays intact.