diff --git a/src/app/components/media/Image.test.tsx b/src/app/components/media/Image.test.tsx index b7f32a662..c74db1c2a 100644 --- a/src/app/components/media/Image.test.tsx +++ b/src/app/components/media/Image.test.tsx @@ -64,6 +64,22 @@ describe('Image', () => { expect(rendered).toHaveAttribute('height', '123'); }); + it('keeps lottie emoticons at inline-emoticon size', async () => { + const gzipped = Buffer.from(gzipSync(lottieJson)).toString('base64'); + render( + + ); + + await waitFor(() => expect(screen.getByLabelText('emoticon').tagName).toBe('CANVAS')); + const canvas = screen.getByLabelText('emoticon'); + expect(canvas.parentElement).toHaveStyle({ width: '1em', height: '1em' }); + }); + it('forwards the canvas ref and pointer events for lottie images', async () => { const gzipped = Buffer.from(gzipSync(lottieJson)).toString('base64'); const ref = createRef(); diff --git a/src/app/components/media/Image.tsx b/src/app/components/media/Image.tsx index 7c01e1372..55ec8be10 100644 --- a/src/app/components/media/Image.tsx +++ b/src/app/components/media/Image.tsx @@ -10,6 +10,7 @@ import type { IImageInfo } from '$types/matrix/common'; type ImageProps = Omit, 'onPointerDown'> & { info?: IImageInfo; mimeType?: string; + disableDefaultSizing?: boolean; disablePixelation?: boolean; pixelated?: boolean; onLottieLoad?: (canvas?: HTMLCanvasElement) => void; @@ -274,6 +275,7 @@ function resolveCachedLottieJson(src: string): Promise { type LottieImageProps = LottieDotProps & { data: string; alt?: string; + emoticon?: boolean; onLottieLoad?: (canvas?: HTMLCanvasElement) => void; onLottieError?: () => void; pixelated?: boolean; @@ -284,6 +286,7 @@ type LottieImageProps = LottieDotProps & { function LottieImage({ data, alt, + emoticon, className, style, onLottieLoad, @@ -353,7 +356,12 @@ function LottieImage({
(); const lottieProps = props as LottieDotProps; + const emoticon = 'data-mx-emoticon' in props; const declaredLottieCandidate = isGzippedLottieCandidate( src, mimeType ?? info?.mimetype, @@ -410,7 +420,7 @@ export const Image = forwardRef