MBL-3092: Add support for text links & improve annotated string concatenation#2483
Merged
MBL-3092: Add support for text links & improve annotated string concatenation#2483
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2483 +/- ##
============================================
- Coverage 64.43% 64.42% -0.01%
+ Complexity 2433 2432 -1
============================================
Files 385 385
Lines 29196 29196
Branches 4229 4229
============================================
- Hits 18811 18810 -1
Misses 8103 8103
- Partials 2282 2283 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Arkariang
approved these changes
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📲 What
Add support for text links, and improve how
AnnotatedStrings are concatenated overall, with spaces between them.🤔 Why
Project story text should be generally readable. In addition, for parity with the pre-existing implementation, text links should be clickable and handled accordingly.
🛠 How
After transformation, a rich text block that contains any styled or linked text becomes a parent
Paragraph,Header, orListItemobject, with a list ofChildParagraphs forchildren.Use the list of
ChildParagraphs to build anAnnotatedString(which is eventually passed to aTextcomposable): Within anAnnotatedString.Builder, process eachChildParagraphby mapping availablestylesandlinkproperties toSpanStyleandLinkAnnotation.Urlrespectively, thenappend()thetextproperty.Link Support
Strings annotated with
LinkAnnotation.Urlare handled by a defaultUriHandlerCompositionLocal(LocalUriHandler). Provide a customUriHandlerthat simply callsApplicationUtils.openUrlExternally()to match the behavior of the pre-existing Project Story implementation. Note:openUrlExternallyattempts to force links to open in a browser-like app, bypassing deep linking behavior for any supported apps (including e.g. YouTube, Bluesky, the Kickstarter app itself, etc.).Concatenation
In a typical scenario, for all but the last
ChildParagraph, we would subsequentlyappend()a space. However, due to the particular way in which the server-side parser currently processes linked & styled text, the API can return child elements withtextthat starts with punctuation.Some examples from the Roller Pro Project:
Link
Style
Note
We anticipate possible changes to the API in the future.
To handle this detail now, flip the logic to
append()a space before each processedChildParagraphexcept for the first, and only if the first character oftextneeds a leading space. To determine if a character needs a leading space, defer to the Unicode categories from theCharacterclass alongside a small set of specific characters.While this solution considers multiple languages, the Kickstarter story editor and server-side parser both effectively expect stories in English; and this overall scenario is highly dependent on whether or not punctuation and surrounding text is styled, such that this approach works for a vast majority of cases (excuse our French).
👀 See
Before 🐛
Styled text runs together with normal text. Links neither styled nor clickable
Screen_recording_20260304_120953.mp4
After 🦋 |
All text is readable. Links are styled and clickable.
Screen_recording_20260304_123357.mp4
📋 QA
Story 📖
[MBL-3092] Handle text links + improve styled text spacing - Jira