Browse Source

Merge branch 'master' into master

Michael Diarmid 6 years ago
parent
commit
9d2bba932b
No account linked to committer's email address
8 changed files with 83 additions and 8 deletions
  1. 23
    0
      docs/Reference.md
  2. 2
    0
      ios/RNCWKWebView.h
  3. 6
    3
      ios/RNCWKWebView.m
  4. 2
    0
      ios/RNCWKWebViewManager.m
  5. 2
    0
      js/WebView.ios.js
  6. 18
    0
      js/WebViewTypes.js
  7. 1
    1
      package.json
  8. 29
    4
      typings/index.d.ts

+ 23
- 0
docs/Reference.md View File

47
 - [`allowFileAccess`](Reference.md#allowFileAccess)
47
 - [`allowFileAccess`](Reference.md#allowFileAccess)
48
 - [`saveFormDataDisabled`](Reference.md#saveFormDataDisabled)
48
 - [`saveFormDataDisabled`](Reference.md#saveFormDataDisabled)
49
 - [`enableCache`](Reference.md#enableCache)
49
 - [`enableCache`](Reference.md#enableCache)
50
+- [`pagingEnabled`](Reference.md#pagingEnabled)
51
+- [`allowsLinkPreview`](Reference.md#allowsLinkPreview)
50
 
52
 
51
 ## Methods Index
53
 ## Methods Index
52
 
54
 
528
 | ------- | -------- | ------- |
530
 | ------- | -------- | ------- |
529
 | boolean | No       | true    |
531
 | boolean | No       | true    |
530
 
532
 
533
+---
534
+
535
+### `pagingEnabled`
536
+
537
+If the value of this property is true, the scroll view stops on multiples of the scroll view’s bounds when the user scrolls. The default value is false.
538
+
539
+| Type    | Required | Platform |
540
+| ------- | -------- | -------- |
541
+| boolean | No       | iOS      |
542
+
543
+---
544
+
545
+### `allowsLinkPreview`
546
+
547
+A Boolean value that determines whether pressing on a link displays a preview of the destination for the link. In iOS this property is available on devices that support 3D Touch. In iOS 10 and later, the default value is true; before that, the default value is false.
548
+
549
+| Type    | Required | Platform |
550
+| ------- | -------- | -------- |
551
+| boolean | No       | iOS      |
552
+
553
+
531
 ## Methods
554
 ## Methods
532
 
555
 
533
 ### `extraNativeComponentConfig()`
556
 ### `extraNativeComponentConfig()`

+ 2
- 0
ios/RNCWKWebView.h View File

26
 @property (nonatomic, assign) BOOL messagingEnabled;
26
 @property (nonatomic, assign) BOOL messagingEnabled;
27
 @property (nonatomic, copy) NSString *injectedJavaScript;
27
 @property (nonatomic, copy) NSString *injectedJavaScript;
28
 @property (nonatomic, assign) BOOL scrollEnabled;
28
 @property (nonatomic, assign) BOOL scrollEnabled;
29
+@property (nonatomic, assign) BOOL pagingEnabled;
29
 @property (nonatomic, assign) CGFloat decelerationRate;
30
 @property (nonatomic, assign) CGFloat decelerationRate;
30
 @property (nonatomic, assign) BOOL allowsInlineMediaPlayback;
31
 @property (nonatomic, assign) BOOL allowsInlineMediaPlayback;
31
 @property (nonatomic, assign) BOOL bounces;
32
 @property (nonatomic, assign) BOOL bounces;
39
 @property (nonatomic, assign) BOOL allowsBackForwardNavigationGestures;
40
 @property (nonatomic, assign) BOOL allowsBackForwardNavigationGestures;
40
 @property (nonatomic, copy) NSString *userAgent;
41
 @property (nonatomic, copy) NSString *userAgent;
41
 @property (nonatomic, assign) BOOL enableCache;
42
 @property (nonatomic, assign) BOOL enableCache;
43
+@property (nonatomic, assign) BOOL allowsLinkPreview;
42
 
44
 
43
 - (void)postMessage:(NSString *)message;
45
 - (void)postMessage:(NSString *)message;
44
 - (void)injectJavaScript:(NSString *)script;
46
 - (void)injectJavaScript:(NSString *)script;

+ 6
- 3
ios/RNCWKWebView.m View File

70
     _automaticallyAdjustContentInsets = YES;
70
     _automaticallyAdjustContentInsets = YES;
71
     _contentInset = UIEdgeInsetsZero;
71
     _contentInset = UIEdgeInsetsZero;
72
   }
72
   }
73
-    
73
+
74
   // Workaround for a keyboard dismissal bug present in iOS 12
74
   // Workaround for a keyboard dismissal bug present in iOS 12
75
   // https://openradar.appspot.com/radar?id=5018321736957952
75
   // https://openradar.appspot.com/radar?id=5018321736957952
76
   if (@available(iOS 12.0, *)) {
76
   if (@available(iOS 12.0, *)) {
114
     _webView.UIDelegate = self;
114
     _webView.UIDelegate = self;
115
     _webView.navigationDelegate = self;
115
     _webView.navigationDelegate = self;
116
     _webView.scrollView.scrollEnabled = _scrollEnabled;
116
     _webView.scrollView.scrollEnabled = _scrollEnabled;
117
+    _webView.scrollView.pagingEnabled = _pagingEnabled;
117
     _webView.scrollView.bounces = _bounces;
118
     _webView.scrollView.bounces = _bounces;
119
+    _webView.allowsLinkPreview = _allowsLinkPreview;
118
     [_webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];
120
     [_webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];
119
     _webView.allowsBackForwardNavigationGestures = _allowsBackForwardNavigationGestures;
121
     _webView.allowsBackForwardNavigationGestures = _allowsBackForwardNavigationGestures;
122
+
120
     if (_userAgent) {
123
     if (_userAgent) {
121
       _webView.customUserAgent = _userAgent;
124
       _webView.customUserAgent = _userAgent;
122
     }
125
     }
140
         [_webView removeFromSuperview];
143
         [_webView removeFromSuperview];
141
         _webView = nil;
144
         _webView = nil;
142
     }
145
     }
143
-    
146
+
144
     [super removeFromSuperview];
147
     [super removeFromSuperview];
145
 }
148
 }
146
 
149
 
149
     keyboardTimer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(keyboardDisplacementFix) userInfo:nil repeats:false];
152
     keyboardTimer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(keyboardDisplacementFix) userInfo:nil repeats:false];
150
     [[NSRunLoop mainRunLoop] addTimer:keyboardTimer forMode:NSRunLoopCommonModes];
153
     [[NSRunLoop mainRunLoop] addTimer:keyboardTimer forMode:NSRunLoopCommonModes];
151
 }
154
 }
