Skip to content

Commit

Permalink
link handler tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
kosbog authored May 19, 2022
1 parent 5972ed4 commit f836f97
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/RichEditor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {Component} from 'react';
import {WebView} from 'react-native-webview';
import {actions, messages} from './const';
import {Keyboard, Platform, StyleSheet, TextInput, View} from 'react-native';
import {Keyboard, Platform, StyleSheet, TextInput, View, Linking} from 'react-native';
import {createHTML} from './editor';

const PlatformIOS = Platform.OS === 'ios';
Expand Down Expand Up @@ -281,12 +281,13 @@ export default class RichTextEditor extends Component {
javaScriptEnabled={true}
source={viewHTML}
onLoad={that.init}
onNavigationStateChange={(event) => {
if (event.navigationType === 'click' && event.url) {
onLink?.openURL(event.url);
return false;
}
return true;
onShouldStartLoadWithRequest={event => {
if (event.url !== 'about:blank') {
this.webviewBridge?.stopLoading();
Linking?.openURL(event.url);
return false;
}
return true;
}}
/>
{Platform.OS === 'android' && <TextInput ref={ref => (that._input = ref)} style={styles._input} />}
Expand Down

0 comments on commit f836f97

Please sign in to comment.