Fix AI Scribe overlay button display in iOS

The button was never displayed because the selectionchange event listener was loaded when the WebView was not entirely loaded so selectionchange event were never fired.

Now we setup selection listener when the WebView is loaded instead of created.
This commit is contained in:
Théo Poizat
2026-01-08 11:35:06 +01:00
committed by Dat H. Pham
parent 03c70922a0
commit b28dea732a
@@ -89,6 +89,10 @@ class _MobileEditorState extends State<MobileEditorWidget> with TextSelectionMix
Future<void> _onWebViewCreated(HtmlEditorApi editorApi) async {
widget.onCreatedEditorAction.call(context, editorApi, widget.content);
}
Future<void> _onWebViewCompleted(HtmlEditorApi editorApi, WebUri? webUri) async {
widget.onLoadCompletedEditorAction(editorApi, webUri);
try {
await _setupSelectionListener(editorApi);
} catch (e) {
@@ -96,6 +100,7 @@ class _MobileEditorState extends State<MobileEditorWidget> with TextSelectionMix
}
}
@override
Widget build(BuildContext context) {
return HtmlEditor(
@@ -109,7 +114,7 @@ class _MobileEditorState extends State<MobileEditorWidget> with TextSelectionMix
useDefaultFontStyle: true,
),
onCreated: _onWebViewCreated,
onCompleted: widget.onLoadCompletedEditorAction,
onCompleted: _onWebViewCompleted,
onContentHeightChanged: PlatformInfo.isIOS ? widget.onEditorContentHeightChanged : null,
);
}