Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

RichTextElement.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import React from "react";
  2. import PropTypes from "prop-types";
  3. import { ListContainer } from "./RichTextElement.styled";
  4. import selectedTheme from "../../../themes";
  5. const RichTextElement = ({ attributes, children, element }) => {
  6. const style = { textAlign: element.align };
  7. switch (element.type) {
  8. case "block-quote":
  9. return (
  10. <blockquote style={style} {...attributes}>
  11. {children}
  12. </blockquote>
  13. );
  14. case "bulleted-list":
  15. return (
  16. <ListContainer style={style} {...attributes}>
  17. {children}
  18. </ListContainer>
  19. );
  20. case "link":
  21. return (
  22. <a href="" style={style} {...attributes}>
  23. {children}
  24. </a>
  25. );
  26. case "heading-one":
  27. return (
  28. <h1 style={style} {...attributes}>
  29. {children}
  30. </h1>
  31. );
  32. case "heading-two":
  33. return (
  34. <h2 style={style} {...attributes}>
  35. {children}
  36. </h2>
  37. );
  38. case "list-item":
  39. return (
  40. <li style={style} {...attributes}>
  41. {children}
  42. </li>
  43. );
  44. case "numbered-list":
  45. return (
  46. <ol style={style} {...attributes}>
  47. {children}
  48. </ol>
  49. );
  50. default:
  51. return (
  52. <div
  53. style={style}
  54. {...attributes}
  55. color={selectedTheme.colors.colorPicker.darkGray}
  56. >
  57. {children}
  58. </div>
  59. );
  60. }
  61. };
  62. RichTextElement.propTypes = {
  63. attributes: PropTypes.any,
  64. children: PropTypes.any,
  65. element: PropTypes.any,
  66. };
  67. export default RichTextElement;