From 4ba4ca7ba9ac32538d5fc5d5b43fe978e7d6bb0f Mon Sep 17 00:00:00 2001 From: Claude Fable 5 Date: Sun, 19 Jul 2026 11:36:17 +0200 Subject: [PATCH] Editor: Auto-Fokus beim Wechsel in den Edit-Modus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Claude-Session: https://claude.ai/code/session_0155v2aT8AG1kZDQEZiCLBWC --- apps/web/src/pages/PageEditorPage.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/web/src/pages/PageEditorPage.tsx b/apps/web/src/pages/PageEditorPage.tsx index 6747e93..68b2afb 100644 --- a/apps/web/src/pages/PageEditorPage.tsx +++ b/apps/web/src/pages/PageEditorPage.tsx @@ -209,6 +209,22 @@ function PageEditor({ editor?.setEditable(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 // the toolbar's style picker (#75). Offline the query fails silently and // sections render with neutral styling — content stays intact. -- 2.45.2