diff --git a/packages/block-library/src/media-text/deprecated.js b/packages/block-library/src/media-text/deprecated.js index ab36e6859b3e8..2123e259a97fa 100644 --- a/packages/block-library/src/media-text/deprecated.js +++ b/packages/block-library/src/media-text/deprecated.js @@ -12,10 +12,7 @@ import { getColorClassName, } from '@wordpress/block-editor'; -/** - * Internal dependencies - */ -import { DEFAULT_MEDIA_WIDTH } from './index'; +const DEFAULT_MEDIA_WIDTH = 50; export default [ { diff --git a/packages/block-library/src/media-text/index.js b/packages/block-library/src/media-text/index.js index 781b7e60b52cf..b20dc9693bafa 100644 --- a/packages/block-library/src/media-text/index.js +++ b/packages/block-library/src/media-text/index.js @@ -1,29 +1,17 @@ -/** - * External dependencies - */ -import classnames from 'classnames'; -import { noop } from 'lodash'; - /** * WordPress dependencies */ -import { createBlock } from '@wordpress/blocks'; -import { - InnerBlocks, - getColorClassName, -} from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ +import deprecated from './deprecated'; import edit from './edit'; import icon from './icon'; -import deprecated from './deprecated'; -import { imageFillStyles } from './media-container'; import metadata from './block.json'; - -export const DEFAULT_MEDIA_WIDTH = 50; +import save from './save'; +import transforms from './transforms'; const { name } = metadata; @@ -31,125 +19,15 @@ export { metadata, name }; export const settings = { title: __( 'Media & Text' ), - description: __( 'Set media and words side-by-side for a richer layout.' ), - icon, - keywords: [ __( 'image' ), __( 'video' ) ], - supports: { align: [ 'wide', 'full' ], html: false, }, - - transforms: { - from: [ - { - type: 'block', - blocks: [ 'core/image' ], - transform: ( { alt, url, id } ) => ( - createBlock( 'core/media-text', { - mediaAlt: alt, - mediaId: id, - mediaUrl: url, - mediaType: 'image', - } ) - ), - }, - { - type: 'block', - blocks: [ 'core/video' ], - transform: ( { src, id } ) => ( - createBlock( 'core/media-text', { - mediaId: id, - mediaUrl: src, - mediaType: 'video', - } ) - ), - }, - ], - to: [ - { - type: 'block', - blocks: [ 'core/image' ], - isMatch: ( { mediaType, mediaUrl } ) => { - return ! mediaUrl || mediaType === 'image'; - }, - transform: ( { mediaAlt, mediaId, mediaUrl } ) => { - return createBlock( 'core/image', { - alt: mediaAlt, - id: mediaId, - url: mediaUrl, - } ); - }, - }, - { - type: 'block', - blocks: [ 'core/video' ], - isMatch: ( { mediaType, mediaUrl } ) => { - return ! mediaUrl || mediaType === 'video'; - }, - transform: ( { mediaId, mediaUrl } ) => { - return createBlock( 'core/video', { - id: mediaId, - src: mediaUrl, - } ); - }, - }, - ], - }, - + transforms, edit, - - save( { attributes } ) { - const { - backgroundColor, - customBackgroundColor, - isStackedOnMobile, - mediaAlt, - mediaPosition, - mediaType, - mediaUrl, - mediaWidth, - mediaId, - verticalAlignment, - imageFill, - focalPoint, - } = attributes; - const mediaTypeRenders = { - image: () => {, - video: () =>