152
-  
155
+
153
 -(void)keyboardWillShow
156
 -(void)keyboardWillShow
154
 {
157
 {
155
     if (keyboardTimer != nil) {
158
     if (keyboardTimer != nil) {

+ 2
- 0
ios/RNCWKWebViewManager.m View File

45
 RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
45
 RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
46
 RCT_EXPORT_VIEW_PROPERTY(hideKeyboardAccessoryView, BOOL)
46
 RCT_EXPORT_VIEW_PROPERTY(hideKeyboardAccessoryView, BOOL)
47
 RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
47
 RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
48
+RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL)
48
 RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString)
49
 RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString)
49
 RCT_EXPORT_VIEW_PROPERTY(enableCache, BOOL)
50
 RCT_EXPORT_VIEW_PROPERTY(enableCache, BOOL)
51
+RCT_EXPORT_VIEW_PROPERTY(allowsLinkPreview, BOOL)
50
 
52
 
51
 /**
53
 /**
52
  * Expose methods to enable messaging the webview.
54
  * Expose methods to enable messaging the webview.

+ 2
- 0
js/WebView.ios.js View File

270
         injectedJavaScript={this.props.injectedJavaScript}
270
         injectedJavaScript={this.props.injectedJavaScript}
271
         bounces={this.props.bounces}
271
         bounces={this.props.bounces}
272
         scrollEnabled={this.props.scrollEnabled}
272
         scrollEnabled={this.props.scrollEnabled}
273
+        pagingEnabled={this.props.pagingEnabled}
273
         decelerationRate={decelerationRate}
274
         decelerationRate={decelerationRate}
274
         contentInset={this.props.contentInset}
275
         contentInset={this.props.contentInset}
275
         automaticallyAdjustContentInsets={
276
         automaticallyAdjustContentInsets={
291
           this.props.mediaPlaybackRequiresUserAction
292
           this.props.mediaPlaybackRequiresUserAction
292
         }
293
         }
293
         dataDetectorTypes={this.props.dataDetectorTypes}
294
         dataDetectorTypes={this.props.dataDetectorTypes}
295
+        allowsLinkPreview={this.props.allowsLinkPreview}
294
         {...nativeConfig.props}
296
         {...nativeConfig.props}
295
       />
297
       />
296
     );
298
     );

+ 18
- 0
js/WebViewTypes.js View File

168
    */
168
    */
169
   scrollEnabled?: ?boolean,
169
   scrollEnabled?: ?boolean,
170
 
170
 
171
+  /**
172
+   * If the value of this property is true, the scroll view stops on multiples
173
+   * of the scroll view’s bounds when the user scrolls.
174
+   * The default value is false.
175
+   * @platform ios
176
+   */
177
+  pagingEnabled?: ?boolean,
178
+
171
   /**
179
   /**
172
    * The amount by which the web view content is inset from the edges of
180
    * The amount by which the web view content is inset from the edges of
173
    * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
181
    * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
233
    * The custom user agent string.
241
    * The custom user agent string.
234
    */
242
    */
235
   userAgent?: ?string,
243
   userAgent?: ?string,
244
+
245
+  /**
246
+   * A Boolean value that determines whether pressing on a link
247
+   * displays a preview of the destination for the link.
248
+   *
249
+   * This property is available on devices that support 3D Touch.
250
+   * In iOS 10 and later, the default value is `true`; before that, the default value is `false`.
251
+   * @platform ios
252
+   */
253
+  allowsLinkPreview?: ?boolean,
236
 |}>;
