Uh oh!
There was an error while loading. Please reload this page.
Substr measurements expensify - #56
Conversation
azimgd
commented
May 18, 2023
@Szymon20000 could you have a look please? |
061b587 to
d6ef986Compareparasharrajat
commented
May 24, 2023
Instead of |
azimgd
commented
May 25, 2023
https://reactnative.dev/docs/text#nested-text
Nested text with style is essentially just a string and not a view component, therefore this implementation isn't straightforward to implement. |
Taking a look now. Wouldn't be cleaner to implement onLayout for nested Text components? We could then wrap fragment that has to be highlighted into nested text.
|
azimgd
commented
May 29, 2023
It would, however please take a look at the comment above.
|
Szymon20000
commented
May 29, 2023
It doesn't seems to be that hard. At least just checked it on iOS Fabric. |
Szymon20000
commented
May 29, 2023
BaseTextShadowNode::buildAttributedString <- This method creates fragments. It could also create regions |
Szymon20000
commented
May 29, 2023
Otherwise the code seems to be correct to me :) |
Szymon20000
commented
May 29, 2023
We could also add regionID prop for nested text instead. Then paragraphEventEmitter would return map {regionID: RegionMeasurment} |
parasharrajat
commented
Jun 1, 2023
@azimgd Any thoughts on @Szymon20000's comments? |
@azimgd Any help with the above issue? |
perunt
commented
Jun 6, 2023
@parasharrajatthis PR fix this issue |
parasharrajat
commented
Jun 6, 2023
Awesome. Thanks @perunt. I'll watch it. |
puneetlath
commented
Jun 8, 2023
@azimgd thoughts on the feedback? |
azimgd
commented
Jun 15, 2023
I'm not entirely certain about the approach we should take here since it seems that the upstream PR will not be merged, and the expensify/RN fork is being abandoned. I'm actively working on it, but unfortunately cannot provide an estimate for when it will be completed. Let me know any thoughts or suggestions you may have, and I will keep you updated once I have smth. |
parasharrajat
commented
Jun 15, 2023
@azimgd We haven't finalized the decision of dropping the fork yet. If that is blocking you move forward, I will suggest we wait for the final verdict on it before you start spending time on a custom implementation. Also, it will be great to show us the plan before implementing it. |
Szymon20000
commented
Jun 15, 2023
I think the upstream pr could be merged. We just need to change the API a bit. |
puneetlath
commented
Jul 6, 2023
Hey @azimgd. Is this still something you want to work on or shall we ask someone else to try one of the alternative approaches? |
azimgd
commented
Jul 6, 2023
Hey @puneetlath, I'm still exploring alternative approach. |
puneetlath
commented
Jul 11, 2023
Ok cool. Can we help in any way? |
puneetlath
commented
Oct 19, 2023
Let's go ahead and close this out since we're no longer taking this approach. Thanks for the effort everyone! |

Upstream PR Link
react#37397
Summary
I would like to apply styling to a substring of text, such as a background color, padding, and rounded corners. This functionality could be used for:
@usernameis simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimenbook.The problem is that the Text element in RN behaves like a block element rather than an inline element when it is multiline. Additionally, it does not allow you to have borders or rounded corners. This makes it unsuitable for implementing a multiline inline code block.
Adding a new prop called textLayoutRegions which accepts an array of regions (substring positions) could be used to solve the problem. Passing this prop will calculate the regions [[start, end], [start, end] ...] position and pass the response into onTextLayout callback. Knowing exact substring position and dimensions will allow implementing custom styled View behind the text.
Changelog
[GENERAL] [ADDED] - New
textLayoutRegionsprop for Text component that accepts an array of substring regions. Each region's layout position will be appended intoonTextLayoutevent callback.[GENERAL] [ADDED] - New
regionsprops foronTextLayoutevent callback.Test Plan