diff --git a/packages/block-library/src/cover/index.js b/packages/block-library/src/cover/index.js index 8a8808327ec97b..8dff936dc440d1 100644 --- a/packages/block-library/src/cover/index.js +++ b/packages/block-library/src/cover/index.js @@ -26,6 +26,7 @@ import { BlockAlignmentToolbar, MediaPlaceholder, MediaUpload, + MediaUploadCheck, AlignmentToolbar, PanelColorSettings, RichText, @@ -259,21 +260,23 @@ export const settings = { setAttributes( { contentAlign: nextAlign } ); } } /> - - ( - - ) } - /> - + + + ( + + ) } + /> + + ) } diff --git a/packages/block-library/src/file/edit.js b/packages/block-library/src/file/edit.js index 5d1dc30cf9e365..eb311fb48a73a9 100644 --- a/packages/block-library/src/file/edit.js +++ b/packages/block-library/src/file/edit.js @@ -19,6 +19,7 @@ import { Component, Fragment } from '@wordpress/element'; import { MediaUpload, MediaPlaceholder, + MediaUploadCheck, BlockControls, RichText, mediaUpload, @@ -165,20 +166,22 @@ class FileEdit extends Component { } } /> - - ( - - ) } - /> - + + + ( + + ) } + /> + +
diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index 7a2c77298918f6..f7dd63a22db4ac 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -39,6 +39,7 @@ import { InspectorControls, MediaPlaceholder, MediaUpload, + MediaUploadCheck, BlockAlignmentToolbar, mediaUpload, } from '@wordpress/editor'; @@ -328,21 +329,23 @@ class ImageEdit extends Component { ); } else { toolbarEditButton = ( - - ( - - ) } - /> - + + + ( + + ) } + /> + + ); } } diff --git a/packages/block-library/src/video/edit.js b/packages/block-library/src/video/edit.js index 26039e79c85c3a..118bd117606685 100644 --- a/packages/block-library/src/video/edit.js +++ b/packages/block-library/src/video/edit.js @@ -19,6 +19,7 @@ import { InspectorControls, MediaPlaceholder, MediaUpload, + MediaUploadCheck, RichText, mediaUpload, } from '@wordpress/editor'; @@ -207,30 +208,32 @@ class VideoEdit extends Component { { value: 'none', label: __( 'None' ) }, ] } /> - - ( - + ) } + /> + { !! this.props.attributes.poster && + - ) } - /> - { !! this.props.attributes.poster && - - } - + } + +
diff --git a/packages/editor/src/components/block-drop-zone/index.js b/packages/editor/src/components/block-drop-zone/index.js index 3af8b0cff3a6f7..3e9c0db427e58a 100644 --- a/packages/editor/src/components/block-drop-zone/index.js +++ b/packages/editor/src/components/block-drop-zone/index.js @@ -19,6 +19,11 @@ import { Component } from '@wordpress/element'; import { withDispatch, withSelect } from '@wordpress/data'; import { compose } from '@wordpress/compose'; +/** + * Internal dependencies + */ +import MediaUploadCheck from '../media-upload/check'; + const parseDropEvent = ( event ) => { let result = { srcRootClientId: null, @@ -111,14 +116,16 @@ class BlockDropZone extends Component { const isAppender = index === undefined; return ( - + + + ); } } diff --git a/packages/editor/src/components/media-upload/README.md b/packages/editor/src/components/media-upload/README.md index ae670b227ea925..1dc11cb2a37ed3 100644 --- a/packages/editor/src/components/media-upload/README.md +++ b/packages/editor/src/components/media-upload/README.md @@ -24,25 +24,28 @@ You can check how this component is implemented for the edit post page using `wp ## Usage +To make sure the current user has Upload permissions, you need to wrap the MediaUpload component into the MediaUploadCheck one. ```jsx import { Button } from '@wordpress/components'; -import { MediaUpload } from '@wordpress/editor'; +import { MediaUpload, MediaUploadCheck } from '@wordpress/editor'; const ALLOWED_MEDIA_TYPES = [ 'audio' ]; function MyMediaUploader() { return ( - console.log( 'selected ' + media.length ) } - allowedTypes={ ALLOWED_MEDIA_TYPES } - value={ mediaId } - render={ ( { open } ) => ( - - ) } - /> + + console.log( 'selected ' + media.length ) } + allowedTypes={ ALLOWED_MEDIA_TYPES } + value={ mediaId } + render={ ( { open } ) => ( + + ) } + /> + ); } ```