iamacup / react-native-markdown-display

React Native 100% compatible CommonMark renderer
MIT License
564 stars 166 forks source link

Select and copy text by using rules #173

Closed y-maslouskaya closed 8 months ago

y-maslouskaya commented 2 years ago

I am trying to allow to select and paste text. I found a related question under the issue #126, so I decided to try rules to change component to and apply selectable={true}. But for some reason the text disappeared (only numbers were left) in my component after I had added rules. Did I write rules incorrectly? Thank you in advance!

ordered_list: (node, children, parent, styles) => ( <Text key={node.key} style={styles.ordered_list} selectable={true}> {children} </Text> ),

Screen Shot 2022-06-21 at 6 38 12 PM
luco commented 1 year ago

Same here

esalaza commented 1 year ago

See my comment in #126 for an alternative.

Polombo98 commented 10 months ago

This is the original rule for text: text: (node, children, parent, styles, inheritedStyles = {}) => ( <Text key={node.key} style={[inheritedStyles, styles.text]}> {node.content} </Text> ),

As you can see, it uses node.content

Please use it to get the text

isaachinman commented 5 months ago

Anyone have an actual example of how to implement this?

import Markdown from 'react-native-markdown-display'

<Markdown style={{ body: { userSelect: 'auto' } }} />

This sort of straightforward/basic approach is not working.

mengheangrat commented 5 months ago

const rules = { textgroup: (node, children, parent, myStyles, inheritedStyles = {}) => { return ( <Text key={node.key} style={[inheritedStyles, styles.textMarkdown]} selectable={true} selectionColor={CONSTANT.SECONDARY_LIGHT_GREY}> {children} </Text> ); }, };

Apply this rule you will be able to select all text.