Browse Source

update rn version of demo to 0.58.4

iou90 5 years ago
parent
commit
8f81f555e2
5 changed files with 48 additions and 605 deletions
  1. 0
    1
      demo/App.js
  2. 1
    1
      demo/android/gradle.properties
  3. 15
    15
      demo/config.js
  4. 1
    1
      demo/package.json
  5. 31
    587
      demo/yarn.lock

+ 0
- 1
demo/App.js View File

95
           source={{ html: heightHtml }}
95
           source={{ html: heightHtml }}
96
           customScript={heightScript}
96
           customScript={heightScript}
97
           onMessage={event => {
97
           onMessage={event => {
98
-            console.log('onMessage', event.nativeEvent.data);
99
             const { data } = event.nativeEvent;
98
             const { data } = event.nativeEvent;
100
             let messageData;
99
             let messageData;
101
             // maybe parse stringified JSON
100
             // maybe parse stringified JSON

+ 1
- 1
demo/android/gradle.properties View File

15
 # When configured, Gradle will run in incubating parallel mode.
15
 # When configured, Gradle will run in incubating parallel mode.
16
 # This option should only be used with decoupled projects. More details, visit
16
 # This option should only be used with decoupled projects. More details, visit
17
 # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17
 # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18
-# org.gradle.parallel=true
18
+# org.gradle.parallel=true

+ 15
- 15
demo/config.js View File

25
     }
25
     }
26
 `;
26
 `;
27
 
27
 
28
-
29
-//https://medium.com/@elhardoum/opening-external-links-in-browser-in-react-native-webview-18fe6a66312a
28
+// https://medium.com/@elhardoum/opening-external-links-in-browser-in-react-native-webview-18fe6a66312a
30
 const autoDetectLinkScript = `
29
 const autoDetectLinkScript = `
31
-(function(){
32
-  function isUrl(str){
33
-    return str.startsWith('http');
30
+(function() {
31
+  var links = document.querySelectorAll('a[href]');
32
+  if (links) {
33
+    for (var index = 0; index < links.length; index++) {
34
+      links[index].addEventListener('click', function(event) {
35
+        event.preventDefault();
36
+        window.ReactNativeWebView.postMessage(JSON.stringify({ url: this.href }));
37
+      });
38
+    }
34
   }
39
   }
35
-  var e=function(e,n,t){if(n=n.replace(/^on/g,""),"addEventListener"in window)e.addEventListener(n,t,!1);else if("attachEvent"in window)e.attachEvent("on"+n,t);else{var o=e["on"+n];e["on"+n]=o?function(e){o(e),t(e)}:t}return e},n=document.querySelectorAll("a[href]");if(n)for(var t in n)n.hasOwnProperty(t)&&e(n[t],"onclick",function(e){!isUrl(this.href)||(e.preventDefault(),window.postMessage(JSON.stringify({url:this.href})))})
36
-}());
40
+})();
37
 `;
41
 `;
38
 
42
 
39
 const autoHeightScript = `
43
 const autoHeightScript = `
40
 var styleElement = document.createElement('style');
44
 var styleElement = document.createElement('style');
41
-styleElement.innerHTML = '${style1
42
-  .replace(/\'/g, "\\'")
43
-  .replace(/\n/g, '\\n')}';
45
+styleElement.innerHTML = '${style1.replace(/\'/g, "\\'").replace(/\n/g, '\\n')}';
44
 document.head.appendChild(styleElement);
46
 document.head.appendChild(styleElement);
45
 document.body.style.background = 'cornflowerblue';
47
 document.body.style.background = 'cornflowerblue';
46
 `;
48
 `;
50
 <head>
52
 <head>
51
   <meta name="viewport" content="target-densitydpi=device-dpi, initial-scale=1.0, user-scalable=no" />
53
   <meta name="viewport" content="target-densitydpi=device-dpi, initial-scale=1.0, user-scalable=no" />
52
 </head>
54
 </head>
53
-<p class="localStyle" style="display: inline;background-color: transparent !important;background-image: linear-gradient(to bottom, rgba(146, 249, 190, 1), rgba(146, 249, 190, 1));font-style: normal;zoom:1;font-size: 21px;line-height: 1.58;letter-spacing: -.003em;padding-top:0;padding-bottom:0;">hey</p>
55
+<p class="localStyle" style="display: inline;background-color: transparent !important;background-image: linear-gradient(to bottom, rgba(146, 249, 190, 1), rgba(146, 249, 190, 1));font-style: normal;font-size: 21px;line-height: 1.58;letter-spacing: -.003em;padding-top:0;padding-bottom:0;">hey</p>
54
 </html>
56
 </html>
55
 `;
57
 `;
56
 
58
 
60
 
62
 
61
 const autoWidthScript = `
63
 const autoWidthScript = `
62
 var styleElement = document.createElement('style');
64
 var styleElement = document.createElement('style');
63
-styleElement.innerHTML = '${style1
64
-  .replace(/\'/g, "\\'")
65
-  .replace(/\n/g, '\\n')}';
65
+styleElement.innerHTML = '${style1.replace(/\'/g, "\\'").replace(/\n/g, '\\n')}';
66
 document.head.appendChild(styleElement);
66
 document.head.appendChild(styleElement);
67
 `;
67
 `;
68
 
68
 
76
   autoWidthScript,
76
   autoWidthScript,
77
   inlineBodyStyle,
77
   inlineBodyStyle,
78
   autoDetectLinkScript
78
   autoDetectLinkScript
79
-};
79
+};

+ 1
- 1
demo/package.json View File

8
   },
8
   },
9
   "dependencies": {
9
   "dependencies": {
10
     "react": "16.6.3",
10
     "react": "16.6.3",
11
-    "react-native": "0.58.3",
11
+    "react-native": "0.58.4",
12
     "react-native-autoheight-webview": "../"
12
     "react-native-autoheight-webview": "../"
13
   },
13
   },
14
   "devDependencies": {
14
   "devDependencies": {

+ 31
- 587
demo/yarn.lock
File diff suppressed because it is too large
View File