);
@@ -208,6 +259,7 @@ class MediaTextEdit extends Component {
/> ) }
);
+ const editImageIcon = (
);
return (
@@ -222,6 +274,15 @@ class MediaTextEdit extends Component {
+
+ { mediaUrl && }
+
-
- (
-
- ) }
- />
-
-
- );
- }
-
renderImage() {
const { mediaAlt, mediaUrl, className, imageFill, focalPoint } = this.props;
const backgroundStyles = imageFill ? imageFillStyles( mediaUrl, focalPoint ) : {};
return (
- { this.renderToolbarEditButton() }
@@ -71,7 +47,6 @@ class MediaContainer extends Component {
const { mediaUrl, className } = this.props;
return (
- { this.renderToolbarEditButton() }
@@ -80,60 +55,85 @@ class MediaContainer extends Component {
}
renderPlaceholder() {
- const { onSelectMedia, className } = this.props;
+ const {
+ mediaUrl,
+ mediaId,
+ mediaType,
+ toggleIsEditing,
+ onSelectMedia,
+ onSelectUrl,
+ className,
+ } = this.props;
+
+ const labels = {
+ title: ! mediaUrl ? __( 'Media' ) : __( 'Edit media' ),
+ };
+
+ const mediaPreview = ( !! mediaUrl && );
+
return (
+
}
- labels={ {
- title: __( 'Media area' ),
- } }
className={ className }
+ labels={ labels }
onSelect={ onSelectMedia }
+ onSelectURL={ onSelectUrl }
+ onDoubleClick={ toggleIsEditing }
+ onCancel={ !! mediaUrl && toggleIsEditing }
+ onError={ this.onUploadError }
accept="image/*,video/*"
allowedTypes={ ALLOWED_MEDIA_TYPES }
+ value={ { mediaId, mediaUrl } }
+ mediaPreview={ mediaType === 'image' && mediaPreview }
/>
);
}
render() {
- const { mediaPosition, mediaUrl, mediaType, mediaWidth, commitWidthChange, onWidthChange } = this.props;
- if ( mediaType && mediaUrl ) {
- const onResize = ( event, direction, elt ) => {
- onWidthChange( parseInt( elt.style.width ) );
- };
- const onResizeStop = ( event, direction, elt ) => {
- commitWidthChange( parseInt( elt.style.width ) );
- };
- const enablePositions = {
- right: mediaPosition === 'left',
- left: mediaPosition === 'right',
- };
+ const { isEditing, mediaPosition, mediaType, mediaWidth, commitWidthChange, onWidthChange } = this.props;
+ if ( isEditing ) {
+ return this.renderPlaceholder();
+ }
+ const onResize = ( event, direction, elt ) => {
+ onWidthChange( parseInt( elt.style.width ) );
+ };
+ const onResizeStop = ( event, direction, elt ) => {
+ commitWidthChange( parseInt( elt.style.width ) );
+ };
+ const enablePositions = {
+ right: mediaPosition === 'left',
+ left: mediaPosition === 'right',
+ };
- let mediaElement = null;
- switch ( mediaType ) {
- case 'image':
- mediaElement = this.renderImage();
- break;
- case 'video':
- mediaElement = this.renderVideo();
- break;
- }
- return (
-
- { mediaElement }
-
- );
+ let mediaElement = null;
+ switch ( mediaType ) {
+ case 'image':
+ mediaElement = this.renderImage();
+ break;
+ case 'video':
+ mediaElement = this.renderVideo();
+ break;
}
- return this.renderPlaceholder();
+ return (
+
+ { mediaElement }
+
+ );
}
}
diff --git a/packages/block-library/src/video/edit.js b/packages/block-library/src/video/edit.js
index 35532afe073cc..a38de03ca1721 100644
--- a/packages/block-library/src/video/edit.js
+++ b/packages/block-library/src/video/edit.js
@@ -1,3 +1,8 @@
+/**
+ * External dependencies
+ */
+import classnames from 'classnames';
+
/**
* WordPress dependencies
*/
@@ -8,7 +13,10 @@ import {
Disabled,
IconButton,
PanelBody,
+ Path,
+ Rect,
SelectControl,
+ SVG,
ToggleControl,
Toolbar,
withNotices,
@@ -148,7 +156,7 @@ class VideoEdit extends Component {
} = this.props;
const { editing } = this.state;
const switchToEditing = () => {
- this.setState( { editing: true } );
+ this.setState( { editing: ! this.state.editing } );
};
const onSelectVideo = ( media ) => {
if ( ! media || ! media.url ) {
@@ -164,19 +172,35 @@ class VideoEdit extends Component {
this.setState( { src: media.url, editing: false } );
};
+ const editImageIcon = ( );
+
if ( editing ) {
return (
- }
- className={ className }
- onSelect={ onSelectVideo }
- onSelectURL={ this.onSelectURL }
- accept="video/*"
- allowedTypes={ ALLOWED_MEDIA_TYPES }
- value={ this.props.attributes }
- notices={ noticeUI }
- onError={ noticeOperations.createErrorNotice }
- />
+
+
+ { !! src && (
+
+ ) }
+
+ }
+ className={ className }
+ onSelect={ onSelectVideo }
+ onSelectURL={ this.onSelectURL }
+ onCancel={ !! src && switchToEditing }
+ accept="video/*"
+ allowedTypes={ ALLOWED_MEDIA_TYPES }
+ value={ this.props.attributes }
+ notices={ noticeUI }
+ onError={ noticeOperations.createErrorNotice }
+ />
+
);
}
const videoPosterDescription = `video-block__poster-image-description-${ instanceId }`;
@@ -190,7 +214,7 @@ class VideoEdit extends Component {
className="components-icon-button components-toolbar__control"
label={ __( 'Edit video' ) }
onClick={ switchToEditing }
- icon="edit"
+ icon={ editImageIcon }
/>
diff --git a/packages/components/src/placeholder/style.scss b/packages/components/src/placeholder/style.scss
index 63938e69498e9..839c047bbc838 100644
--- a/packages/components/src/placeholder/style.scss
+++ b/packages/components/src/placeholder/style.scss
@@ -30,6 +30,7 @@
justify-content: center;
font-weight: 600;
margin-bottom: 1em;
+ margin-top: 1em;
.dashicon,
.block-editor-block-icon {