import type { Element } from "hast"; import { ChevronDown, ChevronUp } from "lucide-react"; import { memo } from "react"; import ReactMarkdown from "react-markdown"; import rehypeKatex from "rehype-katex"; import rehypeRaw from "rehype-raw"; import rehypeSanitize from "rehype-sanitize"; import remarkBreaks from "remark-breaks"; import remarkGfm from "remark-gfm"; import remarkMath from "remark-math"; import { cn } from "@/lib/utils"; import { useTranslate } from "@/utils/i18n"; import { remarkDisableSetext } from "@/utils/remark-plugins/remark-disable-setext"; import { remarkPreserveType } from "@/utils/remark-plugins/remark-preserve-type"; import { remarkTag } from "@/utils/remark-plugins/remark-tag"; import { CodeBlock } from "./CodeBlock"; import { isTagNode, isTaskListItemNode } from "./ConditionalComponent"; import { COMPACT_MODE_CONFIG, SANITIZE_SCHEMA } from "./constants"; import { useCompactLabel, useCompactMode } from "./hooks"; import { Blockquote, Heading, HorizontalRule, Image, InlineCode, Link, List, ListItem, Paragraph } from "./markdown"; import { Table, TableBody, TableCell, TableHead, TableHeaderCell, TableRow } from "./Table"; import { Tag } from "./Tag"; import { TaskListItem } from "./TaskListItem"; import type { MemoContentProps } from "./types"; const MemoContent = (props: MemoContentProps) => { const { className, contentClassName, content, onClick, onDoubleClick } = props; const t = useTranslate(); const { containerRef: memoContentContainerRef, mode: showCompactMode, toggle: toggleCompactMode, } = useCompactMode(Boolean(props.compact)); const compactLabel = useCompactLabel(showCompactMode, t as (key: string) => string); return (
{children}, hr: () =>