import { Typography, Divider, Skeleton, Space } from "antd"; import MdView from "../template/MdView"; import TocPath, { type ITocPathNode } from "../corpus/TocPath"; import PaliChapterChannelList from "../corpus/PaliChapterChannelList"; import type { ArticleMode, ArticleType } from "./Article"; import VisibleObserver from "../general/VisibleObserver"; import type { IStudio } from "../auth/Studio"; const { Paragraph, Title, Text } = Typography; export interface IFirstAnthology { id: string; title: string; count: number; } export interface IWidgetArticleData { id?: string; title?: string; subTitle?: string; summary?: string | null; content?: string; html?: string[]; path?: ITocPathNode[]; mode?: ArticleMode | null; created_at?: string; updated_at?: string; owner?: IStudio; channels?: string[]; type?: ArticleType; articleId?: string; remains?: boolean; anthology?: IFirstAnthology; hideTitle?: boolean; onEnd?: () => void; onPathChange?: ( node: ITocPathNode, e: React.MouseEvent ) => void; } const ArticleViewWidget = ({ title = "", subTitle, summary, content, html = [], path = [], channels, type, articleId, hideTitle, onEnd, remains, onPathChange, }: IWidgetArticleData) => { console.log("ArticleViewWidget render"); let currChannelList = <>; switch (type) { case "chapter": { const chapterProps = articleId?.split("-"); if (Array.isArray(chapterProps) && chapterProps.length >= 2) { const book = Number(chapterProps[0]); const para = Number(chapterProps[1]); if (!Number.isNaN(book) && !Number.isNaN(para)) { currChannelList = ( ); } } break; } default: break; } return ( <> {hideTitle ? ( <> ) : ( ) => { if (typeof onPathChange !== "undefined") { onPathChange(node, e); } }} /> )} {hideTitle ? ( <> ) : ( <div dangerouslySetInnerHTML={{ __html: title ? title : "", }} /> )} {subTitle} {currChannelList} {summary} {html ? html.map((item, id) => { return (
); }) : content} {remains ? ( <> { console.log("visible", visible); if (visible && typeof onEnd !== "undefined") { onEnd(); } }} /> ) : undefined} ); }; export default ArticleViewWidget;