Enhance lesson editor: prev/next nav + richer toolbar

- page.tsx: fetch sibling lessons, pass prevLesson/nextLesson props
- LessonEditor: ChevronLeft/Right nav buttons with lesson title tooltip
- Toolbar: added Underline, Strikethrough, inline Code, H1, Horizontal rule,
  Link dialog (prompt), labeled buttons for better discoverability
- Install @tiptap/extension-underline

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-08 10:29:39 +05:00
parent 66b311f17e
commit 093e403f5f
4 changed files with 140 additions and 46 deletions
@@ -12,19 +12,30 @@ interface Props {
export default async function LessonEditorPage({ params }: Props) {
const { courseId, moduleId, lessonId } = await params;
const lesson = await prisma.lesson.findUnique({
where: { id: lessonId },
include: {
files: { orderBy: { createdAt: "asc" } },
homework: true,
module: {
include: { course: { select: { title: true, slug: true } } },
const [lesson, siblings] = await Promise.all([
prisma.lesson.findUnique({
where: { id: lessonId },
include: {
files: { orderBy: { createdAt: "asc" } },
homework: true,
module: {
include: { course: { select: { title: true, slug: true } } },
},
},
},
});
}),
prisma.lesson.findMany({
where: { moduleId },
orderBy: { order: "asc" },
select: { id: true, title: true },
}),
]);
if (!lesson || lesson.moduleId !== moduleId) notFound();
const idx = siblings.findIndex((l) => l.id === lessonId);
const prevLesson = idx > 0 ? siblings[idx - 1] : null;
const nextLesson = idx < siblings.length - 1 ? siblings[idx + 1] : null;
return (
<div className="p-8 max-w-4xl">
<nav className="text-xs mb-6 uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
@@ -50,6 +61,8 @@ export default async function LessonEditorPage({ params }: Props) {
courseId={courseId}
moduleId={moduleId}
courseSlug={lesson.module.course.slug}
prevLesson={prevLesson}
nextLesson={nextLesson}
/>
</div>