Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix(editor): retain focus when clicking below an empty note

tianma-if841b38fca870
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx
index c4732911..50a99fcd 100644
--- a/apps/web/src/components/EditorPane.tsx
+++ b/apps/web/src/components/EditorPane.tsx
@@ -1943,6 +1943,19 @@ const RichEditorPane = ({
);
if (clickedEmptyCanvas) {
editorCanvasInteractionVersionRef.current += 1;
+ if (
+ target === event.currentTarget &&
+ !isMobileViewport &&
+ !effectiveReadOnly &&
+ isEditorReady(editor) &&
+ editor.isEditable &&
+ editor.isEmpty &&
+ proseMirror &&
+ event.clientY >= proseMirror.getBoundingClientRect().bottom
+ ) {
+ editor.view.focus();
+ return;
+ }
// This handler runs in capture phase, before ProseMirror translates the
// click coordinates into a selection. In a desktop WebView that later
// selection can map the empty area beside/below a block image back onto
@@ -1959,7 +1972,7 @@ const RichEditorPane = ({
});
}
}
- }, [editor, onOpenMemo, showEditorLinkOpenHint]);
+ }, [editor, effectiveReadOnly, isMobileViewport, onOpenMemo, showEditorLinkOpenHint]);
const handleEditorFocusCapture = useCallback((event: ReactFocusEvent<HTMLDivElement>) => {
if (showAttachmentMenu(event.target)) return;