254
 |}>;
237
 
255
 
238
 export type AndroidWebViewProps = $ReadOnly<{|
256
 export type AndroidWebViewProps = $ReadOnly<{|

+ 1
- 1
package.json View File

8
     "Thibault Malbranche <malbranche.thibault@gmail.com>"
8
     "Thibault Malbranche <malbranche.thibault@gmail.com>"
9
   ],
9
   ],
10
   "license": "MIT",
10
   "license": "MIT",
11
-  "version": "2.10.0",
11
+  "version": "2.13.0",
12
   "homepage": "https://github.com/react-native-community/react-native-webview#readme",
12
   "homepage": "https://github.com/react-native-community/react-native-webview#readme",
13
   "scripts": {
13
   "scripts": {
14
     "test:ios:flow": "flow check",
14
     "test:ios:flow": "flow check",

+ 29
- 4
typings/index.d.ts View File

9
   readonly canGoForward: boolean;
9
   readonly canGoForward: boolean;
10
 }
10
 }
11
 
11
 
12
+export interface WebViewIOSLoadRequestEvent extends WebViewNativeEvent {
13
+  target: number;
14
+  lockIdentifier: number;
15
+  navigationType: "click" | "formsubmit" | "backforward" | "reload" | "formresubmit" | "other";
16
+}
17
+
12
 export interface WebViewProgressEvent extends WebViewNativeEvent {
18
 export interface WebViewProgressEvent extends WebViewNativeEvent {
13
   readonly progress: number;
19
   readonly progress: number;
14
 }
20
 }
145
    */
151
    */
146
   scrollEnabled?: boolean;
152
   scrollEnabled?: boolean;
147
 
153
 
154
+  /**
155
+   * If the value of this property is true, the scroll view stops on multiples
156
+   * of the scroll view’s bounds when the user scrolls.
157
+   * The default value is false.
158
+   * @platform ios
159
+   */
160
+  pagingEnabled?: boolean,
161
+
148
   /**
162
   /**
149
    * The amount by which the web view content is inset from the edges of
163
    * The amount by which the web view content is inset from the edges of
150
    * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
164
    * the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.
182
    * to stop loading.
196
    * to stop loading.
183
    * @platform ios
197
    * @platform ios
184
    */
198
    */
185
-  onShouldStartLoadWithRequest?: (event: WebViewNativeEvent) => any;
199
+  onShouldStartLoadWithRequest?: (event: WebViewIOSLoadRequestEvent) => any;
186
 
200
 
187
   /**
201
   /**
188
    * Boolean that determines whether HTML5 videos play inline or use the
202
    * Boolean that determines whether HTML5 videos play inline or use the
202
   /**
216
   /**
203
    * If true, this will be able horizontal swipe gestures when using the WKWebView. The default value is `false`.
217
    * If true, this will be able horizontal swipe gestures when using the WKWebView. The default value is `false`.
204
    */
218
    */
205
-  allowsBackForwardNavigationGestures?: boolean
219
+  allowsBackForwardNavigationGestures?: boolean;
220
+
221
+  /**
222
+   * A Boolean value that determines whether pressing on a link
223
+   * displays a preview of the destination for the link.
224
+   *
225
+   * This property is available on devices that support 3D Touch.
226
+   * In iOS 10 and later, the default value is `true`; before that, the default value is `false`.
227
+   * @platform ios
228
+   */
229
+  allowsLinkPreview?: boolean;
206
 }
230
 }
207
 
231
 
208
 export interface AndroidWebViewProps {
232
 export interface AndroidWebViewProps {
374
    * Boolean value that forces the `WebView` to show the loading view
398
    * Boolean value that forces the `WebView` to show the loading view
375
    * on the first load.
399
    * on the first load.
376
    */
400
    */
377
-  startInLoadingState?: string;
401
+  startInLoadingState?: boolean;
378
 
402
 
379
   /**
403
   /**
380
    * Set this to provide JavaScript that will be injected into the web page
404
    * Set this to provide JavaScript that will be injected into the web page
421
   public goBack: () => void;
445
   public goBack: () => void;
422
   public reload: () => void;
446
   public reload: () => void;
423
   public stopLoading: () => void;
447
   public stopLoading: () => void;
424
-  public injectJavaScript: (js: string) => void
448
+  public postMessage: (msg: string) => void;
449
+  public injectJavaScript: (js: string) => void;
425
 }
450
 }