| 12345678910111213141516171819202122232425262728293031 |
- import React from "react";
- import PropTypes from "prop-types";
- const RichTextLeaf = ({ attributes, children, leaf }) => {
- if (leaf.bold) {
- children = <strong>{children}</strong>;
- }
-
- if (leaf.code) {
- children = <code>{children}</code>;
- }
-
- if (leaf.italic) {
- children = <i>{children}</i>;
- }
-
- if (leaf.underline) {
- children = <u>{children}</u>;
- }
- if (leaf.color) {
- children = <span style={{ color: leaf.color }}>{children}</span>;
- }
- return <span {...attributes}>{children}</span>;
- };
-
- RichTextLeaf.propTypes = {
- attributes: PropTypes.any,
- children: PropTypes.any,
- leaf: PropTypes.any,
- selectedColor: PropTypes.any,
- };
- export default RichTextLeaf;
|