Skip to content

Commit c4f4b9e

Browse files
iray-tnoclaude
andcommitted
Rename to CSS lineBreak and wordBreak
Per review, align the props with CSS `line-break` and `word-break` instead of Android's LineBreakConfig terms, and document them as Android-only for now: - android_lineBreakStyle ('none' | 'loose' | 'normal' | 'strict') -> lineBreak ('auto' | 'loose' | 'normal' | 'strict') - android_lineBreakWordStyle ('none' | 'phrase') -> wordBreak ('normal' | 'auto-phrase') The C++ enums, ParagraphAttributes fields and MapBuffer keys follow the CSS names. 'auto' and 'normal' still set no LineBreakConfig, so default layout is unchanged. Regenerate the TypeScript and C++ API snapshots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 8e85522 commit c4f4b9e

19 files changed

Lines changed: 209 additions & 227 deletions

File tree

‎packages/react-native/Libraries/Text/TextNativeComponent.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ const textViewConfig = {
4747
onTextLayout: true,
4848
dataDetectorType: true,
4949
android_hyphenationFrequency: true,
50-
android_lineBreakStyle: true,
51-
android_lineBreakWordStyle: true,
50+
lineBreak: true,
51+
wordBreak: true,
5252
lineBreakStrategyIOS: true,
5353
},
5454
directEventTypes: {

‎packages/react-native/Libraries/Text/TextProps.js‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,26 +151,28 @@ type TextBaseProps = Readonly<{
151151

152152
/**
153153
* Sets the strictness of the line-breaking rules, such as which characters
154-
* may start or end a line in Chinese and Japanese text (kinsoku). Matches CSS
155-
* `line-break`. Ignored below Android 13 (API level 33).
154+
* may start or end a line in Chinese and Japanese text (kinsoku), as CSS
155+
* `line-break`. Currently Android only, and ignored below Android 13 (API
156+
* level 33).
156157
*
157-
* @default `'none'`
158+
* @default `'auto'`
158159
* @platform android
159160
*/
160-
android_lineBreakStyle?: ?('none' | 'loose' | 'normal' | 'strict'),
161+
lineBreak?: ?('auto' | 'loose' | 'normal' | 'strict'),
161162

162163
/**
163-
* Sets word-based line breaking. `'phrase'` breaks Japanese text at phrase
164-
* boundaries instead of between any two characters. Matches CSS
165-
* `word-break: auto-phrase`. Ignored below Android 13 (API level 33).
164+
* Sets word-based line breaking, as CSS `word-break`. `'auto-phrase'` breaks
165+
* Japanese text at phrase boundaries instead of between any two characters.
166+
* Currently Android only, and ignored below Android 13 (API level 33).
166167
*
167168
* Support depends on the locale, and text is laid out in the device locale:
168-
* where that locale has no phrase-based breaking, `'phrase'` has no effect.
169+
* where that locale has no phrase-based breaking, `'auto-phrase'` has no
170+
* effect.
169171
*
170-
* @default `'none'`
172+
* @default `'normal'`
171173
* @platform android
172174
*/
173-
android_lineBreakWordStyle?: ?('none' | 'phrase'),
175+
wordBreak?: ?('normal' | 'auto-phrase'),
174176

175177
children?: ?React.Node,
176178

‎packages/react-native/ReactAndroid/api/ReactAndroid.api‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6079,8 +6079,6 @@ public class com/facebook/react/views/text/ReactTextViewManager : com/facebook/r
60796079
public final fun setAccessible (Lcom/facebook/react/views/text/ReactTextView;Z)V
60806080
public final fun setAdjustFontSizeToFit (Lcom/facebook/react/views/text/ReactTextView;Z)V
60816081
public final fun setAndroidHyphenationFrequency (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
6082-
public final fun setAndroidLineBreakStyle (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
6083-
public final fun setAndroidLineBreakWordStyle (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
60846082
public final fun setBorderColor (Lcom/facebook/react/views/text/ReactTextView;ILjava/lang/Integer;)V
60856083
public final fun setBorderRadius (Lcom/facebook/react/views/text/ReactTextView;IF)V
60866084
public final fun setBorderRadius (Lcom/facebook/react/views/text/ReactTextView;ILcom/facebook/react/bridge/Dynamic;)V
@@ -6092,6 +6090,7 @@ public class com/facebook/react/views/text/ReactTextViewManager : com/facebook/r
60926090
public final fun setFontSize (Lcom/facebook/react/views/text/ReactTextView;F)V
60936091
public final fun setIncludeFontPadding (Lcom/facebook/react/views/text/ReactTextView;Z)V
60946092
public final fun setLetterSpacing (Lcom/facebook/react/views/text/ReactTextView;F)V
6093+
public final fun setLineBreak (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
60956094
public final fun setNumberOfLines (Lcom/facebook/react/views/text/ReactTextView;I)V
60966095
public final fun setOverflow (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
60976096
public synthetic fun setPadding (Landroid/view/View;IIII)V
@@ -6100,6 +6099,7 @@ public class com/facebook/react/views/text/ReactTextViewManager : com/facebook/r
61006099
public final fun setSelectable (Lcom/facebook/react/views/text/ReactTextView;Z)V
61016100
public final fun setSelectionColor (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/Integer;)V
61026101
public final fun setTextAlignVertical (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
6102+
public final fun setWordBreak (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
61036103
public synthetic fun updateExtraData (Landroid/view/View;Ljava/lang/Object;)V
61046104
public fun updateExtraData (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/Object;)V
61056105
public synthetic fun updateState (Landroid/view/View;Lcom/facebook/react/uimanager/ReactStylesDiffMap;Lcom/facebook/react/uimanager/StateWrapper;)Ljava/lang/Object;

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.kt‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,17 +343,17 @@ public constructor(
343343
}
344344
}
345345

346-
@ReactProp(name = "android_lineBreakStyle")
347-
public fun setAndroidLineBreakStyle(view: ReactTextView, lineBreakStyle: String?) {
346+
@ReactProp(name = "lineBreak")
347+
public fun setLineBreak(view: ReactTextView, lineBreak: String?) {
348348
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
349-
view.lineBreakStyle = TextAttributeProps.getLineBreakStyle(lineBreakStyle)
349+
view.lineBreakStyle = TextAttributeProps.getLineBreakStyle(lineBreak)
350350
}
351351
}
352352

353-
@ReactProp(name = "android_lineBreakWordStyle")
354-
public fun setAndroidLineBreakWordStyle(view: ReactTextView, lineBreakWordStyle: String?) {
353+
@ReactProp(name = "wordBreak")
354+
public fun setWordBreak(view: ReactTextView, wordBreak: String?) {
355355
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
356-
view.lineBreakWordStyle = TextAttributeProps.getLineBreakWordStyle(lineBreakWordStyle)
356+
view.lineBreakWordStyle = TextAttributeProps.getLineBreakWordStyle(wordBreak)
357357
}
358358
}
359359

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.kt‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -616,28 +616,30 @@ public class TextAttributeProps private constructor() {
616616

617617
// The LineBreakConfig constants are inlined at compile time, so reading them is safe below API
618618
// 33. Callers apply the result only on API 33+.
619+
// Maps CSS `line-break` values to LineBreakConfig.LINE_BREAK_STYLE_*.
619620
@SuppressLint("InlinedApi")
620-
internal fun getLineBreakStyle(lineBreakStyle: String?): Int =
621-
when (lineBreakStyle) {
621+
internal fun getLineBreakStyle(lineBreak: String?): Int =
622+
when (lineBreak) {
622623
null,
623-
"none" -> LineBreakConfig.LINE_BREAK_STYLE_NONE
624+
"auto" -> LineBreakConfig.LINE_BREAK_STYLE_NONE
624625
"loose" -> LineBreakConfig.LINE_BREAK_STYLE_LOOSE
625626
"normal" -> LineBreakConfig.LINE_BREAK_STYLE_NORMAL
626627
"strict" -> LineBreakConfig.LINE_BREAK_STYLE_STRICT
627628
else -> {
628-
FLog.w(ReactConstants.TAG, "Invalid android_lineBreakStyle: $lineBreakStyle")
629+
FLog.w(ReactConstants.TAG, "Invalid lineBreak: $lineBreak")
629630
LineBreakConfig.LINE_BREAK_STYLE_NONE
630631
}
631632
}
632633

634+
// Maps CSS `word-break` values to LineBreakConfig.LINE_BREAK_WORD_STYLE_*.
633635
@SuppressLint("InlinedApi")
634-
internal fun getLineBreakWordStyle(lineBreakWordStyle: String?): Int =
635-
when (lineBreakWordStyle) {
636+
internal fun getLineBreakWordStyle(wordBreak: String?): Int =
637+
when (wordBreak) {
636638
null,
637-
"none" -> LineBreakConfig.LINE_BREAK_WORD_STYLE_NONE
638-
"phrase" -> LineBreakConfig.LINE_BREAK_WORD_STYLE_PHRASE
639+
"normal" -> LineBreakConfig.LINE_BREAK_WORD_STYLE_NONE
640+
"auto-phrase" -> LineBreakConfig.LINE_BREAK_WORD_STYLE_PHRASE
639641
else -> {
640-
FLog.w(ReactConstants.TAG, "Invalid android_lineBreakWordStyle: $lineBreakWordStyle")
642+
FLog.w(ReactConstants.TAG, "Invalid wordBreak: $wordBreak")
641643
LineBreakConfig.LINE_BREAK_WORD_STYLE_NONE
642644
}
643645
}

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ internal object TextLayoutManager {
100100
const val PA_KEY_TEXT_ALIGN_VERTICAL: Int = 8
101101
const val PA_KEY_TEXT_WIDTH_MODE: Int = 9
102102
const val PA_KEY_MINIMUM_FONT_SCALE: Int = 10
103-
const val PA_KEY_LINE_BREAK_STYLE: Int = 11
104-
const val PA_KEY_LINE_BREAK_WORD_STYLE: Int = 12
103+
const val PA_KEY_LINE_BREAK: Int = 11
104+
const val PA_KEY_WORD_BREAK: Int = 12
105105

106106
private val TAG: String = TextLayoutManager::class.java.simpleName
107107

@@ -1197,14 +1197,14 @@ internal object TextLayoutManager {
11971197
)
11981198
val lineBreakStyle =
11991199
TextAttributeProps.getLineBreakStyle(
1200-
if (paragraphAttributes.contains(PA_KEY_LINE_BREAK_STYLE))
1201-
paragraphAttributes.getString(PA_KEY_LINE_BREAK_STYLE)
1200+
if (paragraphAttributes.contains(PA_KEY_LINE_BREAK))
1201+
paragraphAttributes.getString(PA_KEY_LINE_BREAK)
12021202
else null,
12031203
)
12041204
val lineBreakWordStyle =
12051205
TextAttributeProps.getLineBreakWordStyle(
1206-
if (paragraphAttributes.contains(PA_KEY_LINE_BREAK_WORD_STYLE))
1207-
paragraphAttributes.getString(PA_KEY_LINE_BREAK_WORD_STYLE)
1206+
if (paragraphAttributes.contains(PA_KEY_WORD_BREAK))
1207+
paragraphAttributes.getString(PA_KEY_WORD_BREAK)
12081208
else null,
12091209
)
12101210
val adjustFontSizeToFit =

‎packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ bool ParagraphAttributes::operator==(const ParagraphAttributes& rhs) const {
2323
adjustsFontSizeToFit,
2424
includeFontPadding,
2525
android_hyphenationFrequency,
26-
android_lineBreakStyle,
27-
android_lineBreakWordStyle,
26+
lineBreak,
27+
wordBreak,
2828
textAlignVertical) ==
2929
std::tie(
3030
rhs.maximumNumberOfLines,
@@ -34,8 +34,8 @@ bool ParagraphAttributes::operator==(const ParagraphAttributes& rhs) const {
3434
rhs.adjustsFontSizeToFit,
3535
rhs.includeFontPadding,
3636
rhs.android_hyphenationFrequency,
37-
rhs.android_lineBreakStyle,
38-
rhs.android_lineBreakWordStyle,
37+
rhs.lineBreak,
38+
rhs.wordBreak,
3939
rhs.textAlignVertical) &&
4040
floatEquality(minimumFontSize, rhs.minimumFontSize) &&
4141
floatEquality(minimumFontScale, rhs.minimumFontScale);
@@ -80,13 +80,9 @@ SharedDebugStringConvertibleList ParagraphAttributes::getDebugProps() const {
8080
android_hyphenationFrequency,
8181
paragraphAttributes.android_hyphenationFrequency),
8282
debugStringConvertibleItem(
83-
"android_lineBreakStyle",
84-
android_lineBreakStyle,
85-
paragraphAttributes.android_lineBreakStyle),
83+
"lineBreak", lineBreak, paragraphAttributes.lineBreak),
8684
debugStringConvertibleItem(
87-
"android_lineBreakWordStyle",
88-
android_lineBreakWordStyle,
89-
paragraphAttributes.android_lineBreakWordStyle),
85+
"wordBreak", wordBreak, paragraphAttributes.wordBreak),
9086
debugStringConvertibleItem(
9187
"textAlignVertical",
9288
textAlignVertical,

‎packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,16 @@ class ParagraphAttributes : public DebugStringConvertible {
6969
HyphenationFrequency android_hyphenationFrequency{};
7070

7171
/*
72-
* (Android only) Strictness of the line-breaking rules.
72+
* Strictness of the line-breaking rules (CSS `line-break`).
73+
* Currently applied on Android only.
7374
*/
74-
LineBreakStyle android_lineBreakStyle{};
75+
LineBreak lineBreak{};
7576

7677
/*
77-
* (Android only) Word-based line breaking.
78+
* Word-based line breaking (CSS `word-break`).
79+
* Currently applied on Android only.
7880
*/
79-
LineBreakWordStyle android_lineBreakWordStyle{};
81+
WordBreak wordBreak{};
8082

8183
/*
8284
* In case of font size adjustment enabled, defines the minimum font size.
@@ -122,8 +124,8 @@ struct hash<facebook::react::ParagraphAttributes> {
122124
attributes.minimumFontSize,
123125
attributes.includeFontPadding,
124126
attributes.android_hyphenationFrequency,
125-
attributes.android_lineBreakStyle,
126-
attributes.android_lineBreakWordStyle,
127+
attributes.lineBreak,
128+
attributes.wordBreak,
127129
attributes.minimumFontScale,
128130
attributes.textAlignVertical);
129131
}

0 commit comments

Comments
 (0)