Skip to content

Commit

Permalink
Quote block: Add transform to paragraph (#51809)
Browse files Browse the repository at this point in the history
* Add ungroup transform as transform to p

* Lint

* Update test and snapshot.

---------

Co-authored-by: Juan Aldasoro <[email protected]>
  • Loading branch information
richtabor and juanfra authored Jul 10, 2023
1 parent 55970a1 commit 5c3c9fd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ exports[`Quote block transforms to Group block 1`] = `
<!-- /wp:group -->"
`;

exports[`Quote block transforms to Paragraph block 1`] = `
"<!-- wp:paragraph -->
<p>"This will make running your own blog a viable alternative again."</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>— <a href="https://twitter.com/azumbrunnen_/status/1019347243084800005">Adrian Zumbrunnen</a></p>
<!-- /wp:paragraph -->"
`;

exports[`Quote block transforms to Pullquote block 1`] = `
"<!-- wp:pullquote -->
<figure class="wp-block-pullquote"><blockquote><p>"This will make running your own blog a viable alternative again."</p><cite>— <a href="https://twitter.com/azumbrunnen_/status/1019347243084800005">Adrian Zumbrunnen</a></cite></blockquote></figure>
Expand Down
6 changes: 5 additions & 1 deletion packages/block-library/src/quote/test/transforms.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ const initialHtml = `
<!-- /wp:quote -->`;

const transformsWithInnerBlocks = [ 'Columns', 'Group' ];
const blockTransforms = [ 'Pullquote', ...transformsWithInnerBlocks ];
const blockTransforms = [
'Pullquote',
'Paragraph',
...transformsWithInnerBlocks,
];

setupCoreBlocks();

Expand Down
13 changes: 13 additions & 0 deletions packages/block-library/src/quote/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ const transforms = {
} );
},
},
{
type: 'block',
blocks: [ 'core/paragraph' ],
transform: ( { citation }, innerBlocks ) =>
citation
? [
...innerBlocks,
createBlock( 'core/paragraph', {
content: citation,
} ),
]
: innerBlocks,
},
{
type: 'block',
blocks: [ 'core/group' ],
Expand Down

0 comments on commit 5c3c9fd

Please sign in to comment.