@@ -545,6 +545,42 @@ export const Editor = forwardRef<EditorHandle, EditorProps>(function Editor(
545545 scheduleSave ( JSON . stringify ( editor . document ) )
546546 } , [ editor , scheduleSave , backfillImageCaptions ] )
547547
548+ /**
549+ * Handles clicks on the editor wrapper's padding area.
550+ *
551+ * The editor wrapper has generous bottom padding (`pb-[60vh]`) so that
552+ * users can scroll content above the fold. Clicking in this padding zone
553+ * does not naturally focus the editor because the click target is outside
554+ * the `.bn-editor` contenteditable region. This callback detects such
555+ * clicks and programmatically focuses the editor with the cursor placed
556+ * at the end of the last block.
557+ *
558+ * Early-return guards:
559+ * 1. **Locked mode** – when the editor is read-only (`locked` is `true`),
560+ * the callback is a no-op so that clicking the padding area does not
561+ * steal focus or move the cursor.
562+ * 2. **Inside `.bn-editor`** – if the click originated inside the
563+ * contenteditable region (including any descendant elements), the
564+ * callback returns early and lets the default browser behaviour handle
565+ * focus normally.
566+ *
567+ * @param e - The React mouse event from the wrapper `<div>`.
568+ */
569+ const handleWrapperClick = useCallback (
570+ ( e : React . MouseEvent < HTMLDivElement > ) => {
571+ if ( locked ) return
572+ const target = e . target as HTMLElement
573+ if ( target . closest ( '.bn-editor' ) ) return
574+
575+ const lastBlock = editor . document [ editor . document . length - 1 ]
576+ if ( lastBlock ) {
577+ editor . setTextCursorPosition ( lastBlock , 'end' )
578+ }
579+ editor . focus ( )
580+ } ,
581+ [ editor , locked ]
582+ )
583+
548584 return (
549585 < >
550586 { /* Editor wrapper — starts invisible (`opacity-0`) and transitions to
@@ -554,6 +590,7 @@ export const Editor = forwardRef<EditorHandle, EditorProps>(function Editor(
554590 className = { `w-full min-h-screen px-8 pb-[60vh] ${ contentReady ? 'opacity-100' : 'opacity-0' } ` }
555591 data-editor-root
556592 data-locked = { locked || undefined }
593+ onClick = { handleWrapperClick }
557594 style = {
558595 {
559596 '--editor-font-size' : `${ fontSize } px` ,
0 commit comments