text & html entrelineas

This commit is contained in:
David Ascanio 2026-05-30 08:30:53 -03:00
parent d71334089f
commit 46205886ca
3 changed files with 12 additions and 7 deletions

View File

@ -21,6 +21,7 @@ interface EntrelineaDoc {
filter?: string
page?: number | string
text?: string
html?: string
studies?: Study[]
[key: string]: unknown
}
@ -80,7 +81,7 @@ function formatEntrelineaText(html: string): string {
}
const bodyHtml = computed<string>(() =>
formatEntrelineaText(props.highlightedText || props.document?.text || '')
formatEntrelineaText(props.document?.html || props.document?.text || '')
)
/* -------------------------------------------------------------------------- */
@ -93,7 +94,7 @@ const toast = useToast()
function toSearchHit(doc: EntrelineaDoc): SearchHit {
const id = doc.id || ''
return { _id: id, id, title: id || 'Entrelínea', body: doc.text, ...doc }
return { _id: id, id, title: doc.text?.slice(0, 100) || 'Entrelínea', body: doc.text, ...doc }
}
watch(
@ -114,9 +115,10 @@ function onToggleFavorite() {
if (!props.collection || !props.document?.id) return
const wasFav = isFav.value
favorites.toggle(props.collection, toSearchHit(props.document))
console.log("text slice", props.document.text?.slice(0, 100))
toast.add({
title: wasFav ? 'Eliminado de tu lista' : 'Guardado en tu lista',
description: props.document.id,
title: 'Entrelínea',
description: props.document.text?.slice(0, 100) || props.document.id,
icon: wasFav ? 'i-lucide-bookmark-x' : 'i-lucide-bookmark-check',
color: wasFav ? 'neutral' : 'primary',
duration: 1800

View File

@ -59,6 +59,7 @@ interface EntrelineaDoc {
description?: string
page?: number | string
text?: string
html?: string
studies?: Study[]
[key: string]: unknown
}
@ -255,7 +256,7 @@ function toSearchHit(doc: EntrelineaDoc): SearchHit {
return {
_id: id,
id,
title: id || 'Entrelínea',
title: doc.text?.slice(0, 100) || 'Entrelínea',
body: doc.text,
...doc
}
@ -273,7 +274,7 @@ function toggleFavorite(doc: EntrelineaDoc, ev?: Event) {
favorites.toggle(FAVORITES_COLLECTION, toSearchHit(doc))
toast.add({
title: wasFav ? 'Eliminado de tu lista' : 'Guardado en tu lista',
description: doc.id,
description: doc.text?.slice(0, 100),
icon: wasFav ? 'i-lucide-bookmark-x' : 'i-lucide-bookmark-check',
color: wasFav ? 'neutral' : 'primary',
duration: 1800

View File

@ -527,7 +527,9 @@ const nearLimit = computed(() => histTotal.value >= Math.floor(HISTORY_LIMIT * 0
/>
</div>
<div class="text-sm font-semibold line-clamp-2">
{{ it.hit?.origin || it.hit?.title || 'Sin título' }}
{{ it.collection === ENTRELINEAS_COLLECTION
? (it.hit?.title || 'Sin título')
: (it.hit?.origin || it.hit?.title || 'Sin título') }}
</div>
</div>
<UButton