import Link from "next/link"; import { FaExpand } from "react-icons/fa"; import ReactMarkdown from "react-markdown"; import { Card } from "../../../common/Card"; import { CopyText } from "../../../common/CopyText"; import { QuestionFragment } from "../../../fragments.generated"; import { cleanText } from "../../../utils"; import { QuestionOptions } from "../QuestionOptions"; import { QuestionFooter } from "./QuestionFooter"; const truncateText = (length: number, text: string): string => { if (!text) { return ""; } if (text.length <= length) { return text; } const breakpoints = " .!?"; let lastLetter: string | undefined = undefined; let lastIndex: number | undefined = undefined; for (let index = length; index > 0; index--) { const letter = text[index]; if (breakpoints.includes(letter)) { lastLetter = letter; lastIndex = index; break; } } let truncatedText = text.slice(0, lastIndex) + (lastLetter != "." ? "..." : ".."); return truncatedText; }; // Auxiliary components const DisplayMarkdown: React.FC<{ description: string }> = ({ description, }) => { const formatted = truncateText(250, cleanText(description)); // overflow-hidden overflow-ellipsis h-24 return formatted === "" ? null : (