|
@@ -11,6 +11,7 @@
|
11
|
11
|
'use strict';
|
12
|
12
|
|
13
|
13
|
import type {Node, Element, ComponentType} from 'react';
|
|
14
|
+
|
14
|
15
|
import type {SyntheticEvent} from 'CoreEventTypes';
|
15
|
16
|
import type {EdgeInsetsProp} from 'EdgeInsetsPropType';
|
16
|
17
|
import type {ViewStyleProp} from 'StyleSheet';
|
|
@@ -126,58 +127,13 @@ export type WebViewNativeConfig = $ReadOnly<{|
|
126
|
127
|
viewManager?: ?Object,
|
127
|
128
|
|}>;
|
128
|
129
|
|
129
|
|
-export type WebViewSharedProps = $ReadOnly<{|
|
130
|
|
- ...ViewProps,
|
131
|
|
- /**
|
132
|
|
- * Deprecated. Use `source` instead.
|
133
|
|
- */
|
134
|
|
- url?: ?string,
|
135
|
|
- /**
|
136
|
|
- * Deprecated. Use `source` instead.
|
137
|
|
- */
|
138
|
|
- html?: ?string,
|
139
|
|
-
|
140
|
|
- /**
|
141
|
|
- * Loads static html or a uri (with optional headers) in the WebView.
|
142
|
|
- */
|
143
|
|
- source?: ?WebViewSource,
|
144
|
|
-
|
|
130
|
+export type IOSWebViewProps = $ReadOnly<{|
|
145
|
131
|
/**
|
146
|
132
|
* If true, use WKWebView instead of UIWebView.
|
147
|
133
|
* @platform ios
|
148
|
134
|
*/
|
149
|
135
|
useWebKit?: ?boolean,
|
150
|
136
|
|
151
|
|
- /**
|
152
|
|
- * Function that returns a view to show if there's an error.
|
153
|
|
- */
|
154
|
|
- renderError: (errorDomain: ?string, errorCode: number, errorDesc: string) => Element<any>, // view to show if there's an error
|
155
|
|
-
|
156
|
|
- /**
|
157
|
|
- * Function that returns a loading indicator.
|
158
|
|
- */
|
159
|
|
- renderLoading: () => Element<any>,
|
160
|
|
-
|
161
|
|
- /**
|
162
|
|
- * Function that is invoked when the `WebView` has finished loading.
|
163
|
|
- */
|
164
|
|
- onLoad: (event: WebViewNavigationEvent) => mixed,
|
165
|
|
-
|
166
|
|
- /**
|
167
|
|
- * Function that is invoked when the `WebView` load succeeds or fails.
|
168
|
|
- */
|
169
|
|
- onLoadEnd: (event: WebViewNavigationEvent | WebViewErrorEvent) => mixed,
|
170
|
|
-
|
171
|
|
- /**
|
172
|
|
- * Function that is invoked when the `WebView` starts loading.
|
173
|
|
- */
|
174
|
|
- onLoadStart: (event: WebViewNavigationEvent) => mixed,
|
175
|
|
-
|
176
|
|
- /**
|
177
|
|
- * Function that is invoked when the `WebView` load fails.
|
178
|
|
- */
|
179
|
|
- onError: (event: WebViewErrorEvent) => mixed,
|
180
|
|
-
|
181
|
137
|
/**
|
182
|
138
|
* Boolean value that determines whether the web view bounces
|
183
|
139
|
* when it reaches the edge of the content. The default value is `true`.
|
|
@@ -205,13 +161,6 @@ export type WebViewSharedProps = $ReadOnly<{|
|
205
|
161
|
*/
|
206
|
162
|
scrollEnabled?: ?boolean,
|
207
|
163
|
|
208
|
|
- /**
|
209
|
|
- * Controls whether to adjust the content inset for web views that are
|
210
|
|
- * placed behind a navigation bar, tab bar, or toolbar. The default value
|
211
|
|
- * is `true`.
|
212
|
|
- */
|
213
|
|
- automaticallyAdjustContentInsets?: ?boolean,
|
214
|
|
-
|
215
|
164
|
/**
|
216
|
165
|
* The amount by which the web view content is inset from the edges of
|
217
|
166
|
* the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
|
|
@@ -219,28 +168,6 @@ export type WebViewSharedProps = $ReadOnly<{|
|
219
|
168
|
*/
|
220
|
169
|
contentInset?: ?EdgeInsetsProp,
|
221
|
170
|
|
222
|
|
- /**
|
223
|
|
- * Function that is invoked when the `WebView` loading starts or ends.
|
224
|
|
- */
|
225
|
|
- onNavigationStateChange?: (event: WebViewNavigation) => mixed,
|
226
|
|
-
|
227
|
|
- /**
|
228
|
|
- * A function that is invoked when the webview calls `window.postMessage`.
|
229
|
|
- * Setting this property will inject a `postMessage` global into your
|
230
|
|
- * webview, but will still call pre-existing values of `postMessage`.
|
231
|
|
- *
|
232
|
|
- * `window.postMessage` accepts one argument, `data`, which will be
|
233
|
|
- * available on the event object, `event.nativeEvent.data`. `data`
|
234
|
|
- * must be a string.
|
235
|
|
- */
|
236
|
|
- onMessage?: (event: WebViewMessageEvent) => mixed,
|
237
|
|
-
|
238
|
|
- /**
|
239
|
|
- * Boolean value that forces the `WebView` to show the loading view
|
240
|
|
- * on the first load.
|
241
|
|
- */
|
242
|
|
- startInLoadingState?: ?boolean,
|
243
|
|
-
|
244
|
171
|
/**
|
245
|
172
|
* Determines the types of data converted to clickable URLs in the web view's content.
|
246
|
173
|
* By default only phone numbers are detected.
|
|
@@ -267,6 +194,59 @@ export type WebViewSharedProps = $ReadOnly<{|
|
267
|
194
|
| ?DataDetectorTypes
|
268
|
195
|
| $ReadOnlyArray<DataDetectorTypes>,
|
269
|
196
|
|
|
197
|
+ /**
|
|
198
|
+ * Function that allows custom handling of any web view requests. Return
|
|
199
|
+ * `true` from the function to continue loading the request and `false`
|
|
200
|
+ * to stop loading.
|
|
201
|
+ * @platform ios
|
|
202
|
+ */
|
|
203
|
+ onShouldStartLoadWithRequest?: (event: WebViewEvent) => mixed,
|
|
204
|
+
|
|
205
|
+ /**
|
|
206
|
+ * Boolean that determines whether HTML5 videos play inline or use the
|
|
207
|
+ * native full-screen controller. The default value is `false`.
|
|
208
|
+ *
|
|
209
|
+ * **NOTE** : In order for video to play inline, not only does this
|
|
210
|
+ * property need to be set to `true`, but the video element in the HTML
|
|
211
|
+ * document must also include the `webkit-playsinline` attribute.
|
|
212
|
+ * @platform ios
|
|
213
|
+ */
|
|
214
|
+ allowsInlineMediaPlayback?: ?boolean,
|
|
215
|
+|}>;
|
|
216
|
+
|
|
217
|
+export type AndroidWebViewProps = $ReadOnly<{|
|
|
218
|
+ onNavigationStateChange?: (event: WebViewNavigation) => mixed,
|
|
219
|
+ onContentSizeChange?: (event: WebViewEvent) => mixed,
|
|
220
|
+
|
|
221
|
+ /**
|
|
222
|
+ * Sets whether Geolocation is enabled. The default is false.
|
|
223
|
+ * @platform android
|
|
224
|
+ */
|
|
225
|
+ geolocationEnabled?: ?boolean,
|
|
226
|
+
|
|
227
|
+ /**
|
|
228
|
+ * Boolean that sets whether JavaScript running in the context of a file
|
|
229
|
+ * scheme URL should be allowed to access content from any origin.
|
|
230
|
+ * Including accessing content from other file scheme URLs
|
|
231
|
+ * @platform android
|
|
232
|
+ */
|
|
233
|
+ allowUniversalAccessFromFileURLs?: ?boolean,
|
|
234
|
+
|
|
235
|
+ /**
|
|
236
|
+ * Used on Android only, controls whether form autocomplete data should be saved
|
|
237
|
+ * @platform android
|
|
238
|
+ */
|
|
239
|
+ saveFormDataDisabled?: ?boolean,
|
|
240
|
+
|
|
241
|
+ /*
|
|
242
|
+ * Used on Android only, controls whether the given list of URL prefixes should
|
|
243
|
+ * make {@link com.facebook.react.views.webview.ReactWebViewClient} to launch a
|
|
244
|
+ * default activity intent for those URL instead of loading it within the webview.
|
|
245
|
+ * Use this to list URLs that WebView cannot handle, e.g. a PDF url.
|
|
246
|
+ * @platform android
|
|
247
|
+ */
|
|
248
|
+ urlPrefixesForDefaultIntent?: $ReadOnlyArray<string>,
|
|
249
|
+
|
270
|
250
|
/**
|
271
|
251
|
* Boolean value to enable JavaScript in the `WebView`. Used on Android only
|
272
|
252
|
* as JavaScript is enabled by default on iOS. The default value is `true`.
|
|
@@ -290,44 +270,115 @@ export type WebViewSharedProps = $ReadOnly<{|
|
290
|
270
|
domStorageEnabled?: ?boolean,
|
291
|
271
|
|
292
|
272
|
/**
|
293
|
|
- * Set this to provide JavaScript that will be injected into the web page
|
294
|
|
- * when the view loads.
|
|
273
|
+ * Sets the user-agent for the `WebView`.
|
|
274
|
+ * @platform android
|
295
|
275
|
*/
|
296
|
|
- injectedJavaScript?: ?string,
|
|
276
|
+ userAgent?: ?string,
|
297
|
277
|
|
298
|
278
|
/**
|
299
|
|
- * Sets the user-agent for the `WebView`.
|
|
279
|
+ * Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin.
|
|
280
|
+ *
|
|
281
|
+ * Possible values for `mixedContentMode` are:
|
|
282
|
+ *
|
|
283
|
+ * - `'never'` (default) - WebView will not allow a secure origin to load content from an insecure origin.
|
|
284
|
+ * - `'always'` - WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
|
|
285
|
+ * - `'compatibility'` - WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
|
300
|
286
|
* @platform android
|
301
|
287
|
*/
|
302
|
|
- userAgent?: ?string,
|
|
288
|
+ mixedContentMode?: ?('never' | 'always' | 'compatibility'),
|
|
289
|
+|}>;
|
303
|
290
|
|
|
291
|
+export type WebViewSharedProps = $ReadOnly<{|
|
|
292
|
+ ...ViewProps,
|
|
293
|
+ ...IOSWebViewProps,
|
|
294
|
+ ...AndroidWebViewProps,
|
304
|
295
|
/**
|
305
|
|
- * Boolean that controls whether the web content is scaled to fit
|
306
|
|
- * the view and enables the user to change the scale. The default value
|
|
296
|
+ * Deprecated. Use `source` instead.
|
|
297
|
+ */
|
|
298
|
+ url?: ?string,
|
|
299
|
+ /**
|
|
300
|
+ * Deprecated. Use `source` instead.
|
|
301
|
+ */
|
|
302
|
+ html?: ?string,
|
|
303
|
+
|
|
304
|
+ /**
|
|
305
|
+ * Loads static html or a uri (with optional headers) in the WebView.
|
|
306
|
+ */
|
|
307
|
+ source?: ?WebViewSource,
|
|
308
|
+
|
|
309
|
+ /**
|
|
310
|
+ * Function that returns a view to show if there's an error.
|
|
311
|
+ */
|
|
312
|
+ renderError: (errorDomain: ?string, errorCode: number, errorDesc: string) => Element<any>, // view to show if there's an error
|
|
313
|
+
|
|
314
|
+ /**
|
|
315
|
+ * Function that returns a loading indicator.
|
|
316
|
+ */
|
|
317
|
+ renderLoading: () => Element<any>,
|
|
318
|
+
|
|
319
|
+ /**
|
|
320
|
+ * Function that is invoked when the `WebView` has finished loading.
|
|
321
|
+ */
|
|
322
|
+ onLoad: (event: WebViewNavigationEvent) => mixed,
|
|
323
|
+
|
|
324
|
+ /**
|
|
325
|
+ * Function that is invoked when the `WebView` load succeeds or fails.
|
|
326
|
+ */
|
|
327
|
+ onLoadEnd: (event: WebViewNavigationEvent | WebViewErrorEvent) => mixed,
|
|
328
|
+
|
|
329
|
+ /**
|
|
330
|
+ * Function that is invoked when the `WebView` starts loading.
|
|
331
|
+ */
|
|
332
|
+ onLoadStart: (event: WebViewNavigationEvent) => mixed,
|
|
333
|
+
|
|
334
|
+ /**
|
|
335
|
+ * Function that is invoked when the `WebView` load fails.
|
|
336
|
+ */
|
|
337
|
+ onError: (event: WebViewErrorEvent) => mixed,
|
|
338
|
+
|
|
339
|
+ /**
|
|
340
|
+ * Controls whether to adjust the content inset for web views that are
|
|
341
|
+ * placed behind a navigation bar, tab bar, or toolbar. The default value
|
307
|
342
|
* is `true`.
|
|
343
|
+ */
|
|
344
|
+ automaticallyAdjustContentInsets?: ?boolean,
|
|
345
|
+
|
|
346
|
+ /**
|
|
347
|
+ * Function that is invoked when the `WebView` loading starts or ends.
|
|
348
|
+ */
|
|
349
|
+ onNavigationStateChange?: (event: WebViewNavigation) => mixed,
|
|
350
|
+
|
|
351
|
+ /**
|
|
352
|
+ * A function that is invoked when the webview calls `window.postMessage`.
|
|
353
|
+ * Setting this property will inject a `postMessage` global into your
|
|
354
|
+ * webview, but will still call pre-existing values of `postMessage`.
|
308
|
355
|
*
|
309
|
|
- * On iOS, when `useWebKit=true`, this prop will not work.
|
|
356
|
+ * `window.postMessage` accepts one argument, `data`, which will be
|
|
357
|
+ * available on the event object, `event.nativeEvent.data`. `data`
|
|
358
|
+ * must be a string.
|
310
|
359
|
*/
|
311
|
|
- scalesPageToFit?: ?boolean,
|
|
360
|
+ onMessage?: (event: WebViewMessageEvent) => mixed,
|
312
|
361
|
|
313
|
362
|
/**
|
314
|
|
- * Function that allows custom handling of any web view requests. Return
|
315
|
|
- * `true` from the function to continue loading the request and `false`
|
316
|
|
- * to stop loading.
|
317
|
|
- * @platform ios
|
|
363
|
+ * Boolean value that forces the `WebView` to show the loading view
|
|
364
|
+ * on the first load.
|
318
|
365
|
*/
|
319
|
|
- onShouldStartLoadWithRequest?: (event: WebViewEvent) => mixed,
|
|
366
|
+ startInLoadingState?: ?boolean,
|
320
|
367
|
|
321
|
368
|
/**
|
322
|
|
- * Boolean that determines whether HTML5 videos play inline or use the
|
323
|
|
- * native full-screen controller. The default value is `false`.
|
|
369
|
+ * Set this to provide JavaScript that will be injected into the web page
|
|
370
|
+ * when the view loads.
|
|
371
|
+ */
|
|
372
|
+ injectedJavaScript?: ?string,
|
|
373
|
+
|
|
374
|
+ /**
|
|
375
|
+ * Boolean that controls whether the web content is scaled to fit
|
|
376
|
+ * the view and enables the user to change the scale. The default value
|
|
377
|
+ * is `true`.
|
324
|
378
|
*
|
325
|
|
- * **NOTE** : In order for video to play inline, not only does this
|
326
|
|
- * property need to be set to `true`, but the video element in the HTML
|
327
|
|
- * document must also include the `webkit-playsinline` attribute.
|
328
|
|
- * @platform ios
|
|
379
|
+ * On iOS, when `useWebKit=true`, this prop will not work.
|
329
|
380
|
*/
|
330
|
|
- allowsInlineMediaPlayback?: ?boolean,
|
|
381
|
+ scalesPageToFit?: ?boolean,
|
331
|
382
|
|
332
|
383
|
/**
|
333
|
384
|
* Boolean that determines whether HTML5 audio and video requires the user
|
|
@@ -344,18 +395,6 @@ export type WebViewSharedProps = $ReadOnly<{|
|
344
|
395
|
*/
|
345
|
396
|
originWhitelist?: $ReadOnlyArray<string>,
|
346
|
397
|
|
347
|
|
- /**
|
348
|
|
- * Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin.
|
349
|
|
- *
|
350
|
|
- * Possible values for `mixedContentMode` are:
|
351
|
|
- *
|
352
|
|
- * - `'never'` (default) - WebView will not allow a secure origin to load content from an insecure origin.
|
353
|
|
- * - `'always'` - WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
|
354
|
|
- * - `'compatibility'` - WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
|
355
|
|
- * @platform android
|
356
|
|
- */
|
357
|
|
- mixedContentMode?: ?('never' | 'always' | 'compatibility'),
|
358
|
|
-
|
359
|
398
|
/**
|
360
|
399
|
* Override the native component used to render the WebView. Enables a custom native
|
361
|
400
|
* WebView which uses the same JavaScript as the original WebView.
|