Skip to content
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
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