Skip to content

Commit

Permalink
Blocks: Addressed feedback related to BlockEditContext changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Apr 16, 2018
1 parent fbb66c8 commit cf63e10
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 56 deletions.
70 changes: 36 additions & 34 deletions blocks/library/paragraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,40 +226,42 @@ class ParagraphBlock extends Component {
/>
</PanelBody>
</InspectorControls>
<RichText
tagName="p"
className={ classnames( 'wp-block-paragraph', className, {
'has-background': backgroundColor,
'has-drop-cap': dropCap,
} ) }
style={ {
backgroundColor: backgroundColor,
color: textColor,
fontSize: fontSize ? fontSize + 'px' : undefined,
textAlign: align,
} }
value={ content }
onChange={ ( nextContent ) => {
setAttributes( {
content: nextContent,
} );
} }
onSplit={ insertBlocksAfter ?
( before, after, ...blocks ) => {
setAttributes( { content: before } );
insertBlocksAfter( [
...blocks,
createBlock( 'core/paragraph', { content: after } ),
] );
} :
undefined
}
onMerge={ mergeBlocks }
onReplace={ this.onReplace }
onRemove={ () => onReplace( [] ) }
placeholder={ placeholder || __( 'Add text or type / to add content' ) }
autocompleters={ autocompleters }
/>
<div>
<RichText
tagName="p"
className={ classnames( 'wp-block-paragraph', className, {
'has-background': backgroundColor,
'has-drop-cap': dropCap,
} ) }
style={ {
backgroundColor: backgroundColor,
color: textColor,
fontSize: fontSize ? fontSize + 'px' : undefined,
textAlign: align,
} }
value={ content }
onChange={ ( nextContent ) => {
setAttributes( {
content: nextContent,
} );
} }
onSplit={ insertBlocksAfter ?
( before, after, ...blocks ) => {
setAttributes( { content: before } );
insertBlocksAfter( [
...blocks,
createBlock( 'core/paragraph', { content: after } ),
] );
} :
undefined
}
onMerge={ mergeBlocks }
onReplace={ this.onReplace }
onRemove={ () => onReplace( [] ) }
placeholder={ placeholder || __( 'Add text or type / to add content' ) }
autocompleters={ autocompleters }
/>
</div>
</Fragment>
);
}
Expand Down
44 changes: 23 additions & 21 deletions blocks/library/paragraph/test/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,31 @@
exports[`core/paragraph block edit matches snapshot 1`] = `
<div>
<div
class="blocks-rich-text"
>
<div>
<div>
<div
class="blocks-rich-text"
>
<div>
<div
class="components-autocomplete"
>
<p
aria-autocomplete="list"
aria-expanded="false"
aria-label="Add text or type / to add content"
aria-multiline="false"
class="wp-block-paragraph blocks-rich-text__tinymce"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
/>
<p
class="blocks-rich-text__tinymce wp-block-paragraph"
<div>
<div
class="components-autocomplete"
>
Add text or type / to add content
</p>
<p
aria-autocomplete="list"
aria-expanded="false"
aria-label="Add text or type / to add content"
aria-multiline="false"
class="wp-block-paragraph blocks-rich-text__tinymce"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
/>
<p
class="blocks-rich-text__tinymce wp-block-paragraph"
>
Add text or type / to add content
</p>
</div>
</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion docs/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Gutenberg's deprecation policy is intended to support backwards-compatibility fo
## 2.7.0

- `wp.element.getWrapperDisplayName` function removed. Please use `wp.element.createHigherOrderComponent` instead.
- `isSelected` usage is no longer mandatory with `BlockControls`, `InspectorControls` and `RichText`. It is now handled by the editor internally to ensure that controls are visible only when block is selected. See updated docs: https://github.com/WordPress/gutenberg/blob/master/blocks/README.md#components.

## 2.6.0

Expand Down

0 comments on commit cf63e10

Please sign in to comment.