Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move editorMediaUpload to the editor module #6682

Merged
merged 1 commit into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@youknowriad - did you update this comment above in the PR where you migrate blocks to store? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha :) comment posted on the wrong PR

export { default as editorMediaUpload } from './editor-media-upload';
2 changes: 1 addition & 1 deletion core-blocks/audio/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
2 changes: 1 addition & 1 deletion core-blocks/gallery/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
7 changes: 2 additions & 5 deletions core-blocks/gallery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core-blocks/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
Toolbar,
} from '@wordpress/components';
import { withSelect } from '@wordpress/data';
import { editorMediaUpload } from '@wordpress/blocks';
import {
RichText,
BlockControls,
Expand All @@ -37,6 +36,7 @@ import {
MediaUpload,
BlockAlignmentToolbar,
UrlInputButton,
editorMediaUpload,
} from '@wordpress/editor';

/**
Expand Down
2 changes: 1 addition & 1 deletion core-blocks/video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
3 changes: 2 additions & 1 deletion editor/components/image-placeholder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
2 changes: 2 additions & 0 deletions editor/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
getColorName,
withColors,
} from './components';
import { editorMediaUpload } from './utils';

const componentsToDepreacate = {
Autocomplete,
Expand Down Expand Up @@ -63,6 +64,7 @@ const functionsToDeprecate = {
getColorClass,
getColorName,
withColors,
editorMediaUpload,
};

forEach( componentsToDepreacate, ( WrappedComponent, key ) => {
Expand Down
1 change: 1 addition & 0 deletions editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ import './store';
import './hooks';

export * from './components';
export * from './utils';
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finally :)

mediaUpload( filesList, onFileChange, allowedType, {
post: postId,
} );
Expand Down
1 change: 1 addition & 0 deletions editor/utils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as editorMediaUpload } from './editor-media-upload';