diff --git a/src/lib/components/notes/Notes.svelte b/src/lib/components/notes/Notes.svelte index b6da80055c..3ebe4fb8ed 100644 --- a/src/lib/components/notes/Notes.svelte +++ b/src/lib/components/notes/Notes.svelte @@ -32,7 +32,7 @@ import { WEBUI_NAME, config, prompts as _prompts, user } from '$lib/stores'; import { createNewNote, deleteNoteById, getNotes } from '$lib/apis/notes'; - import { capitalizeFirstLetter } from '$lib/utils'; + import { capitalizeFirstLetter, copyToClipboard } from '$lib/utils'; import EllipsisHorizontal from '../icons/EllipsisHorizontal.svelte'; import DeleteConfirmDialog from '$lib/components/common/ConfirmDialog.svelte'; @@ -324,6 +324,16 @@ downloadHandler(type); }} + onCopyLink={async () => { + const baseUrl = window.location.origin; + const res = await copyToClipboard(`${baseUrl}/notes/${note.id}`); + + if (res) { + toast.success($i18n.t('Copied link to clipboard')); + } else { + toast.error($i18n.t('Failed to copy link')); + } + }} onDelete={() => { selectedNote = note; showDeleteConfirm = true; diff --git a/src/lib/components/notes/Notes/NoteMenu.svelte b/src/lib/components/notes/Notes/NoteMenu.svelte index eb4040e883..fd147778c8 100644 --- a/src/lib/components/notes/Notes/NoteMenu.svelte +++ b/src/lib/components/notes/Notes/NoteMenu.svelte @@ -23,8 +23,8 @@ export let onDownload = (type) => {}; export let onDelete = () => {}; - export let onCopyLink = () => {}; - export let onCopyToClipboard = () => {}; + export let onCopyLink = null; + export let onCopyToClipboard = null; export let onChange = () => {}; @@ -89,40 +89,46 @@ - - - - - {$i18n.t('Share')} - - - + { - onCopyLink(); - }} > - - {$i18n.t('Copy link')} - + - { - onCopyToClipboard(); - }} + {$i18n.t('Share')} + + - - {$i18n.t('Copy to clipboard')} - - - + {#if onCopyLink} + { + onCopyLink(); + }} + > + + {$i18n.t('Copy link')} + + {/if} + + {#if onCopyToClipboard} + { + onCopyToClipboard(); + }} + > + + {$i18n.t('Copy to clipboard')} + + {/if} + + + {/if}