소스 검색

add onTitle

visuddhinanda 2 년 전
부모
커밋
384427fbfc
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      dashboard/src/components/article/TypePali.tsx

+ 6 - 0
dashboard/src/components/article/TypePali.tsx

@@ -34,6 +34,7 @@ interface IWidget {
   onArticleChange?: Function;
   onFinal?: Function;
   onLoad?: Function;
+  onTitle?: Function;
 }
 const TypePaliWidget = ({
   type,
@@ -48,6 +49,7 @@ const TypePaliWidget = ({
   onArticleChange,
   onFinal,
   onLoad,
+  onTitle,
 }: IWidget) => {
   const [articleData, setArticleData] = useState<IArticleDataResponse>();
   const [articleHtml, setArticleHtml] = useState<string[]>(["<span />"]);
@@ -139,6 +141,10 @@ const TypePaliWidget = ({
           if (typeof onLoad !== "undefined") {
             onLoad(json.data);
           }
+          if (typeof onTitle !== "undefined") {
+            const bookTitle = json.data.path ? json.data.path[0].title : "";
+            onTitle(`${bookTitle}-${json.data.title}`);
+          }
         } else {
           message.error(json.message);
         }