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.
This commit is contained in:
Claude
2026-01-21 15:15:10 +00:00
parent 3449f5e66f
commit 9adc918e69
2 changed files with 5 additions and 4 deletions

View File

@@ -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 {

View File

@@ -172,8 +172,9 @@ function serializeContent(editor: any): SerializedContent {
const seenBlobs = new Set<string>();
const seenAddrs = new Set<string>();
// 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<RichEditorHandle, RichEditorProps>(
() => ({
focus: () => editor?.commands.focus(),
clear: () => editor?.commands.clearContent(),
getContent: () => editor?.getText() || "",
getContent: () => editor?.getText({ blockSeparator: "\n" }) || "",
getSerializedContent: () => {
if (!editor)
return {