Add script trigger content size changed on android

Signed-off-by: dab246 <tdvu@linagora.com>
(cherry picked from commit c39e932b634d164d75c0cf1cac35c27be04d8e1b)
This commit is contained in:
dab246
2023-10-13 15:19:07 +07:00
committed by Dat H. Pham
parent 1a38aac984
commit f35bcd8c88
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
class HtmlUtils {
static const scrollEventJSChannelName = 'ScrollEventListener';
static const contentSizeChangedEventJSChannelName = 'ContentSizeChangedEventListener';
static const runScriptsHandleScrollEvent = '''
let contentElement = document.getElementsByClassName('tmail-content')[0];
@@ -61,6 +62,16 @@ class HtmlUtils {
}
''';
static const scriptsHandleContentSizeChanged = '''
<script>
const bodyResizeObserver = new ResizeObserver(entries => {
window.flutter_inappwebview.callHandler('$contentSizeChangedEventJSChannelName', '');
})
bodyResizeObserver.observe(document.body)
</script>
''';
static String customCssStyleHtmlEditor({TextDirection direction = TextDirection.ltr}) {
if (PlatformInfo.isWeb) {
return '''