Kaynağa Gözat

Added scroll and log callbacks

Yedidya Kennard 8 yıl önce
ebeveyn
işleme
b39bfc4d1a

+ 1
- 0
example/android/app/src/main/AndroidManifest.xml Dosyayı Görüntüle

@@ -18,6 +18,7 @@
18 18
       android:theme="@style/AppTheme">
19 19
       <activity
20 20
         android:name=".MainActivity"
21
+        android:windowSoftInputMode="adjustResize"
21 22
         android:label="@string/app_name"
22 23
         android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
23 24
         <intent-filter>

+ 10
- 4
src/RichTextEditor.js Dosyayı Görüntüle

@@ -19,14 +19,14 @@ export default class RichTextEditor extends Component {
19 19
     this._sendAction = this._sendAction.bind(this);
20 20
   }
21 21
 
22
-  onBridgeMessage(message){
22
+  onBridgeMessage(str){
23 23
     try {
24
-      const json = JSON.parse(message);
24
+      const message = JSON.parse(str);
25 25
 
26
-      switch (json.type) {
26
+      switch (message.type) {
27 27
         case messages.HTML_RESPONSE:
28 28
           if (this.resolve) {
29
-            this.resolve(json.data);
29
+            this.resolve(message.data);
30 30
             this.resolve = undefined;
31 31
             this.reject = undefined;
32 32
             if (this.pendingHtml) {
@@ -38,6 +38,12 @@ export default class RichTextEditor extends Component {
38 38
         case messages.ZSS_INITIALIZED:
39 39
           this.setHTML(this.props.initialHTML);
40 40
           break;
41
+        case messages.LOG:
42
+          console.log('FROM ZSS', message.data);
43
+          break;
44
+        case messages.SCROLL:
45
+          this.webviewBridge.setNativeProps({contentOffset: {y: message.data}});
46
+          break;
41 47
       }
42 48
 
43 49
     } catch(e) {

+ 3
- 2
src/ZSSRichTextEditor/ZSSRichTextEditor.js Dosyayı Görüntüle

@@ -38,6 +38,7 @@ zss_editor.updateScrollOffset = false;
38 38
  */
39 39
 zss_editor.init = function() {
40 40
 
41
+
41 42
     $('#zss_editor_content').on('touchend', function(e) {
42 43
                                 zss_editor.enabledEditingItems(e);
43 44
                                 var clicked = $(e.target);
@@ -103,13 +104,13 @@ zss_editor.updateOffset = function() {
103 104
 
104 105
 // This will show up in the XCode console as we are able to push this into an NSLog.
105 106
 zss_editor.debug = function(msg) {
106
-    WebViewBridge.send('debug://'+msg);
107
+    WebViewBridge.send(JSON.stringify({type: 'LOG', data: msg}));
107 108
 }
108 109
 
109 110
 
110 111
 zss_editor.setScrollPosition = function() {
111 112
     var position = window.pageYOffset;
112
-    WebViewBridge.send('scroll://'+position);
113
+    WebViewBridge.send(JSON.stringify({type: 'SCROLL', data: position}));
113 114
 }
114 115
 
115 116
 

+ 3
- 1
src/const.js Dosyayı Görüntüle

@@ -30,5 +30,7 @@ export const actions = {
30 30
 
31 31
 export const messages = {
32 32
   HTML_RESPONSE : 'HTML_RESPONSE',
33
-  ZSS_INITIALIZED: 'ZSS_INITIALIZED'
33
+  ZSS_INITIALIZED: 'ZSS_INITIALIZED',
34
+  SCROLL: 'SCROLL',
35
+  LOG: 'LOG'
34 36
 }