Multiple feature additions and improvements across the application: - NextGen Editor: drag handles, smart paste, block actions - Structured views: Kanban and table layouts for notes - Architectural Grid: new brainstorming/agent interface prototype - Flashcards: SM-2 revision algorithm with AI generation - MCP server: robustness improvements - Graph/PDF chat: fix click propagation and copy behavior - Various UI/UX enhancements and bug fixes Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import prisma from '@/lib/prisma'
|
|
import { auth } from '@/auth'
|
|
import { extractBlockContentById } from '@/lib/blocks/extract-blocks'
|
|
|
|
// 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 = extractBlockContentById(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',
|
|
})
|
|
}
|