Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quote block: Add transform to paragraph #51809

Merged
merged 3 commits into from
Jul 10, 2023
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
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