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

Reorganize core supported blocks into top-level blocks directory #399

Merged
merged 5 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
],
"plugins": [
"lodash",
"transform-runtime",
"transform-object-rest-spread",
[ "transform-react-jsx", {
"pragma": "wp.element.createElement"
Expand All @@ -18,6 +17,11 @@
} ]
],
"env": {
"default": {
"plugins": [
"transform-runtime"
]
},
"test": {
"presets": [ "latest" ]
}
Expand Down
File renamed without changes.
17 changes: 17 additions & 0 deletions blocks/api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* External dependencies
*/
import * as query from 'hpq';

export { query };
export { default as parse } from './parser';
export { default as serialize } from './serializer';
export { getCategories } from './categories';
export {
registerBlock,
unregisterBlock,
setUnknownTypeHandler,
getUnknownTypeHandler,
getBlockSettings,
getBlocks
} from './registration';
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions blocks/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Editable } from './editable';
19 changes: 4 additions & 15 deletions blocks/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
/**
* External dependencies
* Internal dependencies
*/
import * as query from 'hpq';
import './library';

export { query };
export { default as Editable } from './components/editable';
export { default as parse } from './parser';
export { default as serialize } from './serializer';
export { getCategories } from './categories';
export {
registerBlock,
unregisterBlock,
setUnknownTypeHandler,
getUnknownTypeHandler,
getBlockSettings,
getBlocks
} from './registration';
export * from './api';
export * from './components';
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
const { html } = wp.blocks.query;
/**
* Internal dependencies
*/
import { registerBlock, query, setUnknownTypeHandler } from 'api';

wp.blocks.registerBlock( 'core/freeform', {
const { html } = query;

registerBlock( 'core/freeform', {
title: wp.i18n.__( 'Freeform' ),

icon: 'text',
Expand All @@ -27,4 +32,4 @@ wp.blocks.registerBlock( 'core/freeform', {
}
} );

wp.blocks.setUnknownTypeHandler( 'core/freeform' );
setUnknownTypeHandler( 'core/freeform' );
11 changes: 8 additions & 3 deletions editor/blocks/image/index.js → blocks/library/image/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
const { attr, html } = wp.blocks.query;
const Editable = wp.blocks.Editable;
/**
* Internal dependencies
*/
import { registerBlock, query } from 'api';
import Editable from 'components/editable';

wp.blocks.registerBlock( 'core/image', {
const { attr, html } = query;

registerBlock( 'core/image', {
title: wp.i18n.__( 'Image' ),

icon: 'format-image',
Expand Down
1 change: 0 additions & 1 deletion editor/blocks/index.js → blocks/library/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ import './freeform';
import './image';
import './text';
import './list';

16 changes: 7 additions & 9 deletions editor/blocks/list/index.js → blocks/library/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@
* Internal dependencies
*/
import './style.scss';
import { registerBlock, query } from 'api';
import Editable from 'components/editable';

const Editable = wp.blocks.Editable;
const { html, prop } = wp.blocks.query;
const { html, prop } = query;
Copy link
Member Author

Choose a reason for hiding this comment

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

That we can't destructure query here is a little disappointing. Might be worth a rethink on exporting hpq as wp.blocks.query, either renaming the property or simply assuming dependent plugins refer to hpq directly.


wp.blocks.registerBlock( 'core/list', {
registerBlock( 'core/list', {
title: wp.i18n.__( 'List' ),
icon: 'editor-ul',
category: 'common',

attributes: {
listType: prop( 'ol,ul', 'nodeName' ),
items: wp.blocks.query.query(
'li',
{
value: html()
}
)
items: query.query( 'li', {
value: html()
} )
},

controls: [
Expand Down
File renamed without changes.
11 changes: 8 additions & 3 deletions editor/blocks/text/index.js → blocks/library/text/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
const { html, prop } = wp.blocks.query;
const Editable = wp.blocks.Editable;
/**
* Internal dependencies
*/
import { registerBlock, query } from 'api';
import Editable from 'components/editable';

wp.blocks.registerBlock( 'core/text', {
const { html, prop } = query;

registerBlock( 'core/text', {
title: wp.i18n.__( 'Text' ),

icon: 'text',
Expand Down
1 change: 0 additions & 1 deletion editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Provider } from 'react-redux';
* Internal dependencies
*/
import './assets/stylesheets/main.scss';
import './blocks';
import Layout from './layout';
import { createReduxStore } from './state';

Expand Down
26 changes: 13 additions & 13 deletions languages/gutenberg.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"X-Generator: babel-plugin-wp-i18n\n"

#: editor/blocks/freeform/index.js:4
#: blocks/library/freeform/index.js:9
msgid "Freeform"
msgstr ""

#: editor/blocks/image/index.js:26
msgid "Write caption…"
#: blocks/library/image/index.js:10
msgid "Image"
msgstr ""

#: editor/blocks/image/index.js:5
msgid "Image"
#: blocks/library/image/index.js:31
msgid "Write caption…"
msgstr ""

#: editor/blocks/list/index.js:10
#: blocks/library/list/index.js:11
msgid "List"
msgstr ""

#: editor/blocks/list/index.js:27
#: editor/blocks/text/index.js:19
#: blocks/library/list/index.js:25
#: blocks/library/text/index.js:24
msgid "Align left"
msgstr ""

#: editor/blocks/list/index.js:35
#: editor/blocks/text/index.js:27
#: blocks/library/list/index.js:33
#: blocks/library/text/index.js:32
msgid "Align center"
msgstr ""

#: editor/blocks/list/index.js:43
#: editor/blocks/text/index.js:35
#: blocks/library/list/index.js:41
#: blocks/library/text/index.js:40
msgid "Align right"
msgstr ""

#: editor/blocks/list/index.js:51
#: blocks/library/list/index.js:49
msgid "Justify"
msgstr ""

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
],
"scripts": {
"test-unit": "cross-env NODE_ENV=test webpack && mocha build --require bootstrap-test.js",
"build": "cross-env NODE_ENV=production webpack",
"build": "cross-env BABEL_ENV=default NODE_ENV=production webpack",
"lint": "eslint .",
"dev": "webpack --watch",
"dev": "cross-env BABEL_ENV=default webpack --watch",
"test": "npm run lint && npm run test-unit"
},
"devDependencies": {
Expand Down