import { VNodeDirective } from 'vue' ; interface CustomElement extends Element { handler : ( evt : MouseEvent ) => void ; } export default { bind ( el , binding ) { const elCustom = el as CustomElement ; elCustom . handler = ( evt ) => binding . value ( evt , el ) ; document . body . addEventListener ( 'mousedown' , elCustom . handler , true ) ; document . body . addEventListener ( 'contextmenu' , elCustom . handler , true ) ; } , unbind ( el , binding ) { const elCustom = el as CustomElement ; document . body . removeEventListener ( 'mousedown' , elCustom . handler , true ) ; document . body . removeEventListener ( 'contextmenu' , elCustom . handler , true ) ; } } ;