Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support arbitrary selectable text in Text component #1346

Merged
merged 26 commits into from
Oct 19, 2022

Commits on Aug 9, 2022

  1. Support arbitrary selectable text in Text component

    Summary:
    RN Mac's implementation of the `selectable` prop on `Text` only allows selecting the entire Text component and right click to copy. This diff makes the `Text.selectable` prop on Mac allow arbitrary selection. To do this we used `NSTextView` to render the `Text` component instead of RN Mac's custom text rendering, because it has a `selectable` property which gives us the behavior we want.
    
    We also allow adding custom menu items in the context menu.
    
    Note the change to RNTesterPage.js was required to fix microsoft#754.
    
    Test Plan:
    See test plan of D27250072 for integration to Zeratul.
    
    Confirmed text selection works in RNTester Text example:
    {F588619781}
    
    ---
    
    Also I went to RNTester Text examples and did an image diff comparison before and after these changes (differences are in pink):
    
    {F588602710}
    - The font smoothing isn't something we need
    
    ---
    
    {F588602715}
    - The examples with images are different because they load random images
    - The pink background on "With size and background color" isn't a difference, the background color is pink in code
    
    ---
    
    {F588602706}
    - The <TextInput multiline/> example has an off by 1 pixel difference that wasn't trivial to fix and doesn't seem significant enough to investigate
    
    Reviewers: skyle, ericroz
    
    Reviewed By: skyle
    
    Subscribers: eliwhite
    
    Differential Revision: https://phabricator.intern.facebook.com/D27484533
    
    Tasks: T83817888
    
    Signature: 27484533:1617928003:6c1c60a15db8ef3551aafe22229fafc9fea0053e
    
    # Conflicts:
    #	Libraries/Text/Text/RCTTextView.m
    #	React/Base/RCTTouchHandler.h
    #	React/Base/RCTTouchHandler.m
    lyahdav authored and Shawn Dempsey committed Aug 9, 2022
    Configuration menu
    Copy the full SHA
    e23bf89 View commit details
    Browse the repository at this point in the history

Commits on Aug 10, 2022

  1. Fix GH tags

    Shawn Dempsey committed Aug 10, 2022
    Configuration menu
    Copy the full SHA
    c8917ad View commit details
    Browse the repository at this point in the history
  2. Revert RNTesterPage style change

    Shawn Dempsey committed Aug 10, 2022
    Configuration menu
    Copy the full SHA
    13ac427 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a4d3720 View commit details
    Browse the repository at this point in the history

Commits on Aug 17, 2022

  1. Fix hit-testing in RCTTextView for selection

    Summary:
    This fixes a regression introduced by D29340382 since the `contentView` of the window was changed to the `RCTRootView` instance. The problem isn't there though, but is due to now the `contentView` having flipped geometry. The `hitTest:` method expects coordinates in the superview's coordinate space:
    
    > A point that is in the coordinate system of the view’s superview, not of the view itself.
    
    Also see how `RCTTouchHandler` also calls `convertPoint:` on the `superview` before passing to `hitTest:` for the same reason: https://fburl.com/diffusion/krx4lxao
    
    Test Plan: 
    {F628902534}
    
    
    Reviewers: lyahdav
    
    Reviewed By: lyahdav
    
    Subscribers: eliwhite
    
    Differential Revision: https://phabricator.intern.facebook.com/D29469639
    
    Tasks: T94420821
    
    Signature: 29469639:1625001662:97028699aee404282c83e35cd66f6308bc793a2a
    appden authored and Shawn Dempsey committed Aug 17, 2022
    Configuration menu
    Copy the full SHA
    46606cd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a4d20e0 View commit details
    Browse the repository at this point in the history

Commits on Aug 29, 2022

  1. Configuration menu
    Copy the full SHA
    007317f View commit details
    Browse the repository at this point in the history

Commits on Sep 8, 2022

  1. Configuration menu
    Copy the full SHA
    4a64054 View commit details
    Browse the repository at this point in the history

Commits on Sep 9, 2022

  1. Configuration menu
    Copy the full SHA
    7d3b7ee View commit details
    Browse the repository at this point in the history

Commits on Sep 12, 2022

  1. Configuration menu
    Copy the full SHA
    c3231cf View commit details
    Browse the repository at this point in the history

Commits on Sep 14, 2022

  1. Revert changes to touch handler

    Shawn Dempsey committed Sep 14, 2022
    Configuration menu
    Copy the full SHA
    0b7743a View commit details
    Browse the repository at this point in the history

Commits on Sep 15, 2022

  1. Only keep NSTextView changes

    Shawn Dempsey committed Sep 15, 2022
    Configuration menu
    Copy the full SHA
    655c33a View commit details
    Browse the repository at this point in the history
  2. Merge branch 'main' of github.com:microsoft/react-native-macos into t…

    …ext-selection
    Shawn Dempsey committed Sep 15, 2022
    Configuration menu
    Copy the full SHA
    df41b3b View commit details
    Browse the repository at this point in the history
  3. Merge branch 'text-selection' of github.com:shwanton/react-native-mac…

    …os into text-selection
    Shawn Dempsey committed Sep 15, 2022
    Configuration menu
    Copy the full SHA
    bc083f9 View commit details
    Browse the repository at this point in the history
  4. Remove unused property

    Shawn Dempsey committed Sep 15, 2022
    Configuration menu
    Copy the full SHA
    2364192 View commit details
    Browse the repository at this point in the history
  5. Re-add focus ring for selected text

    Shawn Dempsey committed Sep 15, 2022
    Configuration menu
    Copy the full SHA
    b08aae9 View commit details
    Browse the repository at this point in the history
  6. Fix typos

    Shawn Dempsey committed Sep 15, 2022
    Configuration menu
    Copy the full SHA
    b72d4bc View commit details
    Browse the repository at this point in the history

Commits on Sep 28, 2022

  1. Ensure that RCTTextView manages the key loop view

    Shawn Dempsey committed Sep 28, 2022
    Configuration menu
    Copy the full SHA
    eafbb5f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b13a21f View commit details
    Browse the repository at this point in the history
  3. move focusable property lower in list

    Shawn Dempsey committed Sep 28, 2022
    Configuration menu
    Copy the full SHA
    948b162 View commit details
    Browse the repository at this point in the history
  4. Fix macos tags

    Shawn Dempsey committed Sep 28, 2022
    Configuration menu
    Copy the full SHA
    96421cb View commit details
    Browse the repository at this point in the history

Commits on Oct 5, 2022

  1. Configuration menu
    Copy the full SHA
    a9b9d13 View commit details
    Browse the repository at this point in the history
  2. Remove iOS only highlighted prop that was causing re-render issues on…

    … macOS
    Shawn Dempsey committed Oct 5, 2022
    Configuration menu
    Copy the full SHA
    e8c32de View commit details
    Browse the repository at this point in the history

Commits on Oct 11, 2022

  1. Configuration menu
    Copy the full SHA
    42af687 View commit details
    Browse the repository at this point in the history

Commits on Oct 18, 2022

  1. Configuration menu
    Copy the full SHA
    feb63ab View commit details
    Browse the repository at this point in the history
  2. yarn lint

    Shawn Dempsey committed Oct 18, 2022
    Configuration menu
    Copy the full SHA
    9f49a9c View commit details
    Browse the repository at this point in the history