Skip to content

Commit

Permalink
♻️ fix keyboard shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
lostdesign committed Jul 7, 2021
1 parent 60336b7 commit 86ac2f1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
16 changes: 9 additions & 7 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ const template = [
{ role: 'about' },
{
label: 'Settings',
accelerator: 'CommandOrControl + ,',
click() {
win.webContents.send('open-settings')
},
...(isMacOS ? { accelerator: 'CMD + ,' } : { accelerator: 'CTRL + ,' })
}
},
{ type: 'separator' },
{ role: 'quit' }
Expand Down Expand Up @@ -74,35 +74,37 @@ const template = [
click() {
win.webContents.send('set-today')
},
accelerator: 'CTRL + SHIFT + ENTER'
accelerator: 'CommandOrControl + .'
},
{ type: 'separator' },
{
label: 'Previous Day',
click() {
win.webContents.send('previous-day')
},
accelerator: 'CTRL + SHIFT + LEFT'
accelerator: 'CommandOrControl + P'
},
{
label: 'Next Day',
click() {
win.webContents.send('next-day')
},
accelerator: 'CTRL + SHIFT + RIGHT'
accelerator: 'CommandOrControl + N'
},
{ type: 'separator' },
{
label: 'Previous Week',
click() {
win.webContents.send('previous-week')
}
},
accelerator: 'CommandOrControl + Shift + P'
},
{
label: 'Next Week',
click() {
win.webContents.send('next-week')
}
},
accelerator: 'CommandOrControl + Shift + N'
},
{ type: 'separator' },
{ role: 'reload' }
Expand Down
4 changes: 1 addition & 3 deletions src/components/editor.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div
v-if="editor"
class="px-10 mt-5 text-gray-400 dark:text-gray-500 relative"
class="px-10 mt-5 text-gray-400 dark:text-gray-500 relative flex-grow"
@click="_focusEditor"
>
<bubble-menu class="bubble-menu" :editor="editor" v-if="editor">
Expand Down Expand Up @@ -140,13 +140,11 @@ export default {
},
data() {
return {
keysPressed: {},
editor: null
}
},
methods: {
...mapActions('file', [FileActions.SET_CONTENT, FileActions.SAVE_FILE]),
_focusEditor() {
this.editor
.chain()
Expand Down
2 changes: 1 addition & 1 deletion src/views/Home.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<Layout>
<main class="flex-col items-stretch h-full min-h-screen">
<main class="flex flex-col items-stretch min-h-screen">
<app-header />
<editor />
</main>
Expand Down
25 changes: 19 additions & 6 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ import MoonIcon from '@/assets/icons/moon.svg'
const { ipcRenderer } = require('electron')
export default {
components: {
BackIcon,
LanguageDropdown,
MoonIcon,
Layout,
SunIcon
},
data() {
return {
version,
Expand All @@ -105,12 +112,18 @@ export default {
}
}
},
components: {
BackIcon,
LanguageDropdown,
MoonIcon,
Layout,
SunIcon
methods: {
_handleEscapeKey() {
if (event.key !== 'Escape') return
this.$router.push('/', () => {})
}
},
mounted() {
document.addEventListener('keyup', this._handleEscapeKey, true)
},
beforeDestroy() {
document.removeEventListener('keyup', this._handleEscapeKey, true)
}
}
</script>

0 comments on commit 86ac2f1

Please sign in to comment.