diff --git a/blocks/index.js b/blocks/index.js index 57c6df6c1a83e1..2a98ad9c6a0df5 100644 --- a/blocks/index.js +++ b/blocks/index.js @@ -8,5 +8,3 @@ // Blocks are inferred from the HTML source of a post through a parsing mechanism // and then stored as objects in state, from which it is then rendered for editing. export * from './api'; - -export { default as editorMediaUpload } from './editor-media-upload'; diff --git a/core-blocks/audio/edit.js b/core-blocks/audio/edit.js index 5db78844da3490..758539d04c400b 100644 --- a/core-blocks/audio/edit.js +++ b/core-blocks/audio/edit.js @@ -10,11 +10,11 @@ import { Toolbar, } from '@wordpress/components'; import { Component, Fragment } from '@wordpress/element'; -import { editorMediaUpload } from '@wordpress/blocks'; import { MediaUpload, RichText, BlockControls, + editorMediaUpload, } from '@wordpress/editor'; /** diff --git a/core-blocks/gallery/edit.js b/core-blocks/gallery/edit.js index 5f9db010ca2402..31f6d5827c7773 100644 --- a/core-blocks/gallery/edit.js +++ b/core-blocks/gallery/edit.js @@ -18,13 +18,13 @@ import { ToggleControl, Toolbar, } from '@wordpress/components'; -import { editorMediaUpload } from '@wordpress/blocks'; import { BlockControls, BlockAlignmentToolbar, MediaUpload, ImagePlaceholder, InspectorControls, + editorMediaUpload, } from '@wordpress/editor'; /** diff --git a/core-blocks/gallery/index.js b/core-blocks/gallery/index.js index 3321d94972df20..d791771fbff566 100644 --- a/core-blocks/gallery/index.js +++ b/core-blocks/gallery/index.js @@ -7,11 +7,8 @@ import { filter, every } from 'lodash'; * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { - createBlock, - editorMediaUpload, -} from '@wordpress/blocks'; -import { RichText } from '@wordpress/editor'; +import { createBlock } from '@wordpress/blocks'; +import { RichText, editorMediaUpload } from '@wordpress/editor'; /** * Internal dependencies diff --git a/core-blocks/image/edit.js b/core-blocks/image/edit.js index f4af5401d7f6cf..02a6d1dfa5ee09 100644 --- a/core-blocks/image/edit.js +++ b/core-blocks/image/edit.js @@ -28,7 +28,6 @@ import { Toolbar, } from '@wordpress/components'; import { withSelect } from '@wordpress/data'; -import { editorMediaUpload } from '@wordpress/blocks'; import { RichText, BlockControls, @@ -37,6 +36,7 @@ import { MediaUpload, BlockAlignmentToolbar, UrlInputButton, + editorMediaUpload, } from '@wordpress/editor'; /** diff --git a/core-blocks/video/index.js b/core-blocks/video/index.js index b0e1fb20d6e56e..891ac72c6737d2 100644 --- a/core-blocks/video/index.js +++ b/core-blocks/video/index.js @@ -14,12 +14,12 @@ import { Toolbar, } from '@wordpress/components'; import { Component, Fragment } from '@wordpress/element'; -import { editorMediaUpload } from '@wordpress/blocks'; import { BlockAlignmentToolbar, BlockControls, MediaUpload, RichText, + editorMediaUpload, } from '@wordpress/editor'; /** diff --git a/editor/components/image-placeholder/index.js b/editor/components/image-placeholder/index.js index e7b33dfb65e489..0dde498cc89c28 100644 --- a/editor/components/image-placeholder/index.js +++ b/editor/components/image-placeholder/index.js @@ -8,11 +8,12 @@ import { map } from 'lodash'; */ import { DropZone, FormFileUpload, Placeholder, Button } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; -import { editorMediaUpload, rawHandler } from '@wordpress/blocks'; +import { rawHandler } from '@wordpress/blocks'; /** * Internal dependencies */ +import { editorMediaUpload } from '../../utils'; import MediaUpload from '../media-upload'; /** diff --git a/editor/deprecated.js b/editor/deprecated.js index 97ec99bcacb9a5..f1e130c825cbde 100644 --- a/editor/deprecated.js +++ b/editor/deprecated.js @@ -35,6 +35,7 @@ import { getColorName, withColors, } from './components'; +import { editorMediaUpload } from './utils'; const componentsToDepreacate = { Autocomplete, @@ -63,6 +64,7 @@ const functionsToDeprecate = { getColorClass, getColorName, withColors, + editorMediaUpload, }; forEach( componentsToDepreacate, ( WrappedComponent, key ) => { diff --git a/editor/index.js b/editor/index.js index ed8e1be7dd2ce7..7a1538bcc1c7b4 100644 --- a/editor/index.js +++ b/editor/index.js @@ -3,3 +3,4 @@ import './store'; import './hooks'; export * from './components'; +export * from './utils'; diff --git a/blocks/editor-media-upload/index.js b/editor/utils/editor-media-upload/index.js similarity index 81% rename from blocks/editor-media-upload/index.js rename to editor/utils/editor-media-upload/index.js index e8da4ecb305b6a..0fc879da6e90a8 100644 --- a/blocks/editor-media-upload/index.js +++ b/editor/utils/editor-media-upload/index.js @@ -13,11 +13,7 @@ import { mediaUpload } from '@wordpress/utils'; * @param {string} allowedType The type of media that can be uploaded. */ export default function editorMediaUpload( filesList, onFileChange, allowedType ) { - let postId = null; - // Editor isn't guaranteed in block context. - if ( select( 'core/editor' ) ) { - postId = select( 'core/editor' ).getCurrentPostId(); - } + const postId = select( 'core/editor' ).getCurrentPostId(); mediaUpload( filesList, onFileChange, allowedType, { post: postId, } ); diff --git a/editor/utils/index.js b/editor/utils/index.js new file mode 100644 index 00000000000000..b1f9d6a838063e --- /dev/null +++ b/editor/utils/index.js @@ -0,0 +1 @@ +export { default as editorMediaUpload } from './editor-media-upload';