import { Hash, ListTree, X } from "lucide-react"; import React, { useMemo } from "react"; import { extractNoteHeadings, type NoteHeadingItem } from "../../domain/notes"; import { useI18n } from "../../application/i18n/I18nProvider"; export interface NoteOutlineProps { content: string; onSelectHeading?: (heading: NoteHeadingItem) => void; onClose?: () => void; className?: string; } export const NoteOutline: React.FC = ({ content, onSelectHeading, onClose, className = "", }) => { const { t } = useI18n(); const headings = useMemo(() => extractNoteHeadings(content), [content]); const getIndentClass = (level: number) => { switch (level) { case 1: return "pl-2 font-semibold text-foreground"; case 2: return "pl-5 text-foreground/90"; case 3: return "pl-8 text-muted-foreground"; case 4: default: return "pl-11 text-muted-foreground/80 text-xs"; } }; return (
大纲目录 ({headings.length})
{onClose && ( )}
{headings.length === 0 ? (

暂无标题大纲

在 Markdown 中使用 #、## 编写各级标题

) : ( headings.map((item) => ( )) )}
); };