diff --git a/Libraries/Components/WebView/WebView.ios.js b/Libraries/Components/WebView/WebView.ios.js index 49891d3e660..018f913d1c4 100644 --- a/Libraries/Components/WebView/WebView.ios.js +++ b/Libraries/Components/WebView/WebView.ios.js @@ -59,6 +59,15 @@ type ErrorEvent = { type Event = Object; +const DataDetectorTypes = [ + 'phoneNumber', + 'link', + 'address', + 'calendarEvent', + 'none', + 'all', +]; + var defaultRenderLoading = () => ( @@ -238,6 +247,28 @@ var WebView = React.createClass({ */ style: View.propTypes.style, + /** + * Determines the types of data converted to clickable URLs in the web view’s content. + * By default only phone numbers are detected. + * + * You can provide one type or an array of many types. + * + * Possible values for `dataDetectorTypes` are: + * + * - `'phoneNumber'` + * - `'link'` + * - `'address'` + * - `'calendarEvent'` + * - `'none'` + * - `'all'` + * + * @platform ios + */ + dataDetectorTypes: PropTypes.oneOfType([ + PropTypes.oneOf(DataDetectorTypes), + PropTypes.arrayOf(PropTypes.oneOf(DataDetectorTypes)), + ]), + /** * Boolean value to enable JavaScript in the `WebView`. Used on Android only * as JavaScript is enabled by default on iOS. The default value is `true`. @@ -374,6 +405,7 @@ var WebView = React.createClass({ scalesPageToFit={this.props.scalesPageToFit} allowsInlineMediaPlayback={this.props.allowsInlineMediaPlayback} mediaPlaybackRequiresUserAction={this.props.mediaPlaybackRequiresUserAction} + dataDetectorTypes={this.props.dataDetectorTypes} />; return ( diff --git a/React/Base/RCTConvert.h b/React/Base/RCTConvert.h index 231f888c482..0c6da151fc6 100644 --- a/React/Base/RCTConvert.h +++ b/React/Base/RCTConvert.h @@ -66,6 +66,7 @@ typedef NSURL RCTFileURL; + (UIKeyboardType)UIKeyboardType:(id)json; + (UIKeyboardAppearance)UIKeyboardAppearance:(id)json; + (UIReturnKeyType)UIReturnKeyType:(id)json; ++ (UIDataDetectorTypes)UIDataDetectorTypes:(id)json; + (UIViewContentMode)UIViewContentMode:(id)json; + (UIBarStyle)UIBarStyle:(id)json; diff --git a/React/Base/RCTConvert.m b/React/Base/RCTConvert.m index d2d3b457877..e37766cee88 100644 --- a/React/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -319,6 +319,15 @@ RCT_ENUM_CONVERTER(UIKeyboardType, (@{ @"numeric": @(UIKeyboardTypeDecimalPad), }), UIKeyboardTypeDefault, integerValue) +RCT_MULTI_ENUM_CONVERTER(UIDataDetectorTypes, (@{ + @"phoneNumber": @(UIDataDetectorTypePhoneNumber), + @"link": @(UIDataDetectorTypeLink), + @"address": @(UIDataDetectorTypeAddress), + @"calendarEvent": @(UIDataDetectorTypeCalendarEvent), + @"none": @(UIDataDetectorTypeNone), + @"all": @(UIDataDetectorTypeAll), +}), UIDataDetectorTypePhoneNumber, unsignedLongLongValue) + RCT_ENUM_CONVERTER(UIKeyboardAppearance, (@{ @"default": @(UIKeyboardAppearanceDefault), @"light": @(UIKeyboardAppearanceLight), diff --git a/React/Views/RCTWebViewManager.m b/React/Views/RCTWebViewManager.m index 5809e24be5f..af5f5b03b8a 100644 --- a/React/Views/RCTWebViewManager.m +++ b/React/Views/RCTWebViewManager.m @@ -47,7 +47,7 @@ RCT_EXPORT_VIEW_PROPERTY(onLoadingError, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onShouldStartLoadWithRequest, RCTDirectEventBlock) RCT_REMAP_VIEW_PROPERTY(allowsInlineMediaPlayback, _webView.allowsInlineMediaPlayback, BOOL) RCT_REMAP_VIEW_PROPERTY(mediaPlaybackRequiresUserAction, _webView.mediaPlaybackRequiresUserAction, BOOL) - +RCT_REMAP_VIEW_PROPERTY(dataDetectorTypes, _webView.dataDetectorTypes, UIDataDetectorTypes) RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag) {