EmbedBlock.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import PropTypes from 'prop-types';
  2. import React from 'react';
  3. import { STRINGS } from '../../../config/wagtailConfig';
  4. import MediaBlock from '../blocks/MediaBlock';
  5. /**
  6. * Editor block to display media and edit content.
  7. */
  8. const EmbedBlock = props => {
  9. const { entity, onEditEntity, onRemoveEntity } = props.blockProps;
  10. const { url, title, thumbnail } = entity.getData();
  11. return (
  12. <MediaBlock {...props} src={thumbnail} alt="">
  13. {url ? (
  14. <a
  15. className="Tooltip__link EmbedBlock__link"
  16. href={url}
  17. title={url}
  18. target="_blank"
  19. rel="noopener noreferrer"
  20. >
  21. {title}
  22. </a>
  23. ) : null}
  24. <button className="button Tooltip__button" type="button" onClick={onEditEntity}>
  25. {STRINGS.EDIT}
  26. </button>
  27. <button className="button button-secondary no Tooltip__button" onClick={onRemoveEntity}>
  28. {STRINGS.DELETE}
  29. </button>
  30. </MediaBlock>
  31. );
  32. };
  33. EmbedBlock.propTypes = {
  34. blockProps: PropTypes.shape({
  35. entity: PropTypes.object,
  36. }).isRequired,
  37. };
  38. export default EmbedBlock;