diff --git a/lib/src/widgets/html_editor_widget_web.dart b/lib/src/widgets/html_editor_widget_web.dart index af5279b5..dfc63215 100644 --- a/lib/src/widgets/html_editor_widget_web.dart +++ b/lib/src/widgets/html_editor_widget_web.dart @@ -47,9 +47,6 @@ class _HtmlEditorWidgetWebState extends State { /// The view ID for the IFrameElement. Must be unique. late String createdViewId; - /// The actual height of the editor, used to automatically set the height - late double actualHeight; - /// A Future that is observed by the [FutureBuilder]. We don't use a function /// as the Future on the [FutureBuilder] because when the widget is rebuilt, /// the function may be excessively called, hurting performance. @@ -71,7 +68,6 @@ class _HtmlEditorWidgetWebState extends State { @override void initState() { - actualHeight = widget.otherOptions.height; createdViewId = getRandString(10); widget.controller.viewId = createdViewId; initSummernote(); @@ -250,7 +246,6 @@ class _HtmlEditorWidgetWebState extends State { \$('#summernote-2').summernote({ placeholder: "${widget.htmlEditorOptions.hint}", tabsize: 2, - height: ${widget.otherOptions.height}, disableResizeEditor: false, disableDragAndDrop: ${widget.htmlEditorOptions.disableDragAndDrop}, disableGrammar: false, @@ -617,9 +612,6 @@ class _HtmlEditorWidgetWebState extends State { } final iframe = html.IFrameElement() ..width = maxWidth - ..height = widget.htmlEditorOptions.autoAdjustHeight - ? actualHeight.toString() - : widget.otherOptions.height.toString() // ignore: unsafe_html, necessary to load HTML string ..srcdoc = htmlString ..style.border = 'none' @@ -635,45 +627,37 @@ class _HtmlEditorWidgetWebState extends State { @override Widget build(BuildContext context) { - final child = SizedBox( - height: widget.htmlEditorOptions.autoAdjustHeight - ? actualHeight - : widget.otherOptions.height, - child: Column( - children: [ - widget.htmlToolbarOptions.toolbarPosition == ToolbarPosition.aboveEditor - ? ToolbarWidget( - key: toolbarKey, - controller: widget.controller, - htmlToolbarOptions: widget.htmlToolbarOptions, - callbacks: widget.callbacks) - : const SizedBox(height: 0, width: 0), - Expanded( - child: Directionality( - textDirection: TextDirection.ltr, - child: FutureBuilder( - future: summernoteInit, - builder: (context, snapshot) { - if (snapshot.hasData) { - return HtmlElementView( - viewType: createdViewId, - ); - } else { - return Container( - height: widget.htmlEditorOptions.autoAdjustHeight - ? actualHeight - : widget.otherOptions.height); - } - }))), - widget.htmlToolbarOptions.toolbarPosition == ToolbarPosition.belowEditor - ? ToolbarWidget( - key: toolbarKey, - controller: widget.controller, - htmlToolbarOptions: widget.htmlToolbarOptions, - callbacks: widget.callbacks) - : const SizedBox(height: 0, width: 0), - ], - ), + final child = Column( + children: [ + widget.htmlToolbarOptions.toolbarPosition == ToolbarPosition.aboveEditor + ? ToolbarWidget( + key: toolbarKey, + controller: widget.controller, + htmlToolbarOptions: widget.htmlToolbarOptions, + callbacks: widget.callbacks) + : const SizedBox(height: 0, width: 0), + Expanded( + child: Directionality( + textDirection: TextDirection.ltr, + child: FutureBuilder( + future: summernoteInit, + builder: (context, snapshot) { + if (snapshot.hasData) { + return HtmlElementView( + viewType: createdViewId, + ); + } else { + return const SizedBox.shrink(); + } + }))), + widget.htmlToolbarOptions.toolbarPosition == ToolbarPosition.belowEditor + ? ToolbarWidget( + key: toolbarKey, + controller: widget.controller, + htmlToolbarOptions: widget.htmlToolbarOptions, + callbacks: widget.callbacks) + : const SizedBox(height: 0, width: 0), + ], ); return Focus( @@ -922,20 +906,6 @@ class _HtmlEditorWidgetWebState extends State { var jsonStr2 = _jsonEncoder.convert(data2); _summernoteOnLoadListener = html.window.onMessage.listen((event) { var data = json.decode(event.data); - if (data['type'] != null && - data['type'].contains('toDart: htmlHeight') && - data['view'] == createdViewId && - widget.htmlEditorOptions.autoAdjustHeight) { - final docHeight = data['height'] ?? actualHeight; - if ((docHeight != null && docHeight != actualHeight) && - mounted && - docHeight > 0) { - setState(mounted, this.setState, () { - actualHeight = - docHeight + (toolbarKey.currentContext?.size?.height ?? 0); - }); - } - } if (data['type'] != null && data['type'].contains('toDart: onChangeContent') && data['view'] == createdViewId) {