Skip to content

Commit

Permalink
fixup! Handle additional cases for drag drop in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora authored and hoangdat committed Nov 27, 2024
1 parent 2a38ec4 commit 2021c2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/src/widgets/html_editor_widget_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
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}), "*");
}
});
Expand Down Expand Up @@ -895,6 +895,9 @@ class _HtmlEditorWidgetWebState extends State<HtmlEditorWidget> {
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']);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/utils/callbacks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Callbacks {
this.onScroll,
this.onTextFontSizeChanged,
this.onDragEnter,
this.onDragOver,
this.onDragLeave,
this.onInitialTextLoadComplete,
});
Expand Down Expand Up @@ -194,6 +195,8 @@ class Callbacks {

void Function(List<dynamic>? types)? onDragEnter;

void Function(List<dynamic>? types)? onDragOver;

void Function(List<dynamic>? types)? onDragLeave;

void Function(String initialText)? onInitialTextLoadComplete;
Expand Down

0 comments on commit 2021c2a

Please sign in to comment.