Skip to content

Commit

Permalink
Add onCompleted method for editor
Browse files Browse the repository at this point in the history
  • Loading branch information
dab246 committed Sep 14, 2023
1 parent 41429e0 commit bb708d4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/src/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class HtmlEditor extends StatefulWidget {
this.adjustHeight = true,
this.minHeight = 100,
this.onCreated,
this.onCompleted,
this.splitBlockquotes = true,
this.addDefaultSelectionMenuItems = true,
this.textSelectionMenuItems,
Expand All @@ -51,6 +52,10 @@ class HtmlEditor extends StatefulWidget {
/// when the API is ready.
final void Function(HtmlEditorApi)? onCreated;

/// Define the `onCompleted(HtmlEditorApi, WebUri)` callback to get notified
/// when the web view loaded
final void Function(HtmlEditorApi, WebUri?)? onCompleted;

/// Defines if blockquotes should be split when the user adds a new line
/// - defaults to `true`.
final bool splitBlockquotes;
Expand Down Expand Up @@ -569,6 +574,10 @@ pre {
key: ValueKey(_initialPageContent),
onWebViewCreated: _onWebViewCreated,
onLoadStop: (controller, uri) async {
if (widget.onCompleted != null) {
widget.onCompleted!(_api, uri);
}

if (widget.adjustHeight) {
final scrollHeight = await controller.evaluateJavascript(
source: 'document.body.scrollHeight');
Expand Down

0 comments on commit bb708d4

Please sign in to comment.