mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-12 00:17:02 +02:00
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:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user