Make URLs in homework answers and feedback clickable
Apply linkify() to student submission text (curator review page + student cabinet: reviewed/approved/pending) and to curator feedback text, so pasted links (e.g. Yandex.Disk) render as clickable anchors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { notFound } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
import { linkify } from "@/lib/linkify";
|
||||
import { FeedbackForm } from "./feedback-form";
|
||||
import { ContentTabs } from "./content-tabs";
|
||||
import { DeleteSubmissionButton } from "./delete-button";
|
||||
@@ -151,7 +152,7 @@ export default async function SubmissionPage({ params }: Props) {
|
||||
className="px-4 py-3 text-sm whitespace-pre-wrap"
|
||||
style={{ border: "2px solid var(--border)" }}
|
||||
>
|
||||
{submission.text}
|
||||
{linkify(submission.text)}
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-sm italic" style={{ color: "var(--muted-foreground)" }}>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useState, useTransition } from "react";
|
||||
import { submitHomework } from "@/lib/actions/student-actions";
|
||||
import { AudioRecorder } from "@/components/curator/audio-recorder";
|
||||
import { linkify } from "@/lib/linkify";
|
||||
|
||||
interface HWFile { name: string; url: string; size: number }
|
||||
|
||||
@@ -99,7 +100,7 @@ export function HomeworkSection({ homework, submission, slug, lessonId, allowAud
|
||||
<div className="space-y-2">
|
||||
<p className="text-xs font-bold uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>Ваш ответ</p>
|
||||
<div className="px-4 py-3 text-sm whitespace-pre-wrap opacity-70" style={{ border: "2px solid var(--border)" }}>
|
||||
{submission!.text || "—"}
|
||||
{submission!.text ? linkify(submission!.text) : "—"}
|
||||
</div>
|
||||
{submission!.audioUrl && (
|
||||
<div className="px-4 py-2" style={{ border: "1px solid var(--border)" }}>
|
||||
@@ -118,7 +119,7 @@ export function HomeworkSection({ homework, submission, slug, lessonId, allowAud
|
||||
{fb.curator.name} · {new Date(fb.createdAt).toLocaleDateString("ru-RU")}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-sm whitespace-pre-wrap">{fb.text}</p>
|
||||
<p className="text-sm whitespace-pre-wrap">{linkify(fb.text)}</p>
|
||||
{fbFiles.length > 0 && (
|
||||
<div className="space-y-1">
|
||||
{fbFiles.map((f) => (
|
||||
@@ -155,7 +156,7 @@ export function HomeworkSection({ homework, submission, slug, lessonId, allowAud
|
||||
</div>
|
||||
{submission.text && (
|
||||
<div className="px-4 py-3 text-sm whitespace-pre-wrap opacity-70" style={{ border: "2px solid var(--border)" }}>
|
||||
{submission.text}
|
||||
{linkify(submission.text)}
|
||||
</div>
|
||||
)}
|
||||
{submission.audioUrl && (
|
||||
@@ -197,7 +198,7 @@ export function HomeworkSection({ homework, submission, slug, lessonId, allowAud
|
||||
</div>
|
||||
{submission.text && (
|
||||
<div className="px-4 py-3 text-sm whitespace-pre-wrap" style={{ border: "2px solid var(--border)" }}>
|
||||
{submission.text}
|
||||
{linkify(submission.text)}
|
||||
</div>
|
||||
)}
|
||||
{submission.audioUrl && (
|
||||
|
||||
Reference in New Issue
Block a user