Skip to content

Commit 7957c7a

Browse files
fix: rename default to auto alignment value (#607)
# Summary This PR: Updates readme for text alignment Refactors `default` to `auto` in alignment ## Test Plan Run example app and play around with alignment. When we do not set any alignment html should not contain `style-"text-alignment: ..."` ## Screenshots / Videos https://github.com/user-attachments/assets/47e53faf-76ff-450f-a121-f8e11b430bd4 ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ✅ | | Android | ❌ | ## Checklist - [ ] E2E tests are passing - [ ] Required E2E tests have been added (if applicable) ---------
1 parent 596a75b commit 7957c7a

4 files changed

Lines changed: 11 additions & 6 deletions

File tree

docs/INPUT_API_REFERENCE.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ interface OnChangeStateEvent {
299299
- `isActive` indicates if the style is active within current selection.
300300
- `isBlocking` indicates if the style is blocked by other currently active, meaning it can't be toggled.
301301
- `isConflicting` indicates if the style is in conflict with other currently active styles, meaning toggling it will remove conflicting style.
302-
- `alignment` indicates the current text alignment of the paragraph at the cursor position. Possible values: `'left'`, `'center'`, `'right'`, `'justify'`.
302+
- `alignment` indicates the current text alignment of the paragraph at the cursor position. Possible values: `'left'`, `'center'`, `'right'`, `'justify'`, `'auto'`.
303303

304304
| Type | Platform |
305305
|-------------------------------------------------------------|----------|
@@ -609,12 +609,15 @@ Sets the selection at the given indexes.
609609
### `.setTextAlignment()`
610610

611611
```ts
612-
setTextAlignment: (alignment: 'left' | 'center' | 'right' | 'justify' | 'default') => void;
612+
setTextAlignment: (alignment: 'left' | 'center' | 'right' | 'justify' | 'auto') => void;
613613
```
614614

615615
Sets text alignment for the paragraph(s) at the current selection. When inside a list, the alignment is applied to all contiguous list items.
616616

617-
- `alignment` - the desired text alignment. Use `'default'` to reset to the system natural alignment.
617+
- `alignment` - the desired text alignment. Use `'auto'` to reset to the system natural alignment.
618+
619+
> [!NOTE]
620+
> This method is iOS only for now.
618621
619622
### `.startMention()`
620623

ios/utils/AlignmentUtils.mm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ + (NSString *)alignmentToString:(NSTextAlignment)alignment {
1616
return @"justify";
1717
case NSTextAlignmentNatural:
1818
default:
19-
return @"left";
19+
return @"auto";
2020
}
2121
}
2222

@@ -68,6 +68,8 @@ + (NSString *)alignmentToMarker:(NSTextAlignment)alignment {
6868

6969
+ (NSString *)cssValueForAlignment:(NSTextAlignment)alignment {
7070
switch (alignment) {
71+
case NSTextAlignmentLeft:
72+
return @"left";
7173
case NSTextAlignmentCenter:
7274
return @"center";
7375
case NSTextAlignmentRight:

src/native/EnrichedTextInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export const EnrichedTextInput = ({
271271
Commands.setSelection(nullthrows(nativeRef.current), start, end);
272272
},
273273
setTextAlignment: (
274-
alignment: 'left' | 'center' | 'right' | 'justify' | 'default'
274+
alignment: 'left' | 'center' | 'right' | 'justify' | 'auto'
275275
) => {
276276
Commands.setTextAlignment(nullthrows(nativeRef.current), alignment);
277277
},

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ export interface EnrichedTextInputInstance extends NativeMethods {
426426
attributes?: Record<string, string>
427427
) => void;
428428
setTextAlignment: (
429-
alignment: 'left' | 'center' | 'right' | 'justify' | 'default'
429+
alignment: 'left' | 'center' | 'right' | 'justify' | 'auto'
430430
) => void;
431431
}
432432

0 commit comments

Comments
 (0)