Skip to content

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

web: don't create new p tag at editor end if there is selection

Abdullah Atta8996708164e6
diff --git a/apps/web/src/components/editor/tiptap.tsx b/apps/web/src/components/editor/tiptap.tsx
index 12531b203..8c5423fb6 100644
--- a/apps/web/src/components/editor/tiptap.tsx
+++ b/apps/web/src/components/editor/tiptap.tsx
@@ -260,7 +260,9 @@ function TipTap(props: TipTapProps) {
if (!editorContainer) return;
const currentEditor = editor;
function onClick(e: MouseEvent) {
- if (e.target !== editorContainer) return;
+ if (e.target !== editorContainer || !currentEditor?.state.selection.empty)
+ return;
+
const lastNode = currentEditor?.state.doc.lastChild;
const isLastNodeParagraph = lastNode?.type.name === "paragraph";
const isEmpty = lastNode?.nodeSize === 2;