Skip to content

Commit

Permalink
Move transform styles function to blockEditor package. (#15572)
Browse files Browse the repository at this point in the history
This commit moves the transform styles function to blockEditor package so they can safely be used by the blocks.
  • Loading branch information
jorgefilipecosta authored May 28, 2019
1 parent b14d70c commit bb24bbe
Show file tree
Hide file tree
Showing 21 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/block-editor/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ import './store';
import './hooks';

export * from './components';
export * from './utils';

export { SETTINGS_DEFAULTS } from './store/defaults';
4 changes: 4 additions & 0 deletions packages/block-editor/src/utils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Internal dependencies
*/
export { default as __experimentalTransformStyles } from './transform-styles';
File renamed without changes.
9 changes: 6 additions & 3 deletions packages/block-library/src/html/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
*/
import { __ } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
import { BlockControls, PlainText } from '@wordpress/block-editor';
import { transformStyles } from '@wordpress/editor';
import {
BlockControls,
PlainText,
__experimentalTransformStyles,
} from '@wordpress/block-editor';
import { Disabled, SandBox } from '@wordpress/components';
import { withSelect } from '@wordpress/data';

Expand Down Expand Up @@ -35,7 +38,7 @@ class HTMLEdit extends Component {

this.setState( { styles: [
defaultStyles,
...transformStyles( styles ),
...__experimentalTransformStyles( styles ),
] } );
}

Expand Down
5 changes: 2 additions & 3 deletions packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import { compose } from '@wordpress/compose';
import { Component } from '@wordpress/element';
import { withDispatch, withSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { BlockEditorProvider } from '@wordpress/block-editor';
import { BlockEditorProvider, __experimentalTransformStyles } from '@wordpress/block-editor';
import apiFetch from '@wordpress/api-fetch';
import { addQueryArgs } from '@wordpress/url';
import { decodeEntities } from '@wordpress/html-entities';

/**
* Internal dependencies
*/
import transformStyles from '../../editor-styles';
import { mediaUpload } from '../../utils';
import ReusableBlocksButtons from '../reusable-blocks-buttons';

Expand Down Expand Up @@ -111,7 +110,7 @@ class EditorProvider extends Component {
return;
}

const updatedStyles = transformStyles( this.props.settings.styles, '.editor-styles-wrapper' );
const updatedStyles = __experimentalTransformStyles( this.props.settings.styles, '.editor-styles-wrapper' );

map( updatedStyles, ( updatedCSS ) => {
if ( updatedCSS ) {
Expand Down
6 changes: 5 additions & 1 deletion packages/editor/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ import './hooks';

export * from './components';
export * from './utils';
export { default as transformStyles } from './editor-styles';

/*
* Backward compatibility
*/
export { __experimentalTransformStyles as transformStyles } from '@wordpress/block-editor';

0 comments on commit bb24bbe

Please sign in to comment.