diff --git a/example/lib/main.dart b/example/lib/main.dart index 4b7ea32e..c405eb20 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -119,7 +119,7 @@ class _HtmlEditorExampleState extends State { debugPrint('enter/return pressed'); }, onFocus: () { debugPrint('editor focused'); - }, onBlur: () { + }, onUnFocus: () { debugPrint('editor unfocused'); }, onBlurCodeview: () { debugPrint('codeview either focused or unfocused'); @@ -207,7 +207,7 @@ class _HtmlEditorExampleState extends State { Theme.of(context).colorScheme.secondary), onPressed: () async { var txt = await controller.getText(); - if (txt.contains('src=\"data:')) { + if (txt.contains('src=\\"data:')) { txt = ''; } diff --git a/lib/src/widgets/html_editor_widget_mobile.dart b/lib/src/widgets/html_editor_widget_mobile.dart index b0c2b15a..e957d048 100644 --- a/lib/src/widgets/html_editor_widget_mobile.dart +++ b/lib/src/widgets/html_editor_widget_mobile.dart @@ -601,10 +601,10 @@ class _HtmlEditorWidgetMobileState extends State { }); """); } - if (c.onBlur != null) { + if (c.onUnFocus != null) { widget.controller.editorController!.evaluateJavascript(source: """ \$('#summernote-2').on('summernote.blur', function() { - window.flutter_inappwebview.callHandler('onBlur', 'fired'); + window.flutter_inappwebview.callHandler('onUnFocus', 'fired'); }); """); } @@ -697,11 +697,11 @@ class _HtmlEditorWidgetMobileState extends State { c.onFocus!.call(); }); } - if (c.onBlur != null) { + if (c.onUnFocus != null) { widget.controller.editorController!.addJavaScriptHandler( - handlerName: 'onBlur', + handlerName: 'onUnFocus', callback: (_) { - c.onBlur!.call(); + c.onUnFocus!.call(); }); } if (c.onBlurCodeview != null) { diff --git a/lib/src/widgets/html_editor_widget_web.dart b/lib/src/widgets/html_editor_widget_web.dart index af5279b5..358169e3 100644 --- a/lib/src/widgets/html_editor_widget_web.dart +++ b/lib/src/widgets/html_editor_widget_web.dart @@ -2,7 +2,6 @@ export 'dart:html'; import 'dart:async'; import 'dart:convert'; -import 'dart:html'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -64,8 +63,8 @@ class _HtmlEditorWidgetWebState extends State { final _jsonEncoder = const JsonEncoder(); - StreamSubscription? _editorJSListener; - StreamSubscription? _summernoteOnLoadListener; + StreamSubscription? _editorJSListener; + StreamSubscription? _summernoteOnLoadListener; static const String _summernoteLoadedMessage = '_HtmlEditorWidgetWebState::summernoteLoaded'; final _focusNode = FocusNode(); @@ -719,10 +718,10 @@ class _HtmlEditorWidgetWebState extends State { });\n """; } - if (c.onBlur != null) { + if (c.onUnFocus != null) { callbacks = """$callbacks \$('#summernote-2').on('summernote.blur', function() { - window.parent.postMessage(JSON.stringify({"view": "$createdViewId", "type": "toDart: onBlur"}), "*"); + window.parent.postMessage(JSON.stringify({"view": "$createdViewId", "type": "toDart: onUnFocus"}), "*"); });\n """; } @@ -819,8 +818,8 @@ class _HtmlEditorWidgetWebState extends State { _focusNode.requestFocus(); c.onFocus!.call(); } - if (data['type'].contains('onBlur')) { - c.onBlur!.call(); + if (data['type'].contains('onUnFocus')) { + c.onUnFocus!.call(); } if (data['type'].contains('onBlurCodeview')) { c.onBlurCodeview!.call(); diff --git a/lib/utils/callbacks.dart b/lib/utils/callbacks.dart index 186642cf..436d6305 100644 --- a/lib/utils/callbacks.dart +++ b/lib/utils/callbacks.dart @@ -12,7 +12,7 @@ class Callbacks { this.onDialogShown, this.onEnter, this.onFocus, - this.onBlur, + this.onUnFocus, this.onBlurCodeview, this.onImageLinkInsert, this.onImageUpload, @@ -92,7 +92,7 @@ class Callbacks { /// the webview or dismissing the keyboard does not trigger this callback. /// This callback will only be triggered if the user taps on an empty space /// in the toolbar or switches the view mode of the editor. - void Function()? onBlur; + void Function()? onUnFocus; /// Called whenever the code view either gains or loses focus (the Summernote /// docs say this will only be called when the code view loses focus but