@@ -4,7 +4,7 @@ import * as ContextMenu from '@/components/ui/shadcn/context-menu'
44import { useApp , useDialog , useSnippets } from ' @/composables'
55import { LibraryFilter } from ' @/composables/types'
66import { i18n } from ' @/electron'
7- import { onClickOutside } from ' @vueuse/core'
7+ import { onClickOutside , useClipboard } from ' @vueuse/core'
88import { format } from ' date-fns'
99
1010interface Props {
@@ -17,6 +17,7 @@ const {
1717 highlightedSnippetIds,
1818 highlightedFolderId,
1919 isFocusedSnippetName,
20+ focusedSnippetId,
2021 state,
2122} = useApp ()
2223
@@ -33,11 +34,12 @@ const {
3334} = useSnippets ()
3435
3536const { confirm } = useDialog ()
37+ const { copy } = useClipboard ()
3638
37- const isFocused = ref (false )
3839const snippetRef = ref <HTMLDivElement >()
3940
4041const isSelected = computed (() => state .snippetId === props .snippet .id )
42+
4143const isInMultiSelection = computed (
4244 () =>
4345 selectedSnippetIds .value .length > 1
@@ -47,6 +49,8 @@ const isHighlighted = computed(() =>
4749 highlightedSnippetIds .value .has (props .snippet .id ),
4850)
4951
52+ const isFocused = computed (() => focusedSnippetId .value === props .snippet .id )
53+
5054const isDuplicateDisabled = computed (
5155 () => highlightedSnippetIds .value .size > 1 ,
5256)
@@ -73,7 +77,7 @@ const folderName = computed(() => {
7377
7478function onSnippetClick(id : number , event : MouseEvent ) {
7579 selectSnippet (id , event .shiftKey )
76- isFocused .value = true
80+ focusedSnippetId .value = id
7781}
7882
7983function onClickContextMenu() {
@@ -185,6 +189,13 @@ async function onDuplicate() {
185189 isFocusedSnippetName .value = true
186190}
187191
192+ function onCopySnippetLink() {
193+ // copy(`masscode://folder/${state.folderId}/snippet/${props.snippet.id}`)
194+ copy (
195+ ` masscode://goto?folderId=${state .folderId }&snippetId=${props .snippet .id } ` ,
196+ )
197+ }
198+
188199function onDragStart(event : DragEvent ) {
189200 const ids
190201 = selectedSnippetIds .value .length > 1
@@ -218,7 +229,7 @@ function onDragStart(event: DragEvent) {
218229}
219230
220231onClickOutside (snippetRef , () => {
221- isFocused .value = false
232+ focusedSnippetId .value = undefined
222233 highlightedSnippetIds .value .clear ()
223234})
224235 </script >
@@ -267,6 +278,10 @@ onClickOutside(snippetRef, () => {
267278 }}
268279 </ContextMenu .Item >
269280 <ContextMenu .Separator />
281+ <ContextMenu .Item @click =" onCopySnippetLink" >
282+ {{ i18n.t("action.copy.snippetLink") }}
283+ </ContextMenu .Item >
284+ <ContextMenu .Separator />
270285 <ContextMenu .Item
271286 :disabled =" isDuplicateDisabled"
272287 @click =" onDuplicate"
0 commit comments