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

Add a new empty para block on Enter.KEY #159

Merged
merged 15 commits into from
Oct 16, 2018
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
2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 68 files
+1 −1 assets/stylesheets/_colors.scss
+34 −0 bin/process-git-diff.js
+1 −1 components/code-editor/index.js
+44 −1 docs/data/data-core-blocks.md
+7 −7 docs/manifest.json
+2 −0 docs/reference/deprecated.md
+171 −31 docs/reference/faq.md
+3 −3 docs/reference/scripts.md
+6 −0 docs/root-manifest.json
+4 −3 lib/client-assets.php
+751 −48 package-lock.json
+4 −1 package.json
+14 −12 packages/block-library/src/embed/index.js
+8 −0 packages/block-library/src/gallery/style.scss
+20 −1 packages/block-library/src/heading/edit.native.js
+6 −2 packages/block-library/src/index.js
+91 −0 packages/block-library/src/missing/index.js
+20 −1 packages/block-library/src/paragraph/edit.native.js
+4 −0 packages/blocks/src/api/index.js
+27 −16 packages/blocks/src/api/parser.js
+51 −2 packages/blocks/src/api/registration.js
+7 −2 packages/blocks/src/api/serializer.js
+1 −2 packages/blocks/src/api/test/factory.js
+16 −13 packages/blocks/src/api/test/parser.js
+46 −4 packages/blocks/src/api/test/registration.js
+27 −7 packages/blocks/src/api/test/serializer.js
+0 −2 packages/blocks/src/api/test/validation.js
+40 −2 packages/blocks/src/store/actions.js
+4 −2 packages/blocks/src/store/reducer.js
+33 −1 packages/blocks/src/store/selectors.js
+40 −9 packages/blocks/src/store/test/reducer.js
+1 −1 packages/components/package.json
+7 −8 packages/components/src/date-time/README.md
+50 −10 packages/components/src/date-time/date.js
+105 −15 packages/components/src/date-time/index.js
+161 −92 packages/components/src/date-time/style.scss
+73 −32 packages/components/src/date-time/test/time.js
+186 −43 packages/components/src/date-time/time.js
+23 −26 packages/components/src/form-token-field/index.js
+13 −11 packages/components/src/form-token-field/style.scss
+2 −3 packages/components/src/form-token-field/token-input.js
+6 −0 packages/date/CHANGELOG.md
+3 −0 packages/date/src/index.js
+2 −2 packages/edit-post/src/components/header/writing-menu/index.js
+29 −12 packages/edit-post/src/components/sidebar/post-schedule/index.js
+4 −0 packages/edit-post/src/components/sidebar/post-schedule/style.scss
+44 −21 packages/editor/src/components/block-inspector/index.js
+1 −0 packages/editor/src/components/block-inspector/style.scss
+4 −1 packages/editor/src/components/block-list/block.js
+2 −2 packages/editor/src/components/block-settings-menu/block-unknown-convert-button.js
+8 −2 packages/editor/src/components/block-settings-menu/reusable-block-convert-button.js
+3 −3 packages/editor/src/components/block-styles/index.js
+0 −2 packages/editor/src/components/inner-blocks/test/index.js
+12 −9 packages/editor/src/components/post-publish-panel/postpublish.js
+13 −7 packages/editor/src/components/post-publish-panel/style.scss
+12 −2 packages/editor/src/components/post-saved-state/index.js
+2 −1 packages/editor/src/components/post-schedule/label.js
+2 −2 packages/editor/src/components/post-taxonomies/flat-term-selector.js
+14 −2 packages/editor/src/components/rich-text/index.native.js
+5 −5 packages/editor/src/store/selectors.js
+9 −9 packages/editor/src/store/test/selectors.js
+59 −0 test/e2e/specs/datepicker.test.js
+130 −0 test/e2e/specs/embedding.test.js
+6 −0 test/integration/full-content/fixtures/core__missing.html
+14 −0 test/integration/full-content/fixtures/core__missing.json
+17 −0 test/integration/full-content/fixtures/core__missing.parsed.json
+6 −0 test/integration/full-content/fixtures/core__missing.serialized.html
+16 −9 webpack.config.js
2 changes: 2 additions & 0 deletions src/block-management/block-holder.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type PropsType = BlockType & {
onChange: ( clientId: string, attributes: mixed ) => void,
onToolbarButtonPressed: ( button: number, clientId: string ) => void,
onBlockHolderPressed: ( clientId: string ) => void,
insertBlocksAfter: ( blocks: Array<Object> ) => void,
};

type StateType = {
Expand Down Expand Up @@ -69,6 +70,7 @@ export default class BlockHolder extends React.Component<PropsType, StateType> {
setAttributes={ ( attrs ) =>
this.props.onChange( this.props.clientId, { ...this.props.attributes, ...attrs } )
}
insertBlocksAfter={ this.props.insertBlocksAfter }
isSelected={ this.props.focused }
style={ style }
/>
Expand Down
18 changes: 18 additions & 0 deletions src/block-management/block-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ export default class BlockManager extends React.Component<PropsType, StateType>
this.state.dataSource.setDirty();
}

insertBlocksAfter( clientId: string, blocks: Array<Object> ) {
// find currently focused block
const focusedItemIndex = this.getDataSourceIndexFromClientId( clientId );

const newBlock = blocks[ 0 ];
newBlock.focused = true;

// set it into the datasource, and use the same object instance to send it to props/redux
this.state.dataSource.splice( focusedItemIndex + 1, 0, newBlock );
this.props.createBlockAction( newBlock.clientId, newBlock, clientId );

// now set the focus
this.props.focusBlockAction( newBlock.clientId ); // this not working atm
}

onChange( clientId: string, attributes: mixed ) {
// Update Redux store
this.props.onChange( clientId, attributes );
Expand Down Expand Up @@ -252,6 +267,9 @@ export default class BlockManager extends React.Component<PropsType, StateType>
showTitle={ this.state.inspectBlocks }
focused={ value.item.focused }
clientId={ value.clientId }
insertBlocksAfter={ ( blocks ) =>
this.insertBlocksAfter.bind( this )( value.item.clientId, blocks )
}
{ ...value.item }
/>
{ this.state.blockTypePickerVisible && value.item.focused && insertHere }
Expand Down