contenido
Version:
Contenido is a library with a set of tools to help you create your own rich text editor on top of draft-js without thinking about how to handle things.
24 lines (18 loc) • 567 B
text/typescript
// Types
import type { ContentBlock } from 'draft-js';
// Custom Utilities
import initialBlockStyles from './initialBlockStyle';
const blockStyleFn = (
block: ContentBlock,
customBlockStyles?: { [key: string]: string }[]
) => {
const blockType = block.getType();
let blockStyles = initialBlockStyles;
if (customBlockStyles && customBlockStyles?.length > 0) {
customBlockStyles.forEach(
(blockStyle) => (blockStyles = { ...blockStyles, ...blockStyle })
);
}
return blockStyles[blockType || 'unstyled'];
};
export default blockStyleFn;