Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/RichEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export default class RichTextEditor extends Component {

renderWebView() {
let that = this;
const { html, editorStyle, useContainer, style, onLink, dataDetectorTypes, ...rest } = that.props;
const { html, editorStyle, useContainer, style, onLink, dataDetectorTypes, baseUrl, ...rest } = that.props;
const { html: viewHTML } = that.state;
return (
<>
Expand All @@ -285,9 +285,13 @@ export default class RichTextEditor extends Component {
domStorageEnabled={false}
bounces={false}
javaScriptEnabled={true}
source={viewHTML}
source={{ ...viewHTML, baseUrl: baseUrl}}
onLoad={that.init}
onShouldStartLoadWithRequest={event => {
if (baseUrl && event.url.startsWith(baseUrl)) {
// We are trying to open a page which starts with the baseUrl, so we handle it internally
return true;
}
if (event.url !== 'about:blank') {
this.webviewBridge?.stopLoading();
Linking?.openURL(event.url);
Expand Down
13 changes: 12 additions & 1 deletion src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,14 +485,25 @@ function createHTML(options = {}) {

init: function (){
if (${useContainer}){
// setInterval(Actions.UPDATE_HEIGHT, 150);
// setInterval(Actions.UPDATE_HEIGHT, 800);
// If there were images in the initial content, they may change the height of the container
// when they are loaded. As such we need to register waiting for finish of load of the images.
Actions.REGISTER_IMAGE_LOAD_HEIGHT();
Actions.UPDATE_HEIGHT();
} else {
// react-native-webview There is a bug in the body and html height setting of a certain version of 100%
// body.style.height = docEle.clientHeight + 'px';
}
},

REGISTER_IMAGE_LOAD_HEIGHT: function () {
const images = document.getElementsByTagName('img');
for (let i = 0; i < images.length; i++) {
images[i].onload = Actions.UPDATE_HEIGHT;
images[i].onerror = Actions.UPDATE_HEIGHT;
}
},

UPDATE_HEIGHT: function() {
if (!${useContainer}) return;
// var height = Math.max(docEle.scrollHeight, body.scrollHeight);
Expand Down