### What problem does this PR solve? Feat: Write the thinking style in the MarkdownContent layer #4930 ### Type of change - [x] New Feature (non-breaking change which adds functionality)tags/v0.17.0
| & > p { | & > p { | ||||
| margin: 0; | margin: 0; | ||||
| } | } | ||||
| :global(section.think) { | |||||
| padding-left: 10px; | |||||
| color: #8b8b8b; | |||||
| border-left: 2px solid #d5d3d3; | |||||
| margin-bottom: 10px; | |||||
| font-size: 12px; | |||||
| } | |||||
| } | } | ||||
| .messageText { | .messageText { | ||||
| .chunkText(); | .chunkText(); |
| .markdownContentWrapper { | |||||
| :global(section.think) { | |||||
| padding-left: 10px; | |||||
| color: #8b8b8b; | |||||
| border-left: 2px solid #d5d3d3; | |||||
| margin-bottom: 10px; | |||||
| font-size: 12px; | |||||
| } | |||||
| } | |||||
| .referencePopoverWrapper { | .referencePopoverWrapper { | ||||
| max-width: 50vw; | max-width: 50vw; | ||||
| } | } |
| } | } | ||||
| const nextText = replaceTextByOldReg(text); | const nextText = replaceTextByOldReg(text); | ||||
| return loading | return loading | ||||
| ? nextText?.concat('~~2$$') | |||||
| ? nextText?.concat('~~2$$') // TODO: The style of thinking also needs to be displayed when outputting | |||||
| : pipe(replaceThinkToSection, preprocessLaTeX)(nextText); | : pipe(replaceThinkToSection, preprocessLaTeX)(nextText); | ||||
| }, [content, loading, t]); | }, [content, loading, t]); | ||||
| <Markdown | <Markdown | ||||
| rehypePlugins={[rehypeWrapReference, rehypeKatex, rehypeRaw]} | rehypePlugins={[rehypeWrapReference, rehypeKatex, rehypeRaw]} | ||||
| remarkPlugins={[remarkGfm, remarkMath]} | remarkPlugins={[remarkGfm, remarkMath]} | ||||
| className={styles.markdownContentWrapper} | |||||
| components={ | components={ | ||||
| { | { | ||||
| 'custom-typography': ({ children }: { children: string }) => | 'custom-typography': ({ children }: { children: string }) => |
| return inlineProcessedContent; | return inlineProcessedContent; | ||||
| }; | }; | ||||
| export function replaceThinkToSection(text: string) { | |||||
| export function replaceThinkToSection(text: string = '') { | |||||
| const pattern = /<think>([\s\S]*?)<\/think>/g; | const pattern = /<think>([\s\S]*?)<\/think>/g; | ||||
| const result = text.replace(pattern, '<section class="think">$1</section>'); | const result = text.replace(pattern, '<section class="think">$1</section>'); |