Skip to content

Commit

Permalink
fixup! Fix composer memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed Apr 8, 2024
1 parent 749d94f commit 4d119fd
Showing 1 changed file with 65 additions and 65 deletions.
130 changes: 65 additions & 65 deletions lib/src/widgets/html_editor_widget_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -898,79 +898,79 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
if (data['type'].contains('onEditLink')) {
c.onEditLink!.call(data['urlDisplayText'], data['url'], data['isOpenInNewTab'], data['linkTagId']);
}
}

if (data['message'] == _summernoteLoadedMessage) {
if (widget.htmlEditorOptions.disabled && !alreadyDisabled) {
widget.controller.disable();
alreadyDisabled = true;
}
if (widget.callbacks != null && widget.callbacks!.onInit != null) {
widget.callbacks!.onInit!.call();
}
if (widget.htmlEditorOptions.initialText != null) {
widget.controller.setText(widget.htmlEditorOptions.initialText!);
if (data['message'] == _summernoteLoadedMessage) {
if (widget.htmlEditorOptions.disabled && !alreadyDisabled) {
widget.controller.disable();
alreadyDisabled = true;
}
if (widget.callbacks != null && widget.callbacks!.onInit != null) {
widget.callbacks!.onInit!.call();
}
if (widget.htmlEditorOptions.initialText != null) {
widget.controller.setText(widget.htmlEditorOptions.initialText!);
}
var data = <String, Object>{'type': 'toIframe: getHeight'};
data['view'] = createdViewId;
var data2 = <String, Object>{'type': 'toIframe: setInputType'};
data2['view'] = createdViewId;
var jsonStr = _jsonEncoder.convert(data);
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);
});
}
}
var data = <String, Object>{'type': 'toIframe: getHeight'};
data['view'] = createdViewId;
var data2 = <String, Object>{'type': 'toIframe: setInputType'};
data2['view'] = createdViewId;
var jsonStr = _jsonEncoder.convert(data);
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) {
if (widget.callbacks != null &&
widget.callbacks!.onChangeContent != null) {
widget.callbacks!.onChangeContent!.call(data['contents']);
}
if (data['type'] != null &&
data['type'].contains('toDart: onChangeContent') &&
data['view'] == createdViewId) {
if (widget.callbacks != null &&
widget.callbacks!.onChangeContent != null) {
widget.callbacks!.onChangeContent!.call(data['contents']);
}

if (mounted) {
final scrollableState = Scrollable.maybeOf(context);
if (widget.htmlEditorOptions.shouldEnsureVisible &&
scrollableState != null) {
scrollableState.position.ensureVisible(
context.findRenderObject()!,
duration: const Duration(milliseconds: 100),
curve: Curves.easeIn);
}

if (mounted) {
final scrollableState = Scrollable.maybeOf(context);
if (widget.htmlEditorOptions.shouldEnsureVisible &&
scrollableState != null) {
scrollableState.position.ensureVisible(
context.findRenderObject()!,
duration: const Duration(milliseconds: 100),
curve: Curves.easeIn);
}
}
if (data['type'] != null &&
data['type'].contains('toDart: updateToolbar') &&
data['view'] == createdViewId) {
if (widget.controller.toolbar != null) {
widget.controller.toolbar!.updateToolbar(data);
}
}
if (data['type'] != null &&
data['type'].contains('toDart: updateToolbar') &&
data['view'] == createdViewId) {
if (widget.controller.toolbar != null) {
widget.controller.toolbar!.updateToolbar(data);
}
});
html.window.postMessage(jsonStr, '*');
html.window.postMessage(jsonStr2, '*');

if (widget.otherOptions.dropZoneHeight != null ||
widget.otherOptions.dropZoneWidth != null) {
_setDimensionDropZoneView(
height: widget.otherOptions.dropZoneHeight,
width: widget.otherOptions.dropZoneWidth
);
}
});
html.window.postMessage(jsonStr, '*');
html.window.postMessage(jsonStr2, '*');

if (widget.otherOptions.dropZoneHeight != null ||
widget.otherOptions.dropZoneWidth != null) {
_setDimensionDropZoneView(
height: widget.otherOptions.dropZoneHeight,
width: widget.otherOptions.dropZoneWidth
);
}
}
}
});
}

Expand Down

0 comments on commit 4d119fd

Please sign in to comment.