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

Update for latest gutenberg compatibility #23

Merged
merged 13 commits into from
Aug 13, 2018
4,519 changes: 4,519 additions & 0 deletions 01-basic-esnext/package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions 01-basic/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Using inline styles - no external stylesheet needed. Not recommended
* because all of these styles will appear in `post_content`.
*/
( function( blocks, i18n, element ) {
(function (blocks, i18n, element) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't be space after function. Should be space before function.

var el = element.createElement;
var __ = i18n.__;

Expand All @@ -17,25 +17,25 @@
};

blocks.registerBlockType( 'gutenberg-examples/example-01-basic', {
title: __( 'Example: Basic', 'gutenberg-examples' ),
Copy link
Member

Choose a reason for hiding this comment

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

Why are you removing the textdomain?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not all examples have text domain and currently it throws console error as we are not loading translations.

title: __( 'Example: Basic' ),
icon: 'universal-access-alt',
category: 'layout',
edit: function() {
edit: function () {
return el(
'p',
{ style: blockStyle },
'Hello World, step 1 (from the editor).'
);
},
save: function() {
save: function () {
return el(
'p',
{ style: blockStyle },
'Hello World, step 1 (from the frontend).'
);
},
} );
} )(
});
Copy link
Member

Choose a reason for hiding this comment

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

This spacing shouldn't be collapsed.

Copy link
Member

Choose a reason for hiding this comment

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

Still whitespace issue here; space after }.

})(
window.wp.blocks,
window.wp.i18n,
window.wp.element
Expand Down
2 changes: 1 addition & 1 deletion 02-stylesheets/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
var __ = i18n.__;

blocks.registerBlockType( 'gutenberg-examples/example-02-stylesheets', {
title: __( 'Example: Stylesheets', 'gutenberg-examples' ),
title: __( 'Example: Stylesheets' ),
icon: 'universal-access-alt',
category: 'layout',
edit: function( props ) {
Expand Down
18 changes: 8 additions & 10 deletions 03-editable-esnext/block.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { __ } = wp.i18n;
const { registerBlockType, RichText, source: { children } } = wp.blocks;
const { registerBlockType } = wp.blocks;
const { RichText } = wp.editor;

registerBlockType( 'gutenberg-examples/example-03-editable-esnext', {
title: __( 'Example: Editable (esnext)' ),
Expand All @@ -13,23 +14,20 @@ registerBlockType( 'gutenberg-examples/example-03-editable-esnext', {
},
},
edit: props => {
const { attributes: { content }, focus, className, setFocus } = props;
const { attributes: { content }, setAttributes, className } = props;
const onChangeContent = newContent => {
props.setAttributes( { content: newContent } );
setAttributes( { content: newContent } );
};
return (
<RichText
tagName="p"
className={ className }
onChange={ onChangeContent }
value={ content }
focus={ focus }
onFocus={ setFocus }
/>
);
},
save: props => (
<p>
{ props.attributes.content }
</p>
)
save: props => {
return <RichText.Content tagName="p" value={ props.attributes.content } />;
}
} );
Loading