Просмотр исходного кода

ZSS init called when React side web view onLoad is called, fix issue with race condition on Android

Yedidya Kennard 8 лет назад
Родитель
Сommit
8e349f974a
4 измененных файлов: 11 добавлений и 2 удалений
  1. 5
    0
      src/RichTextEditor.js
  2. 3
    0
      src/WebviewMessageHandler.js
  3. 2
    1
      src/const.js
  4. 1
    1
      src/editor.html

+ 5
- 0
src/RichTextEditor.js Просмотреть файл

177
           onBridgeMessage={(message) => this.onBridgeMessage(message)}
177
           onBridgeMessage={(message) => this.onBridgeMessage(message)}
178
           injectedJavaScript={injectScript}
178
           injectedJavaScript={injectScript}
179
           source={pageSource}
179
           source={pageSource}
180
+          onLoad={() => this.init()}
180
         />
181
         />
181
         {this._renderLinkModal()}
182
         {this._renderLinkModal()}
182
       </View>
183
       </View>
370
     this._sendAction(actions.restoreSelection);
371
     this._sendAction(actions.restoreSelection);
371
   }
372
   }
372
 
373
 
374
+  init() {
375
+    this._sendAction(actions.init);
376
+  }
377
+
373
   async getTitleHtml() {
378
   async getTitleHtml() {
374
     return new Promise((resolve, reject) => {
379
     return new Promise((resolve, reject) => {
375
       this.titleResolve = resolve;
380
       this.titleResolve = resolve;

+ 3
- 0
src/WebviewMessageHandler.js Просмотреть файл

135
         case '${actions.setBackgroundColor}':
135
         case '${actions.setBackgroundColor}':
136
           zss_editor.setBackgroundColor(action.data);
136
           zss_editor.setBackgroundColor(action.data);
137
           break;
137
           break;
138
+        case '${actions.init}':
139
+          zss_editor.init();
140
+          break;
138
       }
141
       }
139
     };
142
     };
140
   }
143
   }

+ 2
- 1
src/const.js Просмотреть файл

41
   restoreSelection: 'RESTORE_SELECTION',
41
   restoreSelection: 'RESTORE_SELECTION',
42
   setCustomCSS: 'SET_CUSTOM_CSS',
42
   setCustomCSS: 'SET_CUSTOM_CSS',
43
   setTextColor: 'SET_TEXT_COLOR',
43
   setTextColor: 'SET_TEXT_COLOR',
44
-  setBackgroundColor: 'SET_BACKGROUND_COLOR'
44
+  setBackgroundColor: 'SET_BACKGROUND_COLOR',
45
+  init: 'ZSSS_INIT'
45
 };
46
 };
46
 
47
 
47
 
48
 

+ 1
- 1
src/editor.html Просмотреть файл

1649
 		</style>
1649
 		</style>
1650
 	</head>
1650
 	</head>
1651
 
1651
 
1652
-	<body onLoad="zss_editor.init();">
1652
+	<body>
1653
 		<!-- ZSSRichTextEditor Editable Content -->
1653
 		<!-- ZSSRichTextEditor Editable Content -->
1654
 		<div id="zss_editor_title" class="zss_editor_title" contenteditable="true" placeholder="" disableLineBreaks="true"></div>
1654
 		<div id="zss_editor_title" class="zss_editor_title" contenteditable="true" placeholder="" disableLineBreaks="true"></div>
1655
 		<div id="separatorContainer"><hr></div>
1655
 		<div id="separatorContainer"><hr></div>