Editor: Auto-Fokus beim Wechsel in den Edit-Modus #140
@ -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.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user