import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons"; import { Button, Checkbox, Col, Form, Input, Radio, Row, Space, Typography, } from "antd"; const { Text } = Typography; import {} from "antd"; import { useEffect, useState } from "react"; import "./index.less"; interface IProps { onChange?: Function; styles?: React.CSSProperties; } interface IChapter { chapter_level: string; chapter_title: string; chapter_file_id?: string; } const Chatpter = (props: IProps) => { const [form] = Form.useForm(); const [chapterList, setChapterList] = useState([]); const onTocChange = () => { const { toc } = form.getFieldsValue(); const process = toc .split("\n") .filter((i: string) => i.replace(/\s/, "").length > 0) .map((row: string, index: number) => { const [chapter_level, chapter_title, chapter_file_id] = row.split("|"); return !chapter_file_id ? { order: index, chapter_level, chapter_title } : { order: index, chapter_level, chapter_title, chapter_file_id }; }); setChapterList(process); }; useEffect(() => { if (props.onChange) props.onChange(chapterList); }, [chapterList]); return (
    {chapterList.map((c, index) => (
  • {c.chapter_title} {c.chapter_file_id && ( {c.chapter_file_id} )}
  • ))}
); }; export default Chatpter;