Move Linkification for dataDetectorType into TextLayoutManager (fixes dataDetectorType with Facsimile)#55756
Open
NickGerleman wants to merge 1 commit intofacebook:mainfrom
Open
Move Linkification for dataDetectorType into TextLayoutManager (fixes dataDetectorType with Facsimile)#55756NickGerleman wants to merge 1 commit intofacebook:mainfrom
NickGerleman wants to merge 1 commit intofacebook:mainfrom
Conversation
… dataDetectorType with Facsimile) Summary: Move `dataDetectorType` Linkify handling from `ReactTextView` (view-level `Linkify` on the `TextView`) to `TextLayoutManager.kt` (`Linkify` on the `Spannable`), so it works for both `ReactTextView` and `PreparedLayoutTextView`. Previously, `dataDetectorType` was handled as a `ReactProp` on `ReactTextViewManager`, which called `Linkify.addLinks()` inside `ReactTextView.setText()`. This meant the feature only worked for the legacy `ReactTextView` path, not for the new `PreparedLayoutTextView`. This diff: - Moves the `DataDetectorType` C++ enum from `components/text/platform/android/` to `attributedstring/primitives.h` (where all other paragraph-related enums live), replacing the original with a forwarding include. - Moves the `DataDetectorType` conversion functions to `attributedstring/conversions.h`, replacing the originals with a forwarding include. - Adds `dataDetectorType` as a field on `ParagraphAttributes` (with hash, equality, and debug support). - Serializes `dataDetectorType` via MapBuffer (key=9) so it flows from C++ to Java. - Adds `REBUILD_FIELD_SWITCH_CASE` for `dataDetectorType` in `BaseParagraphProps.cpp`. - In `TextLayoutManager.kt`, reads `PA_KEY_DATA_DETECTOR_TYPE` from the paragraph attributes MapBuffer and calls `Linkify.addLinks()` on the `Spannable` before layout creation. - Removes the `ReactProp` handler and `setLinkifyMask`/`mLinkifyMaskType` from `ReactTextViewManager.kt` and `ReactTextView.java`. - Adds URLSpan-based `LinkMovementMethod` detection in `ReactTextView.setText()` so that links added by `TextLayoutManager` remain clickable. `HostPlatformParagraphProps` is intentionally left unchanged—`dataDetectorType` is parsed into both `BaseParagraphProps::paragraphAttributes` (for MapBuffer) and `HostPlatformParagraphProps` (for getDiffProps). Changelog: [Internal] Differential Revision: D94017172
|
@NickGerleman has exported this pull request. If you are a Meta employee, you can view the originating Diff in D94017172. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Move
dataDetectorTypeLinkify handling fromReactTextView(view-levelLinkifyon theTextView) toTextLayoutManager.kt(Linkifyon theSpannable), so it works for bothReactTextViewandPreparedLayoutTextView.Previously,
dataDetectorTypewas handled as aReactProponReactTextViewManager, which calledLinkify.addLinks()insideReactTextView.setText(). This meant the feature only worked for the legacyReactTextViewpath, not for the newPreparedLayoutTextView.This diff:
DataDetectorTypeC++ enum fromcomponents/text/platform/android/to
attributedstring/primitives.h(where all other paragraph-related enumslive), replacing the original with a forwarding include.
DataDetectorTypeconversion functions toattributedstring/conversions.h, replacing the originals with a forwardinginclude.
dataDetectorTypeas a field onParagraphAttributes(with hash,equality, and debug support).
dataDetectorTypevia MapBuffer (key=9) so it flows from C++to Java.
REBUILD_FIELD_SWITCH_CASEfordataDetectorTypeinBaseParagraphProps.cpp.TextLayoutManager.kt, readsPA_KEY_DATA_DETECTOR_TYPEfrom theparagraph attributes MapBuffer and calls
Linkify.addLinks()on theSpannablebefore layout creation.ReactProphandler andsetLinkifyMask/mLinkifyMaskTypefrom
ReactTextViewManager.ktandReactTextView.java.LinkMovementMethoddetection inReactTextView.setText()so that links added by
TextLayoutManagerremain clickable.HostPlatformParagraphPropsis intentionally left unchanged—dataDetectorTypeis parsed into both
BaseParagraphProps::paragraphAttributes(for MapBuffer)and
HostPlatformParagraphProps(for getDiffProps).Changelog: [Internal]
Differential Revision: D94017172