Skip to content

Commit

Permalink
Blocks: Remove wrapping div from paragraph block (#7477)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth authored and gziolo committed Jun 25, 2018
1 parent e7c7f51 commit ae8f041
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 66 deletions.
84 changes: 41 additions & 43 deletions core-blocks/paragraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,49 +210,47 @@ class ParagraphBlock extends Component {
isLargeText={ fontSize >= 18 }
/>
</InspectorControls>
<div>
<RichText
tagName="p"
className={ classnames( 'wp-block-paragraph', className, {
'has-background': backgroundColor.value,
'has-drop-cap': dropCap,
[ backgroundColor.class ]: backgroundColor.class,
[ textColor.class ]: textColor.class,
} ) }
style={ {
backgroundColor: backgroundColor.class ? undefined : backgroundColor.value,
color: textColor.class ? undefined : textColor.value,
fontSize: fontSize ? fontSize + 'px' : undefined,
textAlign: align,
} }
value={ content }
onChange={ ( nextContent ) => {
setAttributes( {
content: nextContent,
} );
} }
onSplit={ insertBlocksAfter ?
( before, after, ...blocks ) => {
if ( after ) {
blocks.push( createBlock( name, { content: after } ) );
}

insertBlocksAfter( blocks );

if ( before ) {
setAttributes( { content: before } );
} else {
onReplace( [] );
}
} :
undefined
}
onMerge={ mergeBlocks }
onReplace={ this.onReplace }
onRemove={ () => onReplace( [] ) }
placeholder={ placeholder || __( 'Add text or type / to add content' ) }
/>
</div>
<RichText
tagName="p"
className={ classnames( 'wp-block-paragraph', className, {
'has-background': backgroundColor.value,
'has-drop-cap': dropCap,
[ backgroundColor.class ]: backgroundColor.class,
[ textColor.class ]: textColor.class,
} ) }
style={ {
backgroundColor: backgroundColor.class ? undefined : backgroundColor.value,
color: textColor.class ? undefined : textColor.value,
fontSize: fontSize ? fontSize + 'px' : undefined,
textAlign: align,
} }
value={ content }
onChange={ ( nextContent ) => {
setAttributes( {
content: nextContent,
} );
} }
onSplit={ insertBlocksAfter ?
( before, after, ...blocks ) => {
if ( after ) {
blocks.push( createBlock( name, { content: after } ) );
}

insertBlocksAfter( blocks );

if ( before ) {
setAttributes( { content: before } );
} else {
onReplace( [] );
}
} :
undefined
}
onMerge={ mergeBlocks }
onReplace={ this.onReplace }
onRemove={ () => onReplace( [] ) }
placeholder={ placeholder || __( 'Add text or type / to add content' ) }
/>
</Fragment>
);
}
Expand Down
44 changes: 21 additions & 23 deletions core-blocks/paragraph/test/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,29 @@
exports[`core/paragraph block edit matches snapshot 1`] = `
<div>
<div>
<div
class="editor-rich-text"
>
<div
class="editor-rich-text"
>
<div>
<div>
<div>
<div
class="components-autocomplete"
<div
class="components-autocomplete"
>
<p
aria-autocomplete="list"
aria-expanded="false"
aria-label="Add text or type / to add content"
aria-multiline="true"
class="wp-block-paragraph editor-rich-text__tinymce"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
/>
<p
class="editor-rich-text__tinymce wp-block-paragraph"
>
<p
aria-autocomplete="list"
aria-expanded="false"
aria-label="Add text or type / to add content"
aria-multiline="true"
class="wp-block-paragraph editor-rich-text__tinymce"
contenteditable="true"
data-is-placeholder-visible="true"
role="textbox"
/>
<p
class="editor-rich-text__tinymce wp-block-paragraph"
>
Add text or type / to add content
</p>
</div>
Add text or type / to add content
</p>
</div>
</div>
</div>
Expand Down

0 comments on commit ae8f041

Please sign in to comment.