Pārlūkot izejas kodu

update rn version of demo to 0.58.4

iou90 5 gadus atpakaļ
vecāks
revīzija
8f81f555e2
5 mainītis faili ar 48 papildinājumiem un 605 dzēšanām
  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 Parādīt failu

@@ -95,7 +95,6 @@ export default class Explorer extends Component {
95 95
           source={{ html: heightHtml }}
96 96
           customScript={heightScript}
97 97
           onMessage={event => {
98
-            console.log('onMessage', event.nativeEvent.data);
99 98
             const { data } = event.nativeEvent;
100 99
             let messageData;
101 100
             // maybe parse stringified JSON

+ 1
- 1
demo/android/gradle.properties Parādīt failu

@@ -15,4 +15,4 @@
15 15
 # When configured, Gradle will run in incubating parallel mode.
16 16
 # This option should only be used with decoupled projects. More details, visit
17 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 Parādīt failu

@@ -25,22 +25,24 @@ const inlineBodyStyle = `
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 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 43
 const autoHeightScript = `
40 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 46
 document.head.appendChild(styleElement);
45 47
 document.body.style.background = 'cornflowerblue';
46 48
 `;
@@ -50,7 +52,7 @@ const autoWidthHtml0 = `
50 52
 <head>
51 53
   <meta name="viewport" content="target-densitydpi=device-dpi, initial-scale=1.0, user-scalable=no" />
52 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 56
 </html>
55 57
 `;
56 58
 
@@ -60,9 +62,7 @@ const autoWidthHtml1 = `
60 62
 
61 63
 const autoWidthScript = `
62 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 66
 document.head.appendChild(styleElement);
67 67
 `;
68 68
 
@@ -76,4 +76,4 @@ export {
76 76
   autoWidthScript,
77 77
   inlineBodyStyle,
78 78
   autoDetectLinkScript
79
-};
79
+};

+ 1
- 1
demo/package.json Parādīt failu

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

+ 31
- 587
demo/yarn.lock
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu