diff --git a/app/components/PublicationDetail.vue b/app/components/PublicationDetail.vue index 43ab7d9..98abbca 100644 --- a/app/components/PublicationDetail.vue +++ b/app/components/PublicationDetail.vue @@ -6,7 +6,7 @@ import { useHistoryStore } from '~/stores/history' import { storeToRefs } from 'pinia' import { useSettingsStore } from '~/stores/settings' import type { SearchHit } from '~/types' -import { select } from '#build/ui' +import { pageHeader, select } from '#build/ui' interface TypesenseHighlight { field?: string @@ -796,7 +796,8 @@ const links = computed(() => { icon: 'ph-arrow-square-out', to: matchUrl, target: '_blank' - } + }, + ...formatFiles(props.document?.files) ] }) @@ -958,9 +959,14 @@ const items = computed(() => { + > + +
Cargando párrafos... @@ -1054,11 +1060,11 @@ const items = computed(() => {
- + {{ $t('ui.copy') }}
diff --git a/app/utils/textUtilities.ts b/app/utils/textUtilities.ts index 013face..7f27da8 100644 --- a/app/utils/textUtilities.ts +++ b/app/utils/textUtilities.ts @@ -1,5 +1,5 @@ /* Copy to Clipboard */ -export async function copyToClipboard(type: string) { +export async function copyToClipboard(doc: ItemObject) { const toast = useToast() const selection = window.getSelection() @@ -8,8 +8,8 @@ export async function copyToClipboard(type: string) { const range = selection?.getRangeAt(0) container.appendChild(range.cloneContents()) - const htmlOutput = container.innerHTML - const textOutput = selection?.toString() + const htmlOutput = container.innerHTML + '
' + doc.title + '
' + formatSignature(doc) + const textOutput = selection?.toString() + '\n\n' + doc.title + '\n' + formatSignature(doc) try { // Modern Clipboard API requires ClipboardItem @@ -21,16 +21,22 @@ export async function copyToClipboard(type: string) { await navigator.clipboard.write([clipboardItem]) toast.add({ title: 'Texto copiado!', - description: `${textOutput}`, + description: `${truncateAtWord(textOutput, 150)}`, icon: 'ph-clipboard-text', - color: type == 'activities' ? 'success' : 'info' + color: doc.type == 'activities' ? 'success' : 'info' }) } catch (err) { console.error('Failed to copy: ', err) } } -export function debugDocument(json) { +const truncateAtWord = (str: string, limit: number) => { + if (str.length <= limit) return str + const subString = str.slice(0, limit) + return subString.slice(0, subString.lastIndexOf('')) + '...' +} + +export function debugDocument(json: []) { let data = '' // Iterate through keys and values for (const key in json) {