Skip to content

Support for Text Alignment #365#478

Closed
Wmg20 wants to merge 5 commits intosoftware-mansion:mainfrom
Wmg20:feat/support-for-text-alignment
Closed

Support for Text Alignment #365#478
Wmg20 wants to merge 5 commits intosoftware-mansion:mainfrom
Wmg20:feat/support-for-text-alignment

Conversation

@Wmg20
Copy link

@Wmg20 Wmg20 commented Mar 10, 2026

Summary

Support for feature request: #365

This PR introduces text alignment support (left, center, right) to EnrichedTextInput.

Features & Implementation:

  • Core API: Added setParagraphAlignment(alignment) to the JS Ref and included alignment structures in the text change events.
  • Android: Handled paragraph alignment using Android Layout.Alignment spans (ALIGN_NORMAL, ALIGN_CENTER, ALIGN_OPPOSITE). Emits active alignment state back to the JS context.
  • iOS: Implemented native NSTextAlignment via NSMutableParagraphStyle and updated the active alignment state when cursor location changes.
  • Example App: Included Left, Center, and Right buttons in the floating toolbar, correctly updating to reflect the cursor's current line alignment. Updated API_REFERENCE.md to document the new functionality.

Test Plan

  1. Compile and run the example application.
  2. Type multiple paragraphs.
  3. Tap the alignment buttons in the floating toolbar and verify the text correctly aligns to Left, Center, and Right.
  4. Move the cursor between differently aligned paragraphs and verify the active button in the toolbar dynamically updates.
  5. Verify behavior on both platforms (iOS and Android).

Screenshots / Videos

android-text-alignment iOS-text-alignment

Compatibility

OS Implemented
iOS
Android

@kacperzolkiewski
Copy link
Collaborator

kacperzolkiewski commented Mar 11, 2026

Hello @Wmg20,
Thank you for opening this PR, we really appreciate the contribution!

I wanted to let you know that we already have an iOS implementation of text alignment in #403, which is currently awaiting review. If it gets merged, we'd love to have the Android side implemented in a similar fashion so both platforms stay consistent.
A few key points from the iOS approach that would be great to align on:

  1. List alignment is applied as a unit:
  • when the cursor is inside a list, the alignment change is applied to all contiguous list items, not just the current paragraph.
  1. List markers stay on the left:
  • regardless of text alignment (right, center, etc.), bullets / numbers / checkboxes are always drawn at the left margin.

It would be great if you could take a look at #403 and adapt the Android implementation to follow the same conventions. That way we keep the behavior consistent across platforms.

Thanks again for your effort and feel free to reach out if you have any questions!

@Wmg20
Copy link
Author

Wmg20 commented Mar 14, 2026

Hi @kacperzolkiewski ,

Thanks for the clarification and the detailed context.

I’ll take a look at #403 and align the Android implementation with the iOS approach so the behavior stays consistent across platforms. In particular, I’ll make sure that:

List alignment is applied to the entire contiguous list, not just the current paragraph when the cursor is inside a list.

List markers remain left-aligned, regardless of the selected text alignment (center, right, etc.).

I’ll update the Android implementation accordingly and push the changes.
Thanks again for pointing this out!

@kacperzolkiewski
Copy link
Collaborator

@Wmg20 I’ll close this PR since you’ve opened the Android version: #488

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.

3 participants