vikunja-frontend/src/directives/shortcut.ts

21 lines
446 B
TypeScript
Raw Normal View History

2022-04-11 20:08:28 +00:00
import type {Directive} from 'vue'
import {install, uninstall} from '@github/hotkey'
import {isAppleDevice} from '@/helpers/isAppleDevice'
2022-10-17 11:14:07 +00:00
const directive = <Directive<HTMLElement,string>>{
mounted(el, {value}) {
if(value === '') {
return
}
if (isAppleDevice() && value.includes('Control')) {
value = value.replace('Control', 'Meta')
}
install(el, value)
},
beforeUnmount(el) {
uninstall(el)
},
}
export default directive