feat(notes): liens internes, onglet Réseau, living blocks et consentement IA
Rend les liens entre notes visibles et persistants (sync NoteLink au save, auto-save, graphe réseau rafraîchi), ajoute living blocks, Memory Echo, recherche globale, consentement IA explicite et consolide les prototypes design en architectural-grid. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
52
memento-note/app/api/blocks/[blockId]/status/route.ts
Normal file
52
memento-note/app/api/blocks/[blockId]/status/route.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { auth } from '@/auth'
|
||||
|
||||
function extractBlockContent(html: string, blockId: string): string | null {
|
||||
const regex = new RegExp(
|
||||
`<(?:p|h[1-6]|blockquote)[^>]*data-id="${blockId}"[^>]*>([\\s\\S]*?)<\\/(?:p|h[1-6]|blockquote)>`,
|
||||
'i'
|
||||
)
|
||||
const match = regex.exec(html)
|
||||
if (!match) return null
|
||||
return match[1].replace(/<[^>]+>/g, '').trim()
|
||||
}
|
||||
|
||||
// GET /api/blocks/[blockId]/status?sourceNoteId=xxx
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ blockId: string }> }
|
||||
) {
|
||||
const session = await auth()
|
||||
if (!session?.user?.id) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
const { blockId } = await params
|
||||
const sourceNoteId = request.nextUrl.searchParams.get('sourceNoteId')
|
||||
|
||||
if (!sourceNoteId) {
|
||||
return NextResponse.json({ error: 'sourceNoteId required' }, { status: 400 })
|
||||
}
|
||||
|
||||
const note = await prisma.note.findFirst({
|
||||
where: { id: sourceNoteId, userId: session.user.id },
|
||||
select: { id: true, title: true, content: true },
|
||||
})
|
||||
|
||||
if (!note) {
|
||||
return NextResponse.json({ exists: false, content: '', sourceNoteTitle: '' })
|
||||
}
|
||||
|
||||
const content = extractBlockContent(note.content, blockId)
|
||||
|
||||
if (content === null) {
|
||||
return NextResponse.json({ exists: false, content: '', sourceNoteTitle: note.title || '' })
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
exists: true,
|
||||
content,
|
||||
sourceNoteTitle: note.title || 'Sans titre',
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user