Iframe.js
7 years ago
core-embeds.js
7 years ago
embed-controls.js
6 years ago
embed-loading.js
7 years ago
embed-placeholder.js
6 years ago
icons.js
6 years ago
embed-placeholder.js
50 lines
| 1 | /** |
| 2 | * WordPress dependencies |
| 3 | */ |
| 4 | const {__, _x} = wp.i18n; |
| 5 | import classnames from 'classnames'; |
| 6 | const {Button, Placeholder, ExternalLink} = wp.components; |
| 7 | const {BlockIcon} = wp.blockEditor; |
| 8 | |
| 9 | const EmbedPlaceholder = (props) => { |
| 10 | const {icon, label, value, onSubmit, onChange, cannotEmbed, docLink, DocTitle} = props; |
| 11 | const classes = classnames( 'wp-block-embed', {} ); |
| 12 | return ( |
| 13 | <div> |
| 14 | <Placeholder icon={<BlockIcon icon={icon} showColors/>} label={label} className={classes}> |
| 15 | |
| 16 | <form onSubmit={onSubmit}> |
| 17 | <input |
| 18 | type="url" |
| 19 | value={value || ''} |
| 20 | className="components-placeholder__input" |
| 21 | aria-label={label} |
| 22 | placeholder={__('Enter URL to embed here…')} |
| 23 | onChange={onChange}/> |
| 24 | <Button |
| 25 | isLarge |
| 26 | type="submit"> |
| 27 | {_x('Embed', 'button label')} |
| 28 | </Button> |
| 29 | |
| 30 | {cannotEmbed && |
| 31 | <p className="components-placeholder__error"> |
| 32 | {__('Sorry, we could not embed that content.')}<br/> |
| 33 | </p> |
| 34 | } |
| 35 | |
| 36 | </form> |
| 37 | {docLink && |
| 38 | <div className="components-placeholder__learn-more"> |
| 39 | <ExternalLink href={docLink}>{DocTitle}</ExternalLink> |
| 40 | </div> |
| 41 | } |
| 42 | |
| 43 | </Placeholder> |
| 44 | </div> |
| 45 | |
| 46 | ); |
| 47 | }; |
| 48 | |
| 49 | export default EmbedPlaceholder; |
| 50 |