11'use client'
22
33import { createContext , memo , useCallback , useContext , useMemo , useRef } from 'react'
4+ import { useRouter } from 'next/navigation'
45import type { Components , ExtraProps } from 'react-markdown'
56import ReactMarkdown from 'react-markdown'
6- import remarkBreaks from 'remark-breaks'
77import rehypeSlug from 'rehype-slug'
8+ import remarkBreaks from 'remark-breaks'
89import remarkGfm from 'remark-gfm'
9- import { useRouter } from 'next/navigation'
1010import { Checkbox } from '@/components/emcn'
1111import { cn } from '@/lib/core/utils/cn'
1212import { getFileExtension } from '@/lib/uploads/utils/file-utils'
@@ -95,22 +95,34 @@ const STATIC_MARKDOWN_COMPONENTS = {
9595 </ p >
9696 ) ,
9797 h1 : ( { id, children } : { id ?: string ; children ?: React . ReactNode } ) => (
98- < h1 id = { id } className = 'mt-6 mb-4 break-words font-semibold text-[24px] text-[var(--text-primary)] first:mt-0' >
98+ < h1
99+ id = { id }
100+ className = 'mt-6 mb-4 break-words font-semibold text-[24px] text-[var(--text-primary)] first:mt-0'
101+ >
99102 { children }
100103 </ h1 >
101104 ) ,
102105 h2 : ( { id, children } : { id ?: string ; children ?: React . ReactNode } ) => (
103- < h2 id = { id } className = 'mt-5 mb-3 break-words font-semibold text-[20px] text-[var(--text-primary)] first:mt-0' >
106+ < h2
107+ id = { id }
108+ className = 'mt-5 mb-3 break-words font-semibold text-[20px] text-[var(--text-primary)] first:mt-0'
109+ >
104110 { children }
105111 </ h2 >
106112 ) ,
107113 h3 : ( { id, children } : { id ?: string ; children ?: React . ReactNode } ) => (
108- < h3 id = { id } className = 'mt-4 mb-2 break-words font-semibold text-[16px] text-[var(--text-primary)] first:mt-0' >
114+ < h3
115+ id = { id }
116+ className = 'mt-4 mb-2 break-words font-semibold text-[16px] text-[var(--text-primary)] first:mt-0'
117+ >
109118 { children }
110119 </ h3 >
111120 ) ,
112121 h4 : ( { id, children } : { id ?: string ; children ?: React . ReactNode } ) => (
113- < h4 id = { id } className = 'mt-3 mb-2 break-words font-semibold text-[14px] text-[var(--text-primary)] first:mt-0' >
122+ < h4
123+ id = { id }
124+ className = 'mt-3 mb-2 break-words font-semibold text-[14px] text-[var(--text-primary)] first:mt-0'
125+ >
114126 { children }
115127 </ h4 >
116128 ) ,
@@ -348,7 +360,11 @@ const MarkdownPreview = memo(function MarkdownPreview({
348360 const committedMarkdown = useMemo (
349361 ( ) =>
350362 committed ? (
351- < ReactMarkdown remarkPlugins = { REMARK_PLUGINS } rehypePlugins = { REHYPE_PLUGINS } components = { MARKDOWN_COMPONENTS } >
363+ < ReactMarkdown
364+ remarkPlugins = { REMARK_PLUGINS }
365+ rehypePlugins = { REHYPE_PLUGINS }
366+ components = { MARKDOWN_COMPONENTS }
367+ >
352368 { committed }
353369 </ ReactMarkdown >
354370 ) : null ,
@@ -360,7 +376,11 @@ const MarkdownPreview = memo(function MarkdownPreview({
360376 < NavigateCtx . Provider value = { navigate } >
361377 < MarkdownCheckboxCtx . Provider value = { ctxValue } >
362378 < div ref = { scrollRef } className = 'h-full overflow-auto p-6' >
363- < ReactMarkdown remarkPlugins = { REMARK_PLUGINS } rehypePlugins = { REHYPE_PLUGINS } components = { MARKDOWN_COMPONENTS } >
379+ < ReactMarkdown
380+ remarkPlugins = { REMARK_PLUGINS }
381+ rehypePlugins = { REHYPE_PLUGINS }
382+ components = { MARKDOWN_COMPONENTS }
383+ >
364384 { content }
365385 </ ReactMarkdown >
366386 </ div >
@@ -378,7 +398,11 @@ const MarkdownPreview = memo(function MarkdownPreview({
378398 key = { generation }
379399 className = { cn ( isStreaming && 'animate-stream-fade-in' , '[&>:first-child]:mt-0' ) }
380400 >
381- < ReactMarkdown remarkPlugins = { REMARK_PLUGINS } rehypePlugins = { REHYPE_PLUGINS } components = { MARKDOWN_COMPONENTS } >
401+ < ReactMarkdown
402+ remarkPlugins = { REMARK_PLUGINS }
403+ rehypePlugins = { REHYPE_PLUGINS }
404+ components = { MARKDOWN_COMPONENTS }
405+ >
382406 { incoming }
383407 </ ReactMarkdown >
384408 </ div >
0 commit comments