From 9adc918e69c4d3f83aa6a370912145bf696b389e Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Jan 2026 15:15:10 +0000 Subject: [PATCH] fix: use single newline separator in TipTap getText() calls TipTap's getText() uses double newlines (\n\n) by default to separate block nodes like paragraphs, which was causing extra blank lines in posted content. Changed to getText({ blockSeparator: '\n' }) in both RichEditor and MentionEditor to use single newlines between paragraphs. --- src/components/editor/MentionEditor.tsx | 2 +- src/components/editor/RichEditor.tsx | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/editor/MentionEditor.tsx b/src/components/editor/MentionEditor.tsx index b8f5428..71c4a80 100644 --- a/src/components/editor/MentionEditor.tsx +++ b/src/components/editor/MentionEditor.tsx @@ -966,7 +966,7 @@ export const MentionEditor = forwardRef< () => ({ focus: () => editor?.commands.focus(), clear: () => editor?.commands.clearContent(), - getContent: () => editor?.getText() || "", + getContent: () => editor?.getText({ blockSeparator: "\n" }) || "", getSerializedContent: () => { if (!editor) return { diff --git a/src/components/editor/RichEditor.tsx b/src/components/editor/RichEditor.tsx index 8839ea3..e315d2d 100644 --- a/src/components/editor/RichEditor.tsx +++ b/src/components/editor/RichEditor.tsx @@ -172,8 +172,9 @@ function serializeContent(editor: any): SerializedContent { const seenBlobs = new Set(); const seenAddrs = new Set(); - // Get plain text representation - const text = editor.getText(); + // Get plain text representation with single newline between blocks + // (TipTap's default is double newline which adds extra blank lines) + const text = editor.getText({ blockSeparator: "\n" }); // Walk the document to collect emoji, blob, and address reference data editor.state.doc.descendants((node: any) => { @@ -533,7 +534,7 @@ export const RichEditor = forwardRef( () => ({ focus: () => editor?.commands.focus(), clear: () => editor?.commands.clearContent(), - getContent: () => editor?.getText() || "", + getContent: () => editor?.getText({ blockSeparator: "\n" }) || "", getSerializedContent: () => { if (!editor) return {