feat(iOS): Add prop for allowingReadAccessToURL (#771)
This commit is contained in:
parent
e515a31cf0
commit
0424dd0801
|
@ -42,6 +42,7 @@ This document lays out the current public properties and methods for the React N
|
|||
- [`directionalLockEnabled`](Reference.md#directionalLockEnabled)
|
||||
- [`geolocationEnabled`](Reference.md#geolocationenabled)
|
||||
- [`allowUniversalAccessFromFileURLs`](Reference.md#allowUniversalAccessFromFileURLs)
|
||||
- [`allowingReadAccessToURL`](Reference.md#allowingReadAccessToURL)
|
||||
- [`useWebKit`](Reference.md#usewebkit)
|
||||
- [`url`](Reference.md#url)
|
||||
- [`html`](Reference.md#html)
|
||||
|
@ -795,6 +796,16 @@ Boolean that sets whether JavaScript running in the context of a file scheme URL
|
|||
|
||||
---
|
||||
|
||||
### `allowingReadAccessToURL`
|
||||
|
||||
A String value that indicates which URLs the WebView's file can then reference in scripts, AJAX requests, and CSS imports. This is only used in `RNCWKWebView` for WebViews that are loaded with a source.uri set to a `'file://'` URL. If not provided, the default is to only allow read access to the URL provided in source.uri itself.
|
||||
|
||||
| Type | Required | Platform |
|
||||
| ------ | -------- | ------------- |
|
||||
| string | No | iOS WKWebView |
|
||||
|
||||
---
|
||||
|
||||
### `useWebKit`
|
||||
|
||||
If true, use WKWebView instead of UIWebView.
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
@property (nonatomic, assign) BOOL showsHorizontalScrollIndicator;
|
||||
@property (nonatomic, assign) BOOL showsVerticalScrollIndicator;
|
||||
@property (nonatomic, assign) BOOL directionalLockEnabled;
|
||||
@property (nonatomic, copy) NSString *allowingReadAccessToURL;
|
||||
|
||||
+ (void)setClientAuthenticationCredential:(nullable NSURLCredential*)credential;
|
||||
- (void)postMessage:(NSString *)message;
|
||||
|
|
|
@ -377,6 +377,17 @@ static NSURLCredential* clientAuthenticationCredential;
|
|||
}
|
||||
}
|
||||
|
||||
- (void)setAllowingReadAccessToURL:(NSString *)allowingReadAccessToURL
|
||||
{
|
||||
if (![_allowingReadAccessToURL isEqualToString:allowingReadAccessToURL]) {
|
||||
_allowingReadAccessToURL = [allowingReadAccessToURL copy];
|
||||
|
||||
if (_webView != nil) {
|
||||
[self visitSource];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setContentInset:(UIEdgeInsets)contentInset
|
||||
{
|
||||
_contentInset = contentInset;
|
||||
|
@ -422,7 +433,8 @@ static NSURLCredential* clientAuthenticationCredential;
|
|||
[_webView loadRequest:request];
|
||||
}
|
||||
else {
|
||||
[_webView loadFileURL:request.URL allowingReadAccessToURL:request.URL];
|
||||
NSURL* readAccessUrl = _allowingReadAccessToURL ? [NSURL URLWithString:_allowingReadAccessToURL] : request.URL;
|
||||
[_webView loadFileURL:request.URL allowingReadAccessToURL:readAccessUrl];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString)
|
|||
RCT_EXPORT_VIEW_PROPERTY(applicationNameForUserAgent, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(cacheEnabled, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(allowsLinkPreview, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(allowingReadAccessToURL, NSString)
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
|
||||
RCT_EXPORT_VIEW_PROPERTY(contentInsetAdjustmentBehavior, UIScrollViewContentInsetAdjustmentBehavior)
|
||||
|
|
|
@ -254,6 +254,7 @@ export interface AndroidNativeWebViewProps extends CommonNativeWebViewProps {
|
|||
}
|
||||
|
||||
export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
|
||||
allowingReadAccessToURL?: string;
|
||||
allowsBackForwardNavigationGestures?: boolean;
|
||||
allowsInlineMediaPlayback?: boolean;
|
||||
allowsLinkPreview?: boolean;
|
||||
|
@ -432,6 +433,18 @@ export interface IOSWebViewProps extends WebViewSharedProps {
|
|||
* @platform ios
|
||||
*/
|
||||
keyboardDisplayRequiresUserAction?: boolean;
|
||||
|
||||
/**
|
||||
* A String value that indicates which URLs the WebView's file can then
|
||||
* reference in scripts, AJAX requests, and CSS imports. This is only used
|
||||
* in `RNCWKWebView` for WebViews that are loaded with a source.uri set to a
|
||||
* `'file://'` URL.
|
||||
*
|
||||
* If not provided, the default is to only allow read access to the URL
|
||||
* provided in source.uri itself.
|
||||
* @platform ios
|
||||
*/
|
||||
allowingReadAccessToURL?: string;
|
||||
}
|
||||
|
||||
export interface AndroidWebViewProps extends WebViewSharedProps {
|
||||
|
|
Loading…
Reference in New Issue