Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 186 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
"axios": "^1.11.0",
"bootstrap": "^5.3.7",
"file-saver": "^2.0.5",

"jspdf": "^4.2.1",
"papaparse": "^5.5.3",

"react": "^18.3.1",
"react-bootstrap": "^2.10.10",
"react-dom": "^18.3.1",
Expand Down
43 changes: 43 additions & 0 deletions frontend/src/components/ChatPanel/MessageBubble.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import React from "react";

import ReactMarkdown from "react-markdown";
import rehypeSanitize, { defaultSchema } from "rehype-sanitize";

import { exportQuizToPdf, exportQuizToWord } from "../../utils/quizExporter";

import BookmarkBorderIcon from "@mui/icons-material/BookmarkBorder";
import BookmarkIcon from "@mui/icons-material/Bookmark";


// Strict allowlist for AI-generated markdown content.
//
// ReactMarkdown converts markdown to a virtual DOM; rehype-sanitize then
Expand Down Expand Up @@ -46,6 +50,7 @@ const MODE_BADGE = {
socratic: { label: "Socratic", bg: "rgba(139,92,246,0.15)", color: "#8B5CF6" },
eli5: { label: "Simple", bg: "rgba(34,197,94,0.15)", color: "#22C55E" },
concise: { label: "Concise", bg: "rgba(249,115,22,0.15)", color: "#F97316" },
quiz: { label: "Quiz", bg: "rgba(139,92,246,0.15)", color: "#8B5CF6" },
};

const MessageBubble = ({
Expand Down Expand Up @@ -153,6 +158,43 @@ const MessageBubble = ({
<span>{msg.text}</span>
)}


{msg.role === "bot" && !msg.streaming && (msg.mode === "quiz" || msg.text.includes("# Quiz") || msg.text.toLowerCase().includes("quiz:")) && (
<div style={{ marginTop: "14px", display: "flex", gap: "10px" }}>
<button
onClick={() => exportQuizToPdf(msg.text, "quiz")}
style={{
padding: "6px 14px",
borderRadius: "10px",
border: "none",
background: "linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%)",
color: "white",
fontWeight: 600,
fontSize: "12px",
cursor: "pointer",
boxShadow: "0 4px 10px rgba(139, 92, 246, 0.2)",
transition: "all 0.2s ease"
}}
>
📄 Download PDF
</button>
<button
onClick={() => exportQuizToWord(msg.text, "quiz")}
style={{
padding: "6px 14px",
borderRadius: "10px",
border: darkMode ? "1px solid rgba(255,255,255,0.15)" : "1px solid rgba(0,0,0,0.15)",
background: "transparent",
color: darkMode ? "#D1D5DB" : "#4B5563",
fontWeight: 600,
fontSize: "12px",
cursor: "pointer",
transition: "all 0.2s ease"
}}
>
📝 Download Word
</button>

{followup && !msg.streaming && (
<div style={{
marginTop: "16px",
Expand Down Expand Up @@ -202,6 +244,7 @@ const MessageBubble = ({
</button>
))}
</div>

</div>
)}

Expand Down
Loading
Loading