feat(android): custom style - #648
Conversation
…wski/feat-custom-style-android
There was a problem hiding this comment.
Pull request overview
Adds Android support for applying and persisting custom foreground/background colors in the enriched text editor by introducing a dedicated custom-style span, plumbing it through editing/state, and extending HTML parsing/serialization for <span style="...">.
Changes:
- Introduces
CustomStylesand aEnriched*CustomStyleSpanto apply/merge/split foreground & background color spans during editing. - Extends span/state plumbing to track and emit
customStyleinonChangeState, and wiressetStyle(...)command on Android. - Updates HTML import/export to parse/serialize CSS
color/background-colorvia a newEnrichedColorParser.
Reviewed changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| android/src/main/java/com/swmansion/enriched/textinput/watchers/EnrichedTextWatcher.kt | Runs custom-style span maintenance after text edits. |
| android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpanState.kt | Tracks customStyle and emits it in state payload. |
| android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSelection.kt | Detects active custom-style at selection and updates span state. |
| android/src/main/java/com/swmansion/enriched/textinput/styles/CustomStyles.kt | New: applies custom-style spans for selection/caret and maintains span integrity. |
| android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedSpans.kt | Registers the new custom-style span type and merging config. |
| android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputCustomStyleSpan.kt | New: input-side custom-style span implementation. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputViewManager.kt | Implements Android setStyle command by delegating to the view. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt | Adds setStyle(...) entrypoint and transactions for applying custom style. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputSpannableFactory.kt | Creates custom-style spans when parsing HTML into the input. |
| android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextCustomStyleSpan.kt | New: read-only text rendering custom-style span implementation. |
| android/src/main/java/com/swmansion/enriched/text/EnrichedTextSpanFactory.kt | Creates custom-style spans when parsing HTML for enriched text rendering. |
| android/src/main/java/com/swmansion/enriched/common/spans/EnrichedCustomStyleSpan.kt | New: base span that applies foreground/background colors to TextPaint. |
| android/src/main/java/com/swmansion/enriched/common/parser/EnrichedSpanFactory.kt | Adds factory method for creating custom-style spans. |
| android/src/main/java/com/swmansion/enriched/common/parser/EnrichedParser.java | Parses <span style> to spans and serializes custom-style spans back to <span style>. |
| android/src/main/java/com/swmansion/enriched/common/parser/EnrichedColorParser.kt | New: parses CSS colors and serializes ARGB to hex. |
| android/src/main/java/com/swmansion/enriched/common/EnrichedSpanFlags.kt | Assigns priority/flags for custom-style spans. |
| android/src/main/java/com/swmansion/enriched/common/CustomStyle.kt | New: stores foreground/background color state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…wski/feat-custom-style-android
|
Currently you can't see the selection and the cursor inside a text with some background color set Screen.Recording.2026-07-29.at.10.51.09.mov |
@hejsztynx, |
Summary
Add custom style to support foreground and background colors
Test Plan
Run the example app and experiment with applying foreground and background colors through the toolbar across different text styles.
Screenshots / Videos
Screen.Recording.2026-06-22.at.09.08.41.mov
Compatibility
Checklist