import React from 'react'; import PropTypes from 'prop-types'; import {MediaBlock} from './media'; import {EmbedBlock} from './embeds'; import {TableBlock} from './tables'; import {ContentBlock} from 'draft-js'; import {DragableEditor3Block} from './media/dragable-editor3-block'; const BlockRendererComponent: React.StatelessComponent = (props) => { const {block, contentState} = props; const entityKey = block.getEntityAt(0); if (!entityKey) { return null; } const type = contentState.getEntity(entityKey).getType(); function getComponent() { if (type === 'MEDIA') { return ; } else if (type === 'EMBED') { return ; } else if (type === 'TABLE') { return ; } else { return null; } } const component = getComponent(); if (component == null) { return null; } else { return ( {component} ); } }; BlockRendererComponent.propTypes = { block: PropTypes.object.isRequired, contentState: PropTypes.object.isRequired, }; export function blockRenderer(contentBlock: ContentBlock) { return contentBlock.getType() !== 'atomic' ? null : { component: BlockRendererComponent, editable: false, }; }