mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-19 16:12:30 +00:00
Startup no longer triggers preloadMarkdownText (#3746). Restore the named export so MessageBubble can still warm the lazy markdown chunk when the reasoning panel opens (compatible with current main). Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import { Suspense, lazy } from "react";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
interface MarkdownTextProps {
|
|
children: string;
|
|
className?: string;
|
|
}
|
|
|
|
const loadMarkdownRenderer = () => import("@/components/MarkdownTextRenderer");
|
|
const LazyMarkdownRenderer = lazy(loadMarkdownRenderer);
|
|
|
|
export function preloadMarkdownText(): void {
|
|
void loadMarkdownRenderer();
|
|
}
|
|
|
|
/**
|
|
* Lightweight markdown renderer mirroring agent-chat-ui: GFM + math via
|
|
* ``remark-math`` / ``rehype-katex``, and fenced code blocks delegated to
|
|
* ``CodeBlock`` for copy-to-clipboard and syntax highlighting.
|
|
*/
|
|
export function MarkdownText({ children, className }: MarkdownTextProps) {
|
|
return (
|
|
<Suspense
|
|
fallback={
|
|
<div
|
|
className={cn(
|
|
"whitespace-pre-wrap break-words leading-relaxed text-foreground/92",
|
|
className,
|
|
)}
|
|
>
|
|
{children}
|
|
</div>
|
|
}
|
|
>
|
|
<LazyMarkdownRenderer className={className}>{children}</LazyMarkdownRenderer>
|
|
</Suspense>
|
|
);
|
|
}
|