diff --git a/packages/block-library/src/preformatted/index.js b/packages/block-library/src/preformatted/index.js index 18abd542f1460..35f0b9bf21227 100644 --- a/packages/block-library/src/preformatted/index.js +++ b/packages/block-library/src/preformatted/index.js @@ -2,7 +2,7 @@ * WordPress */ import { __ } from '@wordpress/i18n'; -import { createBlock, getPhrasingContentSchema } from '@wordpress/blocks'; +import { children, createBlock, getPhrasingContentSchema } from '@wordpress/blocks'; import { RichText } from '@wordpress/editor'; export const name = 'core/preformatted'; @@ -58,7 +58,7 @@ export const settings = { ], }, - edit( { attributes, setAttributes, className } ) { + edit( { attributes, mergeBlocks, setAttributes, className } ) { const { content } = attributes; return ( @@ -72,6 +72,7 @@ export const settings = { } } placeholder={ __( 'Write preformatted text…' ) } wrapperClassName={ className } + onMerge={ mergeBlocks } /> ); }, @@ -81,4 +82,10 @@ export const settings = { return ; }, + + merge( attributes, attributesToMerge ) { + return { + content: children.concat( attributes.content, attributesToMerge.content ), + }; + }, }; diff --git a/packages/block-library/src/quote/index.js b/packages/block-library/src/quote/index.js index 0da556e69fa65..b41a320ba1db2 100644 --- a/packages/block-library/src/quote/index.js +++ b/packages/block-library/src/quote/index.js @@ -8,7 +8,7 @@ import { castArray, get, isString, isEmpty, omit } from 'lodash'; */ import { __ } from '@wordpress/i18n'; import { Fragment } from '@wordpress/element'; -import { createBlock, getPhrasingContentSchema } from '@wordpress/blocks'; +import { children, createBlock, getPhrasingContentSchema } from '@wordpress/blocks'; import { BlockControls, AlignmentToolbar, @@ -233,6 +233,14 @@ export const settings = { ); }, + merge( attributes, attributesToMerge ) { + return { + ...attributes, + value: attributes.value.concat( attributesToMerge.value ), + citation: children.concat( attributes.citation, attributesToMerge.citation ), + }; + }, + deprecated: [ { attributes: { diff --git a/packages/block-library/src/verse/index.js b/packages/block-library/src/verse/index.js index 2ac312c7a77f6..c57a4e620d283 100644 --- a/packages/block-library/src/verse/index.js +++ b/packages/block-library/src/verse/index.js @@ -3,7 +3,7 @@ */ import { __ } from '@wordpress/i18n'; import { Fragment } from '@wordpress/element'; -import { createBlock } from '@wordpress/blocks'; +import { children, createBlock } from '@wordpress/blocks'; import { RichText, BlockControls, @@ -53,7 +53,7 @@ export const settings = { ], }, - edit( { attributes, setAttributes, className } ) { + edit( { attributes, setAttributes, className, mergeBlocks } ) { const { textAlign, content } = attributes; return ( @@ -77,6 +77,7 @@ export const settings = { style={ { textAlign: textAlign } } placeholder={ __( 'Write…' ) } wrapperClassName={ className } + onMerge={ mergeBlocks } /> ); @@ -94,4 +95,10 @@ export const settings = { /> ); }, + + merge( attributes, attributesToMerge ) { + return { + content: children.concat( attributes.content, attributesToMerge.content ), + }; + }, };