@@ -982,8 +982,10 @@ const MarkdownLinkFavicon = memo(function MarkdownLinkFavicon({ host }: { host:
982982} ) ;
983983
984984const CHAT_MARKDOWN_IMAGE_BOUNDS_CLASS_NAME = "max-h-[30rem] max-w-[min(100%,30rem)]" ;
985+ const CHAT_MARKDOWN_IMAGE_ALIGNMENT_CLASS_NAME = "align-bottom" ;
985986const CHAT_MARKDOWN_IMAGE_SIZE_CLASS_NAME = cn (
986987 "h-auto w-auto object-contain" ,
988+ CHAT_MARKDOWN_IMAGE_ALIGNMENT_CLASS_NAME ,
987989 CHAT_MARKDOWN_IMAGE_BOUNDS_CLASS_NAME ,
988990) ;
989991
@@ -993,22 +995,29 @@ function authoredImageSizeStyle(
993995) : CSSProperties | undefined {
994996 const parsedWidth = Number ( width ) ;
995997 const parsedHeight = Number ( height ) ;
996- const style : CSSProperties = { } ;
997- if ( Number . isFinite ( parsedWidth ) && parsedWidth > 0 ) style . width = parsedWidth ;
998- if ( Number . isFinite ( parsedHeight ) && parsedHeight > 0 ) style . height = parsedHeight ;
999- if ( style . width !== undefined && style . height !== undefined ) {
1000- style . aspectRatio = `${ parsedWidth } / ${ parsedHeight } ` ;
1001- style . height = "auto" ;
1002- style . maxWidth = `min(100%, 30rem, ${ ( 30 * parsedWidth ) / parsedHeight } rem)` ;
998+ const hasWidth = Number . isFinite ( parsedWidth ) && parsedWidth > 0 ;
999+ const hasHeight = Number . isFinite ( parsedHeight ) && parsedHeight > 0 ;
1000+ if ( hasWidth && hasHeight ) {
1001+ return {
1002+ width : parsedWidth ,
1003+ height : "auto" ,
1004+ aspectRatio : `${ parsedWidth } / ${ parsedHeight } ` ,
1005+ maxWidth : `min(100%, 30rem, ${ ( 30 * parsedWidth ) / parsedHeight } rem)` ,
1006+ } ;
10031007 }
1004- return style . width === undefined && style . height === undefined ? undefined : style ;
1008+ if ( hasWidth ) return { maxWidth : `min(100%, 30rem, ${ parsedWidth } px)` } ;
1009+ if ( hasHeight ) return { maxHeight : `min(30rem, ${ parsedHeight } px)` } ;
1010+ return undefined ;
10051011}
10061012
1007- const CHAT_MARKDOWN_WORKSPACE_IMAGE_LAYOUT_CLASS_NAME = "inline-block! align-bottom" ;
1013+ const CHAT_MARKDOWN_WORKSPACE_IMAGE_LAYOUT_CLASS_NAME = cn (
1014+ "inline-block!" ,
1015+ CHAT_MARKDOWN_IMAGE_ALIGNMENT_CLASS_NAME ,
1016+ ) ;
10081017const CHAT_MARKDOWN_WORKSPACE_IMAGE_CLASS_NAME = cn (
10091018 CHAT_MARKDOWN_IMAGE_SIZE_CLASS_NAME ,
10101019 CHAT_MARKDOWN_WORKSPACE_IMAGE_LAYOUT_CLASS_NAME ,
1011- "my-1 rounded-lg border border-border/40" ,
1020+ "rounded-lg border border-border/40" ,
10121021) ;
10131022
10141023function ChatMarkdownImageFallback ( props : {
@@ -1020,7 +1029,7 @@ function ChatMarkdownImageFallback(props: {
10201029 data-markdown-copy = { props . copyMarkdown }
10211030 className = { cn (
10221031 CHAT_MARKDOWN_WORKSPACE_IMAGE_LAYOUT_CLASS_NAME ,
1023- "my-1 rounded-md border border-border/40 bg-muted/40 px-2 py-1 text-xs text-muted-foreground" ,
1032+ "rounded-md border border-border/40 bg-muted/40 px-2 py-1 text-xs text-muted-foreground" ,
10241033 ) }
10251034 >
10261035 < span className = "inline-flex items-center gap-1.5" >
@@ -1058,7 +1067,7 @@ const ChatMarkdownWorkspaceImage = memo(function ChatMarkdownWorkspaceImage(prop
10581067 aria-label = "Loading image"
10591068 className = { cn (
10601069 CHAT_MARKDOWN_WORKSPACE_IMAGE_LAYOUT_CLASS_NAME ,
1061- "my-1 aspect-video w-64 max-w-full rounded-lg bg-muted/60" ,
1070+ "aspect-video w-64 max-w-full rounded-lg bg-muted/60" ,
10621071 CHAT_MARKDOWN_IMAGE_BOUNDS_CLASS_NAME ,
10631072 ) }
10641073 style = { props . style }
0 commit comments