Skip to content

Commit

Permalink
fixup! Fix double scrolling editor
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed Nov 20, 2024
1 parent e0b57fc commit cd44a90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
6 changes: 1 addition & 5 deletions lib/src/html_editor_controller_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController {
/// Recalculates the height of the editor to remove any vertical scrolling.
/// This method will not do anything if [autoAdjustHeight] is turned off.
@override
void recalculateHeight() {
_evaluateJavascriptWeb(data: {
'type': 'toIframe: getHeight',
});
}
void recalculateHeight() {}

/// A function to quickly call a document.execCommand function in a readable format
@override
Expand Down
12 changes: 7 additions & 5 deletions lib/src/widgets/html_editor_widget_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
var headString = '';
var summernoteCallbacks = '''callbacks: {
onKeydown: function(e) {
if (e.keyCode === 13) { /* ENTER */
const editor = querySelector('.note-editable');
editor.blur();
editor.focus();
}
var chars = \$(".note-editable").text();
var totalChars = chars.length;
${widget.htmlEditorOptions.characterLimit != null ? '''allowedKeys = (
Expand Down Expand Up @@ -277,10 +283,6 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
var str = \$('#summernote-2').summernote('code');
window.parent.postMessage(JSON.stringify({"type": "toDart: getTextWithSignatureContent", "text": str}), "*");
}
if (data["type"].includes("getHeight")) {
var height = document.body.scrollHeight;
window.parent.postMessage(JSON.stringify({"view": "$createdViewId", "type": "toDart: htmlHeight", "height": height}), "*");
}
if (data["type"].includes("setInputType")) {
document.getElementsByClassName('note-editable')[0].setAttribute('inputmode', '${widget.htmlEditorOptions.inputType.name}');
}
Expand Down Expand Up @@ -898,7 +900,7 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
widget.callbacks?.onInitialTextLoadComplete?.call(
widget.htmlEditorOptions.initialText!);
}
var data = <String, Object>{'type': 'toIframe: getHeight'};
var data = <String, Object>{};
data['view'] = createdViewId;
var data2 = <String, Object>{'type': 'toIframe: setInputType'};
data2['view'] = createdViewId;
Expand Down

0 comments on commit cd44a90

Please sign in to comment.