Skip to content

Commit

Permalink
Core blocks: Refactor blocks to use edit file - part 2 (#6641)
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo authored May 9, 2018
1 parent 39b420f commit 823dcf2
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { Component } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { keycodes } from '@wordpress/utils';

/**
* Internal dependencies
*/
import './editor.scss';

const { BACKSPACE, DELETE, F10 } = keycodes;

function isTmceEmpty( editor ) {
Expand All @@ -23,7 +28,7 @@ function isTmceEmpty( editor ) {
return /^\n?$/.test( body.innerText || body.textContent );
}

export default class OldEditor extends Component {
export default class FreeformEdit extends Component {
constructor( props ) {
super( props );
this.initialize = this.initialize.bind( this );
Expand Down
5 changes: 2 additions & 3 deletions core-blocks/freeform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import './editor.scss';
import OldEditor from './old-editor';
import edit from './edit';

export const name = 'core/freeform';

Expand All @@ -33,7 +32,7 @@ export const settings = {
customClassName: false,
},

edit: OldEditor,
edit,

save( { attributes } ) {
const { content } = attributes;
Expand Down
5 changes: 2 additions & 3 deletions core-blocks/gallery/block.js → core-blocks/gallery/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
/**
* Internal dependencies
*/
import './editor.scss';
import GalleryImage from './gallery-image';

const MAX_COLUMNS = 8;
Expand All @@ -43,7 +44,7 @@ export function defaultColumnsNumber( attributes ) {
return Math.min( 3, attributes.images.length );
}

class GalleryBlock extends Component {
export default class GalleryEdit extends Component {
constructor() {
super( ...arguments );

Expand Down Expand Up @@ -270,5 +271,3 @@ class GalleryBlock extends Component {
);
}
}

export default GalleryBlock;
5 changes: 2 additions & 3 deletions core-blocks/gallery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import { RichText } from '@wordpress/editor';
/**
* Internal dependencies
*/
import './editor.scss';
import './style.scss';
import { default as GalleryBlock, defaultColumnsNumber } from './block';
import { default as edit, defaultColumnsNumber } from './edit';

const blockAttributes = {
align: {
Expand Down Expand Up @@ -165,7 +164,7 @@ export const settings = {
}
},

edit: GalleryBlock,
edit,

save( { attributes } ) {
const { images, columns = defaultColumnsNumber( attributes ), align, imageCrop, linkTo } = attributes;
Expand Down
5 changes: 3 additions & 2 deletions core-blocks/image/block.js → core-blocks/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ import {
/**
* Internal dependencies
*/
import './editor.scss';
import ImageSize from './image-size';

/**
* Module constants
*/
const MIN_SIZE = 20;

class ImageBlock extends Component {
class ImageEdit extends Component {
constructor() {
super( ...arguments );
this.updateAlt = this.updateAlt.bind( this );
Expand Down Expand Up @@ -399,4 +400,4 @@ export default compose( [
image: id ? getMedia( id ) : null,
};
} ),
] )( ImageBlock );
] )( ImageEdit );
5 changes: 2 additions & 3 deletions core-blocks/image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { RichText } from '@wordpress/editor';
* Internal dependencies
*/
import './style.scss';
import './editor.scss';
import ImageBlock from './block';
import edit from './edit';

export const name = 'core/image';

Expand Down Expand Up @@ -180,7 +179,7 @@ export const settings = {
}
},

edit: ImageBlock,
edit,

save( { attributes } ) {
const { url, alt, caption, align, href, width, height, id } = attributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ import {
* Internal dependencies
*/
import './editor.scss';
import './style.scss';

const MAX_POSTS_COLUMNS = 6;

class LatestPostsBlock extends Component {
class LatestPostsEdit extends Component {
constructor() {
super( ...arguments );

Expand Down Expand Up @@ -176,4 +175,4 @@ export default withAPIData( ( props ) => {
latestPosts: `/wp/v2/posts?${ latestPostsQuery }`,
categoriesList: `/wp/v2/categories?${ categoriesListQuery }`,
};
} )( LatestPostsBlock );
} )( LatestPostsEdit );
5 changes: 2 additions & 3 deletions core-blocks/latest-posts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import './editor.scss';
import './style.scss';
import LatestPostsBlock from './block';
import edit from './edit';

export const name = 'core/latest-posts';

Expand All @@ -34,7 +33,7 @@ export const settings = {
}
},

edit: LatestPostsBlock,
edit,

save() {
return null;
Expand Down

0 comments on commit 823dcf2

Please sign in to comment.