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

19 lines
541 B
TypeScript
Raw Normal View History

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);
};