diff --git a/src/ParsedText.js b/src/ParsedText.js
index d8a0cc5..f9fd428 100644
--- a/src/ParsedText.js
+++ b/src/ParsedText.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { Text } from 'react-native';
+import { Text, View, Pressable } from 'react-native';
import PropTypes from 'prop-types';
import TextExtraction from './lib/TextExtraction';
@@ -109,26 +109,39 @@ class ParsedText extends React.Component {
return textExtraction.parse().map((props, index) => {
const { style: parentStyle } = this.props;
- const { style, ...remainder } = props;
+ const { style, onPress = null, onLongPress = null, ...remainder } = props;
+ const isNormalText = typeof onPress !== 'function';
+ const ParentComponent = isNormalText ? View : Pressable;
return (
-
+ onPress={onPress}
+ onLongPress={onLongPress}
+ >
+
+
);
});
}
render() {
// Discard custom props before passing remainder to Text
- const { parse, childrenProps, ...remainder } = { ...this.props };
+ const { parse, childrenProps, style = {}, ...remainder } = {
+ ...this.props,
+ };
return (
- (this._root = ref)} {...remainder}>
+ (this._root = ref)}
+ style={[{ flexDirection: 'row', flexWrap: 'wrap' }, style]}
+ {...remainder}
+ >
{this.getParsedText()}
-
+
);
}
}