Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: Forced to click on 1st line to focus editor (fixes streetwriters/notesnook#712)

thecodrrb21b124d9d28
diff --git a/apps/web/src/components/editor/tiptap.tsx b/apps/web/src/components/editor/tiptap.tsx
index ac5ec4787..bae0b64fa 100644
--- a/apps/web/src/components/editor/tiptap.tsx
+++ b/apps/web/src/components/editor/tiptap.tsx
@@ -157,6 +157,19 @@ function TipTap(props: TipTapProps) {
if (isSearching && !isEditorSearching) toggleSearch();
}, [toggleSearch, editor?.storage.searchreplace?.isSearching]);
+ useEffect(() => {
+ if (!editorContainer) return;
+ const currentEditor = editor;
+ function onClick(e: MouseEvent) {
+ if (currentEditor?.isFocused || e.target !== editorContainer) return;
+ currentEditor?.commands.focus("end");
+ }
+ editorContainer.addEventListener("click", onClick);
+ return () => {
+ editorContainer.removeEventListener("click", onClick);
+ };
+ }, [editor, editorContainer]);
+
if (!toolbarContainerId) return null;
return (