From 596372a4d9b8acc8f6ca9a3b9ca5d1e6619076d7 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Fri, 2 Feb 2018 15:30:35 -0500 Subject: [PATCH 01/41] Framework: Per-block script bundles --- .../raw-handling/test/integration/index.js | 4 +- blocks/index.js | 1 - blocks/library/index.js | 91 ------------------- blocks/library/paragraph/index.js | 14 ++- blocks/library/paragraph/index.php | 16 ++++ blocks/test/full-content.js | 4 +- .../components/document-outline/test/index.js | 4 +- editor/store/test/reducer.js | 3 +- editor/store/test/selectors.js | 4 +- lib/client-assets.php | 43 +++++---- test/unit/setup-wp-aliases.js | 2 +- webpack.config.js | 16 +++- 12 files changed, 68 insertions(+), 134 deletions(-) delete mode 100644 blocks/library/index.js create mode 100644 blocks/library/paragraph/index.php diff --git a/blocks/api/raw-handling/test/integration/index.js b/blocks/api/raw-handling/test/integration/index.js index 5ac2086d3568c9..a074dabc515f8b 100644 --- a/blocks/api/raw-handling/test/integration/index.js +++ b/blocks/api/raw-handling/test/integration/index.js @@ -8,7 +8,6 @@ import path from 'path'; /** * Internal dependencies */ -import { registerCoreBlocks } from '../../../../library'; import rawHandler from '../../index'; import serialize from '../../../serializer'; @@ -24,7 +23,8 @@ describe( 'raw handling: integration', () => { beforeAll( () => { // Load all hooks that modify blocks require( 'blocks/hooks' ); - registerCoreBlocks(); + + // TODO: Need to load/register core blocks. Maybe requireIndex ? } ); types.forEach( ( type ) => { diff --git a/blocks/index.js b/blocks/index.js index 4ef35d2d54ab47..626424cc8bdbae 100644 --- a/blocks/index.js +++ b/blocks/index.js @@ -13,7 +13,6 @@ import './hooks'; // 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 { registerCoreBlocks } from './library'; export { default as AlignmentToolbar } from './alignment-toolbar'; export { default as BlockAlignmentToolbar } from './block-alignment-toolbar'; export { default as BlockControls } from './block-controls'; diff --git a/blocks/library/index.js b/blocks/library/index.js deleted file mode 100644 index 17e7534aa35cd1..00000000000000 --- a/blocks/library/index.js +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Internal dependencies - */ -import { - registerBlockType, - setDefaultBlockName, - setUnknownTypeHandlerName, -} from '../api'; -import * as audio from './audio'; -import * as button from './button'; -import * as categories from './categories'; -import * as code from './code'; -import * as coverImage from './cover-image'; -import * as embed from './embed'; -import * as freeform from './freeform'; -import * as gallery from './gallery'; -import * as heading from './heading'; -import * as html from './html'; -import * as image from './image'; -import * as latestPosts from './latest-posts'; -import * as list from './list'; -import * as more from './more'; -import * as paragraph from './paragraph'; -import * as preformatted from './preformatted'; -import * as pullquote from './pullquote'; -import * as quote from './quote'; -import * as reusableBlock from './block'; -import * as separator from './separator'; -import * as shortcode from './shortcode'; -import * as subhead from './subhead'; -import * as table from './table'; -import * as textColumns from './text-columns'; -import * as verse from './verse'; -import * as video from './video'; - -export const registerCoreBlocks = () => { - [ - // FIXME: Temporary fix. - // - // The Shortcode block declares a catch-all shortcode transform, - // meaning it will attempt to intercept pastes and block conversions of - // any valid shortcode-like content. Other blocks (e.g. Gallery) may - // declare specific shortcode transforms (e.g. `[gallery]`), with which - // this block would conflict. Thus, the Shortcode block needs to be - // registered as early as possible, so that any other block types' - // shortcode transforms can be honoured. - // - // This isn't a proper solution, as it is at odds with the - // specification of shortcode conversion, in the sense that conversion - // is explicitly independent of block order. Thus, concurrent parse - // rules (i.e. a same text input can yield two different transforms, - // like `[gallery] -> { Gallery, Shortcode }`) are unsupported, - // yielding non-deterministic results. A proper solution could be to - // let the editor (or site owners) determine a default block handler of - // unknown shortcodes — see `setUnknownTypeHandlerName`. - shortcode, - - audio, - button, - categories, - code, - coverImage, - embed, - ...embed.common, - ...embed.others, - freeform, - gallery, - heading, - html, - image, - list, - latestPosts, - more, - paragraph, - preformatted, - pullquote, - quote, - reusableBlock, - separator, - subhead, - table, - textColumns, - verse, - video, - ].forEach( ( { name, settings } ) => { - registerBlockType( name, settings ); - } ); - - setDefaultBlockName( paragraph.name ); - setUnknownTypeHandlerName( freeform.name ); -}; diff --git a/blocks/library/paragraph/index.js b/blocks/library/paragraph/index.js index 396a8ee59dd6e4..96aaca734f7492 100644 --- a/blocks/library/paragraph/index.js +++ b/blocks/library/paragraph/index.js @@ -7,6 +7,11 @@ import classnames from 'classnames'; * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType, + setDefaultBlockName, +} from '@wordpress/blocks'; import { concatChildren, Component } from '@wordpress/element'; import { Autocomplete, PanelBody, PanelColor, withFallbackStyles } from '@wordpress/components'; @@ -15,7 +20,6 @@ import { Autocomplete, PanelBody, PanelColor, withFallbackStyles } from '@wordpr */ import './editor.scss'; import './style.scss'; -import { createBlock } from '../../api'; import { blockAutocompleter, userAutocompleter } from '../../autocompleters'; import AlignmentToolbar from '../../alignment-toolbar'; import BlockAlignmentToolbar from '../../block-alignment-toolbar'; @@ -192,9 +196,7 @@ class ParagraphBlock extends Component { } } -export const name = 'core/paragraph'; - -export const settings = { +registerBlockType( 'core/paragraph', { title: __( 'Paragraph' ), description: __( 'This is a simple text only block for adding a single paragraph of content.' ), @@ -283,4 +285,6 @@ export const settings = { return

{ content }

; }, -}; +} ); + +setDefaultBlockName( 'core/paragraph' ); diff --git a/blocks/library/paragraph/index.php b/blocks/library/paragraph/index.php new file mode 100644 index 00000000000000..521aceaede7d75 --- /dev/null +++ b/blocks/library/paragraph/index.php @@ -0,0 +1,16 @@ + 'core-paragraph-block', + ) ); +} + +add_action( 'init', 'register_core_paragraph_block' ); diff --git a/blocks/test/full-content.js b/blocks/test/full-content.js index be355e6d242a37..c038d098913120 100644 --- a/blocks/test/full-content.js +++ b/blocks/test/full-content.js @@ -9,7 +9,6 @@ import { format } from 'util'; /** * Internal dependencies */ -import { registerCoreBlocks } from '../library'; import parse from '../api/parser'; import { parse as grammarParse } from '../api/post.pegjs'; import serialize from '../api/serializer'; @@ -94,7 +93,8 @@ describe( 'full post content fixture', () => { // Load all hooks that modify blocks require( 'blocks/hooks' ); - registerCoreBlocks(); + + // TODO: Need to load/register core blocks. Maybe requireIndex ? } ); fileBasenames.forEach( f => { diff --git a/editor/components/document-outline/test/index.js b/editor/components/document-outline/test/index.js index a38c04c147381d..561310fc7c456f 100644 --- a/editor/components/document-outline/test/index.js +++ b/editor/components/document-outline/test/index.js @@ -6,7 +6,7 @@ import { shallow } from 'enzyme'; /** * WordPress dependencies */ -import { createBlock, registerCoreBlocks } from '@wordpress/blocks'; +import { createBlock } from '@wordpress/blocks'; /** * Internal dependencies @@ -14,7 +14,7 @@ import { createBlock, registerCoreBlocks } from '@wordpress/blocks'; import { DocumentOutline } from '../'; describe( 'DocumentOutline', () => { - registerCoreBlocks(); + // TODO: Need to load/register core blocks. Maybe requireIndex ? const paragraph = createBlock( 'core/paragraph' ); const headingH1 = createBlock( 'core/heading', { diff --git a/editor/store/test/reducer.js b/editor/store/test/reducer.js index fd53c7a4a57950..7602655d0c9619 100644 --- a/editor/store/test/reducer.js +++ b/editor/store/test/reducer.js @@ -8,7 +8,6 @@ import deepFreeze from 'deep-freeze'; * WordPress dependencies */ import { - registerCoreBlocks, registerBlockType, unregisterBlockType, } from '@wordpress/blocks'; @@ -958,7 +957,7 @@ describe( 'state', () => { describe( 'preferences()', () => { beforeAll( () => { - registerCoreBlocks(); + // TODO: Need to load/register core blocks (or at least some demo blocks). Maybe requireIndex ? } ); it( 'should apply all defaults', () => { diff --git a/editor/store/test/selectors.js b/editor/store/test/selectors.js index cebb550803b332..e9c92e5efbe64a 100644 --- a/editor/store/test/selectors.js +++ b/editor/store/test/selectors.js @@ -8,7 +8,7 @@ import { union } from 'lodash'; * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { registerBlockType, unregisterBlockType, registerCoreBlocks, getBlockTypes } from '@wordpress/blocks'; +import { registerBlockType, unregisterBlockType, getBlockTypes } from '@wordpress/blocks'; /** * Internal dependencies @@ -1949,7 +1949,7 @@ describe( 'selectors', () => { describe( 'getRecentInserterItems', () => { beforeAll( () => { - registerCoreBlocks(); + // TODO: Need to load/register core blocks (or at least some demo blocks). Maybe requireIndex ? } ); it( 'should return the 8 most recently used blocks', () => { diff --git a/lib/client-assets.php b/lib/client-assets.php index 041adf545b0d00..e4f34c95da56d7 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -78,27 +78,27 @@ function gutenberg_register_scripts_and_styles() { // Editor Scripts. wp_register_script( 'wp-data', - gutenberg_url( 'data/build/index.js' ), + gutenberg_url( 'build/data.js' ), array( 'wp-element' ), - filemtime( gutenberg_dir_path() . 'data/build/index.js' ) + filemtime( gutenberg_dir_path() . 'build/data.js' ) ); wp_register_script( 'wp-utils', - gutenberg_url( 'utils/build/index.js' ), + gutenberg_url( 'build/utils.js' ), array(), - filemtime( gutenberg_dir_path() . 'utils/build/index.js' ) + filemtime( gutenberg_dir_path() . 'build/utils.js' ) ); wp_register_script( 'wp-hooks', - gutenberg_url( 'hooks/build/index.js' ), + gutenberg_url( 'build/hooks.js' ), array(), - filemtime( gutenberg_dir_path() . 'hooks/build/index.js' ) + filemtime( gutenberg_dir_path() . 'build/hooks.js' ) ); wp_register_script( 'wp-date', - gutenberg_url( 'date/build/index.js' ), + gutenberg_url( 'build/date.js' ), array( 'moment' ), - filemtime( gutenberg_dir_path() . 'date/build/index.js' ) + filemtime( gutenberg_dir_path() . 'build/date.js' ) ); global $wp_locale; wp_add_inline_script( 'wp-date', 'window._wpDateSettings = ' . wp_json_encode( array( @@ -128,27 +128,27 @@ function gutenberg_register_scripts_and_styles() { ) ), 'before' ); wp_register_script( 'wp-i18n', - gutenberg_url( 'i18n/build/index.js' ), + gutenberg_url( 'build/i18n.js' ), array(), - filemtime( gutenberg_dir_path() . 'i18n/build/index.js' ) + filemtime( gutenberg_dir_path() . 'build/i18n.js' ) ); wp_register_script( 'wp-element', - gutenberg_url( 'element/build/index.js' ), + gutenberg_url( 'build/element.js' ), array( 'react', 'react-dom', 'react-dom-server' ), - filemtime( gutenberg_dir_path() . 'element/build/index.js' ) + filemtime( gutenberg_dir_path() . 'build/element.js' ) ); wp_register_script( 'wp-components', - gutenberg_url( 'components/build/index.js' ), + gutenberg_url( 'build/components.js' ), array( 'wp-element', 'wp-i18n', 'wp-utils', 'wp-hooks', 'wp-api-request', 'moment' ), - filemtime( gutenberg_dir_path() . 'components/build/index.js' ) + filemtime( gutenberg_dir_path() . 'build/components.js' ) ); wp_register_script( 'wp-blocks', - gutenberg_url( 'blocks/build/index.js' ), + gutenberg_url( 'build/blocks.js' ), array( 'wp-element', 'wp-components', 'wp-utils', 'wp-hooks', 'wp-i18n', 'tinymce-latest', 'tinymce-latest-lists', 'tinymce-latest-paste', 'tinymce-latest-table', 'media-views', 'media-models', 'shortcode' ), - filemtime( gutenberg_dir_path() . 'blocks/build/index.js' ) + filemtime( gutenberg_dir_path() . 'build/blocks.js' ) ); wp_add_inline_script( 'wp-blocks', @@ -161,16 +161,16 @@ function gutenberg_register_scripts_and_styles() { wp_register_script( 'wp-editor', - gutenberg_url( 'editor/build/index.js' ), + gutenberg_url( 'build/editor.js' ), array( 'postbox', 'jquery', 'wp-api', 'wp-data', 'wp-date', 'wp-i18n', 'wp-blocks', 'wp-element', 'wp-components', 'wp-utils', 'word-count', 'editor' ), - filemtime( gutenberg_dir_path() . 'editor/build/index.js' ) + filemtime( gutenberg_dir_path() . 'build/editor.js' ) ); wp_register_script( 'wp-edit-post', - gutenberg_url( 'edit-post/build/index.js' ), + gutenberg_url( 'build/editPost.js' ), array( 'jquery', 'heartbeat', 'wp-element', 'wp-components', 'wp-editor', 'wp-i18n', 'wp-date', 'wp-utils', 'wp-data' ), - filemtime( gutenberg_dir_path() . 'edit-post/build/index.js' ), + filemtime( gutenberg_dir_path() . 'build/editPost.js' ), true ); @@ -897,8 +897,7 @@ function gutenberg_editor_scripts_and_styles( $hook ) { $script .= sprintf( 'var editorSettings = %s;', wp_json_encode( $editor_settings ) ); $script .= << { Object.defineProperty( global.wp, entryPointName, { get: () => require( entryPointName ), diff --git a/webpack.config.js b/webpack.config.js index b886aa80bcdb26..50719351e5856a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -4,6 +4,8 @@ const webpack = require( 'webpack' ); const ExtractTextPlugin = require( 'extract-text-webpack-plugin' ); const WebpackRTLPlugin = require( 'webpack-rtl-plugin' ); +const fs = require( 'fs' ); +const { camelCase, castArray } = require( 'lodash' ); // Main CSS loader for everything but blocks.. const mainCSSExtractTextPlugin = new ExtractTextPlugin( { @@ -53,7 +55,11 @@ const entryPointNames = [ 'i18n', 'utils', 'data', - 'edit-post', + [ 'editPost', 'edit-post' ], + ...fs.readdirSync( './blocks/library' ).map( ( block ) => [ + '__block_' + camelCase( block ), + 'blocks/library/' + block, + ] ), ]; const packageNames = [ @@ -77,8 +83,10 @@ const externals = { const config = { entry: Object.assign( - entryPointNames.reduce( ( memo, entryPointName ) => { - memo[ entryPointName ] = `./${ entryPointName }/index.js`; + entryPointNames.reduce( ( memo, entryPoint ) => { + entryPoint = castArray( entryPoint ); + const [ name, path = name ] = entryPoint; + memo[ name ] = `./${ path }/index.js`; return memo; }, {} ), packageNames.reduce( ( memo, packageName ) => { @@ -87,7 +95,7 @@ const config = { }, {} ) ), output: { - filename: '[name]/build/index.js', + filename: 'build/[name].js', path: __dirname, library: [ 'wp', '[name]' ], libraryTarget: 'this', From 459a2be66b18d376ec58b6ab11d8963aba2dfd37 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Tue, 3 Apr 2018 01:29:44 +0530 Subject: [PATCH 02/41] Server-side registration for heading core block --- blocks/library/heading/index.js | 15 ++++++++++----- blocks/library/heading/index.php | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 blocks/library/heading/index.php diff --git a/blocks/library/heading/index.js b/blocks/library/heading/index.js index c59b23ec9ac9d2..3f013ab912b105 100644 --- a/blocks/library/heading/index.js +++ b/blocks/library/heading/index.js @@ -2,6 +2,12 @@ * WordPress dependencies */ import { __, sprintf } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType, + setDefaultBlockName, +} from '@wordpress/blocks'; + import { concatChildren } from '@wordpress/element'; import { Toolbar } from '@wordpress/components'; @@ -9,15 +15,12 @@ import { Toolbar } from '@wordpress/components'; * Internal dependencies */ import './editor.scss'; -import { createBlock } from '../../api'; import RichText from '../../rich-text'; import BlockControls from '../../block-controls'; import InspectorControls from '../../inspector-controls'; import AlignmentToolbar from '../../alignment-toolbar'; -export const name = 'core/heading'; - -export const settings = { +registerBlockType( 'core/heading', { title: __( 'Heading' ), description: __( 'Search engines use the headings to index the structure and content of your web pages.' ), @@ -180,4 +183,6 @@ export const settings = { ); }, -}; +} ); + +setDefaultBlockName( 'core/heading' ); \ No newline at end of file diff --git a/blocks/library/heading/index.php b/blocks/library/heading/index.php new file mode 100644 index 00000000000000..072e6d9fb52dad --- /dev/null +++ b/blocks/library/heading/index.php @@ -0,0 +1,16 @@ + 'core-heading-block', + ) ); +} + +add_action( 'init', 'register_core_heading_block' ); From c43594398490645bf78327110b09b6844f6e7759 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Tue, 3 Apr 2018 02:49:40 +0530 Subject: [PATCH 03/41] Server-side registration for more core blocks Partially completed server-side registration for more core blocks. Some core blocks are still left. Only editor_script handles are being enqueued as of now. --- blocks/library/audio/index.js | 11 +++++++---- blocks/library/audio/index.php | 16 ++++++++++++++++ blocks/library/button/index.js | 9 +++++---- blocks/library/button/index.php | 16 ++++++++++++++++ blocks/library/code/index.js | 11 ++++++----- blocks/library/code/index.php | 16 ++++++++++++++++ blocks/library/cover-image/index.js | 11 ++++++----- blocks/library/cover-image/index.php | 16 ++++++++++++++++ blocks/library/freeform/index.js | 9 +++++---- blocks/library/freeform/index.php | 16 ++++++++++++++++ blocks/library/gallery/index.js | 11 ++++++----- blocks/library/gallery/index.php | 16 ++++++++++++++++ blocks/library/heading/index.js | 4 +--- blocks/library/html/index.js | 9 +++++---- blocks/library/html/index.php | 16 ++++++++++++++++ blocks/library/list/index.js | 11 ++++++----- blocks/library/list/index.php | 16 ++++++++++++++++ blocks/library/more/index.js | 9 +++++---- blocks/library/more/index.php | 16 ++++++++++++++++ blocks/library/preformatted/index.js | 11 ++++++----- blocks/library/preformatted/index.php | 16 ++++++++++++++++ blocks/library/pullquote/index.js | 9 +++++---- blocks/library/pullquote/index.php | 16 ++++++++++++++++ blocks/library/quote/index.js | 11 ++++++----- blocks/library/quote/index.php | 16 ++++++++++++++++ blocks/library/separator/index.js | 11 ++++++----- blocks/library/separator/index.php | 16 ++++++++++++++++ blocks/library/shortcode/index.js | 10 ++++++---- blocks/library/shortcode/index.php | 16 ++++++++++++++++ blocks/library/subhead/index.js | 11 ++++++----- blocks/library/subhead/index.php | 16 ++++++++++++++++ blocks/library/text-columns/index.js | 9 +++++---- blocks/library/text-columns/index.php | 16 ++++++++++++++++ blocks/library/verse/index.js | 11 ++++++----- blocks/library/verse/index.php | 16 ++++++++++++++++ blocks/library/video/index.js | 9 +++++---- blocks/library/video/index.php | 16 ++++++++++++++++ 37 files changed, 391 insertions(+), 84 deletions(-) create mode 100644 blocks/library/audio/index.php create mode 100644 blocks/library/button/index.php create mode 100644 blocks/library/code/index.php create mode 100644 blocks/library/cover-image/index.php create mode 100644 blocks/library/freeform/index.php create mode 100644 blocks/library/gallery/index.php create mode 100644 blocks/library/html/index.php create mode 100644 blocks/library/list/index.php create mode 100644 blocks/library/more/index.php create mode 100644 blocks/library/preformatted/index.php create mode 100644 blocks/library/pullquote/index.php create mode 100644 blocks/library/quote/index.php create mode 100644 blocks/library/separator/index.php create mode 100644 blocks/library/shortcode/index.php create mode 100644 blocks/library/subhead/index.php create mode 100644 blocks/library/text-columns/index.php create mode 100644 blocks/library/verse/index.php create mode 100644 blocks/library/video/index.php diff --git a/blocks/library/audio/index.js b/blocks/library/audio/index.js index 6a66ce3e81de54..a3dc14724f3a73 100644 --- a/blocks/library/audio/index.js +++ b/blocks/library/audio/index.js @@ -6,6 +6,11 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; + +import { + registerBlockType +} from '@wordpress/blocks'; + import { Button, IconButton, Placeholder, Toolbar } from '@wordpress/components'; import { Component } from '@wordpress/element'; @@ -19,9 +24,7 @@ import RichText from '../../rich-text'; import BlockControls from '../../block-controls'; import BlockAlignmentToolbar from '../../block-alignment-toolbar'; -export const name = 'core/audio'; - -export const settings = { +registerBlockType( 'core/audio', { title: __( 'Audio' ), description: __( 'The Audio block allows you to embed audio files and play them back using a simple player.' ), @@ -179,4 +182,4 @@ export const settings = { ); }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/audio/index.php b/blocks/library/audio/index.php new file mode 100644 index 00000000000000..fa389dffdd9027 --- /dev/null +++ b/blocks/library/audio/index.php @@ -0,0 +1,16 @@ + 'core-audio-block', + ) ); +} + +add_action( 'init', 'register_core_audio_block' ); diff --git a/blocks/library/button/index.js b/blocks/library/button/index.js index 6e68c7d4ed7c3b..55d7d067d91fac 100644 --- a/blocks/library/button/index.js +++ b/blocks/library/button/index.js @@ -2,6 +2,9 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + registerBlockType +} from '@wordpress/blocks'; import { Component } from '@wordpress/element'; import { Dashicon, IconButton, PanelColor, withFallbackStyles } from '@wordpress/components'; @@ -172,9 +175,7 @@ const blockAttributes = { }, }; -export const name = 'core/button'; - -export const settings = { +registerBlockType( 'core/button', { title: __( 'Button' ), description: __( 'A nice little button. Call something out with it.' ), @@ -236,4 +237,4 @@ export const settings = { ); }, } ], -}; +} ); \ No newline at end of file diff --git a/blocks/library/button/index.php b/blocks/library/button/index.php new file mode 100644 index 00000000000000..8a3509c1f1cae6 --- /dev/null +++ b/blocks/library/button/index.php @@ -0,0 +1,16 @@ + 'core-button-block', + ) ); +} + +add_action( 'init', 'register_core_button_block' ); diff --git a/blocks/library/code/index.js b/blocks/library/code/index.js index cf40be5028f014..5462a92017322b 100644 --- a/blocks/library/code/index.js +++ b/blocks/library/code/index.js @@ -2,17 +2,18 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType +} from '@wordpress/blocks'; /** * Internal dependencies */ import './editor.scss'; import PlainText from '../../plain-text'; -import { createBlock } from '../../api'; -export const name = 'core/code'; - -export const settings = { +registerBlockType( 'core/code', { title: __( 'Code' ), description: __( 'The code block maintains spaces and tabs, great for showing code snippets.' ), @@ -69,4 +70,4 @@ export const settings = { save( { attributes } ) { return
{ attributes.content }
; }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/code/index.php b/blocks/library/code/index.php new file mode 100644 index 00000000000000..e1a47a57fad26c --- /dev/null +++ b/blocks/library/code/index.php @@ -0,0 +1,16 @@ + 'core-code-block', + ) ); +} + +add_action( 'init', 'register_core_code_block' ); diff --git a/blocks/library/cover-image/index.js b/blocks/library/cover-image/index.js index 6e13282346f23e..92a9a5d35745da 100644 --- a/blocks/library/cover-image/index.js +++ b/blocks/library/cover-image/index.js @@ -8,6 +8,10 @@ import { isEmpty } from 'lodash'; */ import { IconButton, PanelBody, Toolbar } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType +} from '@wordpress/blocks'; import classnames from 'classnames'; /** @@ -15,7 +19,6 @@ import classnames from 'classnames'; */ import './editor.scss'; import './style.scss'; -import { createBlock } from '../../api'; import RichText from '../../rich-text'; import AlignmentToolbar from '../../alignment-toolbar'; import MediaUpload from '../../media-upload'; @@ -28,9 +31,7 @@ import RangeControl from '../../inspector-controls/range-control'; const validAlignments = [ 'left', 'center', 'right', 'wide', 'full' ]; -export const name = 'core/cover-image'; - -export const settings = { +registerBlockType( 'core/cover-image', { title: __( 'Cover Image' ), description: __( 'Cover Image is a bold image block with an optional title.' ), @@ -236,7 +237,7 @@ export const settings = { ); }, -}; +} ); function dimRatioToClass( ratio ) { return ( ratio === 0 || ratio === 50 ) ? diff --git a/blocks/library/cover-image/index.php b/blocks/library/cover-image/index.php new file mode 100644 index 00000000000000..c2d0fb0dd71c47 --- /dev/null +++ b/blocks/library/cover-image/index.php @@ -0,0 +1,16 @@ + 'core-cover-image-block', + ) ); +} + +add_action( 'init', 'register_core_cover_image_block' ); diff --git a/blocks/library/freeform/index.js b/blocks/library/freeform/index.js index fa5e63be0138eb..1672e4c35175c2 100644 --- a/blocks/library/freeform/index.js +++ b/blocks/library/freeform/index.js @@ -2,6 +2,9 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + registerBlockType +} from '@wordpress/blocks'; /** * Internal dependencies @@ -9,9 +12,7 @@ import { __ } from '@wordpress/i18n'; import './editor.scss'; import OldEditor from './old-editor'; -export const name = 'core/freeform'; - -export const settings = { +registerBlockType( 'core/freeform', { title: __( 'Classic' ), desription: __( 'The classic editor, in block form.' ), @@ -33,4 +34,4 @@ export const settings = { const { content } = attributes; return content; }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/freeform/index.php b/blocks/library/freeform/index.php new file mode 100644 index 00000000000000..202b238a882b48 --- /dev/null +++ b/blocks/library/freeform/index.php @@ -0,0 +1,16 @@ + 'core-freeform-block', + ) ); +} + +add_action( 'init', 'register_core_freeform_block' ); diff --git a/blocks/library/gallery/index.js b/blocks/library/gallery/index.js index 5f5cba42c2f113..5bb50c8e92d5c0 100644 --- a/blocks/library/gallery/index.js +++ b/blocks/library/gallery/index.js @@ -7,6 +7,10 @@ import { filter, every } from 'lodash'; * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType +} from '@wordpress/blocks'; import { createMediaFromFile, preloadImage } from '@wordpress/utils'; /** @@ -14,7 +18,6 @@ import { createMediaFromFile, preloadImage } from '@wordpress/utils'; */ import './editor.scss'; import './style.scss'; -import { createBlock } from '../../api'; import { default as GalleryBlock, defaultColumnsNumber } from './block'; const blockAttributes = { @@ -60,9 +63,7 @@ const blockAttributes = { }, }; -export const name = 'core/gallery'; - -export const settings = { +registerBlockType( 'core/gallery', { title: __( 'Gallery' ), description: __( 'Image galleries are a great way to share groups of pictures on your site.' ), icon: 'format-gallery', @@ -235,4 +236,4 @@ export const settings = { }, }, ], -}; +} ); \ No newline at end of file diff --git a/blocks/library/gallery/index.php b/blocks/library/gallery/index.php new file mode 100644 index 00000000000000..767ccf01ecb0a3 --- /dev/null +++ b/blocks/library/gallery/index.php @@ -0,0 +1,16 @@ + 'core-gallery-block', + ) ); +} + +add_action( 'init', 'register_core_gallery_block' ); diff --git a/blocks/library/heading/index.js b/blocks/library/heading/index.js index 3f013ab912b105..7c8e9f08540ccc 100644 --- a/blocks/library/heading/index.js +++ b/blocks/library/heading/index.js @@ -183,6 +183,4 @@ registerBlockType( 'core/heading', { ); }, -} ); - -setDefaultBlockName( 'core/heading' ); \ No newline at end of file +} ); \ No newline at end of file diff --git a/blocks/library/html/index.js b/blocks/library/html/index.js index dff185107a1fee..cfc69e7f268bc9 100644 --- a/blocks/library/html/index.js +++ b/blocks/library/html/index.js @@ -2,6 +2,9 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + registerBlockType +} from '@wordpress/blocks'; import { withState } from '@wordpress/components'; /** @@ -11,9 +14,7 @@ import './editor.scss'; import BlockControls from '../../block-controls'; import PlainText from '../../plain-text'; -export const name = 'core/html'; - -export const settings = { +registerBlockType( 'core/html', { title: __( 'Custom HTML' ), description: __( 'Add custom HTML code and preview it right here in the editor.' ), @@ -72,4 +73,4 @@ export const settings = { save( { attributes } ) { return attributes.content; }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/html/index.php b/blocks/library/html/index.php new file mode 100644 index 00000000000000..389db4b95324d8 --- /dev/null +++ b/blocks/library/html/index.php @@ -0,0 +1,16 @@ + 'core-html-block', + ) ); +} + +add_action( 'init', 'register_core_html_block' ); diff --git a/blocks/library/list/index.js b/blocks/library/list/index.js index c11432eaa965b2..3bf37ca08bfefc 100644 --- a/blocks/library/list/index.js +++ b/blocks/library/list/index.js @@ -8,18 +8,19 @@ import { find, compact, get, initial, last, isEmpty } from 'lodash'; */ import { Component, createElement } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType +} from '@wordpress/blocks'; /** * Internal dependencies */ import './editor.scss'; -import { createBlock } from '../../api'; import RichText from '../../rich-text'; import BlockControls from '../../block-controls'; -export const name = 'core/list'; - -export const settings = { +registerBlockType( 'core/list', { title: __( 'List' ), description: __( 'List. Numbered or bulleted.' ), icon: 'editor-ul', @@ -315,4 +316,4 @@ export const settings = { values ); }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/list/index.php b/blocks/library/list/index.php new file mode 100644 index 00000000000000..3f70a8316c25a0 --- /dev/null +++ b/blocks/library/list/index.php @@ -0,0 +1,16 @@ + 'core-list-block', + ) ); +} + +add_action( 'init', 'register_core_list_block' ); diff --git a/blocks/library/more/index.js b/blocks/library/more/index.js index 719bbe650fb7d8..caea5f0d38ec08 100644 --- a/blocks/library/more/index.js +++ b/blocks/library/more/index.js @@ -2,6 +2,9 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + registerBlockType +} from '@wordpress/blocks'; /** * Internal dependencies @@ -10,9 +13,7 @@ import './editor.scss'; import InspectorControls from '../../inspector-controls'; import ToggleControl from '../../inspector-controls/toggle-control'; -export const name = 'core/more'; - -export const settings = { +registerBlockType( 'core/more', { title: __( 'More' ), description: __( '"More" allows you to break your post into a part shown on index pages, and the subsequent after clicking a "Read More" link.' ), @@ -72,4 +73,4 @@ export const settings = { save() { return null; }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/more/index.php b/blocks/library/more/index.php new file mode 100644 index 00000000000000..7f38045eab35fc --- /dev/null +++ b/blocks/library/more/index.php @@ -0,0 +1,16 @@ + 'core-more-block', + ) ); +} + +add_action( 'init', 'register_core_more_block' ); diff --git a/blocks/library/preformatted/index.js b/blocks/library/preformatted/index.js index b810625630c7b8..6c3b0baae4b111 100644 --- a/blocks/library/preformatted/index.js +++ b/blocks/library/preformatted/index.js @@ -2,17 +2,18 @@ * WordPress */ import { __ } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType +} from '@wordpress/blocks'; /** * Internal dependencies */ import './editor.scss'; -import { createBlock } from '../../api'; import RichText from '../../rich-text'; -export const name = 'core/preformatted'; - -export const settings = { +registerBlockType( 'core/preformatted', { title: __( 'Preformatted' ), description: __( 'Preformatted text keeps your spaces, tabs and linebreaks as they are.' ), @@ -84,4 +85,4 @@ export const settings = { return
{ content }
; }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/preformatted/index.php b/blocks/library/preformatted/index.php new file mode 100644 index 00000000000000..b11cc935ffe018 --- /dev/null +++ b/blocks/library/preformatted/index.php @@ -0,0 +1,16 @@ + 'core-preformatted-block', + ) ); +} + +add_action( 'init', 'register_core_preformatted_block' ); diff --git a/blocks/library/pullquote/index.js b/blocks/library/pullquote/index.js index a233968b701d7f..fc3f739497d3f1 100644 --- a/blocks/library/pullquote/index.js +++ b/blocks/library/pullquote/index.js @@ -7,6 +7,9 @@ import { map } from 'lodash'; * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + registerBlockType +} from '@wordpress/blocks'; /** * Internal dependencies @@ -43,9 +46,7 @@ const blockAttributes = { }, }; -export const name = 'core/pullquote'; - -export const settings = { +registerBlockType( 'core/pullquote', { title: __( 'Pullquote' ), @@ -149,4 +150,4 @@ export const settings = { ); }, } ], -}; +} ); diff --git a/blocks/library/pullquote/index.php b/blocks/library/pullquote/index.php new file mode 100644 index 00000000000000..20f2a59547d435 --- /dev/null +++ b/blocks/library/pullquote/index.php @@ -0,0 +1,16 @@ + 'core-pullquote-block', + ) ); +} + +add_action( 'init', 'register_core_pullquote_block' ); diff --git a/blocks/library/quote/index.js b/blocks/library/quote/index.js index 9df285905498c4..f32a4b7403f8f5 100644 --- a/blocks/library/quote/index.js +++ b/blocks/library/quote/index.js @@ -8,6 +8,10 @@ import classnames from 'classnames'; * WordPress dependencies */ import { __, sprintf } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType +} from '@wordpress/blocks'; import { Toolbar } from '@wordpress/components'; /** @@ -15,7 +19,6 @@ import { Toolbar } from '@wordpress/components'; */ import './style.scss'; import './editor.scss'; -import { createBlock } from '../../api'; import AlignmentToolbar from '../../alignment-toolbar'; import BlockControls from '../../block-controls'; import RichText from '../../rich-text'; @@ -51,9 +54,7 @@ const blockAttributes = { }, }; -export const name = 'core/quote'; - -export const settings = { +registerBlockType( 'core/quote', { title: __( 'Quote' ), description: __( 'Quote. In quoting others, we cite ourselves. (Julio Cortázar)' ), icon: 'format-quote', @@ -272,4 +273,4 @@ export const settings = { }, }, ], -}; +} ); \ No newline at end of file diff --git a/blocks/library/quote/index.php b/blocks/library/quote/index.php new file mode 100644 index 00000000000000..b83115a7d21ed7 --- /dev/null +++ b/blocks/library/quote/index.php @@ -0,0 +1,16 @@ + 'core-quote-block', + ) ); +} + +add_action( 'init', 'register_core_quote_block' ); diff --git a/blocks/library/separator/index.js b/blocks/library/separator/index.js index b387cd4eec4d52..93e30f8e191a7c 100644 --- a/blocks/library/separator/index.js +++ b/blocks/library/separator/index.js @@ -2,16 +2,17 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType +} from '@wordpress/blocks'; /** * Internal dependencies */ import './style.scss'; -import { createBlock } from '../../api'; -export const name = 'core/separator'; - -export const settings = { +registerBlockType( 'core/separator', { title: __( 'Separator' ), description: __( 'Use the separator to indicate a thematic change in the content.' ), @@ -44,4 +45,4 @@ export const settings = { save() { return
; }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/separator/index.php b/blocks/library/separator/index.php new file mode 100644 index 00000000000000..bd0889196326ec --- /dev/null +++ b/blocks/library/separator/index.php @@ -0,0 +1,16 @@ + 'core-separator-block', + ) ); +} + +add_action( 'init', 'register_core_separator_block' ); diff --git a/blocks/library/shortcode/index.js b/blocks/library/shortcode/index.js index 3c839f73368d45..83ebfde80ed77d 100644 --- a/blocks/library/shortcode/index.js +++ b/blocks/library/shortcode/index.js @@ -2,6 +2,10 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + registerBlockType +} from '@wordpress/blocks'; + import { withInstanceId, Dashicon } from '@wordpress/components'; /** @@ -10,9 +14,7 @@ import { withInstanceId, Dashicon } from '@wordpress/components'; import './editor.scss'; import PlainText from '../../plain-text'; -export const name = 'core/shortcode'; - -export const settings = { +registerBlockType( 'core/shortcode', { title: __( 'Shortcode' ), description: __( 'A shortcode is a WordPress-specific code snippet that is written between square brackets as [shortcode]. ' ), @@ -82,4 +84,4 @@ export const settings = { save( { attributes } ) { return attributes.text; }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/shortcode/index.php b/blocks/library/shortcode/index.php new file mode 100644 index 00000000000000..fdf50fcec81394 --- /dev/null +++ b/blocks/library/shortcode/index.php @@ -0,0 +1,16 @@ + 'core-shortcode-block', + ) ); +} + +add_action( 'init', 'register_core_shortcode_block' ); diff --git a/blocks/library/subhead/index.js b/blocks/library/subhead/index.js index e96b8b7336713b..491cb79b44e80d 100644 --- a/blocks/library/subhead/index.js +++ b/blocks/library/subhead/index.js @@ -2,20 +2,21 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType +} from '@wordpress/blocks'; /** * Internal dependencies */ import './editor.scss'; import './style.scss'; -import { createBlock } from '../../api'; import RichText from '../../rich-text'; import InspectorControls from '../../inspector-controls'; import BlockDescription from '../../block-description'; -export const name = 'core/subhead'; - -export const settings = { +registerBlockType( 'core/subhead', { title: __( 'Subhead' ), icon: 'text', @@ -90,4 +91,4 @@ export const settings = { return

{ content }

; }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/subhead/index.php b/blocks/library/subhead/index.php new file mode 100644 index 00000000000000..2b31c8b846f8ad --- /dev/null +++ b/blocks/library/subhead/index.php @@ -0,0 +1,16 @@ + 'core-subhead-block', + ) ); +} + +add_action( 'init', 'register_core_subhead_block' ); diff --git a/blocks/library/text-columns/index.js b/blocks/library/text-columns/index.js index 0e2560bef5b8fb..1efa74d2c5ad13 100644 --- a/blocks/library/text-columns/index.js +++ b/blocks/library/text-columns/index.js @@ -7,6 +7,9 @@ import { times } from 'lodash'; * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + registerBlockType +} from '@wordpress/blocks'; /** * Internal dependencies @@ -19,9 +22,7 @@ import RangeControl from '../../inspector-controls/range-control'; import RichText from '../../rich-text'; import InspectorControls from '../../inspector-controls'; -export const name = 'core/text-columns'; - -export const settings = { +registerBlockType( 'core/text-columns', { title: __( 'Text Columns' ), description: __( 'Add text across columns. This block is experimental' ), @@ -119,4 +120,4 @@ export const settings = { ); }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/text-columns/index.php b/blocks/library/text-columns/index.php new file mode 100644 index 00000000000000..16fad05a8b67f0 --- /dev/null +++ b/blocks/library/text-columns/index.php @@ -0,0 +1,16 @@ + 'core-text-columns-block', + ) ); +} + +add_action( 'init', 'register_core_text_columns_block' ); diff --git a/blocks/library/verse/index.js b/blocks/library/verse/index.js index 66e059a925e7f3..a3ac228693acea 100644 --- a/blocks/library/verse/index.js +++ b/blocks/library/verse/index.js @@ -2,17 +2,18 @@ * WordPress */ import { __ } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType +} from '@wordpress/blocks'; /** * Internal dependencies */ import './editor.scss'; -import { createBlock } from '../../api'; import RichText from '../../rich-text'; -export const name = 'core/verse'; - -export const settings = { +registerBlockType( 'core/verse', { title: __( 'Verse' ), description: __( 'Write poetry and other literary expressions honoring all spaces and line-breaks.' ), @@ -74,4 +75,4 @@ export const settings = { save( { attributes, className } ) { return
{ attributes.content }
; }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/verse/index.php b/blocks/library/verse/index.php new file mode 100644 index 00000000000000..e0dc3fb303e7ee --- /dev/null +++ b/blocks/library/verse/index.php @@ -0,0 +1,16 @@ + 'core-verse-block', + ) ); +} + +add_action( 'init', 'register_core_verse_block' ); diff --git a/blocks/library/video/index.js b/blocks/library/video/index.js index 6445e8331f7b09..abea6c04c545aa 100644 --- a/blocks/library/video/index.js +++ b/blocks/library/video/index.js @@ -6,6 +6,9 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + registerBlockType +} from '@wordpress/blocks'; import { Placeholder, Toolbar, IconButton, Button } from '@wordpress/components'; import { Component } from '@wordpress/element'; @@ -19,9 +22,7 @@ import RichText from '../../rich-text'; import BlockControls from '../../block-controls'; import BlockAlignmentToolbar from '../../block-alignment-toolbar'; -export const name = 'core/video'; - -export const settings = { +registerBlockType( 'core/video', { title: __( 'Video' ), description: __( 'The Video block allows you to embed video files and play them back using a simple player.' ), @@ -181,4 +182,4 @@ export const settings = { ); }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/video/index.php b/blocks/library/video/index.php new file mode 100644 index 00000000000000..6d5f15eeda847d --- /dev/null +++ b/blocks/library/video/index.php @@ -0,0 +1,16 @@ + 'core-video-block', + ) ); +} + +add_action( 'init', 'register_core_video_block' ); From ffb559459ec6872454c71d18179b26d0c0246b95 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Tue, 3 Apr 2018 19:55:24 +0530 Subject: [PATCH 04/41] Server-side registration for core dynamic blocks Added initial support for server-side registration for core dynamic blocks like Reusable block, Categories block and Latest posts block --- blocks/library/block/index.js | 9 ++-- blocks/library/block/index.php | 21 +++++--- blocks/library/categories/index.js | 9 ++-- blocks/library/categories/index.php | 13 +++-- blocks/library/latest-posts/index.js | 9 ++-- blocks/library/latest-posts/index.php | 77 +++++++++++++++------------ 6 files changed, 81 insertions(+), 57 deletions(-) diff --git a/blocks/library/block/index.js b/blocks/library/block/index.js index 61d2c4f3111a60..be992798503110 100644 --- a/blocks/library/block/index.js +++ b/blocks/library/block/index.js @@ -10,6 +10,9 @@ import { connect } from 'react-redux'; import { Component } from '@wordpress/element'; import { Placeholder, Spinner } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; +import { + registerBlockType +} from '@wordpress/blocks'; /** * Internal dependencies @@ -155,9 +158,7 @@ const ConnectedReusableBlockEdit = connect( } ) )( ReusableBlockEdit ); -export const name = 'core/block'; - -export const settings = { +registerBlockType( 'core/block', { title: __( 'Reusable Block' ), category: 'reusable-blocks', isPrivate: true, @@ -175,4 +176,4 @@ export const settings = { edit: ConnectedReusableBlockEdit, save: () => null, -}; +} ); diff --git a/blocks/library/block/index.php b/blocks/library/block/index.php index 98807d0bd04284..b3d3b6afc10cc0 100644 --- a/blocks/library/block/index.php +++ b/blocks/library/block/index.php @@ -32,12 +32,19 @@ function gutenberg_render_block_core_reusable_block( $attributes ) { return gutenberg_render_block( $block ); } -register_block_type( 'core/block', array( - 'attributes' => array( - 'ref' => array( - 'type' => 'number', +function register_core_reusable_block() { + wp_register_script( 'core-reusable-block', gutenberg_url( '/build/__block_block.js' ) ); + + register_block_type( 'core/block', array( + 'editor_script' => 'core-reusable-block', + 'attributes' => array( + 'ref' => array( + 'type' => 'number', + ), ), - ), + + 'render_callback' => 'gutenberg_render_block_core_reusable_block', + ) ); +} - 'render_callback' => 'gutenberg_render_block_core_reusable_block', -) ); +add_action( 'init', 'register_core_reusable_block' ); \ No newline at end of file diff --git a/blocks/library/categories/index.js b/blocks/library/categories/index.js index d180b7df245df7..898b81fd862b35 100644 --- a/blocks/library/categories/index.js +++ b/blocks/library/categories/index.js @@ -2,6 +2,9 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + registerBlockType +} from '@wordpress/blocks'; /** * Internal dependencies @@ -10,9 +13,7 @@ import './editor.scss'; import './style.scss'; import CategoriesBlock from './block'; -export const name = 'core/categories'; - -export const settings = { +registerBlockType( 'core/categories', { title: __( 'Categories' ), description: __( 'Shows a list of your site\'s categories.' ), @@ -55,4 +56,4 @@ export const settings = { save() { return null; }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/categories/index.php b/blocks/library/categories/index.php index 490b3ed39f8b56..a946883c605127 100644 --- a/blocks/library/categories/index.php +++ b/blocks/library/categories/index.php @@ -84,6 +84,13 @@ function onCatChange() { return ob_get_clean(); } -register_block_type( 'core/categories', array( - 'render_callback' => 'gutenberg_render_block_core_categories', -) ); +function register_core_categories_block() { + wp_register_script( 'core-categories-block', gutenberg_url( '/build/__block_categories.js' ) ); + + register_block_type( 'core/categories', array( + 'editor_script' => 'core-categories-block', + 'render_callback' => 'gutenberg_render_block_core_categories', + ) ); +} + +add_action( 'init', 'register_core_categories_block' ); \ No newline at end of file diff --git a/blocks/library/latest-posts/index.js b/blocks/library/latest-posts/index.js index 3762b61e2a68b9..9fdb9f14550c74 100644 --- a/blocks/library/latest-posts/index.js +++ b/blocks/library/latest-posts/index.js @@ -2,6 +2,9 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + registerBlockType, +} from '@wordpress/blocks'; /** * Internal dependencies @@ -10,9 +13,7 @@ import './editor.scss'; import './style.scss'; import LatestPostsBlock from './block'; -export const name = 'core/latest-posts'; - -export const settings = { +registerBlockType( 'core/latest-posts', { title: __( 'Latest Posts' ), description: __( 'Shows a list of your site\'s most recent posts.' ), @@ -39,4 +40,4 @@ export const settings = { save() { return null; }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/latest-posts/index.php b/blocks/library/latest-posts/index.php index 5358c2aa44546d..a0dd53e147d24d 100644 --- a/blocks/library/latest-posts/index.php +++ b/blocks/library/latest-posts/index.php @@ -65,39 +65,46 @@ function gutenberg_render_block_core_latest_posts( $attributes ) { return $block_content; } -register_block_type( 'core/latest-posts', array( - 'attributes' => array( - 'categories' => array( - 'type' => 'string', - ), - 'postsToShow' => array( - 'type' => 'number', - 'default' => 5, - ), - 'displayPostDate' => array( - 'type' => 'boolean', - 'default' => false, - ), - 'layout' => array( - 'type' => 'string', - 'default' => 'list', - ), - 'columns' => array( - 'type' => 'number', - 'default' => 3, - ), - 'align' => array( - 'type' => 'string', - 'default' => 'center', - ), - 'order' => array( - 'type' => 'string', - 'default' => 'desc', - ), - 'orderBy' => array( - 'type' => 'string', - 'default' => 'date', +function register_core_latest_posts_block() { + wp_register_script( 'core-latest-posts-block', gutenberg_url( '/build/__block_latestPosts.js' ) ); + + register_block_type( 'core/latest-posts', array( + 'editor_script' => 'core-latest-posts-block', + 'attributes' => array( + 'categories' => array( + 'type' => 'string', + ), + 'postsToShow' => array( + 'type' => 'number', + 'default' => 5, + ), + 'displayPostDate' => array( + 'type' => 'boolean', + 'default' => false, + ), + 'layout' => array( + 'type' => 'string', + 'default' => 'list', + ), + 'columns' => array( + 'type' => 'number', + 'default' => 3, + ), + 'align' => array( + 'type' => 'string', + 'default' => 'center', + ), + 'order' => array( + 'type' => 'string', + 'default' => 'desc', + ), + 'orderBy' => array( + 'type' => 'string', + 'default' => 'date', + ), ), - ), - 'render_callback' => 'gutenberg_render_block_core_latest_posts', -) ); + 'render_callback' => 'gutenberg_render_block_core_latest_posts', + ) ); +} + +add_action( 'init', 'register_core_latest_posts_block' ); From 13fc4d726d0daa77fa75f7fc9a135bf1ded7929f Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Wed, 4 Apr 2018 02:29:57 +0530 Subject: [PATCH 05/41] Server-side registration for embed and table blocks --- blocks/library/embed/index.js | 41 ++++++++++++++++++---------------- blocks/library/embed/index.php | 16 +++++++++++++ blocks/library/table/index.js | 9 ++++---- blocks/library/table/index.php | 16 +++++++++++++ 4 files changed, 59 insertions(+), 23 deletions(-) create mode 100644 blocks/library/embed/index.php create mode 100644 blocks/library/table/index.php diff --git a/blocks/library/embed/index.js b/blocks/library/embed/index.js index da1076c7359043..fa6aaa5d5d872f 100644 --- a/blocks/library/embed/index.js +++ b/blocks/library/embed/index.js @@ -8,6 +8,10 @@ import { includes } from 'lodash'; * WordPress dependencies */ import { __, sprintf } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType +} from '@wordpress/blocks'; import { Component, renderToString } from '@wordpress/element'; import { Button, Placeholder, Spinner, SandBox } from '@wordpress/components'; import { addQueryArgs } from '@wordpress/url'; @@ -17,7 +21,6 @@ import { addQueryArgs } from '@wordpress/url'; */ import './style.scss'; import './editor.scss'; -import { createBlock } from '../../api'; import RichText from '../../rich-text'; import BlockControls from '../../block-controls'; import BlockAlignmentToolbar from '../../block-alignment-toolbar'; @@ -237,25 +240,25 @@ function getEmbedBlockSettings( { title, icon, category = 'embed', transforms, k }; } -export const name = 'core/embed'; - -export const settings = getEmbedBlockSettings( { - title: __( 'Embed' ), - icon: 'embed-generic', - transforms: { - from: [ - { - type: 'raw', - isMatch: ( node ) => node.nodeName === 'P' && /^\s*(https?:\/\/\S+)\s*/i.test( node.textContent ), - transform: ( node ) => { - return createBlock( 'core/embed', { - url: node.textContent.trim(), - } ); +registerBlockType( 'core/embed', + getEmbedBlockSettings( { + title: __( 'Embed' ), + icon: 'embed-generic', + transforms: { + from: [ + { + type: 'raw', + isMatch: ( node ) => node.nodeName === 'P' && /^\s*(https?:\/\/\S+)\s*/i.test( node.textContent ), + transform: ( node ) => { + return createBlock( 'core/embed', { + url: node.textContent.trim(), + } ); + }, }, - }, - ], - }, -} ); + ], + }, + } + ) ); export const common = [ { diff --git a/blocks/library/embed/index.php b/blocks/library/embed/index.php new file mode 100644 index 00000000000000..62c81d8c2b97ff --- /dev/null +++ b/blocks/library/embed/index.php @@ -0,0 +1,16 @@ + 'core-embed-block', + ) ); +} + +add_action( 'init', 'register_core_embed_block' ); diff --git a/blocks/library/table/index.js b/blocks/library/table/index.js index b9c7636f089b37..f76296c1267724 100644 --- a/blocks/library/table/index.js +++ b/blocks/library/table/index.js @@ -2,6 +2,9 @@ * External dependencies */ import { __ } from '@wordpress/i18n'; +import { + registerBlockType +} from '@wordpress/blocks'; /** * Internal dependencies @@ -12,9 +15,7 @@ import TableBlock from './table-block'; import BlockControls from '../../block-controls'; import BlockAlignmentToolbar from '../../block-alignment-toolbar'; -export const name = 'core/table'; - -export const settings = { +registerBlockType( 'core/table', { title: __( 'Table' ), description: __( 'Tables. Best used for tabular data.' ), icon: 'editor-table', @@ -86,4 +87,4 @@ export const settings = { ); }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/table/index.php b/blocks/library/table/index.php new file mode 100644 index 00000000000000..66f8455a037296 --- /dev/null +++ b/blocks/library/table/index.php @@ -0,0 +1,16 @@ + 'core-table-block', + ) ); +} + +add_action( 'init', 'register_core_table_block' ); From 17d6e28ff026f650738da657f9a130dbdf2859ff Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Wed, 4 Apr 2018 03:32:33 +0530 Subject: [PATCH 06/41] Server-side registration for image block Registered image block on the server-side. --- blocks/library/image/index.js | 13 ++++++++----- blocks/library/image/index.php | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 blocks/library/image/index.php diff --git a/blocks/library/image/index.js b/blocks/library/image/index.js index a3b50f5d3737b0..563902fa06ec5f 100644 --- a/blocks/library/image/index.js +++ b/blocks/library/image/index.js @@ -2,6 +2,12 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType, + getBlockAttributes, + getBlockType +} from '@wordpress/blocks'; import { createMediaFromFile, preloadImage } from '@wordpress/utils'; /** @@ -9,12 +15,9 @@ import { createMediaFromFile, preloadImage } from '@wordpress/utils'; */ import './style.scss'; import './editor.scss'; -import { createBlock, getBlockAttributes, getBlockType } from '../../api'; import ImageBlock from './block'; -export const name = 'core/image'; - -export const settings = { +registerBlockType( 'core/image', { title: __( 'Image' ), description: __( 'Worth a thousand words.' ), @@ -181,4 +184,4 @@ export const settings = { ); }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/image/index.php b/blocks/library/image/index.php new file mode 100644 index 00000000000000..a78772f26d155d --- /dev/null +++ b/blocks/library/image/index.php @@ -0,0 +1,16 @@ + 'core-image-block', + ) ); +} + +add_action( 'init', 'register_core_image_block' ); From 8d5c5884f7f76156bf72387f7b1394be7b931cc5 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Thu, 5 Apr 2018 17:18:08 +0530 Subject: [PATCH 07/41] Updated WebPack configuration to generate different CSS files for each block WebPack was configured to bundle CSS of all blocks in one single file. Since we now need to enqueue each CSS separately, the configuration has now been updated to generate different CSS files for each block --- webpack.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 50719351e5856a..06eb9f6ebb7dcc 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -14,12 +14,12 @@ const mainCSSExtractTextPlugin = new ExtractTextPlugin( { // CSS loader for styles specific to block editing. const editBlocksCSSPlugin = new ExtractTextPlugin( { - filename: './blocks/build/edit-blocks.css', + filename: './build/[name]_editor.css', } ); // CSS loader for styles specific to blocks in general. const blocksCSSPlugin = new ExtractTextPlugin( { - filename: './blocks/build/style.css', + filename: './build/[name].css', } ); // Configuration for the ExtractTextPlugin. From e5e7ce90d485e118f157aa41bd527bad0106afe1 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Fri, 6 Apr 2018 02:52:58 +0530 Subject: [PATCH 08/41] Enqueued base structural styles for blocks separately on server-side Earlier, we were enqueuing a monolithic bundle for the CSS. Now, common structural CSS for each block is being enqueued separately. This is needed to ensure that we can later intelligently enqueue these assets (load CSS only for blocks present on the page) --- blocks/library/audio/index.php | 10 ++++++++++ blocks/library/button/index.php | 10 ++++++++++ blocks/library/categories/index.php | 10 ++++++++++ blocks/library/cover-image/index.php | 10 ++++++++++ blocks/library/embed/index.php | 10 ++++++++++ blocks/library/gallery/index.php | 11 +++++++++++ blocks/library/image/index.php | 10 ++++++++++ blocks/library/latest-posts/index.php | 10 ++++++++++ blocks/library/paragraph/index.php | 10 ++++++++++ blocks/library/pullquote/index.php | 10 ++++++++++ blocks/library/quote/index.php | 10 ++++++++++ blocks/library/separator/index.php | 10 ++++++++++ blocks/library/subhead/index.php | 10 ++++++++++ blocks/library/table/index.php | 10 ++++++++++ blocks/library/text-columns/index.php | 10 ++++++++++ blocks/library/video/index.php | 10 ++++++++++ 16 files changed, 161 insertions(+) diff --git a/blocks/library/audio/index.php b/blocks/library/audio/index.php index fa389dffdd9027..8f86d8d56d2161 100644 --- a/blocks/library/audio/index.php +++ b/blocks/library/audio/index.php @@ -8,7 +8,17 @@ function register_core_audio_block() { wp_register_script( 'core-audio-block', gutenberg_url( '/build/__block_audio.js' ) ); + wp_register_style( + 'core-audio-block', + gutenberg_url( '/build/__block_audio.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_audio.css' ) + ); + + wp_style_add_data( 'core-audio-block', 'rtl', 'replace' ); + register_block_type( 'core/audio', array( + 'style' => 'core-audio-block', 'editor_script' => 'core-audio-block', ) ); } diff --git a/blocks/library/button/index.php b/blocks/library/button/index.php index 8a3509c1f1cae6..a9575ef978e02b 100644 --- a/blocks/library/button/index.php +++ b/blocks/library/button/index.php @@ -8,7 +8,17 @@ function register_core_button_block() { wp_register_script( 'core-button-block', gutenberg_url( '/build/__block_button.js' ) ); + wp_register_style( + 'core-button-block', + gutenberg_url( '/build/__block_button.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_button.css' ) + ); + + wp_style_add_data( 'core-button-block', 'rtl', 'replace' ); + register_block_type( 'core/button', array( + 'style' => 'core-button-block', 'editor_script' => 'core-button-block', ) ); } diff --git a/blocks/library/categories/index.php b/blocks/library/categories/index.php index a946883c605127..58fc82f6c7193b 100644 --- a/blocks/library/categories/index.php +++ b/blocks/library/categories/index.php @@ -87,7 +87,17 @@ function onCatChange() { function register_core_categories_block() { wp_register_script( 'core-categories-block', gutenberg_url( '/build/__block_categories.js' ) ); + wp_register_style( + 'core-categories-block', + gutenberg_url( '/build/__block_categories.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_categories.css' ) + ); + + wp_style_add_data( 'core-categories-block', 'rtl', 'replace' ); + register_block_type( 'core/categories', array( + 'style' => 'core-categories-block', 'editor_script' => 'core-categories-block', 'render_callback' => 'gutenberg_render_block_core_categories', ) ); diff --git a/blocks/library/cover-image/index.php b/blocks/library/cover-image/index.php index c2d0fb0dd71c47..d5dc385a27b772 100644 --- a/blocks/library/cover-image/index.php +++ b/blocks/library/cover-image/index.php @@ -8,7 +8,17 @@ function register_core_cover_image_block() { wp_register_script( 'core-cover-image-block', gutenberg_url( '/build/__block_coverImage.js' ) ); + wp_register_style( + 'core-cover-image-block', + gutenberg_url( '/build/__block_coverImage.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_coverImage.css' ) + ); + + wp_style_add_data( 'core-cover-image-block', 'rtl', 'replace' ); + register_block_type( 'core/cover-image', array( + 'style' => 'core-cover-image-block', 'editor_script' => 'core-cover-image-block', ) ); } diff --git a/blocks/library/embed/index.php b/blocks/library/embed/index.php index 62c81d8c2b97ff..b811b2cf167b73 100644 --- a/blocks/library/embed/index.php +++ b/blocks/library/embed/index.php @@ -8,7 +8,17 @@ function register_core_embed_block() { wp_register_script( 'core-embed-block', gutenberg_url( '/build/__block_embed.js' ) ); + wp_register_style( + 'core-embed-block', + gutenberg_url( '/build/__block_embed.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_embed.css' ) + ); + + wp_style_add_data( 'core-embed-block', 'rtl', 'replace' ); + register_block_type( 'core/embed', array( + 'style' => 'core-embed-block', 'editor_script' => 'core-embed-block', ) ); } diff --git a/blocks/library/gallery/index.php b/blocks/library/gallery/index.php index 767ccf01ecb0a3..55e09814c1a532 100644 --- a/blocks/library/gallery/index.php +++ b/blocks/library/gallery/index.php @@ -8,9 +8,20 @@ function register_core_gallery_block() { wp_register_script( 'core-gallery-block', gutenberg_url( '/build/__block_gallery.js' ) ); + wp_register_style( + 'core-gallery-block', + gutenberg_url( '/build/__block_gallery.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_gallery.css' ) + ); + + wp_style_add_data( 'core-gallery-block', 'rtl', 'replace' ); + register_block_type( 'core/gallery', array( + 'style' => 'core-gallery-block', 'editor_script' => 'core-gallery-block', ) ); + } add_action( 'init', 'register_core_gallery_block' ); diff --git a/blocks/library/image/index.php b/blocks/library/image/index.php index a78772f26d155d..c20653ea46b1ee 100644 --- a/blocks/library/image/index.php +++ b/blocks/library/image/index.php @@ -8,7 +8,17 @@ function register_core_image_block() { wp_register_script( 'core-image-block', gutenberg_url( '/build/__block_image.js' ) ); + wp_register_style( + 'core-image-block', + gutenberg_url( '/build/__block_image.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_image.css' ) + ); + + wp_style_add_data( 'core-image-block', 'rtl', 'replace' ); + register_block_type( 'core/image', array( + 'style' => 'core-image-block', 'editor_script' => 'core-image-block', ) ); } diff --git a/blocks/library/latest-posts/index.php b/blocks/library/latest-posts/index.php index a0dd53e147d24d..6a9126cf5354e8 100644 --- a/blocks/library/latest-posts/index.php +++ b/blocks/library/latest-posts/index.php @@ -68,7 +68,17 @@ function gutenberg_render_block_core_latest_posts( $attributes ) { function register_core_latest_posts_block() { wp_register_script( 'core-latest-posts-block', gutenberg_url( '/build/__block_latestPosts.js' ) ); + wp_register_style( + 'core-latest-posts-block', + gutenberg_url( '/build/__block_latestPosts.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_latestPosts.css' ) + ); + + wp_style_add_data( 'core-latest-posts-block', 'rtl', 'replace' ); + register_block_type( 'core/latest-posts', array( + 'style' => 'core-latest-posts-block', 'editor_script' => 'core-latest-posts-block', 'attributes' => array( 'categories' => array( diff --git a/blocks/library/paragraph/index.php b/blocks/library/paragraph/index.php index 521aceaede7d75..42dd649556ae98 100644 --- a/blocks/library/paragraph/index.php +++ b/blocks/library/paragraph/index.php @@ -8,7 +8,17 @@ function register_core_paragraph_block() { wp_register_script( 'core-paragraph-block', gutenberg_url( '/build/__block_paragraph.js' ) ); + wp_register_style( + 'core-paragraph-block', + gutenberg_url( '/build/__block_paragraph.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_paragraph.css' ) + ); + + wp_style_add_data( 'core-paragraph-block', 'rtl', 'replace' ); + register_block_type( 'core/paragraph', array( + 'style' => 'core-paragraph-block', 'editor_script' => 'core-paragraph-block', ) ); } diff --git a/blocks/library/pullquote/index.php b/blocks/library/pullquote/index.php index 20f2a59547d435..09d4c41dab576d 100644 --- a/blocks/library/pullquote/index.php +++ b/blocks/library/pullquote/index.php @@ -8,7 +8,17 @@ function register_core_pullquote_block() { wp_register_script( 'core-pullquote-block', gutenberg_url( '/build/__block_pullquote.js' ) ); + wp_register_style( + 'core-pullquote-block', + gutenberg_url( '/build/__block_pullquote.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_pullquote.css' ) + ); + + wp_style_add_data( 'core-pullquote-block', 'rtl', 'replace' ); + register_block_type( 'core/pullquote', array( + 'style' => 'core-pullquote-block', 'editor_script' => 'core-pullquote-block', ) ); } diff --git a/blocks/library/quote/index.php b/blocks/library/quote/index.php index b83115a7d21ed7..af843e9b306b92 100644 --- a/blocks/library/quote/index.php +++ b/blocks/library/quote/index.php @@ -8,7 +8,17 @@ function register_core_quote_block() { wp_register_script( 'core-quote-block', gutenberg_url( '/build/__block_quote.js' ) ); + wp_register_style( + 'core-quote-block', + gutenberg_url( '/build/__block_quote.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_quote.css' ) + ); + + wp_style_add_data( 'core-quote-block', 'rtl', 'replace' ); + register_block_type( 'core/quote', array( + 'style' => 'core-quote-block', 'editor_script' => 'core-quote-block', ) ); } diff --git a/blocks/library/separator/index.php b/blocks/library/separator/index.php index bd0889196326ec..e0d5ab4d52dfb9 100644 --- a/blocks/library/separator/index.php +++ b/blocks/library/separator/index.php @@ -8,7 +8,17 @@ function register_core_separator_block() { wp_register_script( 'core-separator-block', gutenberg_url( '/build/__block_separator.js' ) ); + wp_register_style( + 'core-separator-block', + gutenberg_url( '/build/__block_separator.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_separator.css' ) + ); + + wp_style_add_data( 'core-separator-block', 'rtl', 'replace' ); + register_block_type( 'core/separator', array( + 'style' => 'core-separator-block', 'editor_script' => 'core-separator-block', ) ); } diff --git a/blocks/library/subhead/index.php b/blocks/library/subhead/index.php index 2b31c8b846f8ad..e598e00d41f811 100644 --- a/blocks/library/subhead/index.php +++ b/blocks/library/subhead/index.php @@ -8,7 +8,17 @@ function register_core_subhead_block() { wp_register_script( 'core-subhead-block', gutenberg_url( '/build/__block_subhead.js' ) ); + wp_register_style( + 'core-subhead-block', + gutenberg_url( '/build/__block_subhead.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_subhead.css' ) + ); + + wp_style_add_data( 'core-subhead-block', 'rtl', 'replace' ); + register_block_type( 'core/subhead', array( + 'style' => 'core-subhead-block', 'editor_script' => 'core-subhead-block', ) ); } diff --git a/blocks/library/table/index.php b/blocks/library/table/index.php index 66f8455a037296..e29b1cccdc9f49 100644 --- a/blocks/library/table/index.php +++ b/blocks/library/table/index.php @@ -8,7 +8,17 @@ function register_core_table_block() { wp_register_script( 'core-table-block', gutenberg_url( '/build/__block_table.js' ) ); + wp_register_style( + 'core-table-block', + gutenberg_url( '/build/__block_table.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_table.css' ) + ); + + wp_style_add_data( 'core-table-block', 'rtl', 'replace' ); + register_block_type( 'core/table', array( + 'style' => 'core-table-block', 'editor_script' => 'core-table-block', ) ); } diff --git a/blocks/library/text-columns/index.php b/blocks/library/text-columns/index.php index 16fad05a8b67f0..79fafa0bea3e62 100644 --- a/blocks/library/text-columns/index.php +++ b/blocks/library/text-columns/index.php @@ -8,7 +8,17 @@ function register_core_text_columns_block() { wp_register_script( 'core-text-columns-block', gutenberg_url( '/build/__block_textColumns.js' ) ); + wp_register_style( + 'core-text-columns-block', + gutenberg_url( '/build/__block_textColumns.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_textColumns.css' ) + ); + + wp_style_add_data( 'core-text-columns-block', 'rtl', 'replace' ); + register_block_type( 'core/text-columns', array( + 'style' => 'core-text-columns-block', 'editor_script' => 'core-text-columns-block', ) ); } diff --git a/blocks/library/video/index.php b/blocks/library/video/index.php index 6d5f15eeda847d..b0663abc1389e9 100644 --- a/blocks/library/video/index.php +++ b/blocks/library/video/index.php @@ -8,7 +8,17 @@ function register_core_video_block() { wp_register_script( 'core-video-block', gutenberg_url( '/build/__block_video.js' ) ); + wp_register_style( + 'core-video-block', + gutenberg_url( '/build/__block_video.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_video.css' ) + ); + + wp_style_add_data( 'core-video-block', 'rtl', 'replace' ); + register_block_type( 'core/video', array( + 'style' => 'core-video-block', 'editor_script' => 'core-video-block', ) ); } From c41d21ab2e6c99744e9c5908ab203141e3f55a55 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Sat, 7 Apr 2018 04:40:08 +0530 Subject: [PATCH 09/41] Enqueued editor-specific styles for blocks separately on server-side Earlier, we were enqueuing a monolithic bundle for the editor-specific CSS. Now, editor specific CSS for each block is being enqueued separately. --- blocks/library/audio/index.php | 10 ++++++++++ blocks/library/button/index.php | 10 ++++++++++ blocks/library/categories/index.php | 10 ++++++++++ blocks/library/code/index.php | 10 ++++++++++ blocks/library/cover-image/index.php | 10 ++++++++++ blocks/library/embed/index.php | 10 ++++++++++ blocks/library/freeform/index.php | 10 ++++++++++ blocks/library/gallery/index.php | 10 ++++++++++ blocks/library/heading/index.php | 10 ++++++++++ blocks/library/html/index.php | 10 ++++++++++ blocks/library/image/index.php | 10 ++++++++++ blocks/library/latest-posts/index.php | 10 ++++++++++ blocks/library/list/index.php | 10 ++++++++++ blocks/library/more/index.php | 10 ++++++++++ blocks/library/paragraph/index.php | 10 ++++++++++ blocks/library/preformatted/index.php | 10 ++++++++++ blocks/library/pullquote/index.php | 10 ++++++++++ blocks/library/quote/index.php | 10 ++++++++++ blocks/library/shortcode/index.php | 10 ++++++++++ blocks/library/subhead/index.php | 10 ++++++++++ blocks/library/table/index.php | 10 ++++++++++ blocks/library/text-columns/index.php | 10 ++++++++++ blocks/library/verse/index.php | 10 ++++++++++ blocks/library/video/index.php | 10 ++++++++++ 24 files changed, 240 insertions(+) diff --git a/blocks/library/audio/index.php b/blocks/library/audio/index.php index 8f86d8d56d2161..61a082bde54589 100644 --- a/blocks/library/audio/index.php +++ b/blocks/library/audio/index.php @@ -17,8 +17,18 @@ function register_core_audio_block() { wp_style_add_data( 'core-audio-block', 'rtl', 'replace' ); + wp_register_style( + 'core-audio-block-editor', + gutenberg_url( '/build/__block_audio_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_audio_editor.css' ) + ); + + wp_style_add_data( 'core-audio-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/audio', array( 'style' => 'core-audio-block', + 'editor_style' => 'core-audio-block-editor', 'editor_script' => 'core-audio-block', ) ); } diff --git a/blocks/library/button/index.php b/blocks/library/button/index.php index a9575ef978e02b..6cca91c9428178 100644 --- a/blocks/library/button/index.php +++ b/blocks/library/button/index.php @@ -17,8 +17,18 @@ function register_core_button_block() { wp_style_add_data( 'core-button-block', 'rtl', 'replace' ); + wp_register_style( + 'core-button-block-editor', + gutenberg_url( '/build/__block_button_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_button_editor.css' ) + ); + + wp_style_add_data( 'core-button-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/button', array( 'style' => 'core-button-block', + 'editor_style' => 'core-button-block-editor', 'editor_script' => 'core-button-block', ) ); } diff --git a/blocks/library/categories/index.php b/blocks/library/categories/index.php index 58fc82f6c7193b..80bffeaf9ca668 100644 --- a/blocks/library/categories/index.php +++ b/blocks/library/categories/index.php @@ -96,8 +96,18 @@ function register_core_categories_block() { wp_style_add_data( 'core-categories-block', 'rtl', 'replace' ); + wp_register_style( + 'core-categories-block-editor', + gutenberg_url( '/build/__block_categories_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_categories_editor.css' ) + ); + + wp_style_add_data( 'core-categories-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/categories', array( 'style' => 'core-categories-block', + 'editor_style' => 'core-categories-block-editor', 'editor_script' => 'core-categories-block', 'render_callback' => 'gutenberg_render_block_core_categories', ) ); diff --git a/blocks/library/code/index.php b/blocks/library/code/index.php index e1a47a57fad26c..368a9da3a13c16 100644 --- a/blocks/library/code/index.php +++ b/blocks/library/code/index.php @@ -8,7 +8,17 @@ function register_core_code_block() { wp_register_script( 'core-code-block', gutenberg_url( '/build/__block_code.js' ) ); + wp_register_style( + 'core-code-block-editor', + gutenberg_url( '/build/__block_code_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_code_editor.css' ) + ); + + wp_style_add_data( 'core-code-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/code', array( + 'editor_style' => 'core-code-block-editor', 'editor_script' => 'core-code-block', ) ); } diff --git a/blocks/library/cover-image/index.php b/blocks/library/cover-image/index.php index d5dc385a27b772..6f794cddbc95e7 100644 --- a/blocks/library/cover-image/index.php +++ b/blocks/library/cover-image/index.php @@ -17,8 +17,18 @@ function register_core_cover_image_block() { wp_style_add_data( 'core-cover-image-block', 'rtl', 'replace' ); + wp_register_style( + 'core-cover-image-block-editor', + gutenberg_url( '/build/__block_coverImage_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_coverImage_editor.css' ) + ); + + wp_style_add_data( 'core-cover-image-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/cover-image', array( 'style' => 'core-cover-image-block', + 'editor_style' => 'core-cover-image-block-editor', 'editor_script' => 'core-cover-image-block', ) ); } diff --git a/blocks/library/embed/index.php b/blocks/library/embed/index.php index b811b2cf167b73..58417f8e7a5ac9 100644 --- a/blocks/library/embed/index.php +++ b/blocks/library/embed/index.php @@ -17,8 +17,18 @@ function register_core_embed_block() { wp_style_add_data( 'core-embed-block', 'rtl', 'replace' ); + wp_register_style( + 'core-embed-block-editor', + gutenberg_url( '/build/__block_embed_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_embed_editor.css' ) + ); + + wp_style_add_data( 'core-embed-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/embed', array( 'style' => 'core-embed-block', + 'editor_style' => 'core-embed-block-editor', 'editor_script' => 'core-embed-block', ) ); } diff --git a/blocks/library/freeform/index.php b/blocks/library/freeform/index.php index 202b238a882b48..b4c45c77de1f48 100644 --- a/blocks/library/freeform/index.php +++ b/blocks/library/freeform/index.php @@ -8,7 +8,17 @@ function register_core_freeform_block() { wp_register_script( 'core-freeform-block', gutenberg_url( '/build/__block_freeform.js' ) ); + wp_register_style( + 'core-freeform-block-editor', + gutenberg_url( '/build/__block_freeform_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_freeform_editor.css' ) + ); + + wp_style_add_data( 'core-freeform-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/freeform', array( + 'editor_style' => 'core-freeform-block-editor', 'editor_script' => 'core-freeform-block', ) ); } diff --git a/blocks/library/gallery/index.php b/blocks/library/gallery/index.php index 55e09814c1a532..dbbb24dae7a2f1 100644 --- a/blocks/library/gallery/index.php +++ b/blocks/library/gallery/index.php @@ -17,8 +17,18 @@ function register_core_gallery_block() { wp_style_add_data( 'core-gallery-block', 'rtl', 'replace' ); + wp_register_style( + 'core-gallery-block-editor', + gutenberg_url( '/build/__block_gallery_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_gallery_editor.css' ) + ); + + wp_style_add_data( 'core-gallery-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/gallery', array( 'style' => 'core-gallery-block', + 'editor_style' => 'core-gallery-block-editor', 'editor_script' => 'core-gallery-block', ) ); diff --git a/blocks/library/heading/index.php b/blocks/library/heading/index.php index 072e6d9fb52dad..b48ffec4024527 100644 --- a/blocks/library/heading/index.php +++ b/blocks/library/heading/index.php @@ -8,7 +8,17 @@ function register_core_heading_block() { wp_register_script( 'core-heading-block', gutenberg_url( '/build/__block_heading.js' ) ); + wp_register_style( + 'core-heading-block-editor', + gutenberg_url( '/build/__block_heading_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_heading_editor.css' ) + ); + + wp_style_add_data( 'core-heading-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/heading', array( + 'editor_style' => 'core-heading-block-editor', 'editor_script' => 'core-heading-block', ) ); } diff --git a/blocks/library/html/index.php b/blocks/library/html/index.php index 389db4b95324d8..c7c63d0cc0367e 100644 --- a/blocks/library/html/index.php +++ b/blocks/library/html/index.php @@ -8,7 +8,17 @@ function register_core_html_block() { wp_register_script( 'core-html-block', gutenberg_url( '/build/__block_html.js' ) ); + wp_register_style( + 'core-html-block-editor', + gutenberg_url( '/build/__block_html_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_html_editor.css' ) + ); + + wp_style_add_data( 'core-html-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/html', array( + 'editor_style' => 'core-html-block-editor', 'editor_script' => 'core-html-block', ) ); } diff --git a/blocks/library/image/index.php b/blocks/library/image/index.php index c20653ea46b1ee..c7a0ecd2a6619f 100644 --- a/blocks/library/image/index.php +++ b/blocks/library/image/index.php @@ -17,8 +17,18 @@ function register_core_image_block() { wp_style_add_data( 'core-image-block', 'rtl', 'replace' ); + wp_register_style( + 'core-image-block-editor', + gutenberg_url( '/build/__block_image_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_image_editor.css' ) + ); + + wp_style_add_data( 'core-image-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/image', array( 'style' => 'core-image-block', + 'editor_style' => 'core-image-block-editor', 'editor_script' => 'core-image-block', ) ); } diff --git a/blocks/library/latest-posts/index.php b/blocks/library/latest-posts/index.php index 6a9126cf5354e8..40b2b6bf397e8a 100644 --- a/blocks/library/latest-posts/index.php +++ b/blocks/library/latest-posts/index.php @@ -77,8 +77,18 @@ function register_core_latest_posts_block() { wp_style_add_data( 'core-latest-posts-block', 'rtl', 'replace' ); + wp_register_style( + 'core-latest-posts-block-editor', + gutenberg_url( '/build/__block_latestPosts_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_latestPosts_editor.css' ) + ); + + wp_style_add_data( 'core-latest-posts-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/latest-posts', array( 'style' => 'core-latest-posts-block', + 'editor_style' => 'core-latest-posts-block-editor', 'editor_script' => 'core-latest-posts-block', 'attributes' => array( 'categories' => array( diff --git a/blocks/library/list/index.php b/blocks/library/list/index.php index 3f70a8316c25a0..5b953193430962 100644 --- a/blocks/library/list/index.php +++ b/blocks/library/list/index.php @@ -8,7 +8,17 @@ function register_core_list_block() { wp_register_script( 'core-list-block', gutenberg_url( '/build/__block_list.js' ) ); + wp_register_style( + 'core-list-block-editor', + gutenberg_url( '/build/__block_list_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_list_editor.css' ) + ); + + wp_style_add_data( 'core-list-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/list', array( + 'editor_style' => 'core-list-block-editor', 'editor_script' => 'core-list-block', ) ); } diff --git a/blocks/library/more/index.php b/blocks/library/more/index.php index 7f38045eab35fc..99dd872dee8c1f 100644 --- a/blocks/library/more/index.php +++ b/blocks/library/more/index.php @@ -8,7 +8,17 @@ function register_core_more_block() { wp_register_script( 'core-more-block', gutenberg_url( '/build/__block_more.js' ) ); + wp_register_style( + 'core-more-block-editor', + gutenberg_url( '/build/__block_more_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_more_editor.css' ) + ); + + wp_style_add_data( 'core-more-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/more', array( + 'editor_style' => 'core-more-block-editor', 'editor_script' => 'core-more-block', ) ); } diff --git a/blocks/library/paragraph/index.php b/blocks/library/paragraph/index.php index 42dd649556ae98..0b29ed84467ff7 100644 --- a/blocks/library/paragraph/index.php +++ b/blocks/library/paragraph/index.php @@ -17,8 +17,18 @@ function register_core_paragraph_block() { wp_style_add_data( 'core-paragraph-block', 'rtl', 'replace' ); + wp_register_style( + 'core-paragraph-block-editor', + gutenberg_url( '/build/__block_paragraph_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_paragraph_editor.css' ) + ); + + wp_style_add_data( 'core-paragraph-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/paragraph', array( 'style' => 'core-paragraph-block', + 'editor_style' => 'core-paragraph-block-editor', 'editor_script' => 'core-paragraph-block', ) ); } diff --git a/blocks/library/preformatted/index.php b/blocks/library/preformatted/index.php index b11cc935ffe018..1ada23fc744c27 100644 --- a/blocks/library/preformatted/index.php +++ b/blocks/library/preformatted/index.php @@ -8,7 +8,17 @@ function register_core_preformatted_block() { wp_register_script( 'core-preformatted-block', gutenberg_url( '/build/__block_preformatted.js' ) ); + wp_register_style( + 'core-preformatted-block-editor', + gutenberg_url( '/build/__block_preformatted_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_preformatted_editor.css' ) + ); + + wp_style_add_data( 'core-preformatted-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/preformatted', array( + 'editor_style' => 'core-preformatted-block-editor', 'editor_script' => 'core-preformatted-block', ) ); } diff --git a/blocks/library/pullquote/index.php b/blocks/library/pullquote/index.php index 09d4c41dab576d..2fcec9985b4f54 100644 --- a/blocks/library/pullquote/index.php +++ b/blocks/library/pullquote/index.php @@ -17,8 +17,18 @@ function register_core_pullquote_block() { wp_style_add_data( 'core-pullquote-block', 'rtl', 'replace' ); + wp_register_style( + 'core-pullquote-block-editor', + gutenberg_url( '/build/__block_pullquote_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_pullquote_editor.css' ) + ); + + wp_style_add_data( 'core-pullquote-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/pullquote', array( 'style' => 'core-pullquote-block', + 'editor_style' => 'core-pullquote-block-editor', 'editor_script' => 'core-pullquote-block', ) ); } diff --git a/blocks/library/quote/index.php b/blocks/library/quote/index.php index af843e9b306b92..f385f967b9ef13 100644 --- a/blocks/library/quote/index.php +++ b/blocks/library/quote/index.php @@ -17,8 +17,18 @@ function register_core_quote_block() { wp_style_add_data( 'core-quote-block', 'rtl', 'replace' ); + wp_register_style( + 'core-quote-block-editor', + gutenberg_url( '/build/__block_quote_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_quote_editor.css' ) + ); + + wp_style_add_data( 'core-quote-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/quote', array( 'style' => 'core-quote-block', + 'editor_style' => 'core-quote-block-editor', 'editor_script' => 'core-quote-block', ) ); } diff --git a/blocks/library/shortcode/index.php b/blocks/library/shortcode/index.php index fdf50fcec81394..de8ef3703c2186 100644 --- a/blocks/library/shortcode/index.php +++ b/blocks/library/shortcode/index.php @@ -8,7 +8,17 @@ function register_core_shortcode_block() { wp_register_script( 'core-shortcode-block', gutenberg_url( '/build/__block_shortcode.js' ) ); + wp_register_style( + 'core-shortcode-block-editor', + gutenberg_url( '/build/__block_shortcode_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_shortcode_editor.css' ) + ); + + wp_style_add_data( 'core-shortcode-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/shortcode', array( + 'editor_style' => 'core-shortcode-block-editor', 'editor_script' => 'core-shortcode-block', ) ); } diff --git a/blocks/library/subhead/index.php b/blocks/library/subhead/index.php index e598e00d41f811..d2dc0f537234fc 100644 --- a/blocks/library/subhead/index.php +++ b/blocks/library/subhead/index.php @@ -17,8 +17,18 @@ function register_core_subhead_block() { wp_style_add_data( 'core-subhead-block', 'rtl', 'replace' ); + wp_register_style( + 'core-subhead-block-editor', + gutenberg_url( '/build/__block_subhead_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_subhead_editor.css' ) + ); + + wp_style_add_data( 'core-subhead-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/subhead', array( 'style' => 'core-subhead-block', + 'editor_style' => 'core-subhead-block-editor', 'editor_script' => 'core-subhead-block', ) ); } diff --git a/blocks/library/table/index.php b/blocks/library/table/index.php index e29b1cccdc9f49..9b035a71791144 100644 --- a/blocks/library/table/index.php +++ b/blocks/library/table/index.php @@ -17,8 +17,18 @@ function register_core_table_block() { wp_style_add_data( 'core-table-block', 'rtl', 'replace' ); + wp_register_style( + 'core-table-block-editor', + gutenberg_url( '/build/__block_table_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_table_editor.css' ) + ); + + wp_style_add_data( 'core-table-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/table', array( 'style' => 'core-table-block', + 'editor_style' => 'core-table-block-editor', 'editor_script' => 'core-table-block', ) ); } diff --git a/blocks/library/text-columns/index.php b/blocks/library/text-columns/index.php index 79fafa0bea3e62..628f03e349b28a 100644 --- a/blocks/library/text-columns/index.php +++ b/blocks/library/text-columns/index.php @@ -17,8 +17,18 @@ function register_core_text_columns_block() { wp_style_add_data( 'core-text-columns-block', 'rtl', 'replace' ); + wp_register_style( + 'core-text-columns-block-editor', + gutenberg_url( '/build/__block_textColumns_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_textColumns_editor.css' ) + ); + + wp_style_add_data( 'core-text-columns-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/text-columns', array( 'style' => 'core-text-columns-block', + 'editor_style' => 'core-text-columns-block-editor', 'editor_script' => 'core-text-columns-block', ) ); } diff --git a/blocks/library/verse/index.php b/blocks/library/verse/index.php index e0dc3fb303e7ee..513868203c941b 100644 --- a/blocks/library/verse/index.php +++ b/blocks/library/verse/index.php @@ -8,7 +8,17 @@ function register_core_verse_block() { wp_register_script( 'core-verse-block', gutenberg_url( '/build/__block_verse.js' ) ); + wp_register_style( + 'core-verse-block-editor', + gutenberg_url( '/build/__block_verse_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_verse_editor.css' ) + ); + + wp_style_add_data( 'core-verse-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/verse', array( + 'editor_style' => 'core-verse-block-editor', 'editor_script' => 'core-verse-block', ) ); } diff --git a/blocks/library/video/index.php b/blocks/library/video/index.php index b0663abc1389e9..fe030efd606888 100644 --- a/blocks/library/video/index.php +++ b/blocks/library/video/index.php @@ -17,8 +17,18 @@ function register_core_video_block() { wp_style_add_data( 'core-video-block', 'rtl', 'replace' ); + wp_register_style( + 'core-video-block-editor', + gutenberg_url( '/build/__block_video_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_video_editor.css' ) + ); + + wp_style_add_data( 'core-video-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/video', array( 'style' => 'core-video-block', + 'editor_style' => 'core-video-block-editor', 'editor_script' => 'core-video-block', ) ); } From fd3aab2734e1e08fa553f0ff7c28154913439441 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Sun, 8 Apr 2018 16:48:35 +0530 Subject: [PATCH 10/41] Removed 'wp-edit-blocks' style registration Since editor-specific styles for individual blocks are enqueued separately now, there is no need to register the 'wp-edit-blocks' style handle now. --- lib/client-assets.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index e4f34c95da56d7..10f0123f8b3f6f 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -183,7 +183,7 @@ function gutenberg_register_scripts_and_styles() { wp_register_style( 'wp-editor', gutenberg_url( 'editor/build/style.css' ), - array( 'wp-components', 'wp-blocks', 'wp-edit-blocks', 'wp-editor-font' ), + array( 'wp-components', 'wp-blocks', 'wp-editor-font' ), filemtime( gutenberg_dir_path() . 'editor/build/style.css' ) ); wp_style_add_data( 'wp-editor', 'rtl', 'replace' ); @@ -211,14 +211,6 @@ function gutenberg_register_scripts_and_styles() { filemtime( gutenberg_dir_path() . 'blocks/build/style.css' ) ); wp_style_add_data( 'wp-blocks', 'rtl', 'replace' ); - - wp_register_style( - 'wp-edit-blocks', - gutenberg_url( 'blocks/build/edit-blocks.css' ), - array(), - filemtime( gutenberg_dir_path() . 'blocks/build/edit-blocks.css' ) - ); - wp_style_add_data( 'wp-edit-blocks', 'rtl', 'replace' ); } add_action( 'wp_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5 ); add_action( 'admin_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5 ); From ef8c868737eab8456c9737100db06e374a8b3dda Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Mon, 9 Apr 2018 20:47:49 +0530 Subject: [PATCH 11/41] Modified Webpack configuration to use separate CSS loader for each block's individual styles --- webpack.config.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 924b712c86cbb4..c2dba5d24c6f36 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -23,9 +23,14 @@ const editBlocksCSSPlugin = new ExtractTextPlugin( { filename: './build/[name]_editor.css', } ); -// CSS loader for styles specific to blocks in general. -const blocksCSSPlugin = new ExtractTextPlugin( { - filename: './build/[name].css', +// CSS loader for each individual block's styles +const individualBlocksCSSPlugin = new ExtractTextPlugin( { + filename: './build/[name].css' +} ); + +// CSS loader for common styles specific to blocks in general. +const commonBlocksCSSPlugin = new ExtractTextPlugin( { + filename: './blocks/build/style.css', } ); // Configuration for the ExtractTextPlugin. @@ -158,7 +163,17 @@ const config = { include: [ /blocks/, ], - use: blocksCSSPlugin.extract( extractConfig ), + exclude: [ + /blocks\/library/, + ], + use: commonBlocksCSSPlugin.extract( extractConfig ), + }, + { + test: /style\.s?css$/, + include: [ + /blocks\/library/, + ], + use: individualBlocksCSSPlugin.extract( extractConfig ), }, { test: /editor\.s?css$/, @@ -177,7 +192,8 @@ const config = { ], }, plugins: [ - blocksCSSPlugin, + commonBlocksCSSPlugin, + individualBlocksCSSPlugin, editBlocksCSSPlugin, mainCSSExtractTextPlugin, // Create RTL files with a -rtl suffix From 191561e2b5afc332a39496766d3492d64c467442 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Mon, 9 Apr 2018 22:28:24 +0530 Subject: [PATCH 12/41] Undid tuples configuration for entry points in Webpack Configuration --- webpack.config.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index c2dba5d24c6f36..eaa76cd4381db2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -4,7 +4,6 @@ const ExtractTextPlugin = require( 'extract-text-webpack-plugin' ); const WebpackRTLPlugin = require( 'webpack-rtl-plugin' ); const fs = require( 'fs' ); -const { camelCase, castArray } = require( 'lodash' ); const { get } = require( 'lodash' ); const { basename } = require( 'path' ); @@ -86,11 +85,10 @@ const entryPointNames = [ 'viewport', 'core-data', 'plugins', - [ 'editPost', 'edit-post' ], - ...fs.readdirSync( './blocks/library' ).map( ( block ) => [ - '__block_' + camelCase( block ), - 'blocks/library/' + block, - ] ), + 'edit-post', + ...fs.readdirSync( './blocks/library' ).map( ( block ) => + 'blocks/library/' + block + ), ]; const packageNames = [ @@ -123,10 +121,9 @@ const config = { mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', entry: Object.assign( - entryPointNames.reduce( ( memo, entryPoint ) => { - entryPoint = castArray( entryPoint ); - const [ name, path = name ] = entryPoint; - memo[ name ] = `./${ path }/index.js`; + entryPointNames.reduce( ( memo, path ) => { + const name = camelCaseDash( path ); + memo[ name ] = `./${ path }`; return memo; }, {} ), packageNames.reduce( ( memo, packageName ) => { From 0dc5a6e924c106995d167786516c7e3e38771e98 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Tue, 10 Apr 2018 00:34:49 +0530 Subject: [PATCH 13/41] Changed relative paths of style, editor_style and editor_script attributes for individual blocks Since the Webpack configuration now builds individual blocks to /build/blocks/library/, relative paths of style, editor_style and editor_script attributes have been changed in server side code for individual blocks. --- blocks/library/audio/index.php | 12 ++++++------ blocks/library/block/index.php | 2 +- blocks/library/button/index.php | 10 +++++----- blocks/library/categories/index.php | 10 +++++----- blocks/library/code/index.php | 6 +++--- blocks/library/cover-image/index.php | 10 +++++----- blocks/library/embed/index.php | 10 +++++----- blocks/library/freeform/index.php | 6 +++--- blocks/library/gallery/index.php | 10 +++++----- blocks/library/heading/index.php | 6 +++--- blocks/library/html/index.php | 6 +++--- blocks/library/image/index.php | 10 +++++----- blocks/library/latest-posts/index.php | 10 +++++----- blocks/library/list/index.php | 6 +++--- blocks/library/more/index.php | 6 +++--- blocks/library/paragraph/index.php | 10 +++++----- blocks/library/preformatted/index.php | 6 +++--- blocks/library/pullquote/index.php | 10 +++++----- blocks/library/quote/index.php | 10 +++++----- blocks/library/separator/index.php | 6 +++--- blocks/library/shortcode/index.php | 6 +++--- blocks/library/subhead/index.php | 10 +++++----- blocks/library/table/index.php | 10 +++++----- blocks/library/text-columns/index.php | 10 +++++----- blocks/library/verse/index.php | 6 +++--- blocks/library/video/index.php | 10 +++++----- 26 files changed, 107 insertions(+), 107 deletions(-) diff --git a/blocks/library/audio/index.php b/blocks/library/audio/index.php index 61a082bde54589..dfda93cce3526c 100644 --- a/blocks/library/audio/index.php +++ b/blocks/library/audio/index.php @@ -6,22 +6,22 @@ */ function register_core_audio_block() { - wp_register_script( 'core-audio-block', gutenberg_url( '/build/__block_audio.js' ) ); + wp_register_script( 'core-audio-block', gutenberg_url( '/build/blocks/library/audio.js' ) ); wp_register_style( 'core-audio-block', - gutenberg_url( '/build/__block_audio.css' ), + gutenberg_url( '/build/blocks/library/audio.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_audio.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/audio.css' ) ); wp_style_add_data( 'core-audio-block', 'rtl', 'replace' ); wp_register_style( 'core-audio-block-editor', - gutenberg_url( '/build/__block_audio_editor.css' ), + gutenberg_url( '/build/blocks/library/audio_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_audio_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/audio_editor.css' ) ); wp_style_add_data( 'core-audio-block-editor', 'rtl', 'replace' ); @@ -33,4 +33,4 @@ function register_core_audio_block() { ) ); } -add_action( 'init', 'register_core_audio_block' ); +add_action( 'init', 'register_core_audio_block' ); \ No newline at end of file diff --git a/blocks/library/block/index.php b/blocks/library/block/index.php index a21fd0645d188b..5674427fcf341b 100644 --- a/blocks/library/block/index.php +++ b/blocks/library/block/index.php @@ -33,7 +33,7 @@ function gutenberg_render_core_reusable_block( $attributes ) { } function register_core_reusable_block() { - wp_register_script( 'core-reusable-block', gutenberg_url( '/build/__block_block.js' ) ); + wp_register_script( 'core-reusable-block', gutenberg_url( '/build/blocks/library/block.js' ) ); register_block_type( 'core/block', array( 'editor_script' => 'core-reusable-block', diff --git a/blocks/library/button/index.php b/blocks/library/button/index.php index 6cca91c9428178..a896a9c021b1a0 100644 --- a/blocks/library/button/index.php +++ b/blocks/library/button/index.php @@ -6,22 +6,22 @@ */ function register_core_button_block() { - wp_register_script( 'core-button-block', gutenberg_url( '/build/__block_button.js' ) ); + wp_register_script( 'core-button-block', gutenberg_url( '/build/blocks/library/button.js' ) ); wp_register_style( 'core-button-block', - gutenberg_url( '/build/__block_button.css' ), + gutenberg_url( '/build/blocks/library/button.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_button.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/button.css' ) ); wp_style_add_data( 'core-button-block', 'rtl', 'replace' ); wp_register_style( 'core-button-block-editor', - gutenberg_url( '/build/__block_button_editor.css' ), + gutenberg_url( '/build/blocks/library/button_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_button_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/button_editor.css' ) ); wp_style_add_data( 'core-button-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/categories/index.php b/blocks/library/categories/index.php index 7cec30f27609e1..31231adc949640 100644 --- a/blocks/library/categories/index.php +++ b/blocks/library/categories/index.php @@ -85,22 +85,22 @@ function onCatChange() { } function register_core_categories_block() { - wp_register_script( 'core-categories-block', gutenberg_url( '/build/__block_categories.js' ) ); + wp_register_script( 'core-categories-block', gutenberg_url( '/build/blocks/library/categories.js' ) ); wp_register_style( 'core-categories-block', - gutenberg_url( '/build/__block_categories.css' ), + gutenberg_url( '/build/blocks/library/categories.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_categories.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/categories.css' ) ); wp_style_add_data( 'core-categories-block', 'rtl', 'replace' ); wp_register_style( 'core-categories-block-editor', - gutenberg_url( '/build/__block_categories_editor.css' ), + gutenberg_url( '/build/blocks/library/categories_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_categories_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/categories_editor.css' ) ); wp_style_add_data( 'core-categories-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/code/index.php b/blocks/library/code/index.php index 368a9da3a13c16..dd70f84d9fcddc 100644 --- a/blocks/library/code/index.php +++ b/blocks/library/code/index.php @@ -6,13 +6,13 @@ */ function register_core_code_block() { - wp_register_script( 'core-code-block', gutenberg_url( '/build/__block_code.js' ) ); + wp_register_script( 'core-code-block', gutenberg_url( '/build/blocks/library/code.js' ) ); wp_register_style( 'core-code-block-editor', - gutenberg_url( '/build/__block_code_editor.css' ), + gutenberg_url( '/build/blocks/library/code_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_code_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/code_editor.css' ) ); wp_style_add_data( 'core-code-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/cover-image/index.php b/blocks/library/cover-image/index.php index 6f794cddbc95e7..57672a8998c9a0 100644 --- a/blocks/library/cover-image/index.php +++ b/blocks/library/cover-image/index.php @@ -6,22 +6,22 @@ */ function register_core_cover_image_block() { - wp_register_script( 'core-cover-image-block', gutenberg_url( '/build/__block_coverImage.js' ) ); + wp_register_script( 'core-cover-image-block', gutenberg_url( '/build/blocks/library/coverImage.js' ) ); wp_register_style( 'core-cover-image-block', - gutenberg_url( '/build/__block_coverImage.css' ), + gutenberg_url( '/build/blocks/library/coverImage.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_coverImage.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/coverImage.css' ) ); wp_style_add_data( 'core-cover-image-block', 'rtl', 'replace' ); wp_register_style( 'core-cover-image-block-editor', - gutenberg_url( '/build/__block_coverImage_editor.css' ), + gutenberg_url( '/build/blocks/library/coverImage_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_coverImage_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/coverImage_editor.css' ) ); wp_style_add_data( 'core-cover-image-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/embed/index.php b/blocks/library/embed/index.php index 58417f8e7a5ac9..0eecc63b5b794e 100644 --- a/blocks/library/embed/index.php +++ b/blocks/library/embed/index.php @@ -6,22 +6,22 @@ */ function register_core_embed_block() { - wp_register_script( 'core-embed-block', gutenberg_url( '/build/__block_embed.js' ) ); + wp_register_script( 'core-embed-block', gutenberg_url( '/build/blocks/library/embed.js' ) ); wp_register_style( 'core-embed-block', - gutenberg_url( '/build/__block_embed.css' ), + gutenberg_url( '/build/blocks/library/embed.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_embed.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/embed.css' ) ); wp_style_add_data( 'core-embed-block', 'rtl', 'replace' ); wp_register_style( 'core-embed-block-editor', - gutenberg_url( '/build/__block_embed_editor.css' ), + gutenberg_url( '/build/blocks/library/embed_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_embed_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/embed_editor.css' ) ); wp_style_add_data( 'core-embed-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/freeform/index.php b/blocks/library/freeform/index.php index b4c45c77de1f48..04079d7df3e818 100644 --- a/blocks/library/freeform/index.php +++ b/blocks/library/freeform/index.php @@ -6,13 +6,13 @@ */ function register_core_freeform_block() { - wp_register_script( 'core-freeform-block', gutenberg_url( '/build/__block_freeform.js' ) ); + wp_register_script( 'core-freeform-block', gutenberg_url( '/build/blocks/library/freeform.js' ) ); wp_register_style( 'core-freeform-block-editor', - gutenberg_url( '/build/__block_freeform_editor.css' ), + gutenberg_url( '/build/blocks/library/freeform_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_freeform_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/freeform_editor.css' ) ); wp_style_add_data( 'core-freeform-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/gallery/index.php b/blocks/library/gallery/index.php index dbbb24dae7a2f1..a6deca2e7b9f94 100644 --- a/blocks/library/gallery/index.php +++ b/blocks/library/gallery/index.php @@ -6,22 +6,22 @@ */ function register_core_gallery_block() { - wp_register_script( 'core-gallery-block', gutenberg_url( '/build/__block_gallery.js' ) ); + wp_register_script( 'core-gallery-block', gutenberg_url( '/build/blocks/library/gallery.js' ) ); wp_register_style( 'core-gallery-block', - gutenberg_url( '/build/__block_gallery.css' ), + gutenberg_url( '/build/blocks/library/gallery.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_gallery.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/gallery.css' ) ); wp_style_add_data( 'core-gallery-block', 'rtl', 'replace' ); wp_register_style( 'core-gallery-block-editor', - gutenberg_url( '/build/__block_gallery_editor.css' ), + gutenberg_url( '/build/blocks/library/gallery_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_gallery_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/gallery_editor.css' ) ); wp_style_add_data( 'core-gallery-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/heading/index.php b/blocks/library/heading/index.php index b48ffec4024527..21e4f630bea0c4 100644 --- a/blocks/library/heading/index.php +++ b/blocks/library/heading/index.php @@ -6,13 +6,13 @@ */ function register_core_heading_block() { - wp_register_script( 'core-heading-block', gutenberg_url( '/build/__block_heading.js' ) ); + wp_register_script( 'core-heading-block', gutenberg_url( '/build/blocks/library/heading.js' ) ); wp_register_style( 'core-heading-block-editor', - gutenberg_url( '/build/__block_heading_editor.css' ), + gutenberg_url( '/build/blocks/library/heading_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_heading_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/heading_editor.css' ) ); wp_style_add_data( 'core-heading-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/html/index.php b/blocks/library/html/index.php index c7c63d0cc0367e..e21dae6706d0b3 100644 --- a/blocks/library/html/index.php +++ b/blocks/library/html/index.php @@ -6,13 +6,13 @@ */ function register_core_html_block() { - wp_register_script( 'core-html-block', gutenberg_url( '/build/__block_html.js' ) ); + wp_register_script( 'core-html-block', gutenberg_url( '/build/blocks/library/html.js' ) ); wp_register_style( 'core-html-block-editor', - gutenberg_url( '/build/__block_html_editor.css' ), + gutenberg_url( '/build/blocks/library/html_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_html_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/html_editor.css' ) ); wp_style_add_data( 'core-html-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/image/index.php b/blocks/library/image/index.php index c7a0ecd2a6619f..c0601ce0034805 100644 --- a/blocks/library/image/index.php +++ b/blocks/library/image/index.php @@ -6,22 +6,22 @@ */ function register_core_image_block() { - wp_register_script( 'core-image-block', gutenberg_url( '/build/__block_image.js' ) ); + wp_register_script( 'core-image-block', gutenberg_url( '/build/blocks/library/image.js' ) ); wp_register_style( 'core-image-block', - gutenberg_url( '/build/__block_image.css' ), + gutenberg_url( '/build/blocks/library/image.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_image.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/image.css' ) ); wp_style_add_data( 'core-image-block', 'rtl', 'replace' ); wp_register_style( 'core-image-block-editor', - gutenberg_url( '/build/__block_image_editor.css' ), + gutenberg_url( '/build/blocks/library/image_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_image_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/image_editor.css' ) ); wp_style_add_data( 'core-image-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/latest-posts/index.php b/blocks/library/latest-posts/index.php index f841caf91d0079..3da9d182422ba7 100644 --- a/blocks/library/latest-posts/index.php +++ b/blocks/library/latest-posts/index.php @@ -66,22 +66,22 @@ function gutenberg_render_core_latest_posts_block( $attributes ) { } function register_core_latest_posts_block() { - wp_register_script( 'core-latest-posts-block', gutenberg_url( '/build/__block_latestPosts.js' ) ); + wp_register_script( 'core-latest-posts-block', gutenberg_url( '/build/blocks/library/latestPosts.js' ) ); wp_register_style( 'core-latest-posts-block', - gutenberg_url( '/build/__block_latestPosts.css' ), + gutenberg_url( '/build/blocks/library/latestPosts.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_latestPosts.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/latestPosts.css' ) ); wp_style_add_data( 'core-latest-posts-block', 'rtl', 'replace' ); wp_register_style( 'core-latest-posts-block-editor', - gutenberg_url( '/build/__block_latestPosts_editor.css' ), + gutenberg_url( '/build/blocks/library/latestPosts_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_latestPosts_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/latestPosts_editor.css' ) ); wp_style_add_data( 'core-latest-posts-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/list/index.php b/blocks/library/list/index.php index 5b953193430962..c5e904c1d0d5f8 100644 --- a/blocks/library/list/index.php +++ b/blocks/library/list/index.php @@ -6,13 +6,13 @@ */ function register_core_list_block() { - wp_register_script( 'core-list-block', gutenberg_url( '/build/__block_list.js' ) ); + wp_register_script( 'core-list-block', gutenberg_url( '/build/blocks/library/list.js' ) ); wp_register_style( 'core-list-block-editor', - gutenberg_url( '/build/__block_list_editor.css' ), + gutenberg_url( '/build/blocks/library/list_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_list_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/list_editor.css' ) ); wp_style_add_data( 'core-list-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/more/index.php b/blocks/library/more/index.php index 99dd872dee8c1f..444a0ea5e29b88 100644 --- a/blocks/library/more/index.php +++ b/blocks/library/more/index.php @@ -6,13 +6,13 @@ */ function register_core_more_block() { - wp_register_script( 'core-more-block', gutenberg_url( '/build/__block_more.js' ) ); + wp_register_script( 'core-more-block', gutenberg_url( '/build/blocks/library/more.js' ) ); wp_register_style( 'core-more-block-editor', - gutenberg_url( '/build/__block_more_editor.css' ), + gutenberg_url( '/build/blocks/library/more_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_more_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/more_editor.css' ) ); wp_style_add_data( 'core-more-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/paragraph/index.php b/blocks/library/paragraph/index.php index 0b29ed84467ff7..f5fba6e698a476 100644 --- a/blocks/library/paragraph/index.php +++ b/blocks/library/paragraph/index.php @@ -6,22 +6,22 @@ */ function register_core_paragraph_block() { - wp_register_script( 'core-paragraph-block', gutenberg_url( '/build/__block_paragraph.js' ) ); + wp_register_script( 'core-paragraph-block', gutenberg_url( '/build/blocks/library/paragraph.js' ) ); wp_register_style( 'core-paragraph-block', - gutenberg_url( '/build/__block_paragraph.css' ), + gutenberg_url( '/build/blocks/library/paragraph.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_paragraph.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/paragraph.css' ) ); wp_style_add_data( 'core-paragraph-block', 'rtl', 'replace' ); wp_register_style( 'core-paragraph-block-editor', - gutenberg_url( '/build/__block_paragraph_editor.css' ), + gutenberg_url( '/build/blocks/library/paragraph_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_paragraph_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/paragraph_editor.css' ) ); wp_style_add_data( 'core-paragraph-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/preformatted/index.php b/blocks/library/preformatted/index.php index 1ada23fc744c27..ac5463f05fc9b3 100644 --- a/blocks/library/preformatted/index.php +++ b/blocks/library/preformatted/index.php @@ -6,13 +6,13 @@ */ function register_core_preformatted_block() { - wp_register_script( 'core-preformatted-block', gutenberg_url( '/build/__block_preformatted.js' ) ); + wp_register_script( 'core-preformatted-block', gutenberg_url( '/build/blocks/library/preformatted.js' ) ); wp_register_style( 'core-preformatted-block-editor', - gutenberg_url( '/build/__block_preformatted_editor.css' ), + gutenberg_url( '/build/blocks/library/preformatted_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_preformatted_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/preformatted_editor.css' ) ); wp_style_add_data( 'core-preformatted-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/pullquote/index.php b/blocks/library/pullquote/index.php index 2fcec9985b4f54..702a214a22b9da 100644 --- a/blocks/library/pullquote/index.php +++ b/blocks/library/pullquote/index.php @@ -6,22 +6,22 @@ */ function register_core_pullquote_block() { - wp_register_script( 'core-pullquote-block', gutenberg_url( '/build/__block_pullquote.js' ) ); + wp_register_script( 'core-pullquote-block', gutenberg_url( '/build/blocks/library/pullquote.js' ) ); wp_register_style( 'core-pullquote-block', - gutenberg_url( '/build/__block_pullquote.css' ), + gutenberg_url( '/build/blocks/library/pullquote.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_pullquote.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/pullquote.css' ) ); wp_style_add_data( 'core-pullquote-block', 'rtl', 'replace' ); wp_register_style( 'core-pullquote-block-editor', - gutenberg_url( '/build/__block_pullquote_editor.css' ), + gutenberg_url( '/build/blocks/library/pullquote_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_pullquote_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/pullquote_editor.css' ) ); wp_style_add_data( 'core-pullquote-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/quote/index.php b/blocks/library/quote/index.php index f385f967b9ef13..1d3226deb1e0ef 100644 --- a/blocks/library/quote/index.php +++ b/blocks/library/quote/index.php @@ -6,22 +6,22 @@ */ function register_core_quote_block() { - wp_register_script( 'core-quote-block', gutenberg_url( '/build/__block_quote.js' ) ); + wp_register_script( 'core-quote-block', gutenberg_url( '/build/blocks/library/quote.js' ) ); wp_register_style( 'core-quote-block', - gutenberg_url( '/build/__block_quote.css' ), + gutenberg_url( '/build/blocks/library/quote.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_quote.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/quote.css' ) ); wp_style_add_data( 'core-quote-block', 'rtl', 'replace' ); wp_register_style( 'core-quote-block-editor', - gutenberg_url( '/build/__block_quote_editor.css' ), + gutenberg_url( '/build/blocks/library/quote_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_quote_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/quote_editor.css' ) ); wp_style_add_data( 'core-quote-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/separator/index.php b/blocks/library/separator/index.php index e0d5ab4d52dfb9..c135904a849f43 100644 --- a/blocks/library/separator/index.php +++ b/blocks/library/separator/index.php @@ -6,13 +6,13 @@ */ function register_core_separator_block() { - wp_register_script( 'core-separator-block', gutenberg_url( '/build/__block_separator.js' ) ); + wp_register_script( 'core-separator-block', gutenberg_url( '/build/blocks/library/separator.js' ) ); wp_register_style( 'core-separator-block', - gutenberg_url( '/build/__block_separator.css' ), + gutenberg_url( '/build/blocks/library/separator.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_separator.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/separator.css' ) ); wp_style_add_data( 'core-separator-block', 'rtl', 'replace' ); diff --git a/blocks/library/shortcode/index.php b/blocks/library/shortcode/index.php index de8ef3703c2186..f65acfd26523b0 100644 --- a/blocks/library/shortcode/index.php +++ b/blocks/library/shortcode/index.php @@ -6,13 +6,13 @@ */ function register_core_shortcode_block() { - wp_register_script( 'core-shortcode-block', gutenberg_url( '/build/__block_shortcode.js' ) ); + wp_register_script( 'core-shortcode-block', gutenberg_url( '/build/blocks/library/shortcode.js' ) ); wp_register_style( 'core-shortcode-block-editor', - gutenberg_url( '/build/__block_shortcode_editor.css' ), + gutenberg_url( '/build/blocks/library/shortcode_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_shortcode_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/shortcode_editor.css' ) ); wp_style_add_data( 'core-shortcode-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/subhead/index.php b/blocks/library/subhead/index.php index d2dc0f537234fc..7c2c070eedcd4f 100644 --- a/blocks/library/subhead/index.php +++ b/blocks/library/subhead/index.php @@ -6,22 +6,22 @@ */ function register_core_subhead_block() { - wp_register_script( 'core-subhead-block', gutenberg_url( '/build/__block_subhead.js' ) ); + wp_register_script( 'core-subhead-block', gutenberg_url( '/build/blocks/library/subhead.js' ) ); wp_register_style( 'core-subhead-block', - gutenberg_url( '/build/__block_subhead.css' ), + gutenberg_url( '/build/blocks/library/subhead.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_subhead.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/subhead.css' ) ); wp_style_add_data( 'core-subhead-block', 'rtl', 'replace' ); wp_register_style( 'core-subhead-block-editor', - gutenberg_url( '/build/__block_subhead_editor.css' ), + gutenberg_url( '/build/blocks/library/subhead_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_subhead_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/subhead_editor.css' ) ); wp_style_add_data( 'core-subhead-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/table/index.php b/blocks/library/table/index.php index 9b035a71791144..9a0e214aa182cd 100644 --- a/blocks/library/table/index.php +++ b/blocks/library/table/index.php @@ -6,22 +6,22 @@ */ function register_core_table_block() { - wp_register_script( 'core-table-block', gutenberg_url( '/build/__block_table.js' ) ); + wp_register_script( 'core-table-block', gutenberg_url( '/build/blocks/library/table.js' ) ); wp_register_style( 'core-table-block', - gutenberg_url( '/build/__block_table.css' ), + gutenberg_url( '/build/blocks/library/table.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_table.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/table.css' ) ); wp_style_add_data( 'core-table-block', 'rtl', 'replace' ); wp_register_style( 'core-table-block-editor', - gutenberg_url( '/build/__block_table_editor.css' ), + gutenberg_url( '/build/blocks/library/table_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_table_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/table_editor.css' ) ); wp_style_add_data( 'core-table-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/text-columns/index.php b/blocks/library/text-columns/index.php index 628f03e349b28a..e4aa4db5d90ebf 100644 --- a/blocks/library/text-columns/index.php +++ b/blocks/library/text-columns/index.php @@ -6,22 +6,22 @@ */ function register_core_text_columns_block() { - wp_register_script( 'core-text-columns-block', gutenberg_url( '/build/__block_textColumns.js' ) ); + wp_register_script( 'core-text-columns-block', gutenberg_url( '/build/blocks/library/textColumns.js' ) ); wp_register_style( 'core-text-columns-block', - gutenberg_url( '/build/__block_textColumns.css' ), + gutenberg_url( '/build/blocks/library/textColumns.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_textColumns.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/textColumns.css' ) ); wp_style_add_data( 'core-text-columns-block', 'rtl', 'replace' ); wp_register_style( 'core-text-columns-block-editor', - gutenberg_url( '/build/__block_textColumns_editor.css' ), + gutenberg_url( '/build/blocks/library/textColumns_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_textColumns_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/textColumns_editor.css' ) ); wp_style_add_data( 'core-text-columns-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/verse/index.php b/blocks/library/verse/index.php index 513868203c941b..84414de7d021b7 100644 --- a/blocks/library/verse/index.php +++ b/blocks/library/verse/index.php @@ -6,13 +6,13 @@ */ function register_core_verse_block() { - wp_register_script( 'core-verse-block', gutenberg_url( '/build/__block_verse.js' ) ); + wp_register_script( 'core-verse-block', gutenberg_url( '/build/blocks/library/verse.js' ) ); wp_register_style( 'core-verse-block-editor', - gutenberg_url( '/build/__block_verse_editor.css' ), + gutenberg_url( '/build/blocks/library/verse_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_verse_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/verse_editor.css' ) ); wp_style_add_data( 'core-verse-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/video/index.php b/blocks/library/video/index.php index fe030efd606888..e9be486abd1fcc 100644 --- a/blocks/library/video/index.php +++ b/blocks/library/video/index.php @@ -6,22 +6,22 @@ */ function register_core_video_block() { - wp_register_script( 'core-video-block', gutenberg_url( '/build/__block_video.js' ) ); + wp_register_script( 'core-video-block', gutenberg_url( '/build/blocks/library/video.js' ) ); wp_register_style( 'core-video-block', - gutenberg_url( '/build/__block_video.css' ), + gutenberg_url( '/build/blocks/library/video.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_video.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/video.css' ) ); wp_style_add_data( 'core-video-block', 'rtl', 'replace' ); wp_register_style( 'core-video-block-editor', - gutenberg_url( '/build/__block_video_editor.css' ), + gutenberg_url( '/build/blocks/library/video_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/__block_video_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks/library/video_editor.css' ) ); wp_style_add_data( 'core-video-block-editor', 'rtl', 'replace' ); From 4764672773006d3d054514ac0272f1f1125452e8 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Tue, 10 Apr 2018 00:40:46 +0530 Subject: [PATCH 14/41] Fixed relative paths of coreData.js and viewport.js in client-assets.php Since the Webpack configuration now builds scripts for core-data and viewport in build/ folder, the same have now been updated in client-assets.php --- lib/client-assets.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index 49909947689a58..a27d4afef634e1 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -85,9 +85,9 @@ function gutenberg_register_scripts_and_styles() { ); wp_register_script( 'wp-core-data', - gutenberg_url( 'build/core-data.js' ), + gutenberg_url( 'build/coreData.js' ), array( 'wp-data', 'wp-api-request' ), - filemtime( gutenberg_dir_path() . 'build/core-data.js' ), + filemtime( gutenberg_dir_path() . 'build/coreData.js' ), true ); wp_register_script( @@ -177,9 +177,9 @@ function gutenberg_register_scripts_and_styles() { ); wp_register_script( 'wp-viewport', - gutenberg_url( 'viewport/build/index.js' ), + gutenberg_url( 'build/viewport.js' ), array( 'wp-element', 'wp-data', 'wp-components' ), - filemtime( gutenberg_dir_path() . 'viewport/build/index.js' ), + filemtime( gutenberg_dir_path() . 'build/viewport.js' ), true ); // Loading the old editor and its config to ensure the classic block works as expected. From f12b5b6ffbee296de8addfef4bc37cc324578139 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Tue, 10 Apr 2018 02:19:56 +0530 Subject: [PATCH 15/41] Server-side registration for nextpage and columns blocks --- blocks/library/columns/index.js | 9 ++++---- blocks/library/columns/index.php | 36 +++++++++++++++++++++++++++++++ blocks/library/nextpage/index.js | 11 +++++----- blocks/library/nextpage/index.php | 26 ++++++++++++++++++++++ test/unit/setup-wp-aliases.js | 2 +- 5 files changed, 74 insertions(+), 10 deletions(-) create mode 100644 blocks/library/columns/index.php create mode 100644 blocks/library/nextpage/index.php diff --git a/blocks/library/columns/index.js b/blocks/library/columns/index.js index 011cfa37702c28..fec6d75ed2d89b 100644 --- a/blocks/library/columns/index.js +++ b/blocks/library/columns/index.js @@ -9,6 +9,9 @@ import memoize from 'memize'; * WordPress dependencies */ import { __, sprintf } from '@wordpress/i18n'; +import { + registerBlockType +} from '@wordpress/blocks'; import { PanelBody, RangeControl } from '@wordpress/components'; /** @@ -36,9 +39,7 @@ const getColumnLayouts = memoize( ( columns ) => { } ) ); } ); -export const name = 'core/columns'; - -export const settings = { +registerBlockType( 'core/columns', { title: sprintf( /* translators: Block title modifier */ __( '%1$s (%2$s)' ), @@ -114,4 +115,4 @@ export const settings = { ); }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/columns/index.php b/blocks/library/columns/index.php new file mode 100644 index 00000000000000..e978af800cb8f7 --- /dev/null +++ b/blocks/library/columns/index.php @@ -0,0 +1,36 @@ + 'core-columns-block', + 'editor_style' => 'core-columns-block-editor', + 'editor_script' => 'core-columns-block', + ) ); +} + +add_action( 'init', 'register_core_columns_block' ); diff --git a/blocks/library/nextpage/index.js b/blocks/library/nextpage/index.js index e67e276609f8a6..a77406306b9fec 100644 --- a/blocks/library/nextpage/index.js +++ b/blocks/library/nextpage/index.js @@ -2,17 +2,18 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + createBlock, + registerBlockType +} from '@wordpress/blocks'; import { RawHTML } from '@wordpress/element'; /** * Internal dependencies */ import './editor.scss'; -import { createBlock } from '../../api'; -export const name = 'core/nextpage'; - -export const settings = { +registerBlockType( 'core/nextpage', { title: __( 'Page break' ), description: __( 'This block allows you to set break points on your post. Visitors of your blog are then presented with content split into multiple pages.' ), @@ -58,4 +59,4 @@ export const settings = { ); }, -}; +} ); \ No newline at end of file diff --git a/blocks/library/nextpage/index.php b/blocks/library/nextpage/index.php new file mode 100644 index 00000000000000..7fefafdb4d3389 --- /dev/null +++ b/blocks/library/nextpage/index.php @@ -0,0 +1,26 @@ + 'core-nextpage-block-editor', + 'editor_script' => 'core-nextpage-block', + ) ); +} + +add_action( 'init', 'register_core_nextpage_block' ); diff --git a/test/unit/setup-wp-aliases.js b/test/unit/setup-wp-aliases.js index a11f5712dc505c..25f41196584ad3 100644 --- a/test/unit/setup-wp-aliases.js +++ b/test/unit/setup-wp-aliases.js @@ -15,7 +15,7 @@ global.wp = { 'date', 'editor', 'data', - 'editPost', + 'edit-post', 'core-data', 'viewport', 'plugins', From 272bb03108ee1794c9c7fdea23d62e492b60ad1a Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Tue, 10 Apr 2018 03:30:20 +0530 Subject: [PATCH 16/41] Removed import for "setDefaultBlockName" in heading block's JavaScript We don't need "setDefaultBlockName" in heading block's JavaScriot. So removed the import. --- blocks/library/heading/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/blocks/library/heading/index.js b/blocks/library/heading/index.js index 1cfa3e736095e9..c6cff0a946fe5b 100644 --- a/blocks/library/heading/index.js +++ b/blocks/library/heading/index.js @@ -4,8 +4,7 @@ import { __, sprintf } from '@wordpress/i18n'; import { createBlock, - registerBlockType, - setDefaultBlockName, + registerBlockType } from '@wordpress/blocks'; import { concatChildren } from '@wordpress/element'; From 29389ee8f3cfedfb350c3584e9cfcfd329132892 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Tue, 10 Apr 2018 03:42:14 +0530 Subject: [PATCH 17/41] Fixed syntax errors by running 'npm run lint:fix' --- blocks/library/audio/index.js | 4 ++-- blocks/library/block/index.js | 2 +- blocks/library/button/index.js | 4 ++-- blocks/library/categories/index.js | 4 ++-- blocks/library/code/index.js | 4 ++-- blocks/library/columns/index.js | 4 ++-- blocks/library/cover-image/index.js | 2 +- blocks/library/embed/index.js | 6 +++--- blocks/library/freeform/index.js | 4 ++-- blocks/library/gallery/index.js | 4 ++-- blocks/library/heading/index.js | 4 ++-- blocks/library/html/index.js | 4 ++-- blocks/library/image/index.js | 2 +- blocks/library/latest-posts/index.js | 2 +- blocks/library/list/index.js | 4 ++-- blocks/library/more/index.js | 4 ++-- blocks/library/nextpage/index.js | 4 ++-- blocks/library/preformatted/index.js | 4 ++-- blocks/library/pullquote/index.js | 2 +- blocks/library/quote/index.js | 4 ++-- blocks/library/separator/index.js | 4 ++-- blocks/library/shortcode/index.js | 4 ++-- blocks/library/subhead/index.js | 4 ++-- blocks/library/table/index.js | 4 ++-- blocks/library/text-columns/index.js | 4 ++-- blocks/library/verse/index.js | 4 ++-- blocks/library/video/index.js | 4 ++-- webpack.config.js | 8 ++++---- 28 files changed, 54 insertions(+), 54 deletions(-) diff --git a/blocks/library/audio/index.js b/blocks/library/audio/index.js index 9a3469e7e7c3e1..a5a29deadd5018 100644 --- a/blocks/library/audio/index.js +++ b/blocks/library/audio/index.js @@ -8,7 +8,7 @@ import { __ } from '@wordpress/i18n'; import { - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { @@ -182,4 +182,4 @@ registerBlockType( 'core/audio', { ); }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/block/index.js b/blocks/library/block/index.js index 6e491d99ff057f..1b30a01edb45f6 100644 --- a/blocks/library/block/index.js +++ b/blocks/library/block/index.js @@ -11,7 +11,7 @@ import { Placeholder, Spinner, Disabled } from '@wordpress/components'; import { withSelect, withDispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { - registerBlockType + registerBlockType, } from '@wordpress/blocks'; /** diff --git a/blocks/library/button/index.js b/blocks/library/button/index.js index b42b961e8dcfa5..5c3c937a7e25a9 100644 --- a/blocks/library/button/index.js +++ b/blocks/library/button/index.js @@ -3,7 +3,7 @@ */ import { __ } from '@wordpress/i18n'; import { - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { Component } from '@wordpress/element'; import { @@ -243,4 +243,4 @@ registerBlockType( 'core/button', { ); }, } ], -} ); \ No newline at end of file +} ); diff --git a/blocks/library/categories/index.js b/blocks/library/categories/index.js index 898b81fd862b35..411a765f269592 100644 --- a/blocks/library/categories/index.js +++ b/blocks/library/categories/index.js @@ -3,7 +3,7 @@ */ import { __ } from '@wordpress/i18n'; import { - registerBlockType + registerBlockType, } from '@wordpress/blocks'; /** @@ -56,4 +56,4 @@ registerBlockType( 'core/categories', { save() { return null; }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/code/index.js b/blocks/library/code/index.js index 5462a92017322b..2acb992189eb7e 100644 --- a/blocks/library/code/index.js +++ b/blocks/library/code/index.js @@ -4,7 +4,7 @@ import { __ } from '@wordpress/i18n'; import { createBlock, - registerBlockType + registerBlockType, } from '@wordpress/blocks'; /** @@ -70,4 +70,4 @@ registerBlockType( 'core/code', { save( { attributes } ) { return
{ attributes.content }
; }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/columns/index.js b/blocks/library/columns/index.js index fec6d75ed2d89b..6d804ecfe0e045 100644 --- a/blocks/library/columns/index.js +++ b/blocks/library/columns/index.js @@ -10,7 +10,7 @@ import memoize from 'memize'; */ import { __, sprintf } from '@wordpress/i18n'; import { - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { PanelBody, RangeControl } from '@wordpress/components'; @@ -115,4 +115,4 @@ registerBlockType( 'core/columns', { ); }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/cover-image/index.js b/blocks/library/cover-image/index.js index dece6b341cb2ec..1b84d7a16ce8d8 100644 --- a/blocks/library/cover-image/index.js +++ b/blocks/library/cover-image/index.js @@ -10,7 +10,7 @@ import { IconButton, PanelBody, RangeControl, ToggleControl, Toolbar } from '@wo import { __ } from '@wordpress/i18n'; import { createBlock, - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import classnames from 'classnames'; diff --git a/blocks/library/embed/index.js b/blocks/library/embed/index.js index 698ce308fc1dcb..a608b60e5e9734 100644 --- a/blocks/library/embed/index.js +++ b/blocks/library/embed/index.js @@ -11,7 +11,7 @@ import { stringify } from 'querystring'; import { __, sprintf } from '@wordpress/i18n'; import { createBlock, - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { Component, renderToString } from '@wordpress/element'; import { Button, Placeholder, Spinner, SandBox } from '@wordpress/components'; @@ -258,7 +258,7 @@ function getEmbedBlockSettings( { title, icon, category = 'embed', transforms, k }; } -registerBlockType( 'core/embed', +registerBlockType( 'core/embed', getEmbedBlockSettings( { title: __( 'Embed' ), icon: 'embed-generic', @@ -276,7 +276,7 @@ registerBlockType( 'core/embed', ], }, } - ) ); + ) ); export const common = [ { diff --git a/blocks/library/freeform/index.js b/blocks/library/freeform/index.js index 1a67657f572964..fa43fc5c0ed363 100644 --- a/blocks/library/freeform/index.js +++ b/blocks/library/freeform/index.js @@ -4,7 +4,7 @@ import { RawHTML } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { - registerBlockType + registerBlockType, } from '@wordpress/blocks'; /** @@ -41,4 +41,4 @@ registerBlockType( 'core/freeform', { return { content }; }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/gallery/index.js b/blocks/library/gallery/index.js index 07de2c5499d426..bb77b0891862d8 100644 --- a/blocks/library/gallery/index.js +++ b/blocks/library/gallery/index.js @@ -9,7 +9,7 @@ import { filter, every } from 'lodash'; import { __ } from '@wordpress/i18n'; import { createBlock, - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { mediaUpload } from '@wordpress/utils'; @@ -235,4 +235,4 @@ registerBlockType( 'core/gallery', { }, }, ], -} ); \ No newline at end of file +} ); diff --git a/blocks/library/heading/index.js b/blocks/library/heading/index.js index c6cff0a946fe5b..54ca7da5a8e622 100644 --- a/blocks/library/heading/index.js +++ b/blocks/library/heading/index.js @@ -4,7 +4,7 @@ import { __, sprintf } from '@wordpress/i18n'; import { createBlock, - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { concatChildren } from '@wordpress/element'; @@ -183,4 +183,4 @@ registerBlockType( 'core/heading', { ); }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/html/index.js b/blocks/library/html/index.js index 6d2fe0118cbf68..e5d785729e2df2 100644 --- a/blocks/library/html/index.js +++ b/blocks/library/html/index.js @@ -4,7 +4,7 @@ import { RawHTML } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { withState, SandBox, CodeEditor } from '@wordpress/components'; @@ -85,4 +85,4 @@ registerBlockType( 'core/html', { save( { attributes } ) { return { attributes.content }; }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/image/index.js b/blocks/library/image/index.js index a5b60190362606..83c9a64c86e7c9 100644 --- a/blocks/library/image/index.js +++ b/blocks/library/image/index.js @@ -6,7 +6,7 @@ import { createBlock, registerBlockType, getBlockAttributes, - getBlockType + getBlockType, } from '@wordpress/blocks'; /** diff --git a/blocks/library/latest-posts/index.js b/blocks/library/latest-posts/index.js index 9fdb9f14550c74..3e2a95a75f37c5 100644 --- a/blocks/library/latest-posts/index.js +++ b/blocks/library/latest-posts/index.js @@ -40,4 +40,4 @@ registerBlockType( 'core/latest-posts', { save() { return null; }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/list/index.js b/blocks/library/list/index.js index 378301fd7681a7..e371d395b9f9fb 100644 --- a/blocks/library/list/index.js +++ b/blocks/library/list/index.js @@ -10,7 +10,7 @@ import { Component, createElement } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { createBlock, - registerBlockType + registerBlockType, } from '@wordpress/blocks'; /** @@ -316,4 +316,4 @@ registerBlockType( 'core/list', { values ); }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/more/index.js b/blocks/library/more/index.js index d011f1609c4c3d..2c9eb1a1f669cb 100644 --- a/blocks/library/more/index.js +++ b/blocks/library/more/index.js @@ -8,7 +8,7 @@ import { compact } from 'lodash'; */ import { __ } from '@wordpress/i18n'; import { - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { PanelBody, ToggleControl } from '@wordpress/components'; import { Component, RawHTML } from '@wordpress/element'; @@ -139,4 +139,4 @@ registerBlockType( 'core/more', { ); }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/nextpage/index.js b/blocks/library/nextpage/index.js index a77406306b9fec..de90b69bc99c51 100644 --- a/blocks/library/nextpage/index.js +++ b/blocks/library/nextpage/index.js @@ -4,7 +4,7 @@ import { __ } from '@wordpress/i18n'; import { createBlock, - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { RawHTML } from '@wordpress/element'; @@ -59,4 +59,4 @@ registerBlockType( 'core/nextpage', { ); }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/preformatted/index.js b/blocks/library/preformatted/index.js index 9c8c472af28c5b..153f8973f8ab3a 100644 --- a/blocks/library/preformatted/index.js +++ b/blocks/library/preformatted/index.js @@ -4,7 +4,7 @@ import { __ } from '@wordpress/i18n'; import { createBlock, - registerBlockType + registerBlockType, } from '@wordpress/blocks'; /** @@ -84,4 +84,4 @@ registerBlockType( 'core/preformatted', { return
{ content }
; }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/pullquote/index.js b/blocks/library/pullquote/index.js index 546337d3e92f91..559ea4f2ef0f79 100644 --- a/blocks/library/pullquote/index.js +++ b/blocks/library/pullquote/index.js @@ -8,7 +8,7 @@ import { map } from 'lodash'; */ import { __ } from '@wordpress/i18n'; import { - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { withState } from '@wordpress/components'; diff --git a/blocks/library/quote/index.js b/blocks/library/quote/index.js index 3ee04db5e0e3ac..f55a3363eecc50 100644 --- a/blocks/library/quote/index.js +++ b/blocks/library/quote/index.js @@ -10,7 +10,7 @@ import classnames from 'classnames'; import { __, sprintf } from '@wordpress/i18n'; import { createBlock, - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { Toolbar, withState } from '@wordpress/components'; @@ -283,4 +283,4 @@ registerBlockType( 'core/quote', { }, }, ], -} ); \ No newline at end of file +} ); diff --git a/blocks/library/separator/index.js b/blocks/library/separator/index.js index 93e30f8e191a7c..ff2a98f7da57c9 100644 --- a/blocks/library/separator/index.js +++ b/blocks/library/separator/index.js @@ -4,7 +4,7 @@ import { __ } from '@wordpress/i18n'; import { createBlock, - registerBlockType + registerBlockType, } from '@wordpress/blocks'; /** @@ -45,4 +45,4 @@ registerBlockType( 'core/separator', { save() { return
; }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/shortcode/index.js b/blocks/library/shortcode/index.js index 998fda86d58904..fdc37cddae7784 100644 --- a/blocks/library/shortcode/index.js +++ b/blocks/library/shortcode/index.js @@ -4,7 +4,7 @@ import { RawHTML } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { withInstanceId, Dashicon } from '@wordpress/components'; @@ -86,4 +86,4 @@ registerBlockType( 'core/shortcode', { save( { attributes } ) { return { attributes.text }; }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/subhead/index.js b/blocks/library/subhead/index.js index ae2daaaa270c97..17205758f56cb1 100644 --- a/blocks/library/subhead/index.js +++ b/blocks/library/subhead/index.js @@ -4,7 +4,7 @@ import { __ } from '@wordpress/i18n'; import { createBlock, - registerBlockType + registerBlockType, } from '@wordpress/blocks'; /** @@ -83,4 +83,4 @@ registerBlockType( 'core/subhead', { return

{ content }

; }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/table/index.js b/blocks/library/table/index.js index 8e46fb031de995..25b4ed1642b12b 100644 --- a/blocks/library/table/index.js +++ b/blocks/library/table/index.js @@ -3,7 +3,7 @@ */ import { __ } from '@wordpress/i18n'; import { - registerBlockType + registerBlockType, } from '@wordpress/blocks'; /** @@ -86,4 +86,4 @@ registerBlockType( 'core/table', { ); }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/text-columns/index.js b/blocks/library/text-columns/index.js index f0c77dcd352b84..1d05a4bff004bc 100644 --- a/blocks/library/text-columns/index.js +++ b/blocks/library/text-columns/index.js @@ -8,7 +8,7 @@ import { times } from 'lodash'; */ import { __ } from '@wordpress/i18n'; import { - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { PanelBody, RangeControl } from '@wordpress/components'; @@ -121,4 +121,4 @@ registerBlockType( 'core/text-columns', { ); }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/verse/index.js b/blocks/library/verse/index.js index f2676ec07763c6..9531220a4b87cd 100644 --- a/blocks/library/verse/index.js +++ b/blocks/library/verse/index.js @@ -4,7 +4,7 @@ import { __ } from '@wordpress/i18n'; import { createBlock, - registerBlockType + registerBlockType, } from '@wordpress/blocks'; /** @@ -74,4 +74,4 @@ registerBlockType( 'core/verse', { save( { attributes, className } ) { return
{ attributes.content }
; }, -} ); \ No newline at end of file +} ); diff --git a/blocks/library/video/index.js b/blocks/library/video/index.js index 4954406deb0d7e..af2d8825498e6d 100644 --- a/blocks/library/video/index.js +++ b/blocks/library/video/index.js @@ -7,7 +7,7 @@ */ import { __ } from '@wordpress/i18n'; import { - registerBlockType + registerBlockType, } from '@wordpress/blocks'; import { Button, @@ -197,4 +197,4 @@ registerBlockType( 'core/video', { ); }, -} ); \ No newline at end of file +} ); diff --git a/webpack.config.js b/webpack.config.js index eaa76cd4381db2..e03645e03ea18f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -24,7 +24,7 @@ const editBlocksCSSPlugin = new ExtractTextPlugin( { // CSS loader for each individual block's styles const individualBlocksCSSPlugin = new ExtractTextPlugin( { - filename: './build/[name].css' + filename: './build/[name].css', } ); // CSS loader for common styles specific to blocks in general. @@ -86,9 +86,9 @@ const entryPointNames = [ 'core-data', 'plugins', 'edit-post', - ...fs.readdirSync( './blocks/library' ).map( ( block ) => - 'blocks/library/' + block - ), + ...fs.readdirSync( './blocks/library' ).map( ( block ) => + 'blocks/library/' + block + ), ]; const packageNames = [ From f0b0f68d16e2f33aa532eda7195edb36578e3413 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Tue, 10 Apr 2018 13:03:06 +0530 Subject: [PATCH 18/41] Fixed errors brought up by npm run lint:fix Removed import for registerCoreBlocks in editor/test/selectors.js since it's no longer used. Replaced name by 'core/paragraph' in paragraph/index.js since the name constant is no longer defined --- blocks/library/paragraph/index.js | 2 +- editor/store/test/selectors.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/blocks/library/paragraph/index.js b/blocks/library/paragraph/index.js index a378b82675da95..cb06a9e3c961bf 100644 --- a/blocks/library/paragraph/index.js +++ b/blocks/library/paragraph/index.js @@ -76,7 +76,7 @@ class ParagraphBlock extends Component { onReplace( blocks ) { const { attributes, onReplace } = this.props; onReplace( blocks.map( ( block, index ) => ( - index === 0 && block.name === name ? + index === 0 && block.name === 'core/paragraph' ? { ...block, attributes: { ...attributes, diff --git a/editor/store/test/selectors.js b/editor/store/test/selectors.js index 4da10278bb3837..567447130f4019 100644 --- a/editor/store/test/selectors.js +++ b/editor/store/test/selectors.js @@ -7,7 +7,7 @@ import { filter, property, union } from 'lodash'; * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { registerBlockType, unregisterBlockType, registerCoreBlocks, getBlockTypes } from '@wordpress/blocks'; +import { registerBlockType, unregisterBlockType, getBlockTypes } from '@wordpress/blocks'; import { moment } from '@wordpress/date'; /** From e9e050c154bcfa56aaff0e57cba4d6dbdafdad1a Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Tue, 10 Apr 2018 18:36:39 +0530 Subject: [PATCH 19/41] Changed Webpack configuration to change output folder for individual block assets The previous Webpack configuration was building individual block assets to /build/blocks/library/paragraph.js (/css) It has now been changed to /build/__block_paragraph.js (/css) --- blocks/library/audio/index.php | 10 +++++----- blocks/library/block/index.php | 2 +- blocks/library/button/index.php | 10 +++++----- blocks/library/categories/index.php | 10 +++++----- blocks/library/code/index.php | 6 +++--- blocks/library/columns/index.php | 10 +++++----- blocks/library/cover-image/index.php | 10 +++++----- blocks/library/embed/index.php | 10 +++++----- blocks/library/freeform/index.php | 6 +++--- blocks/library/gallery/index.php | 10 +++++----- blocks/library/heading/index.php | 6 +++--- blocks/library/html/index.php | 6 +++--- blocks/library/image/index.php | 10 +++++----- blocks/library/latest-posts/index.php | 10 +++++----- blocks/library/list/index.php | 6 +++--- blocks/library/more/index.php | 6 +++--- blocks/library/nextpage/index.php | 6 +++--- blocks/library/paragraph/index.php | 10 +++++----- blocks/library/preformatted/index.php | 6 +++--- blocks/library/pullquote/index.php | 10 +++++----- blocks/library/quote/index.php | 10 +++++----- blocks/library/separator/index.php | 6 +++--- blocks/library/shortcode/index.php | 6 +++--- blocks/library/subhead/index.php | 10 +++++----- blocks/library/table/index.php | 10 +++++----- blocks/library/text-columns/index.php | 10 +++++----- blocks/library/verse/index.php | 6 +++--- blocks/library/video/index.php | 10 +++++----- webpack.config.js | 3 ++- 29 files changed, 116 insertions(+), 115 deletions(-) diff --git a/blocks/library/audio/index.php b/blocks/library/audio/index.php index dfda93cce3526c..820983c30209df 100644 --- a/blocks/library/audio/index.php +++ b/blocks/library/audio/index.php @@ -6,22 +6,22 @@ */ function register_core_audio_block() { - wp_register_script( 'core-audio-block', gutenberg_url( '/build/blocks/library/audio.js' ) ); + wp_register_script( 'core-audio-block', gutenberg_url( '/build/__block_audio.js' ) ); wp_register_style( 'core-audio-block', - gutenberg_url( '/build/blocks/library/audio.css' ), + gutenberg_url( '/build/__block_audio.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/audio.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_audio.css' ) ); wp_style_add_data( 'core-audio-block', 'rtl', 'replace' ); wp_register_style( 'core-audio-block-editor', - gutenberg_url( '/build/blocks/library/audio_editor.css' ), + gutenberg_url( '/build/__block_audio_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/audio_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_audio_editor.css' ) ); wp_style_add_data( 'core-audio-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/block/index.php b/blocks/library/block/index.php index 5674427fcf341b..a21fd0645d188b 100644 --- a/blocks/library/block/index.php +++ b/blocks/library/block/index.php @@ -33,7 +33,7 @@ function gutenberg_render_core_reusable_block( $attributes ) { } function register_core_reusable_block() { - wp_register_script( 'core-reusable-block', gutenberg_url( '/build/blocks/library/block.js' ) ); + wp_register_script( 'core-reusable-block', gutenberg_url( '/build/__block_block.js' ) ); register_block_type( 'core/block', array( 'editor_script' => 'core-reusable-block', diff --git a/blocks/library/button/index.php b/blocks/library/button/index.php index a896a9c021b1a0..6cca91c9428178 100644 --- a/blocks/library/button/index.php +++ b/blocks/library/button/index.php @@ -6,22 +6,22 @@ */ function register_core_button_block() { - wp_register_script( 'core-button-block', gutenberg_url( '/build/blocks/library/button.js' ) ); + wp_register_script( 'core-button-block', gutenberg_url( '/build/__block_button.js' ) ); wp_register_style( 'core-button-block', - gutenberg_url( '/build/blocks/library/button.css' ), + gutenberg_url( '/build/__block_button.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/button.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_button.css' ) ); wp_style_add_data( 'core-button-block', 'rtl', 'replace' ); wp_register_style( 'core-button-block-editor', - gutenberg_url( '/build/blocks/library/button_editor.css' ), + gutenberg_url( '/build/__block_button_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/button_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_button_editor.css' ) ); wp_style_add_data( 'core-button-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/categories/index.php b/blocks/library/categories/index.php index 31231adc949640..7cec30f27609e1 100644 --- a/blocks/library/categories/index.php +++ b/blocks/library/categories/index.php @@ -85,22 +85,22 @@ function onCatChange() { } function register_core_categories_block() { - wp_register_script( 'core-categories-block', gutenberg_url( '/build/blocks/library/categories.js' ) ); + wp_register_script( 'core-categories-block', gutenberg_url( '/build/__block_categories.js' ) ); wp_register_style( 'core-categories-block', - gutenberg_url( '/build/blocks/library/categories.css' ), + gutenberg_url( '/build/__block_categories.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/categories.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_categories.css' ) ); wp_style_add_data( 'core-categories-block', 'rtl', 'replace' ); wp_register_style( 'core-categories-block-editor', - gutenberg_url( '/build/blocks/library/categories_editor.css' ), + gutenberg_url( '/build/__block_categories_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/categories_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_categories_editor.css' ) ); wp_style_add_data( 'core-categories-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/code/index.php b/blocks/library/code/index.php index dd70f84d9fcddc..368a9da3a13c16 100644 --- a/blocks/library/code/index.php +++ b/blocks/library/code/index.php @@ -6,13 +6,13 @@ */ function register_core_code_block() { - wp_register_script( 'core-code-block', gutenberg_url( '/build/blocks/library/code.js' ) ); + wp_register_script( 'core-code-block', gutenberg_url( '/build/__block_code.js' ) ); wp_register_style( 'core-code-block-editor', - gutenberg_url( '/build/blocks/library/code_editor.css' ), + gutenberg_url( '/build/__block_code_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/code_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_code_editor.css' ) ); wp_style_add_data( 'core-code-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/columns/index.php b/blocks/library/columns/index.php index e978af800cb8f7..e7116969d39da1 100644 --- a/blocks/library/columns/index.php +++ b/blocks/library/columns/index.php @@ -6,22 +6,22 @@ */ function register_core_columns_block() { - wp_register_script( 'core-columns-block', gutenberg_url( '/build/blocks/library/columns.js' ) ); + wp_register_script( 'core-columns-block', gutenberg_url( '/build/__block_columns.js' ) ); wp_register_style( 'core-columns-block', - gutenberg_url( '/build/blocks/library/columns.css' ), + gutenberg_url( '/build/__block_columns.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/columns.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_columns.css' ) ); wp_style_add_data( 'core-columns-block', 'rtl', 'replace' ); wp_register_style( 'core-columns-block-editor', - gutenberg_url( '/build/blocks/library/columns_editor.css' ), + gutenberg_url( '/build/__block_columns_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/columns_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_columns_editor.css' ) ); wp_style_add_data( 'core-columns-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/cover-image/index.php b/blocks/library/cover-image/index.php index 57672a8998c9a0..6f794cddbc95e7 100644 --- a/blocks/library/cover-image/index.php +++ b/blocks/library/cover-image/index.php @@ -6,22 +6,22 @@ */ function register_core_cover_image_block() { - wp_register_script( 'core-cover-image-block', gutenberg_url( '/build/blocks/library/coverImage.js' ) ); + wp_register_script( 'core-cover-image-block', gutenberg_url( '/build/__block_coverImage.js' ) ); wp_register_style( 'core-cover-image-block', - gutenberg_url( '/build/blocks/library/coverImage.css' ), + gutenberg_url( '/build/__block_coverImage.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/coverImage.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_coverImage.css' ) ); wp_style_add_data( 'core-cover-image-block', 'rtl', 'replace' ); wp_register_style( 'core-cover-image-block-editor', - gutenberg_url( '/build/blocks/library/coverImage_editor.css' ), + gutenberg_url( '/build/__block_coverImage_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/coverImage_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_coverImage_editor.css' ) ); wp_style_add_data( 'core-cover-image-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/embed/index.php b/blocks/library/embed/index.php index 0eecc63b5b794e..58417f8e7a5ac9 100644 --- a/blocks/library/embed/index.php +++ b/blocks/library/embed/index.php @@ -6,22 +6,22 @@ */ function register_core_embed_block() { - wp_register_script( 'core-embed-block', gutenberg_url( '/build/blocks/library/embed.js' ) ); + wp_register_script( 'core-embed-block', gutenberg_url( '/build/__block_embed.js' ) ); wp_register_style( 'core-embed-block', - gutenberg_url( '/build/blocks/library/embed.css' ), + gutenberg_url( '/build/__block_embed.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/embed.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_embed.css' ) ); wp_style_add_data( 'core-embed-block', 'rtl', 'replace' ); wp_register_style( 'core-embed-block-editor', - gutenberg_url( '/build/blocks/library/embed_editor.css' ), + gutenberg_url( '/build/__block_embed_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/embed_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_embed_editor.css' ) ); wp_style_add_data( 'core-embed-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/freeform/index.php b/blocks/library/freeform/index.php index 04079d7df3e818..b4c45c77de1f48 100644 --- a/blocks/library/freeform/index.php +++ b/blocks/library/freeform/index.php @@ -6,13 +6,13 @@ */ function register_core_freeform_block() { - wp_register_script( 'core-freeform-block', gutenberg_url( '/build/blocks/library/freeform.js' ) ); + wp_register_script( 'core-freeform-block', gutenberg_url( '/build/__block_freeform.js' ) ); wp_register_style( 'core-freeform-block-editor', - gutenberg_url( '/build/blocks/library/freeform_editor.css' ), + gutenberg_url( '/build/__block_freeform_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/freeform_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_freeform_editor.css' ) ); wp_style_add_data( 'core-freeform-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/gallery/index.php b/blocks/library/gallery/index.php index a6deca2e7b9f94..dbbb24dae7a2f1 100644 --- a/blocks/library/gallery/index.php +++ b/blocks/library/gallery/index.php @@ -6,22 +6,22 @@ */ function register_core_gallery_block() { - wp_register_script( 'core-gallery-block', gutenberg_url( '/build/blocks/library/gallery.js' ) ); + wp_register_script( 'core-gallery-block', gutenberg_url( '/build/__block_gallery.js' ) ); wp_register_style( 'core-gallery-block', - gutenberg_url( '/build/blocks/library/gallery.css' ), + gutenberg_url( '/build/__block_gallery.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/gallery.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_gallery.css' ) ); wp_style_add_data( 'core-gallery-block', 'rtl', 'replace' ); wp_register_style( 'core-gallery-block-editor', - gutenberg_url( '/build/blocks/library/gallery_editor.css' ), + gutenberg_url( '/build/__block_gallery_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/gallery_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_gallery_editor.css' ) ); wp_style_add_data( 'core-gallery-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/heading/index.php b/blocks/library/heading/index.php index 21e4f630bea0c4..b48ffec4024527 100644 --- a/blocks/library/heading/index.php +++ b/blocks/library/heading/index.php @@ -6,13 +6,13 @@ */ function register_core_heading_block() { - wp_register_script( 'core-heading-block', gutenberg_url( '/build/blocks/library/heading.js' ) ); + wp_register_script( 'core-heading-block', gutenberg_url( '/build/__block_heading.js' ) ); wp_register_style( 'core-heading-block-editor', - gutenberg_url( '/build/blocks/library/heading_editor.css' ), + gutenberg_url( '/build/__block_heading_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/heading_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_heading_editor.css' ) ); wp_style_add_data( 'core-heading-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/html/index.php b/blocks/library/html/index.php index e21dae6706d0b3..c7c63d0cc0367e 100644 --- a/blocks/library/html/index.php +++ b/blocks/library/html/index.php @@ -6,13 +6,13 @@ */ function register_core_html_block() { - wp_register_script( 'core-html-block', gutenberg_url( '/build/blocks/library/html.js' ) ); + wp_register_script( 'core-html-block', gutenberg_url( '/build/__block_html.js' ) ); wp_register_style( 'core-html-block-editor', - gutenberg_url( '/build/blocks/library/html_editor.css' ), + gutenberg_url( '/build/__block_html_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/html_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_html_editor.css' ) ); wp_style_add_data( 'core-html-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/image/index.php b/blocks/library/image/index.php index c0601ce0034805..c7a0ecd2a6619f 100644 --- a/blocks/library/image/index.php +++ b/blocks/library/image/index.php @@ -6,22 +6,22 @@ */ function register_core_image_block() { - wp_register_script( 'core-image-block', gutenberg_url( '/build/blocks/library/image.js' ) ); + wp_register_script( 'core-image-block', gutenberg_url( '/build/__block_image.js' ) ); wp_register_style( 'core-image-block', - gutenberg_url( '/build/blocks/library/image.css' ), + gutenberg_url( '/build/__block_image.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/image.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_image.css' ) ); wp_style_add_data( 'core-image-block', 'rtl', 'replace' ); wp_register_style( 'core-image-block-editor', - gutenberg_url( '/build/blocks/library/image_editor.css' ), + gutenberg_url( '/build/__block_image_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/image_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_image_editor.css' ) ); wp_style_add_data( 'core-image-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/latest-posts/index.php b/blocks/library/latest-posts/index.php index 3da9d182422ba7..f841caf91d0079 100644 --- a/blocks/library/latest-posts/index.php +++ b/blocks/library/latest-posts/index.php @@ -66,22 +66,22 @@ function gutenberg_render_core_latest_posts_block( $attributes ) { } function register_core_latest_posts_block() { - wp_register_script( 'core-latest-posts-block', gutenberg_url( '/build/blocks/library/latestPosts.js' ) ); + wp_register_script( 'core-latest-posts-block', gutenberg_url( '/build/__block_latestPosts.js' ) ); wp_register_style( 'core-latest-posts-block', - gutenberg_url( '/build/blocks/library/latestPosts.css' ), + gutenberg_url( '/build/__block_latestPosts.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/latestPosts.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_latestPosts.css' ) ); wp_style_add_data( 'core-latest-posts-block', 'rtl', 'replace' ); wp_register_style( 'core-latest-posts-block-editor', - gutenberg_url( '/build/blocks/library/latestPosts_editor.css' ), + gutenberg_url( '/build/__block_latestPosts_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/latestPosts_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_latestPosts_editor.css' ) ); wp_style_add_data( 'core-latest-posts-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/list/index.php b/blocks/library/list/index.php index c5e904c1d0d5f8..5b953193430962 100644 --- a/blocks/library/list/index.php +++ b/blocks/library/list/index.php @@ -6,13 +6,13 @@ */ function register_core_list_block() { - wp_register_script( 'core-list-block', gutenberg_url( '/build/blocks/library/list.js' ) ); + wp_register_script( 'core-list-block', gutenberg_url( '/build/__block_list.js' ) ); wp_register_style( 'core-list-block-editor', - gutenberg_url( '/build/blocks/library/list_editor.css' ), + gutenberg_url( '/build/__block_list_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/list_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_list_editor.css' ) ); wp_style_add_data( 'core-list-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/more/index.php b/blocks/library/more/index.php index 444a0ea5e29b88..99dd872dee8c1f 100644 --- a/blocks/library/more/index.php +++ b/blocks/library/more/index.php @@ -6,13 +6,13 @@ */ function register_core_more_block() { - wp_register_script( 'core-more-block', gutenberg_url( '/build/blocks/library/more.js' ) ); + wp_register_script( 'core-more-block', gutenberg_url( '/build/__block_more.js' ) ); wp_register_style( 'core-more-block-editor', - gutenberg_url( '/build/blocks/library/more_editor.css' ), + gutenberg_url( '/build/__block_more_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/more_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_more_editor.css' ) ); wp_style_add_data( 'core-more-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/nextpage/index.php b/blocks/library/nextpage/index.php index 7fefafdb4d3389..a2e788e5e5bc13 100644 --- a/blocks/library/nextpage/index.php +++ b/blocks/library/nextpage/index.php @@ -6,13 +6,13 @@ */ function register_core_nextpage_block() { - wp_register_script( 'core-nextpage-block', gutenberg_url( '/build/blocks/library/nextpage.js' ) ); + wp_register_script( 'core-nextpage-block', gutenberg_url( '/build/__block_nextpage.js' ) ); wp_register_style( 'core-nextpage-block-editor', - gutenberg_url( '/build/blocks/library/nextpage_editor.css' ), + gutenberg_url( '/build/__block_nextpage_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/nextpage_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_nextpage_editor.css' ) ); wp_style_add_data( 'core-nextpage-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/paragraph/index.php b/blocks/library/paragraph/index.php index f5fba6e698a476..0b29ed84467ff7 100644 --- a/blocks/library/paragraph/index.php +++ b/blocks/library/paragraph/index.php @@ -6,22 +6,22 @@ */ function register_core_paragraph_block() { - wp_register_script( 'core-paragraph-block', gutenberg_url( '/build/blocks/library/paragraph.js' ) ); + wp_register_script( 'core-paragraph-block', gutenberg_url( '/build/__block_paragraph.js' ) ); wp_register_style( 'core-paragraph-block', - gutenberg_url( '/build/blocks/library/paragraph.css' ), + gutenberg_url( '/build/__block_paragraph.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/paragraph.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_paragraph.css' ) ); wp_style_add_data( 'core-paragraph-block', 'rtl', 'replace' ); wp_register_style( 'core-paragraph-block-editor', - gutenberg_url( '/build/blocks/library/paragraph_editor.css' ), + gutenberg_url( '/build/__block_paragraph_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/paragraph_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_paragraph_editor.css' ) ); wp_style_add_data( 'core-paragraph-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/preformatted/index.php b/blocks/library/preformatted/index.php index ac5463f05fc9b3..1ada23fc744c27 100644 --- a/blocks/library/preformatted/index.php +++ b/blocks/library/preformatted/index.php @@ -6,13 +6,13 @@ */ function register_core_preformatted_block() { - wp_register_script( 'core-preformatted-block', gutenberg_url( '/build/blocks/library/preformatted.js' ) ); + wp_register_script( 'core-preformatted-block', gutenberg_url( '/build/__block_preformatted.js' ) ); wp_register_style( 'core-preformatted-block-editor', - gutenberg_url( '/build/blocks/library/preformatted_editor.css' ), + gutenberg_url( '/build/__block_preformatted_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/preformatted_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_preformatted_editor.css' ) ); wp_style_add_data( 'core-preformatted-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/pullquote/index.php b/blocks/library/pullquote/index.php index 702a214a22b9da..2fcec9985b4f54 100644 --- a/blocks/library/pullquote/index.php +++ b/blocks/library/pullquote/index.php @@ -6,22 +6,22 @@ */ function register_core_pullquote_block() { - wp_register_script( 'core-pullquote-block', gutenberg_url( '/build/blocks/library/pullquote.js' ) ); + wp_register_script( 'core-pullquote-block', gutenberg_url( '/build/__block_pullquote.js' ) ); wp_register_style( 'core-pullquote-block', - gutenberg_url( '/build/blocks/library/pullquote.css' ), + gutenberg_url( '/build/__block_pullquote.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/pullquote.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_pullquote.css' ) ); wp_style_add_data( 'core-pullquote-block', 'rtl', 'replace' ); wp_register_style( 'core-pullquote-block-editor', - gutenberg_url( '/build/blocks/library/pullquote_editor.css' ), + gutenberg_url( '/build/__block_pullquote_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/pullquote_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_pullquote_editor.css' ) ); wp_style_add_data( 'core-pullquote-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/quote/index.php b/blocks/library/quote/index.php index 1d3226deb1e0ef..f385f967b9ef13 100644 --- a/blocks/library/quote/index.php +++ b/blocks/library/quote/index.php @@ -6,22 +6,22 @@ */ function register_core_quote_block() { - wp_register_script( 'core-quote-block', gutenberg_url( '/build/blocks/library/quote.js' ) ); + wp_register_script( 'core-quote-block', gutenberg_url( '/build/__block_quote.js' ) ); wp_register_style( 'core-quote-block', - gutenberg_url( '/build/blocks/library/quote.css' ), + gutenberg_url( '/build/__block_quote.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/quote.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_quote.css' ) ); wp_style_add_data( 'core-quote-block', 'rtl', 'replace' ); wp_register_style( 'core-quote-block-editor', - gutenberg_url( '/build/blocks/library/quote_editor.css' ), + gutenberg_url( '/build/__block_quote_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/quote_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_quote_editor.css' ) ); wp_style_add_data( 'core-quote-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/separator/index.php b/blocks/library/separator/index.php index c135904a849f43..e0d5ab4d52dfb9 100644 --- a/blocks/library/separator/index.php +++ b/blocks/library/separator/index.php @@ -6,13 +6,13 @@ */ function register_core_separator_block() { - wp_register_script( 'core-separator-block', gutenberg_url( '/build/blocks/library/separator.js' ) ); + wp_register_script( 'core-separator-block', gutenberg_url( '/build/__block_separator.js' ) ); wp_register_style( 'core-separator-block', - gutenberg_url( '/build/blocks/library/separator.css' ), + gutenberg_url( '/build/__block_separator.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/separator.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_separator.css' ) ); wp_style_add_data( 'core-separator-block', 'rtl', 'replace' ); diff --git a/blocks/library/shortcode/index.php b/blocks/library/shortcode/index.php index f65acfd26523b0..de8ef3703c2186 100644 --- a/blocks/library/shortcode/index.php +++ b/blocks/library/shortcode/index.php @@ -6,13 +6,13 @@ */ function register_core_shortcode_block() { - wp_register_script( 'core-shortcode-block', gutenberg_url( '/build/blocks/library/shortcode.js' ) ); + wp_register_script( 'core-shortcode-block', gutenberg_url( '/build/__block_shortcode.js' ) ); wp_register_style( 'core-shortcode-block-editor', - gutenberg_url( '/build/blocks/library/shortcode_editor.css' ), + gutenberg_url( '/build/__block_shortcode_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/shortcode_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_shortcode_editor.css' ) ); wp_style_add_data( 'core-shortcode-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/subhead/index.php b/blocks/library/subhead/index.php index 7c2c070eedcd4f..d2dc0f537234fc 100644 --- a/blocks/library/subhead/index.php +++ b/blocks/library/subhead/index.php @@ -6,22 +6,22 @@ */ function register_core_subhead_block() { - wp_register_script( 'core-subhead-block', gutenberg_url( '/build/blocks/library/subhead.js' ) ); + wp_register_script( 'core-subhead-block', gutenberg_url( '/build/__block_subhead.js' ) ); wp_register_style( 'core-subhead-block', - gutenberg_url( '/build/blocks/library/subhead.css' ), + gutenberg_url( '/build/__block_subhead.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/subhead.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_subhead.css' ) ); wp_style_add_data( 'core-subhead-block', 'rtl', 'replace' ); wp_register_style( 'core-subhead-block-editor', - gutenberg_url( '/build/blocks/library/subhead_editor.css' ), + gutenberg_url( '/build/__block_subhead_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/subhead_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_subhead_editor.css' ) ); wp_style_add_data( 'core-subhead-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/table/index.php b/blocks/library/table/index.php index 9a0e214aa182cd..9b035a71791144 100644 --- a/blocks/library/table/index.php +++ b/blocks/library/table/index.php @@ -6,22 +6,22 @@ */ function register_core_table_block() { - wp_register_script( 'core-table-block', gutenberg_url( '/build/blocks/library/table.js' ) ); + wp_register_script( 'core-table-block', gutenberg_url( '/build/__block_table.js' ) ); wp_register_style( 'core-table-block', - gutenberg_url( '/build/blocks/library/table.css' ), + gutenberg_url( '/build/__block_table.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/table.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_table.css' ) ); wp_style_add_data( 'core-table-block', 'rtl', 'replace' ); wp_register_style( 'core-table-block-editor', - gutenberg_url( '/build/blocks/library/table_editor.css' ), + gutenberg_url( '/build/__block_table_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/table_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_table_editor.css' ) ); wp_style_add_data( 'core-table-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/text-columns/index.php b/blocks/library/text-columns/index.php index e4aa4db5d90ebf..628f03e349b28a 100644 --- a/blocks/library/text-columns/index.php +++ b/blocks/library/text-columns/index.php @@ -6,22 +6,22 @@ */ function register_core_text_columns_block() { - wp_register_script( 'core-text-columns-block', gutenberg_url( '/build/blocks/library/textColumns.js' ) ); + wp_register_script( 'core-text-columns-block', gutenberg_url( '/build/__block_textColumns.js' ) ); wp_register_style( 'core-text-columns-block', - gutenberg_url( '/build/blocks/library/textColumns.css' ), + gutenberg_url( '/build/__block_textColumns.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/textColumns.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_textColumns.css' ) ); wp_style_add_data( 'core-text-columns-block', 'rtl', 'replace' ); wp_register_style( 'core-text-columns-block-editor', - gutenberg_url( '/build/blocks/library/textColumns_editor.css' ), + gutenberg_url( '/build/__block_textColumns_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/textColumns_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_textColumns_editor.css' ) ); wp_style_add_data( 'core-text-columns-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/verse/index.php b/blocks/library/verse/index.php index 84414de7d021b7..513868203c941b 100644 --- a/blocks/library/verse/index.php +++ b/blocks/library/verse/index.php @@ -6,13 +6,13 @@ */ function register_core_verse_block() { - wp_register_script( 'core-verse-block', gutenberg_url( '/build/blocks/library/verse.js' ) ); + wp_register_script( 'core-verse-block', gutenberg_url( '/build/__block_verse.js' ) ); wp_register_style( 'core-verse-block-editor', - gutenberg_url( '/build/blocks/library/verse_editor.css' ), + gutenberg_url( '/build/__block_verse_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/verse_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_verse_editor.css' ) ); wp_style_add_data( 'core-verse-block-editor', 'rtl', 'replace' ); diff --git a/blocks/library/video/index.php b/blocks/library/video/index.php index e9be486abd1fcc..fe030efd606888 100644 --- a/blocks/library/video/index.php +++ b/blocks/library/video/index.php @@ -6,22 +6,22 @@ */ function register_core_video_block() { - wp_register_script( 'core-video-block', gutenberg_url( '/build/blocks/library/video.js' ) ); + wp_register_script( 'core-video-block', gutenberg_url( '/build/__block_video.js' ) ); wp_register_style( 'core-video-block', - gutenberg_url( '/build/blocks/library/video.css' ), + gutenberg_url( '/build/__block_video.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/video.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_video.css' ) ); wp_style_add_data( 'core-video-block', 'rtl', 'replace' ); wp_register_style( 'core-video-block-editor', - gutenberg_url( '/build/blocks/library/video_editor.css' ), + gutenberg_url( '/build/__block_video_editor.css' ), array(), - filemtime( gutenberg_dir_path() . 'build/blocks/library/video_editor.css' ) + filemtime( gutenberg_dir_path() . 'build/__block_video_editor.css' ) ); wp_style_add_data( 'core-video-block-editor', 'rtl', 'replace' ); diff --git a/webpack.config.js b/webpack.config.js index e03645e03ea18f..03fa68710ece3f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -122,7 +122,8 @@ const config = { entry: Object.assign( entryPointNames.reduce( ( memo, path ) => { - const name = camelCaseDash( path ); + let name = camelCaseDash( path ); + name = name.replace( 'blocks/library/', '__block_' ); memo[ name ] = `./${ path }`; return memo; }, {} ), From 818e8cb7192670d9a77868fa0b860122189d0f14 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Tue, 10 Apr 2018 19:12:28 +0530 Subject: [PATCH 20/41] Renamed style.scss in blocks/library/block to editor.scss since it looks to be CSS used by the editor Renamed style.scss in blocks/library/block to editor.scss since it looks to be CSS used by the editor. Also enqueued the same as the editor_style attribute for 'core/block' server-side. --- .../block/edit-panel/{style.scss => editor.scss} | 0 blocks/library/block/index.php | 10 ++++++++++ .../block/indicator/{style.scss => editor.scss} | 0 3 files changed, 10 insertions(+) rename blocks/library/block/edit-panel/{style.scss => editor.scss} (100%) rename blocks/library/block/indicator/{style.scss => editor.scss} (100%) diff --git a/blocks/library/block/edit-panel/style.scss b/blocks/library/block/edit-panel/editor.scss similarity index 100% rename from blocks/library/block/edit-panel/style.scss rename to blocks/library/block/edit-panel/editor.scss diff --git a/blocks/library/block/index.php b/blocks/library/block/index.php index a21fd0645d188b..0048ab4d764622 100644 --- a/blocks/library/block/index.php +++ b/blocks/library/block/index.php @@ -35,7 +35,17 @@ function gutenberg_render_core_reusable_block( $attributes ) { function register_core_reusable_block() { wp_register_script( 'core-reusable-block', gutenberg_url( '/build/__block_block.js' ) ); + wp_register_style( + 'core-reusable-block-editor', + gutenberg_url( '/build/__block_block_editor.css' ), + array(), + filemtime( gutenberg_dir_path() . 'build/__block_block_editor.css' ) + ); + + wp_style_add_data( 'core-reusable-block-editor', 'rtl', 'replace' ); + register_block_type( 'core/block', array( + 'editor_style' => 'core-reusable-block-editor', 'editor_script' => 'core-reusable-block', 'attributes' => array( 'ref' => array( diff --git a/blocks/library/block/indicator/style.scss b/blocks/library/block/indicator/editor.scss similarity index 100% rename from blocks/library/block/indicator/style.scss rename to blocks/library/block/indicator/editor.scss From f1931aaa7d4d5fe917a3996d7402266b2851deae Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Tue, 10 Apr 2018 19:16:28 +0530 Subject: [PATCH 21/41] Renamed style.scss to editor.scss for core/block in index.js as well --- blocks/library/block/edit-panel/index.js | 2 +- blocks/library/block/indicator/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/blocks/library/block/edit-panel/index.js b/blocks/library/block/edit-panel/index.js index d05596c88aaa92..40c16d169e60f2 100644 --- a/blocks/library/block/edit-panel/index.js +++ b/blocks/library/block/edit-panel/index.js @@ -9,7 +9,7 @@ import { keycodes } from '@wordpress/utils'; /** * Internal dependencies */ -import './style.scss'; +import './editor.scss'; /** * Module constants diff --git a/blocks/library/block/indicator/index.js b/blocks/library/block/indicator/index.js index ffeb4bffcfb324..8bae9744abe881 100644 --- a/blocks/library/block/indicator/index.js +++ b/blocks/library/block/indicator/index.js @@ -7,7 +7,7 @@ import { __, sprintf } from '@wordpress/i18n'; /** * Internal dependencies */ -import './style.scss'; +import './editor.scss'; function SharedBlockIndicator( { title } ) { return ( From 02812b4a5bbd7a60c2cf3ab77dad4191d8aa33c2 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Wed, 11 Apr 2018 03:31:55 +0530 Subject: [PATCH 22/41] Specified dependencies for editor_style handles for individual blocks --- blocks/library/audio/index.php | 6 +++++- blocks/library/audio/merge-conflicts.md | 1 - blocks/library/block/index.php | 6 +++++- blocks/library/button/index.php | 6 +++++- blocks/library/categories/index.php | 6 +++++- blocks/library/code/index.php | 6 +++++- blocks/library/columns/index.php | 6 +++++- blocks/library/cover-image/index.php | 6 +++++- blocks/library/embed/index.php | 6 +++++- blocks/library/freeform/index.php | 6 +++++- blocks/library/gallery/index.php | 6 +++++- blocks/library/heading/index.php | 6 +++++- blocks/library/html/index.php | 6 +++++- blocks/library/image/index.php | 6 +++++- blocks/library/latest-posts/index.php | 6 +++++- blocks/library/list/index.php | 6 +++++- blocks/library/more/index.php | 6 +++++- blocks/library/nextpage/index.php | 6 +++++- blocks/library/paragraph/index.php | 6 +++++- blocks/library/preformatted/index.php | 6 +++++- blocks/library/pullquote/index.php | 6 +++++- blocks/library/quote/index.php | 6 +++++- blocks/library/separator/index.php | 6 +++++- blocks/library/shortcode/index.php | 6 +++++- blocks/library/subhead/index.php | 6 +++++- blocks/library/table/index.php | 6 +++++- blocks/library/text-columns/index.php | 6 +++++- blocks/library/verse/index.php | 6 +++++- blocks/library/video/index.php | 6 +++++- 29 files changed, 140 insertions(+), 29 deletions(-) delete mode 100644 blocks/library/audio/merge-conflicts.md diff --git a/blocks/library/audio/index.php b/blocks/library/audio/index.php index 820983c30209df..ec888ed796cbb0 100644 --- a/blocks/library/audio/index.php +++ b/blocks/library/audio/index.php @@ -6,7 +6,11 @@ */ function register_core_audio_block() { - wp_register_script( 'core-audio-block', gutenberg_url( '/build/__block_audio.js' ) ); + wp_register_script( + 'core-audio-block', + gutenberg_url( '/build/__block_audio.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element', 'wp-utils' ) + ); wp_register_style( 'core-audio-block', diff --git a/blocks/library/audio/merge-conflicts.md b/blocks/library/audio/merge-conflicts.md deleted file mode 100644 index 87a7677c261032..00000000000000 --- a/blocks/library/audio/merge-conflicts.md +++ /dev/null @@ -1 +0,0 @@ -both modified: test/unit/setup-wp-aliases.js \ No newline at end of file diff --git a/blocks/library/block/index.php b/blocks/library/block/index.php index 0048ab4d764622..866d8fe930dd62 100644 --- a/blocks/library/block/index.php +++ b/blocks/library/block/index.php @@ -33,7 +33,11 @@ function gutenberg_render_core_reusable_block( $attributes ) { } function register_core_reusable_block() { - wp_register_script( 'core-reusable-block', gutenberg_url( '/build/__block_block.js' ) ); + wp_register_script( + 'core-reusable-block', + gutenberg_url( '/build/__block_block.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element', 'wp-data', 'wp-utils' ) + ); wp_register_style( 'core-reusable-block-editor', diff --git a/blocks/library/button/index.php b/blocks/library/button/index.php index 6cca91c9428178..cce05326bf6174 100644 --- a/blocks/library/button/index.php +++ b/blocks/library/button/index.php @@ -6,7 +6,11 @@ */ function register_core_button_block() { - wp_register_script( 'core-button-block', gutenberg_url( '/build/__block_button.js' ) ); + wp_register_script( + 'core-button-block', + gutenberg_url( '/build/__block_button.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element' ) + ); wp_register_style( 'core-button-block', diff --git a/blocks/library/categories/index.php b/blocks/library/categories/index.php index 7cec30f27609e1..cd145d121bbe73 100644 --- a/blocks/library/categories/index.php +++ b/blocks/library/categories/index.php @@ -85,7 +85,11 @@ function onCatChange() { } function register_core_categories_block() { - wp_register_script( 'core-categories-block', gutenberg_url( '/build/__block_categories.js' ) ); + wp_register_script( + 'core-categories-block', + gutenberg_url( '/build/__block_categories.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element', 'wp-data' ) + ); wp_register_style( 'core-categories-block', diff --git a/blocks/library/code/index.php b/blocks/library/code/index.php index 368a9da3a13c16..a9dcf647bc9298 100644 --- a/blocks/library/code/index.php +++ b/blocks/library/code/index.php @@ -6,7 +6,11 @@ */ function register_core_code_block() { - wp_register_script( 'core-code-block', gutenberg_url( '/build/__block_code.js' ) ); + wp_register_script( + 'core-code-block', + gutenberg_url( '/build/__block_code.js' ), + array( 'wp-blocks', 'wp-i18n' ) + ); wp_register_style( 'core-code-block-editor', diff --git a/blocks/library/columns/index.php b/blocks/library/columns/index.php index e7116969d39da1..cbeb12e782e253 100644 --- a/blocks/library/columns/index.php +++ b/blocks/library/columns/index.php @@ -6,7 +6,11 @@ */ function register_core_columns_block() { - wp_register_script( 'core-columns-block', gutenberg_url( '/build/__block_columns.js' ) ); + wp_register_script( + 'core-columns-block', + gutenberg_url( '/build/__block_columns.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components' ) + ); wp_register_style( 'core-columns-block', diff --git a/blocks/library/cover-image/index.php b/blocks/library/cover-image/index.php index 6f794cddbc95e7..b76a9527debf9d 100644 --- a/blocks/library/cover-image/index.php +++ b/blocks/library/cover-image/index.php @@ -6,7 +6,11 @@ */ function register_core_cover_image_block() { - wp_register_script( 'core-cover-image-block', gutenberg_url( '/build/__block_coverImage.js' ) ); + wp_register_script( + 'core-cover-image-block', + gutenberg_url( '/build/__block_coverImage.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components' ) + ); wp_register_style( 'core-cover-image-block', diff --git a/blocks/library/embed/index.php b/blocks/library/embed/index.php index 58417f8e7a5ac9..45aecd84938052 100644 --- a/blocks/library/embed/index.php +++ b/blocks/library/embed/index.php @@ -6,7 +6,11 @@ */ function register_core_embed_block() { - wp_register_script( 'core-embed-block', gutenberg_url( '/build/__block_embed.js' ) ); + wp_register_script( + 'core-embed-block', + gutenberg_url( '/build/__block_embed.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element' ) + ); wp_register_style( 'core-embed-block', diff --git a/blocks/library/freeform/index.php b/blocks/library/freeform/index.php index b4c45c77de1f48..ed5d1b0774dbae 100644 --- a/blocks/library/freeform/index.php +++ b/blocks/library/freeform/index.php @@ -6,7 +6,11 @@ */ function register_core_freeform_block() { - wp_register_script( 'core-freeform-block', gutenberg_url( '/build/__block_freeform.js' ) ); + wp_register_script( + 'core-freeform-block', + gutenberg_url( '/build/__block_freeform.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-utils' ) + ); wp_register_style( 'core-freeform-block-editor', diff --git a/blocks/library/gallery/index.php b/blocks/library/gallery/index.php index dbbb24dae7a2f1..36a2888bd5dc5a 100644 --- a/blocks/library/gallery/index.php +++ b/blocks/library/gallery/index.php @@ -6,7 +6,11 @@ */ function register_core_gallery_block() { - wp_register_script( 'core-gallery-block', gutenberg_url( '/build/__block_gallery.js' ) ); + wp_register_script( + 'core-gallery-block', + gutenberg_url( '/build/__block_gallery.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element', 'wp-utils', 'wp-data' ) + ); wp_register_style( 'core-gallery-block', diff --git a/blocks/library/heading/index.php b/blocks/library/heading/index.php index b48ffec4024527..b492986756fdbb 100644 --- a/blocks/library/heading/index.php +++ b/blocks/library/heading/index.php @@ -6,7 +6,11 @@ */ function register_core_heading_block() { - wp_register_script( 'core-heading-block', gutenberg_url( '/build/__block_heading.js' ) ); + wp_register_script( + 'core-heading-block', + gutenberg_url( '/build/__block_heading.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element' ) + ); wp_register_style( 'core-heading-block-editor', diff --git a/blocks/library/html/index.php b/blocks/library/html/index.php index c7c63d0cc0367e..77e458759d5ae5 100644 --- a/blocks/library/html/index.php +++ b/blocks/library/html/index.php @@ -6,7 +6,11 @@ */ function register_core_html_block() { - wp_register_script( 'core-html-block', gutenberg_url( '/build/__block_html.js' ) ); + wp_register_script( + 'core-html-block', + gutenberg_url( '/build/__block_html.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element' ) + ); wp_register_style( 'core-html-block-editor', diff --git a/blocks/library/image/index.php b/blocks/library/image/index.php index c7a0ecd2a6619f..304ce4d0cbf99a 100644 --- a/blocks/library/image/index.php +++ b/blocks/library/image/index.php @@ -6,7 +6,11 @@ */ function register_core_image_block() { - wp_register_script( 'core-image-block', gutenberg_url( '/build/__block_image.js' ) ); + wp_register_script( + 'core-image-block', + gutenberg_url( '/build/__block_image.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element', 'wp-utils', 'wp-data' ) + ); wp_register_style( 'core-image-block', diff --git a/blocks/library/latest-posts/index.php b/blocks/library/latest-posts/index.php index f841caf91d0079..f8484bb2a810d0 100644 --- a/blocks/library/latest-posts/index.php +++ b/blocks/library/latest-posts/index.php @@ -66,7 +66,11 @@ function gutenberg_render_core_latest_posts_block( $attributes ) { } function register_core_latest_posts_block() { - wp_register_script( 'core-latest-posts-block', gutenberg_url( '/build/__block_latestPosts.js' ) ); + wp_register_script( + 'core-latest-posts-block', + gutenberg_url( '/build/__block_latestPosts.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element', 'wp-utils' ) + ); wp_register_style( 'core-latest-posts-block', diff --git a/blocks/library/list/index.php b/blocks/library/list/index.php index 5b953193430962..fa256089e6972f 100644 --- a/blocks/library/list/index.php +++ b/blocks/library/list/index.php @@ -6,7 +6,11 @@ */ function register_core_list_block() { - wp_register_script( 'core-list-block', gutenberg_url( '/build/__block_list.js' ) ); + wp_register_script( + 'core-list-block', + gutenberg_url( '/build/__block_list.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-element' ) + ); wp_register_style( 'core-list-block-editor', diff --git a/blocks/library/more/index.php b/blocks/library/more/index.php index 99dd872dee8c1f..7ef26ef29a32da 100644 --- a/blocks/library/more/index.php +++ b/blocks/library/more/index.php @@ -6,7 +6,11 @@ */ function register_core_more_block() { - wp_register_script( 'core-more-block', gutenberg_url( '/build/__block_more.js' ) ); + wp_register_script( + 'core-more-block', + gutenberg_url( '/build/__block_more.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element' ) + ); wp_register_style( 'core-more-block-editor', diff --git a/blocks/library/nextpage/index.php b/blocks/library/nextpage/index.php index a2e788e5e5bc13..c96c2b705973fb 100644 --- a/blocks/library/nextpage/index.php +++ b/blocks/library/nextpage/index.php @@ -6,7 +6,11 @@ */ function register_core_nextpage_block() { - wp_register_script( 'core-nextpage-block', gutenberg_url( '/build/__block_nextpage.js' ) ); + wp_register_script( + 'core-nextpage-block', + gutenberg_url( '/build/__block_nextpage.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-element' ) + ); wp_register_style( 'core-nextpage-block-editor', diff --git a/blocks/library/paragraph/index.php b/blocks/library/paragraph/index.php index 0b29ed84467ff7..5df897579f6fae 100644 --- a/blocks/library/paragraph/index.php +++ b/blocks/library/paragraph/index.php @@ -6,7 +6,11 @@ */ function register_core_paragraph_block() { - wp_register_script( 'core-paragraph-block', gutenberg_url( '/build/__block_paragraph.js' ) ); + wp_register_script( + 'core-paragraph-block', + gutenberg_url( '/build/__block_paragraph.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element' ) + ); wp_register_style( 'core-paragraph-block', diff --git a/blocks/library/preformatted/index.php b/blocks/library/preformatted/index.php index 1ada23fc744c27..aad099b61029d5 100644 --- a/blocks/library/preformatted/index.php +++ b/blocks/library/preformatted/index.php @@ -6,7 +6,11 @@ */ function register_core_preformatted_block() { - wp_register_script( 'core-preformatted-block', gutenberg_url( '/build/__block_preformatted.js' ) ); + wp_register_script( + 'core-preformatted-block', + gutenberg_url( '/build/__block_preformatted.js' ), + array( 'wp-blocks', 'wp-i18n' ) + ); wp_register_style( 'core-preformatted-block-editor', diff --git a/blocks/library/pullquote/index.php b/blocks/library/pullquote/index.php index 2fcec9985b4f54..3a746b47bf659c 100644 --- a/blocks/library/pullquote/index.php +++ b/blocks/library/pullquote/index.php @@ -6,7 +6,11 @@ */ function register_core_pullquote_block() { - wp_register_script( 'core-pullquote-block', gutenberg_url( '/build/__block_pullquote.js' ) ); + wp_register_script( + 'core-pullquote-block', + gutenberg_url( '/build/__block_pullquote.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components' ) + ); wp_register_style( 'core-pullquote-block', diff --git a/blocks/library/quote/index.php b/blocks/library/quote/index.php index f385f967b9ef13..938d765752fe13 100644 --- a/blocks/library/quote/index.php +++ b/blocks/library/quote/index.php @@ -6,7 +6,11 @@ */ function register_core_quote_block() { - wp_register_script( 'core-quote-block', gutenberg_url( '/build/__block_quote.js' ) ); + wp_register_script( + 'core-quote-block', + gutenberg_url( '/build/__block_quote.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components' ) + ); wp_register_style( 'core-quote-block', diff --git a/blocks/library/separator/index.php b/blocks/library/separator/index.php index e0d5ab4d52dfb9..e0ae81e6b55b53 100644 --- a/blocks/library/separator/index.php +++ b/blocks/library/separator/index.php @@ -6,7 +6,11 @@ */ function register_core_separator_block() { - wp_register_script( 'core-separator-block', gutenberg_url( '/build/__block_separator.js' ) ); + wp_register_script( + 'core-separator-block', + gutenberg_url( '/build/__block_separator.js' ), + array( 'wp-blocks', 'wp-i18n' ) + ); wp_register_style( 'core-separator-block', diff --git a/blocks/library/shortcode/index.php b/blocks/library/shortcode/index.php index de8ef3703c2186..dacf105569ae41 100644 --- a/blocks/library/shortcode/index.php +++ b/blocks/library/shortcode/index.php @@ -6,7 +6,11 @@ */ function register_core_shortcode_block() { - wp_register_script( 'core-shortcode-block', gutenberg_url( '/build/__block_shortcode.js' ) ); + wp_register_script( + 'core-shortcode-block', + gutenberg_url( '/build/__block_shortcode.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element' ) + ); wp_register_style( 'core-shortcode-block-editor', diff --git a/blocks/library/subhead/index.php b/blocks/library/subhead/index.php index d2dc0f537234fc..c4c19d8f76f1ca 100644 --- a/blocks/library/subhead/index.php +++ b/blocks/library/subhead/index.php @@ -6,7 +6,11 @@ */ function register_core_subhead_block() { - wp_register_script( 'core-subhead-block', gutenberg_url( '/build/__block_subhead.js' ) ); + wp_register_script( + 'core-subhead-block', + gutenberg_url( '/build/__block_subhead.js' ), + array( 'wp-blocks', 'wp-i18n' ) + ); wp_register_style( 'core-subhead-block', diff --git a/blocks/library/table/index.php b/blocks/library/table/index.php index 9b035a71791144..30dca33b3ef3ae 100644 --- a/blocks/library/table/index.php +++ b/blocks/library/table/index.php @@ -6,7 +6,11 @@ */ function register_core_table_block() { - wp_register_script( 'core-table-block', gutenberg_url( '/build/__block_table.js' ) ); + wp_register_script( + 'core-table-block', + gutenberg_url( '/build/__block_table.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element' ) + ); wp_register_style( 'core-table-block', diff --git a/blocks/library/text-columns/index.php b/blocks/library/text-columns/index.php index 628f03e349b28a..3595406d5fb956 100644 --- a/blocks/library/text-columns/index.php +++ b/blocks/library/text-columns/index.php @@ -6,7 +6,11 @@ */ function register_core_text_columns_block() { - wp_register_script( 'core-text-columns-block', gutenberg_url( '/build/__block_textColumns.js' ) ); + wp_register_script( + 'core-text-columns-block', + gutenberg_url( '/build/__block_textColumns.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components' ) + ); wp_register_style( 'core-text-columns-block', diff --git a/blocks/library/verse/index.php b/blocks/library/verse/index.php index 513868203c941b..18478ba01ad241 100644 --- a/blocks/library/verse/index.php +++ b/blocks/library/verse/index.php @@ -6,7 +6,11 @@ */ function register_core_verse_block() { - wp_register_script( 'core-verse-block', gutenberg_url( '/build/__block_verse.js' ) ); + wp_register_script( + 'core-verse-block', + gutenberg_url( '/build/__block_verse.js' ), + array( 'wp-blocks', 'wp-i18n' ) + ); wp_register_style( 'core-verse-block-editor', diff --git a/blocks/library/video/index.php b/blocks/library/video/index.php index fe030efd606888..951e5bba51ae42 100644 --- a/blocks/library/video/index.php +++ b/blocks/library/video/index.php @@ -6,7 +6,11 @@ */ function register_core_video_block() { - wp_register_script( 'core-video-block', gutenberg_url( '/build/__block_video.js' ) ); + wp_register_script( + 'core-video-block', + gutenberg_url( '/build/__block_video.js' ), + array( 'wp-blocks', 'wp-i18n', 'wp-components', 'wp-element', 'wp-utils' ) + ); wp_register_style( 'core-video-block', From 28727b04b640f794b418b04cb6c844bb4f6d4ec5 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Thu, 12 Apr 2018 04:07:02 +0530 Subject: [PATCH 23/41] Fixed issues in Webpack configuration Removed commonBlockCSSPlugin since it's function can now be implemented by mainCSSExtractTextPlugin. Also, CSS for all modules will now bundle to /root/build/ rather than /root/folder/build/ --- webpack.config.js | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index b60ec4c72c49ec..12130c313a6275 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -14,7 +14,7 @@ const CustomTemplatedPathPlugin = require( '@wordpress/custom-templated-path-web // Main CSS loader for everything but blocks.. const mainCSSExtractTextPlugin = new ExtractTextPlugin( { - filename: './[basename]/build/style.css', + filename: './build/[name].css', } ); // CSS loader for styles specific to block editing. @@ -27,11 +27,6 @@ const individualBlocksCSSPlugin = new ExtractTextPlugin( { filename: './build/[name].css', } ); -// CSS loader for common styles specific to blocks in general. -const commonBlocksCSSPlugin = new ExtractTextPlugin( { - filename: './blocks/build/style.css', -} ); - // Configuration for the ExtractTextPlugin. const extractConfig = { use: [ @@ -156,16 +151,6 @@ const config = { exclude: /node_modules/, use: 'babel-loader', }, - { - test: /style\.s?css$/, - include: [ - /blocks/, - ], - exclude: [ - /blocks\/library/, - ], - use: commonBlocksCSSPlugin.extract( extractConfig ), - }, { test: /style\.s?css$/, include: [ @@ -176,21 +161,20 @@ const config = { { test: /editor\.s?css$/, include: [ - /blocks/, + /blocks\/library/, ], use: editBlocksCSSPlugin.extract( extractConfig ), }, { test: /\.s?css$/, exclude: [ - /blocks/, + /blocks\/library/, ], use: mainCSSExtractTextPlugin.extract( extractConfig ), }, ], }, plugins: [ - commonBlocksCSSPlugin, individualBlocksCSSPlugin, editBlocksCSSPlugin, mainCSSExtractTextPlugin, @@ -231,4 +215,4 @@ if ( config.mode !== 'production' ) { config.devtool = process.env.SOURCEMAP || 'source-map'; } -module.exports = config; +module.exports = config; \ No newline at end of file From 21dc8d76f2045658fa64b8252a3ad3cea83fc39b Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Thu, 12 Apr 2018 19:26:18 +0530 Subject: [PATCH 24/41] Imported core block library dependencies externally in individual block libraries Internal core block library dependencies were causing issues with the changed Webpack configuration in this branch. Imported them as external dependencies since individual block libraries in /blocks/library are now totally independent of core block libraries in /blocks/ --- blocks/library/audio/index.js | 6 +++--- blocks/library/block/index.js | 2 +- blocks/library/button/index.js | 12 ++++++------ blocks/library/categories/block.js | 8 +++++--- blocks/library/code/index.js | 2 +- blocks/library/columns/index.js | 8 ++++---- blocks/library/cover-image/index.js | 14 +++++++------- blocks/library/embed/index.js | 6 +++--- blocks/library/gallery/block.js | 12 +++++++----- blocks/library/gallery/gallery-image.js | 6 +----- blocks/library/heading/index.js | 8 ++++---- blocks/library/html/index.js | 2 +- blocks/library/image/block.js | 16 +++++++++------- blocks/library/latest-posts/block.js | 8 +++++--- blocks/library/list/index.js | 4 ++-- blocks/library/more/index.js | 4 ++-- blocks/library/paragraph/index.js | 12 ++++++------ blocks/library/preformatted/index.js | 2 +- blocks/library/pullquote/index.js | 6 +++--- blocks/library/quote/index.js | 6 +++--- blocks/library/shortcode/index.js | 2 +- blocks/library/subhead/index.js | 2 +- blocks/library/table/index.js | 4 ++-- blocks/library/table/table-block.js | 10 ++++------ blocks/library/text-columns/index.js | 8 ++++---- blocks/library/verse/index.js | 2 +- blocks/library/video/index.js | 8 ++++---- 27 files changed, 91 insertions(+), 89 deletions(-) diff --git a/blocks/library/audio/index.js b/blocks/library/audio/index.js index a5a29deadd5018..fc60a82f4862e2 100644 --- a/blocks/library/audio/index.js +++ b/blocks/library/audio/index.js @@ -9,6 +9,9 @@ import { __ } from '@wordpress/i18n'; import { registerBlockType, + MediaUpload, + RichText, + BlockControls, } from '@wordpress/blocks'; import { @@ -27,9 +30,6 @@ import { mediaUpload } from '@wordpress/utils'; */ import './style.scss'; import './editor.scss'; -import MediaUpload from '../../media-upload'; -import RichText from '../../rich-text'; -import BlockControls from '../../block-controls'; registerBlockType( 'core/audio', { title: __( 'Audio' ), diff --git a/blocks/library/block/index.js b/blocks/library/block/index.js index 1b30a01edb45f6..9f2b2cc71e733d 100644 --- a/blocks/library/block/index.js +++ b/blocks/library/block/index.js @@ -12,12 +12,12 @@ import { withSelect, withDispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { registerBlockType, + BlockEdit, } from '@wordpress/blocks'; /** * Internal dependencies */ -import BlockEdit from '../../block-edit'; import SharedBlockEditPanel from './edit-panel'; import SharedBlockIndicator from './indicator'; diff --git a/blocks/library/button/index.js b/blocks/library/button/index.js index 5c3c937a7e25a9..ea94aae3b84ffa 100644 --- a/blocks/library/button/index.js +++ b/blocks/library/button/index.js @@ -4,6 +4,12 @@ import { __ } from '@wordpress/i18n'; import { registerBlockType, + RichText, + UrlInput, + BlockControls, + BlockAlignmentToolbar, + ColorPalette, + InspectorControls, } from '@wordpress/blocks'; import { Component } from '@wordpress/element'; import { @@ -20,13 +26,7 @@ import { */ import './editor.scss'; import './style.scss'; -import RichText from '../../rich-text'; -import UrlInput from '../../url-input'; -import BlockControls from '../../block-controls'; -import BlockAlignmentToolbar from '../../block-alignment-toolbar'; -import ColorPalette from '../../color-palette'; import ContrastChecker from '../../contrast-checker'; -import InspectorControls from '../../inspector-controls'; const { getComputedStyle } = window; diff --git a/blocks/library/categories/block.js b/blocks/library/categories/block.js index e2cc937fe7bae0..8fe806e563f37c 100644 --- a/blocks/library/categories/block.js +++ b/blocks/library/categories/block.js @@ -2,6 +2,11 @@ * WordPress dependencies */ import { Component } from '@wordpress/element'; +import { + InspectorControls, + BlockControls, + BlockAlignmentToolbar, +} from '@wordpress/blocks'; import { PanelBody, Placeholder, Spinner, ToggleControl } from '@wordpress/components'; import { withSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; @@ -12,9 +17,6 @@ import { times, unescape } from 'lodash'; */ import './editor.scss'; import './style.scss'; -import InspectorControls from '../../inspector-controls'; -import BlockControls from '../../block-controls'; -import BlockAlignmentToolbar from '../../block-alignment-toolbar'; class CategoriesBlock extends Component { constructor() { diff --git a/blocks/library/code/index.js b/blocks/library/code/index.js index 2acb992189eb7e..734dc0cd8f1042 100644 --- a/blocks/library/code/index.js +++ b/blocks/library/code/index.js @@ -5,13 +5,13 @@ import { __ } from '@wordpress/i18n'; import { createBlock, registerBlockType, + PlainText, } from '@wordpress/blocks'; /** * Internal dependencies */ import './editor.scss'; -import PlainText from '../../plain-text'; registerBlockType( 'core/code', { title: __( 'Code' ), diff --git a/blocks/library/columns/index.js b/blocks/library/columns/index.js index 6d804ecfe0e045..d8cead93bf8d5b 100644 --- a/blocks/library/columns/index.js +++ b/blocks/library/columns/index.js @@ -11,6 +11,10 @@ import memoize from 'memize'; import { __, sprintf } from '@wordpress/i18n'; import { registerBlockType, + InspectorControls, + BlockControls, + BlockAlignmentToolbar, + InnerBlocks, } from '@wordpress/blocks'; import { PanelBody, RangeControl } from '@wordpress/components'; @@ -19,10 +23,6 @@ import { PanelBody, RangeControl } from '@wordpress/components'; */ import './style.scss'; import './editor.scss'; -import InspectorControls from '../../inspector-controls'; -import BlockControls from '../../block-controls'; -import BlockAlignmentToolbar from '../../block-alignment-toolbar'; -import InnerBlocks from '../../inner-blocks'; /** * Returns the layouts configuration for a given number of columns. diff --git a/blocks/library/cover-image/index.js b/blocks/library/cover-image/index.js index 1b84d7a16ce8d8..1210176d664e82 100644 --- a/blocks/library/cover-image/index.js +++ b/blocks/library/cover-image/index.js @@ -11,6 +11,13 @@ import { __ } from '@wordpress/i18n'; import { createBlock, registerBlockType, + RichText, + AlignmentToolbar, + MediaUpload, + ImagePlaceholder, + BlockControls, + BlockAlignmentToolbar, + InspectorControls, } from '@wordpress/blocks'; import classnames from 'classnames'; @@ -19,13 +26,6 @@ import classnames from 'classnames'; */ import './editor.scss'; import './style.scss'; -import RichText from '../../rich-text'; -import AlignmentToolbar from '../../alignment-toolbar'; -import MediaUpload from '../../media-upload'; -import ImagePlaceholder from '../../image-placeholder'; -import BlockControls from '../../block-controls'; -import BlockAlignmentToolbar from '../../block-alignment-toolbar'; -import InspectorControls from '../../inspector-controls'; const validAlignments = [ 'left', 'center', 'right', 'wide', 'full' ]; diff --git a/blocks/library/embed/index.js b/blocks/library/embed/index.js index a608b60e5e9734..0404e0ff85db37 100644 --- a/blocks/library/embed/index.js +++ b/blocks/library/embed/index.js @@ -12,6 +12,9 @@ import { __, sprintf } from '@wordpress/i18n'; import { createBlock, registerBlockType, + RichText, + BlockControls, + BlockAlignmentToolbar, } from '@wordpress/blocks'; import { Component, renderToString } from '@wordpress/element'; import { Button, Placeholder, Spinner, SandBox } from '@wordpress/components'; @@ -22,9 +25,6 @@ import classnames from 'classnames'; */ import './style.scss'; import './editor.scss'; -import RichText from '../../rich-text'; -import BlockControls from '../../block-controls'; -import BlockAlignmentToolbar from '../../block-alignment-toolbar'; // These embeds do not work in sandboxes const HOSTS_NO_PREVIEWS = [ 'facebook.com' ]; diff --git a/blocks/library/gallery/block.js b/blocks/library/gallery/block.js index 1dd4f19a32417d..48e3fb10185507 100644 --- a/blocks/library/gallery/block.js +++ b/blocks/library/gallery/block.js @@ -7,6 +7,13 @@ import { filter, pick } from 'lodash'; * WordPress dependencies */ import { Component } from '@wordpress/element'; +import { + MediaUpload, + ImagePlaceholder, + InspectorControls, + BlockControls, + BlockAlignmentToolbar, +} from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; import { mediaUpload } from '@wordpress/utils'; import { @@ -23,11 +30,6 @@ import { /** * Internal dependencies */ -import MediaUpload from '../../media-upload'; -import ImagePlaceholder from '../../image-placeholder'; -import InspectorControls from '../../inspector-controls'; -import BlockControls from '../../block-controls'; -import BlockAlignmentToolbar from '../../block-alignment-toolbar'; import GalleryImage from './gallery-image'; const MAX_COLUMNS = 8; diff --git a/blocks/library/gallery/gallery-image.js b/blocks/library/gallery/gallery-image.js index d25c715815f0ef..b03fb9e2c722ab 100644 --- a/blocks/library/gallery/gallery-image.js +++ b/blocks/library/gallery/gallery-image.js @@ -8,15 +8,11 @@ import classnames from 'classnames'; */ import { Component } from '@wordpress/element'; import { IconButton, Spinner } from '@wordpress/components'; +import { RichText } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; import { keycodes } from '@wordpress/utils'; import { withSelect } from '@wordpress/data'; -/** - * Internal dependencies - */ -import RichText from '../../rich-text'; - /** * Module constants */ diff --git a/blocks/library/heading/index.js b/blocks/library/heading/index.js index 54ca7da5a8e622..1226623f5b2266 100644 --- a/blocks/library/heading/index.js +++ b/blocks/library/heading/index.js @@ -5,6 +5,10 @@ import { __, sprintf } from '@wordpress/i18n'; import { createBlock, registerBlockType, + RichText, + BlockControls, + InspectorControls, + AlignmentToolbar, } from '@wordpress/blocks'; import { concatChildren } from '@wordpress/element'; @@ -14,10 +18,6 @@ import { PanelBody, Toolbar } from '@wordpress/components'; * Internal dependencies */ import './editor.scss'; -import RichText from '../../rich-text'; -import BlockControls from '../../block-controls'; -import InspectorControls from '../../inspector-controls'; -import AlignmentToolbar from '../../alignment-toolbar'; registerBlockType( 'core/heading', { title: __( 'Heading' ), diff --git a/blocks/library/html/index.js b/blocks/library/html/index.js index e5d785729e2df2..007ac213b96913 100644 --- a/blocks/library/html/index.js +++ b/blocks/library/html/index.js @@ -5,6 +5,7 @@ import { RawHTML } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { registerBlockType, + BlockControls, } from '@wordpress/blocks'; import { withState, SandBox, CodeEditor } from '@wordpress/components'; @@ -12,7 +13,6 @@ import { withState, SandBox, CodeEditor } from '@wordpress/components'; * Internal dependencies */ import './editor.scss'; -import BlockControls from '../../block-controls'; registerBlockType( 'core/html', { title: __( 'Custom HTML' ), diff --git a/blocks/library/image/block.js b/blocks/library/image/block.js index d303f9022cfd1d..6f6316cba62c9e 100644 --- a/blocks/library/image/block.js +++ b/blocks/library/image/block.js @@ -15,6 +15,15 @@ import { * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { + RichText, + ImagePlaceholder, + MediaUpload, + InspectorControls, + BlockControls, + BlockAlignmentToolbar, + UrlInputButton, +} from '@wordpress/blocks'; import { Component, compose } from '@wordpress/element'; import { getBlobByURL, revokeBlobURL, viewPort } from '@wordpress/utils'; import { @@ -30,13 +39,6 @@ import { withSelect } from '@wordpress/data'; /** * Internal dependencies */ -import RichText from '../../rich-text'; -import ImagePlaceholder from '../../image-placeholder'; -import MediaUpload from '../../media-upload'; -import InspectorControls from '../../inspector-controls'; -import BlockControls from '../../block-controls'; -import BlockAlignmentToolbar from '../../block-alignment-toolbar'; -import UrlInputButton from '../../url-input/button'; import ImageSize from './image-size'; import { mediaUpload } from '../../../utils/mediaupload'; diff --git a/blocks/library/latest-posts/block.js b/blocks/library/latest-posts/block.js index 2feae16fa2d46c..1db1e0401f6878 100644 --- a/blocks/library/latest-posts/block.js +++ b/blocks/library/latest-posts/block.js @@ -10,6 +10,11 @@ import { stringify } from 'querystringify'; * WordPress dependencies */ import { Component } from '@wordpress/element'; +import { + InspectorControls, + BlockControls, + BlockAlignmentToolbar, +} from '@wordpress/blocks'; import { PanelBody, Placeholder, @@ -28,9 +33,6 @@ import { decodeEntities } from '@wordpress/utils'; */ import './editor.scss'; import './style.scss'; -import InspectorControls from '../../inspector-controls'; -import BlockControls from '../../block-controls'; -import BlockAlignmentToolbar from '../../block-alignment-toolbar'; const MAX_POSTS_COLUMNS = 6; diff --git a/blocks/library/list/index.js b/blocks/library/list/index.js index e371d395b9f9fb..414d3ddac6fe46 100644 --- a/blocks/library/list/index.js +++ b/blocks/library/list/index.js @@ -11,14 +11,14 @@ import { __ } from '@wordpress/i18n'; import { createBlock, registerBlockType, + RichText, + BlockControls, } from '@wordpress/blocks'; /** * Internal dependencies */ import './editor.scss'; -import RichText from '../../rich-text'; -import BlockControls from '../../block-controls'; registerBlockType( 'core/list', { title: __( 'List' ), diff --git a/blocks/library/more/index.js b/blocks/library/more/index.js index 2c9eb1a1f669cb..765e54d21c5b0d 100644 --- a/blocks/library/more/index.js +++ b/blocks/library/more/index.js @@ -9,6 +9,8 @@ import { compact } from 'lodash'; import { __ } from '@wordpress/i18n'; import { registerBlockType, + createBlock, + InspectorControls, } from '@wordpress/blocks'; import { PanelBody, ToggleControl } from '@wordpress/components'; import { Component, RawHTML } from '@wordpress/element'; @@ -17,8 +19,6 @@ import { Component, RawHTML } from '@wordpress/element'; * Internal dependencies */ import './editor.scss'; -import { createBlock } from '../../api'; -import InspectorControls from '../../inspector-controls'; registerBlockType( 'core/more', { title: __( 'More' ), diff --git a/blocks/library/paragraph/index.js b/blocks/library/paragraph/index.js index 6c08ee2ae12002..f998f9d641688b 100644 --- a/blocks/library/paragraph/index.js +++ b/blocks/library/paragraph/index.js @@ -12,6 +12,12 @@ import { createBlock, registerBlockType, setDefaultBlockName, + AlignmentToolbar, + BlockAlignmentToolbar, + BlockControls, + RichText, + InspectorControls, + ColorPalette, } from '@wordpress/blocks'; import { concatChildren, Component, RawHTML } from '@wordpress/element'; import { @@ -31,12 +37,6 @@ import './editor.scss'; import './style.scss'; import { blockAutocompleter } from '../../autocompleters'; import { defaultAutocompleters } from '../../hooks/default-autocompleters'; -import AlignmentToolbar from '../../alignment-toolbar'; -import BlockAlignmentToolbar from '../../block-alignment-toolbar'; -import BlockControls from '../../block-controls'; -import RichText from '../../rich-text'; -import InspectorControls from '../../inspector-controls'; -import ColorPalette from '../../color-palette'; import ContrastChecker from '../../contrast-checker'; const { getComputedStyle } = window; diff --git a/blocks/library/preformatted/index.js b/blocks/library/preformatted/index.js index 153f8973f8ab3a..6cb75d1525d570 100644 --- a/blocks/library/preformatted/index.js +++ b/blocks/library/preformatted/index.js @@ -5,13 +5,13 @@ import { __ } from '@wordpress/i18n'; import { createBlock, registerBlockType, + RichText, } from '@wordpress/blocks'; /** * Internal dependencies */ import './editor.scss'; -import RichText from '../../rich-text'; registerBlockType( 'core/preformatted', { title: __( 'Preformatted' ), diff --git a/blocks/library/pullquote/index.js b/blocks/library/pullquote/index.js index 559ea4f2ef0f79..228e053b4be2a1 100644 --- a/blocks/library/pullquote/index.js +++ b/blocks/library/pullquote/index.js @@ -9,6 +9,9 @@ import { map } from 'lodash'; import { __ } from '@wordpress/i18n'; import { registerBlockType, + RichText, + BlockControls, + BlockAlignmentToolbar, } from '@wordpress/blocks'; import { withState } from '@wordpress/components'; @@ -17,9 +20,6 @@ import { withState } from '@wordpress/components'; */ import './editor.scss'; import './style.scss'; -import RichText from '../../rich-text'; -import BlockControls from '../../block-controls'; -import BlockAlignmentToolbar from '../../block-alignment-toolbar'; const toRichTextValue = value => map( value, ( subValue => subValue.children ) ); const fromRichTextValue = value => map( value, ( subValue ) => ( { diff --git a/blocks/library/quote/index.js b/blocks/library/quote/index.js index f55a3363eecc50..62206dc4901110 100644 --- a/blocks/library/quote/index.js +++ b/blocks/library/quote/index.js @@ -11,6 +11,9 @@ import { __, sprintf } from '@wordpress/i18n'; import { createBlock, registerBlockType, + AlignmentToolbar, + BlockControls, + RichText, } from '@wordpress/blocks'; import { Toolbar, withState } from '@wordpress/components'; @@ -19,9 +22,6 @@ import { Toolbar, withState } from '@wordpress/components'; */ import './style.scss'; import './editor.scss'; -import AlignmentToolbar from '../../alignment-toolbar'; -import BlockControls from '../../block-controls'; -import RichText from '../../rich-text'; const toRichTextValue = value => value.map( ( subValue => subValue.children ) ); const fromRichTextValue = value => value.map( ( subValue ) => ( { diff --git a/blocks/library/shortcode/index.js b/blocks/library/shortcode/index.js index fdc37cddae7784..c2ca129564961e 100644 --- a/blocks/library/shortcode/index.js +++ b/blocks/library/shortcode/index.js @@ -5,6 +5,7 @@ import { RawHTML } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { registerBlockType, + PlainText, } from '@wordpress/blocks'; import { withInstanceId, Dashicon } from '@wordpress/components'; @@ -13,7 +14,6 @@ import { withInstanceId, Dashicon } from '@wordpress/components'; * Internal dependencies */ import './editor.scss'; -import PlainText from '../../plain-text'; registerBlockType( 'core/shortcode', { title: __( 'Shortcode' ), diff --git a/blocks/library/subhead/index.js b/blocks/library/subhead/index.js index 17205758f56cb1..9f1e4816c58e7c 100644 --- a/blocks/library/subhead/index.js +++ b/blocks/library/subhead/index.js @@ -5,6 +5,7 @@ import { __ } from '@wordpress/i18n'; import { createBlock, registerBlockType, + RichText, } from '@wordpress/blocks'; /** @@ -12,7 +13,6 @@ import { */ import './editor.scss'; import './style.scss'; -import RichText from '../../rich-text'; registerBlockType( 'core/subhead', { title: __( 'Subhead' ), diff --git a/blocks/library/table/index.js b/blocks/library/table/index.js index 25b4ed1642b12b..2bf1e035d63cb2 100644 --- a/blocks/library/table/index.js +++ b/blocks/library/table/index.js @@ -4,6 +4,8 @@ import { __ } from '@wordpress/i18n'; import { registerBlockType, + BlockControls, + BlockAlignmentToolbar, } from '@wordpress/blocks'; /** @@ -12,8 +14,6 @@ import { import './editor.scss'; import './style.scss'; import TableBlock from './table-block'; -import BlockControls from '../../block-controls'; -import BlockAlignmentToolbar from '../../block-alignment-toolbar'; registerBlockType( 'core/table', { title: __( 'Table' ), diff --git a/blocks/library/table/table-block.js b/blocks/library/table/table-block.js index 7f91ff7c3daff0..76ce4348cb3aad 100644 --- a/blocks/library/table/table-block.js +++ b/blocks/library/table/table-block.js @@ -2,15 +2,13 @@ * WordPress dependencies */ import { Component } from '@wordpress/element'; +import { + RichText, + BlockControls, +} from '@wordpress/blocks'; import { Toolbar, DropdownMenu } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; -/** - * Internal dependencies - */ -import RichText from '../../rich-text'; -import BlockControls from '../../block-controls'; - function isTableSelected( editor ) { return editor.dom.getParent( editor.selection.getStart( true ), diff --git a/blocks/library/text-columns/index.js b/blocks/library/text-columns/index.js index 1d05a4bff004bc..bc78854772c7b2 100644 --- a/blocks/library/text-columns/index.js +++ b/blocks/library/text-columns/index.js @@ -9,6 +9,10 @@ import { times } from 'lodash'; import { __ } from '@wordpress/i18n'; import { registerBlockType, + BlockControls, + BlockAlignmentToolbar, + RichText, + InspectorControls, } from '@wordpress/blocks'; import { PanelBody, RangeControl } from '@wordpress/components'; @@ -17,10 +21,6 @@ import { PanelBody, RangeControl } from '@wordpress/components'; */ import './style.scss'; import './editor.scss'; -import BlockControls from '../../block-controls'; -import BlockAlignmentToolbar from '../../block-alignment-toolbar'; -import RichText from '../../rich-text'; -import InspectorControls from '../../inspector-controls'; registerBlockType( 'core/text-columns', { title: __( 'Text Columns' ), diff --git a/blocks/library/verse/index.js b/blocks/library/verse/index.js index 9531220a4b87cd..8f6be3eeb0f4cc 100644 --- a/blocks/library/verse/index.js +++ b/blocks/library/verse/index.js @@ -5,13 +5,13 @@ import { __ } from '@wordpress/i18n'; import { createBlock, registerBlockType, + RichText, } from '@wordpress/blocks'; /** * Internal dependencies */ import './editor.scss'; -import RichText from '../../rich-text'; registerBlockType( 'core/verse', { title: __( 'Verse' ), diff --git a/blocks/library/video/index.js b/blocks/library/video/index.js index af2d8825498e6d..674064fc79ec55 100644 --- a/blocks/library/video/index.js +++ b/blocks/library/video/index.js @@ -8,6 +8,10 @@ import { __ } from '@wordpress/i18n'; import { registerBlockType, + MediaUpload, + RichText, + BlockControls, + BlockAlignmentToolbar, } from '@wordpress/blocks'; import { Button, @@ -24,10 +28,6 @@ import { mediaUpload } from '@wordpress/utils'; */ import './style.scss'; import './editor.scss'; -import MediaUpload from '../../media-upload'; -import RichText from '../../rich-text'; -import BlockControls from '../../block-controls'; -import BlockAlignmentToolbar from '../../block-alignment-toolbar'; registerBlockType( 'core/video', { title: __( 'Video' ), From 8c86c0e094ef7a774f556ca1081650d58cca09d5 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Thu, 12 Apr 2018 19:29:07 +0530 Subject: [PATCH 25/41] Prevented exports for individual block libraries as Externals in Webpack configuration The new Webpack configuration was exporting individual block libraries in /blocks/libraries as Externals. Changed the configuration to prevent this. --- webpack.config.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 12130c313a6275..0ea37c92635542 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -107,9 +107,11 @@ const externals = { ...packageNames, ...coreGlobals, ].forEach( ( name ) => { - externals[ `@wordpress/${ name }` ] = { - this: [ 'wp', camelCaseDash( name ) ], - }; + if ( ! name.includes( 'blocks/library' ) ) { + externals[ `@wordpress/${ name }` ] = { + this: [ 'wp', camelCaseDash( name ) ], + }; + } } ); const config = { @@ -215,4 +217,4 @@ if ( config.mode !== 'production' ) { config.devtool = process.env.SOURCEMAP || 'source-map'; } -module.exports = config; \ No newline at end of file +module.exports = config; From f2eb736b00c5491a4a4338ffed8be13a0c577731 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Thu, 12 Apr 2018 22:36:11 +0530 Subject: [PATCH 26/41] Exported ContrastChecker and imported it as an external module inside Button and Paragraph block code --- blocks/index.js | 1 + blocks/library/button/index.js | 2 +- blocks/library/paragraph/index.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/blocks/index.js b/blocks/index.js index df573e723fa6b5..0fbe98ec492c4d 100644 --- a/blocks/index.js +++ b/blocks/index.js @@ -20,6 +20,7 @@ export { default as BlockControls } from './block-controls'; export { default as BlockEdit } from './block-edit'; export { default as BlockIcon } from './block-icon'; export { default as ColorPalette } from './color-palette'; +export { default as ContrastChecker } from './contrast-checker'; export { default as ImagePlaceholder } from './image-placeholder'; export { default as InnerBlocks } from './inner-blocks'; export { default as InspectorControls } from './inspector-controls'; diff --git a/blocks/library/button/index.js b/blocks/library/button/index.js index ea94aae3b84ffa..adacb14d27101f 100644 --- a/blocks/library/button/index.js +++ b/blocks/library/button/index.js @@ -9,6 +9,7 @@ import { BlockControls, BlockAlignmentToolbar, ColorPalette, + ContrastChecker, InspectorControls, } from '@wordpress/blocks'; import { Component } from '@wordpress/element'; @@ -26,7 +27,6 @@ import { */ import './editor.scss'; import './style.scss'; -import ContrastChecker from '../../contrast-checker'; const { getComputedStyle } = window; diff --git a/blocks/library/paragraph/index.js b/blocks/library/paragraph/index.js index f998f9d641688b..7778b1fd7e3982 100644 --- a/blocks/library/paragraph/index.js +++ b/blocks/library/paragraph/index.js @@ -18,6 +18,7 @@ import { RichText, InspectorControls, ColorPalette, + ContrastChecker, } from '@wordpress/blocks'; import { concatChildren, Component, RawHTML } from '@wordpress/element'; import { @@ -37,7 +38,6 @@ import './editor.scss'; import './style.scss'; import { blockAutocompleter } from '../../autocompleters'; import { defaultAutocompleters } from '../../hooks/default-autocompleters'; -import ContrastChecker from '../../contrast-checker'; const { getComputedStyle } = window; From d502c513b210ffb79adc2979b0963131e04a75b9 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Thu, 12 Apr 2018 23:05:37 +0530 Subject: [PATCH 27/41] Imported AutoCompleters as external dependencies in paragraph block code --- blocks/index.js | 1 + blocks/library/paragraph/index.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/blocks/index.js b/blocks/index.js index 0fbe98ec492c4d..56ac5fb1edfbf0 100644 --- a/blocks/index.js +++ b/blocks/index.js @@ -15,6 +15,7 @@ import './hooks'; export * from './api'; export { default as AlignmentToolbar } from './alignment-toolbar'; export { default as Autocomplete } from './autocomplete'; +export { blockAutocompleter, userAutocompleter } from './autocompleters'; export { default as BlockAlignmentToolbar } from './block-alignment-toolbar'; export { default as BlockControls } from './block-controls'; export { default as BlockEdit } from './block-edit'; diff --git a/blocks/library/paragraph/index.js b/blocks/library/paragraph/index.js index 7778b1fd7e3982..00ee312fa41283 100644 --- a/blocks/library/paragraph/index.js +++ b/blocks/library/paragraph/index.js @@ -19,6 +19,8 @@ import { InspectorControls, ColorPalette, ContrastChecker, + blockAutocompleter, + defaultAutocompleters, } from '@wordpress/blocks'; import { concatChildren, Component, RawHTML } from '@wordpress/element'; import { @@ -36,8 +38,6 @@ import { */ import './editor.scss'; import './style.scss'; -import { blockAutocompleter } from '../../autocompleters'; -import { defaultAutocompleters } from '../../hooks/default-autocompleters'; const { getComputedStyle } = window; From 8d7cf3b53fc45992ac0deb8cbd2d8123e3f7dc6f Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Sun, 15 Apr 2018 02:06:30 +0530 Subject: [PATCH 28/41] Added documentation blocks for individual block registration functions on server-side Fixed errors reported by running PHPCS linter on /blocks/library/*/index.php Also, added documentation for functions registering individual blocks on the server side --- blocks/library/audio/index.php | 19 ++++++++++++------- blocks/library/block/index.php | 15 ++++++++++----- blocks/library/button/index.php | 17 +++++++++++------ blocks/library/categories/index.php | 17 +++++++++++------ blocks/library/code/index.php | 13 +++++++++---- blocks/library/columns/index.php | 15 ++++++++++----- blocks/library/cover-image/index.php | 13 +++++++++---- blocks/library/embed/index.php | 13 +++++++++---- blocks/library/freeform/index.php | 11 ++++++++--- blocks/library/gallery/index.php | 15 ++++++++++----- blocks/library/heading/index.php | 11 ++++++++--- blocks/library/html/index.php | 11 ++++++++--- blocks/library/image/index.php | 13 +++++++++---- blocks/library/latest-posts/index.php | 17 +++++++++++------ blocks/library/list/index.php | 11 ++++++++--- blocks/library/more/index.php | 11 ++++++++--- blocks/library/nextpage/index.php | 11 ++++++++--- blocks/library/paragraph/index.php | 13 +++++++++---- blocks/library/preformatted/index.php | 11 ++++++++--- blocks/library/pullquote/index.php | 13 +++++++++---- blocks/library/quote/index.php | 13 +++++++++---- blocks/library/separator/index.php | 9 +++++++-- blocks/library/shortcode/index.php | 11 ++++++++--- blocks/library/subhead/index.php | 13 +++++++++---- blocks/library/table/index.php | 13 +++++++++---- blocks/library/text-columns/index.php | 13 +++++++++---- blocks/library/verse/index.php | 11 ++++++++--- blocks/library/video/index.php | 13 +++++++++---- 28 files changed, 253 insertions(+), 113 deletions(-) diff --git a/blocks/library/audio/index.php b/blocks/library/audio/index.php index ec888ed796cbb0..b0152c31a580f1 100644 --- a/blocks/library/audio/index.php +++ b/blocks/library/audio/index.php @@ -1,12 +1,17 @@ 'core-audio-block', - 'editor_style' => 'core-audio-block-editor', + 'style' => 'core-audio-block', + 'editor_style' => 'core-audio-block-editor', 'editor_script' => 'core-audio-block', ) ); } -add_action( 'init', 'register_core_audio_block' ); \ No newline at end of file +add_action( 'init', 'register_core_audio_block' ); diff --git a/blocks/library/block/index.php b/blocks/library/block/index.php index 866d8fe930dd62..12554a72ecb70b 100644 --- a/blocks/library/block/index.php +++ b/blocks/library/block/index.php @@ -1,6 +1,6 @@ 'core-reusable-block-editor', - 'editor_script' => 'core-reusable-block', + 'editor_style' => 'core-reusable-block-editor', + 'editor_script' => 'core-reusable-block', 'attributes' => array( 'ref' => array( 'type' => 'number', ), ), - + 'render_callback' => 'gutenberg_render_core_reusable_block', ) ); } diff --git a/blocks/library/button/index.php b/blocks/library/button/index.php index cce05326bf6174..c41e3bd3a22d62 100644 --- a/blocks/library/button/index.php +++ b/blocks/library/button/index.php @@ -1,12 +1,17 @@ 'core-button-block', - 'editor_style' => 'core-button-block-editor', + 'style' => 'core-button-block', + 'editor_style' => 'core-button-block-editor', 'editor_script' => 'core-button-block', ) ); } diff --git a/blocks/library/categories/index.php b/blocks/library/categories/index.php index cd145d121bbe73..4b49e4c1326158 100644 --- a/blocks/library/categories/index.php +++ b/blocks/library/categories/index.php @@ -1,6 +1,6 @@ 'core-categories-block', - 'editor_style' => 'core-categories-block-editor', - 'editor_script' => 'core-categories-block', + 'style' => 'core-categories-block', + 'editor_style' => 'core-categories-block-editor', + 'editor_script' => 'core-categories-block', 'render_callback' => 'gutenberg_render_core_categories_block', ) ); } diff --git a/blocks/library/code/index.php b/blocks/library/code/index.php index a9dcf647bc9298..9c037dade7ad7c 100644 --- a/blocks/library/code/index.php +++ b/blocks/library/code/index.php @@ -1,15 +1,20 @@ 'core-code-block-editor', + 'editor_style' => 'core-code-block-editor', 'editor_script' => 'core-code-block', ) ); } diff --git a/blocks/library/columns/index.php b/blocks/library/columns/index.php index cbeb12e782e253..d4cd5a4895c27b 100644 --- a/blocks/library/columns/index.php +++ b/blocks/library/columns/index.php @@ -1,10 +1,15 @@ 'core-columns-block', - 'editor_style' => 'core-columns-block-editor', + 'style' => 'core-columns-block', + 'editor_style' => 'core-columns-block-editor', 'editor_script' => 'core-columns-block', ) ); } diff --git a/blocks/library/cover-image/index.php b/blocks/library/cover-image/index.php index b76a9527debf9d..39dcb62a540108 100644 --- a/blocks/library/cover-image/index.php +++ b/blocks/library/cover-image/index.php @@ -1,10 +1,15 @@ 'core-cover-image-block', - 'editor_style' => 'core-cover-image-block-editor', + 'style' => 'core-cover-image-block', + 'editor_style' => 'core-cover-image-block-editor', 'editor_script' => 'core-cover-image-block', ) ); } diff --git a/blocks/library/embed/index.php b/blocks/library/embed/index.php index 45aecd84938052..8586ebac2fa2c2 100644 --- a/blocks/library/embed/index.php +++ b/blocks/library/embed/index.php @@ -1,10 +1,15 @@ 'core-embed-block', - 'editor_style' => 'core-embed-block-editor', + 'style' => 'core-embed-block', + 'editor_style' => 'core-embed-block-editor', 'editor_script' => 'core-embed-block', ) ); } diff --git a/blocks/library/freeform/index.php b/blocks/library/freeform/index.php index ed5d1b0774dbae..dd1e49ed108af0 100644 --- a/blocks/library/freeform/index.php +++ b/blocks/library/freeform/index.php @@ -1,10 +1,15 @@ 'core-freeform-block-editor', + 'editor_style' => 'core-freeform-block-editor', 'editor_script' => 'core-freeform-block', ) ); } diff --git a/blocks/library/gallery/index.php b/blocks/library/gallery/index.php index 36a2888bd5dc5a..29707a679cbbf2 100644 --- a/blocks/library/gallery/index.php +++ b/blocks/library/gallery/index.php @@ -1,10 +1,15 @@ 'core-gallery-block', - 'editor_style' => 'core-gallery-block-editor', + 'style' => 'core-gallery-block', + 'editor_style' => 'core-gallery-block-editor', 'editor_script' => 'core-gallery-block', ) ); - + } add_action( 'init', 'register_core_gallery_block' ); diff --git a/blocks/library/heading/index.php b/blocks/library/heading/index.php index b492986756fdbb..3eca92e4a424bc 100644 --- a/blocks/library/heading/index.php +++ b/blocks/library/heading/index.php @@ -1,10 +1,15 @@ 'core-heading-block-editor', + 'editor_style' => 'core-heading-block-editor', 'editor_script' => 'core-heading-block', ) ); } diff --git a/blocks/library/html/index.php b/blocks/library/html/index.php index 77e458759d5ae5..f2abe8dd2e2db0 100644 --- a/blocks/library/html/index.php +++ b/blocks/library/html/index.php @@ -1,10 +1,15 @@ 'core-html-block-editor', + 'editor_style' => 'core-html-block-editor', 'editor_script' => 'core-html-block', ) ); } diff --git a/blocks/library/image/index.php b/blocks/library/image/index.php index 304ce4d0cbf99a..247b909f9ebb30 100644 --- a/blocks/library/image/index.php +++ b/blocks/library/image/index.php @@ -1,10 +1,15 @@ 'core-image-block', - 'editor_style' => 'core-image-block-editor', + 'style' => 'core-image-block', + 'editor_style' => 'core-image-block-editor', 'editor_script' => 'core-image-block', ) ); } diff --git a/blocks/library/latest-posts/index.php b/blocks/library/latest-posts/index.php index f8484bb2a810d0..5accfc324a78eb 100644 --- a/blocks/library/latest-posts/index.php +++ b/blocks/library/latest-posts/index.php @@ -1,6 +1,6 @@ 'core-latest-posts-block', - 'editor_style' => 'core-latest-posts-block-editor', - 'editor_script' => 'core-latest-posts-block', + 'style' => 'core-latest-posts-block', + 'editor_style' => 'core-latest-posts-block-editor', + 'editor_script' => 'core-latest-posts-block', 'attributes' => array( 'categories' => array( 'type' => 'string', @@ -131,4 +136,4 @@ function register_core_latest_posts_block() { ) ); } -add_action( 'init', 'register_core_latest_posts_block' ); \ No newline at end of file +add_action( 'init', 'register_core_latest_posts_block' ); diff --git a/blocks/library/list/index.php b/blocks/library/list/index.php index fa256089e6972f..ab6c6a8bb6e1be 100644 --- a/blocks/library/list/index.php +++ b/blocks/library/list/index.php @@ -1,10 +1,15 @@ 'core-list-block-editor', + 'editor_style' => 'core-list-block-editor', 'editor_script' => 'core-list-block', ) ); } diff --git a/blocks/library/more/index.php b/blocks/library/more/index.php index 7ef26ef29a32da..90078c3a5cf79e 100644 --- a/blocks/library/more/index.php +++ b/blocks/library/more/index.php @@ -1,10 +1,15 @@ 'core-more-block-editor', + 'editor_style' => 'core-more-block-editor', 'editor_script' => 'core-more-block', ) ); } diff --git a/blocks/library/nextpage/index.php b/blocks/library/nextpage/index.php index c96c2b705973fb..81c7f750a63ea9 100644 --- a/blocks/library/nextpage/index.php +++ b/blocks/library/nextpage/index.php @@ -1,10 +1,15 @@ 'core-nextpage-block-editor', + 'editor_style' => 'core-nextpage-block-editor', 'editor_script' => 'core-nextpage-block', ) ); } diff --git a/blocks/library/paragraph/index.php b/blocks/library/paragraph/index.php index 5df897579f6fae..5d04b095694578 100644 --- a/blocks/library/paragraph/index.php +++ b/blocks/library/paragraph/index.php @@ -1,10 +1,15 @@ 'core-paragraph-block', - 'editor_style' => 'core-paragraph-block-editor', + 'style' => 'core-paragraph-block', + 'editor_style' => 'core-paragraph-block-editor', 'editor_script' => 'core-paragraph-block', ) ); } diff --git a/blocks/library/preformatted/index.php b/blocks/library/preformatted/index.php index aad099b61029d5..9da0987f22f156 100644 --- a/blocks/library/preformatted/index.php +++ b/blocks/library/preformatted/index.php @@ -1,10 +1,15 @@ 'core-preformatted-block-editor', + 'editor_style' => 'core-preformatted-block-editor', 'editor_script' => 'core-preformatted-block', ) ); } diff --git a/blocks/library/pullquote/index.php b/blocks/library/pullquote/index.php index 3a746b47bf659c..0bb0b568990e68 100644 --- a/blocks/library/pullquote/index.php +++ b/blocks/library/pullquote/index.php @@ -1,10 +1,15 @@ 'core-pullquote-block', - 'editor_style' => 'core-pullquote-block-editor', + 'style' => 'core-pullquote-block', + 'editor_style' => 'core-pullquote-block-editor', 'editor_script' => 'core-pullquote-block', ) ); } diff --git a/blocks/library/quote/index.php b/blocks/library/quote/index.php index 938d765752fe13..f6a156d65e099d 100644 --- a/blocks/library/quote/index.php +++ b/blocks/library/quote/index.php @@ -1,10 +1,15 @@ 'core-quote-block', - 'editor_style' => 'core-quote-block-editor', + 'style' => 'core-quote-block', + 'editor_style' => 'core-quote-block-editor', 'editor_script' => 'core-quote-block', ) ); } diff --git a/blocks/library/separator/index.php b/blocks/library/separator/index.php index e0ae81e6b55b53..e6e965b3f46935 100644 --- a/blocks/library/separator/index.php +++ b/blocks/library/separator/index.php @@ -1,10 +1,15 @@ 'core-separator-block', + 'style' => 'core-separator-block', 'editor_script' => 'core-separator-block', ) ); } diff --git a/blocks/library/shortcode/index.php b/blocks/library/shortcode/index.php index dacf105569ae41..23cfa110349d6b 100644 --- a/blocks/library/shortcode/index.php +++ b/blocks/library/shortcode/index.php @@ -1,10 +1,15 @@ 'core-shortcode-block-editor', + 'editor_style' => 'core-shortcode-block-editor', 'editor_script' => 'core-shortcode-block', ) ); } diff --git a/blocks/library/subhead/index.php b/blocks/library/subhead/index.php index c4c19d8f76f1ca..7035872ddea4a4 100644 --- a/blocks/library/subhead/index.php +++ b/blocks/library/subhead/index.php @@ -1,10 +1,15 @@ 'core-subhead-block', - 'editor_style' => 'core-subhead-block-editor', + 'style' => 'core-subhead-block', + 'editor_style' => 'core-subhead-block-editor', 'editor_script' => 'core-subhead-block', ) ); } diff --git a/blocks/library/table/index.php b/blocks/library/table/index.php index 30dca33b3ef3ae..5c9422be43b04c 100644 --- a/blocks/library/table/index.php +++ b/blocks/library/table/index.php @@ -1,10 +1,15 @@ 'core-table-block', - 'editor_style' => 'core-table-block-editor', + 'style' => 'core-table-block', + 'editor_style' => 'core-table-block-editor', 'editor_script' => 'core-table-block', ) ); } diff --git a/blocks/library/text-columns/index.php b/blocks/library/text-columns/index.php index 3595406d5fb956..079e148f182350 100644 --- a/blocks/library/text-columns/index.php +++ b/blocks/library/text-columns/index.php @@ -1,10 +1,15 @@ 'core-text-columns-block', - 'editor_style' => 'core-text-columns-block-editor', + 'style' => 'core-text-columns-block', + 'editor_style' => 'core-text-columns-block-editor', 'editor_script' => 'core-text-columns-block', ) ); } diff --git a/blocks/library/verse/index.php b/blocks/library/verse/index.php index 18478ba01ad241..81000b9dc1dc7c 100644 --- a/blocks/library/verse/index.php +++ b/blocks/library/verse/index.php @@ -1,10 +1,15 @@ 'core-verse-block-editor', + 'editor_style' => 'core-verse-block-editor', 'editor_script' => 'core-verse-block', ) ); } diff --git a/blocks/library/video/index.php b/blocks/library/video/index.php index 951e5bba51ae42..88b01ee6a4efd8 100644 --- a/blocks/library/video/index.php +++ b/blocks/library/video/index.php @@ -1,10 +1,15 @@ 'core-video-block', - 'editor_style' => 'core-video-block-editor', + 'style' => 'core-video-block', + 'editor_style' => 'core-video-block-editor', 'editor_script' => 'core-video-block', ) ); } From 46d19057b506fc2f8ede87c2649b1c5f0bdb04be Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Sun, 15 Apr 2018 15:09:17 +0530 Subject: [PATCH 29/41] Server-side registration for core-embed/ block types --- blocks/library/embed/index.js | 8 +++++ blocks/library/embed/index.php | 62 ++++++++++++++++++++++++++++++++-- 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/blocks/library/embed/index.js b/blocks/library/embed/index.js index 696e73df072b9a..36ad18a0431aa1 100644 --- a/blocks/library/embed/index.js +++ b/blocks/library/embed/index.js @@ -526,3 +526,11 @@ export const others = [ } ), }, ]; + +common.map( ( embedBlockType ) => + registerBlockType( embedBlockType.name, embedBlockType.settings ) +); + +others.map( ( embedBlockType ) => + registerBlockType( embedBlockType.name, embedBlockType.settings ) +); diff --git a/blocks/library/embed/index.php b/blocks/library/embed/index.php index 8586ebac2fa2c2..74751eed90f3ca 100644 --- a/blocks/library/embed/index.php +++ b/blocks/library/embed/index.php @@ -1,6 +1,6 @@ 'core-embed-block-editor', 'editor_script' => 'core-embed-block', ) ); + + foreach ( $common_embed_block_types as $embed_block_type_name ) { + register_block_type( $embed_block_type_name, array( + 'style' => 'core-embed-block', + 'editor_style' => 'core-embed-block-editor', + 'editor_script' => 'core-embed-block', + ) ); + } + + foreach ( $other_embed_block_types as $embed_block_type_name ) { + register_block_type( $embed_block_type_name, array( + 'style' => 'core-embed-block', + 'editor_style' => 'core-embed-block-editor', + 'editor_script' => 'core-embed-block', + ) ); + } } -add_action( 'init', 'register_core_embed_block' ); +add_action( 'init', 'register_core_embed_block_types' ); From ba78892b5275f305496c833e2c16e2d2f480f827 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Mon, 16 Apr 2018 00:45:49 +0530 Subject: [PATCH 30/41] Exported DefaultAutoCompleters from Hooks so that it can be imported in Paragraph block's JavaScript --- blocks/hooks/index.js | 2 ++ blocks/index.js | 1 + 2 files changed, 3 insertions(+) diff --git a/blocks/hooks/index.js b/blocks/hooks/index.js index e464747bf6e953..0f305eea165f6a 100644 --- a/blocks/hooks/index.js +++ b/blocks/hooks/index.js @@ -7,3 +7,5 @@ import './custom-class-name'; import './default-autocompleters'; import './generated-class-name'; import './layout'; + +export { defaultAutocompleters } from './default-autocompleters'; diff --git a/blocks/index.js b/blocks/index.js index 86625876c048cc..a373b4f40471d5 100644 --- a/blocks/index.js +++ b/blocks/index.js @@ -22,6 +22,7 @@ export { default as BlockEdit } from './block-edit'; export { default as BlockIcon } from './block-icon'; export { default as ColorPalette } from './color-palette'; export { default as ContrastChecker } from './contrast-checker'; +export { defaultAutocompleters } from './hooks'; export { default as ImagePlaceholder } from './image-placeholder'; export { default as InnerBlocks } from './inner-blocks'; export { default as InspectorControls } from './inspector-controls'; From d7dada4bb2e84c91d2e2a9e6ade55aa6457e911e Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Thu, 19 Apr 2018 02:29:23 +0530 Subject: [PATCH 31/41] Exported name and settings of each core block since they are needed for tests --- blocks/library/audio/index.js | 8 ++++-- blocks/library/block/index.js | 8 ++++-- blocks/library/button/index.js | 8 ++++-- blocks/library/categories/index.js | 8 ++++-- blocks/library/code/index.js | 8 ++++-- blocks/library/columns/index.js | 8 ++++-- blocks/library/cover-image/index.js | 8 ++++-- blocks/library/embed/index.js | 40 +++++++++++++++------------- blocks/library/freeform/index.js | 8 ++++-- blocks/library/gallery/index.js | 8 ++++-- blocks/library/heading/index.js | 8 ++++-- blocks/library/html/index.js | 8 ++++-- blocks/library/image/index.js | 8 ++++-- blocks/library/latest-posts/index.js | 8 ++++-- blocks/library/list/index.js | 8 ++++-- blocks/library/more/index.js | 8 ++++-- blocks/library/nextpage/index.js | 8 ++++-- blocks/library/paragraph/index.js | 12 ++++++--- blocks/library/preformatted/index.js | 8 ++++-- blocks/library/pullquote/index.js | 7 +++-- blocks/library/quote/index.js | 8 ++++-- blocks/library/separator/index.js | 8 ++++-- blocks/library/shortcode/index.js | 8 ++++-- blocks/library/subhead/index.js | 8 ++++-- blocks/library/table/index.js | 8 ++++-- blocks/library/text-columns/index.js | 8 ++++-- blocks/library/verse/index.js | 8 ++++-- blocks/library/video/index.js | 8 ++++-- 28 files changed, 184 insertions(+), 75 deletions(-) diff --git a/blocks/library/audio/index.js b/blocks/library/audio/index.js index 4e563ed6886af7..6b6a0615b609e2 100644 --- a/blocks/library/audio/index.js +++ b/blocks/library/audio/index.js @@ -26,7 +26,9 @@ import { mediaUpload } from '@wordpress/utils'; import './style.scss'; import './editor.scss'; -registerBlockType( 'core/audio', { +export const name = 'core/audio'; + +export const settings = { title: __( 'Audio' ), description: __( 'The Audio block allows you to embed audio files and play them back using a simple player.' ), @@ -176,4 +178,6 @@ registerBlockType( 'core/audio', { ); }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/block/index.js b/blocks/library/block/index.js index 9f2b2cc71e733d..f3913f8087a721 100644 --- a/blocks/library/block/index.js +++ b/blocks/library/block/index.js @@ -171,7 +171,9 @@ const EnhancedSharedBlockEdit = compose( [ } ), ] )( SharedBlockEdit ); -registerBlockType( 'core/block', { +export const name = 'core/block'; + +export const settings = { title: __( 'Shared Block' ), category: 'shared', isPrivate: true, @@ -189,4 +191,6 @@ registerBlockType( 'core/block', { edit: EnhancedSharedBlockEdit, save: () => null, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/button/index.js b/blocks/library/button/index.js index 89373e6a47fb4a..375bb51c675fd5 100644 --- a/blocks/library/button/index.js +++ b/blocks/library/button/index.js @@ -177,7 +177,9 @@ const blockAttributes = { }, }; -registerBlockType( 'core/button', { +export const name = 'core/button'; + +export const settings = { title: __( 'Button' ), description: __( 'A nice little button. Call something out with it.' ), @@ -239,4 +241,6 @@ registerBlockType( 'core/button', { ); }, } ], -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/categories/index.js b/blocks/library/categories/index.js index 411a765f269592..39a905e20a3391 100644 --- a/blocks/library/categories/index.js +++ b/blocks/library/categories/index.js @@ -13,7 +13,9 @@ import './editor.scss'; import './style.scss'; import CategoriesBlock from './block'; -registerBlockType( 'core/categories', { +export const name = 'core/categories'; + +export const settings = { title: __( 'Categories' ), description: __( 'Shows a list of your site\'s categories.' ), @@ -56,4 +58,6 @@ registerBlockType( 'core/categories', { save() { return null; }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/code/index.js b/blocks/library/code/index.js index 734dc0cd8f1042..09264c2f40254f 100644 --- a/blocks/library/code/index.js +++ b/blocks/library/code/index.js @@ -13,7 +13,9 @@ import { */ import './editor.scss'; -registerBlockType( 'core/code', { +export const name = 'core/code'; + +export const settings = { title: __( 'Code' ), description: __( 'The code block maintains spaces and tabs, great for showing code snippets.' ), @@ -70,4 +72,6 @@ registerBlockType( 'core/code', { save( { attributes } ) { return
{ attributes.content }
; }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/columns/index.js b/blocks/library/columns/index.js index de858625831c0e..92a1311176b20f 100644 --- a/blocks/library/columns/index.js +++ b/blocks/library/columns/index.js @@ -40,7 +40,9 @@ const getColumnLayouts = memoize( ( columns ) => { } ) ); } ); -registerBlockType( 'core/columns', { +export const name = 'core/columns'; + +export const settings = { title: sprintf( /* translators: Block title modifier */ __( '%1$s (%2$s)' ), @@ -116,4 +118,6 @@ registerBlockType( 'core/columns', { ); }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/cover-image/index.js b/blocks/library/cover-image/index.js index a31695131cc239..562f5472b63724 100644 --- a/blocks/library/cover-image/index.js +++ b/blocks/library/cover-image/index.js @@ -59,7 +59,9 @@ const blockAttributes = { }, }; -registerBlockType( 'core/cover-image', { +export const name = 'core/cover-image'; + +export const settings = { title: __( 'Cover Image' ), description: __( 'Cover Image is a bold image block with an optional title.' ), @@ -270,7 +272,9 @@ registerBlockType( 'core/cover-image', { ); }, } ], -} ); +}; + +registerBlockType( name, settings ); function dimRatioToClass( ratio ) { return ( ratio === 0 || ratio === 50 ) ? diff --git a/blocks/library/embed/index.js b/blocks/library/embed/index.js index 397906657f205f..3e50969fa30bcf 100644 --- a/blocks/library/embed/index.js +++ b/blocks/library/embed/index.js @@ -260,26 +260,28 @@ function getEmbedBlockSettings( { title, description, icon, category = 'embed', }; } -registerBlockType( 'core/embed', - getEmbedBlockSettings( { - title: __( 'Embed' ), - description: __( 'The Embed block allows you to easily add videos, images, tweets, audio, and other content to your post or page.' ), - icon: 'embed-generic', - transforms: { - from: [ - { - type: 'raw', - isMatch: ( node ) => node.nodeName === 'P' && /^\s*(https?:\/\/\S+)\s*/i.test( node.textContent ), - transform: ( node ) => { - return createBlock( 'core/embed', { - url: node.textContent.trim(), - } ); - }, +export const name = 'core/embed'; + +export const settings = getEmbedBlockSettings( { + title: __( 'Embed' ), + description: __( 'The Embed block allows you to easily add videos, images, tweets, audio, and other content to your post or page.' ), + icon: 'embed-generic', + transforms: { + from: [ + { + type: 'raw', + isMatch: ( node ) => node.nodeName === 'P' && /^\s*(https?:\/\/\S+)\s*/i.test( node.textContent ), + transform: ( node ) => { + return createBlock( 'core/embed', { + url: node.textContent.trim(), + } ); }, - ], - }, - } - ) ); + }, + ], + }, +} ); + +registerBlockType( name, settings ); export const common = [ { diff --git a/blocks/library/freeform/index.js b/blocks/library/freeform/index.js index fa43fc5c0ed363..ce544fa2bf140d 100644 --- a/blocks/library/freeform/index.js +++ b/blocks/library/freeform/index.js @@ -13,7 +13,9 @@ import { import './editor.scss'; import OldEditor from './old-editor'; -registerBlockType( 'core/freeform', { +export const name = 'core/freeform'; + +export const settings = { title: __( 'Classic' ), description: __( 'The classic editor, in block form.' ), @@ -41,4 +43,6 @@ registerBlockType( 'core/freeform', { return { content }; }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/gallery/index.js b/blocks/library/gallery/index.js index bb77b0891862d8..ed181cb4c23dda 100644 --- a/blocks/library/gallery/index.js +++ b/blocks/library/gallery/index.js @@ -72,7 +72,9 @@ const blockAttributes = { }, }; -registerBlockType( 'core/gallery', { +export const name = 'core/gallery'; + +export const settings = { title: __( 'Gallery' ), description: __( 'Image galleries are a great way to share groups of pictures on your site.' ), icon: 'format-gallery', @@ -235,4 +237,6 @@ registerBlockType( 'core/gallery', { }, }, ], -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/heading/index.js b/blocks/library/heading/index.js index 1226623f5b2266..6bafde6b3f8bff 100644 --- a/blocks/library/heading/index.js +++ b/blocks/library/heading/index.js @@ -19,7 +19,9 @@ import { PanelBody, Toolbar } from '@wordpress/components'; */ import './editor.scss'; -registerBlockType( 'core/heading', { +export const name = 'core/heading'; + +export const settings = { title: __( 'Heading' ), description: __( 'Search engines use the headings to index the structure and content of your web pages.' ), @@ -183,4 +185,6 @@ registerBlockType( 'core/heading', { ); }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/html/index.js b/blocks/library/html/index.js index 35d330afa5b3b8..58082004ee837f 100644 --- a/blocks/library/html/index.js +++ b/blocks/library/html/index.js @@ -14,7 +14,9 @@ import { withState, SandBox, CodeEditor } from '@wordpress/components'; */ import './editor.scss'; -registerBlockType( 'core/html', { +export const name = 'core/html'; + +export const settings = { title: __( 'Custom HTML' ), description: __( 'Add custom HTML code and preview it right here in the editor.' ), @@ -83,4 +85,6 @@ registerBlockType( 'core/html', { save( { attributes } ) { return { attributes.content }; }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/image/index.js b/blocks/library/image/index.js index ca0805d2e38136..f1f358b0541c26 100644 --- a/blocks/library/image/index.js +++ b/blocks/library/image/index.js @@ -55,7 +55,9 @@ const blockAttributes = { }, }; -registerBlockType( 'core/image', { +export const name = 'core/image'; + +export const settings = { title: __( 'Image' ), description: __( 'Worth a thousand words.' ), @@ -206,4 +208,6 @@ registerBlockType( 'core/image', { }, }, ], -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/latest-posts/index.js b/blocks/library/latest-posts/index.js index 3e2a95a75f37c5..af0d9c5ca7e03e 100644 --- a/blocks/library/latest-posts/index.js +++ b/blocks/library/latest-posts/index.js @@ -13,7 +13,9 @@ import './editor.scss'; import './style.scss'; import LatestPostsBlock from './block'; -registerBlockType( 'core/latest-posts', { +export const name = 'core/latest-posts'; + +export const settings = { title: __( 'Latest Posts' ), description: __( 'Shows a list of your site\'s most recent posts.' ), @@ -40,4 +42,6 @@ registerBlockType( 'core/latest-posts', { save() { return null; }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/list/index.js b/blocks/library/list/index.js index 846327dc225588..db582584273e14 100644 --- a/blocks/library/list/index.js +++ b/blocks/library/list/index.js @@ -20,7 +20,9 @@ import { */ import './editor.scss'; -registerBlockType( 'core/list', { +export const name = 'core/list'; + +export const settings = { title: __( 'List' ), description: __( 'List. Numbered or bulleted.' ), icon: 'editor-ul', @@ -312,4 +314,6 @@ registerBlockType( 'core/list', { values ); }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/more/index.js b/blocks/library/more/index.js index 1fdb29b357ab58..5f8c38243c7f98 100644 --- a/blocks/library/more/index.js +++ b/blocks/library/more/index.js @@ -20,7 +20,9 @@ import { Component, Fragment, RawHTML } from '@wordpress/element'; */ import './editor.scss'; -registerBlockType( 'core/more', { +export const name = 'core/more'; + +export const settings = { title: __( 'More' ), description: __( '"More" allows you to break your post into a part shown on index pages, and the subsequent after clicking a "Read More" link.' ), @@ -139,4 +141,6 @@ registerBlockType( 'core/more', { ); }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/nextpage/index.js b/blocks/library/nextpage/index.js index de90b69bc99c51..bb151f15eec9ee 100644 --- a/blocks/library/nextpage/index.js +++ b/blocks/library/nextpage/index.js @@ -13,7 +13,9 @@ import { RawHTML } from '@wordpress/element'; */ import './editor.scss'; -registerBlockType( 'core/nextpage', { +export const name = 'core/nextpage'; + +export const settings = { title: __( 'Page break' ), description: __( 'This block allows you to set break points on your post. Visitors of your blog are then presented with content split into multiple pages.' ), @@ -59,4 +61,6 @@ registerBlockType( 'core/nextpage', { ); }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/paragraph/index.js b/blocks/library/paragraph/index.js index 240685aa24ec73..20ffa0a77f57c8 100644 --- a/blocks/library/paragraph/index.js +++ b/blocks/library/paragraph/index.js @@ -22,7 +22,7 @@ import { blockAutocompleter, defaultAutocompleters, } from '@wordpress/blocks'; -import { +import { concatChildren, Component, Fragment, @@ -309,7 +309,9 @@ const schema = { }, }; -registerBlockType( 'core/paragraph', { +export const name = 'core/paragraph'; + +export const settings = { title: __( 'Paragraph' ), description: __( 'This is a simple text only block for adding a single paragraph of content.' ), @@ -439,6 +441,8 @@ registerBlockType( 'core/paragraph', { return

{ content }

; }, -} ); +}; + +registerBlockType( name, settings ); -setDefaultBlockName( 'core/paragraph' ); +setDefaultBlockName( name ); diff --git a/blocks/library/preformatted/index.js b/blocks/library/preformatted/index.js index 6cb75d1525d570..850f5902b6091a 100644 --- a/blocks/library/preformatted/index.js +++ b/blocks/library/preformatted/index.js @@ -13,7 +13,9 @@ import { */ import './editor.scss'; -registerBlockType( 'core/preformatted', { +export const name = 'core/preformatted'; + +export const settings = { title: __( 'Preformatted' ), description: __( 'Preformatted text keeps your spaces, tabs and linebreaks as they are.' ), @@ -84,4 +86,6 @@ registerBlockType( 'core/preformatted', { return
{ content }
; }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/pullquote/index.js b/blocks/library/pullquote/index.js index 228e053b4be2a1..f351b3ab2f49e2 100644 --- a/blocks/library/pullquote/index.js +++ b/blocks/library/pullquote/index.js @@ -47,8 +47,9 @@ const blockAttributes = { }, }; -registerBlockType( 'core/pullquote', { +export const name = 'core/pullquote'; +export const settings = { title: __( 'Pullquote' ), description: __( 'A pullquote is a brief, attention-catching quotation taken from the main text of an article and used as a subheading or graphic feature.' ), @@ -156,4 +157,6 @@ registerBlockType( 'core/pullquote', { ); }, } ], -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/quote/index.js b/blocks/library/quote/index.js index 62206dc4901110..bbd7561c312e8c 100644 --- a/blocks/library/quote/index.js +++ b/blocks/library/quote/index.js @@ -54,7 +54,9 @@ const blockAttributes = { }, }; -registerBlockType( 'core/quote', { +export const name = 'core/quote'; + +export const settings = { title: __( 'Quote' ), description: __( 'Quote. In quoting others, we cite ourselves. (Julio Cortázar)' ), icon: 'format-quote', @@ -283,4 +285,6 @@ registerBlockType( 'core/quote', { }, }, ], -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/separator/index.js b/blocks/library/separator/index.js index ff2a98f7da57c9..67c5befa492da8 100644 --- a/blocks/library/separator/index.js +++ b/blocks/library/separator/index.js @@ -12,7 +12,9 @@ import { */ import './style.scss'; -registerBlockType( 'core/separator', { +export const name = 'core/separator'; + +export const settings = { title: __( 'Separator' ), description: __( 'Use the separator to indicate a thematic change in the content.' ), @@ -45,4 +47,6 @@ registerBlockType( 'core/separator', { save() { return
; }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/shortcode/index.js b/blocks/library/shortcode/index.js index cdb480a409c4e2..6f44abef834d55 100644 --- a/blocks/library/shortcode/index.js +++ b/blocks/library/shortcode/index.js @@ -15,7 +15,9 @@ import { withInstanceId, Dashicon } from '@wordpress/components'; */ import './editor.scss'; -registerBlockType( 'core/shortcode', { +export const name = 'core/shortcode'; + +export const settings = { title: __( 'Shortcode' ), description: __( 'A shortcode is a WordPress-specific code snippet that is written between square brackets as [shortcode]. ' ), @@ -87,4 +89,6 @@ registerBlockType( 'core/shortcode', { save( { attributes } ) { return { attributes.text }; }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/subhead/index.js b/blocks/library/subhead/index.js index 9f1e4816c58e7c..1d8a7e4672355b 100644 --- a/blocks/library/subhead/index.js +++ b/blocks/library/subhead/index.js @@ -14,7 +14,9 @@ import { import './editor.scss'; import './style.scss'; -registerBlockType( 'core/subhead', { +export const name = 'core/subhead'; + +export const settings = { title: __( 'Subhead' ), description: __( 'Explanatory text under the main heading of an article.' ), @@ -83,4 +85,6 @@ registerBlockType( 'core/subhead', { return

{ content }

; }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/table/index.js b/blocks/library/table/index.js index 2bf1e035d63cb2..099dc828fcb005 100644 --- a/blocks/library/table/index.js +++ b/blocks/library/table/index.js @@ -15,7 +15,9 @@ import './editor.scss'; import './style.scss'; import TableBlock from './table-block'; -registerBlockType( 'core/table', { +export const name = 'core/table'; + +export const settings = { title: __( 'Table' ), description: __( 'Tables. Best used for tabular data.' ), icon: 'editor-table', @@ -86,4 +88,6 @@ registerBlockType( 'core/table', { ); }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/text-columns/index.js b/blocks/library/text-columns/index.js index bc78854772c7b2..603d7ee9fcc4c2 100644 --- a/blocks/library/text-columns/index.js +++ b/blocks/library/text-columns/index.js @@ -22,7 +22,9 @@ import { PanelBody, RangeControl } from '@wordpress/components'; import './style.scss'; import './editor.scss'; -registerBlockType( 'core/text-columns', { +export const name = 'core/text-columns'; + +export const settings = { title: __( 'Text Columns' ), description: __( 'Add text across columns. This block is experimental' ), @@ -121,4 +123,6 @@ registerBlockType( 'core/text-columns', { ); }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/verse/index.js b/blocks/library/verse/index.js index 8f6be3eeb0f4cc..b56b5cfe73c2e9 100644 --- a/blocks/library/verse/index.js +++ b/blocks/library/verse/index.js @@ -13,7 +13,9 @@ import { */ import './editor.scss'; -registerBlockType( 'core/verse', { +export const name = 'core/verse'; + +export const settings = { title: __( 'Verse' ), description: __( 'Write poetry and other literary expressions honoring all spaces and line-breaks.' ), @@ -74,4 +76,6 @@ registerBlockType( 'core/verse', { save( { attributes, className } ) { return
{ attributes.content }
; }, -} ); +}; + +registerBlockType( name, settings ); diff --git a/blocks/library/video/index.js b/blocks/library/video/index.js index 041a1d29778235..3c7ab49db519e6 100644 --- a/blocks/library/video/index.js +++ b/blocks/library/video/index.js @@ -29,7 +29,9 @@ import { mediaUpload } from '@wordpress/utils'; import './style.scss'; import './editor.scss'; -registerBlockType( 'core/video', { +export const name = 'core/video'; + +export const settings = { title: __( 'Video' ), description: __( 'The Video block allows you to embed video files and play them back using a simple player.' ), @@ -197,4 +199,6 @@ registerBlockType( 'core/video', { ); }, -} ); +}; + +registerBlockType( name, settings ); From 16dfb711ba424a60af26707035c70b2d33ab2e93 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Thu, 19 Apr 2018 17:37:51 +0530 Subject: [PATCH 32/41] Fixed unit tests through new registerCoreBlocks() helper function Wrote a new function registerCoreBlocks() which registers all block types in blocks/library/. Imported that helper function at places where it's required --- blocks/api/raw-handling/test/integration/index.js | 4 +++- blocks/index.js | 1 + blocks/test/full-content.js | 3 ++- blocks/test/helpers/index.js | 11 +++++++++++ editor/components/document-outline/test/index.js | 5 +++-- editor/store/test/selectors.js | 3 ++- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/blocks/api/raw-handling/test/integration/index.js b/blocks/api/raw-handling/test/integration/index.js index d5793e6c9cff55..80f42645883547 100644 --- a/blocks/api/raw-handling/test/integration/index.js +++ b/blocks/api/raw-handling/test/integration/index.js @@ -11,6 +11,8 @@ import path from 'path'; import rawHandler from '../../index'; import serialize from '../../../serializer'; +import { registerCoreBlocks } from '../../../../test/helpers'; + const types = [ 'plain', 'classic', @@ -29,7 +31,7 @@ describe( 'raw handling: integration', () => { // Load all hooks that modify blocks require( 'blocks/hooks' ); - // TODO: Need to load/register core blocks. Maybe requireIndex ? + registerCoreBlocks(); } ); types.forEach( ( type ) => { diff --git a/blocks/index.js b/blocks/index.js index 984b5af28a0a74..d73d86009a3d14 100644 --- a/blocks/index.js +++ b/blocks/index.js @@ -32,6 +32,7 @@ export { default as PlainText } from './plain-text'; export { default as MediaUpload } from './media-upload'; export { default as RichText } from './rich-text'; export { default as RichTextProvider } from './rich-text/provider'; +export { registerCoreBlocks } from './test/helpers'; export { default as UrlInput } from './url-input'; export { default as UrlInputButton } from './url-input/button'; export { default as EditorSettings, withEditorSettings } from './editor-settings'; diff --git a/blocks/test/full-content.js b/blocks/test/full-content.js index b52312306cf9da..52869b236210ad 100644 --- a/blocks/test/full-content.js +++ b/blocks/test/full-content.js @@ -9,6 +9,7 @@ import { format } from 'util'; /** * Internal dependencies */ +import { registerCoreBlocks } from './helpers'; import parse from '../api/parser'; import { parse as grammarParse } from '../api/post.pegjs'; import serialize from '../api/serializer'; @@ -100,7 +101,7 @@ describe( 'full post content fixture', () => { // Load all hooks that modify blocks require( 'blocks/hooks' ); - // TODO: Need to load/register core blocks. Maybe requireIndex ? + registerCoreBlocks(); } ); fileBasenames.forEach( ( f ) => { diff --git a/blocks/test/helpers/index.js b/blocks/test/helpers/index.js index f46573240df852..1a7c68ff0cec18 100644 --- a/blocks/test/helpers/index.js +++ b/blocks/test/helpers/index.js @@ -3,6 +3,7 @@ */ import { render } from 'enzyme'; import { noop } from 'lodash'; +import { readdirSync } from 'fs'; /** * Internal dependencies @@ -31,3 +32,13 @@ export const blockEditRender = ( name, settings ) => { /> ); }; + +export function registerCoreBlocks() { + const dirs = readdirSync( __dirname + '/../../library' ); + + dirs.forEach( ( dir ) => { + if ( ! dir.includes( '.' ) ) { + require( '../../library/' + dir ); + } + } ); +} diff --git a/editor/components/document-outline/test/index.js b/editor/components/document-outline/test/index.js index 4406fdecd49fbf..603691aa78f041 100644 --- a/editor/components/document-outline/test/index.js +++ b/editor/components/document-outline/test/index.js @@ -6,7 +6,7 @@ import { mount, shallow } from 'enzyme'; /** * WordPress dependencies */ -import { createBlock } from '@wordpress/blocks'; +import { createBlock, registerCoreBlocks } from '@wordpress/blocks'; /** * Internal dependencies @@ -16,7 +16,8 @@ import { DocumentOutline } from '../'; jest.mock( '../../block-title', () => () => 'Block Title' ); describe( 'DocumentOutline', () => { - // TODO: Need to load/register core blocks. Maybe requireIndex ? + + registerCoreBlocks(); const paragraph = createBlock( 'core/paragraph' ); const headingH1 = createBlock( 'core/heading', { diff --git a/editor/store/test/selectors.js b/editor/store/test/selectors.js index ba184c06f0a835..758b945cd8e1fb 100644 --- a/editor/store/test/selectors.js +++ b/editor/store/test/selectors.js @@ -7,7 +7,7 @@ import { filter, property, union } from 'lodash'; * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { registerBlockType, unregisterBlockType, getBlockTypes } from '@wordpress/blocks'; +import { registerBlockType, registerCoreBlocks, unregisterBlockType, getBlockTypes } from '@wordpress/blocks'; import { moment } from '@wordpress/date'; /** @@ -2626,6 +2626,7 @@ describe( 'selectors', () => { describe( 'getFrecentInserterItems', () => { beforeAll( () => { // TODO: Need to load/register core blocks (or at least some demo blocks). Maybe requireIndex ? + registerCoreBlocks(); } ); it( 'should return the most frecently used blocks', () => { From 53926f4eaadc627d4b559328beb99605022eef34 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Thu, 19 Apr 2018 17:54:48 +0530 Subject: [PATCH 33/41] Imported the 'fs' object rather than only readdirSync from it --- blocks/test/helpers/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blocks/test/helpers/index.js b/blocks/test/helpers/index.js index 1a7c68ff0cec18..c7204cf280e3bc 100644 --- a/blocks/test/helpers/index.js +++ b/blocks/test/helpers/index.js @@ -1,9 +1,9 @@ /** * External dependencie */ +import fs from 'fs'; import { render } from 'enzyme'; import { noop } from 'lodash'; -import { readdirSync } from 'fs'; /** * Internal dependencies @@ -34,7 +34,7 @@ export const blockEditRender = ( name, settings ) => { }; export function registerCoreBlocks() { - const dirs = readdirSync( __dirname + '/../../library' ); + const dirs = fs.readdirSync( __dirname + '/../../library' ); dirs.forEach( ( dir ) => { if ( ! dir.includes( '.' ) ) { From addc03f12da0275185a7555958ebb4f21b4fd33c Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Thu, 19 Apr 2018 18:50:12 +0530 Subject: [PATCH 34/41] Fixed regression: called setUnknownTypeHandlerName for freeForm block --- blocks/library/freeform/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/blocks/library/freeform/index.js b/blocks/library/freeform/index.js index ce544fa2bf140d..d35bfb26cfb55f 100644 --- a/blocks/library/freeform/index.js +++ b/blocks/library/freeform/index.js @@ -5,6 +5,7 @@ import { RawHTML } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { registerBlockType, + setUnknownTypeHandlerName, } from '@wordpress/blocks'; /** @@ -46,3 +47,5 @@ export const settings = { }; registerBlockType( name, settings ); + +setUnknownTypeHandlerName( name ); From 5b17af6e071e779e7c022511dd51fe52f1ef84f3 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Thu, 19 Apr 2018 19:00:51 +0530 Subject: [PATCH 35/41] Excluded hidden folders from output of fs.readdirSync --- blocks/test/helpers/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks/test/helpers/index.js b/blocks/test/helpers/index.js index c7204cf280e3bc..c701ea8a253191 100644 --- a/blocks/test/helpers/index.js +++ b/blocks/test/helpers/index.js @@ -37,7 +37,7 @@ export function registerCoreBlocks() { const dirs = fs.readdirSync( __dirname + '/../../library' ); dirs.forEach( ( dir ) => { - if ( ! dir.includes( '.' ) ) { + if ( dir.substring( 0, 1 ) != "." ) { require( '../../library/' + dir ); } } ); From 4a721203a2abcfea1167b0cc13aa27e148c0719b Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Fri, 20 Apr 2018 00:13:44 +0530 Subject: [PATCH 36/41] Imported registerCoreBlocks as an internal dependency (not external) in tests inside editor/ --- blocks/index.js | 1 - editor/components/block-switcher/test/index.js | 2 +- editor/components/document-outline/test/index.js | 3 ++- editor/store/test/selectors.js | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/blocks/index.js b/blocks/index.js index d73d86009a3d14..984b5af28a0a74 100644 --- a/blocks/index.js +++ b/blocks/index.js @@ -32,7 +32,6 @@ export { default as PlainText } from './plain-text'; export { default as MediaUpload } from './media-upload'; export { default as RichText } from './rich-text'; export { default as RichTextProvider } from './rich-text/provider'; -export { registerCoreBlocks } from './test/helpers'; export { default as UrlInput } from './url-input'; export { default as UrlInputButton } from './url-input/button'; export { default as EditorSettings, withEditorSettings } from './editor-settings'; diff --git a/editor/components/block-switcher/test/index.js b/editor/components/block-switcher/test/index.js index 156f419a72f22b..20666b104579a6 100644 --- a/editor/components/block-switcher/test/index.js +++ b/editor/components/block-switcher/test/index.js @@ -6,12 +6,12 @@ import { shallow } from 'enzyme'; /** * WordPress dependencies */ -import { registerCoreBlocks } from '@wordpress/blocks'; import { keycodes } from '@wordpress/utils'; /** * Internal dependencies */ +import { registerCoreBlocks } from '../../../../blocks/test/helpers'; import { BlockSwitcher } from '../'; const { DOWN } = keycodes; diff --git a/editor/components/document-outline/test/index.js b/editor/components/document-outline/test/index.js index 603691aa78f041..d5ef5a54dd71d0 100644 --- a/editor/components/document-outline/test/index.js +++ b/editor/components/document-outline/test/index.js @@ -6,12 +6,13 @@ import { mount, shallow } from 'enzyme'; /** * WordPress dependencies */ -import { createBlock, registerCoreBlocks } from '@wordpress/blocks'; +import { createBlock } from '@wordpress/blocks'; /** * Internal dependencies */ import { DocumentOutline } from '../'; +import { registerCoreBlocks } from '../../../../blocks/test/helpers'; jest.mock( '../../block-title', () => () => 'Block Title' ); diff --git a/editor/store/test/selectors.js b/editor/store/test/selectors.js index 758b945cd8e1fb..f6cd902f76a751 100644 --- a/editor/store/test/selectors.js +++ b/editor/store/test/selectors.js @@ -7,13 +7,14 @@ import { filter, property, union } from 'lodash'; * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { registerBlockType, registerCoreBlocks, unregisterBlockType, getBlockTypes } from '@wordpress/blocks'; +import { registerBlockType, unregisterBlockType, getBlockTypes } from '@wordpress/blocks'; import { moment } from '@wordpress/date'; /** * Internal dependencies */ import * as selectors from '../selectors'; +import { registerCoreBlocks } from '../../../blocks/test/helpers'; const { hasEditorUndo, From 06073784e580accfd56c4c9b563f8791e12a380e Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Fri, 20 Apr 2018 00:34:23 +0530 Subject: [PATCH 37/41] Fixed syntax errors reported by ESLINT --- blocks/test/helpers/index.js | 2 +- editor/components/document-outline/test/index.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/blocks/test/helpers/index.js b/blocks/test/helpers/index.js index c701ea8a253191..b6c659d8732f17 100644 --- a/blocks/test/helpers/index.js +++ b/blocks/test/helpers/index.js @@ -37,7 +37,7 @@ export function registerCoreBlocks() { const dirs = fs.readdirSync( __dirname + '/../../library' ); dirs.forEach( ( dir ) => { - if ( dir.substring( 0, 1 ) != "." ) { + if ( dir.substring( 0, 1 ) !== '.' ) { require( '../../library/' + dir ); } } ); diff --git a/editor/components/document-outline/test/index.js b/editor/components/document-outline/test/index.js index d5ef5a54dd71d0..6fa2fc457e559a 100644 --- a/editor/components/document-outline/test/index.js +++ b/editor/components/document-outline/test/index.js @@ -17,7 +17,6 @@ import { registerCoreBlocks } from '../../../../blocks/test/helpers'; jest.mock( '../../block-title', () => () => 'Block Title' ); describe( 'DocumentOutline', () => { - registerCoreBlocks(); const paragraph = createBlock( 'core/paragraph' ); From a04a7747d6173feefff61f56a98bdc1f6ba698e0 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Fri, 20 Apr 2018 00:46:10 +0530 Subject: [PATCH 38/41] Fixed URLs of CSS bundles for modules --- lib/client-assets.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index 72340d8865a96c..bd73c789d89caa 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -297,33 +297,33 @@ function gutenberg_register_scripts_and_styles() { wp_register_style( 'wp-editor', - gutenberg_url( 'editor/build/style.css' ), + gutenberg_url( 'build/editor.css' ), array( 'wp-components', 'wp-blocks', 'wp-editor-font' ), - filemtime( gutenberg_dir_path() . 'editor/build/style.css' ) + filemtime( gutenberg_dir_path() . 'build/editor.css' ) ); wp_style_add_data( 'wp-editor', 'rtl', 'replace' ); wp_register_style( 'wp-edit-post', - gutenberg_url( 'edit-post/build/style.css' ), + gutenberg_url( 'build/editPost.css' ), array( 'wp-components', 'wp-editor' ), - filemtime( gutenberg_dir_path() . 'edit-post/build/style.css' ) + filemtime( gutenberg_dir_path() . 'build/editPost.css' ) ); wp_style_add_data( 'wp-edit-post', 'rtl', 'replace' ); wp_register_style( 'wp-components', - gutenberg_url( 'components/build/style.css' ), + gutenberg_url( 'build/components.css' ), array(), - filemtime( gutenberg_dir_path() . 'components/build/style.css' ) + filemtime( gutenberg_dir_path() . 'build/components.css' ) ); wp_style_add_data( 'wp-components', 'rtl', 'replace' ); wp_register_style( 'wp-blocks', - gutenberg_url( 'blocks/build/style.css' ), + gutenberg_url( 'build/blocks.css' ), array(), - filemtime( gutenberg_dir_path() . 'blocks/build/style.css' ) + filemtime( gutenberg_dir_path() . 'build/blocks.css' ) ); wp_style_add_data( 'wp-blocks', 'rtl', 'replace' ); From fe922bc0b0a5e2299b6c2f639757505b954f1096 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Fri, 20 Apr 2018 16:44:27 +0530 Subject: [PATCH 39/41] Excluded files from fs.readdirSync in registerCoreBlocks() function --- blocks/test/helpers/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/blocks/test/helpers/index.js b/blocks/test/helpers/index.js index b6c659d8732f17..226fcba6918993 100644 --- a/blocks/test/helpers/index.js +++ b/blocks/test/helpers/index.js @@ -34,11 +34,16 @@ export const blockEditRender = ( name, settings ) => { }; export function registerCoreBlocks() { - const dirs = fs.readdirSync( __dirname + '/../../library' ); + const path = __dirname + '/../../library'; + const dirs = fs.readdirSync( path ); dirs.forEach( ( dir ) => { - if ( dir.substring( 0, 1 ) !== '.' ) { - require( '../../library/' + dir ); + // We only need a list of directories + if ( fs.statSync( path + '/' + dir ).isDirectory() ) { + // Exclude hidden directories + if ( dir.substring( 0, 1 ) !== '.' ) { + require( '../../library/' + dir ); + } } } ); } From 0d1c7845d8b5262f6203fdee6c4fb6c771c2602b Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Fri, 20 Apr 2018 20:36:03 +0530 Subject: [PATCH 40/41] Fixed syntax error reported by ESLINT --- blocks/library/text-columns/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks/library/text-columns/index.js b/blocks/library/text-columns/index.js index 7d126ded801d05..e41ed9233f2e70 100644 --- a/blocks/library/text-columns/index.js +++ b/blocks/library/text-columns/index.js @@ -13,7 +13,7 @@ import { BlockAlignmentToolbar, RichText, InspectorControls, -} from '@wordpress/blocks' +} from '@wordpress/blocks'; import { PanelBody, RangeControl, withState } from '@wordpress/components'; import { Fragment } from '@wordpress/element'; From e0efb0e1d03aceb06ea755a74dd07508ea35aaa0 Mon Sep 17 00:00:00 2001 From: Kanishk Dudeja Date: Mon, 23 Apr 2018 19:36:03 +0530 Subject: [PATCH 41/41] Changed the path of "build" folder for Gutenberg to confirm if npm build has run or not --- gutenberg.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg.php b/gutenberg.php index 5a6c06a03c147c..c6f167229fbfa0 100644 --- a/gutenberg.php +++ b/gutenberg.php @@ -109,7 +109,7 @@ function gutenberg_build_files_notice() { * @since 1.5.0 */ function gutenberg_pre_init() { - if ( defined( 'GUTENBERG_DEVELOPMENT_MODE' ) && GUTENBERG_DEVELOPMENT_MODE && ! file_exists( dirname( __FILE__ ) . '/blocks/build' ) ) { + if ( defined( 'GUTENBERG_DEVELOPMENT_MODE' ) && GUTENBERG_DEVELOPMENT_MODE && ! file_exists( dirname( __FILE__ ) . '/build' ) ) { add_action( 'admin_notices', 'gutenberg_build_files_notice' ); return; }