1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-30 10:36:35 +02:00
joplin/packages/app-desktop/gui/utils/dragAndDrop.ts

19 lines
541 B
TypeScript

let globalDropEventCallback_: (()=> void)|null = null;
const onGlobalDrop = () => {
const callback = globalDropEventCallback_;
unregisterGlobalDragEndEvent();
if (callback) callback();
};
export const registerGlobalDragEndEvent = (callback: ()=> void) => {
if (globalDropEventCallback_) return;
globalDropEventCallback_ = callback;
document.addEventListener('dragend', onGlobalDrop);
};
export const unregisterGlobalDragEndEvent = () => {
globalDropEventCallback_ = null;
document.removeEventListener('dragend', onGlobalDrop);
};