Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Packages: Add the blocks module to the packages folder #8046

Merged
merged 5 commits into from
Jul 20, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions blocks/api/raw-handling/test/is-inline-content.js

This file was deleted.

45 changes: 0 additions & 45 deletions blocks/api/raw-handling/test/normalise-blocks.js

This file was deleted.

28 changes: 0 additions & 28 deletions blocks/api/raw-handling/test/phrasing-content-reducer.js

This file was deleted.

9 changes: 7 additions & 2 deletions core-blocks/test/full-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import { format } from 'util';
/**
* WordPress dependencies
*/
import { getBlockTypes, parse, serialize } from '@wordpress/blocks';
import {
getBlockTypes,
parse,
serialize,
unstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase
} from '@wordpress/blocks';
import { parse as grammarParse } from '@wordpress/block-serialization-spec-parser';

/**
Expand Down Expand Up @@ -100,7 +105,7 @@ function normalizeParsedBlocks( blocks ) {

describe( 'full post content fixture', () => {
beforeAll( () => {
window._wpBlocks = require( './server-registered.json' );
unstable__bootstrapServerSideBlockDefinitions( require( './server-registered.json' ) );

// Load all hooks that modify blocks
require( 'editor/hooks' );
Expand Down
18 changes: 12 additions & 6 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,18 @@
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/blob/README.md",
"parent": "packages"
},
{
"title": "@wordpress/block-serialization-spec-parser",
"slug": "packages-block-serialization-spec-parser",
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/block-serialization-spec-parser/README.md",
"parent": "packages"
},
{
"title": "@wordpress/blocks",
"slug": "packages-blocks",
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/blocks/README.md",
"parent": "packages"
},
{
"title": "@wordpress/browserslist-config",
"slug": "packages-browserslist-config",
Expand Down Expand Up @@ -425,12 +437,6 @@
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/packages/wordcount/README.md",
"parent": "packages"
},
{
"title": "@wordpress/blocks",
"slug": "packages-blocks",
"markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/blocks/README.md",
"parent": "packages"
},
{
"title": "@wordpress/core-blocks",
"slug": "packages-core-blocks",
Expand Down
5 changes: 2 additions & 3 deletions docs/tool/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const npmReadyPackages = glob( 'packages/*/package.json' )
// These are internal-only packages (for now), not yet published as standalone
// node modules.
const gutenbergPackages = [
'blocks',
'core-blocks',
'edit-post',
'editor',
Expand All @@ -29,8 +28,8 @@ module.exports = {
},
'core/blocks': {
title: 'Block Types Data',
selectors: [ path.resolve( root, 'blocks/store/selectors.js' ) ],
actions: [ path.resolve( root, 'blocks/store/actions.js' ) ],
selectors: [ path.resolve( root, 'packages/blocks/src/store/selectors.js' ) ],
actions: [ path.resolve( root, 'packages/blocks/src/store/actions.js' ) ],
},
'core/editor': {
title: 'The Editor\'s Data',
Expand Down
28 changes: 26 additions & 2 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ function gutenberg_register_scripts_and_styles() {
// WordPress packages.
wp_register_script( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.php', array() );

wp_register_script(
'wp-autop',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, autop was not a separate script but was bundled.

Copy link
Member

Choose a reason for hiding this comment

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

url and wordcount are also bundled into something, I bet editor or edit-post.

gutenberg_url( 'build/autop/index.js' ),
array(),
filemtime( gutenberg_dir_path() . 'build/autop/index.js' ),
true
);
wp_register_script(
'wp-dom-ready',
gutenberg_url( 'build/dom-ready/index.js' ),
Expand Down Expand Up @@ -297,10 +304,24 @@ function gutenberg_register_scripts_and_styles() {
wp_register_script(
'wp-blocks',
gutenberg_url( 'build/blocks/index.js' ),
array( 'wp-blob', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-shortcode', 'wp-block-serialization-spec-parser', 'wp-data', 'lodash' ),
array(
'wp-autop',
'wp-blob',
'wp-block-serialization-spec-parser',
'wp-data',
'wp-deprecated',
'wp-dom',
'wp-element',
'wp-hooks',
'wp-i18n',
'wp-is-shallow-equal',
'wp-shortcode',
'lodash'
),
filemtime( gutenberg_dir_path() . 'build/blocks/index.js' ),
true
);

wp_add_inline_script(
'wp-blocks',
gutenberg_get_script_polyfill( array(
Expand Down Expand Up @@ -1157,7 +1178,10 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
);

// Preload server-registered block schemas.
wp_localize_script( 'wp-blocks', '_wpBlocks', gutenberg_prepare_blocks_for_js() );
wp_add_inline_script(
'wp-blocks',
'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . json_encode( gutenberg_prepare_blocks_for_js() ) . ');'
Copy link
Member

Choose a reason for hiding this comment

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

yes, nice 👍

);

// Get admin url for handling meta boxes.
$meta_box_url = admin_url( 'post.php' );
Expand Down
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@wordpress/api-fetch": "file:packages/api-fetch",
"@wordpress/autop": "file:packages/autop",
"@wordpress/blob": "file:packages/blob",
"@wordpress/blocks": "file:packages/blocks",
"@wordpress/block-serialization-spec-parser": "file:packages/block-serialization-spec-parser",
"@wordpress/components": "file:packages/components",
"@wordpress/compose": "file:packages/compose",
Expand Down Expand Up @@ -46,7 +47,6 @@
"element-closest": "2.0.2",
"equivalent-key-map": "0.2.0",
"eslint-plugin-wordpress": "git://github.com/WordPress-Coding-Standards/eslint-plugin-wordpress.git#1774343f6226052a46b081e01db3fca8793cc9f1",
"hpq": "1.2.0",
"jquery": "3.3.1",
"lodash": "4.17.10",
"memize": "1.0.5",
Expand All @@ -63,8 +63,6 @@
"redux-optimist": "1.0.0",
"refx": "3.0.0",
"rememo": "3.0.0",
"showdown": "1.8.6",
"simple-html-tokenizer": "0.4.1",
"tinycolor2": "1.4.1",
"tinymce": "4.7.2",
"uuid": "3.1.0"
Expand Down
1 change: 1 addition & 0 deletions packages/blocks/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
4 changes: 3 additions & 1 deletion blocks/README.md → packages/blocks/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Blocks
# @wordpress/blocks

"Block" is the abstract term used to describe units of markup that, composed
together, form the content or layout of a webpage. The idea combines concepts
Expand Down Expand Up @@ -266,3 +266,5 @@ Returns type definitions associated with a registered block.

Returns settings associated with a registered control.


<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
50 changes: 50 additions & 0 deletions packages/blocks/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "@wordpress/blocks",
"version": "1.0.0-alpha.1",
"description": "Block API for WordPress",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
"keywords": [
"wordpress",
"blocks"
],
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/blocks/README.md",
"repository": {
"type": "git",
"url": "https://github.com/WordPress/gutenberg.git"
},
"bugs": {
"url": "https://github.com/WordPress/gutenberg/issues"
},
"main": "build/index.js",
"module": "build-module/index.js",
"dependencies": {
"@babel/runtime": "^7.0.0-beta.52",
"@wordpress/autop": "file:../autop",
"@wordpress/blob": "file:../blob",
"@wordpress/block-serialization-spec-parser": "file:../block-serialization-spec-parser",
"@wordpress/data": "file:../data",
"@wordpress/deprecated": "file:../deprecated",
"@wordpress/dom": "file:../dom",
"@wordpress/element": "file:../element",
"@wordpress/hooks": "file:../hooks",
"@wordpress/i18n": "file:../i18n",
"@wordpress/is-shallow-equal": "file:../is-shallow-equal",
"@wordpress/shortcode": "file:../shortcode",
"dom-react": "^2.2.1",
"element-closest": "^2.0.2",
"hpq": "^1.2.0",
"lodash": "^4.17.10",
"rememo": "^3.0.0",
"showdown": "^1.8.6",
"simple-html-tokenizer": "^0.4.1",
"tinycolor2": "^1.4.1",
"uuid": "^3.1.0"
},
"devDependencies": {
"deep-freeze": "^0.0.1"
},
"publishConfig": {
"access": "public"
}
}
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions blocks/api/index.js → packages/blocks/src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export {
isSharedBlock,
getChildBlockNames,
hasChildBlocks,
unstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase
} from './registration';
export {
isUnmodifiedDefaultBlock,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { equal } from 'assert';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just removed assert in favor of Jest built-in asserters in all these tests

Copy link
Member

Choose a reason for hiding this comment

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

Awesome, I like this 💯


/**
* Internal dependencies
*/
Expand All @@ -13,6 +8,6 @@ describe( 'blockquoteNormaliser', () => {
it( 'should normalise blockquote', () => {
const input = '<blockquote>test</blockquote>';
const output = '<blockquote><p>test</p></blockquote>';
equal( deepFilterHTML( input, [ blockquoteNormaliser ] ), output );
expect( deepFilterHTML( input, [ blockquoteNormaliser ] ) ).toEqual( output );
} );
} );
Loading