mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-12 00:17:02 +02:00
Preserve newlines when sending chat messages
The MentionEditor's serializeContent function was not handling hardBreak nodes created by Shift+Enter. This caused newlines within messages to be lost during serialization, even though the editor displayed them correctly. Changes: - Add hardBreak node handling in serializeContent - Preserve newlines (\n) from Shift+Enter keypresses - Ensure multi-line messages are sent with proper line breaks With this fix and the previous Text.tsx fix, newlines are now properly: 1. Captured when typing (Shift+Enter creates hardBreak) 2. Preserved when sending (hardBreak serialized as \n) 3. Rendered when displaying (Text component renders \n as <br />)
This commit is contained in:
@@ -584,6 +584,9 @@ export const MentionEditor = forwardRef<
|
||||
node.content?.forEach((child: any) => {
|
||||
if (child.type === "text") {
|
||||
text += child.text;
|
||||
} else if (child.type === "hardBreak") {
|
||||
// Preserve newlines from Shift+Enter
|
||||
text += "\n";
|
||||
} else if (child.type === "mention") {
|
||||
const pubkey = child.attrs?.id;
|
||||
if (pubkey) {
|
||||
|
||||
Reference in New Issue
Block a user