File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,13 +88,20 @@ export const DndPlugin = createTPlatePlugin<DndConfig>({
8888 useHooks : ( { setOption } ) => {
8989 const handleDocumentDragLeave = useCallback (
9090 ( e : DragEvent ) => {
91+ // This event fires for every element that receives a drag leave event. If `clientX` and `clientY` are both 0,
92+ // it means the drag has left the viewport. Needed, if the drag did not start inside the editor, but for example
93+ // by dragging a file from the filesystem
9194 if ( ! e . clientX && ! e . clientY ) {
9295 setOption ( 'dropTarget' , undefined ) ;
9396 }
9497 } ,
9598 [ setOption ]
9699 ) ;
97100
101+ // We listen for the drop event on the document and not only inside the editor, because we want to
102+ // remove the dropTarget, and therefore hide the drop line, also when the drop happened outside of
103+ // the editor. Needed, if the drag did not start inside the editor, but for example by dragging a
104+ // file from the filesystem
98105 const handleDocumentDrop = useCallback ( ( ) => {
99106 setOption ( '_isOver' , false ) ;
100107 setOption ( 'dropTarget' , undefined ) ;
You can’t perform that action at this time.
0 commit comments