MdTpl.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import Confidence from "./Confidence";
  2. import GrammarTermLookup from "./GrammarTermLookup";
  3. import Mermaid from "./Mermaid";
  4. import Nissaya from "./Nissaya";
  5. import Note from "./Note";
  6. import ParaHandle from "./ParaHandle";
  7. import ParaShell from "./ParaShell";
  8. import Paragraph from "./Paragraph";
  9. import Quote from "./Quote";
  10. import Reference from "./Reference";
  11. import SentEdit from "./SentEdit";
  12. import SentRead from "./SentRead";
  13. import Term from "./Term";
  14. import Toggle from "./Toggle";
  15. import Tpl from "./Tpl";
  16. import Video from "./Video";
  17. import WbwSent from "./WbwSent";
  18. import Wd from "./Wd";
  19. interface IWidgetMdTpl {
  20. tpl?: string;
  21. props?: string;
  22. children?: React.ReactNode | React.ReactNode[];
  23. }
  24. const Widget = ({ tpl, props, children }: IWidgetMdTpl) => {
  25. switch (tpl) {
  26. case "term":
  27. return <Term props={props ? props : ""} />;
  28. case "note":
  29. return <Note props={props ? props : ""}>{children}</Note>;
  30. case "sentread":
  31. return <SentRead props={props ? props : ""} />;
  32. case "sentedit":
  33. return <SentEdit props={props ? props : ""} />;
  34. case "wbw_sent":
  35. return <WbwSent props={props ? props : ""} />;
  36. case "wd":
  37. return <Wd props={props ? props : ""} />;
  38. case "quote":
  39. return <Quote props={props ? props : ""} />;
  40. case "nissaya":
  41. return <Nissaya props={props ? props : ""}>{children}</Nissaya>;
  42. case "toggle":
  43. return <Toggle props={props ? props : undefined}>{children}</Toggle>;
  44. case "para":
  45. return <ParaHandle props={props ? props : ""} />;
  46. case "mermaid":
  47. return <Mermaid props={props ? props : ""} />;
  48. case "para-shell":
  49. return <ParaShell props={props ? props : ""}>{children}</ParaShell>;
  50. case "video":
  51. return <Video props={props ? props : ""} />;
  52. case "grammar":
  53. return <GrammarTermLookup props={props ? props : ""} />;
  54. case "reference":
  55. return <Reference props={props ? props : ""} />;
  56. case "cf":
  57. return <Confidence props={props ? props : ""} />;
  58. case "paragraph":
  59. return <Paragraph props={props ? props : ""} />;
  60. case "tpl":
  61. return <Tpl props={props ? props : ""} />;
  62. default:
  63. return <>未定义模版({tpl})</>;
  64. }
  65. };
  66. export default Widget;