Commit dee69ba
Resubmit: Initial support for selectable text with enablePreparedTextLayout
Summary:
enablePreparedTextLayout replaces ReactTextView (a real TextView) with PreparedLayoutTextView (a ViewGroup that draws a pre-computed Layout). PreparedLayoutTextView does not support native text selection, so selectable text was broken when the flag was on (T222052152).
This diff adds support for selectable text by routing it through ReactTextView when enablePreparedTextLayout is enabled. A new JS component NativeSelectableText resolves to native name RCTSelectableText when the flag is on, or falls back to RCTText when it is off. Text.js uses NativeSelectableText whenever text is selectable, and a new SelectableTextViewManager (which extends ReactTextViewManager) is registered as RCTSelectableText in all ReactPackage sites.
ReactTextViewManager.updateState() is also updated to handle ReferenceStateWrapper holding PreparedLayout, so that it can process state delivered through the PreparedLayout path.
Note that this change relies on facebook/react#35780 to avoid warnings from React
Changelog:
[General][Changed] - Text Can Conditionally Use "RCTSelectableText" Native Component
Differential Revision: D936879151 parent 8f55738 commit dee69ba
17 files changed
Lines changed: 252 additions & 87 deletions
File tree
- packages/react-native
- Libraries/Text
- ReactAndroid
- api
- src/main
- java/com/facebook/react
- fabric/mounting/mountitems
- shell
- views/text
- jni/react/fabric
- ReactCommon/react/renderer
- componentregistry
- components/text
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
30 | | - | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| |||
263 | 267 | | |
264 | 268 | | |
265 | 269 | | |
266 | | - | |
| 270 | + | |
267 | 271 | | |
268 | 272 | | |
269 | 273 | | |
| |||
283 | 287 | | |
284 | 288 | | |
285 | 289 | | |
286 | | - | |
| 290 | + | |
287 | 291 | | |
| 292 | + | |
288 | 293 | | |
289 | 294 | | |
290 | 295 | | |
291 | 296 | | |
292 | 297 | | |
293 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
294 | 304 | | |
295 | 305 | | |
296 | 306 | | |
| |||
457 | 467 | | |
458 | 468 | | |
459 | 469 | | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | 470 | | |
466 | 471 | | |
467 | 472 | | |
468 | 473 | | |
469 | 474 | | |
470 | 475 | | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
| 476 | + | |
479 | 477 | | |
480 | | - | |
481 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
482 | 481 | | |
483 | 482 | | |
484 | 483 | | |
| |||
489 | 488 | | |
490 | 489 | | |
491 | 490 | | |
492 | | - | |
| 491 | + | |
493 | 492 | | |
494 | 493 | | |
495 | | - | |
| 494 | + | |
496 | 495 | | |
497 | 496 | | |
498 | | - | |
| 497 | + | |
499 | 498 | | |
500 | 499 | | |
501 | 500 | | |
502 | 501 | | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
| 502 | + | |
511 | 503 | | |
512 | | - | |
513 | | - | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
514 | 508 | | |
515 | 509 | | |
516 | 510 | | |
517 | 511 | | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
518 | 515 | | |
519 | | - | |
| 516 | + | |
520 | 517 | | |
521 | 518 | | |
522 | 519 | | |
523 | 520 | | |
524 | | - | |
| 521 | + | |
525 | 522 | | |
526 | 523 | | |
527 | | - | |
| 524 | + | |
528 | 525 | | |
529 | 526 | | |
530 | 527 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6114 | 6114 | | |
6115 | 6115 | | |
6116 | 6116 | | |
6117 | | - | |
| 6117 | + | |
6118 | 6118 | | |
6119 | 6119 | | |
6120 | 6120 | | |
| |||
6127 | 6127 | | |
6128 | 6128 | | |
6129 | 6129 | | |
| 6130 | + | |
6130 | 6131 | | |
6131 | 6132 | | |
6132 | 6133 | | |
| 6134 | + | |
6133 | 6135 | | |
6134 | 6136 | | |
| 6137 | + | |
6135 | 6138 | | |
6136 | 6139 | | |
6137 | 6140 | | |
| |||
6149 | 6152 | | |
6150 | 6153 | | |
6151 | 6154 | | |
| 6155 | + | |
6152 | 6156 | | |
6153 | 6157 | | |
6154 | 6158 | | |
| |||
6157 | 6161 | | |
6158 | 6162 | | |
6159 | 6163 | | |
| 6164 | + | |
6160 | 6165 | | |
6161 | 6166 | | |
6162 | 6167 | | |
| |||
6174 | 6179 | | |
6175 | 6180 | | |
6176 | 6181 | | |
| 6182 | + | |
| 6183 | + | |
| 6184 | + | |
6177 | 6185 | | |
6178 | 6186 | | |
6179 | 6187 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
| 101 | + | |
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| |||
150 | 153 | | |
151 | 154 | | |
152 | 155 | | |
| 156 | + | |
153 | 157 | | |
154 | 158 | | |
155 | 159 | | |
| |||
192 | 196 | | |
193 | 197 | | |
194 | 198 | | |
| 199 | + | |
| 200 | + | |
195 | 201 | | |
196 | 202 | | |
197 | 203 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| |||
Lines changed: 36 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
49 | | - | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
134 | 141 | | |
135 | 142 | | |
136 | 143 | | |
| |||
176 | 183 | | |
177 | 184 | | |
178 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
179 | 214 | | |
180 | 215 | | |
181 | 216 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| |||
0 commit comments