feat: improved SVG output UX (#8765)

This commit is contained in:
Hash Brown
2024-09-26 19:41:59 +08:00
committed by GitHub
parent 9a4b53a212
commit 3dfbc348e3
4 changed files with 95 additions and 61 deletions

View File

@@ -85,6 +85,19 @@ const Answer: FC<AnswerProps> = ({
getContentWidth()
}, [responding])
// Recalculate contentWidth when content changes (e.g., SVG preview/source toggle)
useEffect(() => {
if (!containerRef.current)
return
const resizeObserver = new ResizeObserver(() => {
getContentWidth()
})
resizeObserver.observe(containerRef.current)
return () => {
resizeObserver.disconnect()
}
}, [])
return (
<div className='flex mb-2 last:mb-0'>
<div className='shrink-0 relative w-10 h-10'>