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

Allow text to be selected and copied #85

Closed
wants to merge 2 commits into from

Conversation

hyb175
Copy link
Contributor

@hyb175 hyb175 commented Jan 17, 2018

This uses the react-native's own selectable prop on Text component and allow the same behavior as ifselectable is enabled on a normal Text component.

This also adds default styles for strikethrough (i.e. <s>...</s>) that is currently not supported.

screen shot 2018-01-17 at 10 25 46 am

This should address #58

@Exilz
Copy link
Contributor

Exilz commented Jan 19, 2018

Hi,
regarding selectable, it looks like what I tried myself. Are you sure the copy/paste and selection actually works ? Because it looks like this react-native bug.

@hyb175
Copy link
Contributor Author

hyb175 commented Jan 19, 2018

@Exilz Hi. so copy/paste works to the extend of what React-Native currently supports.
So like in the screenshot, ios currently only supports copy/paste the entire content of a <Text /> component, and Android supports select and copy partial or full of the content of a <Text /> component. The pitfall here is that it the user cannot select the whole text to be copied, which I am not sure how to handle. One potential way is to wrap everything in a <Text /> component as it seems to be telling what's copy/paste-able

@hyb175
Copy link
Contributor Author

hyb175 commented Jan 22, 2018

Just to be clear, the bug that was reported still happens, although I think that is more of a feature request than a bug. This change should enable the developers to enable whatever React Native currently support for copying text on a <Text /> component.

@hyb175
Copy link
Contributor Author

hyb175 commented Jan 31, 2018

@Exilz Any more actions you think should be done with this one? Are we ready to merge it or does it not make sense to do this?

@Exilz
Copy link
Contributor

Exilz commented Feb 1, 2018

Well... it can't hurt, and if someone finds some use to it, that's great.

I'll merge with the next release, I might have some improvements to add to default renderers, so it might take a couple of days.

Hopefully, react-native will improve its selectable feature soon enough.

@hyb175
Copy link
Contributor Author

hyb175 commented Feb 1, 2018

@Exilz Sounds good to me. Thanks! And 👍 on react-native improving selectable lol.

@Exilz
Copy link
Contributor

Exilz commented Feb 8, 2018

Merged in 3.8.0.

@Exilz Exilz closed this Feb 8, 2018
@code-by
Copy link

code-by commented Feb 12, 2021

Which props one should use to enable ability to select and copy text?

@jsamr
Copy link
Collaborator

jsamr commented Feb 12, 2021

@code-by depends on the versions.

4.x : textSelectable
5+ : defaultTextProps.selectable

@code-by
Copy link

code-by commented Feb 12, 2021

@code-by depends on the versions.

4.x : textSelectable
5+ : defaultTextProps.selectable

but one could select text only inside one <p> tag and not for all text in document :(

@jsamr
Copy link
Collaborator

jsamr commented Feb 12, 2021

@code-by This is unfortunately a limitation of Android, in which selection can only happen in the same TextView. React native, by design, inherits those limitations.

You could eventually provide your own control to select all the content, but I see no trivial way to do this.

@code-by
Copy link

code-by commented Feb 16, 2021

@code-by This is unfortunately a limitation of Android, in which selection can only happen in the same TextView. React native, by design, inherits those limitations.

You could eventually provide your own control to select all the content, but I see no trivial way to do this.

I found that on iOS there no selection, only ability to copy whole text, that's right?

@viet-nguyen-1926
Copy link

viet-nguyen-1926 commented Apr 26, 2023

@code-by This is unfortunately a limitation of Android, in which selection can only happen in the same TextView. React native, by design, inherits those limitations.
You could eventually provide your own control to select all the content, but I see no trivial way to do this.

I found that on iOS there no selection, only ability to copy whole text, that's right?
@jsamr @code-by
Im using 6.3.4 in RN : 0.66.5 but I had the same problem
on iOS there no selection, only ability to copy whole text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants