@@ -30,31 +30,31 @@ class Hyperlink extends Component {
30
30
const { ...viewProps } = this . props
31
31
delete viewProps . onPress
32
32
delete viewProps . linkDefault
33
- delete viewProps . onLongPress
34
- delete viewProps . linkStyle
33
+ delete viewProps . onLongPress
34
+ delete viewProps . linkStyle
35
35
36
36
return (
37
- < View { ...viewProps } style = { this . props . style } >
38
- { ! this . props . onPress && ! this . props . onLongPress && ! this . props . linkStyle
37
+ < View { ...viewProps } style = { this . props . style } >
38
+ { ! this . props . onPress && ! this . props . onLongPress && ! this . props . linkStyle
39
39
? this . props . children
40
- : this . parse ( this ) . props . children }
40
+ : this . parse ( this ) . props . children }
41
41
</ View >
42
42
)
43
43
}
44
44
45
45
isTextNested ( component ) {
46
- if ( ! React . isValidElement ( component ) )
47
- throw new Error ( 'Invalid component' )
46
+ if ( ! React . isValidElement ( component ) )
47
+ throw new Error ( 'Invalid component' )
48
48
let { type : { displayName } = { } } = component
49
- if ( displayName !== 'Text' )
50
- throw new Error ( 'Not a Text component' )
49
+ if ( displayName !== 'Text' )
50
+ throw new Error ( 'Not a Text component' )
51
51
return typeof component . props . children !== 'string'
52
52
}
53
53
54
54
linkify ( component ) {
55
55
if (
56
- ! this . linkifyIt . pretest ( component . props . children )
57
- || ! this . linkifyIt . test ( component . props . children )
56
+ ! this . linkifyIt . pretest ( component . props . children )
57
+ || ! this . linkifyIt . test ( component . props . children )
58
58
)
59
59
return component
60
60
@@ -78,15 +78,15 @@ class Hyperlink extends Component {
78
78
: this . props . linkText
79
79
80
80
if ( OS !== 'web' ) {
81
- componentProps . onLongPress = ( ) => this . props . onLongPress && this . props . onLongPress ( url )
81
+ componentProps . onLongPress = ( ) => this . props . onLongPress && this . props . onLongPress ( url , text )
82
82
}
83
83
84
84
elements . push (
85
85
< Text
86
86
{ ...componentProps }
87
87
key = { url + index }
88
88
style = { [ component . props . style , this . props . linkStyle ] }
89
- onPress = { ( ) => this . props . onPress && this . props . onPress ( url ) }
89
+ onPress = { ( ) => this . props . onPress && this . props . onPress ( url , text ) }
90
90
>
91
91
{ text }
92
92
</ Text >
@@ -101,8 +101,8 @@ class Hyperlink extends Component {
101
101
102
102
parse ( component ) {
103
103
let { props : { children} = { } , type : { displayName } = { } } = component
104
- if ( ! children )
105
- return component
104
+ if ( ! children )
105
+ return component
106
106
107
107
const componentProps = {
108
108
...component . props ,
@@ -111,13 +111,13 @@ class Hyperlink extends Component {
111
111
}
112
112
113
113
return React . cloneElement ( component , componentProps , React . Children . map ( children , child => {
114
- let { type : { displayName } = { } } = child
115
- if ( typeof child === 'string' && this . linkifyIt . pretest ( child ) )
116
- return this . linkify ( < Text { ...componentProps } style = { component . props . style } > { child } </ Text > )
117
- if ( displayName === 'Text' && ! this . isTextNested ( child ) )
118
- return this . linkify ( child )
119
- return this . parse ( child )
120
- } ) )
114
+ let { type : { displayName } = { } } = child
115
+ if ( typeof child === 'string' && this . linkifyIt . pretest ( child ) )
116
+ return this . linkify ( < Text { ...componentProps } style = { component . props . style } > { child } </ Text > )
117
+ if ( displayName === 'Text' && ! this . isTextNested ( child ) )
118
+ return this . linkify ( child )
119
+ return this . parse ( child )
120
+ } ) )
121
121
}
122
122
}
123
123
@@ -126,8 +126,8 @@ Hyperlink.propTypes = {
126
126
linkify : PropTypes . object ,
127
127
linkStyle : textPropTypes . style ,
128
128
linkText : PropTypes . oneOfType ( [
129
- PropTypes . string ,
130
- PropTypes . func ,
129
+ PropTypes . string ,
130
+ PropTypes . func ,
131
131
] ) ,
132
132
onPress : PropTypes . func ,
133
133
onLongPress : PropTypes . func ,
0 commit comments