create today fleeting note
This commit is contained in:
22
src/hooks/useEditionMode.ts
Normal file
22
src/hooks/useEditionMode.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useMagicKeys } from '@vueuse/core'
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
export const useEditionMode = () => {
|
||||
const mode = ref<'read' | 'edit'>('read')
|
||||
const toggleMode = () => {
|
||||
mode.value = mode.value === 'read' ? 'edit' : 'read'
|
||||
}
|
||||
|
||||
const { escape } = useMagicKeys()
|
||||
|
||||
watch(escape, () => {
|
||||
if (mode.value === 'edit') {
|
||||
toggleMode()
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
mode,
|
||||
toggleMode
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user