ParaLink.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { ArticleCtl, type TDisplayStyle } from "./Article"
  2. import { csParaMap } from "./cs_para_map";
  3. interface IWidgetParaLinkCtl {
  4. title?: string;
  5. bookName?: string | null;
  6. paragraphs?: string | null;
  7. style?: TDisplayStyle;
  8. book?: number;
  9. para?: number;
  10. }
  11. export const ParaLinkCtl = ({
  12. title,
  13. bookName,
  14. paragraphs,
  15. style = "modal",
  16. book,
  17. para,
  18. }: IWidgetParaLinkCtl) => {
  19. const bookPara = csParaMap.find((value) => value.name === bookName);
  20. return (
  21. <>
  22. {bookPara ? (
  23. <ArticleCtl
  24. title={title}
  25. type={"cs-para"}
  26. focus={book && para ? `${book}-${para}` : undefined}
  27. id={`${bookPara?.book}_${bookPara?.para}_${paragraphs}`}
  28. style={style}
  29. />
  30. ) : (
  31. <>{title}</>
  32. )}
  33. </>
  34. );
  35. };
  36. interface IWidget {
  37. props: string;
  38. }
  39. const Widget = ({ props }: IWidget) => {
  40. const prop = JSON.parse(atob(props)) as IWidgetParaLinkCtl;
  41. console.log(prop);
  42. return (
  43. <>
  44. <ParaLinkCtl {...prop} />
  45. </>
  46. );
  47. };
  48. export default Widget;