mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
19 lines
541 B
TypeScript
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);
|
||
|
};
|