Compare commits
1 Commits
614ef3ffaf
...
1eaf5cc4e4
| Author | SHA1 | Date | |
|---|---|---|---|
| 1eaf5cc4e4 |
@@ -1408,34 +1408,6 @@ function FormatoYCitasStep({
|
|||||||
onChangeTipo: (id: string, tipo: BibliografiaTipo) => void
|
onChangeTipo: (id: string, tipo: BibliografiaTipo) => void
|
||||||
}) {
|
}) {
|
||||||
const isGeneratingAny = generatingIds.size > 0
|
const isGeneratingAny = generatingIds.size > 0
|
||||||
const [authorsDraftById, setAuthorsDraftById] = useState<
|
|
||||||
Record<string, string>
|
|
||||||
>({})
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const ids = new Set(refs.map((r) => r.id))
|
|
||||||
setAuthorsDraftById((prev) => {
|
|
||||||
let next = prev
|
|
||||||
|
|
||||||
// Remove drafts for refs that no longer exist
|
|
||||||
for (const id of Object.keys(prev)) {
|
|
||||||
if (!ids.has(id)) {
|
|
||||||
if (next === prev) next = { ...prev }
|
|
||||||
delete next[id]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize drafts for new refs (do not override existing edits)
|
|
||||||
for (const r of refs) {
|
|
||||||
if (typeof next[r.id] !== 'string') {
|
|
||||||
if (next === prev) next = { ...prev }
|
|
||||||
next[r.id] = r.authors.join('\n')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return next
|
|
||||||
})
|
|
||||||
}, [refs])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
@@ -1489,9 +1461,17 @@ function FormatoYCitasStep({
|
|||||||
|
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
{refs.map((r) => {
|
{refs.map((r) => {
|
||||||
|
const infoText = [
|
||||||
|
r.authors.join(', '),
|
||||||
|
r.publisher,
|
||||||
|
r.year ? String(r.year) : undefined,
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' • ')
|
||||||
|
|
||||||
const isGenerating = generatingIds.has(r.id)
|
const isGenerating = generatingIds.has(r.id)
|
||||||
|
|
||||||
const authorsText = authorsDraftById[r.id] ?? r.authors.join('\n')
|
const authorsText = r.authors.join('\n')
|
||||||
const yearText = typeof r.year === 'number' ? String(r.year) : ''
|
const yearText = typeof r.year === 'number' ? String(r.year) : ''
|
||||||
const isbnText = r.isbn ?? ''
|
const isbnText = r.isbn ?? ''
|
||||||
const publisherText = r.publisher ?? ''
|
const publisherText = r.publisher ?? ''
|
||||||
@@ -1540,20 +1520,14 @@ function FormatoYCitasStep({
|
|||||||
value={authorsText}
|
value={authorsText}
|
||||||
disabled={isGeneratingAny || isGenerating}
|
disabled={isGeneratingAny || isGenerating}
|
||||||
className="min-h-22.5"
|
className="min-h-22.5"
|
||||||
onChange={(e) => {
|
onChange={(e) =>
|
||||||
const nextText = e.currentTarget.value
|
|
||||||
setAuthorsDraftById((prev) => ({
|
|
||||||
...prev,
|
|
||||||
[r.id]: nextText,
|
|
||||||
}))
|
|
||||||
|
|
||||||
onChangeRef(r.id, {
|
onChangeRef(r.id, {
|
||||||
authors: nextText
|
authors: e.currentTarget.value
|
||||||
.split(/\r?\n/)
|
.split(/\r?\n/)
|
||||||
.map((x) => x.trim())
|
.map((x) => x.trim())
|
||||||
.filter(Boolean),
|
.filter(Boolean),
|
||||||
})
|
})
|
||||||
}}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user