nanobot/webui/src/components/MarkdownText.tsx
Xubin Ren 0f96ab7e70 fix(webui): drop App markdown warmup; keep preloadMarkdownText export
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>
2026-05-16 01:42:42 +08:00

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>
);
}