Skip to content

Commit

Permalink
Merge pull request #4202 from Expensify/update-staging-from-main
Browse files Browse the repository at this point in the history
  • Loading branch information
OSBotify authored Jul 23, 2021
2 parents 910111f + 827f281 commit cdb143b
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 80 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001007905
versionName "1.0.79-5"
versionCode 1001007906
versionName "1.0.79-6"
}
splits {
abi {
Expand Down
2 changes: 1 addition & 1 deletion ios/ExpensifyCash/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.0.79.5</string>
<string>1.0.79.6</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/ExpensifyCashTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.79.5</string>
<string>1.0.79.6</string>
</dict>
</plist>
148 changes: 90 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "expensify.cash",
"version": "1.0.79-5",
"version": "1.0.79-6",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "Expensify.cash is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down Expand Up @@ -88,7 +88,7 @@
"react-native-picker-select": "8.0.4",
"react-native-plaid-link-sdk": "^7.0.5",
"react-native-reanimated": "^2.3.0-alpha.1",
"react-native-render-html": "^6.0.0-alpha.10",
"react-native-render-html": "6.0.0-beta.8",
"react-native-safe-area-context": "^3.1.4",
"react-native-screens": "^3.0.0",
"react-native-svg": "^12.1.0",
Expand Down
45 changes: 29 additions & 16 deletions src/components/RenderHTML/BaseRenderHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@ const EXTRA_FONTS = [
];

/**
* Compute images maximum width from the available screen width. This function
* Compute embedded maximum width from the available screen width. This function
* is used by the HTML component in the default renderer for img tags to scale
* down images that would otherwise overflow horizontally.
*
* @param {string} tagName - The name of the tag for which max width should be constrained.
* @param {number} contentWidth - The content width provided to the HTML
* component.
* @returns {number} The minimum between contentWidth and MAX_IMG_DIMENSIONS
*/
function computeImagesMaxWidth(contentWidth) {
return Math.min(MAX_IMG_DIMENSIONS, contentWidth);
function computeEmbeddedMaxWidth(tagName, contentWidth) {
if (tagName === 'img') {
return Math.min(MAX_IMG_DIMENSIONS, contentWidth);
}
return contentWidth;
}

function AnchorRenderer({tnode, key, style}) {
Expand Down Expand Up @@ -193,38 +197,47 @@ function ImgRenderer({tnode}) {
);
}

// Define default element models for these renderers.
AnchorRenderer.model = defaultHTMLElementModels.a;
CodeRenderer.model = defaultHTMLElementModels.code;
ImgRenderer.model = defaultHTMLElementModels.img;
EditedRenderer.model = defaultHTMLElementModels.span;
// Declare nonstandard tags and their content model here
const customHTMLElementModels = {
edited: defaultHTMLElementModels.span.extend({
tagName: 'edited',
}),
};

// Define the custom render methods
// Define the custom renderer components
const renderers = {
a: AnchorRenderer,
code: CodeRenderer,
img: ImgRenderer,
edited: EditedRenderer,
};

const renderersProps = {
img: {
initialDimensions: {
width: MAX_IMG_DIMENSIONS,
height: MAX_IMG_DIMENSIONS,
},
},
};

const BaseRenderHTML = ({html, debug, textSelectable}) => {
const {width} = useWindowDimensions();
const containerWidth = width * 0.8;
return (
<HTML
textSelectable={textSelectable}
defaultTextProps={{selectable: textSelectable}}
customHTMLElementModels={customHTMLElementModels}
renderers={renderers}
renderersProps={renderersProps}
baseStyle={webViewStyles.baseFontStyle}
tagsStyles={webViewStyles.tagStyles}
enableCSSInlineProcessing={false}
dangerouslyDisableWhitespaceCollapsing={false}
contentWidth={containerWidth}
computeImagesMaxWidth={computeImagesMaxWidth}
computeEmbeddedMaxWidth={computeEmbeddedMaxWidth}
systemFonts={EXTRA_FONTS}
imagesInitialDimensions={{
width: MAX_IMG_DIMENSIONS,
height: MAX_IMG_DIMENSIONS,
}}
html={html}
source={{html}}
debug={debug}
/>
);
Expand Down

0 comments on commit cdb143b

Please sign in to comment.