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

RichTextLeaf.js 694B

12345678910111213141516171819202122232425262728293031
  1. import React from "react";
  2. import PropTypes from "prop-types";
  3. const RichTextLeaf = ({ attributes, children, leaf }) => {
  4. if (leaf.bold) {
  5. children = <strong>{children}</strong>;
  6. }
  7. if (leaf.code) {
  8. children = <code>{children}</code>;
  9. }
  10. if (leaf.italic) {
  11. children = <i>{children}</i>;
  12. }
  13. if (leaf.underline) {
  14. children = <u>{children}</u>;
  15. }
  16. if (leaf.color) {
  17. children = <span style={{ color: leaf.color }}>{children}</span>;
  18. }
  19. return <span {...attributes}>{children}</span>;
  20. };
  21. RichTextLeaf.propTypes = {
  22. attributes: PropTypes.any,
  23. children: PropTypes.any,
  24. leaf: PropTypes.any,
  25. selectedColor: PropTypes.any,
  26. };
  27. export default RichTextLeaf;