From 3b5536cc37740a7625a355a61d309ca7c0c26f98 Mon Sep 17 00:00:00 2001 From: Adam Chlupacek Date: Wed, 13 Aug 2025 15:11:00 +0200 Subject: [PATCH 1/3] Add support for baseUrl --- src/RichEditor.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/RichEditor.js b/src/RichEditor.js index f194ac3..bfece54 100755 --- a/src/RichEditor.js +++ b/src/RichEditor.js @@ -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 ( <> @@ -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); From 385e832a186e7cf90a6d09f258d3f323e5933068 Mon Sep 17 00:00:00 2001 From: Adam Chlupacek Date: Thu, 14 Aug 2025 12:14:04 +0200 Subject: [PATCH 2/3] Wait for image load to update height signalled. --- src/editor.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/editor.js b/src/editor.js index 6559109..830bf38 100644 --- a/src/editor.js +++ b/src/editor.js @@ -485,7 +485,10 @@ 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% @@ -493,6 +496,13 @@ function createHTML(options = {}) { } }, + REGISTER_IMAGE_LOAD_HEIGHT: function () { + const images = document.getElementsByTagName('img'); + for (let i = 0; i < images.length; i++) { + images[i].onload = Actions.UPDATE_HEIGHT; + } + }, + UPDATE_HEIGHT: function() { if (!${useContainer}) return; // var height = Math.max(docEle.scrollHeight, body.scrollHeight); From af2b685f15f61125572867f8b72f07e71e2d3999 Mon Sep 17 00:00:00 2001 From: Adam Chlupacek Date: Fri, 22 Aug 2025 15:26:43 +0200 Subject: [PATCH 3/3] If image fails to load, update the height anyhow. --- src/editor.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/editor.js b/src/editor.js index 830bf38..ca97996 100644 --- a/src/editor.js +++ b/src/editor.js @@ -500,6 +500,7 @@ function createHTML(options = {}) { 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; } },