diff --git a/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js b/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js index e156c8bda3f40..5417f7af68204 100755 --- a/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js +++ b/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js @@ -48,7 +48,7 @@ const customHTMLElementModels = { 'mention-here': defaultHTMLElementModels.span.extend({tagName: 'mention-here'}), }; -const defaultViewProps = {style: [styles.alignItemsStart, styles.userSelectText, styles.w100, styles.h100]}; +const defaultViewProps = {style: [styles.alignItemsStart, styles.userSelectText]}; // We are using the explicit composite architecture for performance gains. // Configuration for RenderHTML is handled in a top-level component providing diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js index 2f4ee77803460..643785ab09d1b 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js @@ -43,23 +43,19 @@ function ImageRenderer(props) { const imageHeight = htmlAttribs['data-expensify-height'] ? parseInt(htmlAttribs['data-expensify-height'], 10) : undefined; const imagePreviewModalDisabled = htmlAttribs['data-expensify-preview-modal-disabled'] === 'true'; - const shouldFitContainer = htmlAttribs['data-expensify-fit-container'] === 'true'; - const sizingStyle = shouldFitContainer ? [styles.w100, styles.h100] : []; - return imagePreviewModalDisabled ? ( ) : ( {({anchor, report, action, checkIfContextMenuActive}) => ( { const route = ROUTES.getReportAttachmentRoute(report.reportID, source); Navigation.navigate(route); @@ -70,11 +66,10 @@ function ImageRenderer(props) { > )} diff --git a/src/components/ReportActionItem/ReportActionItemImage.js b/src/components/ReportActionItem/ReportActionItemImage.js index f88b84b76a170..089df6cb4a6fe 100644 --- a/src/components/ReportActionItem/ReportActionItemImage.js +++ b/src/components/ReportActionItem/ReportActionItemImage.js @@ -1,8 +1,15 @@ import React from 'react'; import PropTypes from 'prop-types'; import styles from '../../styles/styles'; -import RenderHTML from '../RenderHTML'; import Image from '../Image'; +import ThumbnailImage from '../ThumbnailImage'; +import tryResolveUrlFromApiRoot from '../../libs/tryResolveUrlFromApiRoot'; +import ROUTES from '../../ROUTES'; +import CONST from '../../CONST'; +import {ShowContextMenuContext} from '../ShowContextMenuContext'; +import Navigation from '../../libs/Navigation/Navigation'; +import PressableWithoutFocus from '../Pressable/PressableWithoutFocus'; +import useLocalize from '../../hooks/useLocalize'; const propTypes = { /** thumbnail URI for the image */ @@ -20,20 +27,47 @@ const defaultProps = { enablePreviewModal: false, }; +/** + * An image with an optional thumbnail that fills its parent container. If the thumbnail is passed, + * we try to resolve both the image and thumbnail from the API. Similar to ImageRenderer, we show + * and optional preview modal as well. + */ + function ReportActionItemImage({thumbnail, image, enablePreviewModal}) { + const {translate} = useLocalize(); + if (thumbnail) { - return ( - - `} + const imageSource = tryResolveUrlFromApiRoot(image); + const thumbnailSource = tryResolveUrlFromApiRoot(thumbnail); + const thumbnailComponent = ( + ); + + if (enablePreviewModal) { + return ( + + {({report}) => ( + { + const route = ROUTES.getReportAttachmentRoute(report.reportID, imageSource); + Navigation.navigate(route); + }} + accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON} + accessibilityLabel={translate('accessibilityHints.viewAttachment')} + > + {thumbnailComponent} + + )} + + ); + } + return thumbnailComponent; } return (