Skip to content

Commit e42349e

Browse files
committed
feat(main: menu): add find menu
1 parent f255e2e commit e42349e

4 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/main/menu/main.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ const fileMenu: MenuItemConstructorOptions[] = [
187187
click: () => {
188188
BrowserWindow.getFocusedWindow()?.webContents.send('main-menu:new-folder')
189189
}
190+
},
191+
{
192+
label: 'Find',
193+
accelerator: 'CommandOrControl+F',
194+
click: () => {
195+
BrowserWindow.getFocusedWindow()?.webContents.send('main-menu:search')
196+
}
190197
}
191198
]
192199

src/renderer/App.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ ipc.on('main-menu:copy-snippet', () => {
127127
ipc.on('main-menu:format-snippet', () => {
128128
emitter.emit('snippet:format', true)
129129
})
130+
131+
ipc.on('main-menu:search', () => {
132+
emitter.emit('search:focus', true)
133+
})
130134
</script>
131135

132136
<style lang="scss">

src/renderer/components/snippets/SnippetListHeader.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<div class="action">
33
<UniconsSearch />
44
<input
5+
ref="inputRef"
56
v-model="query"
67
placeholder="Search..."
78
>
@@ -23,14 +24,16 @@
2324
</template>
2425

2526
<script setup lang="ts">
26-
import { onAddNewSnippet } from '@/composable'
27+
import { emitter, onAddNewSnippet } from '@/composable'
2728
import { useSnippetStore } from '@/store/snippets'
2829
import { useDebounceFn } from '@vueuse/core'
29-
import { computed } from 'vue'
30+
import { computed, ref } from 'vue'
3031
import { track } from '@/electron'
3132
3233
const snippetStore = useSnippetStore()
3334
35+
const inputRef = ref<HTMLInputElement>()
36+
3437
const query = computed({
3538
get: () => snippetStore.searchQuery,
3639
set: useDebounceFn(v => {
@@ -45,6 +48,10 @@ const onReset = () => {
4548
snippetStore.searchQuery = undefined
4649
snippetStore.setSnippetsByAlias('all')
4750
}
51+
52+
emitter.on('search:focus', () => {
53+
inputRef.value?.focus()
54+
})
4855
</script>
4956

5057
<style lang="scss" scoped>
@@ -62,6 +69,7 @@ const onReset = () => {
6269
padding: 0 var(--spacing-xs);
6370
height: 24px;
6471
background-color: var(--color-snippet-list);
72+
color: var(--color-text);
6573
}
6674
:deep(svg) {
6775
flex-shrink: 0;

src/shared/types/renderer/composable/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export type EmitterEvents = {
44
'folder:click': any
55
'folder:rename': string
66
'scroll-to:folder': string
7+
'search:focus': boolean
78
}

0 commit comments

Comments
 (0)