💄 feat(playground): Enhance the fade-in animation for the chat

This commit is contained in:
Apple\Apple
2025-06-02 20:15:00 +08:00
parent bafb0078e2
commit 3a5013b876
4 changed files with 95 additions and 8 deletions

View File

@@ -315,6 +315,7 @@ function _MarkdownContent(props) {
content,
className,
animated = false,
previousContentLength = 0,
} = props;
const escapedContent = useMemo(() => {
@@ -336,10 +337,10 @@ function _MarkdownContent(props) {
],
];
if (animated) {
base.push(rehypeSplitWordsIntoSpans);
base.push([rehypeSplitWordsIntoSpans, { previousContentLength }]);
}
return base;
}, [animated]);
}, [animated, previousContentLength]);
return (
<ReactMarkdown
@@ -463,6 +464,7 @@ export function MarkdownRenderer(props) {
className,
style,
animated = false,
previousContentLength = 0,
...otherProps
} = props;
@@ -498,7 +500,12 @@ export function MarkdownRenderer(props) {
正在渲染...
</div>
) : (
<MarkdownContent content={content} className={className} animated={animated} />
<MarkdownContent
content={content}
className={className}
animated={animated}
previousContentLength={previousContentLength}
/>
)}
</div>
);