Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

GuideProse.tsx

33 lines806 Bytes

1import type { EnvironmentId } from "@t3tools/contracts";
2import { createContext, useContext } from "react";
3​
4import { cn } from "~/lib/utils";
5​
6import { PullRequestMarkdown } from "../PullRequestMarkdown";
7​
8export const GuideProseContext = createContext<{
9 readonly environmentId: EnvironmentId;
10 readonly cwd: string;
11} | null>(null);
12​
13export function GuideProse({
14 text,
15 plain = false,
16 className,
17}: {
18 text: string;
19 plain?: boolean;
20 className?: string;
21}) {
22 const context = useContext(GuideProseContext);
23 if (plain || context === null) return text;
24 return (
25 <PullRequestMarkdown
26 text={text}
27 cwd={context.cwd}
28 environmentId={context.environmentId}
29 lineBreaks={false}
30 className={cn("space-y-0 [&_.chat-markdown]:text-inherit", className)}
31 />
32 );