import * as React from 'react'; import { ReactNode } from 'react'; import { styled } from '@mui/material/styles'; import { AlignmentButtons, ClearButtons, FormatButtons, LevelSelect, ListButtons, LinkButtons, QuoteButtons, ImageButtons, ColorButtons, } from './buttons'; /** * A toolbar for the . * @param props The toolbar props. * @param {ReactNode} props.children The toolbar children, usually many . * @param {'small' | 'medium' | 'large'} props.size The default size to apply to the **default** children. * * @example Customizing the size * import { RichTextInput, RichTextInputToolbar } from 'ra-input-rich-text'; * const MyRichTextInput = (props) => ( * } * label="Body" * source="body" * {...props} * /> * ); * * @example Customizing the children * import { RichTextInput, RichTextInputToolbar } from 'ra-input-rich-text'; * const MyRichTextInput = ({ size, ...props }) => ( * * * * * * * * * * * )} * label="Body" * source="body" * {...props} * /> * ); */ export const RichTextInputToolbar = (props: RichTextInputToolbarProps) => { const { size = 'medium', children = ( <> ), ...rest } = props; return ( {children} ); }; const PREFIX = 'RaRichTextInputToolbar'; const classes = { root: `${PREFIX}-root`, }; const Root = styled('div')(({ theme }) => ({ [`&.${classes.root}`]: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', '& > *': { marginRight: theme.spacing(1), marginBottom: theme.spacing(1), }, '& > *:last-child': { marginRight: 0, }, '& button.MuiToggleButton-sizeSmall': { padding: theme.spacing(0.3), fontSize: theme.typography.pxToRem(18), }, '& button.MuiToggleButton-sizeMedium': { padding: theme.spacing(0.5), fontSize: theme.typography.pxToRem(24), }, '& button.MuiToggleButton-sizeLarge': { padding: theme.spacing(1), fontSize: theme.typography.pxToRem(24), }, }, })); export type RichTextInputToolbarProps = { children?: ReactNode; size?: 'small' | 'medium' | 'large'; };