feat(iOS & MacOS): allowUniversalAccessFromFileURLs property(#1730)

* Added allowUniversalAccessFromFileURLs property to iOS and macOS
Updated the types to include allowUniversalAccessFromFileURLs and allowFileAccessFromFileURLs for iOS and macOS
Updated the Reference.md to include in the allowUniversalAccessFromFileURLs section iOS and macOS

* Updated platform in the type definition
This commit is contained in:
RecianuCiprian 2021-01-20 20:31:42 +02:00 committed by GitHub
parent b2f9ed228e
commit 8d098efce7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 3 deletions

View File

@ -57,6 +57,7 @@
@property (nonatomic, assign) BOOL javaScriptEnabled;
@property (nonatomic, assign) BOOL javaScriptCanOpenWindowsAutomatically;
@property (nonatomic, assign) BOOL allowFileAccessFromFileURLs;
@property (nonatomic, assign) BOOL allowUniversalAccessFromFileURLs;
@property (nonatomic, assign) BOOL allowsLinkPreview;
@property (nonatomic, assign) BOOL showsHorizontalScrollIndicator;
@property (nonatomic, assign) BOOL showsVerticalScrollIndicator;

View File

@ -213,6 +213,9 @@ static NSDictionary* customCertificatesForHost;
prefs.javaScriptEnabled = NO;
_prefsUsed = YES;
}
if (_allowUniversalAccessFromFileURLs) {
[wkWebViewConfig setValue:@TRUE forKey:@"allowUniversalAccessFromFileURLs"];
}
if (_allowFileAccessFromFileURLs) {
[prefs setValue:@TRUE forKey:@"allowFileAccessFromFileURLs"];
_prefsUsed = YES;

View File

@ -59,6 +59,7 @@ RCT_EXPORT_VIEW_PROPERTY(injectedJavaScriptBeforeContentLoadedForMainFrameOnly,
RCT_EXPORT_VIEW_PROPERTY(javaScriptEnabled, BOOL)
RCT_EXPORT_VIEW_PROPERTY(javaScriptCanOpenWindowsAutomatically, BOOL)
RCT_EXPORT_VIEW_PROPERTY(allowFileAccessFromFileURLs, BOOL)
RCT_EXPORT_VIEW_PROPERTY(allowUniversalAccessFromFileURLs, BOOL)
RCT_EXPORT_VIEW_PROPERTY(allowsInlineMediaPlayback, BOOL)
RCT_EXPORT_VIEW_PROPERTY(mediaPlaybackRequiresUserAction, BOOL)
#if WEBKIT_IOS_10_APIS_AVAILABLE

View File

@ -1092,9 +1092,9 @@ Boolean that sets whether JavaScript running in the context of a file scheme URL
Boolean that sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from any origin. Including accessing content from other file scheme URLs. The default value is `false`.
| Type | Required | Platform |
| ---- | -------- | -------- |
| bool | No | Android |
| Type | Required | Platform |
| ---- | -------- | -------------------- |
| bool | No | iOS, Android, macOS |
---

View File

@ -313,6 +313,8 @@ export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
allowsBackForwardNavigationGestures?: boolean;
allowsInlineMediaPlayback?: boolean;
allowsLinkPreview?: boolean;
allowFileAccessFromFileURLs?: boolean;
allowUniversalAccessFromFileURLs?: boolean;
automaticallyAdjustContentInsets?: boolean;
autoManageStatusBarEnabled?: boolean;
bounces?: boolean;
@ -334,6 +336,8 @@ export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
export interface MacOSNativeWebViewProps extends CommonNativeWebViewProps {
allowingReadAccessToURL?: string;
allowFileAccessFromFileURLs?: boolean;
allowUniversalAccessFromFileURLs?: boolean;
allowsBackForwardNavigationGestures?: boolean;
allowsInlineMediaPlayback?: boolean;
allowsLinkPreview?: boolean;
@ -548,6 +552,22 @@ export interface IOSWebViewProps extends WebViewSharedProps {
*/
allowingReadAccessToURL?: string;
/**
* Boolean that sets whether JavaScript running in the context of a file
* scheme URL should be allowed to access content from other file scheme URLs.
* Including accessing content from other file scheme URLs
* @platform ios
*/
allowFileAccessFromFileURLs?: boolean;
/**
* Boolean that sets whether JavaScript running in the context of a file
* scheme URL should be allowed to access content from any origin.
* Including accessing content from other file scheme URLs
* @platform ios
*/
allowUniversalAccessFromFileURLs?: boolean;
/**
* Function that is invoked when the WebKit WebView content process gets terminated.
* @platform ios
@ -726,6 +746,22 @@ export interface MacOSWebViewProps extends WebViewSharedProps {
*/
allowingReadAccessToURL?: string;
/**
* Boolean that sets whether JavaScript running in the context of a file
* scheme URL should be allowed to access content from other file scheme URLs.
* Including accessing content from other file scheme URLs
* @platform macos
*/
allowFileAccessFromFileURLs?: boolean;
/**
* Boolean that sets whether JavaScript running in the context of a file
* scheme URL should be allowed to access content from any origin.
* Including accessing content from other file scheme URLs
* @platform macos
*/
allowUniversalAccessFromFileURLs?: boolean;
/**
* Function that is invoked when the WebKit WebView content process gets terminated.
* @platform macos