MdTpl.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { GrammarPopShell } from "../dict/GrammarPop";
  2. import Ai from "./Ai";
  3. import Article from "./Article";
  4. import Confidence from "./Confidence";
  5. import DictPreferenceEditor from "./DictPreferenceEditor";
  6. import Exercise from "./Exercise";
  7. import GrammarTermLookup from "./GrammarTermLookup";
  8. import Mermaid from "./Mermaid";
  9. import Nissaya from "./Nissaya";
  10. import Note from "./Note";
  11. import ParaHandle from "./ParaHandle";
  12. import ParaShell from "./ParaShell";
  13. import Qa from "./Qa";
  14. import Quote from "./Quote";
  15. import QuoteLink from "./QuoteLink";
  16. import Reference from "./Reference";
  17. import SentEdit from "./SentEdit";
  18. import SentRead from "./SentRead";
  19. import Term from "./Term";
  20. import Toggle from "./Toggle";
  21. import Video from "./Video";
  22. import WbwSent from "./WbwSent";
  23. import Wd from "./Wd";
  24. interface IWidgetMdTpl {
  25. tpl?: string;
  26. props?: string;
  27. children?: React.ReactNode | React.ReactNode[];
  28. }
  29. const Widget = ({ tpl, props, children }: IWidgetMdTpl) => {
  30. switch (tpl) {
  31. case "term":
  32. return <Term props={props ? props : ""} />;
  33. case "note":
  34. return <Note props={props ? props : ""}>{children}</Note>;
  35. case "sentread":
  36. return <SentRead props={props ? props : ""} />;
  37. case "sentedit":
  38. return <SentEdit props={props ? props : ""} />;
  39. case "wbw_sent":
  40. return <WbwSent props={props ? props : ""} />;
  41. case "wd":
  42. return <Wd props={props ? props : ""} />;
  43. case "quote":
  44. return <Quote props={props ? props : ""} />;
  45. case "exercise":
  46. return <Exercise props={props ? props : ""}>{children}</Exercise>;
  47. case "article":
  48. return <Article props={props ? props : ""} />;
  49. case "nissaya":
  50. return <Nissaya props={props ? props : ""}>{children}</Nissaya>;
  51. case "toggle":
  52. return <Toggle props={props ? props : undefined}>{children}</Toggle>;
  53. case "para":
  54. return <ParaHandle props={props ? props : ""} />;
  55. case "mermaid":
  56. return <Mermaid props={props ? props : ""} />;
  57. case "grammar-pop":
  58. return <GrammarPopShell props={props ? props : ""} />;
  59. case "quote-link":
  60. return <QuoteLink props={props ? props : ""} />;
  61. case "para-shell":
  62. return <ParaShell props={props ? props : ""}>{children}</ParaShell>;
  63. case "qa":
  64. return <Qa props={props ? props : ""} />;
  65. case "video":
  66. return <Video props={props ? props : ""} />;
  67. case "grammar":
  68. return <GrammarTermLookup props={props ? props : ""} />;
  69. case "reference":
  70. return <Reference props={props ? props : ""} />;
  71. case "dict-pref":
  72. return props ? <DictPreferenceEditor props={props} /> : <>无效的参数</>;
  73. case "ai":
  74. return <Ai props={props ? props : ""} />;
  75. case "cf":
  76. return <Confidence props={props ? props : ""} />;
  77. default:
  78. return <>未定义模版({tpl})</>;
  79. }
  80. };
  81. export default Widget;