diff --git a/src/components/nostr/RichText/Text.tsx b/src/components/nostr/RichText/Text.tsx index 12a03eb..7ac4823 100644 --- a/src/components/nostr/RichText/Text.tsx +++ b/src/components/nostr/RichText/Text.tsx @@ -1,5 +1,4 @@ import { CommonData } from "applesauce-content/nast"; -import { useMemo } from "react"; interface TextNodeProps { node: { @@ -11,23 +10,22 @@ interface TextNodeProps { export function Text({ node }: TextNodeProps) { const text = node.value; - const lines = useMemo(() => text.split("\n"), [text]); - if (text.includes("\n")) { - return ( - <> - {lines.map((line, idx) => - line.trim().length === 0 ? ( -
- ) : idx === 0 || idx === lines.length - 1 ? ( - {line} // FIXME: this should be span or div depnding on context - ) : ( -
- {line} -
- ), - )} - - ); + + // If no newlines, render as simple span + if (!text.includes("\n")) { + return {text}; } - return {text}; + + // Multi-line text: split and render with
between lines + const lines = text.split("\n"); + return ( + <> + {lines.map((line, idx) => ( + + {line} + {idx < lines.length - 1 &&
} +
+ ))} + + ); }