Browse Source

add onTitle

visuddhinanda 2 years ago
parent
commit
384427fbfc
1 changed files with 6 additions and 0 deletions
  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);
         }