Break on breaks for View components #2411
Open
+351
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Add logic for node splitting to continue to split nodes while there is a nested break inside of attached to a View. Some adjustments to logic to avoid a possible infinite loop.
Change to unwrappable fallback behavior for View / Text components to wrap when they don't fit within a page, to avoid content being lost. A warning is still logged, this behavior should likely be handled explicitly.
Notes:
Splitting on nested text breaks has some complexities, I believe, in that Lines are computed at the top level Text component (in the case of text components inside of text components). So a recomputation of lines would need to occur after doing a regular node split or such.
I believe nested text breaking is not really necessary, and should be able to be accomplished by adding break tags to view components. All though digging to top level text components with break tags could be reasonable to add. I added a test to demonstrate the relating behavior for nested text / view breaks.
This relies on the split logic and supporting logic behaving reasonably on deeply nested items. It appeared to, all though there my be other considerations here?
I published the fork to npm scong-react-fork-pdf-renderer for our use. (This is done through the distribution-2 branch in my fork repo)
Some related issues / enhancements
#1037
#1676