feat: add slides generation tool with multiple slide types
- Add slides.tool.ts with support for title, bullets, chart, stats, table, cards, timeline, quote, comparison, equation, image, summary slide types - Chart types: bar, horizontal-bar, line, donut, radar - Integrate with agent executor and canvas system - Add multilingual support (en/fr) - Various UI improvements and bug fixes Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
111
memento-note/components/wikilinks-backlinks-panel.tsx
Normal file
111
memento-note/components/wikilinks-backlinks-panel.tsx
Normal file
@@ -0,0 +1,111 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Link2, ChevronRight, Loader2 } from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { motion, AnimatePresence } from 'motion/react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
|
||||
interface BacklinkNote {
|
||||
id: string
|
||||
title: string | null
|
||||
updatedAt: string
|
||||
notebookId: string | null
|
||||
}
|
||||
|
||||
interface Backlink {
|
||||
id: string
|
||||
sourceNote: BacklinkNote
|
||||
contextSnippet: string | null
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
interface WikilinksBacklinksPanelProps {
|
||||
noteId: string
|
||||
className?: string
|
||||
}
|
||||
|
||||
export function WikilinksBacklinksPanel({ noteId, className }: WikilinksBacklinksPanelProps) {
|
||||
const [backlinks, setBacklinks] = useState<Backlink[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [open, setOpen] = useState(true)
|
||||
const router = useRouter()
|
||||
|
||||
useEffect(() => {
|
||||
if (!noteId) return
|
||||
setLoading(true)
|
||||
fetch(`/api/notes/${noteId}/backlinks`)
|
||||
.then(r => r.json())
|
||||
.then(data => setBacklinks(data.backlinks || []))
|
||||
.catch(() => {})
|
||||
.finally(() => setLoading(false))
|
||||
}, [noteId])
|
||||
|
||||
if (loading && backlinks.length === 0) return null
|
||||
if (!loading && backlinks.length === 0) return null
|
||||
|
||||
return (
|
||||
<div className={cn('space-y-2', className)}>
|
||||
{/* Header */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setOpen(o => !o)}
|
||||
className="flex items-center gap-2 group w-full"
|
||||
>
|
||||
<Link2 size={14} className="text-concrete shrink-0" />
|
||||
<span className="text-[10px] uppercase tracking-[0.25em] font-bold text-concrete group-hover:text-ink transition-colors">
|
||||
Liens entrants
|
||||
</span>
|
||||
<span className="text-[9px] bg-brand-accent/10 text-brand-accent px-1.5 py-0.5 rounded-full font-bold">
|
||||
{backlinks.length}
|
||||
</span>
|
||||
<div className="h-px flex-1 bg-border/40" />
|
||||
<ChevronRight
|
||||
size={12}
|
||||
className={cn('text-concrete transition-transform', open && 'rotate-90')}
|
||||
/>
|
||||
</button>
|
||||
|
||||
<AnimatePresence>
|
||||
{open && (
|
||||
<motion.div
|
||||
initial={{ height: 0, opacity: 0 }}
|
||||
animate={{ height: 'auto', opacity: 1 }}
|
||||
exit={{ height: 0, opacity: 0 }}
|
||||
transition={{ duration: 0.2 }}
|
||||
className="overflow-hidden pl-5 space-y-1.5"
|
||||
>
|
||||
{loading && (
|
||||
<div className="flex items-center gap-2 py-2">
|
||||
<Loader2 size={12} className="animate-spin text-concrete" />
|
||||
<span className="text-[10px] text-concrete">Chargement…</span>
|
||||
</div>
|
||||
)}
|
||||
{backlinks.map(bl => (
|
||||
<button
|
||||
key={bl.id}
|
||||
type="button"
|
||||
onClick={() => router.push(`/notes/${bl.sourceNote.id}`)}
|
||||
className="w-full text-left group/bl p-2.5 rounded-lg bg-white/50 dark:bg-white/5 border border-border/40 hover:border-brand-accent/30 hover:bg-brand-accent/5 transition-all"
|
||||
>
|
||||
<div className="flex items-start gap-2">
|
||||
<Link2 size={10} className="text-brand-accent/60 mt-0.5 shrink-0" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-[11px] font-semibold text-ink truncate group-hover/bl:text-brand-accent transition-colors">
|
||||
{bl.sourceNote.title || '(Sans titre)'}
|
||||
</p>
|
||||
{bl.contextSnippet && (
|
||||
<p className="text-[9px] text-concrete/70 mt-0.5 line-clamp-2 leading-relaxed">
|
||||
…{bl.contextSnippet}…
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user