fix(messages): normalize escaped markdown newlines
This commit is contained in:
1 parent
6ce7e63c71
commit
31aac7c0de
9 files changed
+78
-7
No files matched your search
@@ -8,6 +8,7 @@ import { formatMessageTime } from "../../lib/formatters"
|
||||
import { EmptyState, useReducedMotion } from "../ui"
|
||||
import { useRovingTabIndex } from "../../lib/keyboard"
|
||||
import { useT } from "../../i18n"
|
||||
import { normalizeMarkdownText } from "@shared/markdown-text"
|
||||
|
||||
type ChannelConfig = { labelKey: string; icon: React.ElementType; color: string }
|
||||
|
||||
@@ -121,6 +122,7 @@ export function SearchResults({ results, query, loading, agents, onNavigateToRes
|
||||
const message = results[virtualRow.index]
|
||||
const agent = agentMap.get(message.fromAgentId)
|
||||
const config = channelConfig[message.channel]
|
||||
const normalizedBody = normalizeMarkdownText(message.body)
|
||||
const ChannelIcon = config.icon
|
||||
|
||||
return (
|
||||
@@ -175,7 +177,7 @@ export function SearchResults({ results, query, loading, agents, onNavigateToRes
|
||||
|
||||
{/* Row 3: Body snippet */}
|
||||
<div className="mt-0.5 line-clamp-2 break-words text-[13px] leading-relaxed text-muted-foreground">
|
||||
{highlightMatch(message.body, query)}
|
||||
{highlightMatch(normalizedBody, query)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,6 +14,7 @@ import WaitStateIndicator, { type WaitStateInfo } from "./WaitStateIndicator"
|
||||
import { MessageComposer } from "./MessageComposer"
|
||||
import { formatMessageTime } from "../../lib/formatters"
|
||||
import { useT, type TranslationFn } from "../../i18n"
|
||||
import { MarkdownBody } from "../ui/MarkdownBody"
|
||||
|
||||
interface ThreadPanelProps {
|
||||
threadId: string
|
||||
@@ -51,7 +52,9 @@ function EventItem({ event, agents, t }: { event: ConversationEventRecord; agent
|
||||
<span className="text-xs font-medium text-foreground">{actorName}</span>
|
||||
<span className="text-xs text-muted-foreground">{time}</span>
|
||||
</div>
|
||||
<p className="text-sm text-foreground/80">{event.body}</p>
|
||||
<div className="text-sm text-foreground/80">
|
||||
<MarkdownBody body={event.body} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { memo } from "react";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import { normalizeMarkdownText } from "@shared/markdown-text";
|
||||
|
||||
/**
|
||||
* Read-only markdown renderer used by message bubbles, comment bodies, and
|
||||
@@ -21,6 +22,8 @@ import remarkGfm from "remark-gfm";
|
||||
* wrapping container.
|
||||
*/
|
||||
export const MarkdownBody = memo(function MarkdownBody({ body }: { body: string }) {
|
||||
const normalizedBody = normalizeMarkdownText(body);
|
||||
|
||||
return (
|
||||
<ReactMarkdown
|
||||
remarkPlugins={[remarkGfm]}
|
||||
@@ -76,7 +79,7 @@ export const MarkdownBody = memo(function MarkdownBody({ body }: { body: string
|
||||
hr: () => <hr className="my-2 border-border" />,
|
||||
}}
|
||||
>
|
||||
{body}
|
||||
{normalizedBody}
|
||||
</ReactMarkdown>
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user