Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hold] fixed spaces collapsing in Messages #3869

Merged
merged 4 commits into from
Jul 10, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 115 additions & 58 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"react-native-picker-select": "8.0.4",
"react-native-plaid-link-sdk": "^7.0.5",
"react-native-reanimated": "^2.1.0",
"react-native-render-html": "^6.0.0-alpha.10",
"react-native-safe-area-context": "^3.1.4",
"react-native-screens": "^3.0.0",
"react-native-svg": "^12.1.0",
Expand Down Expand Up @@ -151,6 +150,7 @@
"portfinder": "^1.0.28",
"pusher-js-mock": "^0.3.3",
"react-hot-loader": "^4.12.21",
"react-native-render-html": "^6.0.0-beta.7",
"react-native-svg-transformer": "^0.14.3",
"react-test-renderer": "16.13.1",
"semver": "^7.3.4",
Expand Down
23 changes: 16 additions & 7 deletions src/components/RenderHTML/BaseRenderHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ const EXTRA_FONTS = [
*
* @param {number} contentWidth - The content width provided to the HTML
* component.
* @param {number} tagName - tagname of the Element whose maxWidth is need to be set
parasharrajat marked this conversation as resolved.
Show resolved Hide resolved
* @returns {number} The minimum between contentWidth and MAX_IMG_DIMENSIONS
*/
function computeImagesMaxWidth(contentWidth) {
return Math.min(MAX_IMG_DIMENSIONS, contentWidth);
function computeEmbeddedMaxWidth(contentWidth, tagName) {
if (tagName === 'img') {
return Math.min(MAX_IMG_DIMENSIONS, contentWidth);
}
return contentWidth;
}

function AnchorRenderer({tnode, key, style}) {
Expand Down Expand Up @@ -218,13 +222,18 @@ const BaseRenderHTML = ({html, debug, textSelectable}) => {
tagsStyles={webViewStyles.tagStyles}
enableCSSInlineProcessing={false}
contentWidth={containerWidth}
computeImagesMaxWidth={computeImagesMaxWidth}
computeEmbeddedMaxWidth={computeEmbeddedMaxWidth}
systemFonts={EXTRA_FONTS}
imagesInitialDimensions={{
width: MAX_IMG_DIMENSIONS,
height: MAX_IMG_DIMENSIONS,
dangerouslyDisableWhitespaceCollapsing
renderersProps={{
img: {
initialDimensions: {
width: MAX_IMG_DIMENSIONS,
height: MAX_IMG_DIMENSIONS,
},
},
}}
html={html}
source={{html}}
debug={debug}
/>
);
Expand Down