-
Notifications
You must be signed in to change notification settings - Fork 3k
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
React Native Render HTML: whitespace collapsing (2d shot) #882
React Native Render HTML: whitespace collapsing (2d shot) #882
Conversation
Nice fix! Can you add on your previous PRs commits to this as we reverted the merge from |
@AndrewGable I just did a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Only one pesky merge conflict left to fix.
@AndrewGable I'm looking into it! Would you think it's fair if I add one extra workday for all this PR work? |
Yes, that's fine 👍 |
ec715d2
to
2ed6aad
Compare
This commit upgrade react-native-render-html from 4.2 to 6.0.0-alpha.10, handling whitespaces collapsing according to the CSS 3 Text Module standard. This new version has been written in TypeScript, and you should be able to discover the API with IntelliSense. The renderer API has changed, check this post for more information (Renderer API section): meliorence/react-native-render-html#434 (comment) Note on 6.0.0-alpha.10 This version offers a workaround regarding webpack "Terser" (minifier) plugin replacing unicode escape sequences in strings with unicode characters, which in turns results in SyntaxError during Regex instantiation in chrome browsers, see #876 (could not reproduce in Firefox). Instead, unicode escape sequences are used directly in a regex literal, which are not subject to such minifier optimization.
2ed6aad
to
bcca418
Compare
@AndrewGable OK, I successfully rebased on master (I had to port changes to the image renderer from ReportActionItemFragment.js to RenderHTML component). I tested on desktop and everything looked good. I also applied the linter. Hope everything will be fine this time 🙏 |
Deployed to web with out a hitch! 👍 Thank you! |
@AndrewGable Fantastic! You'll just need to confirm the ending of the mission on the malt.fr platform and the payment will be released on my end 🙂 |
Context
@AndrewGable This is a follow-up on #851. I've upgraded react-native-render-html to version 6.0.0-alpha.10, which fixes the Regex instantiation error faced in chrome browsers. Just to quote to commit:
I have tested the build locally, and the error indeed disappeared! To confirm my initial assumptions, I also tested the build with the alpha-8, and applied the below patch to webpack.prod.js. Indeed, the issue also disappeared!
Summary
src/styles/StyleSheet
(styles are passed to custom renderers, thus there is no need to define distinct styles for code and pre tags)src/pages/home/report/ReportActionItemFragment.js
to theRenderHTML
component, adapted to RNRH v6InlineCodeBlock
and adapted its logic to the new APIpropTypes
forAnchorForCommentsOnly
__DEV__
global variable in webpack environment, required by react-native-render-html, see https://reactnative.dev/docs/javascript-environmentNotes
enableCSSInlineProcessing
prop. If you think you might need this feature, I can enable it.systemFonts
for that purpose (I've already registered all the fonts declared insrc/styles/fontFamily
).Suggestions
Dimension
API. It is known for being unreliable, (see Make a decision about the Dimensions module react-native-community/discussions-and-proposals#291). I recommenduseWindowDimensions
hook instead!.eslintrc.js
is inconfig
folder, which is non standard. Would be best if the linter config could be picked automatically by VSCode, very handy for format action!Future work
DefaultTagRenderer
prop in the renderer component (he would require that you pass down all the props). But I realize that you tamper with the URL for credentials. Instead, you would need to reuse the internal HTMLImageElement component. I haven't exported that yet in the new API, but I will do so soon (see Use internal default renderers logic in custom renderers meliorence/react-native-render-html#424). I could work on a new PR as part of a distinct service if you are interested.RenderHTML
instance, a new instance ofTRenderEngine
is created, with a big tree of objects representing the underlying models for HTML tags and CSS properties, which in turns depends on configuration (custom renderers, styles ... Etc). I am planning to provide two additional React components:TRenderEngineProvider
, which will take config props and create a React context providing one engine instance;RenderHTMLFragment
, which will consume the engine and build the react tree from html / uri.Considering the linear cost of re-instantiating an engine for each message in the thread, I truly believe it could make a very sensible addition.
Fixed Issues
Fixes https://github.com/Expensify/Expensify/issues/143758
Tests
Open a chat thread and make sure: