Skip to content

feat(android): add support for custom style#648

Open
kacperzolkiewski wants to merge 7 commits into
@kacperzolkiewski/feat-custom-stylefrom
@kaceprzolkiewski/feat-custom-style-android
Open

feat(android): add support for custom style#648
kacperzolkiewski wants to merge 7 commits into
@kacperzolkiewski/feat-custom-stylefrom
@kaceprzolkiewski/feat-custom-style-android

Conversation

@kacperzolkiewski

@kacperzolkiewski kacperzolkiewski commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

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

OS Implemented
iOS
Android

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CustomStyles and a Enriched*CustomStyleSpan to apply/merge/split foreground & background color spans during editing.
  • Extends span/state plumbing to track and emit customStyle in onChangeState, and wires setStyle(...) command on Android.
  • Updates HTML import/export to parse/serialize CSS color / background-color via a new EnrichedColorParser.

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.

@kacperzolkiewski kacperzolkiewski marked this pull request as ready for review June 22, 2026 08:04
@kacperzolkiewski kacperzolkiewski requested a review from exploIF June 22, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants