Skip to content

Commit 1699335

Browse files
committed
feat(snippets): add copy to clipboard
1 parent 8a66475 commit 1699335

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/renderer/components/snippets/SnippetHeader.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</div>
1212
<div class="action">
1313
<AppActionButton>
14-
<UniconsArrow />
14+
<UniconsArrow @click="onCopySnippet" />
1515
</AppActionButton>
1616
<AppActionButton>
1717
<UniconsPlus @click="onAddNewFragment" />
@@ -26,9 +26,11 @@
2626

2727
<script setup lang="ts">
2828
import { emitter } from '@/composable'
29+
import { ipc } from '@/electron'
2930
import { useSnippetStore } from '@/store/snippets'
30-
import { useDebounceFn } from '@vueuse/core'
31+
import { useClipboard, useDebounceFn } from '@vueuse/core'
3132
import { computed, ref } from 'vue'
33+
import type { NotificationPayload } from '@@/types'
3234
3335
const snippetStore = useSnippetStore()
3436
const inputRef = ref<HTMLInputElement>()
@@ -47,6 +49,14 @@ const onAddNewFragment = () => {
4749
snippetStore.fragment = snippetStore.fragmentCount!
4850
}
4951
52+
const onCopySnippet = () => {
53+
const { copy } = useClipboard({ source: snippetStore.currentContent })
54+
copy()
55+
ipc.invoke<any, NotificationPayload>('notification', {
56+
body: 'Snippet copied'
57+
})
58+
}
59+
5060
emitter.on('focus:snippet-name', () => {
5161
inputRef.value?.select()
5262
})

0 commit comments

Comments
 (0)