From 2021c2ab42160217821fa26e7fedaacb465a10f4 Mon Sep 17 00:00:00 2001 From: DatDang Date: Mon, 25 Nov 2024 11:43:01 +0700 Subject: [PATCH] fixup! Handle additional cases for drag drop in editor --- lib/src/widgets/html_editor_widget_web.dart | 5 ++++- lib/utils/callbacks.dart | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/widgets/html_editor_widget_web.dart b/lib/src/widgets/html_editor_widget_web.dart index 86bf8225..35da5f1a 100644 --- a/lib/src/widgets/html_editor_widget_web.dart +++ b/lib/src/widgets/html_editor_widget_web.dart @@ -498,7 +498,7 @@ class _HtmlEditorWidgetWebState extends State { document.getElementsByClassName('note-editor')[0].addEventListener("dragover", function(event) { if (event.dataTransfer.types.includes("Files")) { event.preventDefault(); - window.parent.postMessage(JSON.stringify({"view": "$createdViewId", "type": "toDart: onDragEnter", "types": event.dataTransfer.types}), "*"); + window.parent.postMessage(JSON.stringify({"view": "$createdViewId", "type": "toDart: onDragOver", "types": event.dataTransfer.types}), "*"); } }); @@ -895,6 +895,9 @@ class _HtmlEditorWidgetWebState extends State { if (data['type'].contains('onDragEnter') && c.onDragEnter != null) { c.onDragEnter!.call(data['types']); } + if (data['type'].contains('onDragOver') && c.onDragOver != null) { + c.onDragOver!.call(data['types']); + } if (data['type'].contains('onDragLeave') && c.onDragLeave != null) { c.onDragLeave!.call(data['types']); } diff --git a/lib/utils/callbacks.dart b/lib/utils/callbacks.dart index 186642cf..94b991f5 100644 --- a/lib/utils/callbacks.dart +++ b/lib/utils/callbacks.dart @@ -27,6 +27,7 @@ class Callbacks { this.onScroll, this.onTextFontSizeChanged, this.onDragEnter, + this.onDragOver, this.onDragLeave, this.onInitialTextLoadComplete, }); @@ -194,6 +195,8 @@ class Callbacks { void Function(List? types)? onDragEnter; + void Function(List? types)? onDragOver; + void Function(List? types)? onDragLeave; void Function(String initialText)? onInitialTextLoadComplete;